dolibarr 19.0.3
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-2018 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
7 * Copyright (C) 2012-2020 Philippe Grand <philippe.grand@atoo-net.com>
8 * Copyright (C) 2015-2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
9 * Copyright (C) 2018-2022 Frédéric France <frederic.france@netlogic.fr>
10 * Copyright (C) 2021 Waël Almoman <info@almoman.com>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <https://www.gnu.org/licenses/>.
24 */
25
33// Load Dolibarr environment
34require '../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
36require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
37require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
38require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
39require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
40require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
41require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
42require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
43require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
44require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
45require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
46require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
47require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
48
49
50// Load translation files required by the page
51$langs->loadLangs(array("companies", "bills", "members", "users", "other", "paypal"));
52
53
54// Get parameters
55$action = GETPOST('action', 'aZ09');
56$cancel = GETPOST('cancel', 'alpha');
57$backtopage = GETPOST('backtopage', 'alpha');
58$confirm = GETPOST('confirm', 'alpha');
59$rowid = GETPOST('rowid', 'int');
60$id = GETPOST('id') ? GETPOST('id', 'int') : $rowid;
61$typeid = GETPOST('typeid', 'int');
62$userid = GETPOST('userid', 'int');
63$socid = GETPOST('socid', 'int');
64$ref = GETPOST('ref', 'alpha');
65
66if (isModEnabled('mailmanspip')) {
67 include_once DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php';
68
69 $langs->load('mailmanspip');
70
71 $mailmanspip = new MailmanSpip($db);
72}
73
74$object = new Adherent($db);
75$extrafields = new ExtraFields($db);
76
77// fetch optionals attributes and labels
78$extrafields->fetch_name_optionals_label($object->table_element);
79
80$socialnetworks = getArrayOfSocialNetworks();
81
82// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
83$object->getCanvas($id);
84$canvas = $object->canvas ? $object->canvas : GETPOST("canvas");
85$objcanvas = null;
86if (!empty($canvas)) {
87 require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
88 $objcanvas = new Canvas($db, $action);
89 $objcanvas->getCanvas('adherent', 'membercard', $canvas);
90}
91
92// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
93$hookmanager->initHooks(array('membercard', 'globalcard'));
94
95// Fetch object
96if ($id > 0 || !empty($ref)) {
97 // Load member
98 $result = $object->fetch($id, $ref);
99
100 // Define variables to know what current user can do on users
101 $canadduser = ($user->admin || $user->hasRight('user', 'user', 'creer'));
102 // Define variables to know what current user can do on properties of user linked to edited member
103 if ($object->user_id) {
104 // $User is the user who edits, $object->user_id is the id of the related user in the edited member
105 $caneditfielduser = ((($user->id == $object->user_id) && $user->hasRight('user', 'self', 'creer'))
106 || (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'creer')));
107 $caneditpassworduser = ((($user->id == $object->user_id) && $user->hasRight('user', 'self', 'password'))
108 || (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'password')));
109 }
110}
111
112// Define variables to determine what the current user can do on the members
113$canaddmember = $user->hasRight('adherent', 'creer');
114// Define variables to determine what the current user can do on the properties of a member
115if ($id) {
116 $caneditfieldmember = $user->hasRight('adherent', 'creer');
117}
118
119// Security check
120$result = restrictedArea($user, 'adherent', $object->id, '', '', 'socid', 'rowid', 0);
121
122if (!$user->hasRight('adherent', 'creer') && $action == 'edit') {
123 accessforbidden('Not enough permission');
124}
125
126$linkofpubliclist = DOL_MAIN_URL_ROOT.'/public/members/public_list.php'.((isModEnabled('multicompany')) ? '?entity='.$conf->entity : '');
127
128
129/*
130 * Actions
131 */
132
133$parameters = array('id'=>$id, 'rowid'=>$id, 'objcanvas'=>$objcanvas, 'confirm'=>$confirm);
134$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
135if ($reshook < 0) {
136 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
137}
138
139if (empty($reshook)) {
140 $backurlforlist = DOL_URL_ROOT.'/adherents/list.php';
141
142 if (empty($backtopage) || ($cancel && empty($id))) {
143 if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
144 if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
145 $backtopage = $backurlforlist;
146 } else {
147 $backtopage = DOL_URL_ROOT.'/adherents/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
148 }
149 }
150 }
151
152 if ($cancel) {
153 if (!empty($backtopageforcancel)) {
154 header("Location: ".$backtopageforcancel);
155 exit;
156 } elseif (!empty($backtopage)) {
157 header("Location: ".$backtopage);
158 exit;
159 }
160 $action = '';
161 }
162
163 if ($action == 'setuserid' && ($user->hasRight('user', 'self', 'creer') || $user->hasRight('user', 'user', 'creer'))) {
164 $error = 0;
165 if (!$user->hasRight('user', 'user', 'creer')) { // If can edit only itself user, we can link to itself only
166 if ($userid != $user->id && $userid != $object->user_id) {
167 $error++;
168 setEventMessages($langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly"), null, 'errors');
169 }
170 }
171
172 if (!$error) {
173 if ($userid != $object->user_id) { // If link differs from currently in database
174 $result = $object->setUserId($userid);
175 if ($result < 0) {
176 dol_print_error($object->db, $object->error);
177 }
178 $action = '';
179 }
180 }
181 }
182
183 if ($action == 'setsocid') {
184 $error = 0;
185 if (!$error) {
186 if ($socid != $object->socid) { // If link differs from currently in database
187 $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."adherent";
188 $sql .= " WHERE socid = ".((int) $socid);
189 $sql .= " AND entity = ".$conf->entity;
190 $resql = $db->query($sql);
191 if ($resql) {
192 $obj = $db->fetch_object($resql);
193 if ($obj && $obj->rowid > 0) {
194 $othermember = new Adherent($db);
195 $othermember->fetch($obj->rowid);
196 $thirdparty = new Societe($db);
197 $thirdparty->fetch($socid);
198 $error++;
199 setEventMessages($langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty", $othermember->getFullName($langs), $othermember->login, $thirdparty->name), null, 'errors');
200 }
201 }
202
203 if (!$error) {
204 $result = $object->setThirdPartyId($socid);
205 if ($result < 0) {
206 dol_print_error($object->db, $object->error);
207 }
208 $action = '';
209 }
210 }
211 }
212 }
213
214 // Create user from a member
215 if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->hasRight('user', 'user', 'creer')) {
216 if ($result > 0) {
217 // Creation user
218 $nuser = new User($db);
219 $tmpuser = dol_clone($object);
220 if (GETPOST('internalorexternal', 'aZ09') == 'internal') {
221 $tmpuser->fk_soc = 0;
222 }
223
224 $result = $nuser->create_from_member($tmpuser, GETPOST('login', 'alphanohtml'));
225
226 if ($result < 0) {
227 $langs->load("errors");
228 setEventMessages($langs->trans($nuser->error), null, 'errors');
229 } else {
230 setEventMessages($langs->trans("NewUserCreated", $nuser->login), null, 'mesgs');
231 $action = '';
232 }
233 } else {
234 setEventMessages($object->error, $object->errors, 'errors');
235 }
236 }
237
238 // Create third party from a member
239 if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->hasRight('societe', 'creer')) {
240 if ($result > 0) {
241 // User creation
242 $company = new Societe($db);
243 $result = $company->create_from_member($object, GETPOST('companyname', 'alpha'), GETPOST('companyalias', 'alpha'));
244
245 if ($result < 0) {
246 $langs->load("errors");
247 setEventMessages($langs->trans($company->error), null, 'errors');
248 setEventMessages($company->error, $company->errors, 'errors');
249 }
250 } else {
251 setEventMessages($object->error, $object->errors, 'errors');
252 }
253 }
254
255 if ($action == 'update' && !$cancel && $user->hasRight('adherent', 'creer')) {
256 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
257
258 $birthdate = '';
259 if (GETPOST("birthday", 'int') && GETPOST("birthmonth", 'int') && GETPOST("birthyear", 'int')) {
260 $birthdate = dol_mktime(12, 0, 0, GETPOST("birthmonth", 'int'), GETPOST("birthday", 'int'), GETPOST("birthyear", 'int'));
261 }
262 $lastname = GETPOST("lastname", 'alphanohtml');
263 $firstname = GETPOST("firstname", 'alphanohtml');
264 $gender = GETPOST("gender", 'alphanohtml');
265 $societe = GETPOST("societe", 'alphanohtml');
266 $morphy = GETPOST("morphy", 'alphanohtml');
267 $login = GETPOST("login", 'alphanohtml');
268 if ($morphy != 'mor' && empty($lastname)) {
269 $error++;
270 $langs->load("errors");
271 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname")), null, 'errors');
272 }
273 if ($morphy != 'mor' && (!isset($firstname) || $firstname == '')) {
274 $error++;
275 $langs->load("errors");
276 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Firstname")), null, 'errors');
277 }
278 if ($morphy == 'mor' && empty($societe)) {
279 $error++;
280 $langs->load("errors");
281 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Company")), null, 'errors');
282 }
283 // Check if the login already exists
284 if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
285 if (empty($login)) {
286 $error++;
287 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login")), null, 'errors');
288 }
289 }
290 // Create new object
291 if ($result > 0 && !$error) {
292 $object->oldcopy = dol_clone($object, 2);
293
294 // Change values
295 $object->civility_id = trim(GETPOST("civility_id", 'alphanohtml'));
296 $object->firstname = trim(GETPOST("firstname", 'alphanohtml'));
297 $object->lastname = trim(GETPOST("lastname", 'alphanohtml'));
298 $object->gender = trim(GETPOST("gender", 'alphanohtml'));
299 $object->login = trim(GETPOST("login", 'alphanohtml'));
300 if (GETPOSTISSET('pass')) {
301 $object->pass = trim(GETPOST("pass", 'none')); // For password, we must use 'none'
302 }
303
304 $object->societe = trim(GETPOST("societe", 'alphanohtml')); // deprecated
305 $object->company = trim(GETPOST("societe", 'alphanohtml'));
306
307 $object->address = trim(GETPOST("address", 'alphanohtml'));
308 $object->zip = trim(GETPOST("zipcode", 'alphanohtml'));
309 $object->town = trim(GETPOST("town", 'alphanohtml'));
310 $object->state_id = GETPOST("state_id", 'int');
311 $object->country_id = GETPOST("country_id", 'int');
312
313 $object->phone = trim(GETPOST("phone", 'alpha'));
314 $object->phone_perso = trim(GETPOST("phone_perso", 'alpha'));
315 $object->phone_mobile = trim(GETPOST("phone_mobile", 'alpha'));
316 $object->email = preg_replace('/\s+/', '', GETPOST("member_email", 'alpha'));
317 $object->url = trim(GETPOST('member_url', 'custom', 0, FILTER_SANITIZE_URL));
318 $object->socialnetworks = array();
319 foreach ($socialnetworks as $key => $value) {
320 if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') {
321 $object->socialnetworks[$key] = trim(GETPOST($key, 'alphanohtml'));
322 }
323 }
324 $object->birth = $birthdate;
325 $object->default_lang = GETPOST('default_lang', 'alpha');
326 $object->typeid = GETPOST("typeid", 'int');
327 //$object->note = trim(GETPOST("comment", "restricthtml"));
328 $object->morphy = GETPOST("morphy", 'alpha');
329
330 if (GETPOST('deletephoto', 'alpha')) {
331 $object->photo = '';
332 } elseif (!empty($_FILES['photo']['name'])) {
333 $object->photo = dol_sanitizeFileName($_FILES['photo']['name']);
334 }
335
336 // Get status and public property
337 $object->statut = GETPOST("statut", 'alpha');
338 $object->status = GETPOST("statut", 'alpha');
339 $object->public = GETPOST("public", 'alpha');
340
341 // Fill array 'array_options' with data from add form
342 $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
343 if ($ret < 0) {
344 $error++;
345 }
346
347 // Check if we need to also synchronize user information
348 $nosyncuser = 0;
349 if ($object->user_id) { // If linked to a user
350 if ($user->id != $object->user_id && !$user->hasRight('user', 'user', 'creer')) {
351 $nosyncuser = 1; // Disable synchronizing
352 }
353 }
354
355 // Check if we need to also synchronize password information
356 $nosyncuserpass = 1; // no by default
357 if (GETPOSTISSET('pass')) {
358 if ($object->user_id) { // If member is linked to a user
359 $nosyncuserpass = 0; // We may try to sync password
360 if ($user->id == $object->user_id) {
361 if (!$user->hasRight('user', 'self', 'password')) {
362 $nosyncuserpass = 1; // Disable synchronizing
363 }
364 } else {
365 if (!$user->hasRight('user', 'user', 'password')) {
366 $nosyncuserpass = 1; // Disable synchronizing
367 }
368 }
369 }
370 }
371
372 if (!$error) {
373 $result = $object->update($user, 0, $nosyncuser, $nosyncuserpass);
374
375 if ($result >= 0 && !count($object->errors)) {
376 $categories = GETPOST('memcats', 'array');
377 $object->setCategories($categories);
378
379 // Logo/Photo save
380 $dir = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'member').'/photos';
381 $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
382 if ($file_OK) {
383 if (GETPOST('deletephoto')) {
384 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
385 $fileimg = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'member').'/photos/'.$object->photo;
386 $dirthumbs = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'member').'/photos/thumbs';
387 dol_delete_file($fileimg);
388 dol_delete_dir_recursive($dirthumbs);
389 }
390
391 if (image_format_supported($_FILES['photo']['name']) > 0) {
392 dol_mkdir($dir);
393
394 if (@is_dir($dir)) {
395 $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
396 if (!dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']) > 0) {
397 setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors');
398 } else {
399 // Create thumbs
400 $object->addThumbs($newfile);
401 }
402 }
403 } else {
404 setEventMessages("ErrorBadImageFormat", null, 'errors');
405 }
406 } else {
407 switch ($_FILES['photo']['error']) {
408 case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
409 case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
410 $errors[] = "ErrorFileSizeTooLarge";
411 break;
412 case 3: //uploaded file was only partially uploaded
413 $errors[] = "ErrorFilePartiallyUploaded";
414 break;
415 }
416 }
417
418 $rowid = $object->id;
419 $id = $object->id;
420 $action = '';
421
422 if (!empty($backtopage)) {
423 header("Location: ".$backtopage);
424 exit;
425 }
426 } else {
427 setEventMessages($object->error, $object->errors, 'errors');
428 $action = '';
429 }
430 } else {
431 $action = 'edit';
432 }
433 } else {
434 $action = 'edit';
435 }
436 }
437
438 if ($action == 'add' && $user->hasRight('adherent', 'creer')) {
439 if ($canvas) {
440 $object->canvas = $canvas;
441 }
442 $birthdate = '';
443 if (GETPOSTISSET("birthday") && GETPOST("birthday") && GETPOSTISSET("birthmonth") && GETPOST("birthmonth") && GETPOSTISSET("birthyear") && GETPOST("birthyear")) {
444 $birthdate = dol_mktime(12, 0, 0, GETPOST("birthmonth", 'int'), GETPOST("birthday", 'int'), GETPOST("birthyear", 'int'));
445 }
446 $datesubscription = '';
447 if (GETPOSTISSET("reday") && GETPOSTISSET("remonth") && GETPOSTISSET("reyear")) {
448 $datesubscription = dol_mktime(12, 0, 0, GETPOST("remonth", 'int'), GETPOST("reday", "int"), GETPOST("reyear", "int"));
449 }
450
451 $typeid = GETPOST("typeid", 'int');
452 $civility_id = GETPOST("civility_id", 'alphanohtml');
453 $lastname = GETPOST("lastname", 'alphanohtml');
454 $firstname = GETPOST("firstname", 'alphanohtml');
455 $gender = GETPOST("gender", 'alphanohtml');
456 $societe = GETPOST("societe", 'alphanohtml');
457 $address = GETPOST("address", 'alphanohtml');
458 $zip = GETPOST("zipcode", 'alphanohtml');
459 $town = GETPOST("town", 'alphanohtml');
460 $state_id = GETPOST("state_id", 'int');
461 $country_id = GETPOST("country_id", 'int');
462
463 $phone = GETPOST("phone", 'alpha');
464 $phone_perso = GETPOST("phone_perso", 'alpha');
465 $phone_mobile = GETPOST("phone_mobile", 'alpha');
466 $email = preg_replace('/\s+/', '', GETPOST("member_email", 'alpha'));
467 $url = trim(GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL));
468 $login = GETPOST("member_login", 'alphanohtml');
469 $pass = GETPOST("password", 'none'); // For password, we use 'none'
470 $photo = GETPOST("photo", 'alphanohtml');
471 $morphy = GETPOST("morphy", 'alphanohtml');
472 $public = GETPOST("public", 'alphanohtml');
473
474 $userid = GETPOST("userid", 'int');
475 $socid = GETPOST("socid", 'int');
476 $default_lang = GETPOST('default_lang', 'alpha');
477
478 $object->civility_id = $civility_id;
479 $object->firstname = $firstname;
480 $object->lastname = $lastname;
481 $object->gender = $gender;
482 $object->societe = $societe; // deprecated
483 $object->company = $societe;
484 $object->address = $address;
485 $object->zip = $zip;
486 $object->town = $town;
487 $object->state_id = $state_id;
488 $object->country_id = $country_id;
489 $object->phone = $phone;
490 $object->phone_perso = $phone_perso;
491 $object->phone_mobile = $phone_mobile;
492 $object->socialnetworks = array();
493 if (isModEnabled('socialnetworks')) {
494 foreach ($socialnetworks as $key => $value) {
495 if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') {
496 $object->socialnetworks[$key] = GETPOST("member_".$key, 'alphanohtml');
497 }
498 }
499 }
500
501 $object->email = $email;
502 $object->url = $url;
503 $object->login = $login;
504 $object->pass = $pass;
505 $object->birth = $birthdate;
506 $object->photo = $photo;
507 $object->typeid = $typeid;
508 //$object->note = $comment;
509 $object->morphy = $morphy;
510 $object->user_id = $userid;
511 $object->socid = $socid;
512 $object->public = $public;
513 $object->default_lang = $default_lang;
514 // Fill array 'array_options' with data from add form
515 $ret = $extrafields->setOptionalsFromPost(null, $object);
516 if ($ret < 0) {
517 $error++;
518 }
519
520 // Check parameters
521 if (empty($morphy) || $morphy == "-1") {
522 $error++;
523 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MemberNature")), null, 'errors');
524 }
525 // Tests if the login already exists
526 if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
527 if (empty($login)) {
528 $error++;
529 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login")), null, 'errors');
530 } else {
531 $sql = "SELECT login FROM ".MAIN_DB_PREFIX."adherent WHERE login='".$db->escape($login)."'";
532 $result = $db->query($sql);
533 if ($result) {
534 $num = $db->num_rows($result);
535 }
536 if ($num) {
537 $error++;
538 $langs->load("errors");
539 setEventMessages($langs->trans("ErrorLoginAlreadyExists", $login), null, 'errors');
540 }
541 }
542 if (empty($pass)) {
543 $error++;
544 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Password")), null, 'errors');
545 }
546 }
547 if ($morphy == 'mor' && empty($societe)) {
548 $error++;
549 $langs->load("errors");
550 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Company")), null, 'errors');
551 }
552 if ($morphy != 'mor' && empty($lastname)) {
553 $error++;
554 $langs->load("errors");
555 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname")), null, 'errors');
556 }
557 if ($morphy != 'mor' && (!isset($firstname) || $firstname == '')) {
558 $error++;
559 $langs->load("errors");
560 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Firstname")), null, 'errors');
561 }
562 if (!($typeid > 0)) { // Keep () before !
563 $error++;
564 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
565 }
566 if (getDolGlobalString('ADHERENT_MAIL_REQUIRED') && !isValidEMail($email)) {
567 $error++;
568 $langs->load("errors");
569 setEventMessages($langs->trans("ErrorBadEMail", $email), null, 'errors');
570 }
571 if (!empty($object->url) && !isValidUrl($object->url)) {
572 $langs->load("errors");
573 setEventMessages($langs->trans("ErrorBadUrl", $object->url), null, 'errors');
574 }
575 $public = 0;
576 if (isset($public)) {
577 $public = 1;
578 }
579
580 if (!$error) {
581 $db->begin();
582
583 // Create the member
584 $result = $object->create($user);
585 if ($result > 0) {
586 // Foundation categories
587 $memcats = GETPOST('memcats', 'array');
588 $object->setCategories($memcats);
589
590 $db->commit();
591
592 $rowid = $object->id;
593 $id = $object->id;
594
595 $backtopage = preg_replace('/__ID__/', $id, $backtopage);
596 } else {
597 $db->rollback();
598
599 $error++;
600 setEventMessages($object->error, $object->errors, 'errors');
601 }
602
603 // Auto-create thirdparty on member creation
604 if (getDolGlobalString('ADHERENT_DEFAULT_CREATE_THIRDPARTY')) {
605 if ($result > 0) {
606 // Create third party out of a member
607 $company = new Societe($db);
608 $result = $company->create_from_member($object);
609 if ($result < 0) {
610 $langs->load("errors");
611 setEventMessages($langs->trans($company->error), null, 'errors');
612 setEventMessages($company->error, $company->errors, 'errors');
613 }
614 } else {
615 setEventMessages($object->error, $object->errors, 'errors');
616 }
617 }
618 }
619 $action = ($result < 0 || !$error) ? '' : 'create';
620
621 if (!$error && $backtopage) {
622 header("Location: ".$backtopage);
623 exit;
624 }
625 }
626
627 if ($user->hasRight('adherent', 'supprimer') && $action == 'confirm_delete' && $confirm == 'yes') {
628 $result = $object->delete($id, $user);
629 if ($result > 0) {
630 setEventMessages($langs->trans("RecordDeleted"), null, 'errors');
631 if (!empty($backtopage) && !preg_match('/'.preg_quote($_SERVER["PHP_SELF"], '/').'/', $backtopage)) {
632 header("Location: ".$backtopage);
633 exit;
634 } else {
635 header("Location: list.php");
636 exit;
637 }
638 } else {
639 setEventMessages($object->error, null, 'errors');
640 }
641 }
642
643 if ($user->hasRight('adherent', 'creer') && $action == 'confirm_valid' && $confirm == 'yes') {
644 $error = 0;
645
646 $db->begin();
647
648 $adht = new AdherentType($db);
649 $adht->fetch($object->typeid);
650
651 $result = $object->validate($user);
652
653 if ($result >= 0 && !count($object->errors)) {
654 // Send confirmation email (according to parameters of member type. Otherwise generic)
655 if ($object->email && GETPOST("send_mail")) {
656 $subject = '';
657 $msg = '';
658
659 // Send subscription email
660 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
661 $formmail = new FormMail($db);
662 // Set output language
663 $outputlangs = new Translate('', $conf);
664 $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
665 // Load traductions files required by page
666 $outputlangs->loadLangs(array("main", "members", "companies", "install", "other"));
667 // Get email content from template
668 $arraydefaultmessage = null;
669 $labeltouse = getDolGlobalString('ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION');
670
671 if (!empty($labeltouse)) {
672 $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
673 }
674
675 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
676 $subject = $arraydefaultmessage->topic;
677 $msg = $arraydefaultmessage->content;
678 }
679
680 if (empty($labeltouse) || (int) $labeltouse === -1) {
681 //fallback on the old configuration.
682 $langs->load("errors");
683 setEventMessages('<a href="'.DOL_URL_ROOT.'/adherents/admin/member_emails.php">'.$langs->trans('WarningMandatorySetupNotComplete').'</a>', null, 'errors');
684 $error++;
685 } else {
686 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
687 complete_substitutions_array($substitutionarray, $outputlangs, $object);
688 $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
689 $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs);
690
691 $moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/card.php'."\r\n";
692
693 $result = $object->sendEmail($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader);
694 if ($result < 0) {
695 $error++;
696 setEventMessages($object->error, $object->errors, 'errors');
697 }
698 }
699 }
700 } else {
701 $error++;
702 if ($object->error) {
703 setEventMessages($object->error, $object->errors, 'errors');
704 } else {
705 setEventMessages($object->error, $object->errors, 'errors');
706 }
707 }
708
709 if (!$error) {
710 $db->commit();
711 } else {
712 $db->rollback();
713 }
714 $action = '';
715 }
716
717 if ($user->hasRight('adherent', 'supprimer') && $action == 'confirm_resiliate') {
718 $error = 0;
719
720 if ($confirm == 'yes') {
721 $adht = new AdherentType($db);
722 $adht->fetch($object->typeid);
723
724 $result = $object->resiliate($user);
725
726 if ($result >= 0 && !count($object->errors)) {
727 if ($object->email && GETPOST("send_mail")) {
728 $subject = '';
729 $msg = '';
730
731 // Send subscription email
732 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
733 $formmail = new FormMail($db);
734 // Set output language
735 $outputlangs = new Translate('', $conf);
736 $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
737 // Load traductions files required by page
738 $outputlangs->loadLangs(array("main", "members", "companies", "install", "other"));
739 // Get email content from template
740 $arraydefaultmessage = null;
741 $labeltouse = getDolGlobalString('ADHERENT_EMAIL_TEMPLATE_CANCELATION');
742
743 if (!empty($labeltouse)) {
744 $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
745 }
746
747 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
748 $subject = $arraydefaultmessage->topic;
749 $msg = $arraydefaultmessage->content;
750 }
751
752 if (empty($labeltouse) || (int) $labeltouse === -1) {
753 //fallback on the old configuration.
754 setEventMessages('WarningMandatorySetupNotComplete', null, 'errors');
755 $error++;
756 } else {
757 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
758 complete_substitutions_array($substitutionarray, $outputlangs, $object);
759 $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
760 $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnResiliate()), $substitutionarray, $outputlangs);
761
762 $moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/card.php'."\r\n";
763
764 $result = $object->sendEmail($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader);
765 if ($result < 0) {
766 $error++;
767 setEventMessages($object->error, $object->errors, 'errors');
768 }
769 }
770 }
771 } else {
772 $error++;
773
774 if ($object->error) {
775 setEventMessages($object->error, $object->errors, 'errors');
776 } else {
777 setEventMessages($object->error, $object->errors, 'errors');
778 }
779 $action = '';
780 }
781 }
782 if (!empty($backtopage) && !$error) {
783 header("Location: ".$backtopage);
784 exit;
785 }
786 }
787
788 if ($user->hasRight('adherent', 'supprimer') && $action == 'confirm_exclude') {
789 $error = 0;
790
791 if ($confirm == 'yes') {
792 $adht = new AdherentType($db);
793 $adht->fetch($object->typeid);
794
795 $result = $object->exclude($user);
796
797 if ($result >= 0 && !count($object->errors)) {
798 if ($object->email && GETPOST("send_mail")) {
799 $subject = '';
800 $msg = '';
801
802 // Send subscription email
803 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
804 $formmail = new FormMail($db);
805 // Set output language
806 $outputlangs = new Translate('', $conf);
807 $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
808 // Load traductions files required by page
809 $outputlangs->loadLangs(array("main", "members", "companies", "install", "other"));
810 // Get email content from template
811 $arraydefaultmessage = null;
812 $labeltouse = getDolGlobalString('ADHERENT_EMAIL_TEMPLATE_EXCLUSION');
813
814 if (!empty($labeltouse)) {
815 $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
816 }
817
818 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
819 $subject = $arraydefaultmessage->topic;
820 $msg = $arraydefaultmessage->content;
821 }
822
823 if (empty($labeltouse) || (int) $labeltouse === -1) {
824 //fallback on the old configuration.
825 setEventMessages('WarningMandatorySetupNotComplete', null, 'errors');
826 $error++;
827 } else {
828 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
829 complete_substitutions_array($substitutionarray, $outputlangs, $object);
830 $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
831 $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnExclude()), $substitutionarray, $outputlangs);
832
833 $moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/card.php'."\r\n";
834
835 $result = $object->sendEmail($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader);
836 if ($result < 0) {
837 $error++;
838 setEventMessages($object->error, $object->errors, 'errors');
839 }
840 }
841 }
842 } else {
843 $error++;
844
845 if ($object->error) {
846 setEventMessages($object->error, $object->errors, 'errors');
847 } else {
848 setEventMessages($object->error, $object->errors, 'errors');
849 }
850 $action = '';
851 }
852 }
853 if (!empty($backtopage) && !$error) {
854 header("Location: ".$backtopage);
855 exit;
856 }
857 }
858
859 // SPIP Management
860 if ($user->hasRight('adherent', 'supprimer') && $action == 'confirm_del_spip' && $confirm == 'yes') {
861 if (!count($object->errors)) {
862 if (!$mailmanspip->del_to_spip($object)) {
863 setEventMessages($langs->trans('DeleteIntoSpipError').': '.$mailmanspip->error, null, 'errors');
864 }
865 }
866 }
867
868 if ($user->hasRight('adherent', 'creer') && $action == 'confirm_add_spip' && $confirm == 'yes') {
869 if (!count($object->errors)) {
870 if (!$mailmanspip->add_to_spip($object)) {
871 setEventMessages($langs->trans('AddIntoSpipError').': '.$mailmanspip->error, null, 'errors');
872 }
873 }
874 }
875
876 // Actions when printing a doc from card
877 include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
878
879 // Actions to build doc
880 $upload_dir = $conf->adherent->dir_output;
881 $permissiontoadd = $user->hasRight('adherent', 'creer');
882 include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
883
884 // Actions to send emails
885 $triggersendname = 'MEMBER_SENTBYMAIL';
886 $paramname = 'id';
887 $mode = 'emailfrommember';
888 $trackid = 'mem'.$object->id;
889 include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
890}
891
892
893/*
894 * View
895 */
896
897$form = new Form($db);
898$formfile = new FormFile($db);
899$formadmin = new FormAdmin($db);
900$formcompany = new FormCompany($db);
901
902$title = $langs->trans("Member")." - ".$langs->trans("Card");
903$help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros|DE:Modul_Mitglieder';
904llxHeader('', $title, $help_url);
905
906$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
907
908if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
909 // -----------------------------------------
910 // When used with CANVAS
911 // -----------------------------------------
912 if (empty($object->error) && $id) {
913 $object = new Adherent($db);
914 $result = $object->fetch($id);
915 if ($result <= 0) {
916 dol_print_error('', $object->error);
917 }
918 }
919 $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates
920 $objcanvas->display_canvas($action); // Show template
921} else {
922 // -----------------------------------------
923 // When used in standard mode
924 // -----------------------------------------
925
926 // Create mode
927 if ($action == 'create') {
928 $object->canvas = $canvas;
929 $object->state_id = GETPOST('state_id', 'int');
930
931 // We set country_id, country_code and country for the selected country
932 $object->country_id = GETPOST('country_id', 'int') ? GETPOST('country_id', 'int') : $mysoc->country_id;
933 if ($object->country_id) {
934 $tmparray = getCountry($object->country_id, 'all');
935 $object->country_code = $tmparray['code'];
936 $object->country = $tmparray['label'];
937 }
938
939 $soc = new Societe($db);
940 if (!empty($socid)) {
941 if ($socid > 0) {
942 $soc->fetch($socid);
943 }
944
945 if (!($soc->id > 0)) {
946 $langs->load("errors");
947 print($langs->trans('ErrorRecordNotFound'));
948 exit;
949 }
950 }
951
952 $adht = new AdherentType($db);
953
954 print load_fiche_titre($langs->trans("NewMember"), '', $object->picto);
955
956 if ($conf->use_javascript_ajax) {
957 print "\n".'<script type="text/javascript">'."\n";
958 print 'jQuery(document).ready(function () {
959 jQuery("#selectcountry_id").change(function() {
960 document.formsoc.action.value="create";
961 document.formsoc.submit();
962 });
963 function initfieldrequired() {
964 jQuery("#tdcompany").removeClass("fieldrequired");
965 jQuery("#tdlastname").removeClass("fieldrequired");
966 jQuery("#tdfirstname").removeClass("fieldrequired");
967 if (jQuery("#morphy").val() == \'mor\') {
968 jQuery("#tdcompany").addClass("fieldrequired");
969 }
970 if (jQuery("#morphy").val() == \'phy\') {
971 jQuery("#tdlastname").addClass("fieldrequired");
972 jQuery("#tdfirstname").addClass("fieldrequired");
973 }
974 }
975 jQuery("#morphy").change(function() {
976 initfieldrequired();
977 });
978 initfieldrequired();
979 })';
980 print '</script>'."\n";
981 }
982
983 print '<form name="formsoc" action="'.$_SERVER["PHP_SELF"].'" method="post" enctype="multipart/form-data">';
984 print '<input type="hidden" name="token" value="'.newToken().'">';
985 print '<input type="hidden" name="action" value="add">';
986 print '<input type="hidden" name="socid" value="'.$socid.'">';
987 if ($backtopage) {
988 print '<input type="hidden" name="backtopage" value="'.($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]).'">';
989 }
990
991 print dol_get_fiche_head('');
992
993 print '<table class="border centpercent">';
994 print '<tbody>';
995
996 // Login
997 if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
998 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="'.(GETPOSTISSET("member_login") ? GETPOST("member_login", 'alphanohtml', 2) : $object->login).'" autofocus="autofocus"></td></tr>';
999 }
1000
1001 // Password
1002 if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
1003 require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
1004 $generated_password = getRandomPassword(false);
1005 print '<tr><td><span class="fieldrequired">'.$langs->trans("Password").'</span></td><td>';
1006 print '<input type="text" class="minwidth300" maxlength="50" name="password" value="'.dol_escape_htmltag($generated_password).'">';
1007 print '</td></tr>';
1008 }
1009
1010 // Type
1011 print '<tr><td class="fieldrequired">'.$langs->trans("MemberType").'</td><td>';
1012 $listetype = $adht->liste_array(1);
1013 print img_picto('', $adht->picto, 'class="pictofixedwidth"');
1014 if (count($listetype)) {
1015 print $form->selectarray("typeid", $listetype, (GETPOST('typeid', 'int') ? GETPOST('typeid', 'int') : $typeid), (count($listetype) > 1 ? 1 : 0), 0, 0, '', 0, 0, 0, '', 'minwidth150', 1);
1016 } else {
1017 print '<span class="error">'.$langs->trans("NoTypeDefinedGoToSetup").'</span>';
1018 }
1019 print "</td>\n";
1020
1021 // Morphy
1022 $morphys["phy"] = $langs->trans("Physical");
1023 $morphys["mor"] = $langs->trans("Moral");
1024 print '<tr><td class="fieldrequired">'.$langs->trans("MemberNature")."</td><td>\n";
1025 print $form->selectarray("morphy", $morphys, (GETPOST('morphy', 'alpha') ? GETPOST('morphy', 'alpha') : $object->morphy), 1, 0, 0, '', 0, 0, 0, '', '', 1);
1026 print "</td>\n";
1027
1028 // Company
1029 print '<tr><td id="tdcompany">'.$langs->trans("Company").'</td><td><input type="text" name="societe" class="minwidth300" maxlength="128" value="'.(GETPOSTISSET('societe') ? GETPOST('societe', 'alphanohtml') : $soc->name).'"></td></tr>';
1030
1031 // Civility
1032 print '<tr><td>'.$langs->trans("UserTitle").'</td><td>';
1033 print $formcompany->select_civility(GETPOST('civility_id', 'int') ? GETPOST('civility_id', 'int') : $object->civility_id, 'civility_id', 'maxwidth150', 1).'</td>';
1034 print '</tr>';
1035
1036 // Lastname
1037 print '<tr><td id="tdlastname">'.$langs->trans("Lastname").'</td><td><input type="text" name="lastname" class="minwidth300" maxlength="50" value="'.(GETPOSTISSET('lastname') ? GETPOST('lastname', 'alphanohtml') : $object->lastname).'"></td>';
1038 print '</tr>';
1039
1040 // Firstname
1041 print '<tr><td id="tdfirstname">'.$langs->trans("Firstname").'</td><td><input type="text" name="firstname" class="minwidth300" maxlength="50" value="'.(GETPOSTISSET('firstname') ? GETPOST('firstname', 'alphanohtml') : $object->firstname).'"></td>';
1042 print '</tr>';
1043
1044 // Gender
1045 print '<tr><td>'.$langs->trans("Gender").'</td>';
1046 print '<td>';
1047 $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman"), 'other'=>$langs->trans("Genderother"));
1048 print $form->selectarray('gender', $arraygender, GETPOST('gender', 'alphanohtml'), 1, 0, 0, '', 0, 0, 0, '', '', 1);
1049 print '</td></tr>';
1050
1051 // EMail
1052 print '<tr><td>'.(getDolGlobalString('ADHERENT_MAIL_REQUIRED') ? '<span class="fieldrequired">' : '').$langs->trans("EMail").(getDolGlobalString('ADHERENT_MAIL_REQUIRED') ? '</span>' : '').'</td>';
1053 print '<td>'.img_picto('', 'object_email').' <input type="text" name="member_email" class="minwidth300" maxlength="255" value="'.(GETPOSTISSET('member_email') ? GETPOST('member_email', 'alpha') : $soc->email).'"></td></tr>';
1054
1055 // Website
1056 print '<tr><td>'.$form->editfieldkey('Web', 'member_url', GETPOST('member_url', 'alpha'), $object, 0).'</td>';
1057 print '<td>'.img_picto('', 'globe').' <input type="text" class="maxwidth500 widthcentpercentminusx" name="member_url" id="member_url" value="'.(GETPOSTISSET('member_url') ? GETPOST('member_url', 'alpha') : $object->url).'"></td></tr>';
1058
1059 // Address
1060 print '<tr><td class="tdtop">'.$langs->trans("Address").'</td><td>';
1061 print '<textarea name="address" wrap="soft" class="quatrevingtpercent" rows="2">'.(GETPOSTISSET('address') ? GETPOST('address', 'alphanohtml') : $soc->address).'</textarea>';
1062 print '</td></tr>';
1063
1064 // Zip / Town
1065 print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>';
1066 print $formcompany->select_ziptown((GETPOSTISSET('zipcode') ? GETPOST('zipcode', 'alphanohtml') : $soc->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6);
1067 print ' ';
1068 print $formcompany->select_ziptown((GETPOSTISSET('town') ? GETPOST('town', 'alphanohtml') : $soc->town), 'town', array('zipcode', 'selectcountry_id', 'state_id'));
1069 print '</td></tr>';
1070
1071 // Country
1072 if (empty($soc->country_id)) {
1073 $soc->country_id = $mysoc->country_id;
1074 $soc->country_code = $mysoc->country_code;
1075 $soc->state_id = $mysoc->state_id;
1076 }
1077 print '<tr><td>'.$langs->trans('Country').'</td><td>';
1078 print img_picto('', 'country', 'class="pictofixedwidth"');
1079 print $form->select_country(GETPOSTISSET('country_id') ? GETPOST('country_id', 'alpha') : $soc->country_id, 'country_id');
1080 if ($user->admin) {
1081 print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1082 }
1083 print '</td></tr>';
1084
1085 // State
1086 if (!getDolGlobalString('MEMBER_DISABLE_STATE')) {
1087 print '<tr><td>'.$langs->trans('State').'</td><td>';
1088 if ($soc->country_id) {
1089 print img_picto('', 'state', 'class="pictofixedwidth"');
1090 print $formcompany->select_state(GETPOSTISSET('state_id') ? GETPOST('state_id', 'int') : $soc->state_id, $soc->country_code);
1091 } else {
1092 print $countrynotdefined;
1093 }
1094 print '</td></tr>';
1095 }
1096
1097 // Pro phone
1098 print '<tr><td>'.$langs->trans("PhonePro").'</td>';
1099 print '<td>'.img_picto('', 'object_phoning', 'class="pictofixedwidth"').'<input type="text" name="phone" size="20" value="'.(GETPOSTISSET('phone') ? GETPOST('phone', 'alpha') : $soc->phone).'"></td></tr>';
1100
1101 // Personal phone
1102 print '<tr><td>'.$langs->trans("PhonePerso").'</td>';
1103 print '<td>'.img_picto('', 'object_phoning', 'class="pictofixedwidth"').'<input type="text" name="phone_perso" size="20" value="'.(GETPOSTISSET('phone_perso') ? GETPOST('phone_perso', 'alpha') : $object->phone_perso).'"></td></tr>';
1104
1105 // Mobile phone
1106 print '<tr><td>'.$langs->trans("PhoneMobile").'</td>';
1107 print '<td>'.img_picto('', 'object_phoning_mobile', 'class="pictofixedwidth"').'<input type="text" name="phone_mobile" size="20" value="'.(GETPOSTISSET('phone_mobile') ? GETPOST('phone_mobile', 'alpha') : $object->phone_mobile).'"></td></tr>';
1108
1109 if (isModEnabled('socialnetworks')) {
1110 foreach ($socialnetworks as $key => $value) {
1111 if (!$value['active']) {
1112 break;
1113 }
1114 $val = (GETPOSTISSET('member_'.$key) ? GETPOST('member_'.$key, 'alpha') : (empty($object->socialnetworks[$key]) ? '' : $object->socialnetworks[$key]));
1115 print '<tr><td>'.$langs->trans($value['label']).'</td><td><input type="text" name="member_'.$key.'" size="40" value="'.$val.'"></td></tr>';
1116 }
1117 }
1118
1119 // Birth Date
1120 print "<tr><td>".$langs->trans("DateOfBirth")."</td><td>\n";
1121 print $form->selectDate(($object->birth ? $object->birth : -1), 'birth', '', '', 1, 'formsoc');
1122 print "</td></tr>\n";
1123
1124 // Public profil
1125 print "<tr><td>";
1126 $htmltext = $langs->trans("Public", getDolGlobalString('MAIN_INFO_SOCIETE_NOM'), $linkofpubliclist);
1127 print $form->textwithpicto($langs->trans("MembershipPublic"), $htmltext, 1, 'help', '', 0, 3, 'membershippublic');
1128 print "</td><td>\n";
1129 print $form->selectyesno("public", $object->public, 1);
1130 print "</td></tr>\n";
1131
1132 // Categories
1133 if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) {
1134 print '<tr><td>'.$form->editfieldkey("Categories", 'memcats', '', $object, 0).'</td><td>';
1135 $cate_arbo = $form->select_all_categories(Categorie::TYPE_MEMBER, null, 'parent', null, null, 1);
1136 print img_picto('', 'category').$form->multiselectarray('memcats', $cate_arbo, GETPOST('memcats', 'array'), null, null, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
1137 print "</td></tr>";
1138 }
1139
1140 // Other attributes
1141 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
1142
1143 print '<tbody>';
1144 print "</table>\n";
1145
1146 print dol_get_fiche_end();
1147
1148 print $form->buttonsSaveCancel("AddMember");
1149
1150 print "</form>\n";
1151 }
1152
1153 // Edit mode
1154 if ($action == 'edit') {
1155 $res = $object->fetch($id);
1156 if ($res < 0) {
1157 dol_print_error($db, $object->error);
1158 exit;
1159 }
1160 $res = $object->fetch_optionals();
1161 if ($res < 0) {
1162 dol_print_error($db);
1163 exit;
1164 }
1165
1166 $adht = new AdherentType($db);
1167 $adht->fetch($object->typeid);
1168
1169 // We set country_id, and country_code, country of the chosen country
1170 $country = GETPOST('country', 'int');
1171 if (!empty($country) || $object->country_id) {
1172 $sql = "SELECT rowid, code, label from ".MAIN_DB_PREFIX."c_country where rowid = ".(!empty($country) ? $country : $object->country_id);
1173 $resql = $db->query($sql);
1174 if ($resql) {
1175 $obj = $db->fetch_object($resql);
1176 } else {
1177 dol_print_error($db);
1178 }
1179 $object->country_id = $obj->rowid;
1180 $object->country_code = $obj->code;
1181 $object->country = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->label;
1182 }
1183
1184 $head = member_prepare_head($object);
1185
1186
1187 if ($conf->use_javascript_ajax) {
1188 print "\n".'<script type="text/javascript">';
1189 print 'jQuery(document).ready(function () {
1190 jQuery("#selectcountry_id").change(function() {
1191 document.formsoc.action.value="edit";
1192 document.formsoc.submit();
1193 });
1194 function initfieldrequired() {
1195 jQuery("#tdcompany").removeClass("fieldrequired");
1196 jQuery("#tdlastname").removeClass("fieldrequired");
1197 jQuery("#tdfirstname").removeClass("fieldrequired");
1198 if (jQuery("#morphy").val() == \'mor\') {
1199 jQuery("#tdcompany").addClass("fieldrequired");
1200 }
1201 if (jQuery("#morphy").val() == \'phy\') {
1202 jQuery("#tdlastname").addClass("fieldrequired");
1203 jQuery("#tdfirstname").addClass("fieldrequired");
1204 }
1205 }
1206 jQuery("#morphy").change(function() {
1207 initfieldrequired();
1208 });
1209 initfieldrequired();
1210 })';
1211 print '</script>'."\n";
1212 }
1213
1214 print '<form name="formsoc" action="'.$_SERVER["PHP_SELF"].'" method="post" enctype="multipart/form-data">';
1215 print '<input type="hidden" name="token" value="'.newToken().'" />';
1216 print '<input type="hidden" name="action" value="update" />';
1217 print '<input type="hidden" name="rowid" value="'.$id.'" />';
1218 print '<input type="hidden" name="statut" value="'.$object->statut.'" />';
1219 if ($backtopage) {
1220 print '<input type="hidden" name="backtopage" value="'.($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]).'">';
1221 }
1222
1223 print dol_get_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user');
1224
1225 print '<table class="border centpercent">';
1226
1227 // Ref
1228 print '<tr><td class="titlefieldcreate">'.$langs->trans("Ref").'</td><td class="valeur">'.$object->ref.'</td></tr>';
1229
1230 // Login
1231 if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
1232 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="'.(GETPOSTISSET("login") ? GETPOST("login", 'alphanohtml', 2) : $object->login).'"></td></tr>';
1233 }
1234
1235 // Password
1236 if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
1237 print '<tr><td class="fieldrequired">'.$langs->trans("Password").'</td><td><input type="password" name="pass" class="minwidth300" maxlength="50" value="'.dol_escape_htmltag(GETPOSTISSET("pass") ? GETPOST("pass", 'none', 2) : '').'"></td></tr>';
1238 }
1239
1240 // Type
1241 print '<tr><td class="fieldrequired">'.$langs->trans("Type").'</td><td>';
1242 if ($user->hasRight('adherent', 'creer')) {
1243 print $form->selectarray("typeid", $adht->liste_array(), (GETPOSTISSET("typeid") ? GETPOST("typeid", 'int') : $object->typeid), 0, 0, 0, '', 0, 0, 0, '', '', 1);
1244 } else {
1245 print $adht->getNomUrl(1);
1246 print '<input type="hidden" name="typeid" value="'.$object->typeid.'">';
1247 }
1248 print "</td></tr>";
1249
1250 // Morphy
1251 $morphys["phy"] = $langs->trans("Physical");
1252 $morphys["mor"] = $langs->trans("Moral");
1253 print '<tr><td><span class="fieldrequired">'.$langs->trans("MemberNature").'</span></td><td>';
1254 print $form->selectarray("morphy", $morphys, (GETPOSTISSET("morphy") ? GETPOST("morphy", 'alpha') : $object->morphy), 0, 0, 0, '', 0, 0, 0, '', '', 1);
1255 print "</td></tr>";
1256
1257 // Company
1258 print '<tr><td id="tdcompany">'.$langs->trans("Company").'</td><td><input type="text" name="societe" class="minwidth300" maxlength="128" value="'.(GETPOSTISSET("societe") ? GETPOST("societe", 'alphanohtml', 2) : $object->company).'"></td></tr>';
1259
1260 // Civility
1261 print '<tr><td>'.$langs->trans("UserTitle").'</td><td>';
1262 print $formcompany->select_civility(GETPOSTISSET("civility_id") ? GETPOST("civility_id", 'alpha') : $object->civility_id, 'civility_id', 'maxwidth150', 1);
1263 print '</td>';
1264 print '</tr>';
1265
1266 // Lastname
1267 print '<tr><td id="tdlastname">'.$langs->trans("Lastname").'</td><td><input type="text" name="lastname" class="minwidth300" maxlength="50" value="'.(GETPOSTISSET("lastname") ? GETPOST("lastname", 'alphanohtml', 2) : $object->lastname).'"></td>';
1268 print '</tr>';
1269
1270 // Firstname
1271 print '<tr><td id="tdfirstname">'.$langs->trans("Firstname").'</td><td><input type="text" name="firstname" class="minwidth300" maxlength="50" value="'.(GETPOSTISSET("firstname") ? GETPOST("firstname", 'alphanohtml', 3) : $object->firstname).'"></td>';
1272 print '</tr>';
1273
1274 // Gender
1275 print '<tr><td>'.$langs->trans("Gender").'</td>';
1276 print '<td>';
1277 $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman"), 'other'=>$langs->trans("Genderother"));
1278 print $form->selectarray('gender', $arraygender, GETPOSTISSET('gender') ? GETPOST('gender', 'alphanohtml') : $object->gender, 1, 0, 0, '', 0, 0, 0, '', '', 1);
1279 print '</td></tr>';
1280
1281 // Photo
1282 print '<tr><td>'.$langs->trans("Photo").'</td>';
1283 print '<td class="hideonsmartphone" valign="middle">';
1284 print $form->showphoto('memberphoto', $object)."\n";
1285 if ($caneditfieldmember) {
1286 if ($object->photo) {
1287 print "<br>\n";
1288 }
1289 print '<table class="nobordernopadding">';
1290 if ($object->photo) {
1291 print '<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
1292 }
1293 print '<tr><td>'.$langs->trans("PhotoFile").'</td></tr>';
1294 print '<tr><td>';
1295 $maxfilesizearray = getMaxFileSizeArray();
1296 $maxmin = $maxfilesizearray['maxmin'];
1297 if ($maxmin > 0) {
1298 print '<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).'">'; // MAX_FILE_SIZE must precede the field type=file
1299 }
1300 print '<input type="file" class="flat" name="photo" id="photoinput">';
1301 print '</td></tr>';
1302 print '</table>';
1303 }
1304 print '</td></tr>';
1305
1306 // EMail
1307 print '<tr><td>'.(getDolGlobalString("ADHERENT_MAIL_REQUIRED") ? '<span class="fieldrequired">' : '').$langs->trans("EMail").(getDolGlobalString("ADHERENT_MAIL_REQUIRED") ? '</span>' : '').'</td>';
1308 print '<td>'.img_picto('', 'object_email', 'class="pictofixedwidth"').'<input type="text" name="member_email" class="minwidth300" maxlength="255" value="'.(GETPOSTISSET("member_email") ? GETPOST("member_email", '', 2) : $object->email).'"></td></tr>';
1309
1310 // Website
1311 print '<tr><td>'.$form->editfieldkey('Web', 'member_url', GETPOST('member_url', 'alpha'), $object, 0).'</td>';
1312 print '<td>'.img_picto('', 'globe', 'class="pictofixedwidth"').'<input type="text" name="member_url" id="member_url" class="maxwidth200onsmartphone maxwidth500 widthcentpercentminusx " value="'.(GETPOSTISSET('member_url') ? GETPOST('member_url', 'alpha') : $object->url).'"></td></tr>';
1313
1314 // Address
1315 print '<tr><td>'.$langs->trans("Address").'</td><td>';
1316 print '<textarea name="address" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_2.'">'.(GETPOSTISSET("address") ? GETPOST("address", 'alphanohtml', 2) : $object->address).'</textarea>';
1317 print '</td></tr>';
1318
1319 // Zip / Town
1320 print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>';
1321 print $formcompany->select_ziptown((GETPOSTISSET("zipcode") ? GETPOST("zipcode", 'alphanohtml', 2) : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6);
1322 print ' ';
1323 print $formcompany->select_ziptown((GETPOSTISSET("town") ? GETPOST("town", 'alphanohtml', 2) : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id'));
1324 print '</td></tr>';
1325
1326 // Country
1327 //$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
1328 print '<tr><td>'.$langs->trans('Country').'</td><td>';
1329 print img_picto('', 'country', 'class="pictofixedwidth"');
1330 print $form->select_country(GETPOSTISSET("country_id") ? GETPOST("country_id", "alpha") : $object->country_id, 'country_id');
1331 if ($user->admin) {
1332 print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1333 }
1334 print '</td></tr>';
1335
1336 // State
1337 if (!getDolGlobalString('MEMBER_DISABLE_STATE')) {
1338 print '<tr><td>'.$langs->trans('State').'</td><td>';
1339 print img_picto('', 'state', 'class="pictofixedwidth"');
1340 print $formcompany->select_state($object->state_id, GETPOSTISSET("country_id") ? GETPOST("country_id", "alpha") : $object->country_id);
1341 print '</td></tr>';
1342 }
1343
1344 // Pro phone
1345 print '<tr><td>'.$langs->trans("PhonePro").'</td>';
1346 print '<td>'.img_picto('', 'object_phoning', 'class="pictofixedwidth"').'<input type="text" name="phone" value="'.(GETPOSTISSET("phone") ? GETPOST("phone") : $object->phone).'"></td></tr>';
1347
1348 // Personal phone
1349 print '<tr><td>'.$langs->trans("PhonePerso").'</td>';
1350 print '<td>'.img_picto('', 'object_phoning', 'class="pictofixedwidth"').'<input type="text" name="phone_perso" value="'.(GETPOSTISSET("phone_perso") ? GETPOST("phone_perso") : $object->phone_perso).'"></td></tr>';
1351
1352 // Mobile phone
1353 print '<tr><td>'.$langs->trans("PhoneMobile").'</td>';
1354 print '<td>'.img_picto('', 'object_phoning_mobile', 'class="pictofixedwidth"').'<input type="text" name="phone_mobile" value="'.(GETPOSTISSET("phone_mobile") ? GETPOST("phone_mobile") : $object->phone_mobile).'"></td></tr>';
1355
1356 if (isModEnabled('socialnetworks')) {
1357 foreach ($socialnetworks as $key => $value) {
1358 if (!$value['active']) {
1359 break;
1360 }
1361 print '<tr><td>'.$langs->trans($value['label']).'</td><td><input type="text" name="'.$key.'" class="minwidth100" value="'.(GETPOSTISSET($key) ? GETPOST($key, 'alphanohtml') : (isset($object->socialnetworks[$key]) ? $object->socialnetworks[$key] : null)).'"></td></tr>';
1362 }
1363 }
1364
1365 // Birth Date
1366 print "<tr><td>".$langs->trans("DateOfBirth")."</td><td>\n";
1367 print $form->selectDate(($object->birth ? $object->birth : -1), 'birth', '', '', 1, 'formsoc');
1368 print "</td></tr>\n";
1369
1370 // Default language
1371 if (getDolGlobalInt('MAIN_MULTILANGS')) {
1372 print '<tr><td>'.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).'</td><td colspan="3">'."\n";
1373 print img_picto('', 'language').$formadmin->select_language($object->default_lang, 'default_lang', 0, 0, 1);
1374 print '</td>';
1375 print '</tr>';
1376 }
1377
1378 // Public profil
1379 print "<tr><td>";
1380 $htmltext = $langs->trans("Public", getDolGlobalString('MAIN_INFO_SOCIETE_NOM'), $linkofpubliclist);
1381 print $form->textwithpicto($langs->trans("MembershipPublic"), $htmltext, 1, 'help', '', 0, 3, 'membershippublic');
1382 print "</td><td>\n";
1383 print $form->selectyesno("public", (GETPOSTISSET("public") ? GETPOST("public", 'alphanohtml', 2) : $object->public), 1);
1384 print "</td></tr>\n";
1385
1386 // Categories
1387 if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) {
1388 print '<tr><td>'.$form->editfieldkey("Categories", 'memcats', '', $object, 0).'</td>';
1389 print '<td>';
1390 $cate_arbo = $form->select_all_categories(Categorie::TYPE_MEMBER, null, null, null, null, 1);
1391 $c = new Categorie($db);
1392 $cats = $c->containing($object->id, Categorie::TYPE_MEMBER);
1393 $arrayselected = array();
1394 if (is_array($cats)) {
1395 foreach ($cats as $cat) {
1396 $arrayselected[] = $cat->id;
1397 }
1398 }
1399 print $form->multiselectarray('memcats', $cate_arbo, $arrayselected, '', 0, '', 0, '100%');
1400 print "</td></tr>";
1401 }
1402
1403 // Third party Dolibarr
1404 if (isModEnabled('societe')) {
1405 print '<tr><td>'.$langs->trans("LinkedToDolibarrThirdParty").'</td><td colspan="2" class="valeur">';
1406 if ($object->socid) {
1407 $company = new Societe($db);
1408 $result = $company->fetch($object->socid);
1409 print $company->getNomUrl(1);
1410 } else {
1411 print $langs->trans("NoThirdPartyAssociatedToMember");
1412 }
1413 print '</td></tr>';
1414 }
1415
1416 // Login Dolibarr
1417 print '<tr><td>'.$langs->trans("LinkedToDolibarrUser").'</td><td colspan="2" class="valeur">';
1418 if ($object->user_id) {
1419 $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id, $object->user_id, 'none');
1420 } else {
1421 print $langs->trans("NoDolibarrAccess");
1422 }
1423 print '</td></tr>';
1424
1425 // Other attributes. Fields from hook formObjectOptions and Extrafields.
1426 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
1427
1428 print '</table>';
1429 print dol_get_fiche_end();
1430
1431 print $form->buttonsSaveCancel("Save", 'Cancel');
1432
1433 print '</form>';
1434 }
1435
1436 // View
1437 if ($id > 0 && $action != 'edit') {
1438 $res = $object->fetch($id);
1439 if ($res < 0) {
1440 dol_print_error($db, $object->error);
1441 exit;
1442 }
1443 $res = $object->fetch_optionals();
1444 if ($res < 0) {
1445 dol_print_error($db);
1446 exit;
1447 }
1448
1449 $adht = new AdherentType($db);
1450 $res = $adht->fetch($object->typeid);
1451 if ($res < 0) {
1452 dol_print_error($db);
1453 exit;
1454 }
1455
1456
1457 /*
1458 * Show tabs
1459 */
1460 $head = member_prepare_head($object);
1461
1462 print dol_get_fiche_head($head, 'general', $langs->trans("Member"), -1, 'user');
1463
1464 // Confirm create user
1465 if ($action == 'create_user') {
1466 $login = (GETPOSTISSET('login') ? GETPOST('login', 'alphanohtml') : $object->login);
1467 if (empty($login)) {
1468 // Full firstname and name separated with a dot : firstname.name
1469 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
1470 $login = dol_buildlogin($object->lastname, $object->firstname);
1471 }
1472 if (empty($login)) {
1473 $login = strtolower(substr($object->firstname, 0, 4)).strtolower(substr($object->lastname, 0, 4));
1474 }
1475
1476 // Create a form array
1477 $formquestion = array(
1478 array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login)
1479 );
1480 if (isModEnabled('societe') && $object->socid > 0) {
1481 $object->fetch_thirdparty();
1482 $formquestion[] = array('label' => $langs->trans("UserWillBe"), 'type' => 'radio', 'name' => 'internalorexternal', 'default'=>'external', 'values' => array('external'=>$langs->trans("External").' - '.$langs->trans("LinkedToDolibarrThirdParty").' '.$object->thirdparty->getNomUrl(1, '', 0, 1), 'internal'=>$langs->trans("Internal")));
1483 }
1484 $text = '';
1485 if (isModEnabled('societe') && $object->socid <= 0) {
1486 $text .= $langs->trans("UserWillBeInternalUser").'<br>';
1487 }
1488 $text .= $langs->trans("ConfirmCreateLogin");
1489 print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id, $langs->trans("CreateDolibarrLogin"), $text, "confirm_create_user", $formquestion, 'yes');
1490 }
1491
1492 // Confirm create third party
1493 if ($action == 'create_thirdparty') {
1494 $companyalias = '';
1495 $fullname = $object->getFullName($langs);
1496
1497 if ($object->morphy == 'mor') {
1498 $companyname = $object->company;
1499 if (!empty($fullname)) {
1500 $companyalias = $fullname;
1501 }
1502 } else {
1503 $companyname = $fullname;
1504 if (!empty($object->company)) {
1505 $companyalias = $object->company;
1506 }
1507 }
1508
1509 // Create a form array
1510 $formquestion = array(
1511 array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $companyname, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"'),
1512 array('label' => $langs->trans("AliasNames"), 'type' => 'text', 'name' => 'companyalias', 'value' => $companyalias, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"')
1513 );
1514
1515 print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id, $langs->trans("CreateDolibarrThirdParty"), $langs->trans("ConfirmCreateThirdParty"), "confirm_create_thirdparty", $formquestion, 'yes');
1516 }
1517
1518 // Confirm validate member
1519 if ($action == 'valid') {
1520 $langs->load("mails");
1521
1522 $adht = new AdherentType($db);
1523 $adht->fetch($object->typeid);
1524
1525 $subject = '';
1526 $msg = '';
1527
1528 // Send subscription email
1529 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
1530 $formmail = new FormMail($db);
1531 // Set output language
1532 $outputlangs = new Translate('', $conf);
1533 $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
1534 // Load traductions files required by page
1535 $outputlangs->loadLangs(array("main", "members", "companies", "install", "other"));
1536 // Get email content from template
1537 $arraydefaultmessage = null;
1538 $labeltouse = getDolGlobalString("ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION");
1539
1540 if (!empty($labeltouse)) {
1541 $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
1542 }
1543
1544 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1545 $subject = $arraydefaultmessage->topic;
1546 $msg = $arraydefaultmessage->content;
1547 }
1548
1549 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
1550 complete_substitutions_array($substitutionarray, $outputlangs, $object);
1551 $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
1552 $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs);
1553
1554 $tmp = $langs->trans("SendingAnEMailToMember");
1555 $tmp .= '<br>'.$langs->trans("MailFrom").': <b>'.getDolGlobalString('ADHERENT_MAIL_FROM').'</b>, ';
1556 $tmp .= '<br>'.$langs->trans("MailRecipient").': <b>'.$object->email.'</b>';
1557 $helpcontent = '';
1558 $helpcontent .= '<b>'.$langs->trans("MailFrom").'</b>: '.getDolGlobalString('ADHERENT_MAIL_FROM').'<br>'."\n";
1559 $helpcontent .= '<b>'.$langs->trans("MailRecipient").'</b>: '.$object->email.'<br>'."\n";
1560 $helpcontent .= '<b>'.$langs->trans("Subject").'</b>:<br>'."\n";
1561 $helpcontent .= $subjecttosend."\n";
1562 $helpcontent .= "<br>";
1563 $helpcontent .= '<b>'.$langs->trans("Content").'</b>:<br>';
1564 $helpcontent .= dol_htmlentitiesbr($texttosend)."\n";
1565 $label = $form->textwithpicto($tmp, $helpcontent, 1, 'help');
1566
1567 // Create form popup
1568 $formquestion = array();
1569 if ($object->email) {
1570 $formquestion[] = array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => (getDolGlobalString('ADHERENT_DEFAULT_SENDINFOBYMAIL') ? true : false));
1571 }
1572 if (isModEnabled('mailman') && getDolGlobalString('ADHERENT_USE_MAILMAN')) {
1573 $formquestion[] = array('type'=>'other', 'label'=>$langs->transnoentitiesnoconv("SynchroMailManEnabled"), 'value'=>'');
1574 }
1575 if (isModEnabled('mailman') && getDolGlobalString('ADHERENT_USE_SPIP')) {
1576 $formquestion[] = array('type'=>'other', 'label'=>$langs->transnoentitiesnoconv("SynchroSpipEnabled"), 'value'=>'');
1577 }
1578 print $form->formconfirm("card.php?rowid=".$id, $langs->trans("ValidateMember"), $langs->trans("ConfirmValidateMember"), "confirm_valid", $formquestion, 'yes', 1, 220);
1579 }
1580
1581 // Confirm resiliate
1582 if ($action == 'resiliate') {
1583 $langs->load("mails");
1584
1585 $adht = new AdherentType($db);
1586 $adht->fetch($object->typeid);
1587
1588 $subject = '';
1589 $msg = '';
1590
1591 // Send subscription email
1592 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
1593 $formmail = new FormMail($db);
1594 // Set output language
1595 $outputlangs = new Translate('', $conf);
1596 $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
1597 // Load traductions files required by page
1598 $outputlangs->loadLangs(array("main", "members"));
1599 // Get email content from template
1600 $arraydefaultmessage = null;
1601 $labeltouse = getDolGlobalString('ADHERENT_EMAIL_TEMPLATE_CANCELATION');
1602
1603 if (!empty($labeltouse)) {
1604 $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
1605 }
1606
1607 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1608 $subject = $arraydefaultmessage->topic;
1609 $msg = $arraydefaultmessage->content;
1610 }
1611
1612 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
1613 complete_substitutions_array($substitutionarray, $outputlangs, $object);
1614 $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
1615 $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnResiliate()), $substitutionarray, $outputlangs);
1616
1617 $tmp = $langs->trans("SendingAnEMailToMember");
1618 $tmp .= '<br>('.$langs->trans("MailFrom").': <b>'.getDolGlobalString('ADHERENT_MAIL_FROM').'</b>, ';
1619 $tmp .= $langs->trans("MailRecipient").': <b>'.$object->email.'</b>)';
1620 $helpcontent = '';
1621 $helpcontent .= '<b>'.$langs->trans("MailFrom").'</b>: '.getDolGlobalString('ADHERENT_MAIL_FROM').'<br>'."\n";
1622 $helpcontent .= '<b>'.$langs->trans("MailRecipient").'</b>: '.$object->email.'<br>'."\n";
1623 $helpcontent .= '<b>'.$langs->trans("Subject").'</b>:<br>'."\n";
1624 $helpcontent .= $subjecttosend."\n";
1625 $helpcontent .= "<br>";
1626 $helpcontent .= '<b>'.$langs->trans("Content").'</b>:<br>';
1627 $helpcontent .= dol_htmlentitiesbr($texttosend)."\n";
1628 $label = $form->textwithpicto($tmp, $helpcontent, 1, 'help');
1629
1630 // Create an array
1631 $formquestion = array();
1632 if ($object->email) {
1633 $formquestion[] = array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => (getDolGlobalString('ADHERENT_DEFAULT_SENDINFOBYMAIL') ? 'true' : 'false'));
1634 }
1635 if ($backtopage) {
1636 $formquestion[] = array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]));
1637 }
1638 print $form->formconfirm("card.php?rowid=".$id, $langs->trans("ResiliateMember"), $langs->trans("ConfirmResiliateMember"), "confirm_resiliate", $formquestion, 'no', 1, 240);
1639 }
1640
1641 // Confirm exclude
1642 if ($action == 'exclude') {
1643 $langs->load("mails");
1644
1645 $adht = new AdherentType($db);
1646 $adht->fetch($object->typeid);
1647
1648 $subject = '';
1649 $msg = '';
1650
1651 // Send subscription email
1652 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
1653 $formmail = new FormMail($db);
1654 // Set output language
1655 $outputlangs = new Translate('', $conf);
1656 $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
1657 // Load traductions files required by page
1658 $outputlangs->loadLangs(array("main", "members"));
1659 // Get email content from template
1660 $arraydefaultmessage = null;
1661 $labeltouse = getDolGlobalString('ADHERENT_EMAIL_TEMPLATE_EXCLUSION');
1662
1663 if (!empty($labeltouse)) {
1664 $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
1665 }
1666
1667 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1668 $subject = $arraydefaultmessage->topic;
1669 $msg = $arraydefaultmessage->content;
1670 }
1671
1672 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
1673 complete_substitutions_array($substitutionarray, $outputlangs, $object);
1674 $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
1675 $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnExclude()), $substitutionarray, $outputlangs);
1676
1677 $tmp = $langs->trans("SendingAnEMailToMember");
1678 $tmp .= '<br>('.$langs->trans("MailFrom").': <b>'.getDolGlobalString('ADHERENT_MAIL_FROM').'</b>, ';
1679 $tmp .= $langs->trans("MailRecipient").': <b>'.$object->email.'</b>)';
1680 $helpcontent = '';
1681 $helpcontent .= '<b>'.$langs->trans("MailFrom").'</b>: '.getDolGlobalString('ADHERENT_MAIL_FROM').'<br>'."\n";
1682 $helpcontent .= '<b>'.$langs->trans("MailRecipient").'</b>: '.$object->email.'<br>'."\n";
1683 $helpcontent .= '<b>'.$langs->trans("Subject").'</b>:<br>'."\n";
1684 $helpcontent .= $subjecttosend."\n";
1685 $helpcontent .= "<br>";
1686 $helpcontent .= '<b>'.$langs->trans("Content").'</b>:<br>';
1687 $helpcontent .= dol_htmlentitiesbr($texttosend)."\n";
1688 $label = $form->textwithpicto($tmp, $helpcontent, 1, 'help');
1689
1690 // Create an array
1691 $formquestion = array();
1692 if ($object->email) {
1693 $formquestion[] = array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => (getDolGlobalString('ADHERENT_DEFAULT_SENDINFOBYMAIL') ? 'true' : 'false'));
1694 }
1695 if ($backtopage) {
1696 $formquestion[] = array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]));
1697 }
1698 print $form->formconfirm("card.php?rowid=".$id, $langs->trans("ExcludeMember"), $langs->trans("ConfirmExcludeMember"), "confirm_exclude", $formquestion, 'no', 1, 240);
1699 }
1700
1701 // Confirm remove member
1702 if ($action == 'delete') {
1703 $formquestion = array();
1704 if ($backtopage) {
1705 $formquestion[] = array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]));
1706 }
1707 print $form->formconfirm("card.php?rowid=".$id, $langs->trans("DeleteMember"), $langs->trans("ConfirmDeleteMember"), "confirm_delete", $formquestion, 'no', 1);
1708 }
1709
1710 // Confirm add in spip
1711 if ($action == 'add_spip') {
1712 print $form->formconfirm("card.php?rowid=".$id, $langs->trans('AddIntoSpip'), $langs->trans('AddIntoSpipConfirmation'), 'confirm_add_spip');
1713 }
1714 // Confirm removed from spip
1715 if ($action == 'del_spip') {
1716 print $form->formconfirm("card.php?rowid=$id", $langs->trans('DeleteIntoSpip'), $langs->trans('DeleteIntoSpipConfirmation'), 'confirm_del_spip');
1717 }
1718
1719 $rowspan = 17;
1720 if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
1721 $rowspan++;
1722 }
1723 if (isModEnabled('societe')) {
1724 $rowspan++;
1725 }
1726
1727 $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
1728
1729 $morehtmlref = '<a href="'.DOL_URL_ROOT.'/adherents/vcard.php?id='.$object->id.'" class="refid">';
1730 $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
1731 $morehtmlref .= '</a>';
1732
1733
1734 dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref);
1735
1736 print '<div class="fichecenter">';
1737 print '<div class="fichehalfleft">';
1738
1739 print '<div class="underbanner clearboth"></div>';
1740 print '<table class="border tableforfield centpercent">';
1741
1742 // Login
1743 if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
1744 print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.dol_escape_htmltag($object->login).'</td></tr>';
1745 }
1746
1747 // Type
1748 print '<tr><td class="titlefield">'.$langs->trans("Type").'</td>';
1749 print '<td class="valeur">'.$adht->getNomUrl(1)."</td></tr>\n";
1750
1751 // Morphy
1752 print '<tr><td>'.$langs->trans("MemberNature").'</td>';
1753 print '<td class="valeur" >'.$object->getmorphylib('', 1).'</td>';
1754 print '</tr>';
1755
1756 // Company
1757 print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.dol_escape_htmltag($object->company).'</td></tr>';
1758
1759 // Civility
1760 print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'</td>';
1761 print '</tr>';
1762
1763 // Password
1764 if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
1765 print '<tr><td>'.$langs->trans("Password").'</td><td>';
1766 if ($object->pass) {
1767 print preg_replace('/./i', '*', $object->pass);
1768 } else {
1769 if ($user->admin) {
1770 print '<!-- '.$langs->trans("Crypted").': '.$object->pass_indatabase_crypted.' -->';
1771 }
1772 print '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
1773 }
1774 if (!empty($object->pass_indatabase) && empty($object->user_id)) { // Show warning only for old password still in clear (does not happen anymore)
1775 $langs->load("errors");
1776 $htmltext = $langs->trans("WarningPasswordSetWithNoAccount");
1777 print ' '.$form->textwithpicto('', $htmltext, 1, 'warning');
1778 }
1779 print '</td></tr>';
1780 }
1781
1782 // Date end subscription
1783 print '<tr><td>'.$langs->trans("SubscriptionEndDate").'</td><td class="valeur">';
1784 if ($object->datefin) {
1785 print dol_print_date($object->datefin, 'day');
1786 if ($object->hasDelay()) {
1787 print " ".img_warning($langs->trans("Late"));
1788 }
1789 } else {
1790 if ($object->need_subscription == 0) {
1791 print $langs->trans("SubscriptionNotNeeded");
1792 } elseif (!$adht->subscription) {
1793 print $langs->trans("SubscriptionNotRecorded");
1794 if (Adherent::STATUS_VALIDATED == $object->statut) {
1795 print " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft, not excluded and not resiliated
1796 }
1797 } else {
1798 print $langs->trans("SubscriptionNotReceived");
1799 if (Adherent::STATUS_VALIDATED == $object->statut) {
1800 print " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft, not excluded and not resiliated
1801 }
1802 }
1803 }
1804 print '</td></tr>';
1805
1806 print '</table>';
1807
1808 print '</div>';
1809
1810 print '<div class="fichehalfright">';
1811 print '<div class="underbanner clearboth"></div>';
1812
1813 print '<table class="border tableforfield centpercent">';
1814
1815 // Tags / Categories
1816 if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) {
1817 print '<tr><td>'.$langs->trans("Categories").'</td>';
1818 print '<td colspan="2">';
1819 print $form->showCategories($object->id, Categorie::TYPE_MEMBER, 1);
1820 print '</td></tr>';
1821 }
1822
1823 // Birth Date
1824 print '<tr><td class="titlefield">'.$langs->trans("DateOfBirth").'</td><td class="valeur">'.dol_print_date($object->birth, 'day').'</td></tr>';
1825
1826 // Default language
1827 if (getDolGlobalInt('MAIN_MULTILANGS')) {
1828 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
1829 print '<tr><td>'.$langs->trans("DefaultLang").'</td><td>';
1830 //$s=picto_from_langcode($object->default_lang);
1831 //print ($s?$s.' ':'');
1832 $langs->load("languages");
1833 $labellang = ($object->default_lang ? $langs->trans('Language_'.$object->default_lang) : '');
1834 print picto_from_langcode($object->default_lang, 'class="paddingrightonly saturatemedium opacitylow"');
1835 print $labellang;
1836 print '</td></tr>';
1837 }
1838
1839 // Public
1840 print '<tr><td>';
1841 $htmltext = $langs->trans("Public", getDolGlobalString('MAIN_INFO_SOCIETE_NOM'), $linkofpubliclist);
1842 print $form->textwithpicto($langs->trans("MembershipPublic"), $htmltext, 1, 'help', '', 0, 3, 'membershippublic');
1843 print '</td><td class="valeur">'.yn($object->public).'</td></tr>';
1844
1845 // Other attributes
1846 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
1847
1848 // Third party Dolibarr
1849 if (isModEnabled('societe')) {
1850 print '<tr><td>';
1851 $editenable = $user->hasRight('adherent', 'creer');
1852 print $form->editfieldkey('LinkedToDolibarrThirdParty', 'thirdparty', '', $object, $editenable);
1853 print '</td><td colspan="2" class="valeur">';
1854 if ($action == 'editthirdparty') {
1855 $htmlname = 'socid';
1856 print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" name="form'.$htmlname.'">';
1857 print '<input type="hidden" name="rowid" value="'.$object->id.'">';
1858 print '<input type="hidden" name="action" value="set'.$htmlname.'">';
1859 print '<input type="hidden" name="token" value="'.newToken().'">';
1860 print '<table class="nobordernopadding">';
1861 print '<tr><td>';
1862 print $form->select_company($object->socid, 'socid', '', 1);
1863 print '</td>';
1864 print '<td class="left"><input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'"></td>';
1865 print '</tr></table></form>';
1866 } else {
1867 if ($object->socid) {
1868 $company = new Societe($db);
1869 $result = $company->fetch($object->socid);
1870 print $company->getNomUrl(1);
1871
1872 // Show link to invoices
1873 $tmparray = $company->getOutstandingBills('customer');
1874 if (!empty($tmparray['refs'])) {
1875 print ' - '.img_picto($langs->trans("Invoices"), 'bill', 'class="paddingright"').'<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->socid.'">'.$langs->trans("Invoices").' ('.count($tmparray['refs']).')';
1876 // TODO Add alert if warning on at least one invoice late
1877 print '</a>';
1878 }
1879 } else {
1880 print '<span class="opacitymedium">'.$langs->trans("NoThirdPartyAssociatedToMember").'</span>';
1881 }
1882 }
1883 print '</td></tr>';
1884 }
1885
1886 // Login Dolibarr - Link to user
1887 print '<tr><td>';
1888 $editenable = $user->hasRight('adherent', 'creer') && $user->hasRight('user', 'user', 'creer');
1889 print $form->editfieldkey('LinkedToDolibarrUser', 'login', '', $object, $editenable);
1890 print '</td><td colspan="2" class="valeur">';
1891 if ($action == 'editlogin') {
1892 $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id, $object->user_id, 'userid', '');
1893 } else {
1894 if ($object->user_id) {
1895 $linkeduser = new User($db);
1896 $linkeduser->fetch($object->user_id);
1897 print $linkeduser->getNomUrl(-1);
1898 } else {
1899 print '<span class="opacitymedium">'.$langs->trans("NoDolibarrAccess").'</span>';
1900 }
1901 }
1902 print '</td></tr>';
1903
1904 print "</table>\n";
1905
1906 print "</div></div>\n";
1907 print '<div class="clearboth"></div>';
1908
1909 print dol_get_fiche_end();
1910
1911
1912 /*
1913 * Action bar
1914 */
1915
1916 print '<div class="tabsAction">';
1917 $isinspip = 0;
1918 $parameters = array();
1919 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
1920 if (empty($reshook)) {
1921 if ($action != 'editlogin' && $action != 'editthirdparty') {
1922 // Send
1923 if (empty($user->socid)) {
1924 if (Adherent::STATUS_VALIDATED == $object->statut) {
1925 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.((int) $object->id).'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a>'."\n";
1926 }
1927 }
1928
1929 // Send card by email
1930 // TODO Remove this to replace with a template
1931 /*
1932 if ($user->hasRight('adherent', 'creer')) {
1933 if (Adherent::STATUS_VALIDATED == $object->statut) {
1934 if ($object->email) print '<a class="butAction" href="card.php?rowid='.$object->id.'&action=sendinfo">'.$langs->trans("SendCardByMail")."</a>\n";
1935 else print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NoEMail")).'">'.$langs->trans("SendCardByMail")."</a>\n";
1936 } else {
1937 print '<span class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("SendCardByMail")."</span>";
1938 }
1939 } else {
1940 print '<span class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("SendCardByMail")."</span>";
1941 }*/
1942
1943 // Modify
1944 if ($user->hasRight('adherent', 'creer')) {
1945 print '<a class="butAction" href="card.php?rowid='.((int) $object->id).'&action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>'."\n";
1946 } else {
1947 print '<span class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Modify").'</span>'."\n";
1948 }
1949
1950 // Validate
1951 if (Adherent::STATUS_DRAFT == $object->statut) {
1952 if ($user->hasRight('adherent', 'creer')) {
1953 print '<a class="butAction" href="card.php?rowid='.((int) $object->id).'&action=valid&token='.newToken().'">'.$langs->trans("Validate").'</a>'."\n";
1954 } else {
1955 print '<span class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Validate").'</span>'."\n";
1956 }
1957 }
1958
1959 // Reactivate
1960 if (Adherent::STATUS_RESILIATED == $object->statut || Adherent::STATUS_EXCLUDED == $object->statut) {
1961 if ($user->hasRight('adherent', 'creer')) {
1962 print '<a class="butAction" href="card.php?rowid='.((int) $object->id).'&action=valid">'.$langs->trans("Reenable")."</a>\n";
1963 } else {
1964 print '<span class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Reenable").'</span>'."\n";
1965 }
1966 }
1967
1968 // Resiliate
1969 if (Adherent::STATUS_VALIDATED == $object->statut) {
1970 if ($user->hasRight('adherent', 'supprimer')) {
1971 print '<a class="butAction" href="card.php?rowid='.((int) $object->id).'&action=resiliate">'.$langs->trans("Resiliate")."</a></span>\n";
1972 } else {
1973 print '<span class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Resiliate").'</span>'."\n";
1974 }
1975 }
1976
1977 // Exclude
1978 if (Adherent::STATUS_VALIDATED == $object->statut) {
1979 if ($user->hasRight('adherent', 'supprimer')) {
1980 print '<a class="butAction" href="card.php?rowid='.((int) $object->id).'&action=exclude">'.$langs->trans("Exclude")."</a></span>\n";
1981 } else {
1982 print '<span class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Exclude").'</span>'."\n";
1983 }
1984 }
1985
1986 // Create third party
1987 if (isModEnabled('societe') && !$object->socid) {
1988 if ($user->hasRight('societe', 'creer')) {
1989 if (Adherent::STATUS_DRAFT != $object->statut) {
1990 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.((int) $object->id).'&amp;action=create_thirdparty" title="'.dol_escape_htmltag($langs->trans("CreateDolibarrThirdPartyDesc")).'">'.$langs->trans("CreateDolibarrThirdParty").'</a>'."\n";
1991 } else {
1992 print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("CreateDolibarrThirdParty").'</a>'."\n";
1993 }
1994 } else {
1995 print '<span class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("CreateDolibarrThirdParty").'</span>'."\n";
1996 }
1997 }
1998
1999 // Create user
2000 if (!$user->socid && !$object->user_id) {
2001 if ($user->hasRight('user', 'user', 'creer')) {
2002 if (Adherent::STATUS_DRAFT != $object->statut) {
2003 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.((int) $object->id).'&amp;action=create_user" title="'.dol_escape_htmltag($langs->trans("CreateDolibarrLoginDesc")).'">'.$langs->trans("CreateDolibarrLogin").'</a>'."\n";
2004 } else {
2005 print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("CreateDolibarrLogin").'</a>'."\n";
2006 }
2007 } else {
2008 print '<span class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("CreateDolibarrLogin").'</span>'."\n";
2009 }
2010 }
2011
2012 // Action SPIP
2013 if (isModEnabled('mailmanspip') && getDolGlobalString('ADHERENT_USE_SPIP')) {
2014 $isinspip = $mailmanspip->is_in_spip($object);
2015
2016 if ($isinspip == 1) {
2017 print '<a class="butAction" href="card.php?rowid='.((int) $object->id).'&action=del_spip&token='.newToken().'">'.$langs->trans("DeleteIntoSpip").'</a>'."\n";
2018 }
2019 if ($isinspip == 0) {
2020 print '<a class="butAction" href="card.php?rowid='.((int) $object->id).'&action=add_spip&token='.newToken().'">'.$langs->trans("AddIntoSpip").'</a>'."\n";
2021 }
2022 }
2023
2024 // Delete
2025 if ($user->hasRight('adherent', 'supprimer')) {
2026 print '<a class="butActionDelete" href="card.php?rowid='.((int) $object->id).'&action=delete&token='.newToken().'">'.$langs->trans("Delete").'</a>'."\n";
2027 } else {
2028 print '<span class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Delete").'</span>'."\n";
2029 }
2030 }
2031 }
2032 print '</div>';
2033
2034 if ($isinspip == -1) {
2035 print '<br><br><span class="error">'.$langs->trans('SPIPConnectionFailed').': '.$mailmanspip->error.'</span>';
2036 }
2037
2038
2039 // Select mail models is same action as presend
2040 if (GETPOST('modelselected')) {
2041 $action = 'presend';
2042 }
2043
2044 if ($action != 'presend') {
2045 print '<div class="fichecenter"><div class="fichehalfleft">';
2046 print '<a name="builddoc"></a>'; // ancre
2047
2048 // Generated documents
2049 $filename = dol_sanitizeFileName($object->ref);
2050 $filedir = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'member');
2051 $urlsource = $_SERVER['PHP_SELF'].'?id='.$object->id;
2052 $genallowed = $user->hasRight('adherent', 'lire');
2053 $delallowed = $user->hasRight('adherent', 'creer');
2054
2055 print $formfile->showdocuments('member', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', (empty($object->default_lang) ? '' : $object->default_lang), '', $object);
2056 $somethingshown = $formfile->numoffiles;
2057
2058 // Show links to link elements
2059 //$linktoelem = $form->showLinkToObjectBlock($object, null, array('subscription'));
2060 //$somethingshown = $form->showLinkedObjectBlock($object, '');
2061
2062 // Show links to link elements
2063 /*$linktoelem = $form->showLinkToObjectBlock($object,array('order'));
2064 if ($linktoelem) {
2065 print ($somethingshown?'':'<br>').$linktoelem;
2066 }
2067 */
2068
2069 // Show online payment link
2070 $useonlinepayment = (isModEnabled('paypal') || isModEnabled('stripe') || isModEnabled('paybox'));
2071
2072 if ($useonlinepayment) {
2073 print '<br>';
2074 if (empty($amount)) { // Take the maximum amount among what the member is supposed to pay / has paid in the past
2075 $amount = max($adht->amount, $object->first_subscription_amount, $object->last_subscription_amount);
2076 }
2077 if (empty($amount)) {
2078 $amount = 0;
2079 }
2080 require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
2081 print showOnlinePaymentUrl('membersubscription', $object->ref, $amount);
2082 }
2083
2084 print '</div><div class="fichehalfright">';
2085
2086 $MAX = 10;
2087
2088 $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/adherents/agenda.php?id='.$object->id);
2089
2090 // List of actions on element
2091 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
2092 $formactions = new FormActions($db);
2093 $somethingshown = $formactions->showactions($object, $object->element, $socid, 1, 'listactions', $MAX, '', $morehtmlcenter);
2094
2095 print '</div></div>';
2096 }
2097
2098 // Presend form
2099 $modelmail = 'member';
2100 $defaulttopic = 'CardContent';
2101 $diroutput = $conf->adherent->dir_output;
2102 $trackid = 'mem'.$object->id;
2103
2104 include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
2105 }
2106}
2107
2108// End of page
2109llxFooter();
2110$db->close();
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif( $action=='specimen') elseif($action=='setmodel') elseif( $action=='del') elseif($action=='setdoc') $formactions
View.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Class to manage members of a foundation.
const STATUS_EXCLUDED
Excluded.
const STATUS_DRAFT
Draft status.
const STATUS_RESILIATED
Resiliated.
const STATUS_VALIDATED
Validated status.
Class to manage members type.
Class to manage canvas.
Class to manage categories.
Class to manage standard extra fields.
Class to manage building of HTML components.
Class to generate html code for admin pages.
Class to build HTML component for third parties management Only common components are here.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Classe permettant la generation du formulaire html d'envoi de mail unitaire Usage: $formail = new For...
Class to manage mailman and spip.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0, $nohook=0, $varfiles='addedfile', $upload_dir='')
Make control on an uploaded file from an GUI page and move it to final destination.
dol_buildlogin($lastname, $firstname)
Build a login from lastname, firstname.
isValidUrl($url, $http=0, $pass=0, $port=0, $path=0, $query=0, $anchor=0)
Url string validation <http[s]> :// [user[:pass]@] hostname [port] [/path] [?getquery] [anchor].
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.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
getArrayOfSocialNetworks()
Get array of social network dictionary.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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...
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null, $include=null)
Return array of possible common substitutions.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.
member_prepare_head(Adherent $object)
Return array head with list of tabs to view object informations.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:124
getRandomPassword($generic=false, $replaceambiguouschars=null, $length=32)
Return a generated password using default module.
getMaxFileSizeArray()
Return the max allowed for file upload.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.