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