type.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716
  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@capnetworks.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. $search_lastname = GETPOST('search_lastname','alpha');
  37. $search_login = GETPOST('search_login','alpha');
  38. $search_email = GETPOST('search_email','alpha');
  39. $type = GETPOST('type','alpha');
  40. $status = GETPOST('status','alpha');
  41. $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
  42. $sortfield = GETPOST("sortfield",'alpha');
  43. $sortorder = GETPOST("sortorder",'alpha');
  44. $page = GETPOST("page",'int');
  45. if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
  46. $offset = $limit * $page ;
  47. $pageprev = $page - 1;
  48. $pagenext = $page + 1;
  49. if (! $sortorder) { $sortorder="DESC"; }
  50. if (! $sortfield) { $sortfield="d.lastname"; }
  51. $label=GETPOST("label","alpha");
  52. $subscription=GETPOST("subscription","int");
  53. $vote=GETPOST("vote","int");
  54. $comment=GETPOST("comment");
  55. $mail_valid=GETPOST("mail_valid");
  56. // Security check
  57. $result=restrictedArea($user,'adherent',$rowid,'adherent_type');
  58. $extrafields = new ExtraFields($db);
  59. // fetch optionals attributes and labels
  60. $extralabels=$extrafields->fetch_name_optionals_label('adherent_type');
  61. if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers
  62. {
  63. $search_lastname="";
  64. $search_login="";
  65. $search_email="";
  66. $type="";
  67. $sall="";
  68. }
  69. // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
  70. $hookmanager->initHooks(array('membertypecard','globalcard'));
  71. /*
  72. * Actions
  73. */
  74. if ($action == 'add' && $user->rights->adherent->configurer)
  75. {
  76. if (! $cancel)
  77. {
  78. $object = new AdherentType($db);
  79. $object->label = trim($label);
  80. $object->subscription = (int) trim($subscription);
  81. $object->note = trim($comment);
  82. $object->mail_valid = (boolean) trim($mail_valid);
  83. $object->vote = (boolean) trim($vote);
  84. // Fill array 'array_options' with data from add form
  85. $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
  86. if ($ret < 0) $error++;
  87. if ($object->label)
  88. {
  89. $id=$object->create($user);
  90. if ($id > 0)
  91. {
  92. header("Location: ".$_SERVER["PHP_SELF"]);
  93. exit;
  94. }
  95. else
  96. {
  97. $mesg=$object->error;
  98. $action = 'create';
  99. }
  100. }
  101. else
  102. {
  103. $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label"));
  104. $action = 'create';
  105. }
  106. }
  107. }
  108. if ($action == 'update' && $user->rights->adherent->configurer)
  109. {
  110. if (! $cancel)
  111. {
  112. $object = new AdherentType($db);
  113. $object->id = $rowid;
  114. $object->label = trim($label);
  115. $object->subscription = (int) trim($subscription);
  116. $object->note = trim($comment);
  117. $object->mail_valid = (boolean) trim($mail_valid);
  118. $object->vote = (boolean) trim($vote);
  119. // Fill array 'array_options' with data from add form
  120. $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
  121. if ($ret < 0) $error++;
  122. $object->update($user);
  123. header("Location: ".$_SERVER["PHP_SELF"]."?rowid=".$_POST["rowid"]);
  124. exit;
  125. }
  126. }
  127. if ($action == 'delete' && $user->rights->adherent->configurer)
  128. {
  129. $object = new AdherentType($db);
  130. $object->delete($rowid);
  131. header("Location: ".$_SERVER["PHP_SELF"]);
  132. exit;
  133. }
  134. /*
  135. * View
  136. */
  137. llxHeader('',$langs->trans("MembersTypeSetup"),'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');
  138. $form=new Form($db);
  139. // List of members type
  140. if (! $rowid && $action != 'create' && $action != 'edit')
  141. {
  142. //dol_fiche_head('');
  143. $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.vote";
  144. $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
  145. $sql.= " WHERE d.entity IN (".getEntity().")";
  146. $result = $db->query($sql);
  147. if ($result)
  148. {
  149. $num = $db->num_rows($result);
  150. $nbtotalofrecords = $num;
  151. $i = 0;
  152. $param = '';
  153. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  154. if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  155. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  156. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  157. print '<input type="hidden" name="action" value="list">';
  158. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  159. print '<input type="hidden" name="page" value="'.$page.'">';
  160. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  161. print_barre_liste($langs->trans("MembersTypes"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit);
  162. $moreforfilter = '';
  163. print '<div class="div-table-responsive">';
  164. print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
  165. print '<tr class="liste_titre">';
  166. print '<th>'.$langs->trans("Ref").'</th>';
  167. print '<th>'.$langs->trans("Label").'</th>';
  168. print '<th align="center">'.$langs->trans("SubscriptionRequired").'</th>';
  169. print '<th align="center">'.$langs->trans("VoteAllowed").'</th>';
  170. print '<th>&nbsp;</th>';
  171. print "</tr>\n";
  172. while ($i < $num)
  173. {
  174. $objp = $db->fetch_object($result);
  175. print '<tr class="oddeven">';
  176. print '<td><a href="'.$_SERVER["PHP_SELF"].'?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.'</a></td>';
  177. print '<td>'.dol_escape_htmltag($objp->label).'</td>';
  178. print '<td align="center">'.yn($objp->subscription).'</td>';
  179. print '<td align="center">'.yn($objp->vote).'</td>';
  180. if ($user->rights->adherent->configurer)
  181. print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit&rowid='.$objp->rowid.'">'.img_edit().'</a></td>';
  182. else
  183. print '<td align="right">&nbsp;</td>';
  184. print "</tr>";
  185. $i++;
  186. }
  187. print "</table>";
  188. print '</div>';
  189. print '</form>';
  190. }
  191. else
  192. {
  193. dol_print_error($db);
  194. }
  195. }
  196. /* ************************************************************************** */
  197. /* */
  198. /* Creation mode */
  199. /* */
  200. /* ************************************************************************** */
  201. if ($action == 'create')
  202. {
  203. $object = new AdherentType($db);
  204. print load_fiche_titre($langs->trans("NewMemberType"));
  205. print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
  206. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  207. print '<input type="hidden" name="action" value="add">';
  208. dol_fiche_head('');
  209. print '<table class="border" width="100%">';
  210. print '<tbody>';
  211. print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" name="label" size="40"></td></tr>';
  212. print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
  213. print $form->selectyesno("subscription",1,1);
  214. print '</td></tr>';
  215. print '<tr><td>'.$langs->trans("VoteAllowed").'</td><td>';
  216. print $form->selectyesno("vote",0,1);
  217. print '</td></tr>';
  218. print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
  219. print '<textarea name="comment" wrap="soft" class="centpercent" rows="3"></textarea></td></tr>';
  220. print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
  221. require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  222. $doleditor=new DolEditor('mail_valid',$object->mail_valid,'',280,'dolibarr_notes','',false,true,$conf->fckeditor->enabled,15,'90%');
  223. $doleditor->Create();
  224. print '</td></tr>';
  225. // Other attributes
  226. $parameters=array();
  227. $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook
  228. if (empty($reshook) && ! empty($extrafields->attribute_label))
  229. {
  230. print $object->showOptionals($extrafields,'edit');
  231. }
  232. print '<tbody>';
  233. print "</table>\n";
  234. dol_fiche_end();
  235. print '<div class="center">';
  236. print '<input type="submit" name="button" class="button" value="'.$langs->trans("Add").'">';
  237. print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
  238. print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'" onclick="history.go(-1)" />';
  239. print '</div>';
  240. print "</form>\n";
  241. }
  242. /* ************************************************************************** */
  243. /* */
  244. /* View mode */
  245. /* */
  246. /* ************************************************************************** */
  247. if ($rowid > 0)
  248. {
  249. if ($action != 'edit')
  250. {
  251. $object = new AdherentType($db);
  252. $object->fetch($rowid);
  253. $object->fetch_optionals($rowid,$extralabels);
  254. $head = member_type_prepare_head($object);
  255. dol_fiche_head($head, 'card', $langs->trans("MemberType"), -1, 'group');
  256. $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/type.php">'.$langs->trans("BackToList").'</a>';
  257. dol_banner_tab($object, 'rowid', $linkback);
  258. print '<div class="fichecenter">';
  259. print '<div class="underbanner clearboth"></div>';
  260. print '<table class="border" width="100%">';
  261. print '<tr><td class="titlefield">'.$langs->trans("SubscriptionRequired").'</td><td>';
  262. print yn($object->subscription);
  263. print '</tr>';
  264. print '<tr><td>'.$langs->trans("VoteAllowed").'</td><td>';
  265. print yn($object->vote);
  266. print '</tr>';
  267. print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
  268. print nl2br($object->note)."</td></tr>";
  269. print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
  270. print nl2br($object->mail_valid)."</td></tr>";
  271. // Other attributes
  272. include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
  273. print '</table>';
  274. print '</div>';
  275. dol_fiche_end();
  276. /*
  277. * Hotbar
  278. */
  279. print '<div class="tabsAction">';
  280. // Edit
  281. if ($user->rights->adherent->configurer)
  282. {
  283. print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&amp;rowid='.$object->id.'">'.$langs->trans("Modify").'</a></div>';
  284. }
  285. // Add
  286. print '<div class="inline-block divButAction"><a class="butAction" href="card.php?action=create&typeid='.$object->id.'">'.$langs->trans("AddMember").'</a></div>';
  287. // Delete
  288. if ($user->rights->adherent->configurer)
  289. {
  290. print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&rowid='.$object->id.'">'.$langs->trans("DeleteType").'</a></div>';
  291. }
  292. print "</div>";
  293. // Show list of members (nearly same code than in page list.php)
  294. $membertypestatic=new AdherentType($db);
  295. $now=dol_now();
  296. $sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe, ";
  297. $sql.= " d.datefin,";
  298. $sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,";
  299. $sql.= " t.libelle as type, t.subscription";
  300. $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
  301. $sql.= " WHERE d.fk_adherent_type = t.rowid ";
  302. $sql.= " AND d.entity IN (".getEntity().")";
  303. $sql.= " AND t.rowid = ".$object->id;
  304. if ($sall)
  305. {
  306. $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);
  307. }
  308. if ($status != '')
  309. {
  310. $sql.= " AND d.statut IN (".$status.")"; // Peut valoir un nombre ou liste de nombre separes par virgules
  311. }
  312. if ($action == 'search')
  313. {
  314. if (GETPOST('search'))
  315. {
  316. $sql.= natural_search(array("d.firstname","d.lastname"), GETPOST('search'));
  317. }
  318. }
  319. if (! empty($search_lastname))
  320. {
  321. $sql.= natural_search(array("d.firstname","d.lastname"), $search_lastname);
  322. }
  323. if (! empty($search_login))
  324. {
  325. $sql.= natural_search("d.login", $search_login);
  326. }
  327. if (! empty($search_email))
  328. {
  329. $sql.= natural_search("d.email", $search_email);
  330. }
  331. if ($filter == 'uptodate')
  332. {
  333. $sql.=" AND datefin >= '".$db->idate($now)."'";
  334. }
  335. if ($filter == 'outofdate')
  336. {
  337. $sql.=" AND datefin < '".$db->idate($now)."'";
  338. }
  339. // Count total nb of records
  340. $nbtotalofrecords = '';
  341. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
  342. {
  343. $resql = $db->query($sql);
  344. if ($resql) $nbtotalofrecords = $db->num_rows($result);
  345. else dol_print_error($db);
  346. }
  347. // Add order and limit
  348. $sql.= " ".$db->order($sortfield,$sortorder);
  349. $sql.= " ".$db->plimit($conf->liste_limit+1, $offset);
  350. $resql = $db->query($sql);
  351. if ($resql)
  352. {
  353. $num = $db->num_rows($resql);
  354. $i = 0;
  355. $titre=$langs->trans("MembersList");
  356. if ($status != '')
  357. {
  358. if ($status == '-1,1') { $titre=$langs->trans("MembersListQualified"); }
  359. else if ($status == '-1') { $titre=$langs->trans("MembersListToValid"); }
  360. else if ($status == '1' && ! $filter) { $titre=$langs->trans("MembersListValid"); }
  361. else if ($status == '1' && $filter=='uptodate') { $titre=$langs->trans("MembersListUpToDate"); }
  362. else if ($status == '1' && $filter=='outofdate') { $titre=$langs->trans("MembersListNotUpToDate"); }
  363. else if ($status == '0') { $titre=$langs->trans("MembersListResiliated"); }
  364. }
  365. elseif ($action == 'search')
  366. {
  367. $titre=$langs->trans("MembersListQualified");
  368. }
  369. if ($type > 0)
  370. {
  371. $membertype=new AdherentType($db);
  372. $result=$membertype->fetch($type);
  373. $titre.=" (".$membertype->label.")";
  374. }
  375. $param="&rowid=".$rowid;
  376. if (! empty($status)) $param.="&status=".$status;
  377. if (! empty($search_lastname)) $param.="&search_lastname=".$search_lastname;
  378. if (! empty($search_firstname)) $param.="&search_firstname=".$search_firstname;
  379. if (! empty($search_login)) $param.="&search_login=".$search_login;
  380. if (! empty($search_email)) $param.="&search_email=".$search_email;
  381. if (! empty($filter)) $param.="&filter=".$filter;
  382. if ($sall)
  383. {
  384. print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall;
  385. }
  386. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  387. print '<input class="flat" type="hidden" name="rowid" value="'.$rowid.'" size="12"></td>';
  388. print '<br>';
  389. print_barre_liste('',$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords);
  390. $moreforfilter = '';
  391. print '<div class="div-table-responsive">';
  392. print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
  393. print '<tr class="liste_titre">';
  394. print_liste_field_titre($langs->trans("Name")." / ".$langs->trans("Company"),$_SERVER["PHP_SELF"],"d.lastname",$param,"","",$sortfield,$sortorder);
  395. print_liste_field_titre($langs->trans("Login"),$_SERVER["PHP_SELF"],"d.login",$param,"","",$sortfield,$sortorder);
  396. print_liste_field_titre($langs->trans("Nature"),$_SERVER["PHP_SELF"],"d.morphy",$param,"","",$sortfield,$sortorder);
  397. print_liste_field_titre($langs->trans("EMail"),$_SERVER["PHP_SELF"],"d.email",$param,"","",$sortfield,$sortorder);
  398. print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"d.statut,d.datefin",$param,"","",$sortfield,$sortorder);
  399. print_liste_field_titre($langs->trans("EndSubscription"),$_SERVER["PHP_SELF"],"d.datefin",$param,"",'align="center"',$sortfield,$sortorder);
  400. print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"",$param,"",'width="60" align="center"',$sortfield,$sortorder);
  401. print "</tr>\n";
  402. // Lignes des champs de filtre
  403. print '<tr class="liste_titre">';
  404. print '<td class="liste_titre" align="left">';
  405. print '<input class="flat" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).'" size="12"></td>';
  406. print '<td class="liste_titre" align="left">';
  407. print '<input class="flat" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'" size="7"></td>';
  408. print '<td class="liste_titre">&nbsp;</td>';
  409. print '<td class="liste_titre" align="left">';
  410. print '<input class="flat" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).'" size="12"></td>';
  411. print '<td class="liste_titre">&nbsp;</td>';
  412. print '<td align="right" colspan="2" class="liste_titre">';
  413. 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")).'">';
  414. print '&nbsp; ';
  415. 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")).'">';
  416. print '</td>';
  417. print "</tr>\n";
  418. while ($i < $num && $i < $conf->liste_limit)
  419. {
  420. $objp = $db->fetch_object($resql);
  421. $datefin=$db->jdate($objp->datefin);
  422. $adh=new Adherent($db);
  423. $adh->lastname=$objp->lastname;
  424. $adh->firstname=$objp->firstname;
  425. // Lastname
  426. print '<tr class="oddeven">';
  427. if ($objp->societe != '')
  428. {
  429. 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";
  430. }
  431. else
  432. {
  433. print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"),"user").' '.$adh->getFullName($langs,0,-1,32).'</a></td>'."\n";
  434. }
  435. // Login
  436. print "<td>".$objp->login."</td>\n";
  437. // Type
  438. /*print '<td class="nowrap">';
  439. $membertypestatic->id=$objp->type_id;
  440. $membertypestatic->label=$objp->type;
  441. print $membertypestatic->getNomUrl(1,12);
  442. print '</td>';
  443. */
  444. // Moral/Physique
  445. print "<td>".$adh->getmorphylib($objp->morphy)."</td>\n";
  446. // EMail
  447. print "<td>".dol_print_email($objp->email,0,0,1)."</td>\n";
  448. // Statut
  449. print '<td class="nowrap">';
  450. print $adh->LibStatut($objp->statut,$objp->subscription,$datefin,2);
  451. print "</td>";
  452. // Date end subscription
  453. if ($datefin)
  454. {
  455. print '<td align="center" class="nowrap">';
  456. if ($datefin < dol_now() && $objp->statut > 0)
  457. {
  458. print dol_print_date($datefin,'day')." ".img_warning($langs->trans("SubscriptionLate"));
  459. }
  460. else
  461. {
  462. print dol_print_date($datefin,'day');
  463. }
  464. print '</td>';
  465. }
  466. else
  467. {
  468. print '<td align="left" class="nowrap">';
  469. if ($objp->subscription == 'yes')
  470. {
  471. print $langs->trans("SubscriptionNotReceived");
  472. if ($objp->statut > 0) print " ".img_warning();
  473. }
  474. else
  475. {
  476. print '&nbsp;';
  477. }
  478. print '</td>';
  479. }
  480. // Actions
  481. print '<td align="center">';
  482. if ($user->rights->adherent->creer)
  483. {
  484. print '<a href="card.php?rowid='.$objp->rowid.'&action=edit&return=list.php">'.img_edit().'</a>';
  485. }
  486. print '&nbsp;';
  487. if ($user->rights->adherent->supprimer)
  488. {
  489. print '<a href="card.php?rowid='.$objp->rowid.'&action=resign&return=list.php">'.img_picto($langs->trans("Resiliate"),'disable.png').'</a>';
  490. }
  491. print "</td>";
  492. print "</tr>\n";
  493. $i++;
  494. }
  495. print "</table>\n";
  496. print '</div>';
  497. print '</form>';
  498. if ($num > $conf->liste_limit)
  499. {
  500. print_barre_liste('',$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'');
  501. }
  502. }
  503. else
  504. {
  505. dol_print_error($db);
  506. }
  507. }
  508. /* ************************************************************************** */
  509. /* */
  510. /* Edition mode */
  511. /* */
  512. /* ************************************************************************** */
  513. if ($action == 'edit')
  514. {
  515. $object = new AdherentType($db);
  516. $object->id = $rowid;
  517. $object->fetch($rowid);
  518. $object->fetch_optionals($rowid,$extralabels);
  519. $head = member_type_prepare_head($object);
  520. print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?rowid='.$rowid.'">';
  521. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  522. print '<input type="hidden" name="rowid" value="'.$rowid.'">';
  523. print '<input type="hidden" name="action" value="update">';
  524. dol_fiche_head($head, 'card', $langs->trans("MemberType"), 0, 'group');
  525. print '<table class="border" width="100%">';
  526. print '<tr><td width="15%">'.$langs->trans("Ref").'</td><td>'.$object->id.'</td></tr>';
  527. print '<tr><td>'.$langs->trans("Label").'</td><td><input type="text" name="label" size="40" value="'.dol_escape_htmltag($object->label).'"></td></tr>';
  528. print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
  529. print $form->selectyesno("subscription",$object->subscription,1);
  530. print '</td></tr>';
  531. print '<tr><td>'.$langs->trans("VoteAllowed").'</td><td>';
  532. print $form->selectyesno("vote",$object->vote,1);
  533. print '</td></tr>';
  534. print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
  535. print '<textarea name="comment" wrap="soft" class="centpercent" rows="3">'.$object->note.'</textarea></td></tr>';
  536. print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
  537. require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  538. $doleditor=new DolEditor('mail_valid',$object->mail_valid,'',280,'dolibarr_notes','',false,true,$conf->fckeditor->enabled,15,'90%');
  539. $doleditor->Create();
  540. print "</td></tr>";
  541. // Other attributes
  542. $parameters=array();
  543. $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook
  544. if (empty($reshook) && ! empty($extrafields->attribute_label))
  545. {
  546. print $object->showOptionals($extrafields,'edit');
  547. }
  548. print '</table>';
  549. // Extra field
  550. if (empty($reshook) && ! empty($extrafields->attribute_label))
  551. {
  552. print '<br><br><table class="border" width="100%">';
  553. foreach($extrafields->attribute_label as $key=>$label)
  554. {
  555. if (isset($_POST["options_" . $key])) {
  556. if (is_array($_POST["options_" . $key])) {
  557. // $_POST["options"] is an array but following code expects a comma separated string
  558. $value = implode(",", $_POST["options_" . $key]);
  559. } else {
  560. $value = $_POST["options_" . $key];
  561. }
  562. } else {
  563. $value = $adht->array_options["options_" . $key];
  564. }
  565. print '<tr><td width="30%">'.$label.'</td><td>';
  566. print $extrafields->showInputField($key,$value);
  567. print "</td></tr>\n";
  568. }
  569. print '</table><br><br>';
  570. }
  571. dol_fiche_end();
  572. print '<div class="center">';
  573. print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
  574. print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
  575. print '<input type="submit" name="button" class="button" value="'.$langs->trans("Cancel").'">';
  576. print '</div>';
  577. print "</form>";
  578. }
  579. }
  580. llxFooter();
  581. $db->close();