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