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