dolibarr  7.0.0-beta
card.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
4  * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
5  * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
6  * Copyright (C) 2012 Marcos GarcĂ­a <marcosgdf@gmail.com>
7  * Copyright (C) 2012-2016 Philippe Grand <philippe.grand@atoo-net.com>
8  * Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
30 require '../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.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.'/adherents/class/subscription.class.php';
38 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
39 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
40 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
41 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
42 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
43 
44 $langs->load("companies");
45 $langs->load("bills");
46 $langs->load("members");
47 $langs->load("users");
48 $langs->load('other');
49 
50 $action=GETPOST('action','alpha');
51 $cancel=GETPOST('cancel','alpha');
52 $backtopage=GETPOST('backtopage','alpha');
53 $confirm=GETPOST('confirm','alpha');
54 $rowid=GETPOST('rowid','int');
55 $id=GETPOST('id')?GETPOST('id','int'):$rowid;
56 $typeid=GETPOST('typeid','int');
57 $userid=GETPOST('userid','int');
58 $socid=GETPOST('socid','int');
59 
60 if (! empty($conf->mailmanspip->enabled))
61 {
62  include_once DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php';
63 
64  $langs->load('mailmanspip');
65 
66  $mailmanspip = new MailmanSpip($db);
67 }
68 
69 $object = new Adherent($db);
70 $extrafields = new ExtraFields($db);
71 
72 // fetch optionals attributes and labels
73 $extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
74 
75 // Get object canvas (By default, this is not defined, so standard usage of dolibarr)
76 $object->getCanvas($id);
77 $canvas = $object->canvas?$object->canvas:GETPOST("canvas");
78 $objcanvas=null;
79 if (! empty($canvas))
80 {
81  require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
82  $objcanvas = new Canvas($db, $action);
83  $objcanvas->getCanvas('adherent', 'membercard', $canvas);
84 }
85 
86 // Security check
87 $result=restrictedArea($user, 'adherent', $id, '', '', 'fk_soc', 'rowid', $objcanvas);
88 
89 if ($id > 0)
90 {
91  // Load member
92  $result = $object->fetch($id);
93 
94  // Define variables to know what current user can do on users
95  $canadduser=($user->admin || $user->rights->user->user->creer);
96  // Define variables to know what current user can do on properties of user linked to edited member
97  if ($object->user_id)
98  {
99  // $ User is the user who edits, $ object->user_id is the id of the related user in the edited member
100  $caneditfielduser=((($user->id == $object->user_id) && $user->rights->user->self->creer)
101  || (($user->id != $object->user_id) && $user->rights->user->user->creer));
102  $caneditpassworduser=((($user->id == $object->user_id) && $user->rights->user->self->password)
103  || (($user->id != $object->user_id) && $user->rights->user->user->password));
104  }
105 }
106 
107 // Define variables to determine what the current user can do on the members
108 $canaddmember=$user->rights->adherent->creer;
109 // Define variables to determine what the current user can do on the properties of a member
110 if ($id)
111 {
112  $caneditfieldmember=$user->rights->adherent->creer;
113 }
114 
115 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
116 $hookmanager->initHooks(array('membercard','globalcard'));
117 
118 
119 
120 /*
121  * Actions
122  */
123 
124 $parameters=array('id'=>$id, 'rowid'=>$id, 'objcanvas'=>$objcanvas, 'confirm'=>$confirm);
125 $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
126 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
127 
128 if (empty($reshook))
129 {
130  if ($cancel)
131  {
132  if (! empty($backtopage))
133  {
134  header("Location: ".$backtopage);
135  exit;
136  }
137  $action='';
138  }
139 
140  if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer))
141  {
142  $error=0;
143  if (empty($user->rights->user->user->creer)) // If can edit only itself user, we can link to itself only
144  {
145  if ($userid != $user->id && $userid != $object->user_id)
146  {
147  $error++;
148  setEventMessages($langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly"), null, 'errors');
149  }
150  }
151 
152  if (! $error)
153  {
154  if ($userid != $object->user_id) // If link differs from currently in database
155  {
156  $result=$object->setUserId($userid);
157  if ($result < 0) dol_print_error($object->db,$object->error);
158  $action='';
159  }
160  }
161  }
162 
163  if ($action == 'setsocid')
164  {
165  $error=0;
166  if (! $error)
167  {
168  if ($socid != $object->fk_soc) // If link differs from currently in database
169  {
170  $sql ="SELECT rowid FROM ".MAIN_DB_PREFIX."adherent";
171  $sql.=" WHERE fk_soc = '".$socid."'";
172  $sql.=" AND entity = ".$conf->entity;
173  $resql = $db->query($sql);
174  if ($resql)
175  {
176  $obj = $db->fetch_object($resql);
177  if ($obj && $obj->rowid > 0)
178  {
179  $othermember=new Adherent($db);
180  $othermember->fetch($obj->rowid);
181  $thirdparty=new Societe($db);
182  $thirdparty->fetch($socid);
183  $error++;
184  setEventMessages($langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty",$othermember->getFullName($langs),$othermember->login,$thirdparty->name), null, 'errors');
185  }
186  }
187 
188  if (! $error)
189  {
190  $result=$object->setThirdPartyId($socid);
191  if ($result < 0) dol_print_error($object->db,$object->error);
192  $action='';
193  }
194  }
195  }
196  }
197 
198  // Create user from a member
199  if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user->user->creer)
200  {
201  if ($result > 0)
202  {
203  // Creation user
204  $nuser = new User($db);
205  $result=$nuser->create_from_member($object,GETPOST('login'));
206 
207  if ($result < 0)
208  {
209  $langs->load("errors");
210  setEventMessages($langs->trans($nuser->error), null, 'errors');
211  }
212  }
213  else
214  {
215  setEventMessages($object->errors, $object->error, 'errors');
216  }
217  }
218 
219  // Create third party from a member
220  if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer)
221  {
222  if ($result > 0)
223  {
224  // User creation
225  $company = new Societe($db);
226  $result=$company->create_from_member($object, GETPOST('companyname', 'alpha'), GETPOST('companyalias', 'alpha'));
227 
228  if ($result < 0)
229  {
230  $langs->load("errors");
231  setEventMessages($langs->trans($company->error), null, 'errors');
232  setEventMessages($company->error, $company->errors, 'errors');
233  }
234  }
235  else
236  {
237  setEventMessages($object->error, $object->errors, 'errors');
238  }
239  }
240 
241  /*
242  if ($action == 'confirm_sendinfo' && $confirm == 'yes')
243  {
244  if ($object->email)
245  {
246  $from=$conf->email_from;
247  if (! empty($conf->global->ADHERENT_MAIL_FROM)) $from=$conf->global->ADHERENT_MAIL_FROM;
248 
249  $result=$object->send_an_email($langs->transnoentitiesnoconv("ThisIsContentOfYourCard")."\n\n%INFOS%\n\n",$langs->transnoentitiesnoconv("CardContent"));
250 
251  $langs->load("mails");
252  setEventMessages($langs->trans("MailSuccessfulySent", $from, $object->email), null, 'mesgs');
253  }
254  }*/
255 
256  if ($action == 'update' && ! $cancel && $user->rights->adherent->creer)
257  {
258  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
259 
260  $birthdate='';
261  if (isset($_POST["birthday"]) && $_POST["birthday"]
262  && isset($_POST["birthmonth"]) && $_POST["birthmonth"]
263  && isset($_POST["birthyear"]) && $_POST["birthyear"])
264  {
265  $birthdate=dol_mktime(12, 0, 0, $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]);
266  }
267  $lastname=$_POST["lastname"];
268  $firstname=$_POST["firstname"];
269  $societe=$_POST["societe"];
270  $morphy=$_POST["morphy"];
271  $login=$_POST["login"];
272  if ($morphy != 'mor' && empty($lastname)) {
273  $error++;
274  $langs->load("errors");
275  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname")), null, 'errors');
276  }
277  if ($morphy != 'mor' && (!isset($firstname) || $firstname=='')) {
278  $error++;
279  $langs->load("errors");
280  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Firstname")), null, 'errors');
281  }
282  if ($morphy == 'mor' && empty($societe)) {
283  $error++;
284  $langs->load("errors");
285  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Company")), null, 'errors');
286  }
287  // Test si le login existe deja
288  if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
289  {
290  if (empty($login)) {
291  $error++;
292  setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Login")), null, 'errors');
293  }
294  }
295  // Create new object
296  if ($result > 0 && ! $error)
297  {
298  $object->oldcopy = clone $object;
299 
300  // Change values
301  $object->civility_id = trim($_POST["civility_id"]);
302  $object->firstname = trim($_POST["firstname"]);
303  $object->lastname = trim($_POST["lastname"]);
304  $object->login = trim($_POST["login"]);
305  $object->pass = trim($_POST["pass"]);
306 
307  $object->societe = trim($_POST["societe"]);
308  $object->company = trim($_POST["societe"]);
309 
310  $object->address = trim($_POST["address"]);
311  $object->zip = trim($_POST["zipcode"]);
312  $object->town = trim($_POST["town"]);
313  $object->state_id = $_POST["state_id"];
314  $object->country_id = $_POST["country_id"];
315 
316  $object->phone = trim($_POST["phone"]);
317  $object->phone_perso = trim($_POST["phone_perso"]);
318  $object->phone_mobile= trim($_POST["phone_mobile"]);
319  $object->email = trim($_POST["member_email"]);
320  $object->skype = trim($_POST["skype"]);
321  $object->birth = $birthdate;
322 
323  $object->typeid = $_POST["typeid"];
324  //$object->note = trim($_POST["comment"]);
325  $object->morphy = $_POST["morphy"];
326 
327  if (GETPOST('deletephoto')) $object->photo='';
328  elseif (! empty($_FILES['photo']['name'])) $object->photo = dol_sanitizeFileName($_FILES['photo']['name']);
329 
330  // Get status and public property
331  $object->statut = $_POST["statut"];
332  $object->public = $_POST["public"];
333 
334  // Fill array 'array_options' with data from add form
335  $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
336  if ($ret < 0) $error++;
337 
338  // Check if we need to also synchronize user information
339  $nosyncuser=0;
340  if ($object->user_id) // If linked to a user
341  {
342  if ($user->id != $object->user_id && empty($user->rights->user->user->creer)) $nosyncuser=1; // Disable synchronizing
343  }
344 
345  // Check if we need to also synchronize password information
346  $nosyncuserpass=0;
347  if ($object->user_id) // If linked to a user
348  {
349  if ($user->id != $object->user_id && empty($user->rights->user->user->password)) $nosyncuserpass=1; // Disable synchronizing
350  }
351 
352  $result=$object->update($user,0,$nosyncuser,$nosyncuserpass);
353 
354  if ($result >= 0 && ! count($object->errors))
355  {
356  $categories = GETPOST('memcats', 'array');
357  $object->setCategories($categories);
358 
359  // Logo/Photo save
360  $dir= $conf->adherent->dir_output . '/' . get_exdir(0,0,0,1,$object,'member').'/photos';
361  $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
362  if ($file_OK)
363  {
364  if (GETPOST('deletephoto'))
365  {
366  require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
367  $fileimg=$conf->adherent->dir_output.'/'.get_exdir(0,0,0,1,$object,'member').'/photos/'.$object->photo;
368  $dirthumbs=$conf->adherent->dir_output.'/'.get_exdir(0,0,0,1,$object,'member').'/photos/thumbs';
369  dol_delete_file($fileimg);
370  dol_delete_dir_recursive($dirthumbs);
371  }
372 
373  if (image_format_supported($_FILES['photo']['name']) > 0)
374  {
375  dol_mkdir($dir);
376 
377  if (@is_dir($dir))
378  {
379  $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
380  if (! dol_move_uploaded_file($_FILES['photo']['tmp_name'],$newfile,1,0,$_FILES['photo']['error']) > 0)
381  {
382  setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors');
383  }
384  else
385  {
386  // Create thumbs
387  $object->addThumbs($newfile);
388  }
389  }
390  }
391  else
392  {
393  setEventMessages("ErrorBadImageFormat", null, 'errors');
394  }
395  }
396  else
397  {
398  switch($_FILES['photo']['error'])
399  {
400  case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
401  case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
402  $errors[] = "ErrorFileSizeTooLarge";
403  break;
404  case 3: //uploaded file was only partially uploaded
405  $errors[] = "ErrorFilePartiallyUploaded";
406  break;
407  }
408  }
409 
410  $rowid=$object->id;
411  $id=$object->id;
412  $action='';
413 
414  if (! empty($backtopage))
415  {
416  header("Location: ".$backtopage);
417  exit;
418  }
419  }
420  else
421  {
422  setEventMessages($object->error, $object->errors, 'errors');
423  $action='';
424  }
425  }
426  else
427  {
428  $action='edit';
429  }
430  }
431 
432  if ($action == 'add' && $user->rights->adherent->creer)
433  {
434  if ($canvas) $object->canvas=$canvas;
435  $birthdate='';
436  if (isset($_POST["birthday"]) && $_POST["birthday"]
437  && isset($_POST["birthmonth"]) && $_POST["birthmonth"]
438  && isset($_POST["birthyear"]) && $_POST["birthyear"])
439  {
440  $birthdate=dol_mktime(12, 0, 0, $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]);
441  }
442  $datesubscription='';
443  if (isset($_POST["reday"]) && isset($_POST["remonth"]) && isset($_POST["reyear"]))
444  {
445  $datesubscription=dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
446  }
447 
448  $typeid=$_POST["typeid"];
449  $civility_id=$_POST["civility_id"];
450  $lastname=$_POST["lastname"];
451  $firstname=$_POST["firstname"];
452  $societe=$_POST["societe"];
453  $address=$_POST["address"];
454  $zip=$_POST["zipcode"];
455  $town=$_POST["town"];
456  $state_id=$_POST["state_id"];
457  $country_id=$_POST["country_id"];
458 
459  $phone=$_POST["phone"];
460  $phone_perso=$_POST["phone_perso"];
461  $phone_mobile=$_POST["phone_mobile"];
462  $skype=$_POST["member_skype"];
463  $email=$_POST["member_email"];
464  $login=$_POST["member_login"];
465  $pass=$_POST["password"];
466  $photo=$_POST["photo"];
467  //$comment=$_POST["comment"];
468  $morphy=$_POST["morphy"];
469  $subscription=$_POST["subscription"];
470  $public=$_POST["public"];
471 
472  $userid=$_POST["userid"];
473  $socid=$_POST["socid"];
474 
475  $object->civility_id = $civility_id;
476  $object->firstname = $firstname;
477  $object->lastname = $lastname;
478  $object->societe = $societe;
479  $object->address = $address;
480  $object->zip = $zip;
481  $object->town = $town;
482  $object->state_id = $state_id;
483  $object->country_id = $country_id;
484  $object->phone = $phone;
485  $object->phone_perso = $phone_perso;
486  $object->phone_mobile= $phone_mobile;
487  $object->skype = $skype;
488  $object->email = $email;
489  $object->login = $login;
490  $object->pass = $pass;
491  $object->birth = $birthdate;
492  $object->photo = $photo;
493  $object->typeid = $typeid;
494  //$object->note = $comment;
495  $object->morphy = $morphy;
496  $object->user_id = $userid;
497  $object->fk_soc = $socid;
498  $object->public = $public;
499 
500  // Fill array 'array_options' with data from add form
501  $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
502  if ($ret < 0) $error++;
503 
504  // Check parameters
505  if (empty($morphy) || $morphy == "-1") {
506  $error++;
507  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Nature")), null, 'errors');
508  }
509  // Tests if the login already exists
510  if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
511  {
512  if (empty($login)) {
513  $error++;
514  setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Login")), null, 'errors');
515  }
516  else {
517  $sql = "SELECT login FROM ".MAIN_DB_PREFIX."adherent WHERE login='".$db->escape($login)."'";
518  $result = $db->query($sql);
519  if ($result) {
520  $num = $db->num_rows($result);
521  }
522  if ($num) {
523  $error++;
524  $langs->load("errors");
525  setEventMessages($langs->trans("ErrorLoginAlreadyExists",$login), null, 'errors');
526  }
527  }
528  if (empty($pass)) {
529  $error++;
530  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Password")), null, 'errors');
531  }
532  }
533  if ($morphy == 'mor' && empty($societe)) {
534  $error++;
535  $langs->load("errors");
536  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Company")), null, 'errors');
537  }
538  if ($morphy != 'mor' && empty($lastname)) {
539  $error++;
540  $langs->load("errors");
541  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname")), null, 'errors');
542  }
543  if ($morphy != 'mor' && (!isset($firstname) || $firstname=='')) {
544  $error++;
545  $langs->load("errors");
546  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Firstname")), null, 'errors');
547  }
548  if (! ($typeid > 0)) { // Keep () before !
549  $error++;
550  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
551  }
552  if ($conf->global->ADHERENT_MAIL_REQUIRED && ! isValidEMail($email)) {
553  $error++;
554  $langs->load("errors");
555  setEventMessages($langs->trans("ErrorBadEMail",$email), null, 'errors');
556  }
557  $public=0;
558  if (isset($public)) $public=1;
559 
560  if (! $error)
561  {
562  $db->begin();
563 
564  // Email about right and login does not exist
565  $result=$object->create($user);
566  if ($result > 0)
567  {
568  // Foundation categories
569  $memcats = GETPOST('memcats', 'array');
570  $object->setCategories($memcats);
571 
572  $db->commit();
573  $rowid=$object->id;
574  $id=$object->id;
575  $action='';
576  }
577  else
578  {
579  $db->rollback();
580 
581  if ($object->error) {
582  setEventMessages($object->error, $object->errors, 'errors');
583  } else {
584  setEventMessages($object->error, $object->errors, 'errors');
585  }
586 
587  $action = 'create';
588  }
589  }
590  else {
591  $action = 'create';
592  }
593  }
594 
595  if ($user->rights->adherent->supprimer && $action == 'confirm_delete' && $confirm == 'yes')
596  {
597  $result=$object->delete($id, $user);
598  if ($result > 0)
599  {
600  if (! empty($backtopage))
601  {
602  header("Location: ".$backtopage);
603  exit;
604  }
605  else
606  {
607  header("Location: list.php");
608  exit;
609  }
610  }
611  else
612  {
613  $errmesg=$object->error;
614  }
615  }
616 
617  if ($user->rights->adherent->creer && $action == 'confirm_valid' && $confirm == 'yes')
618  {
619  $error=0;
620 
621  $db->begin();
622 
623  $adht = new AdherentType($db);
624  $adht->fetch($object->typeid);
625 
626  $result=$object->validate($user);
627 
628  if ($result >= 0 && ! count($object->errors))
629  {
630  // Send confirmation email (according to parameters of member type. Otherwise generic)
631  if ($object->email && GETPOST("send_mail"))
632  {
633  $result=$object->send_an_email($adht->getMailOnValid(),$conf->global->ADHERENT_MAIL_VALID_SUBJECT,array(),array(),array(),"","",0,2);
634  if ($result < 0)
635  {
636  $error++;
637  setEventMessages($object->error, $object->errors, 'errors');
638  }
639  }
640  }
641  else
642  {
643  $error++;
644  if ($object->error) {
645  setEventMessages($object->error, $object->errors, 'errors');
646  } else {
647  setEventMessages($object->error, $object->errors, 'errors');
648  }
649  }
650 
651  if (! $error)
652  {
653  $db->commit();
654  }
655  else
656  {
657  $db->rollback();
658  }
659  $action='';
660  }
661 
662  if ($user->rights->adherent->supprimer && $action == 'confirm_resign')
663  {
664  $error = 0;
665 
666  if ($confirm == 'yes')
667  {
668  $adht = new AdherentType($db);
669  $adht->fetch($object->typeid);
670 
671  $result=$object->resiliate($user);
672 
673  if ($result >= 0 && ! count($object->errors))
674  {
675  if ($object->email && GETPOST("send_mail"))
676  {
677  $result=$object->send_an_email($adht->getMailOnResiliate(),$conf->global->ADHERENT_MAIL_RESIL_SUBJECT,array(),array(),array(),"","",0,-1);
678  }
679  if ($result < 0)
680  {
681  $error++;
682  setEventMessages($object->error, $object->errors, 'errors');
683  }
684  }
685  else
686  {
687  $error++;
688 
689  if ($object->error) {
690  setEventMessages($object->error, $object->errors, 'errors');
691  } else {
692  setEventMessages($object->error, $object->errors, 'errors');
693  }
694  $action='';
695  }
696  }
697  if (! empty($backtopage) && ! $error)
698  {
699  header("Location: ".$backtopage);
700  exit;
701  }
702  }
703 
704  // SPIP Management
705  if ($user->rights->adherent->supprimer && $action == 'confirm_del_spip' && $confirm == 'yes')
706  {
707  if (! count($object->errors))
708  {
709  if (!$mailmanspip->del_to_spip($object))
710  {
711  setEventMessages($langs->trans('DeleteIntoSpipError').': '.$mailmanspip->error, null, 'errors');
712  }
713  }
714  }
715 
716  if ($user->rights->adherent->creer && $action == 'confirm_add_spip' && $confirm == 'yes')
717  {
718  if (! count($object->errors))
719  {
720  if (!$mailmanspip->add_to_spip($object))
721  {
722  setEventMessages($langs->trans('AddIntoSpipError').': '.$mailmanspip->error, null, 'errors');
723  }
724  }
725  }
726 
727  // Actions when printing a doc from card
728  include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
729 
730  // Actions to build doc
731  $upload_dir = $conf->adherent->dir_output;
732  $permissioncreate=$user->rights->adherent->creer;
733  include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
734 
735  // Actions to send emails
736  $trigger_name='MEMBER_SENTBYMAIL';
737  $paramname='id';
738  $mode='emailfrommember';
739  $trackid='mem'.$object->id;
740  include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
741 
742 }
743 
744 
745 /*
746  * View
747  */
748 
749 $form = new Form($db);
750 $formfile = new FormFile($db);
751 $formcompany = new FormCompany($db);
752 
753 $title=$langs->trans("Member") . " - " . $langs->trans("Card");
754 $help_url='EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
755 llxHeader('',$title,$help_url);
756 
757 $countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
758 
759 if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
760 {
761  // -----------------------------------------
762  // When used with CANVAS
763  // -----------------------------------------
764  if (empty($object->error) && $id)
765  {
766  $object = new Adherent($db);
767  $result=$object->fetch($id);
768  if ($result <= 0) dol_print_error('',$object->error);
769  }
770  $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates
771  $objcanvas->display_canvas($action); // Show template
772 }
773 else
774 {
775  // -----------------------------------------
776  // When used in standard mode
777  // -----------------------------------------
778 
779  if ($action == 'create')
780  {
781  /* ************************************************************************** */
782  /* */
783  /* Creation mode */
784  /* */
785  /* ************************************************************************** */
786  $object->canvas=$canvas;
787  $object->state_id = GETPOST('state_id', 'int');
788 
789  // We set country_id, country_code and country for the selected country
790  $object->country_id=GETPOST('country_id','int')?GETPOST('country_id','int'):$mysoc->country_id;
791  if ($object->country_id)
792  {
793  $tmparray=getCountry($object->country_id,'all');
794  $object->country_code=$tmparray['code'];
795  $object->country=$tmparray['label'];
796  }
797 
798  $adht = new AdherentType($db);
799 
800  print load_fiche_titre($langs->trans("NewMember"));
801 
802  if ($conf->use_javascript_ajax)
803  {
804  print "\n".'<script type="text/javascript" language="javascript">';
805  print 'jQuery(document).ready(function () {
806  jQuery("#selectcountry_id").change(function() {
807  document.formsoc.action.value="create";
808  document.formsoc.submit();
809  });
810  function initfieldrequired()
811  {
812  jQuery("#tdcompany").removeClass("fieldrequired");
813  jQuery("#tdlastname").removeClass("fieldrequired");
814  jQuery("#tdfirstname").removeClass("fieldrequired");
815  if (jQuery("#morphy").val() == \'mor\')
816  {
817  jQuery("#tdcompany").addClass("fieldrequired");
818  }
819  if (jQuery("#morphy").val() == \'phy\')
820  {
821  jQuery("#tdlastname").addClass("fieldrequired");
822  jQuery("#tdfirstname").addClass("fieldrequired");
823  }
824  }
825  jQuery("#morphy").change(function() {
826  initfieldrequired();
827  });
828  initfieldrequired();
829  })';
830  print '</script>'."\n";
831  }
832 
833  print '<form name="formsoc" action="'.$_SERVER["PHP_SELF"].'" method="post" enctype="multipart/form-data">';
834  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
835  print '<input type="hidden" name="action" value="add">';
836  if ($backtopage) print '<input type="hidden" name="backtopage" value="'.($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]).'">';
837 
838  dol_fiche_head('');
839 
840  print '<table class="border" width="100%">';
841  print '<tbody>';
842 
843  // Login
844  if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
845  {
846  print '<tr><td><span class="fieldrequired">'.$langs->trans("Login").' / '.$langs->trans("Id").'</span></td><td><input type="text" name="member_login" class="minwidth300" maxlength="50" value="'.(isset($_POST["member_login"])?GETPOST("member_login", 'alpha', 2):$object->login).'"></td></tr>';
847  }
848 
849  // Password
850  if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
851  {
852  require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
853  $generated_password=getRandomPassword(false);
854  print '<tr><td><span class="fieldrequired">'.$langs->trans("Password").'</span></td><td>';
855  print '<input type="text" class="minwidth300" maxlength="50" name="password" value="'.$generated_password.'">';
856  print '</td></tr>';
857  }
858 
859  // Type
860  print '<tr><td class="fieldrequired">'.$langs->trans("MemberType").'</td><td>';
861  $listetype=$adht->liste_array();
862  if (count($listetype))
863  {
864  print $form->selectarray("typeid", $listetype, GETPOST('typeid','int')?GETPOST('typeid','int'):$typeid, count($listetype)>1?1:0);
865  } else {
866  print '<font class="error">'.$langs->trans("NoTypeDefinedGoToSetup").'</font>';
867  }
868  print "</td>\n";
869 
870  // Morphy
871  $morphys["phy"] = $langs->trans("Physical");
872  $morphys["mor"] = $langs->trans("Moral");
873  print '<tr><td class="fieldrequired">'.$langs->trans("Nature")."</td><td>\n";
874  print $form->selectarray("morphy", $morphys, GETPOST('morphy','alpha')?GETPOST('morphy','alpha'):$object->morphy, 1);
875  print "</td>\n";
876 
877  // Company
878  print '<tr><td id="tdcompany">'.$langs->trans("Company").'</td><td><input type="text" name="societe" class="minwidth300" maxlength="128" value="'.(GETPOST('societe','alpha')?GETPOST('societe','alpha'):$object->societe).'"></td></tr>';
879 
880  // Civility
881  print '<tr><td>'.$langs->trans("UserTitle").'</td><td>';
882  print $formcompany->select_civility(GETPOST('civility_id','int')?GETPOST('civility_id','int'):$object->civility_id,'civility_id').'</td>';
883  print '</tr>';
884 
885  // Lastname
886  print '<tr><td id="tdlastname">'.$langs->trans("Lastname").'</td><td><input type="text" name="lastname" class="minwidth300" maxlength="50" value="'.(GETPOST('lastname','alpha')?GETPOST('lastname','alpha'):$object->lastname).'"></td>';
887  print '</tr>';
888 
889  // Firstname
890  print '<tr><td id="tdfirstname">'.$langs->trans("Firstname").'</td><td><input type="text" name="firstname" class="minwidth300" maxlength="50" value="'.(GETPOST('firstname','alpha')?GETPOST('firstname','alpha'):$object->firstname).'"></td>';
891  print '</tr>';
892 
893  // EMail
894  print '<tr><td>'.($conf->global->ADHERENT_MAIL_REQUIRED?'<span class="fieldrequired">':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'</span>':'').'</td><td><input type="text" name="member_email" class="minwidth300" maxlength="255" value="'.(GETPOST('member_email','alpha')?GETPOST('member_email','alpha'):$object->email).'"></td></tr>';
895 
896  // Address
897  print '<tr><td class="tdtop">'.$langs->trans("Address").'</td><td>';
898  print '<textarea name="address" wrap="soft" class="quatrevingtpercent" rows="2">'.(GETPOST('address','alpha')?GETPOST('address','alpha'):$object->address).'</textarea>';
899  print '</td></tr>';
900 
901  // Zip / Town
902  print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>';
903  print $formcompany->select_ziptown((GETPOST('zipcode','alpha')?GETPOST('zipcode','alpha'):$object->zip),'zipcode',array('town','selectcountry_id','state_id'),6);
904  print ' ';
905  print $formcompany->select_ziptown((GETPOST('town','alpha')?GETPOST('town','alpha'):$object->town),'town',array('zipcode','selectcountry_id','state_id'));
906  print '</td></tr>';
907 
908  // Country
909  $object->country_id=$object->country_id?$object->country_id:$mysoc->country_id;
910  print '<tr><td width="25%">'.$langs->trans('Country').'</td><td>';
911  print $form->select_country(GETPOST('country_id','alpha')?GETPOST('country_id','alpha'):$object->country_id,'country_id');
912  if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
913  print '</td></tr>';
914 
915  // State
916  if (empty($conf->global->MEMBER_DISABLE_STATE))
917  {
918  print '<tr><td>'.$langs->trans('State').'</td><td>';
919  if ($object->country_id)
920  {
921  print $formcompany->select_state(GETPOST('state_id','int')?GETPOST('state_id','int'):$object->state_id,$object->country_code);
922  }
923  else
924  {
925  print $countrynotdefined;
926  }
927  print '</td></tr>';
928  }
929 
930  // Pro phone
931  print '<tr><td>'.$langs->trans("PhonePro").'</td><td><input type="text" name="phone" size="20" value="'.(GETPOST('phone','alpha')?GETPOST('phone','alpha'):$object->phone).'"></td></tr>';
932 
933  // Personal phone
934  print '<tr><td>'.$langs->trans("PhonePerso").'</td><td><input type="text" name="phone_perso" size="20" value="'.(GETPOST('phone_perso','alpha')?GETPOST('phone_perso','alpha'):$object->phone_perso).'"></td></tr>';
935 
936  // Mobile phone
937  print '<tr><td>'.$langs->trans("PhoneMobile").'</td><td><input type="text" name="phone_mobile" size="20" value="'.(GETPOST('phone_mobile','alpha')?GETPOST('phone_mobile','alpha'):$object->phone_mobile).'"></td></tr>';
938 
939  // Skype
940  if (! empty($conf->skype->enabled))
941  {
942  print '<tr><td>'.$langs->trans("Skype").'</td><td><input type="text" name="member_skype" size="40" value="'.(GETPOST('member_skype','alpha')?GETPOST('member_skype','alpha'):$object->skype).'"></td></tr>';
943  }
944 
945  // Birthday
946  print "<tr><td>".$langs->trans("Birthday")."</td><td>\n";
947  $form->select_date(($object->birth ? $object->birth : -1),'birth','','',1,'formsoc');
948  print "</td></tr>\n";
949 
950  // Public profil
951  print "<tr><td>".$langs->trans("Public")."</td><td>\n";
952  print $form->selectyesno("public",$object->public,1);
953  print "</td></tr>\n";
954 
955  // Categories
956  if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire))
957  {
958  print '<tr><td>' . fieldLabel('Categories', 'memcars') . '</td><td>';
959  $cate_arbo = $form->select_all_categories(Categorie::TYPE_MEMBER, null, 'parent', null, null, 1);
960  print $form->multiselectarray('memcats', $cate_arbo, GETPOST('memcats', 'array'), null, null, null, null, '100%');
961  print "</td></tr>";
962  }
963 
964  // Other attributes
965  $parameters=array();
966  $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
967  print $hookmanager->resPrint;
968  if (empty($reshook) && ! empty($extrafields->attribute_label))
969  {
970  print $object->showOptionals($extrafields,'edit');
971  }
972 
973  print '<tbody>';
974  print "</table>\n";
975 
976  dol_fiche_end();
977 
978  print '<div class="center">';
979  print '<input type="submit" name="button" class="button" value="'.$langs->trans("AddMember").'">';
980  print '&nbsp;&nbsp;';
981  if (! empty($backtopage))
982  {
983  print '<input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'">';
984  }
985  else
986  {
987  print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
988  }
989  print '</div>';
990 
991  print "</form>\n";
992  }
993 
994  if ($action == 'edit')
995  {
996  /********************************************
997  *
998  * Edition mode
999  *
1000  ********************************************/
1001 
1002  $res=$object->fetch($id);
1003  if ($res < 0) {
1004  dol_print_error($db,$object->error); exit;
1005  }
1006  $res=$object->fetch_optionals($object->id,$extralabels);
1007  if ($res < 0) {
1008  dol_print_error($db); exit;
1009  }
1010 
1011  $adht = new AdherentType($db);
1012  $adht->fetch($object->typeid);
1013 
1014  // We set country_id, and country_code, country of the chosen country
1015  $country=GETPOST('country','int');
1016  if (!empty($country) || $object->country_id)
1017  {
1018  $sql = "SELECT rowid, code, label from ".MAIN_DB_PREFIX."c_country where rowid = ".(!empty($country)?$country:$object->country_id);
1019  $resql=$db->query($sql);
1020  if ($resql)
1021  {
1022  $obj = $db->fetch_object($resql);
1023  }
1024  else
1025  {
1026  dol_print_error($db);
1027  }
1028  $object->country_id=$obj->rowid;
1029  $object->country_code=$obj->code;
1030  $object->country=$langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->label;
1031  }
1032 
1033  $head = member_prepare_head($object);
1034 
1035 
1036  if ($conf->use_javascript_ajax)
1037  {
1038  print "\n".'<script type="text/javascript" language="javascript">';
1039  print 'jQuery(document).ready(function () {
1040  jQuery("#selectcountry_id").change(function() {
1041  document.formsoc.action.value="edit";
1042  document.formsoc.submit();
1043  });
1044  function initfieldrequired()
1045  {
1046  jQuery("#tdcompany").removeClass("fieldrequired");
1047  jQuery("#tdlastname").removeClass("fieldrequired");
1048  jQuery("#tdfirstname").removeClass("fieldrequired");
1049  if (jQuery("#morphy").val() == \'mor\')
1050  {
1051  jQuery("#tdcompany").addClass("fieldrequired");
1052  }
1053  if (jQuery("#morphy").val() == \'phy\')
1054  {
1055  jQuery("#tdlastname").addClass("fieldrequired");
1056  jQuery("#tdfirstname").addClass("fieldrequired");
1057  }
1058  }
1059  jQuery("#morphy").change(function() {
1060  initfieldrequired();
1061  });
1062  initfieldrequired();
1063  })';
1064  print '</script>'."\n";
1065  }
1066 
1067  print '<form name="formsoc" action="'.$_SERVER["PHP_SELF"].'" method="post" enctype="multipart/form-data">';
1068  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
1069  print '<input type="hidden" name="action" value="update" />';
1070  print '<input type="hidden" name="rowid" value="'.$id.'" />';
1071  print '<input type="hidden" name="statut" value="'.$object->statut.'" />';
1072  if ($backtopage) print '<input type="hidden" name="backtopage" value="'.($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]).'">';
1073 
1074  dol_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user');
1075 
1076  print '<table class="border" width="100%">';
1077 
1078  // Ref
1079  print '<tr><td class="titlefieldcreate">'.$langs->trans("Ref").'</td><td class="valeur">'.$object->id.'</td></tr>';
1080 
1081  // Login
1082  if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
1083  {
1084  print '<tr><td><span class="fieldrequired">'.$langs->trans("Login").' / '.$langs->trans("Id").'</span></td><td><input type="text" name="login" class="minwidth300" maxlength="50" value="'.(isset($_POST["login"])?GETPOST("login",'alpha',2):$object->login).'"></td></tr>';
1085  }
1086 
1087  // Password
1088  if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
1089  {
1090  print '<tr><td class="fieldrequired">'.$langs->trans("Password").'</td><td><input type="password" name="pass" class="minwidth300" maxlength="50" value="'.(isset($_POST["pass"])?GETPOST("pass",'',2):$object->pass).'"></td></tr>';
1091  }
1092  // Morphy
1093  $morphys["phy"] = $langs->trans("Physical");
1094  $morphys["mor"] = $langs->trans("Morale");
1095  print '<tr><td><span class="fieldrequired">'.$langs->trans("Nature").'</span></td><td>';
1096  print $form->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy);
1097  print "</td></tr>";
1098 
1099  // Type
1100  print '<tr><td class="fieldrequired">'.$langs->trans("Type").'</td><td>';
1101  if ($user->rights->adherent->creer)
1102  {
1103  print $form->selectarray("typeid", $adht->liste_array(), (isset($_POST["typeid"])?$_POST["typeid"]:$object->typeid));
1104  }
1105  else
1106  {
1107  print $adht->getNomUrl(1);
1108  print '<input type="hidden" name="typeid" value="'.$object->typeid.'">';
1109  }
1110  print "</td></tr>";
1111 
1112  // Company
1113  print '<tr><td id="tdcompany">'.$langs->trans("Company").'</td><td><input type="text" name="societe" class="minwidth300" maxlength="128" value="'.(isset($_POST["societe"])?GETPOST("societe",'',2):$object->societe).'"></td></tr>';
1114 
1115  // Civility
1116  print '<tr><td>'.$langs->trans("UserTitle").'</td><td>';
1117  print $formcompany->select_civility(isset($_POST["civility_id"])?$_POST["civility_id"]:$object->civility_id)."\n";
1118  print '</td>';
1119  print '</tr>';
1120 
1121  // Lastname
1122  print '<tr><td id="tdlastname">'.$langs->trans("Lastname").'</td><td><input type="text" name="lastname" class="minwidth300" maxlength="50" value="'.(isset($_POST["lastname"])?GETPOST("lastname",'',2):$object->lastname).'"></td>';
1123  print '</tr>';
1124 
1125  // Firstname
1126  print '<tr><td id="tdfirstname">'.$langs->trans("Firstname").'</td><td><input type="text" name="firstname" class="minwidth300" maxlength="50" value="'.(isset($_POST["firstname"])?GETPOST("firstname",'',3):$object->firstname).'"></td>';
1127  print '</tr>';
1128 
1129  // Photo
1130  print '<tr><td>'.$langs->trans("Photo").'</td>';
1131  print '<td class="hideonsmartphone" valign="middle">';
1132  print $form->showphoto('memberphoto',$object)."\n";
1133  if ($caneditfieldmember)
1134  {
1135  if ($object->photo) print "<br>\n";
1136  print '<table class="nobordernopadding">';
1137  if ($object->photo) print '<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
1138  print '<tr><td>'.$langs->trans("PhotoFile").'</td></tr>';
1139  print '<tr><td><input type="file" class="flat" name="photo" id="photoinput"></td></tr>';
1140  print '</table>';
1141  }
1142  print '</td></tr>';
1143 
1144  // EMail
1145  print '<tr><td>'.($conf->global->ADHERENT_MAIL_REQUIRED?'<span class="fieldrequired">':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'</span>':'').'</td><td><input type="text" name="member_email" class="minwidth300" maxlength="255" value="'.(isset($_POST["member_email"])?GETPOST("member_email",'',2):$object->email).'"></td></tr>';
1146 
1147  // Address
1148  print '<tr><td>'.$langs->trans("Address").'</td><td>';
1149  print '<textarea name="address" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_2.'">'.(isset($_POST["address"])?GETPOST("address",'',2):$object->address).'</textarea>';
1150  print '</td></tr>';
1151 
1152  // Zip / Town
1153  print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>';
1154  print $formcompany->select_ziptown((isset($_POST["zipcode"])?GETPOST("zipcode",'',2):$object->zip),'zipcode',array('town','selectcountry_id','state_id'),6);
1155  print ' ';
1156  print $formcompany->select_ziptown((isset($_POST["town"])?GETPOST("town",'',2):$object->town),'town',array('zipcode','selectcountry_id','state_id'));
1157  print '</td></tr>';
1158 
1159  // Country
1160  //$object->country_id=$object->country_id?$object->country_id:$mysoc->country_id; // In edit mode we don't force to company country if not defined
1161  print '<tr><td>'.$langs->trans('Country').'</td><td>';
1162  print $form->select_country(isset($_POST["country_id"])?$_POST["country_id"]:$object->country_id,'country_id');
1163  if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
1164  print '</td></tr>';
1165 
1166  // State
1167  if (empty($conf->global->MEMBER_DISABLE_STATE))
1168  {
1169  print '<tr><td>'.$langs->trans('State').'</td><td>';
1170  print $formcompany->select_state($object->state_id,isset($_POST["country_id"])?GETPOST("country_id"):$object->country_id);
1171  print '</td></tr>';
1172  }
1173 
1174  // Pro phone
1175  print '<tr><td>'.$langs->trans("PhonePro").'</td><td><input type="text" name="phone" size="20" value="'.(isset($_POST["phone"])?GETPOST("phone"):$object->phone).'"></td></tr>';
1176 
1177  // Personal phone
1178  print '<tr><td>'.$langs->trans("PhonePerso").'</td><td><input type="text" name="phone_perso" size="20" value="'.(isset($_POST["phone_perso"])?GETPOST("phone_perso"):$object->phone_perso).'"></td></tr>';
1179 
1180  // Mobile phone
1181  print '<tr><td>'.$langs->trans("PhoneMobile").'</td><td><input type="text" name="phone_mobile" size="20" value="'.(isset($_POST["phone_mobile"])?GETPOST("phone_mobile"):$object->phone_mobile).'"></td></tr>';
1182 
1183  // Skype
1184  if (! empty($conf->skype->enabled))
1185  {
1186  print '<tr><td>'.$langs->trans("Skype").'</td><td><input type="text" name="skype" class="minwidth100" value="'.(isset($_POST["skype"])?GETPOST("skype"):$object->skype).'"></td></tr>';
1187  }
1188 
1189  // Birthday
1190  print "<tr><td>".$langs->trans("Birthday")."</td><td>\n";
1191  $form->select_date(($object->birth ? $object->birth : -1),'birth','','',1,'formsoc');
1192  print "</td></tr>\n";
1193 
1194  // Public profil
1195  print "<tr><td>".$langs->trans("Public")."</td><td>\n";
1196  print $form->selectyesno("public",(isset($_POST["public"])?GETPOST("public",'',2):$object->public),1);
1197  print "</td></tr>\n";
1198 
1199  // Categories
1200  if (! empty( $conf->categorie->enabled ) && !empty( $user->rights->categorie->lire ))
1201  {
1202  print '<tr><td>' . fieldLabel('Categories', 'memcats') . '</td>';
1203  print '<td>';
1204  $cate_arbo = $form->select_all_categories(Categorie::TYPE_MEMBER, null, null, null, null, 1);
1205  $c = new Categorie($db);
1206  $cats = $c->containing($object->id, Categorie::TYPE_MEMBER);
1207  foreach ($cats as $cat) {
1208  $arrayselected[] = $cat->id;
1209  }
1210  print $form->multiselectarray('memcats', $cate_arbo, $arrayselected, '', 0, '', 0, '100%');
1211  print "</td></tr>";
1212  }
1213 
1214  // Third party Dolibarr
1215  if (! empty($conf->societe->enabled))
1216  {
1217  print '<tr><td>'.$langs->trans("LinkedToDolibarrThirdParty").'</td><td colspan="2" class="valeur">';
1218  if ($object->fk_soc)
1219  {
1220  $company=new Societe($db);
1221  $result=$company->fetch($object->fk_soc);
1222  print $company->getNomUrl(1);
1223  }
1224  else
1225  {
1226  print $langs->trans("NoThirdPartyAssociatedToMember");
1227  }
1228  print '</td></tr>';
1229  }
1230 
1231  // Login Dolibarr
1232  print '<tr><td>'.$langs->trans("LinkedToDolibarrUser").'</td><td colspan="2" class="valeur">';
1233  if ($object->user_id)
1234  {
1235  $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'none');
1236  }
1237  else print $langs->trans("NoDolibarrAccess");
1238  print '</td></tr>';
1239 
1240  // Other attributes
1241  $parameters=array();
1242  $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
1243  print $hookmanager->resPrint;
1244  if (empty($reshook) && ! empty($extrafields->attribute_label))
1245  {
1246  print $object->showOptionals($extrafields,'edit',$parameters);
1247  }
1248 
1249  print '</table>';
1250 
1251  dol_fiche_end();
1252 
1253  print '<div class="center">';
1254  print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
1255  print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1256  print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
1257  print '</div>';
1258 
1259  print '</form>';
1260 
1261  }
1262 
1263  if ($id > 0 && $action != 'edit')
1264  {
1265  /* ************************************************************************** */
1266  /* */
1267  /* View mode */
1268  /* */
1269  /* ************************************************************************** */
1270 
1271  $res=$object->fetch($id);
1272  if ($res < 0) {
1273  dol_print_error($db,$object->error); exit;
1274  }
1275  $res=$object->fetch_optionals($object->id,$extralabels);
1276  if ($res < 0) {
1277  dol_print_error($db); exit;
1278  }
1279 
1280  $adht = new AdherentType($db);
1281  $res=$adht->fetch($object->typeid);
1282  if ($res < 0) {
1283  dol_print_error($db); exit;
1284  }
1285 
1286 
1287  /*
1288  * Show tabs
1289  */
1290  $head = member_prepare_head($object);
1291 
1292  dol_fiche_head($head, 'general', $langs->trans("Member"), -1, 'user');
1293 
1294  // Confirm create user
1295  if ($action == 'create_user')
1296  {
1297  $login=$object->login;
1298  if (empty($login))
1299  {
1300  // Full firstname and name separated with a dot : firstname.name
1301  include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
1302  $login=dol_buildlogin($object->lastname,$object->firstname);
1303  }
1304  if (empty($login)) $login=strtolower(substr($object->firstname, 0, 4)) . strtolower(substr($object->lastname, 0, 4));
1305 
1306  // Create a form array
1307  $formquestion=array(
1308  array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login)
1309  );
1310  $text=$langs->trans("ConfirmCreateLogin").'<br>';
1311  if (! empty($conf->societe->enabled))
1312  {
1313  if ($object->fk_soc > 0) $text.=$langs->trans("UserWillBeExternalUser");
1314  else $text.=$langs->trans("UserWillBeInternalUser");
1315  }
1316  print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id,$langs->trans("CreateDolibarrLogin"),$text,"confirm_create_user",$formquestion,'yes');
1317  }
1318 
1319  // Confirm create third party
1320  if ($action == 'create_thirdparty')
1321  {
1322  $companyalias='';
1323  $fullname = $object->getFullName($langs);
1324 
1325  if ($object->morphy == 'mor')
1326  {
1327  $companyname=$object->societe;
1328  if (! empty($fullname)) $companyalias=$fullname;
1329  }
1330  else
1331  {
1332  $companyname=$fullname;
1333  if (! empty($object->societe)) $companyalias=$object->societe;
1334  }
1335 
1336  // Create a form array
1337  $formquestion=array(
1338  array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $companyname, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"'),
1339  array('label' => $langs->trans("AliasNames"), 'type' => 'text', 'name' => 'companyalias', 'value' => $companyalias, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"')
1340  );
1341 
1342  print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id,$langs->trans("CreateDolibarrThirdParty"),$langs->trans("ConfirmCreateThirdParty"),"confirm_create_thirdparty",$formquestion,1);
1343  }
1344 
1345  // Confirm validate member
1346  if ($action == 'valid')
1347  {
1348  $langs->load("mails");
1349 
1350  $adht = new AdherentType($db);
1351  $adht->fetch($object->typeid);
1352 
1353  $subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_VALID_SUBJECT);
1354  $texttosend=$object->makeSubstitution($adht->getMailOnValid());
1355 
1356  $tmp=$langs->trans("SendAnEMailToMember");
1357  $tmp.='<br>'.$langs->trans("MailFrom").': <b>'.$conf->global->ADHERENT_MAIL_FROM.'</b>, ';
1358  $tmp.='<br>'.$langs->trans("MailRecipient").': <b>'.$object->email.'</b>';
1359  $helpcontent='';
1360  $helpcontent.='<b>'.$langs->trans("MailFrom").'</b>: '.$conf->global->ADHERENT_MAIL_FROM.'<br>'."\n";
1361  $helpcontent.='<b>'.$langs->trans("MailRecipient").'</b>: '.$object->email.'<br>'."\n";
1362  $helpcontent.='<b>'.$langs->trans("Subject").'</b>:<br>'."\n";
1363  $helpcontent.=$subjecttosend."\n";
1364  $helpcontent.="<br>";
1365  $helpcontent.='<b>'.$langs->trans("Content").'</b>:<br>';
1366  $helpcontent.=dol_htmlentitiesbr($texttosend)."\n";
1367  $label=$form->textwithpicto($tmp,$helpcontent,1,'help');
1368 
1369  // Create form popup
1370  $formquestion=array();
1371  if ($object->email) $formquestion[]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => ($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL?true:false));
1372  if (! empty($conf->mailman->enabled) && ! empty($conf->global->ADHERENT_USE_MAILMAN)) {
1373  $formquestion[]=array('type'=>'other','label'=>$langs->transnoentitiesnoconv("SynchroMailManEnabled"),'value'=>'');
1374  }
1375  if (! empty($conf->mailman->enabled) && ! empty($conf->global->ADHERENT_USE_SPIP)) {
1376  $formquestion[]=array('type'=>'other','label'=>$langs->transnoentitiesnoconv("SynchroSpipEnabled"),'value'=>'');
1377  }
1378  print $form->formconfirm("card.php?rowid=".$id,$langs->trans("ValidateMember"),$langs->trans("ConfirmValidateMember"),"confirm_valid",$formquestion,1,1);
1379  }
1380 
1381  // Confirm send card by mail
1382  /*if ($action == 'sendinfo')
1383  {
1384  print $form->formconfirm("card.php?rowid=".$id,$langs->trans("SendCardByMail"),$langs->trans("ConfirmSendCardByMail",$object->email),"confirm_sendinfo",'',0,1);
1385  }*/
1386 
1387  // Confirm terminate
1388  if ($action == 'resign')
1389  {
1390  $langs->load("mails");
1391 
1392  $adht = new AdherentType($db);
1393  $adht->fetch($object->typeid);
1394 
1395  $subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_RESIL_SUBJECT);
1396  $texttosend=$object->makeSubstitution($adht->getMailOnResiliate());
1397 
1398  $tmp=$langs->trans("SendAnEMailToMember");
1399  $tmp.='<br>('.$langs->trans("MailFrom").': <b>'.$conf->global->ADHERENT_MAIL_FROM.'</b>, ';
1400  $tmp.=$langs->trans("MailRecipient").': <b>'.$object->email.'</b>)';
1401  $helpcontent='';
1402  $helpcontent.='<b>'.$langs->trans("MailFrom").'</b>: '.$conf->global->ADHERENT_MAIL_FROM.'<br>'."\n";
1403  $helpcontent.='<b>'.$langs->trans("MailRecipient").'</b>: '.$object->email.'<br>'."\n";
1404  $helpcontent.='<b>'.$langs->trans("Subject").'</b>:<br>'."\n";
1405  $helpcontent.=$subjecttosend."\n";
1406  $helpcontent.="<br>";
1407  $helpcontent.='<b>'.$langs->trans("Content").'</b>:<br>';
1408  $helpcontent.=dol_htmlentitiesbr($texttosend)."\n";
1409  $label=$form->textwithpicto($tmp,$helpcontent,1,'help');
1410 
1411  // Create an array
1412  $formquestion=array();
1413  if ($object->email) $formquestion[]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => (! empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL)?'true':'false'));
1414  if ($backtopage) $formquestion[]=array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]));
1415  print $form->formconfirm("card.php?rowid=".$id,$langs->trans("ResiliateMember"),$langs->trans("ConfirmResiliateMember"),"confirm_resign",$formquestion,'no',1);
1416  }
1417 
1418  // Confirm remove member
1419  if ($action == 'delete')
1420  {
1421  $formquestion=array();
1422  if ($backtopage) $formquestion[]=array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]));
1423  print $form->formconfirm("card.php?rowid=".$id,$langs->trans("DeleteMember"),$langs->trans("ConfirmDeleteMember"),"confirm_delete",$formquestion,0,1);
1424  }
1425 
1426  // Confirm add in spip
1427  if ($action == 'add_spip')
1428  {
1429  print $form->formconfirm("card.php?rowid=".$id, $langs->trans('AddIntoSpip'), $langs->trans('AddIntoSpipConfirmation'), 'confirm_add_spip');
1430  }
1431  // Confirm removed from spip
1432  if ($action == 'del_spip')
1433  {
1434  print $form->formconfirm("card.php?rowid=$id", $langs->trans('DeleteIntoSpip'), $langs->trans('DeleteIntoSpipConfirmation'), 'confirm_del_spip');
1435  }
1436 
1437  $rowspan=17;
1438  if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan++;
1439  if (! empty($conf->societe->enabled)) $rowspan++;
1440 
1441  $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
1442 
1443  dol_banner_tab($object, 'rowid', $linkback);
1444 
1445  print '<div class="fichecenter">';
1446  print '<div class="fichehalfleft">';
1447 
1448  print '<div class="underbanner clearboth"></div>';
1449  print '<table class="border centpercent">';
1450 
1451  // Login
1452  if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
1453  {
1454  print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$object->login.'&nbsp;</td></tr>';
1455  }
1456 
1457  // Type
1458  print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td class="valeur">'.$adht->getNomUrl(1)."</td></tr>\n";
1459 
1460  // Morphy
1461  print '<tr><td>'.$langs->trans("Nature").'</td><td class="valeur" >'.$object->getmorphylib().'</td>';
1462  print '</tr>';
1463 
1464  // Company
1465  print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->societe.'</td></tr>';
1466 
1467  // Civility
1468  print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'&nbsp;</td>';
1469  print '</tr>';
1470 
1471  // Password
1472  if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
1473  {
1474  print '<tr><td>'.$langs->trans("Password").'</td><td>'.preg_replace('/./i','*',$object->pass);
1475  if ($object->pass) print preg_replace('/./i','*',$object->pass);
1476  else
1477  {
1478  if ($user->admin) print $langs->trans("Crypted").': '.$object->pass_indatabase_crypted;
1479  else print $langs->trans("Hidden");
1480  }
1481  if ((! empty($object->pass) || ! empty($object->pass_crypted)) && empty($object->user_id))
1482  {
1483  $langs->load("errors");
1484  $htmltext=$langs->trans("WarningPasswordSetWithNoAccount");
1485  print ' '.$form->textwithpicto('', $htmltext,1,'warning');
1486  }
1487  print '</td></tr>';
1488  }
1489 
1490  // Date end subscription
1491  print '<tr><td>'.$langs->trans("SubscriptionEndDate").'</td><td class="valeur">';
1492  if ($object->datefin)
1493  {
1494  print dol_print_date($object->datefin,'day');
1495  if ($object->hasDelay()) {
1496  print " ".img_warning($langs->trans("Late"));
1497  }
1498  }
1499  else
1500  {
1501  if (! $adht->subscription)
1502  {
1503  print $langs->trans("SubscriptionNotRecorded");
1504  if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft and not terminated
1505  }
1506  else
1507  {
1508  print $langs->trans("SubscriptionNotReceived");
1509  if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft and not terminated
1510  }
1511  }
1512  print '</td></tr>';
1513 
1514  // Third party Dolibarr
1515  if (! empty($conf->societe->enabled))
1516  {
1517  print '<tr><td>';
1518  print '<table class="nobordernopadding" width="100%"><tr><td>';
1519  print $langs->trans("LinkedToDolibarrThirdParty");
1520  print '</td>';
1521  if ($action != 'editthirdparty' && $user->rights->adherent->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editthirdparty&amp;rowid='.$object->id.'">'.img_edit($langs->trans('SetLinkToThirdParty'),1).'</a></td>';
1522  print '</tr></table>';
1523  print '</td><td colspan="2" class="valeur">';
1524  if ($action == 'editthirdparty')
1525  {
1526  $htmlname='socid';
1527  print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" name="form'.$htmlname.'">';
1528  print '<input type="hidden" name="rowid" value="'.$object->id.'">';
1529  print '<input type="hidden" name="action" value="set'.$htmlname.'">';
1530  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
1531  print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
1532  print '<tr><td>';
1533  print $form->select_company($object->fk_soc,'socid','',1);
1534  print '</td>';
1535  print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
1536  print '</tr></table></form>';
1537  }
1538  else
1539  {
1540  if ($object->fk_soc)
1541  {
1542  $company=new Societe($db);
1543  $result=$company->fetch($object->fk_soc);
1544  print $company->getNomUrl(1);
1545  }
1546  else
1547  {
1548  print $langs->trans("NoThirdPartyAssociatedToMember");
1549  }
1550  }
1551  print '</td></tr>';
1552  }
1553 
1554  // Login Dolibarr
1555  print '<tr><td>';
1556  print '<table class="nobordernopadding" width="100%"><tr><td>';
1557  print $langs->trans("LinkedToDolibarrUser");
1558  print '</td>';
1559  if ($action != 'editlogin' && $user->rights->adherent->creer)
1560  {
1561  print '<td align="right">';
1562  if ($user->rights->user->user->creer)
1563  {
1564  print '<a href="'.$_SERVER["PHP_SELF"].'?action=editlogin&amp;rowid='.$object->id.'">'.img_edit($langs->trans('SetLinkToUser'),1).'</a>';
1565  }
1566  print '</td>';
1567  }
1568  print '</tr></table>';
1569  print '</td><td colspan="2" class="valeur">';
1570  if ($action == 'editlogin')
1571  {
1572  $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'userid','');
1573  }
1574  else
1575  {
1576  if ($object->user_id)
1577  {
1578  $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'none');
1579  }
1580  else print $langs->trans("NoDolibarrAccess");
1581  }
1582  print '</td></tr>';
1583 
1584  print '</table>';
1585 
1586  print '</div>';
1587  print '<div class="fichehalfright"><div class="ficheaddleft">';
1588 
1589  print '<div class="underbanner clearboth"></div>';
1590  print '<table class="border tableforfield" width="100%">';
1591 
1592  // Birthday
1593  print '<tr><td class="titlefield">'.$langs->trans("Birthday").'</td><td class="valeur">'.dol_print_date($object->birth,'day').'</td></tr>';
1594 
1595  // Public
1596  print '<tr><td>'.$langs->trans("Public").'</td><td class="valeur">'.yn($object->public).'</td></tr>';
1597 
1598  // Categories
1599  if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire))
1600  {
1601  print '<tr><td>' . $langs->trans("Categories") . '</td>';
1602  print '<td colspan="2">';
1603  print $form->showCategories($object->id, 'member', 1);
1604  print '</td></tr>';
1605  }
1606 
1607  // Other attributes
1608  include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
1609 
1610  print "</table>\n";
1611 
1612  print "</div></div></div>\n";
1613  print '<div style="clear:both"></div>';
1614 
1615  dol_fiche_end();
1616 
1617 
1618  /*
1619  * Hotbar
1620  */
1621 
1622  print '<div class="tabsAction">';
1623  $parameters = array();
1624  $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
1625  if (empty($reshook)) {
1626  if ($action != 'valid' && $action != 'editlogin' && $action != 'editthirdparty')
1627  {
1628  // Send
1629  if ($object->statut == 1) {
1630  print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendByMail') . '</a></div>';
1631  }
1632 
1633  // Send card by email
1634  // TODO Remove this to replace with a template
1635  /*
1636  if ($user->rights->adherent->creer)
1637  {
1638  if ($object->statut >= 1)
1639  {
1640  if ($object->email) print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$object->id.'&action=sendinfo">'.$langs->trans("SendCardByMail")."</a></div>\n";
1641  else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NoEMail")).'">'.$langs->trans("SendCardByMail")."</a></div>\n";
1642  }
1643  else
1644  {
1645  print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("SendCardByMail")."</font></div>";
1646  }
1647  }
1648  else
1649  {
1650  print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("SendCardByMail")."</font></div>";
1651  }*/
1652 
1653  // Modify
1654  if ($user->rights->adherent->creer)
1655  {
1656  print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$id.'&action=edit">'.$langs->trans("Modify")."</a></div>";
1657  }
1658  else
1659  {
1660  print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Modify").'</font></div>';
1661  }
1662 
1663  // Validate
1664  if ($object->statut == -1)
1665  {
1666  if ($user->rights->adherent->creer)
1667  {
1668  print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$id.'&action=valid">'.$langs->trans("Validate")."</a></div>\n";
1669  }
1670  else
1671  {
1672  print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Validate").'</font></div>';
1673  }
1674  }
1675 
1676  // Reactivate
1677  if ($object->statut == 0)
1678  {
1679  if ($user->rights->adherent->creer)
1680  {
1681  print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$id.'&action=valid">'.$langs->trans("Reenable")."</a></div>\n";
1682  }
1683  else
1684  {
1685  print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Reenable")."</font></div>";
1686  }
1687  }
1688 
1689  // Terminate
1690  if ($object->statut >= 1)
1691  {
1692  if ($user->rights->adherent->supprimer)
1693  {
1694  print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$id.'&action=resign">'.$langs->trans("Resiliate")."</a></div>\n";
1695  }
1696  else
1697  {
1698  print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Resiliate")."</font></div>";
1699  }
1700  }
1701 
1702  // Create third party
1703  if (! empty($conf->societe->enabled) && ! $object->fk_soc)
1704  {
1705  if ($user->rights->societe->creer)
1706  {
1707  if ($object->statut != -1) print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&amp;action=create_thirdparty">'.$langs->trans("CreateDolibarrThirdParty").'</a></div>';
1708  else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("CreateDolibarrThirdParty").'</a></div>';
1709  }
1710  else
1711  {
1712  print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("CreateDolibarrThirdParty")."</font></div>";
1713  }
1714  }
1715 
1716  // Create user
1717  if (! $user->societe_id && ! $object->user_id)
1718  {
1719  if ($user->rights->user->user->creer)
1720  {
1721  if ($object->statut != -1) print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&amp;action=create_user">'.$langs->trans("CreateDolibarrLogin").'</a></div>';
1722  else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("CreateDolibarrLogin").'</a></div>';
1723  }
1724  else
1725  {
1726  print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("CreateDolibarrLogin")."</font></div>";
1727  }
1728  }
1729 
1730  // Delete
1731  if ($user->rights->adherent->supprimer)
1732  {
1733  print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?rowid='.$object->id.'&action=delete">'.$langs->trans("Delete")."</a></div>\n";
1734  }
1735  else
1736  {
1737  print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Delete")."</font></div>";
1738  }
1739 
1740  // Action SPIP
1741  if (! empty($conf->mailmanspip->enabled) && ! empty($conf->global->ADHERENT_USE_SPIP))
1742  {
1743  $isinspip = $mailmanspip->is_in_spip($object);
1744 
1745  if ($isinspip == 1)
1746  {
1747  print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$object->id.'&action=del_spip">'.$langs->trans("DeleteIntoSpip")."</a></div>\n";
1748  }
1749  if ($isinspip == 0)
1750  {
1751  print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$object->id.'&action=add_spip">'.$langs->trans("AddIntoSpip")."</a></div>\n";
1752  }
1753  }
1754 
1755  }
1756  }
1757  print '</div>';
1758 
1759  if ($isinspip == -1)
1760  {
1761  print '<br><br><font class="error">'.$langs->trans('SPIPConnectionFailed').': '.$mailmanspip->error.'</font>';
1762  }
1763 
1764 
1765  // Select mail models is same action as presend
1766  if (GETPOST('modelselected')) {
1767  $action = 'presend';
1768  }
1769 
1770  if ($action != 'presend')
1771  {
1772  print '<div class="fichecenter"><div class="fichehalfleft">';
1773  print '<a name="builddoc"></a>'; // ancre
1774 
1775  // Documents generes
1776  $filename = dol_sanitizeFileName($object->ref);
1777  //$filename = 'tmp_cards.php';
1778  //$filedir = $conf->adherent->dir_output . '/' . get_exdir($object->id, 2, 0, 0, $object, 'member') . dol_sanitizeFileName($object->ref);
1779  $filedir = $conf->adherent->dir_output . '/' . get_exdir(0, 0, 0, 0, $object, 'member');
1780  $urlsource = $_SERVER['PHP_SELF'] . '?id=' . $object->id;
1781  $genallowed = $user->rights->adherent->lire;
1782  $delallowed = $user->rights->adherent->creer;
1783 
1784  print $formfile->showdocuments('member', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $object->default_lang, '', $object);
1785  $somethingshown = $formfile->numoffiles;
1786 
1787  // Show links to link elements
1788  //$linktoelem = $form->showLinkToObjectBlock($object, null, array('subscription'));
1789  //$somethingshown = $form->showLinkedObjectBlock($object, '');
1790 
1791  // Show links to link elements
1792  /*$linktoelem = $form->showLinkToObjectBlock($object,array('order'));
1793  if ($linktoelem) print ($somethingshown?'':'<br>').$linktoelem;
1794  */
1795 
1796  // Shon online payment link
1797  $useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled));
1798 
1799  if ($useonlinepayment)
1800  {
1801  print '<br>';
1802 
1803  require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
1804  print showOnlinePaymentUrl('membersubscription', $object->ref);
1805  }
1806 
1807  print '</div><div class="fichehalfright"><div class="ficheaddleft">';
1808 
1809  $MAX = 10;
1810 
1811  $morehtmlright = '<a href="'.DOL_URL_ROOT.'/adherents/agenda.php?id='.$object->id.'">';
1812  $morehtmlright.= $langs->trans("SeeAll");
1813  $morehtmlright.= '</a>';
1814 
1815  // List of actions on element
1816  include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
1817  $formactions = new FormActions($db);
1818  $somethingshown = $formactions->showactions($object, 'member', $socid, 1, 'listactions', $MAX, '', $morehtmlright);
1819 
1820  print '</div></div></div>';
1821  }
1822 
1823  // Presend form
1824  $modelmail='member';
1825  $defaulttopic='SendMemberRef';
1826  $diroutput = $conf->adherent->dir_output;
1827  $trackid = 'mem'.$object->id;
1828 
1829  include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
1830  }
1831 }
1832 
1833 llxFooter();
1834 
1835 $db->close();
image_format_supported($file)
Return if a filename is file name of a supported image format.
Definition: images.lib.php:38
llxFooter()
Empty footer.
Definition: wrapper.php:58
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0, $nohook=0, $varfiles='addedfile')
Make control on an uploaded file from an GUI page and move it to final destination.
Definition: files.lib.php:962
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
Class to manage building of HTML components.
Class to manage canvas.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm=false, $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
Show tab header of a card.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart)
Return a path to have a the directory according to object where files are stored. ...
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.
Class to manage Dolibarr users.
Definition: user.class.php:39
member_prepare_head(Adherent $object)
Return array head with list of tabs to view object informations.
Definition: member.lib.php:33
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
dol_buildlogin($lastname, $firstname)
Build a login from lastname, firstname.
if(empty($reshook)) $form
View.
Definition: perms.php:103
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to build HTML component for third parties management Only common components are here...
Class to manage standard extra fields.
Class to manage generation of HTML components Only common components must be here.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1')
Show information for admin users or standard users.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage categories.
if($_POST["cancel"]==$langs->trans("Cancel")&&!$id) if($action== 'setdatev'&&$user->rights->tax->charges->creer) if($action== 'add'&&$_POST["cancel"]<> $langs->trans("Cancel")) if($action== 'delete') $title
Actions.
Definition: card.php:183
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.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories) ...
Definition: files.lib.php:1234
Class to manage members of a foundation.
llxHeader()
Empty header.
Definition: wrapper.php:46
Class to offer components to list and upload files.
Class to manage members type.
getRandomPassword($generic=false)
Return a generated password using default module.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:104
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(preg_match('/set_(.*)/', $action, $reg)) if(preg_match('/del_(.*)/', $action, $reg)) if($action== 'set') else if($action== 'specimen') else if($action== 'setmodel') else if($action== 'del') else if($action== 'setdoc' $formactions)
View.
dol_mkdir($dir, $dataroot='', $newmask=null)
Creation of a directory (this can create recursive subdir)
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
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null)
Remove a file or several files with a mask.
Definition: files.lib.php:1103
fieldLabel($langkey, $fieldkey, $fieldrequired=0)
Show a string with the label tag dedicated to the HTML edit field.
Class to manage mailman and spip.
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.
$parameters
Actions.
Definition: card.php:112