dolibarr  16.0.5
type.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
4  * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
5  * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@inodbox.com>
6  * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
7  * Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr>
8  * Copyright (C) 2019-2022 Thibault Foucart <support@ptibogxiv.net>
9  * Copyright (C) 2020 Josep Lluís Amador <joseplluis@lliuretic.cat>
10  * Copyright (C) 2021 Waël Almoman <info@almoman.com>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <https://www.gnu.org/licenses/>.
24  */
25 
32 require '../main.inc.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
34 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
37 require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
38 
39 $langs->load("members");
40 
41 $rowid = GETPOST('rowid', 'int');
42 $action = GETPOST('action', 'aZ09');
43 $cancel = GETPOST('cancel', 'alpha');
44 $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
45 $backtopage = GETPOST('backtopage', 'alpha');
46 
47 $sall = GETPOST("sall", "alpha");
48 $filter = GETPOST("filter", 'alpha');
49 $search_lastname = GETPOST('search_lastname', 'alpha');
50 $search_login = GETPOST('search_login', 'alpha');
51 $search_email = GETPOST('search_email', 'alpha');
52 $type = GETPOST('type', 'intcomma');
53 $status = GETPOST('status', 'alpha');
54 $optioncss = GETPOST('optioncss', 'alpha');
55 
56 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
57 $sortfield = GETPOST('sortfield', 'aZ09comma');
58 $sortorder = GETPOST('sortorder', 'aZ09comma');
59 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
60 if (empty($page) || $page == -1) {
61  $page = 0;
62 } // If $page is not defined, or '' or -1
63 $offset = $limit * $page;
64 $pageprev = $page - 1;
65 $pagenext = $page + 1;
66 if (!$sortorder) {
67  $sortorder = "DESC";
68 }
69 if (!$sortfield) {
70  $sortfield = "d.lastname";
71 }
72 
73 $label = GETPOST("label", "alpha");
74 $morphy = GETPOST("morphy", "alpha");
75 $status = GETPOST("status", "int");
76 $subscription = GETPOST("subscription", "int");
77 $amount = GETPOST('amount', 'alpha');
78 $duration_value = GETPOST('duration_value', 'int');
79 $duration_unit = GETPOST('duration_unit', 'alpha');
80 $vote = GETPOST("vote", "int");
81 $comment = GETPOST("comment", 'restricthtml');
82 $mail_valid = GETPOST("mail_valid", 'restricthtml');
83 
84 // Security check
85 $result = restrictedArea($user, 'adherent', $rowid, 'adherent_type');
86 
87 $object = new AdherentType($db);
88 
89 $extrafields = new ExtraFields($db);
90 
91 // fetch optionals attributes and labels
92 $extrafields->fetch_name_optionals_label($object->table_element);
93 
94 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
95  $search_lastname = "";
96  $search_login = "";
97  $search_email = "";
98  $type = "";
99  $sall = "";
100 }
101 
102 
103 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
104 $hookmanager->initHooks(array('membertypecard', 'globalcard'));
105 
106 
107 /*
108  * Actions
109  */
110 
111 if ($cancel) {
112  $action = '';
113 
114  if (!empty($backtopage)) {
115  header("Location: ".$backtopage);
116  exit;
117  }
118 }
119 
120 if ($action == 'add' && $user->rights->adherent->configurer) {
121  $object->label = trim($label);
122  $object->morphy = trim($morphy);
123  $object->status = (int) $status;
124  $object->subscription = (int) $subscription;
125  $object->amount = ($amount == '' ? '' : price2num($amount, 'MT'));
126  $object->duration_value = $duration_value;
127  $object->duration_unit = $duration_unit;
128  $object->note = trim($comment);
129  $object->note_public = trim($comment);
130  $object->mail_valid = trim($mail_valid);
131  $object->vote = (int) $vote;
132 
133  // Fill array 'array_options' with data from add form
134  $ret = $extrafields->setOptionalsFromPost(null, $object);
135  if ($ret < 0) {
136  $error++;
137  }
138 
139  if (empty($object->label)) {
140  $error++;
141  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
142  } else {
143  $sql = "SELECT libelle FROM ".MAIN_DB_PREFIX."adherent_type WHERE libelle='".$db->escape($object->label)."'";
144  $sql .= " WHERE entity IN (".getEntity('member_type').")";
145  $result = $db->query($sql);
146  if ($result) {
147  $num = $db->num_rows($result);
148  }
149  if ($num) {
150  $error++;
151  $langs->load("errors");
152  setEventMessages($langs->trans("ErrorLabelAlreadyExists", $login), null, 'errors');
153  }
154  }
155 
156  if (!$error) {
157  $id = $object->create($user);
158  if ($id > 0) {
159  header("Location: ".$_SERVER["PHP_SELF"]);
160  exit;
161  } else {
162  setEventMessages($object->error, $object->errors, 'errors');
163  $action = 'create';
164  }
165  } else {
166  $action = 'create';
167  }
168 }
169 
170 if ($action == 'update' && $user->rights->adherent->configurer) {
171  $object->fetch($rowid);
172 
173  $object->oldcopy = clone $object;
174  $object->label= trim($label);
175  $object->morphy = trim($morphy);
176  $object->status = (int) $status;
177  $object->subscription = (int) $subscription;
178  $object->amount = ($amount == '' ? '' : price2num($amount, 'MT'));
179  $object->duration_value = $duration_value;
180  $object->duration_unit = $duration_unit;
181  $object->note = trim($comment);
182  $object->note_public = trim($comment);
183  $object->mail_valid = trim($mail_valid);
184  $object->vote = (boolean) trim($vote);
185 
186  // Fill array 'array_options' with data from add form
187  $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
188  if ($ret < 0) {
189  $error++;
190  }
191 
192  $ret = $object->update($user);
193 
194  if ($ret >= 0 && !count($object->errors)) {
195  setEventMessages($langs->trans("MemberTypeModified"), null, 'mesgs');
196  } else {
197  setEventMessages($object->error, $object->errors, 'errors');
198  }
199 
200  header("Location: ".$_SERVER["PHP_SELF"]."?rowid=".$object->id);
201  exit;
202 }
203 
204 if ($action == 'confirm_delete' && !empty($user->rights->adherent->configurer)) {
205  $object->fetch($rowid);
206  $res = $object->delete();
207 
208  if ($res > 0) {
209  setEventMessages($langs->trans("MemberTypeDeleted"), null, 'mesgs');
210  header("Location: ".$_SERVER["PHP_SELF"]);
211  exit;
212  } else {
213  setEventMessages($langs->trans("MemberTypeCanNotBeDeleted"), null, 'errors');
214  $action = '';
215  }
216 }
217 
218 
219 /*
220  * View
221  */
222 
223 $form = new Form($db);
224 $formproduct = new FormProduct($db);
225 
226 $help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros|DE:Modul_Mitglieder';
227 
228 llxHeader('', $langs->trans("MembersTypeSetup"), $help_url);
229 
230 // List of members type
231 if (!$rowid && $action != 'create' && $action != 'edit') {
232  //print dol_get_fiche_head('');
233 
234  $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.amount, d.vote, d.statut as status, d.morphy";
235  $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
236  $sql .= " WHERE d.entity IN (".getEntity('member_type').")";
237 
238  $result = $db->query($sql);
239  if ($result) {
240  $num = $db->num_rows($result);
241  $nbtotalofrecords = $num;
242 
243  $i = 0;
244 
245  $param = '';
246  if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
247  $param .= '&contextpage='.$contextpage;
248  }
249  if ($limit > 0 && $limit != $conf->liste_limit) {
250  $param .= '&limit='.$limit;
251  }
252 
253  $newcardbutton = '';
254  if ($user->rights->adherent->configurer) {
255  $newcardbutton .= dolGetButtonTitle($langs->trans('NewMemberType'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/type.php?action=create');
256  }
257 
258  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
259  if ($optioncss != '') {
260  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
261  }
262  print '<input type="hidden" name="token" value="'.newToken().'">';
263  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
264  print '<input type="hidden" name="action" value="list">';
265  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
266  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
267 
268  print_barre_liste($langs->trans("MembersTypes"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'members', 0, $newcardbutton, '', $limit, 0, 0, 1);
269 
270  $moreforfilter = '';
271 
272  print '<div class="div-table-responsive">';
273  print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
274 
275  print '<tr class="liste_titre">';
276  print '<th>'.$langs->trans("Ref").'</th>';
277  print '<th>'.$langs->trans("Label").'</th>';
278  print '<th class="center">'.$langs->trans("MembersNature").'</th>';
279  print '<th class="center">'.$langs->trans("SubscriptionRequired").'</th>';
280  print '<th class="center">'.$langs->trans("Amount").'</th>';
281  print '<th class="center">'.$langs->trans("VoteAllowed").'</th>';
282  print '<th class="center">'.$langs->trans("Status").'</th>';
283  print '<th>&nbsp;</th>';
284  print "</tr>\n";
285 
286  $membertype = new AdherentType($db);
287 
288  while ($i < $num) {
289  $objp = $db->fetch_object($result);
290 
291  $membertype->id = $objp->rowid;
292  $membertype->ref = $objp->rowid;
293  $membertype->label = $objp->rowid;
294  $membertype->status = $objp->status;
295  $membertype->subscription = $objp->subscription;
296  $membertype->amount = $objp->amount;
297 
298  print '<tr class="oddeven">';
299  print '<td class="nowraponall">';
300  print $membertype->getNomUrl(1);
301  //<a href="'.$_SERVER["PHP_SELF"].'?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.'</a>
302  print '</td>';
303  print '<td>'.dol_escape_htmltag($objp->label).'</td>';
304  print '<td class="center">';
305  if ($objp->morphy == 'phy') {
306  print $langs->trans("Physical");
307  } elseif ($objp->morphy == 'mor') {
308  print $langs->trans("Moral");
309  } else {
310  print $langs->trans("MorAndPhy");
311  }
312  print '</td>';
313  print '<td class="center">'.yn($objp->subscription).'</td>';
314  print '<td class="center"><span class="amount">'.(is_null($objp->amount) || $objp->amount === '' ? '' : price($objp->amount)).'</span></td>';
315  print '<td class="center">'.yn($objp->vote).'</td>';
316  print '<td class="center">'.$membertype->getLibStatut(5).'</td>';
317  if ($user->rights->adherent->configurer) {
318  print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=edit&rowid='.$objp->rowid.'">'.img_edit().'</a></td>';
319  } else {
320  print '<td class="right">&nbsp;</td>';
321  }
322  print "</tr>";
323  $i++;
324  }
325 
326  // If no record found
327  if ($num == 0) {
328  /*$colspan = 1;
329  foreach ($arrayfields as $key => $val) {
330  if (!empty($val['checked'])) {
331  $colspan++;
332  }
333  }*/
334  $colspan = 8;
335  print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
336  }
337 
338  print "</table>";
339  print '</div>';
340 
341  print '</form>';
342  } else {
343  dol_print_error($db);
344  }
345 }
346 
347 // Creation
348 if ($action == 'create') {
349  $object = new AdherentType($db);
350 
351  print load_fiche_titre($langs->trans("NewMemberType"), '', 'members');
352 
353  print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
354  print '<input type="hidden" name="token" value="'.newToken().'">';
355  print '<input type="hidden" name="action" value="add">';
356 
357  print dol_get_fiche_head('');
358 
359  print '<table class="border centpercent">';
360  print '<tbody>';
361 
362  print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" class="minwidth200" name="label" autofocus="autofocus"></td></tr>';
363 
364  print '<tr><td>'.$langs->trans("Status").'</td><td>';
365  print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), 1, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100');
366  print '</td></tr>';
367 
368  // Morphy
369  $morphys = array();
370  $morphys[""] = $langs->trans("MorAndPhy");
371  $morphys["phy"] = $langs->trans("Physical");
372  $morphys["mor"] = $langs->trans("Moral");
373  print '<tr><td><span>'.$langs->trans("MembersNature").'</span></td><td>';
374  print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy", 'aZ09') : 'morphy');
375  print "</td></tr>";
376 
377  print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
378  print $form->selectyesno("subscription", 1, 1);
379  print '</td></tr>';
380 
381  print '<tr><td>'.$langs->trans("Amount").'</td><td>';
382  print '<input name="amount" size="5" value="'.(GETPOSTISSET('amount') ? GETPOST('amount') : price($amount)).'">';
383  print '</td></tr>';
384 
385  print '<tr><td>'.$langs->trans("VoteAllowed").'</td><td>';
386  print $form->selectyesno("vote", GETPOSTISSET("vote") ? GETPOST('vote', 'aZ09') : 1, 1);
387  print '</td></tr>';
388 
389  print '<tr><td>'.$langs->trans("Duration").'</td><td colspan="3">';
390  print '<input name="duration_value" size="5" value="'.GETPOST('duraction_unit', 'aZ09').'"> ';
391  print $formproduct->selectMeasuringUnits("duration_unit", "time", GETPOSTISSET("duration_unit") ? GETPOST('duration_unit', 'aZ09') : 'y', 0, 1);
392  print '</td></tr>';
393 
394  print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
395  require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
396  $doleditor = new DolEditor('comment', (GETPOSTISSET('comment') ? GETPOST('comment', 'restricthtml') : $object->note_public), '', 200, 'dolibarr_notes', '', false, true, empty($conf->fckeditor->enabled) ? false : $conf->fckeditor->enabled, 15, '90%');
397  $doleditor->Create();
398 
399  print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
400  require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
401  $doleditor = new DolEditor('mail_valid', GETPOSTISSET('mail_valid') ? GETPOST('mail_valid') : $object->mail_valid, '', 250, 'dolibarr_notes', '', false, true, empty($conf->fckeditor->enabled) ? false : $conf->fckeditor->enabled, 15, '90%');
402  $doleditor->Create();
403  print '</td></tr>';
404 
405  // Other attributes
406  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
407 
408  print '<tbody>';
409  print "</table>\n";
410 
411  print dol_get_fiche_end();
412 
413  print $form->buttonsSaveCancel();
414 
415  print "</form>\n";
416 }
417 
418 // View
419 if ($rowid > 0) {
420  if ($action != 'edit') {
421  $object = new AdherentType($db);
422  $object->fetch($rowid);
423  $object->fetch_optionals();
424 
425  /*
426  * Confirmation deletion
427  */
428  if ($action == 'delete') {
429  print $form->formconfirm($_SERVER['PHP_SELF']."?rowid=".$object->id, $langs->trans("DeleteAMemberType"), $langs->trans("ConfirmDeleteMemberType", $object->label), "confirm_delete", '', 0, 1);
430  }
431 
432  $head = member_type_prepare_head($object);
433 
434  print dol_get_fiche_head($head, 'card', $langs->trans("MemberType"), -1, 'group');
435 
436  $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/type.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
437 
438  dol_banner_tab($object, 'rowid', $linkback);
439 
440  print '<div class="fichecenter">';
441  print '<div class="underbanner clearboth"></div>';
442 
443  print '<table class="tableforfield border centpercent">';
444 
445  // Morphy
446  print '<tr><td>'.$langs->trans("MembersNature").'</td><td class="valeur" >'.$object->getmorphylib($object->morphy).'</td>';
447  print '</tr>';
448 
449  print '<tr><td class="titlefield">'.$langs->trans("SubscriptionRequired").'</td><td>';
450  print yn($object->subscription);
451  print '</tr>';
452 
453  // Amount
454  print '<tr><td class="titlefield">'.$langs->trans("Amount").'</td><td>';
455  print ((is_null($object->amount) || $object->amount === '') ? '' : '<span class="amount">'.price($object->amount).'</span>');
456  print '</tr>';
457 
458  print '<tr><td>'.$langs->trans("VoteAllowed").'</td><td>';
459  print yn($object->vote);
460  print '</tr>';
461 
462  print '<tr><td class="titlefield">'.$langs->trans("Duration").'</td><td colspan="2">'.$object->duration_value.'&nbsp;';
463  if ($object->duration_value > 1) {
464  $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years"));
465  } elseif ($object->duration_value > 0) {
466  $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year"));
467  }
468  print (!empty($object->duration_unit) && isset($dur[$object->duration_unit]) ? $langs->trans($dur[$object->duration_unit]) : '')."&nbsp;";
469  print '</td></tr>';
470 
471  print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
472  print nl2br($object->note)."</td></tr>";
473 
474  print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
475  print nl2br($object->mail_valid)."</td></tr>";
476 
477  // Other attributes
478  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
479 
480  print '</table>';
481  print '</div>';
482 
483  print dol_get_fiche_end();
484 
485  /*
486  * Buttons
487  */
488 
489  print '<div class="tabsAction">';
490 
491  // Edit
492  if ($user->rights->adherent->configurer) {
493  print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&token='.newToken().'&rowid='.$object->id.'">'.$langs->trans("Modify").'</a></div>';
494  }
495 
496  // Add
497  if ($user->rights->adherent->configurer && !empty($object->status)) {
498  print '<div class="inline-block divButAction"><a class="butAction" href="card.php?action=create&token='.newToken().'&typeid='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?rowid='.$object->id).'">'.$langs->trans("AddMember").'</a></div>';
499  } else {
500  print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NoAddMember")).'">'.$langs->trans("AddMember").'</a></div>';
501  }
502 
503  // Delete
504  if ($user->rights->adherent->configurer) {
505  print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&rowid='.$object->id.'">'.$langs->trans("DeleteType").'</a></div>';
506  }
507 
508  print "</div>";
509 
510 
511  // Show list of members (nearly same code than in page list.php)
512 
513  $membertypestatic = new AdherentType($db);
514 
515  $now = dol_now();
516 
517  $sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe as company,";
518  $sql .= " d.datefin,";
519  $sql .= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut as status,";
520  $sql .= " t.libelle as type, t.subscription, t.amount";
521  $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
522  $sql .= " WHERE d.fk_adherent_type = t.rowid ";
523  $sql .= " AND d.entity IN (".getEntity('adherent').")";
524  $sql .= " AND t.rowid = ".((int) $object->id);
525  if ($sall) {
526  $sql .= natural_search(array("d.firstname", "d.lastname", "d.societe", "d.email", "d.login", "d.address", "d.town", "d.note_public", "d.note_private"), $sall);
527  }
528  if ($status != '') {
529  $sql .= natural_search('d.statut', $status, 2);
530  }
531  if ($action == 'search') {
532  if (GETPOST('search', 'alpha')) {
533  $sql .= natural_search(array("d.firstname", "d.lastname"), GETPOST('search', 'alpha'));
534  }
535  }
536  if (!empty($search_lastname)) {
537  $sql .= natural_search(array("d.firstname", "d.lastname"), $search_lastname);
538  }
539  if (!empty($search_login)) {
540  $sql .= natural_search("d.login", $search_login);
541  }
542  if (!empty($search_email)) {
543  $sql .= natural_search("d.email", $search_email);
544  }
545  if ($filter == 'uptodate') {
546  $sql .= " AND (datefin >= '".$db->idate($now)."') OR t.subscription = 0)";
547  }
548  if ($filter == 'outofdate') {
549  $sql .= " AND (datefin < '".$db->idate($now)."' AND t.subscription = 1)";
550  }
551 
552  $sql .= " ".$db->order($sortfield, $sortorder);
553 
554  // Count total nb of records
555  $nbtotalofrecords = '';
556  if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
557  $resql = $db->query($sql);
558  if ($resql) {
559  $nbtotalofrecords = $db->num_rows($result);
560  } else {
561  dol_print_error($db);
562  }
563  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
564  $page = 0;
565  $offset = 0;
566  }
567  }
568 
569  $sql .= " ".$db->plimit($conf->liste_limit + 1, $offset);
570 
571  $resql = $db->query($sql);
572  if ($resql) {
573  $num = $db->num_rows($resql);
574  $i = 0;
575 
576  $titre = $langs->trans("MembersList");
577  if ($status != '') {
578  if ($status == '-1,1') {
579  $titre = $langs->trans("MembersListQualified");
580  } elseif ($status == '-1') {
581  $titre = $langs->trans("MembersListToValid");
582  } elseif ($status == '1' && !$filter) {
583  $titre = $langs->trans("MembersListValid");
584  } elseif ($status == '1' && $filter == 'uptodate') {
585  $titre = $langs->trans("MembersListUpToDate");
586  } elseif ($status == '1' && $filter == 'outofdate') {
587  $titre = $langs->trans("MembersListNotUpToDate");
588  } elseif ($status == '0') {
589  $titre = $langs->trans("MembersListResiliated");
590  } elseif ($status == '-2') {
591  $titre = $langs->trans("MembersListExcluded");
592  }
593  } elseif ($action == 'search') {
594  $titre = $langs->trans("MembersListQualified");
595  }
596 
597  if ($type > 0) {
598  $membertype = new AdherentType($db);
599  $result = $membertype->fetch($type);
600  $titre .= " (".$membertype->label.")";
601  }
602 
603  $param = "&rowid=".urlencode($object->id);
604  if (!empty($status)) {
605  $param .= "&status=".urlencode($status);
606  }
607  if (!empty($search_lastname)) {
608  $param .= "&search_lastname=".urlencode($search_lastname);
609  }
610  if (!empty($search_firstname)) {
611  $param .= "&search_firstname=".urlencode($search_firstname);
612  }
613  if (!empty($search_login)) {
614  $param .= "&search_login=".urlencode($search_login);
615  }
616  if (!empty($search_email)) {
617  $param .= "&search_email=".urlencode($search_email);
618  }
619  if (!empty($filter)) {
620  $param .= "&filter=".urlencode($filter);
621  }
622 
623  if ($sall) {
624  print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall;
625  }
626 
627  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
628  print '<input type="hidden" name="token" value="'.newToken().'">';
629  print '<input class="flat" type="hidden" name="rowid" value="'.$object->id.'" size="12"></td>';
630 
631  print '<br>';
632  print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords);
633 
634  $moreforfilter = '';
635 
636  print '<div class="div-table-responsive">';
637  print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
638 
639  // Fields title search
640  print '<tr class="liste_titre_filter">';
641 
642  print '<td class="liste_titre left">';
643  print '<input class="flat" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).'" size="12"></td>';
644 
645  print '<td class="liste_titre left">';
646  print '<input class="flat" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'" size="7"></td>';
647 
648  print '<td class="liste_titre">&nbsp;</td>';
649 
650  print '<td class="liste_titre left">';
651  print '<input class="flat" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).'" size="12"></td>';
652 
653  print '<td class="liste_titre">&nbsp;</td>';
654 
655  print '<td class="liste_titre right" colspan="2">';
656  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")).'">';
657  print '&nbsp; ';
658  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")).'">';
659  print '</td>';
660 
661  print "</tr>\n";
662 
663  print '<tr class="liste_titre">';
664  print_liste_field_titre("NameSlashCompany", $_SERVER["PHP_SELF"], "d.lastname", $param, "", "", $sortfield, $sortorder);
665  print_liste_field_titre("Login", $_SERVER["PHP_SELF"], "d.login", $param, "", "", $sortfield, $sortorder);
666  print_liste_field_titre("MemberNature", $_SERVER["PHP_SELF"], "d.morphy", $param, "", "", $sortfield, $sortorder);
667  print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "d.email", $param, "", "", $sortfield, $sortorder);
668  print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "d.statut,d.datefin", $param, "", "", $sortfield, $sortorder);
669  print_liste_field_titre("EndSubscription", $_SERVER["PHP_SELF"], "d.datefin", $param, "", 'align="center"', $sortfield, $sortorder);
670  print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", $param, "", 'width="60" align="center"', $sortfield, $sortorder);
671  print "</tr>\n";
672 
673  $adh = new Adherent($db);
674 
675  $imaxinloop = ($limit ? min($num, $limit) : $num);
676  while ($i < $imaxinloop) {
677  $objp = $db->fetch_object($resql);
678 
679  $datefin = $db->jdate($objp->datefin);
680 
681  $adh->lastname = $objp->lastname;
682  $adh->firstname = $objp->firstname;
683  $adh->datefin = $datefin;
684  $adh->need_subscription = $objp->subscription;
685  $adh->statut = $objp->status;
686 
687  print '<tr class="oddeven">';
688 
689  // Lastname
690  if ($objp->company != '') {
691  print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"), "user", 'class="paddingright"').$adh->getFullName($langs, 0, -1, 20).' / '.dol_trunc($objp->company, 12).'</a></td>'."\n";
692  } else {
693  print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"), "user", 'class="paddingright"').$adh->getFullName($langs, 0, -1, 32).'</a></td>'."\n";
694  }
695 
696  // Login
697  print "<td>".dol_escape_htmltag($objp->login)."</td>\n";
698 
699  // Type
700  /*print '<td class="nowrap">';
701  $membertypestatic->id=$objp->type_id;
702  $membertypestatic->label=$objp->type;
703  print $membertypestatic->getNomUrl(1,12);
704  print '</td>';
705  */
706 
707  // Moral/Physique
708  print "<td>".$adh->getmorphylib($objp->morphy)."</td>\n";
709 
710  // EMail
711  print "<td>".dol_print_email($objp->email, 0, 0, 1)."</td>\n";
712 
713  // Status
714  print '<td class="nowrap">';
715  print $adh->getLibStatut(2);
716  print "</td>";
717 
718  // Date end subscription
719  if ($datefin) {
720  print '<td class="nowrap center">';
721  if ($datefin < dol_now() && $objp->status > 0) {
722  print dol_print_date($datefin, 'day')." ".img_warning($langs->trans("SubscriptionLate"));
723  } else {
724  print dol_print_date($datefin, 'day');
725  }
726  print '</td>';
727  } else {
728  print '<td class="nowrap left">';
729  if (!empty($objp->subscription)) {
730  print $langs->trans("SubscriptionNotReceived");
731  if ($objp->status > 0) {
732  print " ".img_warning();
733  }
734  } else {
735  print '&nbsp;';
736  }
737  print '</td>';
738  }
739 
740  // Actions
741  print '<td class="center">';
742  if ($user->rights->adherent->creer) {
743  print '<a class="editfielda marginleftonly" href="card.php?rowid='.$objp->rowid.'&action=edit&token='.newToken().'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?rowid='.$object->id).'">'.img_edit().'</a>';
744  }
745  if ($user->rights->adherent->supprimer) {
746  print '<a class="marginleftonly" href="card.php?rowid='.$objp->rowid.'&action=resign&token='.newToken().'">'.img_picto($langs->trans("Resiliate"), 'disable.png').'</a>';
747  }
748  print "</td>";
749 
750  print "</tr>\n";
751  $i++;
752  }
753 
754  if ($i == 0) {
755  print '<tr><td colspan="7"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
756  }
757 
758  print "</table>\n";
759  print '</div>';
760  print '</form>';
761 
762  if ($num > $limit) {
763  print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '');
764  }
765  } else {
766  dol_print_error($db);
767  }
768  }
769 
770  /* ************************************************************************** */
771  /* */
772  /* Edition mode */
773  /* */
774  /* ************************************************************************** */
775 
776  if ($action == 'edit') {
777  $object = new AdherentType($db);
778  $object->fetch($rowid);
779  $object->fetch_optionals();
780 
781  $head = member_type_prepare_head($object);
782 
783  print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'">';
784  print '<input type="hidden" name="token" value="'.newToken().'">';
785  print '<input type="hidden" name="rowid" value="'.$object->id.'">';
786  print '<input type="hidden" name="action" value="update">';
787 
788  print dol_get_fiche_head($head, 'card', $langs->trans("MemberType"), 0, 'group');
789 
790  print '<table class="border centpercent">';
791 
792  print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>'.$object->id.'</td></tr>';
793 
794  print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" class="minwidth300" name="label" value="'.dol_escape_htmltag($object->label).'"></td></tr>';
795 
796  print '<tr><td>'.$langs->trans("Status").'</td><td>';
797  print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $object->status, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100');
798  print '</td></tr>';
799 
800  // Morphy
801  $morphys[""] = $langs->trans("MorAndPhy");
802  $morphys["phy"] = $langs->trans("Physical");
803  $morphys["mor"] = $langs->trans("Moral");
804  print '<tr><td><span>'.$langs->trans("MembersNature").'</span></td><td>';
805  print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy", 'aZ09') : $object->morphy);
806  print "</td></tr>";
807 
808  print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
809  print $form->selectyesno("subscription", $object->subscription, 1);
810  print '</td></tr>';
811 
812  print '<tr><td>'.$langs->trans("Amount").'</td><td>';
813  print '<input name="amount" size="5" value="';
814  print ((is_null($object->amount) || $object->amount === '') ? '' : price($object->amount));
815  print '">';
816  print '</td></tr>';
817 
818  print '<tr><td>'.$langs->trans("VoteAllowed").'</td><td>';
819  print $form->selectyesno("vote", $object->vote, 1);
820  print '</td></tr>';
821 
822  print '<tr><td>'.$langs->trans("Duration").'</td><td colspan="3">';
823  print '<input name="duration_value" size="5" value="'.$object->duration_value.'"> ';
824  print $formproduct->selectMeasuringUnits("duration_unit", "time", ($object->duration_unit === '' ? 'y' : $object->duration_unit), 0, 1);
825  print '</td></tr>';
826 
827  print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
828  require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
829  $doleditor = new DolEditor('comment', $object->note, '', 280, 'dolibarr_notes', '', false, true, empty($conf->fckeditor->enabled) ? false : $conf->fckeditor->enabled, 15, '90%');
830  $doleditor->Create();
831  print "</td></tr>";
832 
833  print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
834  $doleditor = new DolEditor('mail_valid', $object->mail_valid, '', 280, 'dolibarr_notes', '', false, true, empty($conf->fckeditor->enabled) ? false : $conf->fckeditor->enabled, 15, '90%');
835  $doleditor->Create();
836  print "</td></tr>";
837 
838  // Other attributes
839  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
840 
841  print '</table>';
842 
843  print dol_get_fiche_end();
844 
845  print $form->buttonsSaveCancel();
846 
847  print "</form>";
848  }
849 }
850 
851 // End of page
852 llxFooter();
853 $db->close();
AdherentType
Class to manage members type.
Definition: adherent_type.class.php:35
yn
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
Definition: functions.lib.php:6491
dol_escape_htmltag
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
Definition: functions.lib.php:1468
dol_trunc
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
Definition: functions.lib.php:3805
restrictedArea
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
Definition: security.lib.php:234
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
member_type_prepare_head
member_type_prepare_head(AdherentType $object)
Return array head with list of tabs to view object informations.
Definition: member.lib.php:137
img_warning
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
Definition: functions.lib.php:4521
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
img_edit
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
Definition: functions.lib.php:4389
dol_banner_tab
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
Definition: functions.lib.php:2046
$help_url
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:116
price2num
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
Definition: functions.lib.php:5661
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2514
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
dolGetButtonTitle
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
Definition: functions.lib.php:10605
print_barre_liste
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
Definition: functions.lib.php:5257
Adherent
Class to manage members of a foundation.
Definition: adherent.class.php:46
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
FormProduct
Class with static methods for building HTML components related to products Only components common to ...
Definition: html.formproduct.class.php:30
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:10878
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
print_liste_field_titre
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
Definition: functions.lib.php:5026
natural_search
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
Definition: functions.lib.php:9420
ExtraFields
Class to manage standard extra fields.
Definition: extrafields.class.php:39
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
img_object
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
Definition: functions.lib.php:4211
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2845
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
price
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
Definition: functions.lib.php:5541
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59
DolEditor
Class to manage a WYSIWYG editor.
Definition: doleditor.class.php:30