dolibarr  7.0.0-beta
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@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 
29 require '../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
34 
35 $langs->load("members");
36 
37 $rowid = GETPOST('rowid','int');
38 $action = GETPOST('action','alpha');
39 $cancel = GETPOST('cancel','alpha');
40 $backtopage = GETPOST('backtopage','alpha');
41 
42 $search_lastname = GETPOST('search_lastname','alpha');
43 $search_login = GETPOST('search_login','alpha');
44 $search_email = GETPOST('search_email','alpha');
45 $type = GETPOST('type','alpha');
46 $status = GETPOST('status','alpha');
47 
48 $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
49 $sortfield = GETPOST("sortfield",'alpha');
50 $sortorder = GETPOST("sortorder",'alpha');
51 $page = GETPOST("page",'int');
52 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
53 $offset = $limit * $page ;
54 $pageprev = $page - 1;
55 $pagenext = $page + 1;
56 if (! $sortorder) { $sortorder="DESC"; }
57 if (! $sortfield) { $sortfield="d.lastname"; }
58 
59 $label=GETPOST("label","alpha");
60 $subscription=GETPOST("subscription","int");
61 $vote=GETPOST("vote","int");
62 $comment=GETPOST("comment");
63 $mail_valid=GETPOST("mail_valid");
64 
65 // Security check
66 $result=restrictedArea($user,'adherent',$rowid,'adherent_type');
67 
68 $object = new AdherentType($db);
69 
70 $extrafields = new ExtraFields($db);
71 
72 // fetch optionals attributes and labels
73 $extralabels=$extrafields->fetch_name_optionals_label('adherent_type');
74 
75 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
76 {
77  $search_lastname="";
78  $search_login="";
79  $search_email="";
80  $type="";
81  $sall="";
82 }
83 
84 
85 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
86 $hookmanager->initHooks(array('membertypecard','globalcard'));
87 
88 
89 /*
90  * Actions
91  */
92 
93 if ($cancel) {
94 
95  $action='';
96 
97  if (! empty($backtopage))
98  {
99  header("Location: ".$backtopage);
100  exit;
101  }
102 }
103 
104 if ($action == 'add' && $user->rights->adherent->configurer)
105 {
106  $object->label = trim($label);
107  $object->subscription = (int) trim($subscription);
108  $object->note = trim($comment);
109  $object->mail_valid = trim($mail_valid);
110  $object->vote = trim($vote);
111 
112  // Fill array 'array_options' with data from add form
113  $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
114  if ($ret < 0) $error++;
115 
116  if (empty($object->label)) {
117  $error++;
118  setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")), null, 'errors');
119  }
120  else {
121  $sql = "SELECT libelle FROM ".MAIN_DB_PREFIX."adherent_type WHERE libelle='".$db->escape($object->label)."'";
122  $result = $db->query($sql);
123  if ($result) {
124  $num = $db->num_rows($result);
125  }
126  if ($num) {
127  $error++;
128  $langs->load("errors");
129  setEventMessages($langs->trans("ErrorLabelAlreadyExists",$login), null, 'errors');
130  }
131  }
132 
133  if (! $error)
134  {
135  $id=$object->create($user);
136  if ($id > 0)
137  {
138  header("Location: ".$_SERVER["PHP_SELF"]);
139  exit;
140  }
141  else
142  {
143  setEventMessages($object->error, $object->errors, 'errors');
144  $action = 'create';
145  }
146  }
147  else
148  {
149  $action = 'create';
150  }
151 }
152 
153 if ($action == 'update' && $user->rights->adherent->configurer)
154 {
155  $object->fetch($rowid);
156 
157  $object->oldcopy = clone $object;
158 
159  $object->label = trim($label);
160  $object->subscription = (int) trim($subscription);
161  $object->note = trim($comment);
162  $object->mail_valid = trim($mail_valid);
163  $object->vote = trim($vote);
164 
165  // Fill array 'array_options' with data from add form
166  $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
167  if ($ret < 0) $error++;
168 
169  $ret=$object->update($user);
170 
171  if ($ret >= 0 && ! count($object->errors))
172  {
173  setEventMessages($langs->trans("MemberTypeModified"), null, 'mesgs');
174  }
175  else
176  {
177  setEventMessages($object->error, $object->errors, 'errors');
178  }
179 
180  header("Location: ".$_SERVER["PHP_SELF"]."?rowid=".$object->id);
181  exit;
182 }
183 
184 if ($action == 'confirm_delete' && $user->rights->adherent->configurer)
185 {
186  $object->fetch($rowid);
187  $res=$object->delete();
188 
189  if ($res > 0)
190  {
191  setEventMessages($langs->trans("MemberTypeDeleted"), null, 'mesgs');
192  header("Location: ".$_SERVER["PHP_SELF"]);
193  exit;
194  }
195  else
196  {
197  setEventMessages($langs->trans("MemberTypeCanNotBeDeleted"), null, 'errors');
198  $action='';
199  }
200 }
201 
202 
203 /*
204  * View
205  */
206 
207 $form=new Form($db);
208 
209 llxHeader('',$langs->trans("MembersTypeSetup"),'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');
210 
211 
212 // List of members type
213 if (! $rowid && $action != 'create' && $action != 'edit')
214 {
215  //dol_fiche_head('');
216 
217  $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.vote";
218  $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
219  $sql.= " WHERE d.entity IN (".getEntity('adherent').")";
220 
221  $result = $db->query($sql);
222  if ($result)
223  {
224  $num = $db->num_rows($result);
225  $nbtotalofrecords = $num;
226 
227  $i = 0;
228 
229  $param = '';
230 
231  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
232  if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
233  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
234  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
235  print '<input type="hidden" name="action" value="list">';
236  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
237  print '<input type="hidden" name="page" value="'.$page.'">';
238  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
239 
240  print_barre_liste($langs->trans("MembersTypes"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit);
241 
242  $moreforfilter = '';
243 
244  print '<div class="div-table-responsive">';
245  print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
246 
247  print '<tr class="liste_titre">';
248  print '<th>'.$langs->trans("Ref").'</th>';
249  print '<th>'.$langs->trans("Label").'</th>';
250  print '<th align="center">'.$langs->trans("SubscriptionRequired").'</th>';
251  print '<th align="center">'.$langs->trans("VoteAllowed").'</th>';
252  print '<th>&nbsp;</th>';
253  print "</tr>\n";
254 
255  $membertype = new AdherentType($db);
256 
257  while ($i < $num)
258  {
259  $objp = $db->fetch_object($result);
260 
261  $membertype->id = $objp->rowid;
262  $membertype->ref = $objp->rowid;
263  $membertype->label = $objp->rowid;
264 
265  print '<tr class="oddeven">';
266  print '<td>';
267  print $membertype->getNomUrl(1);
268  //<a href="'.$_SERVER["PHP_SELF"].'?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.'</a>
269  print '</td>';
270  print '<td>'.dol_escape_htmltag($objp->label).'</td>';
271  print '<td align="center">'.yn($objp->subscription).'</td>';
272  print '<td align="center">'.yn($objp->vote).'</td>';
273  if ($user->rights->adherent->configurer)
274  print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit&rowid='.$objp->rowid.'">'.img_edit().'</a></td>';
275  else
276  print '<td align="right">&nbsp;</td>';
277  print "</tr>";
278  $i++;
279  }
280  print "</table>";
281  print '</div>';
282 
283  print '</form>';
284  }
285  else
286  {
287  dol_print_error($db);
288  }
289 }
290 
291 
292 /* ************************************************************************** */
293 /* */
294 /* Creation mode */
295 /* */
296 /* ************************************************************************** */
297 if ($action == 'create')
298 {
299  $object = new AdherentType($db);
300 
301  print load_fiche_titre($langs->trans("NewMemberType"));
302 
303  print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
304  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
305  print '<input type="hidden" name="action" value="add">';
306 
307  dol_fiche_head('');
308 
309  print '<table class="border" width="100%">';
310  print '<tbody>';
311 
312  print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" name="label" size="40"></td></tr>';
313 
314  print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
315  print $form->selectyesno("subscription",1,1);
316  print '</td></tr>';
317 
318  print '<tr><td>'.$langs->trans("VoteAllowed").'</td><td>';
319  print $form->selectyesno("vote",0,1);
320  print '</td></tr>';
321 
322  print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
323  print '<textarea name="comment" wrap="soft" class="centpercent" rows="3"></textarea></td></tr>';
324 
325  print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
326  require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
327  $doleditor=new DolEditor('mail_valid',$object->mail_valid,'',280,'dolibarr_notes','',false,true,$conf->fckeditor->enabled,15,'90%');
328  $doleditor->Create();
329  print '</td></tr>';
330 
331  // Other attributes
332  $parameters=array();
333  $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook
334  print $hookmanager->resPrint;
335  if (empty($reshook) && ! empty($extrafields->attribute_label))
336  {
337  print $object->showOptionals($extrafields,'edit');
338  }
339  print '<tbody>';
340  print "</table>\n";
341 
342  dol_fiche_end();
343 
344  print '<div class="center">';
345  print '<input type="submit" name="button" class="button" value="'.$langs->trans("Add").'">';
346  print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
347  print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'" onclick="history.go(-1)" />';
348  print '</div>';
349 
350  print "</form>\n";
351 }
352 
353 /* ************************************************************************** */
354 /* */
355 /* View mode */
356 /* */
357 /* ************************************************************************** */
358 if ($rowid > 0)
359 {
360  if ($action != 'edit')
361  {
362  $object = new AdherentType($db);
363  $object->fetch($rowid);
364  $object->fetch_optionals($object->id,$extralabels);
365 
366  /*
367  * Confirmation suppression
368  */
369  if ($action == 'delete')
370  {
371  print $form->formconfirm($_SERVER['PHP_SELF']."?rowid=".$object->id,$langs->trans("DeleteAMemberType"),$langs->trans("ConfirmDeleteMemberType",$object->label),"confirm_delete", '',0,1);
372  }
373 
374  $head = member_type_prepare_head($object);
375 
376  dol_fiche_head($head, 'card', $langs->trans("MemberType"), -1, 'group');
377 
378  $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/type.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
379 
380  dol_banner_tab($object, 'rowid', $linkback);
381 
382  print '<div class="fichecenter">';
383  print '<div class="underbanner clearboth"></div>';
384 
385  print '<table class="border" width="100%">';
386 
387  print '<tr><td class="titlefield">'.$langs->trans("SubscriptionRequired").'</td><td>';
388  print yn($object->subscription);
389  print '</tr>';
390 
391  print '<tr><td>'.$langs->trans("VoteAllowed").'</td><td>';
392  print yn($object->vote);
393  print '</tr>';
394 
395  print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
396  print nl2br($object->note)."</td></tr>";
397 
398  print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
399  print nl2br($object->mail_valid)."</td></tr>";
400 
401  // Other attributes
402  include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
403 
404  print '</table>';
405  print '</div>';
406 
407  dol_fiche_end();
408 
409  /*
410  * Buttons
411  */
412 
413  print '<div class="tabsAction">';
414 
415  // Edit
416  if ($user->rights->adherent->configurer)
417  {
418  print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&amp;rowid='.$object->id.'">'.$langs->trans("Modify").'</a></div>';
419  }
420 
421  // Add
422  print '<div class="inline-block divButAction"><a class="butAction" href="card.php?action=create&typeid='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?rowid='.$object->id).'">'.$langs->trans("AddMember").'</a></div>';
423 
424  // Delete
425  if ($user->rights->adherent->configurer)
426  {
427  print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&rowid='.$object->id.'">'.$langs->trans("DeleteType").'</a></div>';
428  }
429 
430  print "</div>";
431 
432 
433  // Show list of members (nearly same code than in page list.php)
434 
435  $membertypestatic=new AdherentType($db);
436 
437  $now=dol_now();
438 
439  $sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe, ";
440  $sql.= " d.datefin,";
441  $sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,";
442  $sql.= " t.libelle as type, t.subscription";
443  $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
444  $sql.= " WHERE d.fk_adherent_type = t.rowid ";
445  $sql.= " AND d.entity IN (".getEntity('adherent').")";
446  $sql.= " AND t.rowid = ".$object->id;
447  if ($sall)
448  {
449  $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);
450  }
451  if ($status != '')
452  {
453  $sql.= natural_search('d.statut', $status, 2);
454  }
455  if ($action == 'search')
456  {
457  if (GETPOST('search','alpha'))
458  {
459  $sql.= natural_search(array("d.firstname","d.lastname"), GETPOST('search','alpha'));
460  }
461  }
462  if (! empty($search_lastname))
463  {
464  $sql.= natural_search(array("d.firstname","d.lastname"), $search_lastname);
465  }
466  if (! empty($search_login))
467  {
468  $sql.= natural_search("d.login", $search_login);
469  }
470  if (! empty($search_email))
471  {
472  $sql.= natural_search("d.email", $search_email);
473  }
474  if ($filter == 'uptodate')
475  {
476  $sql.=" AND datefin >= '".$db->idate($now)."'";
477  }
478  if ($filter == 'outofdate')
479  {
480  $sql.=" AND datefin < '".$db->idate($now)."'";
481  }
482  // Count total nb of records
483  $nbtotalofrecords = '';
484  if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
485  {
486  $resql = $db->query($sql);
487  if ($resql) $nbtotalofrecords = $db->num_rows($result);
488  else dol_print_error($db);
489  }
490  // Add order and limit
491  $sql.= " ".$db->order($sortfield,$sortorder);
492  $sql.= " ".$db->plimit($conf->liste_limit+1, $offset);
493 
494  $resql = $db->query($sql);
495  if ($resql)
496  {
497  $num = $db->num_rows($resql);
498  $i = 0;
499 
500  $titre=$langs->trans("MembersList");
501  if ($status != '')
502  {
503  if ($status == '-1,1') { $titre=$langs->trans("MembersListQualified"); }
504  else if ($status == '-1') { $titre=$langs->trans("MembersListToValid"); }
505  else if ($status == '1' && ! $filter) { $titre=$langs->trans("MembersListValid"); }
506  else if ($status == '1' && $filter=='uptodate') { $titre=$langs->trans("MembersListUpToDate"); }
507  else if ($status == '1' && $filter=='outofdate') { $titre=$langs->trans("MembersListNotUpToDate"); }
508  else if ($status == '0') { $titre=$langs->trans("MembersListResiliated"); }
509  }
510  elseif ($action == 'search')
511  {
512  $titre=$langs->trans("MembersListQualified");
513  }
514 
515  if ($type > 0)
516  {
517  $membertype=new AdherentType($db);
518  $result=$membertype->fetch($type);
519  $titre.=" (".$membertype->label.")";
520  }
521 
522  $param="&rowid=".$object->id;
523  if (! empty($status)) $param.="&status=".$status;
524  if (! empty($search_lastname)) $param.="&search_lastname=".$search_lastname;
525  if (! empty($search_firstname)) $param.="&search_firstname=".$search_firstname;
526  if (! empty($search_login)) $param.="&search_login=".$search_login;
527  if (! empty($search_email)) $param.="&search_email=".$search_email;
528  if (! empty($filter)) $param.="&filter=".$filter;
529 
530  if ($sall)
531  {
532  print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall;
533  }
534 
535  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
536  print '<input class="flat" type="hidden" name="rowid" value="'.$object->id.'" size="12"></td>';
537 
538  print '<br>';
539  print_barre_liste('',$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords);
540 
541  $moreforfilter = '';
542 
543  print '<div class="div-table-responsive">';
544  print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
545 
546  // Lignes des champs de filtre
547  print '<tr class="liste_titre_filter">';
548 
549  print '<td class="liste_titre" align="left">';
550  print '<input class="flat" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).'" size="12"></td>';
551 
552  print '<td class="liste_titre" align="left">';
553  print '<input class="flat" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'" size="7"></td>';
554 
555  print '<td class="liste_titre">&nbsp;</td>';
556 
557  print '<td class="liste_titre" align="left">';
558  print '<input class="flat" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).'" size="12"></td>';
559 
560  print '<td class="liste_titre">&nbsp;</td>';
561 
562  print '<td align="right" colspan="2" class="liste_titre">';
563  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")).'">';
564  print '&nbsp; ';
565  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")).'">';
566  print '</td>';
567 
568  print "</tr>\n";
569 
570  print '<tr class="liste_titre">';
571  print_liste_field_titre( $langs->trans("Name")." / ".$langs->trans("Company"),$_SERVER["PHP_SELF"],"d.lastname",$param,"","",$sortfield,$sortorder);
572  print_liste_field_titre("Login",$_SERVER["PHP_SELF"],"d.login",$param,"","",$sortfield,$sortorder);
573  print_liste_field_titre("Nature",$_SERVER["PHP_SELF"],"d.morphy",$param,"","",$sortfield,$sortorder);
574  print_liste_field_titre("EMail",$_SERVER["PHP_SELF"],"d.email",$param,"","",$sortfield,$sortorder);
575  print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"d.statut,d.datefin",$param,"","",$sortfield,$sortorder);
576  print_liste_field_titre("EndSubscription",$_SERVER["PHP_SELF"],"d.datefin",$param,"",'align="center"',$sortfield,$sortorder);
577  print_liste_field_titre("Action",$_SERVER["PHP_SELF"],"",$param,"",'width="60" align="center"',$sortfield,$sortorder);
578  print "</tr>\n";
579 
580  while ($i < $num && $i < $conf->liste_limit)
581  {
582  $objp = $db->fetch_object($resql);
583 
584  $datefin=$db->jdate($objp->datefin);
585 
586  $adh=new Adherent($db);
587  $adh->lastname=$objp->lastname;
588  $adh->firstname=$objp->firstname;
589 
590  // Lastname
591  print '<tr class="oddeven">';
592  if ($objp->societe != '')
593  {
594  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";
595  }
596  else
597  {
598  print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"),"user").' '.$adh->getFullName($langs,0,-1,32).'</a></td>'."\n";
599  }
600 
601  // Login
602  print "<td>".$objp->login."</td>\n";
603 
604  // Type
605  /*print '<td class="nowrap">';
606  $membertypestatic->id=$objp->type_id;
607  $membertypestatic->label=$objp->type;
608  print $membertypestatic->getNomUrl(1,12);
609  print '</td>';
610  */
611 
612  // Moral/Physique
613  print "<td>".$adh->getmorphylib($objp->morphy)."</td>\n";
614 
615  // EMail
616  print "<td>".dol_print_email($objp->email,0,0,1)."</td>\n";
617 
618  // Statut
619  print '<td class="nowrap">';
620  print $adh->LibStatut($objp->statut,$objp->subscription,$datefin,2);
621  print "</td>";
622 
623  // Date end subscription
624  if ($datefin)
625  {
626  print '<td align="center" class="nowrap">';
627  if ($datefin < dol_now() && $objp->statut > 0)
628  {
629  print dol_print_date($datefin,'day')." ".img_warning($langs->trans("SubscriptionLate"));
630  }
631  else
632  {
633  print dol_print_date($datefin,'day');
634  }
635  print '</td>';
636  }
637  else
638  {
639  print '<td align="left" class="nowrap">';
640  if ($objp->subscription == 'yes')
641  {
642  print $langs->trans("SubscriptionNotReceived");
643  if ($objp->statut > 0) print " ".img_warning();
644  }
645  else
646  {
647  print '&nbsp;';
648  }
649  print '</td>';
650  }
651 
652  // Actions
653  print '<td align="center">';
654  if ($user->rights->adherent->creer)
655  {
656  print '<a href="card.php?rowid='.$objp->rowid.'&action=edit&backtopage='.urlencode($_SERVER["PHP_SELF"].'?rowid='.$object->id).'">'.img_edit().'</a>';
657  }
658  print '&nbsp;';
659  if ($user->rights->adherent->supprimer)
660  {
661  print '<a href="card.php?rowid='.$objp->rowid.'&action=resign">'.img_picto($langs->trans("Resiliate"),'disable.png').'</a>';
662  }
663  print "</td>";
664 
665  print "</tr>\n";
666  $i++;
667  }
668 
669  print "</table>\n";
670  print '</div>';
671  print '</form>';
672 
673  if ($num > $conf->liste_limit)
674  {
675  print_barre_liste('',$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'');
676  }
677  }
678  else
679  {
680  dol_print_error($db);
681  }
682 
683  }
684 
685  /* ************************************************************************** */
686  /* */
687  /* Edition mode */
688  /* */
689  /* ************************************************************************** */
690 
691  if ($action == 'edit')
692  {
693  $object = new AdherentType($db);
694  $object->fetch($rowid);
695  $object->fetch_optionals($object->id,$extralabels);
696 
697  $head = member_type_prepare_head($object);
698 
699  print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'">';
700  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
701  print '<input type="hidden" name="rowid" value="'.$object->id.'">';
702  print '<input type="hidden" name="action" value="update">';
703 
704  dol_fiche_head($head, 'card', $langs->trans("MemberType"), 0, 'group');
705 
706  print '<table class="border" width="100%">';
707 
708  print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>'.$object->id.'</td></tr>';
709 
710  print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" name="label" size="40" value="'.dol_escape_htmltag($object->label).'"></td></tr>';
711 
712  print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
713  print $form->selectyesno("subscription",$object->subscription,1);
714  print '</td></tr>';
715 
716  print '<tr><td>'.$langs->trans("VoteAllowed").'</td><td>';
717  print $form->selectyesno("vote",$object->vote,1);
718  print '</td></tr>';
719 
720  print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
721  print '<textarea name="comment" wrap="soft" class="centpercent" rows="3">'.$object->note.'</textarea></td></tr>';
722 
723  print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
724  require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
725  $doleditor=new DolEditor('mail_valid',$object->mail_valid,'',280,'dolibarr_notes','',false,true,$conf->fckeditor->enabled,15,'90%');
726  $doleditor->Create();
727  print "</td></tr>";
728 
729  // Other attributes
730  $parameters=array();
731  $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook
732  print $hookmanager->resPrint;
733  if (empty($reshook) && ! empty($extrafields->attribute_label))
734  {
735  print $object->showOptionals($extrafields,'edit');
736  }
737 
738  print '</table>';
739 
740  // Extra field
741  if (empty($reshook) && ! empty($extrafields->attribute_label))
742  {
743  print '<br><br><table class="border" width="100%">';
744  foreach($extrafields->attribute_label as $key=>$label)
745  {
746  if (isset($_POST["options_" . $key])) {
747  if (is_array($_POST["options_" . $key])) {
748  // $_POST["options"] is an array but following code expects a comma separated string
749  $value = implode(",", $_POST["options_" . $key]);
750  } else {
751  $value = $_POST["options_" . $key];
752  }
753  } else {
754  $value = $adht->array_options["options_" . $key];
755  }
756  print '<tr><td width="30%">'.$label.'</td><td>';
757  print $extrafields->showInputField($key,$value);
758  print "</td></tr>\n";
759  }
760  print '</table><br><br>';
761  }
762 
763  dol_fiche_end();
764 
765  print '<div class="center">';
766  print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
767  print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
768  print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
769  print '</div>';
770 
771  print "</form>";
772  }
773 }
774 
775 
776 llxFooter();
777 
778 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it's its name (generic function)
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
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.
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
Show tab header of a card.
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.
member_type_prepare_head(AdherentType $object)
Return array head with list of tabs to view object informations.
Definition: member.lib.php:117
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
if(empty($reshook)) $form
View.
Definition: perms.php:103
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage standard extra fields.
Class to manage generation of HTML components Only common components must be here.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='title_generic.png', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0)
Print a title with navigation controls for pagination.
img_warning($titlealt= 'default', $moreatt= '')
Show warning logo.
dol_fiche_end($notab=0)
Show tab footer of a card.
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Class to manage members of a foundation.
llxHeader()
Empty header.
Definition: wrapper.php:46
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
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...
dol_now($mode='gmt')
Return date for now.
Class to manage members type.
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
print
Draft customers invoices.
Definition: index.php:91
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->societe->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1013
Class to manage a WYSIWYG editor.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="")
Show title line of an array.
img_edit($titlealt= 'default', $float=0, $other= 'class="pictoedit"')
Show logo editer/modifier fiche.
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $objcanvas=null)
Check permissions of a user to show a page and an object.