dolibarr 23.0.4
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-2025 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';
44require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
45require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
46require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
47require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
48require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
49require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
50require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
51require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
52require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
53require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
54require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.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$extrafields = new ExtraFields($db);
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 = ".$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']) && empty($_FILES['photo']['error'])) {
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 $langs->load("errors");
471 setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors');
472 }
473 } else {
474 switch ($_FILES['photo']['error']) {
475 case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
476 case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
477 $langs->load("errors");
478 setEventMessages($langs->trans("ErrorFileSizeTooLarge"), null, 'errors');
479 break;
480 case 3: //uploaded file was only partially uploaded
481 setEventMessages($langs->trans("ErrorFileNotUploaded"), null, 'errors');
482 break;
483 }
484 }
485
486 $rowid = $object->id;
487 $id = $object->id;
488 $action = '';
489
490 if (!empty($backtopage)) {
491 header("Location: ".$backtopage);
492 exit;
493 }
494 } else {
495 setEventMessages($object->error, $object->errors, 'errors');
496 $action = '';
497 }
498 } else {
499 $action = 'edit';
500 }
501 } else {
502 $action = 'edit';
503 }
504 }
505
506 if ($action == 'add' && $user->hasRight('adherent', 'creer')) {
507 if ($canvas) {
508 $object->canvas = $canvas;
509 }
510 $birthdate = '';
511 if (GETPOSTISSET("birthday") && GETPOST("birthday") && GETPOSTISSET("birthmonth") && GETPOST("birthmonth") && GETPOSTISSET("birthyear") && GETPOST("birthyear")) {
512 $birthdate = dol_mktime(12, 0, 0, GETPOSTINT("birthmonth"), GETPOSTINT("birthday"), GETPOSTINT("birthyear"));
513 }
514 $datesubscription = '';
515 if (GETPOSTISSET("reday") && GETPOSTISSET("remonth") && GETPOSTISSET("reyear")) {
516 $datesubscription = dol_mktime(12, 0, 0, GETPOSTINT("remonth"), GETPOSTINT("reday"), GETPOSTINT("reyear"));
517 }
518
519 $typeid = GETPOSTINT("typeid");
520 $civility_code = GETPOST("civility_code", 'alphanohtml');
521 $lastname = GETPOST("lastname", 'alphanohtml');
522 $firstname = GETPOST("firstname", 'alphanohtml');
523 $gender = GETPOST("gender", 'alphanohtml');
524 $societe = GETPOST("societe", 'alphanohtml');
525 $address = GETPOST("address", 'alphanohtml');
526 $zip = GETPOST("zipcode", 'alphanohtml');
527 $town = GETPOST("town", 'alphanohtml');
528 $state_id = GETPOSTINT("state_id");
529 $country_id = GETPOSTINT("country_id");
530
531 $phone = GETPOST("phone", 'alpha');
532 $phone_perso = GETPOST("phone_perso", 'alpha');
533 $phone_mobile = GETPOST("phone_mobile", 'alpha');
534 $email = preg_replace('/\s+/', '', GETPOST("member_email", 'aZ09arobase'));
535 $url = trim(GETPOST('url', 'url'));
536 $login = GETPOST("member_login", 'alphanohtml');
537 $pass = GETPOST("password", 'password'); // For password, we use 'none'
538 $photo = GETPOST("photo", 'alphanohtml');
539 $morphy = GETPOST("morphy", 'alphanohtml');
540 $public = GETPOSTINT("public");
541
542 $userid = GETPOSTINT("userid");
543 $socid = GETPOSTINT("socid");
544 $default_lang = GETPOST('default_lang', 'alpha');
545
546 $object->civility_code = $civility_code;
547 $object->firstname = $firstname;
548 $object->lastname = $lastname;
549 $object->gender = $gender;
550 $object->societe = $societe; // deprecated
551 $object->company = $societe;
552 $object->address = $address;
553 $object->zip = $zip;
554 $object->town = $town;
555 $object->state_id = $state_id;
556 $object->country_id = $country_id;
557 $object->phone = $phone;
558 $object->phone_perso = $phone_perso;
559 $object->phone_mobile = $phone_mobile;
560 $object->socialnetworks = array();
561 if (isModEnabled('socialnetworks')) {
562 foreach ($socialnetworks as $key => $value) {
563 if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') {
564 $object->socialnetworks[$key] = GETPOST("member_".$key, 'alphanohtml');
565 }
566 }
567 }
568
569 $object->email = $email;
570 $object->url = $url;
571 $object->login = $login;
572 $object->pass = $pass;
573 $object->birth = $birthdate;
574 $object->photo = $photo;
575 $object->typeid = $typeid;
576 //$object->note = $comment;
577 $object->morphy = $morphy;
578 $object->user_id = $userid;
579 $object->socid = $socid;
580 $object->public = $public;
581 $object->default_lang = $default_lang;
582 // Fill array 'array_options' with data from add form
583 $ret = $extrafields->setOptionalsFromPost(null, $object);
584 if ($ret < 0) {
585 $error++;
586 }
587
588 // Check parameters
589 if (empty($morphy) || $morphy == "-1") {
590 $error++;
591 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MemberNature")), null, 'errors');
592 }
593 // Tests if the login already exists
594 if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
595 if (empty($login)) {
596 $error++;
597 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login")), null, 'errors');
598 } else {
599 $sql = "SELECT login FROM ".MAIN_DB_PREFIX."adherent WHERE login='".$db->escape($login)."'";
600 $result = $db->query($sql);
601 $num = 0;
602 if ($result) {
603 $num = $db->num_rows($result);
604 }
605 if ($num) {
606 $error++;
607 $langs->load("errors");
608 setEventMessages($langs->trans("ErrorLoginAlreadyExists", $login), null, 'errors');
609 }
610 }
611 if (empty($pass)) {
612 $error++;
613 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Password")), null, 'errors');
614 }
615 }
616 if ($morphy == 'mor' && empty($societe)) {
617 $error++;
618 $langs->load("errors");
619 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Company")), null, 'errors');
620 }
621 if ($morphy != 'mor' && empty($lastname)) {
622 $error++;
623 $langs->load("errors");
624 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname")), null, 'errors');
625 }
626 if ($morphy != 'mor' && (!isset($firstname) || $firstname == '')) {
627 $error++;
628 $langs->load("errors");
629 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Firstname")), null, 'errors');
630 }
631 if (!($typeid > 0)) { // Keep () before !
632 $error++;
633 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
634 }
635 if (getDolGlobalString('ADHERENT_MAIL_REQUIRED') && !isValidEmail($email)) {
636 $error++;
637 $langs->load("errors");
638 setEventMessages($langs->trans("ErrorBadEMail", $email), null, 'errors');
639 }
640 if (!empty($object->url) && !isValidUrl($object->url)) {
641 $langs->load("errors");
642 setEventMessages($langs->trans("ErrorBadUrl", $object->url), null, 'errors');
643 }
644
645 if (!$error) {
646 $db->begin();
647
648 // Create the member
649 $result = $object->create($user);
650 if ($result > 0) {
651 // Foundation categories
652 $memcats = GETPOST('memcats', 'array');
653 $object->setCategories($memcats);
654
655 $db->commit();
656
657 $rowid = $object->id;
658 $id = $object->id;
659
660 $backtopage = preg_replace('/__ID__/', (string) $id, $backtopage);
661 } else {
662 $db->rollback();
663
664 $error++;
665 setEventMessages($object->error, $object->errors, 'errors');
666 }
667
668 // Auto-create thirdparty on member creation
669 if (getDolGlobalString('ADHERENT_DEFAULT_CREATE_THIRDPARTY')) {
670 if ($result > 0) {
671 // Create third party out of a member
672 $company = new Societe($db);
673 $result = $company->create_from_member($object);
674 if ($result < 0) {
675 $langs->load("errors");
676 setEventMessages($langs->trans($company->error), null, 'errors');
677 setEventMessages($company->error, $company->errors, 'errors');
678 }
679 } else {
680 setEventMessages($object->error, $object->errors, 'errors');
681 }
682 }
683 }
684 $action = ($result < 0 || !$error) ? '' : 'create';
685
686 if (!$error && $backtopage) {
687 header("Location: ".$backtopage);
688 exit;
689 }
690 }
691
692 if ($user->hasRight('adherent', 'supprimer') && $action == 'confirm_delete' && $confirm == 'yes') {
693 $result = $object->delete($user);
694 if ($result > 0) {
695 setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
696 if (!empty($backtopage) && !preg_match('/'.preg_quote($_SERVER["PHP_SELF"], '/').'/', $backtopage)) {
697 header("Location: ".$backtopage);
698 exit;
699 } else {
700 header("Location: list.php");
701 exit;
702 }
703 } else {
704 setEventMessages($object->error, null, 'errors');
705 }
706 }
707
708 if ($user->hasRight('adherent', 'creer') && $action == 'confirm_valid' && $confirm == 'yes') {
709 $error = 0;
710
711 $db->begin();
712
713 $adht = new AdherentType($db);
714 $adht->fetch($object->typeid);
715
716 $result = $object->validate($user);
717
718 if ($result >= 0 && !count($object->errors)) {
719 // Send confirmation email (according to parameters of member type. Otherwise generic)
720 if ($object->email && GETPOST("send_mail")) {
721 $subject = '';
722 $msg = '';
723
724 // Send subscription email
725 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
726 $formmail = new FormMail($db);
727 // Set output language
728 $outputlangs = new Translate('', $conf);
729 $outputlangs->setDefaultLang(!empty($object->default_lang) ? $object->default_lang : (empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang));
730 // Load traductions files required by page
731 $outputlangs->loadLangs(array("main", "members", "companies", "install", "other"));
732 // Get email content from template
733 $arraydefaultmessage = null;
734 $labeltouse = getDolGlobalString('ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION');
735
736 if (!empty($labeltouse)) {
737 $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
738 }
739
740 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
741 $subject = (string) $arraydefaultmessage->topic;
742 $msg = (string) $arraydefaultmessage->content;
743 }
744
745 if (empty($labeltouse) || (int) $labeltouse === -1) {
746 //fallback on the old configuration.
747 $langs->load("errors");
748 setEventMessages('<a href="'.DOL_URL_ROOT.'/adherents/admin/member_emails.php">'.$langs->trans('WarningMandatorySetupNotComplete').'</a>', null, 'errors');
749 $error++;
750 } else {
751 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
752 complete_substitutions_array($substitutionarray, $outputlangs, $object);
753 $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
754 $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs);
755
756 $moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/card.php'."\r\n";
757
758 $result = $object->sendEmail($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader);
759 if ($result < 0) {
760 $error++;
761 setEventMessages($object->error, $object->errors, 'errors');
762 }
763 }
764 }
765 } else {
766 $error++;
767 setEventMessages($object->error, $object->errors, 'errors');
768 }
769
770 if (!$error) {
771 $db->commit();
772 } else {
773 $db->rollback();
774 }
775 $action = '';
776 }
777
778 if ($user->hasRight('adherent', 'supprimer') && $action == 'confirm_resiliate') {
779 $error = 0;
780
781 if ($confirm == 'yes') {
782 $adht = new AdherentType($db);
783 $adht->fetch($object->typeid);
784
785 $result = $object->resiliate($user);
786
787 if ($result >= 0 && !count($object->errors)) {
788 if ($object->email && GETPOST("send_mail")) {
789 $subject = '';
790 $msg = '';
791
792 // Send subscription email
793 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
794 $formmail = new FormMail($db);
795 // Set output language
796 $outputlangs = new Translate('', $conf);
797 $outputlangs->setDefaultLang(!empty($object->default_lang) ? $object->default_lang : (empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang));
798 // Load traductions files required by page
799 $outputlangs->loadLangs(array("main", "members", "companies", "install", "other"));
800 // Get email content from template
801 $arraydefaultmessage = null;
802 $labeltouse = getDolGlobalString('ADHERENT_EMAIL_TEMPLATE_CANCELATION');
803
804 if (!empty($labeltouse)) {
805 $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
806 }
807
808 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
809 $subject = (string) $arraydefaultmessage->topic;
810 $msg = (string) $arraydefaultmessage->content;
811 }
812
813 if (empty($labeltouse) || (int) $labeltouse === -1) {
814 //fallback on the old configuration.
815 setEventMessages('WarningMandatorySetupNotComplete', null, 'errors');
816 $error++;
817 } else {
818 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
819 complete_substitutions_array($substitutionarray, $outputlangs, $object);
820 $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
821 $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnResiliate()), $substitutionarray, $outputlangs);
822
823 $moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/card.php'."\r\n";
824
825 $result = $object->sendEmail($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader);
826 if ($result < 0) {
827 $error++;
828 setEventMessages($object->error, $object->errors, 'errors');
829 }
830 }
831 }
832 } else {
833 $error++;
834
835 setEventMessages($object->error, $object->errors, 'errors');
836 $action = '';
837 }
838 }
839 if (!empty($backtopage) && !$error) {
840 header("Location: ".$backtopage);
841 exit;
842 }
843 }
844
845 if ($user->hasRight('adherent', 'supprimer') && $action == 'confirm_exclude') {
846 $error = 0;
847
848 if ($confirm == 'yes') {
849 $adht = new AdherentType($db);
850 $adht->fetch($object->typeid);
851
852 $result = $object->exclude($user);
853
854 if ($result >= 0 && !count($object->errors)) {
855 if ($object->email && GETPOST("send_mail")) {
856 $subject = '';
857 $msg = '';
858
859 // Send subscription email
860 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
861 $formmail = new FormMail($db);
862 // Set output language
863 $outputlangs = new Translate('', $conf);
864 $outputlangs->setDefaultLang(!empty($object->default_lang) ? $object->default_lang : (empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang));
865 // Load traductions files required by page
866 $outputlangs->loadLangs(array("main", "members", "companies", "install", "other"));
867 // Get email content from template
868 $arraydefaultmessage = null;
869 $labeltouse = getDolGlobalString('ADHERENT_EMAIL_TEMPLATE_EXCLUSION');
870
871 if (!empty($labeltouse)) {
872 $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
873 }
874
875 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
876 $subject = (string) $arraydefaultmessage->topic;
877 $msg = (string) $arraydefaultmessage->content;
878 }
879
880 if (empty($labeltouse) || (int) $labeltouse === -1) {
881 //fallback on the old configuration.
882 setEventMessages('WarningMandatorySetupNotComplete', null, 'errors');
883 $error++;
884 } else {
885 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
886 complete_substitutions_array($substitutionarray, $outputlangs, $object);
887 $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
888 $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnExclude()), $substitutionarray, $outputlangs);
889
890 $moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/card.php'."\r\n";
891
892 $result = $object->sendEmail($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader);
893 if ($result < 0) {
894 $error++;
895 setEventMessages($object->error, $object->errors, 'errors');
896 }
897 }
898 }
899 } else {
900 $error++;
901
902 setEventMessages($object->error, $object->errors, 'errors');
903 $action = '';
904 }
905 }
906 if (!empty($backtopage) && !$error) {
907 header("Location: ".$backtopage);
908 exit;
909 }
910 }
911
912 if ($action == 'update_extras' && $permissiontoeditextra) {
913 $object->oldcopy = dol_clone($object, 2); // @phan-suppress-current-line PhanTypeMismatchProperty
914 $attribute_name = GETPOST('attribute', 'aZ09');
915
916 // Fill array 'array_options' with data from update form
917 $ret = $extrafields->setOptionalsFromPost(null, $object, $attribute_name);
918 if ($ret < 0) {
919 $error++;
920 }
921 if (!$error) {
922 $result = $object->updateExtraField($attribute_name, 'MEMBER_MODIFY');
923 if ($result < 0) {
924 setEventMessages($object->error, $object->errors, 'errors');
925 $error++;
926 }
927 }
928 if ($error) {
929 $action = 'edit_extras';
930 }
931 }
932
933 // SPIP Management
934 if (is_object($mailmanspip)) {
935 if ($user->hasRight('adherent', 'supprimer') && $action == 'confirm_del_spip' && $confirm == 'yes') {
936 if (!count($object->errors)) {
937 if (!$mailmanspip->del_to_spip($object)) {
938 setEventMessages($langs->trans('DeleteIntoSpipError').': '.$mailmanspip->error, null, 'errors');
939 }
940 }
941 }
942
943 if ($user->hasRight('adherent', 'creer') && $action == 'confirm_add_spip' && $confirm == 'yes') {
944 if (!count($object->errors)) {
945 if (!$mailmanspip->add_to_spip($object)) {
946 setEventMessages($langs->trans('AddIntoSpipError').': '.$mailmanspip->error, null, 'errors');
947 }
948 }
949 }
950 }
951
952 // Actions when printing a doc from card
953 include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
954
955 // Actions to build doc
956 $upload_dir = $conf->member->dir_output;
957 $permissiontoadd = $user->hasRight('adherent', 'creer');
958 include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
959
960 // Actions to send emails
961 $triggersendname = 'MEMBER_SENTBYMAIL';
962 $paramname = 'id';
963 $mode = 'emailfrommember';
964 $trackid = 'mem'.$object->id;
965 include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
966}
967
968
969/*
970 * View
971 */
972
973$form = new Form($db);
974$formfile = new FormFile($db);
975$formadmin = new FormAdmin($db);
976$formcompany = new FormCompany($db);
977
978$title = $langs->trans("Member")." - ".$langs->trans("Card");
979$help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros|DE:Modul_Mitglieder';
980
981llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-member page-card');
982
983$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
984
985if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
986 // -----------------------------------------
987 // When used with CANVAS
988 // -----------------------------------------
989 if (empty($object->error) && $id) {
990 $object = new Adherent($db);
991 $result = $object->fetch($id);
992 if ($result <= 0) {
993 dol_print_error(null, $object->error);
994 }
995 }
996 $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates
997 $objcanvas->display_canvas($action); // Show template
998} else {
999 // -----------------------------------------
1000 // When used in standard mode
1001 // -----------------------------------------
1002
1003 // Create mode
1004 if ($action == 'create') {
1005 $object->canvas = $canvas;
1006 $object->state_id = GETPOSTINT('state_id');
1007
1008 // We set country_id, country_code and country for the selected country
1009 $object->country_id = GETPOSTINT('country_id') ? GETPOSTINT('country_id') : $mysoc->country_id;
1010 if ($object->country_id) {
1011 $tmparray = getCountry($object->country_id, 'all');
1012 $object->country_code = $tmparray['code'];
1013 $object->country = $tmparray['label'];
1014 }
1015
1016 $soc = new Societe($db);
1017 if (!empty($socid)) {
1018 if ($socid > 0) {
1019 $soc->fetch($socid);
1020 }
1021
1022 if (!($soc->id > 0)) {
1023 $langs->load("errors");
1024 print($langs->trans('ErrorRecordNotFound'));
1025 exit;
1026 }
1027 }
1028
1029 $adht = new AdherentType($db);
1030
1031 print load_fiche_titre($langs->trans("NewMember"), '', $object->picto);
1032
1033 if ($conf->use_javascript_ajax) {
1034 print "\n".'<script type="text/javascript">'."\n";
1035 print 'jQuery(document).ready(function () {
1036 jQuery("#selectcountry_id").change(function() {
1037 document.formsoc.action.value="create";
1038 document.formsoc.submit();
1039 });
1040 function initfieldrequired() {
1041 jQuery("#tdcompany").removeClass("fieldrequired");
1042 jQuery("#tdlastname").removeClass("fieldrequired");
1043 jQuery("#tdfirstname").removeClass("fieldrequired");
1044 if (jQuery(\'input[name="morphy"]:checked\').val() == \'mor\') {
1045 jQuery("#tdcompany").addClass("fieldrequired");
1046 }
1047 if (jQuery(\'input[name="morphy"]:checked\').val() == \'phy\') {
1048 jQuery("#tdlastname").addClass("fieldrequired");
1049 jQuery("#tdfirstname").addClass("fieldrequired");
1050 }
1051 }
1052 jQuery(\'input[name="morphy"]\').change(function() {
1053 initfieldrequired();
1054 });
1055 initfieldrequired();
1056 })';
1057 print '</script>'."\n";
1058 }
1059
1060 print '<form name="formsoc" action="'.$_SERVER["PHP_SELF"].'" method="post" enctype="multipart/form-data">';
1061 print '<input type="hidden" name="token" value="'.newToken().'">';
1062 print '<input type="hidden" name="action" value="add">';
1063 print '<input type="hidden" name="socid" value="'.$socid.'">';
1064 if ($backtopage) {
1065 print '<input type="hidden" name="backtopage" value="'.($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]).'">';
1066 }
1067
1068 print dol_get_fiche_head(array());
1069
1070 print '<table class="border centpercent">';
1071 print '<tbody>';
1072
1073 // Login
1074 if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
1075 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>';
1076 }
1077
1078 // Password
1079 if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
1080 require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
1081 $generated_password = getRandomPassword(false);
1082 print '<tr><td><span class="fieldrequired">'.$langs->trans("Password").'</span></td><td>';
1083 print '<input type="password" class="minwidth300" maxlength="50" name="password" value="'.dol_escape_htmltag(GETPOST('password') ? GETPOST('password') : $generated_password).'">';
1084 print '</td></tr>';
1085 }
1086
1087 // Type
1088 print '<tr><td class="fieldrequired">'.$langs->trans("MemberType").'</td><td>';
1089 $listetype = $adht->liste_array(1);
1090 print img_picto('', $adht->picto, 'class="pictofixedwidth"');
1091 if (count($listetype)) {
1092 print $form->selectarray("typeid", $listetype, (GETPOSTINT('typeid') ? GETPOSTINT('typeid') : $typeid), (count($listetype) > 1 ? 1 : 0), 0, 0, '', 0, 0, 0, '', 'minwidth200', 1);
1093 } else {
1094 print '<span class="error">'.$langs->trans("NoTypeDefinedGoToSetup").'</span>';
1095 }
1096 if ($user->hasRight('member', 'configurer')) {
1097 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>';
1098 }
1099 print "</td>\n";
1100
1101 // Legal entity or natural person
1102 $morphys = [
1103 "phy" => $langs->trans("Physical"),
1104 "mor" => $langs->trans("Moral"),
1105 ];
1106 $checkednature = GETPOST("morphy", 'alpha');
1107 $listetype_natures = $adht->morphyByType(1);
1108 $listetype_natures_json = json_encode($listetype_natures);
1109
1110 print '<tr><td class="fieldrequired">'.$langs->trans("MemberNature")."</td><td>\n";
1111 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>';
1112 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>';
1113
1114 // Add JS to manage the background of nature
1115 if ($conf->use_javascript_ajax) {
1116 print "<script>
1117 var listetype_natures = $listetype_natures_json;
1118 </script>";
1119 print '<script>
1120 jQuery(function($) {
1121 function refreshNatureCss() {
1122 $(".spannature").each(function(index) {
1123 let $span = $("#spannature" + (index + 1));
1124 let checked = $span.find(".checkforselect").is(":checked");
1125
1126 if (checked) {
1127 if (index === 0) {
1128 $span.addClass("member-individual-back").removeClass("nonature-back member-company-back");
1129 } else if (index === 1) {
1130 $span.addClass("member-company-back").removeClass("nonature-back member-individual-back");
1131 }
1132 } else {
1133 $span.removeClass("member-individual-back member-company-back")
1134 .addClass("nonature-back");
1135 }
1136 });
1137 }
1138
1139 $(".spannature").on("click", function() {
1140 console.log("Nature clicked");
1141 refreshNatureCss();
1142 });
1143
1144 $("#typeid").on("change", function() {
1145 let morphy = listetype_natures[$(this).val()];
1146
1147 let $phyInput = $("#phisicalinput");
1148 let $morInput = $("#moralinput");
1149 let $tdLast = $("#tdlastname");
1150 let $tdFirst = $("#tdfirstname");
1151 let $tdCompany = $("#tdcompany");
1152 let $span1 = $("#spannature1");
1153 let $span2 = $("#spannature2");
1154
1155 switch (morphy) {
1156 case "phy":
1157 $phyInput.prop({disabled: false, checked: true});
1158 $morInput.prop({disabled: true, checked: false});
1159 $span1.addClass("member-individual-back").removeClass("nonature-back");
1160 $span2.removeClass("member-company-back").addClass("nonature-back");
1161 $tdLast.addClass("fieldrequired");
1162 $tdFirst.addClass("fieldrequired");
1163 $tdCompany.removeClass("fieldrequired");
1164 break;
1165
1166 case "mor":
1167 $phyInput.prop({disabled: true, checked: false});
1168 $morInput.prop({disabled: false, checked: true});
1169 $span2.addClass("member-company-back").removeClass("nonature-back");
1170 $span1.removeClass("member-individual-back").addClass("nonature-back");
1171 $tdCompany.addClass("fieldrequired");
1172 $tdLast.removeClass("fieldrequired");
1173 $tdFirst.removeClass("fieldrequired");
1174 break;
1175
1176 default:
1177 $phyInput.prop({disabled: false, checked: false});
1178 $morInput.prop({disabled: false, checked: false});
1179 $span1.removeClass("member-individual-back").addClass("nonature-back");
1180 $span2.removeClass("member-company-back").addClass("nonature-back");
1181 }
1182 });
1183
1184 // Initial state
1185 refreshNatureCss();
1186 });
1187 </script>';
1188 }
1189
1190 print "</td>\n";
1191
1192 // Company
1193 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>';
1194
1195 // Civility
1196 print '<tr><td>'.$langs->trans("UserTitle").'</td><td>';
1197 print $formcompany->select_civility(GETPOSTISSET('civility_code') ? GETPOST('civility_code') : $object->civility_code, 'civility_code', 'maxwidth150', 1).'</td>';
1198 print '</tr>';
1199
1200 // Lastname
1201 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>';
1202 print '</tr>';
1203
1204 // Firstname
1205 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>';
1206 print '</tr>';
1207
1208 // Gender
1209 print '<tr><td>'.$langs->trans("Gender").'</td>';
1210 print '<td>';
1211 $arraygender = array('man' => $langs->trans("Genderman"), 'woman' => $langs->trans("Genderwoman"), 'other' => $langs->trans("Genderother"));
1212 print $form->selectarray('gender', $arraygender, GETPOST('gender', 'alphanohtml'), 1, 0, 0, '', 0, 0, 0, '', 'minwidth100', 1);
1213 print '</td></tr>';
1214
1215 // EMail
1216 print '<tr><td>'.(getDolGlobalString('ADHERENT_MAIL_REQUIRED') ? '<span class="fieldrequired">' : '').$langs->trans("EMail").(getDolGlobalString('ADHERENT_MAIL_REQUIRED') ? '</span>' : '').'</td>';
1217 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>';
1218
1219 // Website
1220 print '<tr><td>'.$form->editfieldkey('Web', 'member_url', GETPOST('member_url', 'alpha'), $object, 0).'</td>';
1221 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>';
1222
1223 // Address
1224 print '<tr><td class="tdtop">'.$langs->trans("Address").'</td><td>';
1225 print '<textarea name="address" wrap="soft" class="quatrevingtpercent" rows="2">'.(GETPOSTISSET('address') ? GETPOST('address', 'alphanohtml') : $soc->address).'</textarea>';
1226 print '</td></tr>';
1227
1228 // Zip / Town
1229 print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>';
1230 print $formcompany->select_ziptown((GETPOSTISSET('zipcode') ? GETPOST('zipcode', 'alphanohtml') : $soc->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6);
1231 print ' ';
1232 print $formcompany->select_ziptown((GETPOSTISSET('town') ? GETPOST('town', 'alphanohtml') : $soc->town), 'town', array('zipcode', 'selectcountry_id', 'state_id'));
1233 print '</td></tr>';
1234
1235 // Country
1236 if (empty($soc->country_id)) {
1237 $soc->country_id = $mysoc->country_id;
1238 $soc->country_code = $mysoc->country_code;
1239 $soc->state_id = $mysoc->state_id;
1240 }
1241 print '<tr><td>'.$langs->trans('Country').'</td><td>';
1242 print img_picto('', 'country', 'class="pictofixedwidth"');
1243 print $form->select_country(GETPOSTISSET('country_id') ? GETPOST('country_id', 'alpha') : $soc->country_id, 'country_id');
1244 if ($user->admin) {
1245 print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1246 }
1247 print '</td></tr>';
1248
1249 // State
1250 if (!getDolGlobalString('MEMBER_DISABLE_STATE')) {
1251 print '<tr><td>'.$langs->trans('State').'</td><td>';
1252 if ($soc->country_id || GETPOSTISSET('country_id')) {
1253 print img_picto('', 'state', 'class="pictofixedwidth"');
1254 print $formcompany->select_state(GETPOSTISSET('state_id') ? GETPOSTINT('state_id') : $soc->state_id, GETPOSTISSET('country_id') ? GETPOSTINT('country_id') : $soc->country_code);
1255 } else {
1256 print $countrynotdefined;
1257 }
1258 print '</td></tr>';
1259 }
1260
1261 // Pro phone
1262 print '<tr><td>'.$langs->trans("PhonePro").'</td>';
1263 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>';
1264
1265 // Personal phone
1266 print '<tr><td>'.$langs->trans("PhonePerso").'</td>';
1267 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>';
1268
1269 // Mobile phone
1270 print '<tr><td>'.$langs->trans("PhoneMobile").'</td>';
1271 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>';
1272
1273 if (isModEnabled('socialnetworks')) {
1274 foreach ($socialnetworks as $key => $value) {
1275 if (!$value['active']) {
1276 break;
1277 }
1278 $val = (GETPOSTISSET('member_'.$key) ? GETPOST('member_'.$key, 'alpha') : (empty($object->socialnetworks[$key]) ? '' : $object->socialnetworks[$key]));
1279 print '<tr><td>'.$langs->trans($value['label']).'</td><td><input type="text" name="member_'.$key.'" size="40" value="'.$val.'"></td></tr>';
1280 }
1281 }
1282
1283 // Birth Date
1284 print "<tr><td>".$langs->trans("DateOfBirth")."</td><td>\n";
1285 print img_picto('', 'object_calendar', 'class="pictofixedwidth"').$form->selectDate(($object->birth ? $object->birth : -1), 'birth', 0, 0, 1, 'formsoc');
1286 print "</td></tr>\n";
1287
1288 // Public profil
1289 print "<tr><td>";
1290 $htmltext = $langs->trans("Public", getDolGlobalString('MAIN_INFO_SOCIETE_NOM'), $linkofpubliclist);
1291 print $form->textwithpicto($langs->trans("MembershipPublic"), $htmltext, 1, 'help', '', 0, 3, 'membershippublic');
1292 print "</td><td>\n";
1293 print $form->selectyesno("public", $object->public, 1, false, 0, 1);
1294 print "</td></tr>\n";
1295
1296 // Categories
1297 if (isModEnabled('category') && $user->hasRight('categorie', 'lire')) {
1298 print '<tr><td>'.$form->editfieldkey("Categories", 'memcats', '', $object, 0).'</td><td>';
1299 print $form->selectCategories(Categorie::TYPE_MEMBER, 'memcats', $object);
1300 print "</td></tr>";
1301 }
1302
1303 // Other attributes
1304 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
1305
1306 print '<tbody>';
1307 print "</table>\n";
1308
1309 print dol_get_fiche_end();
1310
1311 print $form->buttonsSaveCancel("AddMember");
1312
1313 print "</form>\n";
1314 }
1315
1316 // Edit mode
1317 if ($action == 'edit') {
1318 $res = $object->fetch($id);
1319 if ($res < 0) {
1320 dol_print_error($db, $object->error);
1321 exit;
1322 }
1323 $res = $object->fetch_optionals();
1324 if ($res < 0) {
1325 dol_print_error($db);
1326 exit;
1327 }
1328
1329 $adht = new AdherentType($db);
1330 $adht->fetch($object->typeid);
1331
1332 // We set country_id, and country_code, country of the chosen country
1333 $country = GETPOSTINT('country');
1334 if (!empty($country) || $object->country_id) {
1335 $sql = "SELECT rowid, code, label from ".MAIN_DB_PREFIX."c_country";
1336 $sql .= " WHERE rowid = ".(int) (!empty($country) ? $country : $object->country_id);
1337 $resql = $db->query($sql);
1338 if ($resql) {
1339 $obj = $db->fetch_object($resql);
1340 } else {
1341 dol_print_error($db);
1342 $obj = null;
1343 }
1344 if (is_object($obj)) {
1345 $object->country_id = $obj->rowid;
1346 $object->country_code = $obj->code;
1347 $object->country = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->label;
1348 }
1349 }
1350
1351 $head = member_prepare_head($object);
1352
1353
1354 if ($conf->use_javascript_ajax) {
1355 print "\n".'<script type="text/javascript">';
1356 print 'jQuery(document).ready(function () {
1357 jQuery("#selectcountry_id").change(function() {
1358 document.formsoc.action.value="edit";
1359 document.formsoc.submit();
1360 });
1361 function initfieldrequired() {
1362 jQuery("#tdcompany").removeClass("fieldrequired");
1363 jQuery("#tdlastname").removeClass("fieldrequired");
1364 jQuery("#tdfirstname").removeClass("fieldrequired");
1365 if (jQuery(\'input[name="morphy"]:checked\').val() == \'mor\') {
1366 jQuery("#tdcompany").addClass("fieldrequired");
1367 }
1368 if (jQuery(\'input[name="morphy"]:checked\').val() == \'phy\') {
1369 jQuery("#tdlastname").addClass("fieldrequired");
1370 jQuery("#tdfirstname").addClass("fieldrequired");
1371 }
1372 }
1373 jQuery(\'input[name="morphy"]\').change(function() {
1374 initfieldrequired();
1375 });
1376 initfieldrequired();
1377 })';
1378 print '</script>'."\n";
1379 }
1380
1381 print '<form name="formsoc" action="'.$_SERVER["PHP_SELF"].'" method="post" enctype="multipart/form-data">';
1382 print '<input type="hidden" name="token" value="'.newToken().'" />';
1383 print '<input type="hidden" name="action" value="update" />';
1384 print '<input type="hidden" name="rowid" value="'.$id.'" />';
1385 print '<input type="hidden" name="statut" value="'.$object->status.'" />';
1386 if ($backtopage) {
1387 print '<input type="hidden" name="backtopage" value="'.($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]).'">';
1388 }
1389
1390 print dol_get_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user');
1391
1392 print '<table class="border centpercent">';
1393
1394 // Ref
1395 print '<tr><td class="titlefieldcreate">'.$langs->trans("Ref").'</td><td class="valeur">'.$object->ref.'</td></tr>';
1396
1397 // Login
1398 if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
1399 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>';
1400 }
1401
1402 // Password
1403 if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
1404 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>';
1405 }
1406
1407 // Type
1408 print '<tr><td class="fieldrequired">'.$langs->trans("Type").'</td><td>';
1409 if ($user->hasRight('adherent', 'creer')) {
1410 print $form->selectarray("typeid", $adht->liste_array(), (GETPOSTISSET("typeid") ? GETPOSTINT("typeid") : $object->typeid), 0, 0, 0, '', 0, 0, 0, '', 'minwidth200', 1);
1411 } else {
1412 print $adht->getNomUrl(1);
1413 print '<input type="hidden" name="typeid" value="'.$object->typeid.'">';
1414 }
1415 print "</td></tr>";
1416
1417 // Morphy
1418 $morphys["phy"] = $langs->trans("Physical");
1419 $morphys["mor"] = $langs->trans("Moral");
1420 $checkednature = (GETPOSTISSET("morphy") ? GETPOST("morphy", 'alpha') : $object->morphy);
1421 print '<tr><td><span class="fieldrequired">'.$langs->trans("MemberNature").'</span></td><td>';
1422 print '<span id="spannature1" class="member-individual-back spannature paddinglarge marginrightonly"><label for="phisicalinput" class="valignmiddle">'.$morphys["phy"].'<input id="phisicalinput" class="flat checkforselect marginleftonly valignmiddle" type="radio" name="morphy" value="phy"'.($checkednature == "phy" ? ' checked="checked"' : '').'></label></span>';
1423 print '<span id="spannature1" class="member-company-back spannature paddinglarge marginrightonly"><label for="moralinput" class="valignmiddle">'.$morphys["mor"].'<input id="moralinput" class="flat checkforselect marginleftonly valignmiddle" type="radio" name="morphy" value="mor"'.($checkednature == "mor" ? ' checked="checked"' : '').'></label></span>';
1424 print "</td></tr>";
1425
1426 // Company
1427 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>';
1428
1429 // Civility
1430 print '<tr><td>'.$langs->trans("UserTitle").'</td><td>';
1431 print $formcompany->select_civility(GETPOSTISSET("civility_code") ? GETPOST("civility_code", 'alpha') : $object->civility_code, 'civility_code', 'maxwidth150', 1);
1432 print '</td>';
1433 print '</tr>';
1434
1435 // Lastname
1436 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>';
1437 print '</tr>';
1438
1439 // Firstname
1440 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>';
1441 print '</tr>';
1442
1443 // Gender
1444 print '<tr><td>'.$langs->trans("Gender").'</td>';
1445 print '<td>';
1446 $arraygender = array('man' => $langs->trans("Genderman"), 'woman' => $langs->trans("Genderwoman"), 'other' => $langs->trans("Genderother"));
1447 print $form->selectarray('gender', $arraygender, GETPOSTISSET('gender') ? GETPOST('gender', 'alphanohtml') : $object->gender, 1, 0, 0, '', 0, 0, 0, '', 'minwidth100', 1);
1448 print '</td></tr>';
1449
1450 // Photo
1451 print '<tr><td>'.$langs->trans("Photo").'</td>';
1452 print '<td class="hideonsmartphone" valign="middle">';
1453 print $form->showphoto('memberphoto', $object)."\n";
1454 if ($caneditfieldmember) {
1455 if ($object->photo) {
1456 print "<br>\n";
1457 }
1458 print '<table class="nobordernopadding">';
1459 if ($object->photo) {
1460 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>';
1461 }
1462 print '<tr><td>';
1463 $maxfilesizearray = getMaxFileSizeArray();
1464 $maxmin = $maxfilesizearray['maxmin'];
1465 if ($maxmin > 0) {
1466 print '<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).'">'; // MAX_FILE_SIZE must precede the field type=file
1467 }
1468 print '<input type="file" class="flat" name="photo" id="photoinput">';
1469 print '</td></tr>';
1470 print '</table>';
1471 }
1472 print '</td></tr>';
1473
1474 // EMail
1475 print '<tr><td>'.(getDolGlobalString("ADHERENT_MAIL_REQUIRED") ? '<span class="fieldrequired">' : '').$langs->trans("EMail").(getDolGlobalString("ADHERENT_MAIL_REQUIRED") ? '</span>' : '').'</td>';
1476 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>';
1477
1478 // Website
1479 print '<tr><td>'.$form->editfieldkey('Web', 'member_url', GETPOST('member_url', 'alpha'), $object, 0).'</td>';
1480 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>';
1481
1482 // Address
1483 print '<tr><td>'.$langs->trans("Address").'</td><td>';
1484 print '<textarea name="address" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_2.'">'.(GETPOSTISSET("address") ? GETPOST("address", 'alphanohtml', 2) : $object->address).'</textarea>';
1485 print '</td></tr>';
1486
1487 // Zip / Town
1488 print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>';
1489 print $formcompany->select_ziptown((GETPOSTISSET("zipcode") ? GETPOST("zipcode", 'alphanohtml', 2) : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6);
1490 print ' ';
1491 print $formcompany->select_ziptown((GETPOSTISSET("town") ? GETPOST("town", 'alphanohtml', 2) : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id'));
1492 print '</td></tr>';
1493
1494 // Country
1495 //$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
1496 print '<tr><td>'.$langs->trans('Country').'</td><td>';
1497 print img_picto('', 'country', 'class="pictofixedwidth"');
1498 print $form->select_country(GETPOSTISSET("country_id") ? GETPOST("country_id", "alpha") : $object->country_id, 'country_id');
1499 if ($user->admin) {
1500 print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1501 }
1502 print '</td></tr>';
1503
1504 // State
1505 if (!getDolGlobalString('MEMBER_DISABLE_STATE')) {
1506 print '<tr><td>'.$langs->trans('State').'</td><td>';
1507 print img_picto('', 'state', 'class="pictofixedwidth"');
1508 print $formcompany->select_state($object->state_id, GETPOSTISSET("country_id") ? GETPOST("country_id", "alpha") : $object->country_id);
1509 print '</td></tr>';
1510 }
1511
1512 // Pro phone
1513 print '<tr><td>'.$langs->trans("PhonePro").'</td>';
1514 print '<td>'.img_picto('', 'object_phoning', 'class="pictofixedwidth"').'<input type="text" name="phone" value="'.(GETPOSTISSET("phone") ? GETPOST("phone") : $object->phone).'"></td></tr>';
1515
1516 // Personal phone
1517 print '<tr><td>'.$langs->trans("PhonePerso").'</td>';
1518 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>';
1519
1520 // Mobile phone
1521 print '<tr><td>'.$langs->trans("PhoneMobile").'</td>';
1522 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>';
1523
1524 if (isModEnabled('socialnetworks')) {
1525 foreach ($socialnetworks as $key => $value) {
1526 if (!$value['active']) {
1527 break;
1528 }
1529 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>';
1530 }
1531 }
1532
1533 // Birth Date
1534 print "<tr><td>".$langs->trans("DateOfBirth")."</td><td>\n";
1535 print img_picto('', 'object_calendar', 'class="pictofixedwidth"').$form->selectDate(($object->birth ? $object->birth : -1), 'birth', 0, 0, 1, 'formsoc');
1536 print "</td></tr>\n";
1537
1538 // Default language
1539 if (getDolGlobalInt('MAIN_MULTILANGS')) {
1540 print '<tr><td>'.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).'</td><td colspan="3">'."\n";
1541 print img_picto('', 'language', 'class="pictofixedwidth"').$formadmin->select_language($object->default_lang, 'default_lang', 0, array(), 1);
1542 print '</td>';
1543 print '</tr>';
1544 }
1545
1546 // Public profil
1547 print "<tr><td>";
1548 $htmltext = $langs->trans("Public", getDolGlobalString('MAIN_INFO_SOCIETE_NOM'), $linkofpubliclist);
1549 print $form->textwithpicto($langs->trans("MembershipPublic"), $htmltext, 1, 'help', '', 0, 3, 'membershippublic');
1550 print "</td><td>\n";
1551 print $form->selectyesno("public", (GETPOSTISSET("public") ? GETPOST("public", 'alphanohtml', 2) : $object->public), 1, false, 0, 1);
1552 print "</td></tr>\n";
1553
1554 // Categories
1555 if (isModEnabled('category') && $user->hasRight('categorie', 'lire')) {
1556 print '<tr><td>'.$form->editfieldkey("Categories", 'memcats', '', $object, 0).'</td>';
1557 print '<td>';
1558 print $form->selectCategories(Categorie::TYPE_MEMBER, 'memcats', $object);
1559 print "</td></tr>";
1560 }
1561
1562 // Third party Dolibarr
1563 if (isModEnabled('societe')) {
1564 print '<tr><td>'.$langs->trans("LinkedToDolibarrThirdParty").'</td><td colspan="2" class="valeur">';
1565 if ($object->socid) {
1566 $company = new Societe($db);
1567 $result = $company->fetch($object->socid);
1568 print $company->getNomUrl(1);
1569 } else {
1570 print $langs->trans("NoThirdPartyAssociatedToMember");
1571 }
1572 print '</td></tr>';
1573 }
1574
1575 // Login Dolibarr
1576 print '<tr><td>'.$langs->trans("LinkedToDolibarrUser").'</td><td colspan="2" class="valeur">';
1577 if ($object->user_id) {
1578 $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id, (string) $object->user_id, 'none');
1579 } else {
1580 print $langs->trans("NoDolibarrAccess");
1581 }
1582 print '</td></tr>';
1583
1584 // Other attributes. Fields from hook formObjectOptions and Extrafields.
1585 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
1586
1587 print '</table>';
1588 print dol_get_fiche_end();
1589
1590 print $form->buttonsSaveCancel("Save", 'Cancel');
1591
1592 print '</form>';
1593 }
1594
1595 // View
1596 if ($id > 0 && $action != 'edit') {
1597 $res = $object->fetch($id);
1598 if ($res < 0) {
1599 dol_print_error($db, $object->error);
1600 exit;
1601 }
1602 $res = $object->fetch_optionals();
1603 if ($res < 0) {
1604 dol_print_error($db);
1605 exit;
1606 }
1607
1608 $adht = new AdherentType($db);
1609 $res = $adht->fetch($object->typeid);
1610 if ($res < 0) {
1611 dol_print_error($db);
1612 exit;
1613 }
1614
1615
1616 /*
1617 * Show tabs
1618 */
1619 $head = member_prepare_head($object);
1620
1621 print dol_get_fiche_head($head, 'general', $langs->trans("Member"), -1, 'user', 0, '', '', 0, '', 1);
1622
1623 // Confirm create user
1624 if ($action == 'create_user') {
1625 $login = (GETPOSTISSET('login') ? GETPOST('login', 'alphanohtml') : $object->login);
1626 if (empty($login)) {
1627 // Full firstname and name separated with a dot : firstname.name
1628 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
1629 $login = dol_buildlogin($object->lastname, $object->firstname);
1630 }
1631 if (empty($login)) {
1632 $login = strtolower(substr($object->firstname, 0, 4)).strtolower(substr($object->lastname, 0, 4));
1633 }
1634
1635 // Create a form array
1636 $formquestion = array(
1637 array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login)
1638 );
1639 if (isModEnabled('societe') && $object->socid > 0) {
1640 $object->fetch_thirdparty();
1641 $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")));
1642 }
1643 $text = '';
1644 if (isModEnabled('societe') && $object->socid <= 0) {
1645 $text .= $langs->trans("UserWillBeInternalUser").'<br>';
1646 }
1647 $text .= $langs->trans("ConfirmCreateLogin");
1648 print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id, $langs->trans("CreateDolibarrLogin"), $text, "confirm_create_user", $formquestion, 'yes');
1649 }
1650
1651 // Confirm create third party
1652 if ($action == 'create_thirdparty') {
1653 $companyalias = '';
1654 $fullname = $object->getFullName($langs);
1655
1656 if ($object->morphy == 'mor') {
1657 $companyname = (string) $object->company;
1658 if (!empty($fullname)) {
1659 $companyalias = (string) $fullname;
1660 }
1661 } else {
1662 $companyname = $fullname;
1663 if (!empty($object->company)) {
1664 $companyalias = (string) $object->company;
1665 }
1666 }
1667
1668 // Create a form array
1669 $formquestion = array(
1670 array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $companyname, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"'),
1671 array('label' => $langs->trans("AliasNames"), 'type' => 'text', 'name' => 'companyalias', 'value' => $companyalias, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"')
1672 );
1673
1674 print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id, $langs->trans("CreateDolibarrThirdParty"), $langs->trans("ConfirmCreateThirdParty"), "confirm_create_thirdparty", $formquestion, 'yes');
1675 }
1676
1677 // Confirm validate member
1678 if ($action == 'valid') {
1679 $langs->load("mails");
1680
1681 $adht = new AdherentType($db);
1682 $adht->fetch($object->typeid);
1683
1684 $subject = '';
1685 $msg = '';
1686
1687 // Send subscription email
1688 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
1689 $formmail = new FormMail($db);
1690 // Set output language
1691 $outputlangs = new Translate('', $conf);
1692 $outputlangs->setDefaultLang(!empty($object->default_lang) ? $object->default_lang : (empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang));
1693 // Load traductions files required by page
1694 $outputlangs->loadLangs(array("main", "members", "companies", "install", "other"));
1695 // Get email content from template
1696 $arraydefaultmessage = null;
1697 $labeltouse = getDolGlobalString("ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION");
1698
1699 if (!empty($labeltouse)) {
1700 $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
1701 }
1702
1703 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1704 $subject = (string) $arraydefaultmessage->topic;
1705 $msg = (string) $arraydefaultmessage->content;
1706 }
1707
1708 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
1709 complete_substitutions_array($substitutionarray, $outputlangs, $object);
1710 $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
1711 $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs);
1712
1713 $tmp = $langs->trans("SendingAnEMailToMember");
1714 $tmp .= '<br>'.$langs->trans("MailFrom").': <b>'.getDolGlobalString('ADHERENT_MAIL_FROM', $conf->email_from).'</b>, ';
1715 $tmp .= '<br>'.$langs->trans("MailRecipient").': <b>'.$object->email.'</b>';
1716 $helpcontent = '';
1717 $helpcontent .= '<b>'.$langs->trans("MailFrom").'</b>: '.getDolGlobalString('ADHERENT_MAIL_FROM', $conf->email_from).'<br>'."\n";
1718 $helpcontent .= '<b>'.$langs->trans("MailRecipient").'</b>: '.$object->email.'<br>'."\n";
1719 $helpcontent .= '<b>'.$langs->trans("Subject").'</b>:<br>'."\n";
1720 $helpcontent .= $subjecttosend."\n";
1721 $helpcontent .= "<br>";
1722 $helpcontent .= '<b>'.$langs->trans("Content").'</b>:<br>';
1723 $helpcontent .= dol_htmlentitiesbr($texttosend)."\n";
1724 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1725 $label = $form->textwithpicto($tmp, $helpcontent, 1, 'help');
1726
1727 // Create form popup
1728 $formquestion = array();
1729 if ($object->email) {
1730 $formquestion[] = array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => (getDolGlobalString('ADHERENT_DEFAULT_SENDINFOBYMAIL') ? true : false));
1731 }
1732 if (isModEnabled('mailman') && getDolGlobalString('ADHERENT_USE_MAILMAN')) {
1733 $formquestion[] = array('type' => 'other', 'label' => $langs->transnoentitiesnoconv("SynchroMailManEnabled"), 'value' => '');
1734 }
1735 if (isModEnabled('mailman') && getDolGlobalString('ADHERENT_USE_SPIP')) {
1736 $formquestion[] = array('type' => 'other', 'label' => $langs->transnoentitiesnoconv("SynchroSpipEnabled"), 'value' => '');
1737 }
1738 print $form->formconfirm("card.php?rowid=".$id, $langs->trans("ValidateMember"), $langs->trans("ConfirmValidateMember"), "confirm_valid", $formquestion, 'yes', 1, 250);
1739 }
1740
1741 // Confirm resiliate
1742 if ($action == 'resiliate') {
1743 $langs->load("mails");
1744
1745 $adht = new AdherentType($db);
1746 $adht->fetch($object->typeid);
1747
1748 $subject = '';
1749 $msg = '';
1750
1751 // Send subscription email
1752 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
1753 $formmail = new FormMail($db);
1754 // Set output language
1755 $outputlangs = new Translate('', $conf);
1756 $outputlangs->setDefaultLang(!empty($object->default_lang) ? $object->default_lang : (empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang));
1757 // Load traductions files required by page
1758 $outputlangs->loadLangs(array("main", "members"));
1759 // Get email content from template
1760 $arraydefaultmessage = null;
1761 $labeltouse = getDolGlobalString('ADHERENT_EMAIL_TEMPLATE_CANCELATION');
1762
1763 if (!empty($labeltouse)) {
1764 $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
1765 }
1766
1767 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1768 $subject = (string) $arraydefaultmessage->topic;
1769 $msg = (string) $arraydefaultmessage->content;
1770 }
1771
1772 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
1773 complete_substitutions_array($substitutionarray, $outputlangs, $object);
1774 $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
1775 $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnResiliate()), $substitutionarray, $outputlangs);
1776
1777 $tmp = $langs->trans("SendingAnEMailToMember");
1778 $tmp .= '<br>('.$langs->trans("MailFrom").': <b>'.getDolGlobalString('ADHERENT_MAIL_FROM', $conf->email_from).'</b>, ';
1779 $tmp .= $langs->trans("MailRecipient").': <b>'.$object->email.'</b>)';
1780 $helpcontent = '';
1781 $helpcontent .= '<b>'.$langs->trans("MailFrom").'</b>: '.getDolGlobalString('ADHERENT_MAIL_FROM', $conf->email_from).'<br>'."\n";
1782 $helpcontent .= '<b>'.$langs->trans("MailRecipient").'</b>: '.$object->email.'<br>'."\n";
1783 $helpcontent .= '<b>'.$langs->trans("Subject").'</b>:<br>'."\n";
1784 $helpcontent .= $subjecttosend."\n";
1785 $helpcontent .= "<br>";
1786 $helpcontent .= '<b>'.$langs->trans("Content").'</b>:<br>';
1787 $helpcontent .= dol_htmlentitiesbr($texttosend)."\n";
1788 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1789 $label = $form->textwithpicto($tmp, $helpcontent, 1, 'help');
1790
1791 // Create an array
1792 $formquestion = array();
1793 if ($object->email) {
1794 $formquestion[] = array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => (getDolGlobalString('ADHERENT_DEFAULT_SENDINFOBYMAIL') ? 'true' : 'false'));
1795 }
1796 if ($backtopage) {
1797 $formquestion[] = array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]));
1798 }
1799 print $form->formconfirm("card.php?rowid=".$id, $langs->trans("ResiliateMember"), $langs->trans("ConfirmResiliateMember"), "confirm_resiliate", $formquestion, 'no', 1, 240);
1800 }
1801
1802 // Confirm exclude
1803 if ($action == 'exclude') {
1804 $langs->load("mails");
1805
1806 $adht = new AdherentType($db);
1807 $adht->fetch($object->typeid);
1808
1809 $subject = '';
1810 $msg = '';
1811
1812 // Send subscription email
1813 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
1814 $formmail = new FormMail($db);
1815 // Set output language
1816 $outputlangs = new Translate('', $conf);
1817 $outputlangs->setDefaultLang(!empty($object->default_lang) ? $object->default_lang : (empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang));
1818 // Load traductions files required by page
1819 $outputlangs->loadLangs(array("main", "members"));
1820 // Get email content from template
1821 $arraydefaultmessage = null;
1822 $labeltouse = getDolGlobalString('ADHERENT_EMAIL_TEMPLATE_EXCLUSION');
1823
1824 if (!empty($labeltouse)) {
1825 $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
1826 }
1827
1828 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1829 $subject = (string) $arraydefaultmessage->topic;
1830 $msg = (string) $arraydefaultmessage->content;
1831 }
1832
1833 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
1834 complete_substitutions_array($substitutionarray, $outputlangs, $object);
1835 $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
1836 $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnExclude()), $substitutionarray, $outputlangs);
1837
1838 $tmp = $langs->trans("SendingAnEMailToMember");
1839 $tmp .= '<br>('.$langs->trans("MailFrom").': <b>'.getDolGlobalString('ADHERENT_MAIL_FROM', $conf->email_from).'</b>, ';
1840 $tmp .= $langs->trans("MailRecipient").': <b>'.$object->email.'</b>)';
1841 $helpcontent = '';
1842 $helpcontent .= '<b>'.$langs->trans("MailFrom").'</b>: '.getDolGlobalString('ADHERENT_MAIL_FROM', $conf->email_from).'<br>'."\n";
1843 $helpcontent .= '<b>'.$langs->trans("MailRecipient").'</b>: '.$object->email.'<br>'."\n";
1844 $helpcontent .= '<b>'.$langs->trans("Subject").'</b>:<br>'."\n";
1845 $helpcontent .= $subjecttosend."\n";
1846 $helpcontent .= "<br>";
1847 $helpcontent .= '<b>'.$langs->trans("Content").'</b>:<br>';
1848 $helpcontent .= dol_htmlentitiesbr($texttosend)."\n";
1849 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1850 $label = $form->textwithpicto($tmp, $helpcontent, 1, 'help');
1851
1852 // Create an array
1853 $formquestion = array();
1854 if ($object->email) {
1855 $formquestion[] = array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => (getDolGlobalString('ADHERENT_DEFAULT_SENDINFOBYMAIL') ? 'true' : 'false'));
1856 }
1857 if ($backtopage) {
1858 $formquestion[] = array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]));
1859 }
1860 print $form->formconfirm("card.php?rowid=".$id, $langs->trans("ExcludeMember"), $langs->trans("ConfirmExcludeMember"), "confirm_exclude", $formquestion, 'no', 1, 240);
1861 }
1862
1863 // Confirm remove member
1864 if ($action == 'delete') {
1865 $formquestion = array();
1866 if ($backtopage) {
1867 $formquestion[] = array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]));
1868 }
1869 print $form->formconfirm("card.php?rowid=".$id, $langs->trans("DeleteMember"), $langs->trans("ConfirmDeleteMember"), "confirm_delete", $formquestion, 'no', 1);
1870 }
1871
1872 // Confirm add in spip
1873 if ($action == 'add_spip') {
1874 print $form->formconfirm("card.php?rowid=".$id, $langs->trans('AddIntoSpip'), $langs->trans('AddIntoSpipConfirmation'), 'confirm_add_spip');
1875 }
1876
1877 // Confirm merge
1878 if ($action == 'merge') {
1879 $formquestion = array(
1880 array(
1881 'name' => 'member_origin',
1882 'label' => $langs->trans('MergeOriginMember'),
1883 'type' => 'other',
1884 'value' => $form->selectMembers('', 'member_origin', '', 0, 1, '', 0, array(), 0, 'SelectMember', 0, 'minwidth200', array(), 1, array($object->id))
1885 )
1886 );
1887
1888 print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("MergeMembers"), $langs->trans("ConfirmMergeMembers"), "confirm_merge", $formquestion, 'no', 1, 300);
1889 }
1890
1891 // Confirm removed from spip
1892 if ($action == 'del_spip') {
1893 print $form->formconfirm("card.php?rowid=$id", $langs->trans('DeleteIntoSpip'), $langs->trans('DeleteIntoSpipConfirmation'), 'confirm_del_spip');
1894 }
1895
1896 $rowspan = 17;
1897 if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
1898 $rowspan++;
1899 }
1900 if (isModEnabled('societe')) {
1901 $rowspan++;
1902 }
1903
1904 $linkback = '<a href="'.dolBuildUrl(DOL_URL_ROOT.'/adherents/list.php', ['restore_lastsearch_values' => 1]).'">'.$langs->trans("BackToList").'</a>';
1905
1906 $morehtmlref = '<a href="'.dolBuildUrl(DOL_URL_ROOT.'/adherents/vcard.php', ['id' => $object->id]).'" class="refid valignmiddle">';
1907 $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard', 'class="valignmiddle marginleftonly paddingrightonly"');
1908 $morehtmlref .= '</a>';
1909
1910
1911 dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref);
1912
1913 print '<div class="fichecenter">';
1914 print '<div class="fichehalfleft">';
1915
1916 print '<div class="underbanner clearboth"></div>';
1917 print '<table class="border tableforfield centpercent">';
1918
1919 // Login
1920 if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
1921 print '<tr><td class="titlefieldmiddle">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.dol_escape_htmltag($object->login).'</td></tr>';
1922 }
1923
1924 // Type
1925 print '<tr><td class="titlefieldmiddle">'.$langs->trans("Type").'</td>';
1926 print '<td class="valeur">'.$adht->getNomUrl(1)."</td></tr>\n";
1927
1928 // Morphy
1929 print '<tr><td>'.$langs->trans("MemberNature").'</td>';
1930 print '<td class="valeur">'.$object->getmorphylib('', 1).'</td>';
1931 print '</tr>';
1932
1933 // Company
1934 print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.dol_escape_htmltag($object->company).'</td></tr>';
1935
1936 // Civility
1937 print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'</td>';
1938 print '</tr>';
1939
1940 // Password
1941 if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
1942 print '<tr><td>'.$langs->trans("Password").'</td><td>';
1943 if ($object->pass) {
1944 print preg_replace('/./i', '*', $object->pass);
1945 } else {
1946 if ($user->admin) {
1947 print '<!-- '.$langs->trans("Crypted").': '.$object->pass_indatabase_crypted.' -->';
1948 }
1949 print '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
1950 }
1951 if (!empty($object->pass_indatabase) && empty($object->user_id)) { // Show warning only for old password still in clear (does not happen anymore)
1952 $langs->load("errors");
1953 $htmltext = $langs->trans("WarningPasswordSetWithNoAccount");
1954 print ' '.$form->textwithpicto('', $htmltext, 1, 'warning');
1955 }
1956 print '</td></tr>';
1957 }
1958
1959 // Date end subscription
1960 print '<tr><td>'.$langs->trans("SubscriptionEndDate").'</td><td class="valeur">';
1961 if ($object->datefin) {
1962 print dol_print_date($object->datefin, 'day');
1963 if ($object->hasDelay()) {
1964 print " ".img_warning($langs->trans("Late"));
1965 }
1966 } else {
1967 if ($object->need_subscription == 0) {
1968 print $langs->trans("SubscriptionNotNeeded");
1969 } elseif (!$adht->subscription) {
1970 print $langs->trans("SubscriptionNotRecorded");
1971 if (Adherent::STATUS_VALIDATED == $object->status) {
1972 print " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft, not excluded and not resiliated
1973 }
1974 } else {
1975 print $langs->trans("SubscriptionNotReceived");
1976 if (Adherent::STATUS_VALIDATED == $object->status) {
1977 print " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft, not excluded and not resiliated
1978 }
1979 }
1980 }
1981 print '</td></tr>';
1982
1983 print '</table>';
1984
1985 print '</div>';
1986
1987 print '<div class="fichehalfright">';
1988 print '<div class="underbanner clearboth"></div>';
1989
1990 print '<table class="border tableforfield centpercent">';
1991
1992 // Tags / Categories
1993 if (isModEnabled('category') && $user->hasRight('categorie', 'lire')) {
1994 print '<tr><td>'.$langs->trans("Categories").'</td>';
1995 print '<td>';
1996 print $form->showCategories($object->id, Categorie::TYPE_MEMBER, 1);
1997 print '</td></tr>';
1998 }
1999
2000 // Birth Date
2001 print '<tr><td class="titlefieldmiddle">'.$langs->trans("DateOfBirth").'</td><td class="valeur">'.dol_print_date($object->birth, 'day').'</td></tr>';
2002
2003 // Default language
2004 if (getDolGlobalInt('MAIN_MULTILANGS')) {
2005 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
2006 print '<tr><td>'.$langs->trans("DefaultLang").'</td><td>';
2007 //$s=picto_from_langcode($object->default_lang);
2008 //print ($s?$s.' ':'');
2009 $langs->load("languages");
2010 $labellang = ($object->default_lang ? $langs->trans('Language_'.$object->default_lang) : '');
2011 print picto_from_langcode($object->default_lang, 'class="paddingrightonly saturatemedium opacitylow"');
2012 print $labellang;
2013 print '</td></tr>';
2014 }
2015
2016 // Public
2017 print '<tr><td>';
2018 $htmltext = $langs->trans("Public", getDolGlobalString('MAIN_INFO_SOCIETE_NOM'), $linkofpubliclist);
2019 print $form->textwithpicto($langs->trans("MembershipPublic"), $htmltext, 1, 'help', '', 0, 3, 'membershippublic');
2020 print '</td><td class="valeur">'.yn($object->public).'</td></tr>';
2021
2022 // Other attributes
2023 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
2024
2025 // Third party Dolibarr
2026 if (isModEnabled('societe')) {
2027 print '<tr><td>';
2028 $editenable = $user->hasRight('adherent', 'creer');
2029 print $form->editfieldkey('LinkedToDolibarrThirdParty', 'thirdparty', '', $object, $editenable);
2030 print '</td><td colspan="2" class="valeur">';
2031 if ($action == 'editthirdparty') {
2032 $htmlname = 'socid';
2033 print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" name="form'.$htmlname.'">';
2034 print '<input type="hidden" name="rowid" value="'.$object->id.'">';
2035 print '<input type="hidden" name="action" value="set'.$htmlname.'">';
2036 print '<input type="hidden" name="token" value="'.newToken().'">';
2037 print '<table class="nobordernopadding">';
2038 print '<tr><td>';
2039 print $form->select_company($object->socid, 'socid', '', 1);
2040 print '</td>';
2041 print '<td class="left"><input type="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans("Modify").'"></td>';
2042 print '</tr></table></form>';
2043 } else {
2044 if ($object->socid) {
2045 $company = new Societe($db);
2046 $result = $company->fetch($object->socid);
2047 print $company->getNomUrl(1);
2048
2049 // Show link to invoices
2050 $tmparray = $company->getOutstandingBills('customer');
2051 if (!empty($tmparray['refs'])) {
2052 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']).')';
2053 // TODO Add alert if warning on at least one invoice late
2054 print '</a>';
2055 }
2056 } else {
2057 print '<span class="opacitymedium">'.$langs->trans("NoThirdPartyAssociatedToMember").'</span>';
2058 }
2059 }
2060 print '</td></tr>';
2061 }
2062
2063 // Login Dolibarr - Link to user
2064 print '<tr><td>';
2065 $editenable = $user->hasRight('adherent', 'creer') && $user->hasRight('user', 'user', 'creer');
2066 print $form->editfieldkey('LinkedToDolibarrUser', 'login', '', $object, (int) $editenable);
2067 print '</td><td colspan="2" class="valeur">';
2068 if ($action == 'editlogin') {
2069 $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id, (string) $object->user_id, 'userid', array());
2070 } else {
2071 if ($object->user_id) {
2072 $linkeduser = new User($db);
2073 $linkeduser->fetch($object->user_id);
2074 print $linkeduser->getNomUrl(-1);
2075 } else {
2076 print '<span class="opacitymedium">'.$langs->trans("NoDolibarrAccess").'</span>';
2077 }
2078 }
2079 print '</td></tr>';
2080
2081 print "</table>\n";
2082
2083 print "</div></div>\n";
2084 print '<div class="clearboth"></div>';
2085
2086 print dol_get_fiche_end();
2087
2088
2089 /*
2090 * Action bar
2091 */
2092
2093 print '<div class="tabsAction">';
2094 $isinspip = 0;
2095 $parameters = array();
2096 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
2097 if (empty($reshook)) {
2098 if ($action != 'editlogin' && $action != 'editthirdparty') {
2099 // Send
2100 if (empty($user->socid)) {
2101 if (Adherent::STATUS_VALIDATED == $object->status) {
2102 print dolGetButtonAction('', $langs->trans('SendMail'), 'email', dolBuildUrl($_SERVER["PHP_SELF"], ['id' => $object->id, 'action' => 'presend', 'mode' => 'init'], true).'#formmailbeforetitle', '');
2103 }
2104 }
2105
2106 // Send card by email
2107 // TODO Remove this to replace with a template
2108 /*
2109 if ($user->hasRight('adherent', 'creer')) {
2110 if (Adherent::STATUS_VALIDATED == $object->status) {
2111 if ($object->email) print '<a class="butAction" href="card.php?rowid='.$object->id.'&action=sendinfo">'.$langs->trans("SendCardByMail")."</a>\n";
2112 else print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NoEMail")).'">'.$langs->trans("SendCardByMail")."</a>\n";
2113 } else {
2114 print '<span class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("SendCardByMail")."</span>";
2115 }
2116 } else {
2117 print '<span class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("SendCardByMail")."</span>";
2118 }*/
2119
2120 // Modify
2121 if ($user->hasRight('adherent', 'creer')) {
2122 print '<a class="butAction" href="'.dolBuildUrl($_SERVER["PHP_SELF"], ['id' => $object->id, 'action' => 'edit'], true).'">'.$langs->trans("Modify").'</a>'."\n";
2123 } else {
2124 print '<span class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Modify").'</span>'."\n";
2125 }
2126
2127 // Validate
2128 if (Adherent::STATUS_DRAFT == $object->status) {
2129 if ($user->hasRight('adherent', 'creer')) {
2130 print '<a class="butAction" href="'.dolBuildUrl($_SERVER["PHP_SELF"], ['id' => $object->id, 'action' => 'valid'], true).'">'.$langs->trans("Validate").'</a>'."\n";
2131 } else {
2132 print '<span class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Validate").'</span>'."\n";
2133 }
2134 }
2135
2136 // Reactivate
2138 if ($user->hasRight('adherent', 'creer')) {
2139 print '<a class="butAction" href="'.dolBuildUrl($_SERVER["PHP_SELF"], ['id' => $object->id, 'action' => 'valid'], true).'">'.$langs->trans("Reenable")."</a>\n";
2140 } else {
2141 print '<span class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Reenable").'</span>'."\n";
2142 }
2143 }
2144
2145 // Resiliate
2146 if (Adherent::STATUS_VALIDATED == $object->status) {
2147 if ($user->hasRight('adherent', 'supprimer')) {
2148 print '<a class="butAction" href="'.dolBuildUrl($_SERVER["PHP_SELF"], ['id' => $object->id, 'action' => 'resiliate'], true).'">'.$langs->trans("Resiliate")."</a></span>\n";
2149 } else {
2150 print '<span class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Resiliate").'</span>'."\n";
2151 }
2152 }
2153
2154 // Exclude
2155 if (Adherent::STATUS_VALIDATED == $object->status) {
2156 if ($user->hasRight('adherent', 'supprimer')) {
2157 print '<a class="butAction" href="'.dolBuildUrl($_SERVER["PHP_SELF"], ['id' => $object->id, 'action' => 'exclude'], true).'">'.$langs->trans("Exclude")."</a></span>\n";
2158 } else {
2159 print '<span class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Exclude").'</span>'."\n";
2160 }
2161 }
2162
2163 // Create third party
2164 if (isModEnabled('societe') && !$object->socid) {
2165 if ($user->hasRight('societe', 'creer')) {
2166 if (Adherent::STATUS_DRAFT != $object->status) {
2167 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";
2168 } else {
2169 print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("CreateDolibarrThirdParty").'</a>'."\n";
2170 }
2171 } else {
2172 print '<span class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("CreateDolibarrThirdParty").'</span>'."\n";
2173 }
2174 }
2175
2176 // Create user
2177 if (!$user->socid && !$object->user_id) {
2178 if ($user->hasRight('user', 'user', 'creer')) {
2179 if (Adherent::STATUS_DRAFT != $object->status) {
2180 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";
2181 } else {
2182 print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("CreateDolibarrLogin").'</a>'."\n";
2183 }
2184 } else {
2185 print '<span class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("CreateDolibarrLogin").'</span>'."\n";
2186 }
2187 }
2188
2189 // Action SPIP
2190 if (isModEnabled('mailmanspip') && getDolGlobalString('ADHERENT_USE_SPIP')) {
2191 $isinspip = $mailmanspip->is_in_spip($object);
2192
2193 if ($isinspip == 1) {
2194 print '<a class="butAction" href="'.dolBuildUrl($_SERVER["PHP_SELF"], ['id' => $object->id, 'action' => 'del_spip'], true).'">'.$langs->trans("DeleteIntoSpip").'</a>'."\n";
2195 }
2196 if ($isinspip == 0) {
2197 print '<a class="butAction" href="'.dolBuildUrl($_SERVER["PHP_SELF"], ['id' => $object->id, 'action' => 'add_spip'], true).'">'.$langs->trans("AddIntoSpip").'</a>'."\n";
2198 }
2199 }
2200
2201 // Merge
2202 print dolGetButtonAction($langs->trans('MergeMembers'), $langs->trans('Merge'), 'danger', dolBuildUrl($_SERVER["PHP_SELF"], ['id' => $object->id, 'action' => 'merge'], true), '', $user->hasRight('adherent', 'supprimer'));
2203
2204 // Delete
2205 if ($user->hasRight('adherent', 'supprimer')) {
2206 print '<a class="butActionDelete" href="'.dolBuildUrl($_SERVER["PHP_SELF"], ['id' => $object->id, 'action' => 'delete'], true).'">'.$langs->trans("Delete").'</a>'."\n";
2207 } else {
2208 print '<span class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Delete").'</span>'."\n";
2209 }
2210 }
2211 }
2212 print '</div>';
2213
2214 if ($isinspip == -1) {
2215 print '<br><br><span class="error">'.$langs->trans('SPIPConnectionFailed').': '.$mailmanspip->error.'</span>';
2216 }
2217
2218
2219 // Select mail models is same action as presend
2220 if (GETPOST('modelselected')) {
2221 $action = 'presend';
2222 }
2223
2224 if ($action != 'presend') {
2225 print '<div class="fichecenter"><div class="fichehalfleft">';
2226 print '<a name="builddoc"></a>'; // ancre
2227
2228 // Generated documents
2229 $filename = dol_sanitizeFileName($object->ref);
2230 $filedir = $conf->member->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'member');
2231 $urlsource = $_SERVER['PHP_SELF'].'?id='.$object->id;
2232 $genallowed = $user->hasRight('adherent', 'lire');
2233 $delallowed = $user->hasRight('adherent', 'creer');
2234
2235 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);
2236 $somethingshown = $formfile->numoffiles;
2237
2238 // Show links to link elements
2239 //$tmparray = $form->showLinkToObjectBlock($object, null, array('subscription'), 1);
2240 //$somethingshown = $form->showLinkedObjectBlock($object, '');
2241
2242 // Show online payment link
2243 // The list can be complete by the hook 'doValidatePayment' executed inside getValidOnlinePaymentMethods()
2244 include_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
2245 $validpaymentmethod = getValidOnlinePaymentMethods('');
2246 $useonlinepayment = count($validpaymentmethod);
2247
2248 if ($useonlinepayment) {
2249 print '<br>';
2250 if (empty($amount)) { // Take the maximum amount among what the member is supposed to pay / has paid in the past
2251 $amount = max($adht->amount, $object->first_subscription_amount, $object->last_subscription_amount);
2252 }
2253 if (empty($amount)) {
2254 $amount = 0;
2255 }
2256 require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
2257 print showOnlinePaymentUrl('membersubscription', $object->ref, $amount);
2258 }
2259
2260 print '</div><div class="fichehalfright">';
2261
2262 $MAXEVENT = 10;
2263
2264 $morehtmlcenter = '';
2265 $messagingUrl = dolBuildUrl(DOL_URL_ROOT.'/adherents/messaging.php', ['id' => $object->id]);
2266 $morehtmlcenter .= dolGetButtonTitle($langs->trans('ShowAsConversation'), '', 'fa fa-comments imgforviewmode', $messagingUrl, '', 1);
2267 $morehtmlcenter .= dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', dolBuildUrl(DOL_URL_ROOT.'/adherents/agenda.php', ['id' => $object->id]));
2268
2269 // List of actions on element
2270 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
2271 $formactions = new FormActions($db);
2272 $somethingshown = $formactions->showactions($object, $object->element, $socid, 1, 'listactions', $MAXEVENT, '', $morehtmlcenter);
2273
2274 print '</div></div>';
2275 }
2276
2277 // Presend form
2278 $modelmail = 'member';
2279 $defaulttopic = 'CardContent';
2280 $diroutput = $conf->member->dir_output;
2281 $trackid = 'mem'.$object->id;
2282
2283 include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
2284 }
2285}
2286
2287// End of page
2288llxFooter();
2289$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 standard extra fields.
Class to manage building of HTML components.
Class to generate html code for admin pages.
Class to build HTML component for third parties management Only common components are here.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class permettant la generation du formulaire html d'envoi de mail unitaire Usage: $formail = new Form...
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").
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)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolBuildUrl($url, $params=[], $addtoken=false)
Return path of url.
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.
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.
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
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='')
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.
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:135
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.