type.php 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791
  1. <?php
  2. /* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
  4. * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  5. * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@inodbox.com>
  6. * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
  7. * Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. */
  22. /**
  23. * \file htdocs/adherents/type.php
  24. * \ingroup member
  25. * \brief Member's type setup
  26. */
  27. require '../main.inc.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
  29. require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
  32. $langs->load("members");
  33. $rowid = GETPOST('rowid','int');
  34. $action = GETPOST('action','alpha');
  35. $cancel = GETPOST('cancel','alpha');
  36. $backtopage = GETPOST('backtopage','alpha');
  37. $search_lastname = GETPOST('search_lastname','alpha');
  38. $search_login = GETPOST('search_login','alpha');
  39. $search_email = GETPOST('search_email','alpha');
  40. $type = GETPOST('type','intcomma');
  41. $status = GETPOST('status','alpha');
  42. $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
  43. $sortfield = GETPOST("sortfield",'alpha');
  44. $sortorder = GETPOST("sortorder",'alpha');
  45. $page = GETPOST("page",'int');
  46. if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
  47. $offset = $limit * $page ;
  48. $pageprev = $page - 1;
  49. $pagenext = $page + 1;
  50. if (! $sortorder) { $sortorder="DESC"; }
  51. if (! $sortfield) { $sortfield="d.lastname"; }
  52. $label=GETPOST("label","alpha");
  53. $subscription=GETPOST("subscription","int");
  54. $vote=GETPOST("vote","int");
  55. $comment=GETPOST("comment",'alphanohtml');
  56. $mail_valid=GETPOST("mail_valid",'none');
  57. // Security check
  58. $result=restrictedArea($user,'adherent',$rowid,'adherent_type');
  59. $object = new AdherentType($db);
  60. $extrafields = new ExtraFields($db);
  61. // fetch optionals attributes and labels
  62. $extralabels=$extrafields->fetch_name_optionals_label('adherent_type');
  63. if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
  64. {
  65. $search_lastname="";
  66. $search_login="";
  67. $search_email="";
  68. $type="";
  69. $sall="";
  70. }
  71. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  72. $hookmanager->initHooks(array('membertypecard','globalcard'));
  73. /*
  74. * Actions
  75. */
  76. if ($cancel) {
  77. $action='';
  78. if (! empty($backtopage))
  79. {
  80. header("Location: ".$backtopage);
  81. exit;
  82. }
  83. }
  84. if ($action == 'add' && $user->rights->adherent->configurer)
  85. {
  86. $object->label = trim($label);
  87. $object->subscription = (int) trim($subscription);
  88. $object->note = trim($comment);
  89. $object->mail_valid = trim($mail_valid);
  90. $object->vote = (boolean) trim($vote);
  91. // Fill array 'array_options' with data from add form
  92. $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
  93. if ($ret < 0) $error++;
  94. if (empty($object->label)) {
  95. $error++;
  96. setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")), null, 'errors');
  97. }
  98. else {
  99. $sql = "SELECT libelle FROM ".MAIN_DB_PREFIX."adherent_type WHERE libelle='".$db->escape($object->label)."'";
  100. $result = $db->query($sql);
  101. if ($result) {
  102. $num = $db->num_rows($result);
  103. }
  104. if ($num) {
  105. $error++;
  106. $langs->load("errors");
  107. setEventMessages($langs->trans("ErrorLabelAlreadyExists",$login), null, 'errors');
  108. }
  109. }
  110. if (! $error)
  111. {
  112. $id=$object->create($user);
  113. if ($id > 0)
  114. {
  115. header("Location: ".$_SERVER["PHP_SELF"]);
  116. exit;
  117. }
  118. else
  119. {
  120. setEventMessages($object->error, $object->errors, 'errors');
  121. $action = 'create';
  122. }
  123. }
  124. else
  125. {
  126. $action = 'create';
  127. }
  128. }
  129. if ($action == 'update' && $user->rights->adherent->configurer)
  130. {
  131. $object->fetch($rowid);
  132. $object->oldcopy = clone $object;
  133. $object->label = trim($label);
  134. $object->subscription = (int) trim($subscription);
  135. $object->note = trim($comment);
  136. $object->mail_valid = trim($mail_valid);
  137. $object->vote = (boolean) trim($vote);
  138. // Fill array 'array_options' with data from add form
  139. $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
  140. if ($ret < 0) $error++;
  141. $ret=$object->update($user);
  142. if ($ret >= 0 && ! count($object->errors))
  143. {
  144. setEventMessages($langs->trans("MemberTypeModified"), null, 'mesgs');
  145. }
  146. else
  147. {
  148. setEventMessages($object->error, $object->errors, 'errors');
  149. }
  150. header("Location: ".$_SERVER["PHP_SELF"]."?rowid=".$object->id);
  151. exit;
  152. }
  153. if ($action == 'confirm_delete' && $user->rights->adherent->configurer)
  154. {
  155. $object->fetch($rowid);
  156. $res=$object->delete();
  157. if ($res > 0)
  158. {
  159. setEventMessages($langs->trans("MemberTypeDeleted"), null, 'mesgs');
  160. header("Location: ".$_SERVER["PHP_SELF"]);
  161. exit;
  162. }
  163. else
  164. {
  165. setEventMessages($langs->trans("MemberTypeCanNotBeDeleted"), null, 'errors');
  166. $action='';
  167. }
  168. }
  169. /*
  170. * View
  171. */
  172. $form=new Form($db);
  173. llxHeader('',$langs->trans("MembersTypeSetup"),'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');
  174. // List of members type
  175. if (! $rowid && $action != 'create' && $action != 'edit')
  176. {
  177. //dol_fiche_head('');
  178. $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.vote";
  179. $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
  180. $sql.= " WHERE d.entity IN (".getEntity('member_type').")";
  181. $result = $db->query($sql);
  182. if ($result)
  183. {
  184. $num = $db->num_rows($result);
  185. $nbtotalofrecords = $num;
  186. $i = 0;
  187. $param = '';
  188. $newcardbutton='';
  189. if ($user->rights->adherent->configurer)
  190. {
  191. $newcardbutton='<a class="butActionNew" href="'.DOL_URL_ROOT.'/adherents/type.php?action=create"><span class="valignmiddle">'.$langs->trans('NewMemberType').'</span>';
  192. $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
  193. $newcardbutton.= '</a>';
  194. }
  195. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  196. if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  197. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  198. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  199. print '<input type="hidden" name="action" value="list">';
  200. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  201. print '<input type="hidden" name="page" value="'.$page.'">';
  202. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  203. print_barre_liste($langs->trans("MembersTypes"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, $newcardbutton, '', $limit);
  204. $moreforfilter = '';
  205. print '<div class="div-table-responsive">';
  206. print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
  207. print '<tr class="liste_titre">';
  208. print '<th>'.$langs->trans("Ref").'</th>';
  209. print '<th>'.$langs->trans("Label").'</th>';
  210. print '<th align="center">'.$langs->trans("SubscriptionRequired").'</th>';
  211. print '<th align="center">'.$langs->trans("VoteAllowed").'</th>';
  212. print '<th>&nbsp;</th>';
  213. print "</tr>\n";
  214. $membertype = new AdherentType($db);
  215. while ($i < $num)
  216. {
  217. $objp = $db->fetch_object($result);
  218. $membertype->id = $objp->rowid;
  219. $membertype->ref = $objp->rowid;
  220. $membertype->label = $objp->rowid;
  221. print '<tr class="oddeven">';
  222. print '<td>';
  223. print $membertype->getNomUrl(1);
  224. //<a href="'.$_SERVER["PHP_SELF"].'?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.'</a>
  225. print '</td>';
  226. print '<td>'.dol_escape_htmltag($objp->label).'</td>';
  227. print '<td align="center">'.yn($objp->subscription).'</td>';
  228. print '<td align="center">'.yn($objp->vote).'</td>';
  229. if ($user->rights->adherent->configurer)
  230. print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit&rowid='.$objp->rowid.'">'.img_edit().'</a></td>';
  231. else
  232. print '<td align="right">&nbsp;</td>';
  233. print "</tr>";
  234. $i++;
  235. }
  236. print "</table>";
  237. print '</div>';
  238. print '</form>';
  239. }
  240. else
  241. {
  242. dol_print_error($db);
  243. }
  244. }
  245. /* ************************************************************************** */
  246. /* */
  247. /* Creation mode */
  248. /* */
  249. /* ************************************************************************** */
  250. if ($action == 'create')
  251. {
  252. $object = new AdherentType($db);
  253. print load_fiche_titre($langs->trans("NewMemberType"));
  254. print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
  255. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  256. print '<input type="hidden" name="action" value="add">';
  257. dol_fiche_head('');
  258. print '<table class="border" width="100%">';
  259. print '<tbody>';
  260. print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" class="minwidth200" name="label" autofocus="autofocus"></td></tr>';
  261. print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
  262. print $form->selectyesno("subscription",1,1);
  263. print '</td></tr>';
  264. print '<tr><td>'.$langs->trans("VoteAllowed").'</td><td>';
  265. print $form->selectyesno("vote",0,1);
  266. print '</td></tr>';
  267. print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
  268. print '<textarea name="comment" wrap="soft" class="centpercent" rows="3"></textarea></td></tr>';
  269. print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
  270. require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  271. $doleditor=new DolEditor('mail_valid',$object->mail_valid,'',280,'dolibarr_notes','',false,true,$conf->fckeditor->enabled,15,'90%');
  272. $doleditor->Create();
  273. print '</td></tr>';
  274. // Other attributes
  275. $parameters=array();
  276. $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook
  277. print $hookmanager->resPrint;
  278. if (empty($reshook))
  279. {
  280. print $object->showOptionals($extrafields,'edit');
  281. }
  282. print '<tbody>';
  283. print "</table>\n";
  284. dol_fiche_end();
  285. print '<div class="center">';
  286. print '<input type="submit" name="button" class="button" value="'.$langs->trans("Add").'">';
  287. print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
  288. print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'" onclick="history.go(-1)" />';
  289. print '</div>';
  290. print "</form>\n";
  291. }
  292. /* ************************************************************************** */
  293. /* */
  294. /* View mode */
  295. /* */
  296. /* ************************************************************************** */
  297. if ($rowid > 0)
  298. {
  299. if ($action != 'edit')
  300. {
  301. $object = new AdherentType($db);
  302. $object->fetch($rowid);
  303. $object->fetch_optionals();
  304. /*
  305. * Confirmation suppression
  306. */
  307. if ($action == 'delete')
  308. {
  309. print $form->formconfirm($_SERVER['PHP_SELF']."?rowid=".$object->id,$langs->trans("DeleteAMemberType"),$langs->trans("ConfirmDeleteMemberType",$object->label),"confirm_delete", '',0,1);
  310. }
  311. $head = member_type_prepare_head($object);
  312. dol_fiche_head($head, 'card', $langs->trans("MemberType"), -1, 'group');
  313. $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/type.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  314. dol_banner_tab($object, 'rowid', $linkback);
  315. print '<div class="fichecenter">';
  316. print '<div class="underbanner clearboth"></div>';
  317. print '<table class="border" width="100%">';
  318. print '<tr><td class="titlefield">'.$langs->trans("SubscriptionRequired").'</td><td>';
  319. print yn($object->subscription);
  320. print '</tr>';
  321. print '<tr><td>'.$langs->trans("VoteAllowed").'</td><td>';
  322. print yn($object->vote);
  323. print '</tr>';
  324. print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
  325. print nl2br($object->note)."</td></tr>";
  326. print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
  327. print nl2br($object->mail_valid)."</td></tr>";
  328. // Other attributes
  329. include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
  330. print '</table>';
  331. print '</div>';
  332. dol_fiche_end();
  333. /*
  334. * Buttons
  335. */
  336. print '<div class="tabsAction">';
  337. // Edit
  338. if ($user->rights->adherent->configurer)
  339. {
  340. print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&amp;rowid='.$object->id.'">'.$langs->trans("Modify").'</a></div>';
  341. }
  342. // Add
  343. print '<div class="inline-block divButAction"><a class="butAction" href="card.php?action=create&typeid='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?rowid='.$object->id).'">'.$langs->trans("AddMember").'</a></div>';
  344. // Delete
  345. if ($user->rights->adherent->configurer)
  346. {
  347. print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&rowid='.$object->id.'">'.$langs->trans("DeleteType").'</a></div>';
  348. }
  349. print "</div>";
  350. // Show list of members (nearly same code than in page list.php)
  351. $membertypestatic=new AdherentType($db);
  352. $now=dol_now();
  353. $sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe, ";
  354. $sql.= " d.datefin,";
  355. $sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,";
  356. $sql.= " t.libelle as type, t.subscription";
  357. $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
  358. $sql.= " WHERE d.fk_adherent_type = t.rowid ";
  359. $sql.= " AND d.entity IN (".getEntity('adherent').")";
  360. $sql.= " AND t.rowid = ".$object->id;
  361. if ($sall)
  362. {
  363. $sql.=natural_search(array("f.firstname","d.lastname","d.societe","d.email","d.login","d.address","d.town","d.note_public","d.note_private"), $sall);
  364. }
  365. if ($status != '')
  366. {
  367. $sql.= natural_search('d.statut', $status, 2);
  368. }
  369. if ($action == 'search')
  370. {
  371. if (GETPOST('search','alpha'))
  372. {
  373. $sql.= natural_search(array("d.firstname","d.lastname"), GETPOST('search','alpha'));
  374. }
  375. }
  376. if (! empty($search_lastname))
  377. {
  378. $sql.= natural_search(array("d.firstname","d.lastname"), $search_lastname);
  379. }
  380. if (! empty($search_login))
  381. {
  382. $sql.= natural_search("d.login", $search_login);
  383. }
  384. if (! empty($search_email))
  385. {
  386. $sql.= natural_search("d.email", $search_email);
  387. }
  388. if ($filter == 'uptodate')
  389. {
  390. $sql.=" AND datefin >= '".$db->idate($now)."'";
  391. }
  392. if ($filter == 'outofdate')
  393. {
  394. $sql.=" AND datefin < '".$db->idate($now)."'";
  395. }
  396. $sql.= " ".$db->order($sortfield,$sortorder);
  397. // Count total nb of records
  398. $nbtotalofrecords = '';
  399. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
  400. {
  401. $resql = $db->query($sql);
  402. if ($resql) $nbtotalofrecords = $db->num_rows($result);
  403. else dol_print_error($db);
  404. if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
  405. {
  406. $page = 0;
  407. $offset = 0;
  408. }
  409. }
  410. $sql.= " ".$db->plimit($conf->liste_limit+1, $offset);
  411. $resql = $db->query($sql);
  412. if ($resql)
  413. {
  414. $num = $db->num_rows($resql);
  415. $i = 0;
  416. $titre=$langs->trans("MembersList");
  417. if ($status != '')
  418. {
  419. if ($status == '-1,1') { $titre=$langs->trans("MembersListQualified"); }
  420. else if ($status == '-1') { $titre=$langs->trans("MembersListToValid"); }
  421. else if ($status == '1' && ! $filter) { $titre=$langs->trans("MembersListValid"); }
  422. else if ($status == '1' && $filter=='uptodate') { $titre=$langs->trans("MembersListUpToDate"); }
  423. else if ($status == '1' && $filter=='outofdate') { $titre=$langs->trans("MembersListNotUpToDate"); }
  424. else if ($status == '0') { $titre=$langs->trans("MembersListResiliated"); }
  425. }
  426. elseif ($action == 'search')
  427. {
  428. $titre=$langs->trans("MembersListQualified");
  429. }
  430. if ($type > 0)
  431. {
  432. $membertype=new AdherentType($db);
  433. $result=$membertype->fetch($type);
  434. $titre.=" (".$membertype->label.")";
  435. }
  436. $param="&rowid=".$object->id;
  437. if (! empty($status)) $param.="&status=".$status;
  438. if (! empty($search_lastname)) $param.="&search_lastname=".$search_lastname;
  439. if (! empty($search_firstname)) $param.="&search_firstname=".$search_firstname;
  440. if (! empty($search_login)) $param.="&search_login=".$search_login;
  441. if (! empty($search_email)) $param.="&search_email=".$search_email;
  442. if (! empty($filter)) $param.="&filter=".$filter;
  443. if ($sall)
  444. {
  445. print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall;
  446. }
  447. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  448. print '<input class="flat" type="hidden" name="rowid" value="'.$object->id.'" size="12"></td>';
  449. print '<br>';
  450. print_barre_liste('',$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords);
  451. $moreforfilter = '';
  452. print '<div class="div-table-responsive">';
  453. print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
  454. // Lignes des champs de filtre
  455. print '<tr class="liste_titre_filter">';
  456. print '<td class="liste_titre" align="left">';
  457. print '<input class="flat" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).'" size="12"></td>';
  458. print '<td class="liste_titre" align="left">';
  459. print '<input class="flat" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'" size="7"></td>';
  460. print '<td class="liste_titre">&nbsp;</td>';
  461. print '<td class="liste_titre" align="left">';
  462. print '<input class="flat" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).'" size="12"></td>';
  463. print '<td class="liste_titre">&nbsp;</td>';
  464. print '<td align="right" colspan="2" class="liste_titre">';
  465. print '<input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" name="button_search" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
  466. print '&nbsp; ';
  467. print '<input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/searchclear.png" name="button_removefilter" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
  468. print '</td>';
  469. print "</tr>\n";
  470. print '<tr class="liste_titre">';
  471. print_liste_field_titre( $langs->trans("Name")." / ".$langs->trans("Company"),$_SERVER["PHP_SELF"],"d.lastname",$param,"","",$sortfield,$sortorder);
  472. print_liste_field_titre("Login",$_SERVER["PHP_SELF"],"d.login",$param,"","",$sortfield,$sortorder);
  473. print_liste_field_titre("Nature",$_SERVER["PHP_SELF"],"d.morphy",$param,"","",$sortfield,$sortorder);
  474. print_liste_field_titre("EMail",$_SERVER["PHP_SELF"],"d.email",$param,"","",$sortfield,$sortorder);
  475. print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"d.statut,d.datefin",$param,"","",$sortfield,$sortorder);
  476. print_liste_field_titre("EndSubscription",$_SERVER["PHP_SELF"],"d.datefin",$param,"",'align="center"',$sortfield,$sortorder);
  477. print_liste_field_titre("Action",$_SERVER["PHP_SELF"],"",$param,"",'width="60" align="center"',$sortfield,$sortorder);
  478. print "</tr>\n";
  479. while ($i < $num && $i < $conf->liste_limit)
  480. {
  481. $objp = $db->fetch_object($resql);
  482. $datefin=$db->jdate($objp->datefin);
  483. $adh=new Adherent($db);
  484. $adh->lastname=$objp->lastname;
  485. $adh->firstname=$objp->firstname;
  486. // Lastname
  487. print '<tr class="oddeven">';
  488. if ($objp->societe != '')
  489. {
  490. print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"),"user").' '.$adh->getFullName($langs,0,-1,20).' / '.dol_trunc($objp->societe,12).'</a></td>'."\n";
  491. }
  492. else
  493. {
  494. print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"),"user").' '.$adh->getFullName($langs,0,-1,32).'</a></td>'."\n";
  495. }
  496. // Login
  497. print "<td>".$objp->login."</td>\n";
  498. // Type
  499. /*print '<td class="nowrap">';
  500. $membertypestatic->id=$objp->type_id;
  501. $membertypestatic->label=$objp->type;
  502. print $membertypestatic->getNomUrl(1,12);
  503. print '</td>';
  504. */
  505. // Moral/Physique
  506. print "<td>".$adh->getmorphylib($objp->morphy)."</td>\n";
  507. // EMail
  508. print "<td>".dol_print_email($objp->email,0,0,1)."</td>\n";
  509. // Statut
  510. print '<td class="nowrap">';
  511. print $adh->LibStatut($objp->statut,$objp->subscription,$datefin,2);
  512. print "</td>";
  513. // Date end subscription
  514. if ($datefin)
  515. {
  516. print '<td align="center" class="nowrap">';
  517. if ($datefin < dol_now() && $objp->statut > 0)
  518. {
  519. print dol_print_date($datefin,'day')." ".img_warning($langs->trans("SubscriptionLate"));
  520. }
  521. else
  522. {
  523. print dol_print_date($datefin,'day');
  524. }
  525. print '</td>';
  526. }
  527. else
  528. {
  529. print '<td align="left" class="nowrap">';
  530. if ($objp->subscription == 'yes')
  531. {
  532. print $langs->trans("SubscriptionNotReceived");
  533. if ($objp->statut > 0) print " ".img_warning();
  534. }
  535. else
  536. {
  537. print '&nbsp;';
  538. }
  539. print '</td>';
  540. }
  541. // Actions
  542. print '<td align="center">';
  543. if ($user->rights->adherent->creer)
  544. {
  545. print '<a href="card.php?rowid='.$objp->rowid.'&action=edit&backtopage='.urlencode($_SERVER["PHP_SELF"].'?rowid='.$object->id).'">'.img_edit().'</a>';
  546. }
  547. print '&nbsp;';
  548. if ($user->rights->adherent->supprimer)
  549. {
  550. print '<a href="card.php?rowid='.$objp->rowid.'&action=resign">'.img_picto($langs->trans("Resiliate"),'disable.png').'</a>';
  551. }
  552. print "</td>";
  553. print "</tr>\n";
  554. $i++;
  555. }
  556. print "</table>\n";
  557. print '</div>';
  558. print '</form>';
  559. if ($num > $conf->liste_limit)
  560. {
  561. print_barre_liste('',$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'');
  562. }
  563. }
  564. else
  565. {
  566. dol_print_error($db);
  567. }
  568. }
  569. /* ************************************************************************** */
  570. /* */
  571. /* Edition mode */
  572. /* */
  573. /* ************************************************************************** */
  574. if ($action == 'edit')
  575. {
  576. $object = new AdherentType($db);
  577. $object->fetch($rowid);
  578. $object->fetch_optionals();
  579. $head = member_type_prepare_head($object);
  580. print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'">';
  581. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  582. print '<input type="hidden" name="rowid" value="'.$object->id.'">';
  583. print '<input type="hidden" name="action" value="update">';
  584. dol_fiche_head($head, 'card', $langs->trans("MemberType"), 0, 'group');
  585. print '<table class="border" width="100%">';
  586. print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>'.$object->id.'</td></tr>';
  587. print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" name="label" size="40" value="'.dol_escape_htmltag($object->label).'"></td></tr>';
  588. print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
  589. print $form->selectyesno("subscription",$object->subscription,1);
  590. print '</td></tr>';
  591. print '<tr><td>'.$langs->trans("VoteAllowed").'</td><td>';
  592. print $form->selectyesno("vote",$object->vote,1);
  593. print '</td></tr>';
  594. print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
  595. print '<textarea name="comment" wrap="soft" class="centpercent" rows="3">'.$object->note.'</textarea></td></tr>';
  596. print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
  597. require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  598. $doleditor=new DolEditor('mail_valid',$object->mail_valid,'',280,'dolibarr_notes','',false,true,$conf->fckeditor->enabled,15,'90%');
  599. $doleditor->Create();
  600. print "</td></tr>";
  601. // Other attributes
  602. $parameters=array();
  603. $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook
  604. print $hookmanager->resPrint;
  605. if (empty($reshook))
  606. {
  607. print $object->showOptionals($extrafields,'edit');
  608. }
  609. print '</table>';
  610. // Extra field
  611. if (empty($reshook))
  612. {
  613. print '<br><br><table class="border" width="100%">';
  614. foreach($extrafields->attribute_label as $key=>$label)
  615. {
  616. if (isset($_POST["options_" . $key])) {
  617. if (is_array($_POST["options_" . $key])) {
  618. // $_POST["options"] is an array but following code expects a comma separated string
  619. $value = implode(",", $_POST["options_" . $key]);
  620. } else {
  621. $value = $_POST["options_" . $key];
  622. }
  623. } else {
  624. $value = $adht->array_options["options_" . $key];
  625. }
  626. print '<tr><td width="30%">'.$label.'</td><td>';
  627. print $extrafields->showInputField($key,$value);
  628. print "</td></tr>\n";
  629. }
  630. print '</table><br><br>';
  631. }
  632. dol_fiche_end();
  633. print '<div class="center">';
  634. print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
  635. print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
  636. print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
  637. print '</div>';
  638. print "</form>";
  639. }
  640. }
  641. // End of page
  642. llxFooter();
  643. $db->close();