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