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