type.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812
  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. $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 = trim($statut);
  89. $object->subscription = (int) trim($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 = trim($statut);
  137. $object->subscription = (int) trim($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) ) print img_picto($langs->trans("InActivity"),'statut4');
  235. else print img_picto($langs->trans("ActivityCeased"),'statut5');
  236. print '</td>';
  237. if ($user->rights->adherent->configurer)
  238. print '<td class="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit&rowid='.$objp->rowid.'">'.img_edit().'</a></td>';
  239. else
  240. print '<td class="right">&nbsp;</td>';
  241. print "</tr>";
  242. $i++;
  243. }
  244. print "</table>";
  245. print '</div>';
  246. print '</form>';
  247. }
  248. else
  249. {
  250. dol_print_error($db);
  251. }
  252. }
  253. /* ************************************************************************** */
  254. /* */
  255. /* Creation mode */
  256. /* */
  257. /* ************************************************************************** */
  258. if ($action == 'create')
  259. {
  260. $object = new AdherentType($db);
  261. print load_fiche_titre($langs->trans("NewMemberType"));
  262. print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
  263. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  264. print '<input type="hidden" name="action" value="add">';
  265. dol_fiche_head('');
  266. print '<table class="border" width="100%">';
  267. print '<tbody>';
  268. print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" class="minwidth200" name="label" autofocus="autofocus"></td></tr>';
  269. print '<tr><td>'.$langs->trans("Status").'</td><td>';
  270. print $form->selectarray('statut', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),1);
  271. print '</td></tr>';
  272. print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
  273. print $form->selectyesno("subscription",1,1);
  274. print '</td></tr>';
  275. print '<tr><td>'.$langs->trans("VoteAllowed").'</td><td>';
  276. print $form->selectyesno("vote",0,1);
  277. print '</td></tr>';
  278. print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
  279. print '<textarea name="comment" wrap="soft" class="centpercent" rows="3"></textarea></td></tr>';
  280. print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
  281. require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  282. $doleditor=new DolEditor('mail_valid',$object->mail_valid,'',280,'dolibarr_notes','',false,true,$conf->fckeditor->enabled,15,'90%');
  283. $doleditor->Create();
  284. print '</td></tr>';
  285. // Other attributes
  286. $parameters=array();
  287. $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook
  288. print $hookmanager->resPrint;
  289. if (empty($reshook))
  290. {
  291. print $object->showOptionals($extrafields,'edit');
  292. }
  293. print '<tbody>';
  294. print "</table>\n";
  295. dol_fiche_end();
  296. print '<div class="center">';
  297. print '<input type="submit" name="button" class="button" value="'.$langs->trans("Add").'">';
  298. print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
  299. print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'" onclick="history.go(-1)" />';
  300. print '</div>';
  301. print "</form>\n";
  302. }
  303. /* ************************************************************************** */
  304. /* */
  305. /* View mode */
  306. /* */
  307. /* ************************************************************************** */
  308. if ($rowid > 0)
  309. {
  310. if ($action != 'edit')
  311. {
  312. $object = new AdherentType($db);
  313. $object->fetch($rowid);
  314. $object->fetch_optionals();
  315. /*
  316. * Confirmation suppression
  317. */
  318. if ($action == 'delete')
  319. {
  320. print $form->formconfirm($_SERVER['PHP_SELF']."?rowid=".$object->id,$langs->trans("DeleteAMemberType"),$langs->trans("ConfirmDeleteMemberType",$object->label),"confirm_delete", '',0,1);
  321. }
  322. $head = member_type_prepare_head($object);
  323. dol_fiche_head($head, 'card', $langs->trans("MemberType"), -1, 'group');
  324. $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/type.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  325. dol_banner_tab($object, 'rowid', $linkback);
  326. print '<div class="fichecenter">';
  327. print '<div class="underbanner clearboth"></div>';
  328. print '<table class="border" width="100%">';
  329. print '<tr><td class="titlefield">'.$langs->trans("Status").'</td><td>';
  330. if ( !empty($object->statut) ) print img_picto($langs->trans('TypeStatusActive'),'statut4').' '.$langs->trans("InActivity");
  331. else print img_picto($langs->trans('TypeStatusInactive'),'statut5').' '.$langs->trans("ActivityCeased");
  332. print '</tr>';
  333. print '<tr><td class="titlefield">'.$langs->trans("SubscriptionRequired").'</td><td>';
  334. print yn($object->subscription);
  335. print '</tr>';
  336. print '<tr><td>'.$langs->trans("VoteAllowed").'</td><td>';
  337. print yn($object->vote);
  338. print '</tr>';
  339. print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
  340. print nl2br($object->note)."</td></tr>";
  341. print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
  342. print nl2br($object->mail_valid)."</td></tr>";
  343. // Other attributes
  344. include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
  345. print '</table>';
  346. print '</div>';
  347. dol_fiche_end();
  348. /*
  349. * Buttons
  350. */
  351. print '<div class="tabsAction">';
  352. // Edit
  353. if ($user->rights->adherent->configurer)
  354. {
  355. print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&amp;rowid='.$object->id.'">'.$langs->trans("Modify").'</a></div>';
  356. }
  357. // Add
  358. 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>';
  359. // Delete
  360. if ($user->rights->adherent->configurer)
  361. {
  362. print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&rowid='.$object->id.'">'.$langs->trans("DeleteType").'</a></div>';
  363. }
  364. print "</div>";
  365. // Show list of members (nearly same code than in page list.php)
  366. $membertypestatic=new AdherentType($db);
  367. $now=dol_now();
  368. $sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe, ";
  369. $sql.= " d.datefin,";
  370. $sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,";
  371. $sql.= " t.libelle as type, t.subscription";
  372. $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
  373. $sql.= " WHERE d.fk_adherent_type = t.rowid ";
  374. $sql.= " AND d.entity IN (".getEntity('adherent').")";
  375. $sql.= " AND t.rowid = ".$object->id;
  376. if ($sall)
  377. {
  378. $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);
  379. }
  380. if ($status != '')
  381. {
  382. $sql.= natural_search('d.statut', $status, 2);
  383. }
  384. if ($action == 'search')
  385. {
  386. if (GETPOST('search','alpha'))
  387. {
  388. $sql.= natural_search(array("d.firstname","d.lastname"), GETPOST('search','alpha'));
  389. }
  390. }
  391. if (! empty($search_lastname))
  392. {
  393. $sql.= natural_search(array("d.firstname","d.lastname"), $search_lastname);
  394. }
  395. if (! empty($search_login))
  396. {
  397. $sql.= natural_search("d.login", $search_login);
  398. }
  399. if (! empty($search_email))
  400. {
  401. $sql.= natural_search("d.email", $search_email);
  402. }
  403. if ($filter == 'uptodate')
  404. {
  405. $sql.=" AND datefin >= '".$db->idate($now)."'";
  406. }
  407. if ($filter == 'outofdate')
  408. {
  409. $sql.=" AND datefin < '".$db->idate($now)."'";
  410. }
  411. $sql.= " ".$db->order($sortfield,$sortorder);
  412. // Count total nb of records
  413. $nbtotalofrecords = '';
  414. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
  415. {
  416. $resql = $db->query($sql);
  417. if ($resql) $nbtotalofrecords = $db->num_rows($result);
  418. else dol_print_error($db);
  419. if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
  420. {
  421. $page = 0;
  422. $offset = 0;
  423. }
  424. }
  425. $sql.= " ".$db->plimit($conf->liste_limit+1, $offset);
  426. $resql = $db->query($sql);
  427. if ($resql)
  428. {
  429. $num = $db->num_rows($resql);
  430. $i = 0;
  431. $titre=$langs->trans("MembersList");
  432. if ($status != '')
  433. {
  434. if ($status == '-1,1') { $titre=$langs->trans("MembersListQualified"); }
  435. else if ($status == '-1') { $titre=$langs->trans("MembersListToValid"); }
  436. else if ($status == '1' && ! $filter) { $titre=$langs->trans("MembersListValid"); }
  437. else if ($status == '1' && $filter=='uptodate') { $titre=$langs->trans("MembersListUpToDate"); }
  438. else if ($status == '1' && $filter=='outofdate') { $titre=$langs->trans("MembersListNotUpToDate"); }
  439. else if ($status == '0') { $titre=$langs->trans("MembersListResiliated"); }
  440. }
  441. elseif ($action == 'search')
  442. {
  443. $titre=$langs->trans("MembersListQualified");
  444. }
  445. if ($type > 0)
  446. {
  447. $membertype=new AdherentType($db);
  448. $result=$membertype->fetch($type);
  449. $titre.=" (".$membertype->label.")";
  450. }
  451. $param="&rowid=".$object->id;
  452. if (! empty($status)) $param.="&status=".$status;
  453. if (! empty($search_lastname)) $param.="&search_lastname=".$search_lastname;
  454. if (! empty($search_firstname)) $param.="&search_firstname=".$search_firstname;
  455. if (! empty($search_login)) $param.="&search_login=".$search_login;
  456. if (! empty($search_email)) $param.="&search_email=".$search_email;
  457. if (! empty($filter)) $param.="&filter=".$filter;
  458. if ($sall)
  459. {
  460. print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall;
  461. }
  462. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  463. print '<input class="flat" type="hidden" name="rowid" value="'.$object->id.'" size="12"></td>';
  464. print '<br>';
  465. print_barre_liste('',$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords);
  466. $moreforfilter = '';
  467. print '<div class="div-table-responsive">';
  468. print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
  469. // Lignes des champs de filtre
  470. print '<tr class="liste_titre_filter">';
  471. print '<td class="liste_titre" align="left">';
  472. print '<input class="flat" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).'" size="12"></td>';
  473. print '<td class="liste_titre" align="left">';
  474. print '<input class="flat" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'" size="7"></td>';
  475. print '<td class="liste_titre">&nbsp;</td>';
  476. print '<td class="liste_titre" align="left">';
  477. print '<input class="flat" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).'" size="12"></td>';
  478. print '<td class="liste_titre">&nbsp;</td>';
  479. print '<td align="right" colspan="2" class="liste_titre">';
  480. 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")).'">';
  481. print '&nbsp; ';
  482. 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")).'">';
  483. print '</td>';
  484. print "</tr>\n";
  485. print '<tr class="liste_titre">';
  486. print_liste_field_titre( $langs->trans("Name")." / ".$langs->trans("Company"),$_SERVER["PHP_SELF"],"d.lastname",$param,"","",$sortfield,$sortorder);
  487. print_liste_field_titre("Login",$_SERVER["PHP_SELF"],"d.login",$param,"","",$sortfield,$sortorder);
  488. print_liste_field_titre("Nature",$_SERVER["PHP_SELF"],"d.morphy",$param,"","",$sortfield,$sortorder);
  489. print_liste_field_titre("EMail",$_SERVER["PHP_SELF"],"d.email",$param,"","",$sortfield,$sortorder);
  490. print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"d.statut,d.datefin",$param,"","",$sortfield,$sortorder);
  491. print_liste_field_titre("EndSubscription",$_SERVER["PHP_SELF"],"d.datefin",$param,"",'align="center"',$sortfield,$sortorder);
  492. print_liste_field_titre("Action",$_SERVER["PHP_SELF"],"",$param,"",'width="60" align="center"',$sortfield,$sortorder);
  493. print "</tr>\n";
  494. while ($i < $num && $i < $conf->liste_limit)
  495. {
  496. $objp = $db->fetch_object($resql);
  497. $datefin=$db->jdate($objp->datefin);
  498. $adh=new Adherent($db);
  499. $adh->lastname=$objp->lastname;
  500. $adh->firstname=$objp->firstname;
  501. // Lastname
  502. print '<tr class="oddeven">';
  503. if ($objp->societe != '')
  504. {
  505. 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";
  506. }
  507. else
  508. {
  509. print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"),"user").' '.$adh->getFullName($langs,0,-1,32).'</a></td>'."\n";
  510. }
  511. // Login
  512. print "<td>".$objp->login."</td>\n";
  513. // Type
  514. /*print '<td class="nowrap">';
  515. $membertypestatic->id=$objp->type_id;
  516. $membertypestatic->label=$objp->type;
  517. print $membertypestatic->getNomUrl(1,12);
  518. print '</td>';
  519. */
  520. // Moral/Physique
  521. print "<td>".$adh->getmorphylib($objp->morphy)."</td>\n";
  522. // EMail
  523. print "<td>".dol_print_email($objp->email,0,0,1)."</td>\n";
  524. // Statut
  525. print '<td class="nowrap">';
  526. print $adh->LibStatut($objp->statut,$objp->subscription,$datefin,2);
  527. print "</td>";
  528. // Date end subscription
  529. if ($datefin)
  530. {
  531. print '<td align="center" class="nowrap">';
  532. if ($datefin < dol_now() && $objp->statut > 0)
  533. {
  534. print dol_print_date($datefin,'day')." ".img_warning($langs->trans("SubscriptionLate"));
  535. }
  536. else
  537. {
  538. print dol_print_date($datefin,'day');
  539. }
  540. print '</td>';
  541. }
  542. else
  543. {
  544. print '<td align="left" class="nowrap">';
  545. if ($objp->subscription == 'yes')
  546. {
  547. print $langs->trans("SubscriptionNotReceived");
  548. if ($objp->statut > 0) print " ".img_warning();
  549. }
  550. else
  551. {
  552. print '&nbsp;';
  553. }
  554. print '</td>';
  555. }
  556. // Actions
  557. print '<td align="center">';
  558. if ($user->rights->adherent->creer)
  559. {
  560. print '<a href="card.php?rowid='.$objp->rowid.'&action=edit&backtopage='.urlencode($_SERVER["PHP_SELF"].'?rowid='.$object->id).'">'.img_edit().'</a>';
  561. }
  562. print '&nbsp;';
  563. if ($user->rights->adherent->supprimer)
  564. {
  565. print '<a href="card.php?rowid='.$objp->rowid.'&action=resign">'.img_picto($langs->trans("Resiliate"),'disable.png').'</a>';
  566. }
  567. print "</td>";
  568. print "</tr>\n";
  569. $i++;
  570. }
  571. print "</table>\n";
  572. print '</div>';
  573. print '</form>';
  574. if ($num > $conf->liste_limit)
  575. {
  576. print_barre_liste('',$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'');
  577. }
  578. }
  579. else
  580. {
  581. dol_print_error($db);
  582. }
  583. }
  584. /* ************************************************************************** */
  585. /* */
  586. /* Edition mode */
  587. /* */
  588. /* ************************************************************************** */
  589. if ($action == 'edit')
  590. {
  591. $object = new AdherentType($db);
  592. $object->fetch($rowid);
  593. $object->fetch_optionals();
  594. $head = member_type_prepare_head($object);
  595. print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'">';
  596. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  597. print '<input type="hidden" name="rowid" value="'.$object->id.'">';
  598. print '<input type="hidden" name="action" value="update">';
  599. dol_fiche_head($head, 'card', $langs->trans("MemberType"), 0, 'group');
  600. print '<table class="border" width="100%">';
  601. print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>'.$object->id.'</td></tr>';
  602. 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>';
  603. print '<tr><td>'.$langs->trans("Status").'</td><td>';
  604. print $form->selectarray('statut', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')), $object->statut);
  605. print '</td></tr>';
  606. print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
  607. print $form->selectyesno("subscription",$object->subscription,1);
  608. print '</td></tr>';
  609. print '<tr><td>'.$langs->trans("VoteAllowed").'</td><td>';
  610. print $form->selectyesno("vote",$object->vote,1);
  611. print '</td></tr>';
  612. print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
  613. print '<textarea name="comment" wrap="soft" class="centpercent" rows="3">'.$object->note.'</textarea></td></tr>';
  614. print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
  615. require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  616. $doleditor=new DolEditor('mail_valid',$object->mail_valid,'',280,'dolibarr_notes','',false,true,$conf->fckeditor->enabled,15,'90%');
  617. $doleditor->Create();
  618. print "</td></tr>";
  619. // Other attributes
  620. $parameters=array();
  621. $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook
  622. print $hookmanager->resPrint;
  623. if (empty($reshook))
  624. {
  625. print $object->showOptionals($extrafields,'edit');
  626. }
  627. print '</table>';
  628. // Extra field
  629. if (empty($reshook))
  630. {
  631. print '<br><br><table class="border" width="100%">';
  632. foreach($extrafields->attribute_label as $key=>$label)
  633. {
  634. if (isset($_POST["options_" . $key])) {
  635. if (is_array($_POST["options_" . $key])) {
  636. // $_POST["options"] is an array but following code expects a comma separated string
  637. $value = implode(",", $_POST["options_" . $key]);
  638. } else {
  639. $value = $_POST["options_" . $key];
  640. }
  641. } else {
  642. $value = $adht->array_options["options_" . $key];
  643. }
  644. print '<tr><td width="30%">'.$label.'</td><td>';
  645. print $extrafields->showInputField($key,$value);
  646. print "</td></tr>\n";
  647. }
  648. print '</table><br><br>';
  649. }
  650. dol_fiche_end();
  651. print '<div class="center">';
  652. print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
  653. print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
  654. print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
  655. print '</div>';
  656. print "</form>";
  657. }
  658. }
  659. // End of page
  660. llxFooter();
  661. $db->close();