type.php 28 KB

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