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