type.php 30 KB

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