dolibarr 25.0.0-alpha
new.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2001-2002 Jean-Louis Bergamo <jlb@j1b.org>
4 * Copyright (C) 2006-2013 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2012 J. Fernando Lagrange <fernando@demo-tic.org>
7 * Copyright (C) 2018-2026 Frédéric France <frederic.france@free.fr>
8 * Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
9 * Copyright (C) 2021 Waël Almoman <info@almoman.com>
10 * Copyright (C) 2022 Udo Tamm <dev@dolibit.de>
11 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <https://www.gnu.org/licenses/>.
25 */
26
42if (!defined('NOLOGIN')) {
43 define("NOLOGIN", 1); // This means this output page does not require to be logged.
44}
45if (!defined('NOCSRFCHECK')) {
46 define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
47}
48if (!defined('NOBROWSERNOTIF')) {
49 define('NOBROWSERNOTIF', '1');
50}
51
52
53// For MultiCompany module.
54// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php
55// Because 2 entities can have the same ref.
56$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
57define("DOLENTITY", $entity);
58
59
60// Load Dolibarr environment
61require '../../main.inc.php';
70require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
71require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
72require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
73require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
74require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
75require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
76require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php';
77require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
78
79// Init vars
80$backtopage = GETPOST('backtopage', 'alpha');
81$action = GETPOST('action', 'aZ09');
82
83$errmsg = '';
84$num = 0;
85$error = 0;
86
87// Load translation files
88$langs->loadLangs(array("main", "members", "companies", "install", "other"));
89
90if (isModEnabled('multicompany')) {
91 force_switch_entity($entity);
92}
93
94// Security check
95if (!isModEnabled('member')) {
96 httponly_accessforbidden('Module Membership not enabled');
97}
98
99if (!getDolGlobalString('MEMBER_ENABLE_PUBLIC')) {
100 httponly_accessforbidden("Auto subscription form for public visitors has not been enabled");
101}
102
103// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
104$hookmanager->initHooks(array('publicnewmembercard', 'globalcard'));
105
106$extrafields = new ExtraFields($db);
107
108$object = new Adherent($db);
109
110$user->loadDefaultValues();
111
112$captchaobj = null;
113if (getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA_MEMBER')) {
114 require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
115 $captcha = getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA_HANDLER', 'standard');
116 // List of directories where we can find captcha handlers
117 $dirModCaptcha = array_merge(
118 array(
119 'main' => '/core/modules/security/captcha/'
120 ),
121 is_array($conf->modules_parts['captcha']) ? $conf->modules_parts['captcha'] : array()
122 );
123 $fullpathclassfile = '';
124 foreach ($dirModCaptcha as $dir) {
125 $fullpathclassfile = dol_buildpath($dir."modCaptcha".ucfirst($captcha).'.class.php', 0, 2);
126 if ($fullpathclassfile) {
127 break;
128 }
129 }
130 if ($fullpathclassfile) {
131 include_once $fullpathclassfile;
132 // Charging the numbering class
133 $classname = "modCaptcha".ucfirst($captcha);
134 if (class_exists($classname)) {
135 $captchaobj = new $classname($db, $conf, $langs, $user);
136 '@phan-var-force ModeleCaptcha $captchaobj';
138 } else {
139 print 'Error, the captcha handler class '.$classname.' was not found after the include';
140 }
141 } else {
142 print 'Error, the captcha handler '.$captcha.' has no class file found modCaptcha'.ucfirst($captcha);
143 }
144}
145
153function force_switch_entity($newEntity)
154{
155 global $db, $conf;
156
157 if ($newEntity != $conf->entity) {
158 $conf->entity = $newEntity;
159 $conf->setValues($db);
160 }
161}
162
177function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $arrayofjs = [], $arrayofcss = [], $ws = '') // @phan-suppress-current-line PhanRedefineFunction
178{
179 global $conf, $langs, $mysoc;
180
181 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers
182
183 print '<body id="mainbody" class="publicnewmemberform">';
184
185 include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
186 htmlPrintOnlineHeader($mysoc, $langs, 1, getDolGlobalString('MEMBER_PUBLIC_INTERFACE'), 'MEMBER_IMAGE_PUBLIC_REGISTRATION');
187
188 print '<div class="divmainbodylarge">';
189}
190
198function llxFooterVierge() // @phan-suppress-current-line PhanRedefineFunction
199{
200 global $conf, $langs;
201
202 print '</div>';
203
204 printCommonFooter('public');
205
206 if (!empty($conf->use_javascript_ajax)) {
207 print "\n".'<!-- Includes JS Footer of Dolibarr -->'."\n";
208 print '<script src="'.DOL_URL_ROOT.'/core/js/lib_foot.js.php?lang='.$langs->defaultlang.'"></script>'."\n";
209 }
210
211 print "</body>\n";
212 print "</html>\n";
213}
214
215
216//var_dump(GETPOST('firstname')); exit;
217
218/*
219 * Actions
220 */
221
222$parameters = array();
223// Note that $action and $object may have been modified by some hooks
224$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);
225if ($reshook < 0) {
226 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
227}
228
229// Verify if we can find member
230
231if (empty($reshook) && getDolGlobalInt("MEMBER_SEARCH_MEMBER_PUBLIC_FORM_CREATE") && $action == 'add' && !GETPOSTISSET("nofetchmember")) { // Test on permission not required here
232 $memberfound = false;
233
234 if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED') && GETPOSTISSET('login')) {
235 // Note that this allow to guess anonymous ID already used. But this is not a problem as it is an anonymous pseudonym.
236 // If we try to new account and option MEMBER_SEARCH_MEMBER_PUBLIC_FORM_CREATE was off, we also get the same error.
237 $sql = "SELECT rowid as id";
238 $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a";
239 $sql .= " WHERE a.login = '".$db->escape(GETPOST('login'))."'";
240 $sql .= " AND statut = 1";
241 $sql .= " AND entity IN (".getEntity($object->element).")";
242 $resql = $db->query($sql);
243 if ($resql) {
244 if ($db->num_rows($resql) == 1) {
245 $obj = $db->fetch_object($resql);
246 $object->fetch($obj->id);
247 $memberfound = true;
248 }
249 } else {
250 dol_print_error($db);
251 }
252 }
253
254 if (!$memberfound && GETPOST("morphy") == 'mor' && GETPOSTISSET("societe")) {
255 $sql = "SELECT a.rowid as id";
256 $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a";
257 $sql .= " JOIN ".MAIN_DB_PREFIX."societe as s";
258 $sql .= " ON a.fk_soc = s.rowid";
259 $sql .= " WHERE s.nom = '".$db->escape(GETPOST("societe", 'alphanohtml'))."'";
260 $sql .= " AND a.email = '".$db->escape(preg_replace('/\s+/', '', GETPOST("member_email", 'aZ09arobase')))."'";
261 $sql .= " AND a.statut = 1";
262 $sql .= " AND a.entity IN (".getEntity($object->element).")";
263 $resql = $db->query($sql);
264 if ($resql) {
265 if ($db->num_rows($resql) == 1) {
266 $obj = $db->fetch_object($resql);
267 $object->fetch($obj->id);
268 $memberfound = true;
269 }
270 } else {
271 dol_print_error($db);
272 }
273 }
274
275 if (!$memberfound && GETPOST("morphy") == 'phy' && GETPOSTISSET("lastname") && GETPOSTISSET("firstname") && !empty(GETPOST("member_email", 'aZ09arobase'))) {
276 $sql = "SELECT rowid as id";
277 $sql .= " FROM ".MAIN_DB_PREFIX."adherent";
278 $sql .= " WHERE firstname = '".$db->escape(GETPOST("firstname", 'alphanohtml'))."'";
279 $sql .= " AND lastname = '".$db->escape(GETPOST("lastname", 'alphanohtml'))."'";
280 $sql .= " AND email = '".$db->escape(preg_replace('/\s+/', '', GETPOST("member_email", 'aZ09arobase')))."'";
281 $sql .= " AND statut = 1";
282 $sql .= " AND entity IN (".getEntity($object->element).")";
283 $resql = $db->query($sql);
284 if ($resql) {
285 if ($db->num_rows($resql) == 1) {
286 $obj = $db->fetch_object($resql);
287 $object->fetch($obj->id);
288 $memberfound = true;
289 }
290 } else {
291 dol_print_error($db);
292 }
293 }
294
295 if ($memberfound) {
296 $action = 'subscription';
297 }
298}
299
300// Action called when page is submitted
301if (empty($reshook) && $action == 'add') { // Test on permission not required here. This is an anonymous form. Check is done on constant to enable and mitigation.
302 $error = 0;
303 $urlback = '';
304
305 $db->begin();
306
307 $morphy = GETPOST("morphy", 'alphanohtml');
308 $lastname = GETPOST("lastname", 'alphanohtml');
309 $firstname = GETPOST("firstname", 'alphanohtml');
310 $societe = GETPOST("societe", 'alphanohtml');
311 $email = preg_replace('/\s+/', '', GETPOST("member_email", 'aZ09arobase'));
312 $forcecountry = getDolGlobalString('MEMBER_NEWFORM_FORCECOUNTRYCODE');
313 $country_id = $forcecountry ? (int) getCountry($forcecountry, '3', $db, $langs) : GETPOSTINT('country_id');
314
315 if (!in_array($morphy, array('mor', 'phy'))) {
316 $error++;
317 $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv('MemberNature'))."<br>\n";
318 }
319
320 // test if login already exists
321 if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
322 if (!GETPOST('member_email')) {
323 $error++;
324 $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("EMail"))."<br>\n";
325 }
326 if (!GETPOST('login')) {
327 $error++;
328 $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login"))."<br>\n";
329 }
330 $sql = "SELECT login FROM ".MAIN_DB_PREFIX."adherent WHERE login = '".$db->escape(GETPOST('login'))."'";
331 $result = $db->query($sql);
332 if ($result) {
333 $num = $db->num_rows($result);
334 }
335 if ($num != 0) {
336 $error++;
337 $langs->load("errors");
338 $errmsg .= $langs->trans("ErrorLoginAlreadyExists")."<br>\n";
339 }
340 if (!GETPOSTISSET("pass1") || !GETPOSTISSET("pass2") || GETPOST("pass1", 'none') == '' || GETPOST("pass2", 'none') == '' || GETPOST("pass1", 'none') != GETPOST("pass2", 'none')) {
341 $error++;
342 $langs->load("errors");
343 $errmsg .= $langs->trans("ErrorPasswordsMustMatch")."<br>\n";
344 }
345 }
346 if (GETPOST('typeid') <= 0) {
347 $error++;
348 $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type"))."<br>\n";
349 } elseif (!getDolGlobalString('MEMBER_NEWFORM_FORCETYPE')) {
350 // The type must be one of the active types proposed by the form
351 // (when a type is forced by setup, the type posted is ignored and replaced by the forced one)
352 $tmpadht = new AdherentType($db);
353 if (!array_key_exists(GETPOSTINT('typeid'), $tmpadht->liste_array(1))) {
354 $error++;
355 $errmsg .= $langs->trans("ErrorBadValueForParameter", GETPOSTINT('typeid'), $langs->transnoentitiesnoconv("Type"))."<br>\n";
356 }
357 }
358
359 if ($morphy && $morphy != 'mor' && empty($lastname)) {
360 $error++;
361 $langs->load("errors");
362 $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname"));
363 }
364 if ($morphy && $morphy != 'mor' && (!isset($firstname) || $firstname == '')) {
365 $error++;
366 $langs->load("errors");
367 $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentities("Firstname"));
368 }
369 if ($morphy == 'mor' && empty($societe)) {
370 $error++;
371 $langs->load("errors");
372 $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentities("Company"));
373 }
374 if (empty($country_id)) {
375 $error++;
376 $langs->load("errors");
377 $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentities("Country"));
378 }
379 if (getDolGlobalString('ADHERENT_MAIL_REQUIRED') && $email && !isValidEmail($email)) {
380 $error++;
381 $langs->load("errors");
382 $errmsg .= $langs->trans("ErrorBadEMail", $email);
383 }
384 $birthday = dol_mktime(GETPOSTINT("birthhour"), GETPOSTINT("birthmin"), GETPOSTINT("birthsec"), GETPOSTINT("birthmonth"), GETPOSTINT("birthday"), GETPOSTINT("birthyear"));
385 if (GETPOST("birthmonth") && empty($birthday)) {
386 $error++;
387 $langs->load("errors");
388 $errmsg .= $langs->trans("ErrorBadDateFormat")."<br>\n";
389 }
390
391 // TODO Add this in a hook
392 if (getDolGlobalString('MEMBER_NEWFORM_DOLIBARRTURNOVER')) {
393 if (GETPOST("morphy") == 'mor' && GETPOSTFLOAT('budget') <= 0) {
394 $error++;
395 $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("TurnoverOrBudget"))."<br>\n";
396 }
397 }
398
399 // Check Captcha code if is enabled
400 $ok = false;
401 if (getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA_MEMBER') && is_object($captchaobj)) {
402 if (method_exists($captchaobj, 'validateCodeAfterLoginSubmit')) {
403 $ok = $captchaobj->validateCodeAfterLoginSubmit(); // @phan-suppress-current-line PhanUndeclaredMethod
404 } else {
405 print 'Error, the captcha handler '.get_class($captchaobj).' does not have any method validateCodeAfterLoginSubmit()';
406 }
407 if (!$ok) {
408 $error++;
409 $langs->load("errors");
410 $errmsg .= $langs->trans("ErrorBadValueForCode")."<br>\n";
411 $action = '';
412 }
413 }
414
415 $public = GETPOSTISSET('public') ? 1 : 0;
416
417 if (!$error) {
418 // E-mail looks OK and login does not exist
419 $adh = new Adherent($db);
420 $adh->statut = -1;
421 $adh->status = -1;
422 $adh->public = $public;
423 $adh->firstname = GETPOST('firstname');
424 $adh->lastname = GETPOST('lastname');
425 $adh->gender = GETPOST('gender');
426 $adh->civility_id = GETPOST('civility_id');
427 $adh->company = GETPOST('societe');
428 $adh->societe = $adh->company;
429 $adh->address = GETPOST('address');
430 $adh->zip = GETPOST('zipcode');
431 $adh->town = GETPOST('town');
432 $adh->email = GETPOST('member_email', 'aZ09arobase');
433 if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
434 $adh->login = GETPOST('login');
435 $adh->pass = GETPOST('pass1', 'password');
436 }
437 $adh->photo = GETPOST('photo');
438 $adh->country_id = $country_id;
439 $adh->state_id = GETPOSTINT('state_id');
440 $adh->typeid = getDolGlobalInt("MEMBER_NEWFORM_FORCETYPE", GETPOSTINT('typeid'));
441 $adh->note_private = GETPOST('note_private');
442 $adh->morphy = getDolGlobalString("MEMBER_NEWFORM_FORCEMORPHY", GETPOST('morphy'));
443 $adh->birth = $birthday;
444 $adh->phone = GETPOST('phone');
445 $adh->phone_perso = GETPOST('phone_perso');
446 $adh->phone_mobile = GETPOST('phone_mobile');
447
448 $adh->ip = getUserRemoteIP();
449
450 $nb_post_max = getDolGlobalInt("MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
451 $now = dol_now();
452 $minmonthpost = dol_time_plus_duree($now, -1, "m");
453 // Calculate nb of post for IP
454 $nb_post_ip = 0;
455 if ($nb_post_max > 0) { // Calculate only if there is a limit to check
456 $sql = "SELECT COUNT(ref) as nb_adh";
457 $sql .= " FROM ".MAIN_DB_PREFIX."adherent";
458 $sql .= " WHERE ip = '".$db->escape($adh->ip)."'";
459 $sql .= " AND datec > '".$db->idate($minmonthpost)."'";
460 $resql = $db->query($sql);
461 if ($resql) {
462 $num = $db->num_rows($resql);
463 $i = 0;
464 while ($i < $num) {
465 $i++;
466 $obj = $db->fetch_object($resql);
467 $nb_post_ip = $obj->nb_adh;
468 }
469 }
470 }
471
472
473 // Fill array 'array_options' with data from add form
474 $extrafields->fetch_name_optionals_label($adh->table_element);
475 $ret = $extrafields->setOptionalsFromPost(null, $adh);
476 if ($ret < 0) {
477 $error++;
478 $errmsg .= $adh->error;
479 }
480
481 if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
482 $error++;
483 $langs->load('errors');
484 $errmsg .= $langs->trans("AlreadyTooMuchPostOnThisIPAdress");
485 array_push($adh->errors, $langs->trans("AlreadyTooMuchPostOnThisIPAdress"));
486 }
487
488 if (!$error) {
489 $result = $adh->create($user);
490 if ($result > 0) {
491 require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
492 $object = $adh;
493
494 $adht = new AdherentType($db);
495 $adht->fetch($object->typeid);
496
497 if ($object->email) {
498 $subject = '';
499 $msg = '';
500
501 // Send subscription email
502 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
503 $formmail = new FormMail($db);
504 // Set output language
505 $outputlangs = new Translate('', $conf);
506 $outputlangs->setDefaultLang(!empty($object->default_lang) ? $object->default_lang : (empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang));
507 // Load traductions files required by page
508 $outputlangs->loadLangs(array("main", "members"));
509 // Get email content from template
510 $arraydefaultmessage = null;
511 $labeltouse = getDolGlobalString('ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER');
512
513 if (!empty($labeltouse)) {
514 $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
515 }
516
517 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
518 $subject = $arraydefaultmessage->topic;
519 $msg = $arraydefaultmessage->content;
520 }
521
522 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
523 complete_substitutions_array($substitutionarray, $outputlangs, $object);
524 $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
525 $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs);
526
527 if ($subjecttosend && $texttosend) {
528 $moreinheader = 'X-Dolibarr-Info: send_an_email by public/members/new.php'."\r\n";
529
530 $result = $object->sendEmail($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader);
531 }
532 /*if ($result < 0) {
533 $error++;
534 setEventMessages($object->error, $object->errors, 'errors');
535 }*/
536 }
537
538 // Send email to the foundation to say a new member subscribed with autosubscribe form
539 if (getDolGlobalString('MAIN_INFO_SOCIETE_MAIL') && getDolGlobalString('ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT') &&
540 getDolGlobalString('ADHERENT_AUTOREGISTER_NOTIF_MAIL')) {
541 // Define link to login card
542 $appli = constant('DOL_APPLICATION_TITLE');
543 if (getDolGlobalString('MAIN_APPLICATION_TITLE')) {
544 $appli = getDolGlobalString('MAIN_APPLICATION_TITLE');
545 if (preg_match('/\d\.\d/', $appli)) {
546 if (!preg_match('/'.preg_quote(DOL_VERSION, '/').'/', $appli)) {
547 $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core
548 }
549 } else {
550 $appli .= " ".DOL_VERSION;
551 }
552 } else {
553 $appli .= " ".DOL_VERSION;
554 }
555
556 $to = $adh->makeSubstitution(getDolGlobalString('MAIN_INFO_SOCIETE_MAIL'));
557 $email_from = getDolGlobalString('ADHERENT_MAIL_FROM', $conf->email_from);
558 $mailfile = new CMailFile(
559 '['.$appli.'] ' . getDolGlobalString('ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT'),
560 $to,
561 $email_from,
562 $adh->makeSubstitution(getDolGlobalString('ADHERENT_AUTOREGISTER_NOTIF_MAIL')),
563 array(),
564 array(),
565 array(),
566 "",
567 "",
568 0,
569 -1
570 );
571
572 if (!$mailfile->sendfile()) {
573 dol_syslog($langs->trans("ErrorFailedToSendMail", $email_from, $to), LOG_ERR);
574 }
575 }
576
577 // Auto-create thirdparty on member creation
578 if (getDolGlobalString('ADHERENT_DEFAULT_CREATE_THIRDPARTY')) {
579 $company = new Societe($db);
580 $result = $company->create_from_member($adh);
581 if ($result < 0) {
582 $error++;
583 $errmsg .= implode('<br>', $company->errors);
584 }
585 }
586
587 if (!empty($backtopage)) {
588 $urlback = $backtopage;
589 } elseif (getDolGlobalString('MEMBER_URL_REDIRECT_SUBSCRIPTION')) {
590 $urlback = getDolGlobalString('MEMBER_URL_REDIRECT_SUBSCRIPTION');
591 // TODO Make replacement of __AMOUNT__, etc...
592 } else {
593 $urlback = $_SERVER["PHP_SELF"]."?action=added&token=".newToken();
594 }
595
596 if (getDolGlobalString('MEMBER_NEWFORM_PAYONLINE') && getDolGlobalString('MEMBER_NEWFORM_PAYONLINE') != '-1') {
597 if (empty($adht->caneditamount)) { // If edition of amount not allowed
598 // TODO Check amount is same than the amount required for the type of member
599 // It is not so important because a test is done on return of payment validation.
600 }
601
602 $minimumamountbytype = $adht->minimumamountbytype(1); // Load the array of minimum amount per type
603 $minimumamount = empty($minimumamountbytype[$adh->typeid]) ? 0 : $minimumamountbytype[$adh->typeid];
604 $amount = price2num(GETPOST('amount', 'alpha'), 'MT');
605 $urlback = getOnlinePaymentUrl(0, 'member', $adh->ref, (float) $amount, '', 0);
606 if ($amount < max(getDolGlobalInt("MEMBER_MIN_AMOUNT"), $minimumamount)) {
607 $error++;
608 $errmsg .= $langs->trans("MinimumAmountShort")." : ".price(max(getDolGlobalInt("MEMBER_MIN_AMOUNT"), $minimumamount), 0, $langs, 1, -1, -1, $conf->currency)."<br>\n";
609 }
610
611 if (GETPOST('member_email')) {
612 $urlback .= '&email='.urlencode(GETPOST('member_email'));
613 }
614 if (getDolGlobalString('MEMBER_NEWFORM_PAYONLINE') != '-1' && getDolGlobalString('MEMBER_NEWFORM_PAYONLINE') != 'all') {
615 $urlback .= '&paymentmethod='.urlencode(getDolGlobalString('MEMBER_NEWFORM_PAYONLINE'));
616 }
617 } else {
618 if (!empty($entity)) {
619 $urlback .= '&entity='.((int) $entity);
620 }
621 }
622 } else {
623 $error++;
624 $errmsg .= implode('<br>', $adh->errors);
625 }
626 }
627 }
628
629 if (!$error) {
630 $db->commit();
631
632 header("Location: ".$urlback);
633 exit;
634 } else {
635 $db->rollback();
636 $action = "create";
637 }
638}
639
640// Action called after a submitted was send and member created successfully
641// If MEMBER_URL_REDIRECT_SUBSCRIPTION is set to an url, we never go here because a redirect was done to this url. Same if we ask to redirect to the payment page.
642// backtopage parameter with an url was set on member submit page, we never go here because a redirect was done to this url.
643
644if (empty($reshook) && $action == 'added') { // Test on permission not required here
645 llxHeaderVierge($langs->trans("NewMemberForm"));
646
647 // If we have not been redirected
648 print '<br><br>';
649 print '<div class="center">';
650 print $langs->trans("NewMemberbyWeb");
651 print '</div>';
652
654 exit;
655}
656
657
658/*
659 * View
660 */
661
662$form = new Form($db);
663$formcompany = new FormCompany($db);
664$adht = new AdherentType($db);
665$extrafields->fetch_name_optionals_label($object->table_element); // fetch optionals attributes and labels
666
667
668llxHeaderVierge($langs->trans("NewSubscription"));
669
670print '<br>';
671print load_fiche_titre(img_picto('', 'member_nocolor', 'class="pictofixedwidth"').' &nbsp; '.$langs->trans("NewSubscription"), '', '', 0, '', 'center');
672
673
674print '<div align="center">';
675print '<div id="divsubscribe">';
676
677print '<div class="center subscriptionformhelptext opacitylow justify small margintoponly"><br>';
678if (getDolGlobalString('MEMBER_NEWFORM_TEXT')) {
679 print $langs->trans(getDolGlobalString('MEMBER_NEWFORM_TEXT'))."<br>\n";
680} else {
681 print $langs->trans("NewSubscriptionDesc", getDolGlobalString("MAIN_INFO_SOCIETE_MAIL"))."<br>\n";
682}
683print '</div>';
684print '<br>';
685
686dol_htmloutput_errors($errmsg);
688
689if ($action == "subscription") {
690 $urltocall = DOL_URL_ROOT.'/public/payment/newpayment.php?source=member&ref='.$object->id;
691 print $form->formconfirm($urltocall, $langs->trans("CorrespondingMemberFound"), $langs->trans("CorrespondingMemberFoundQuestion"), "confirm_subscription", '', 'no', 1);
692}
693
694// Print form
695print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" name="newmember" id="newmember">'."\n";
696print '<input type="hidden" name="token" value="'.newToken().'" />';
697print '<input type="hidden" name="entity" value="'.$entity.'" />';
698print '<input type="hidden" name="page_y" value="" />';
699
700if (getDolGlobalString('MEMBER_SKIP_TABLE') || getDolGlobalString('MEMBER_NEWFORM_FORCETYPE') || in_array($action, array('create', 'subscription'))) {
701 if ($action == 'subscription') {
702 print '<input type="hidden" name="nofetchmember" value="nofetchmember" />';
703 }
704 print '<input type="hidden" name="action" value="add" />';
705 print '<br>';
706
707 //$messagemandatory = '<span class="">'.$langs->trans("FieldsWithAreMandatory", '*').'</span>';
708 //print '<br>'.$messagemandatory.'<br>';
709 //print $langs->trans("FieldsWithIsForPublic",'**').'<br>';
710
711 print dol_get_fiche_head();
712
713 if ($conf->use_javascript_ajax) {
714 print "\n".'<script type="text/javascript">'."\n";
715 print 'jQuery(document).ready(function () {
716 jQuery("#selectcountry_id").change(function() {
717 console.log("We change country, so we reload page");
718 document.newmember.action.value="create";
719 jQuery("#newmember").submit();
720 });
721 function initfieldrequired() {
722 console.log("initfieldrequired");
723 jQuery("#tdcompany").removeClass("fieldrequired");
724 jQuery("#tdlastname").removeClass("fieldrequired");
725 jQuery("#tdfirstname").removeClass("fieldrequired");
726 if (jQuery(\'input[name="morphy"]:checked\').val() == \'mor\') {
727 jQuery("#tdcompany").addClass("fieldrequired");
728 }
729 if (jQuery(\'input[name="morphy"]:checked\').val() == \'phy\') {
730 jQuery("#tdlastname").addClass("fieldrequired");
731 jQuery("#tdfirstname").addClass("fieldrequired");
732 }
733 }
734 jQuery(\'input[name="morphy"]\').change(function() {
735 initfieldrequired();
736 });
737 initfieldrequired();
738 })';
739 print '</script>'."\n";
740 }
741
742 print '<table class="border" summary="form to subscribe" id="tablesubscribe">'."\n";
743
744 // Type
745 if (!getDolGlobalString('MEMBER_NEWFORM_FORCETYPE')) {
746 $typeid = GETPOSTINT("typeid");
747 print '<tr><td class="fieldrequired titlefieldmiddle">'.$langs->trans("MemberType").'</td><td>';
748 $listetype = $adht->liste_array(1);
749 print img_picto('', $adht->picto, 'class="pictofixedwidth"');
750 if (count($listetype)) {
751 print $form->selectarray("typeid", $listetype, (GETPOSTINT('typeid') ? GETPOSTINT('typeid') : $typeid), (count($listetype) > 1 ? 1 : 0), 0, 0, '', 0, 0, 0, '', 'minwidth150 maxwidth300 widthcentpercentminusx', 1);
752 } else {
753 print '<span class="error">'.$langs->trans("NoTypeDefinedGoToSetup").'</span>';
754 }
755 print '</td></tr>'."\n";
756 } else {
757 $adht->fetch(getDolGlobalInt('MEMBER_NEWFORM_FORCETYPE'));
758 print '<input type="hidden" id="typeid" name="typeid" value="' . getDolGlobalString('MEMBER_NEWFORM_FORCETYPE').'">';
759 }
760
761 // Moral/Physic attribute
762 $morphys = [
763 "phy" => $langs->trans("Physical"),
764 "mor" => $langs->trans("Moral"),
765 ];
766 $checkednature = GETPOST("morphy", 'alpha');
767 $listetype_natures = $adht->morphyByType(1); // Load the array of morphy per typeof membership
768 $listetype_natures_json = json_encode($listetype_natures);
769
770 if (!getDolGlobalString('MEMBER_NEWFORM_FORCEMORPHY')) {
771 if (empty($checkednature) && !empty($listetype_natures[GETPOSTINT('typeid')])) {
772 $checkednature = $listetype_natures[GETPOSTINT('typeid')];
773 }
774
775 print '<tr><td class="fieldrequired titlefieldmiddle">'.$langs->trans("MemberNature")."</td><td>\n";
776
777 $disabledphy = '';
778 $disabledmor = '';
779 //$disabledphy = ($checkednature == "mor" ? ' disabled="disabled"' : '');
780 //$disabledmor = ($checkednature == "phy" ? ' disabled="disabled"' : '');
781 print '<span id="spannature1" class="nonature-back spannature paddinglarge marginrightonly"><label for="phisicalinput" class="valignmiddle">'.$morphys["phy"].'<input id="phisicalinput" class="flat checkforselect marginleftonly valignmiddle" type="radio" name="morphy" value="phy"'.($checkednature == "phy" ? ' checked="checked"' : '').$disabledphy.'></label></span>';
782 print '<span id="spannature2" class="nonature-back spannature paddinglarge marginrightonly"><label for="moralinput" class="valignmiddle">'.$morphys["mor"].'<input id="moralinput" class="flat checkforselect marginleftonly valignmiddle" type="radio" name="morphy" value="mor"'.($checkednature == "mor" ? ' checked="checked"' : '').$disabledmor.'></label></span>';
783
784 // Add JS to manage the background of nature
785 if ($conf->use_javascript_ajax) {
786 print '<script>
787 var listetype_natures = '.$listetype_natures_json.';
788
789 jQuery(function($) {
790 function refreshNatureCss() {
791 $(".spannature").each(function(index) {
792 let $span = $("#spannature" + (index + 1));
793 let checked = $span.find(".checkforselect").is(":checked");
794
795 if (checked) {
796 if (index === 0) {
797 $span.addClass("member-individual-back").removeClass("nonature-back member-company-back");
798 } else if (index === 1) {
799 $span.addClass("member-company-back").removeClass("nonature-back member-individual-back");
800 }
801 } else {
802 $span.removeClass("member-individual-back member-company-back")
803 .addClass("nonature-back");
804 }
805 });
806 }
807
808 $(".spannature").on("click", function() {
809 console.log("Nature clicked");
810 refreshNatureCss();
811 });
812
813 $("#typeid").on("change", function() {
814 console.log("Type of membership is modified");
815 let morphy = listetype_natures[$(this).val()];
816 console.log("morphy="+morphy);
817
818 let $phyInput = $("#phisicalinput");
819 let $morInput = $("#moralinput");
820 let $tdLast = $("#tdlastname");
821 let $tdFirst = $("#tdfirstname");
822 let $tdCompany = $("#tdcompany");
823 let $span1 = $("#spannature1");
824 let $span2 = $("#spannature2");
825
826 switch (morphy) {
827 case "phy":
828 $phyInput.prop({disabled: false, checked: true});
829 $morInput.prop({disabled: true, checked: false});
830 $span1.addClass("member-individual-back").removeClass("nonature-back");
831 $span2.removeClass("member-company-back").addClass("nonature-back");
832 $("#phisicalinput").prop("checked", true);
833 $tdLast.addClass("fieldrequired");
834 $tdFirst.addClass("fieldrequired");
835 $tdCompany.removeClass("fieldrequired");
836 break;
837
838 case "mor":
839 $phyInput.prop({disabled: true, checked: false});
840 $morInput.prop({disabled: false, checked: true});
841 $span2.addClass("member-company-back").removeClass("nonature-back");
842 $span1.removeClass("member-individual-back").addClass("nonature-back");
843 $("#moralinput").prop("checked", true);
844 $tdCompany.addClass("fieldrequired");
845 $tdLast.removeClass("fieldrequired");
846 $tdFirst.removeClass("fieldrequired");
847 break;
848
849 default:
850 $phyInput.prop({disabled: false});
851 $morInput.prop({disabled: false});';
852 if ($action != "subscription" && !GETPOST('morphy')) {
853 print '
854 $phyInput.prop({checked: false});
855 $morInput.prop({checked: false});
856 $span1.removeClass("member-individual-back").addClass("nonature-back");
857 $span2.removeClass("member-company-back").addClass("nonature-back");';
858 }
859 print'}
860 });
861
862 // Initial state
863 refreshNatureCss();
864 });
865 </script>';
866 }
867 print '</td></tr>'."\n";
868 } else {
869 //print $morphys[$conf->global->MEMBER_NEWFORM_FORCEMORPHY];
870 print '<input type="hidden" id="morphy" name="morphy" value="' . getDolGlobalString('MEMBER_NEWFORM_FORCEMORPHY').'">';
871 }
872
873 // Company // TODO : optional hide
874 print '<tr id="trcompany" class="trcompany"><td id="tdcompany" class="titlefieldmiddle paddingrightonly'.($checkednature == "mor" ? ' fieldrequired"' : '').'">'.$langs->trans("Company").'</td><td>';
875 print img_picto('', 'company', 'class="pictofixedwidth paddingright"');
876 print '<input type="text" name="societe" class="minwidth150 widthcentpercentminusx" value="'.dol_escape_htmltag(GETPOST('societe')).'"></td></tr>'."\n";
877
878 // Title
879 if (getDolGlobalString('MEMBER_NEWFORM_ASK_TITLE')) {
880 print '<tr><td>'.$langs->trans('UserTitle').'</td><td>';
881 print $formcompany->select_civility(GETPOST('civility_id'), 'civility_id').'</td></tr>'."\n";
882 }
883
884 // Firstname
885 print '<tr><td id="tdfirstname" class="classfortooltip'.($checkednature == "phy" ? ' fieldrequired"' : '').'">'.$langs->trans("Firstname").'</td><td><input type="text" name="firstname" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('firstname')).'" spellcheck="false"></td></tr>'."\n";
886
887 // Lastname
888 print '<tr><td id="tdlastname" class="classfortooltip'.($checkednature == "phy" ? ' fieldrequired"' : '').'">'.$langs->trans("Lastname").'</td><td><input type="text" name="lastname" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('lastname')).'" spellcheck="false"></td></tr>'."\n";
889
890 // EMail
891 print '<tr><td>'.(getDolGlobalString('ADHERENT_MAIL_REQUIRED') ? '<span class="fieldrequired">' : '').$langs->trans("EMail").(getDolGlobalString('ADHERENT_MAIL_REQUIRED') ? '</span>' : '').'</td>';
892 print '<td>'.img_picto('', 'object_email').' <input type="text" name="member_email" class="minwidth150 maxwidth300 widthcentpercentminusx" maxlength="255" value="'.dol_escape_htmltag(GETPOST('member_email', "aZ09arobase")).'" spellcheck="false"></td></tr>'."\n";
893
894 // Login
895 if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
896 print '<tr><td><span class="fieldrequired">'.$langs->trans("Login").' / '.$langs->trans("Id").'</span></td><td><input type="text" name="login" maxlength="50" class="minwidth100" value="'.(GETPOSTISSET("login") ? GETPOST("login", 'alphanohtml', 2) : $object->login).'"></td></tr>'."\n";
897 print '<tr><td><span class="fieldrequired">'.$langs->trans("Password").'</span></td><td><input type="password" maxlength="128" name="pass1" class="minwidth100" value="'.dol_escape_htmltag(GETPOST("pass1", "none", 2)).'"></td></tr>'."\n";
898 print '<tr><td><span class="fieldrequired">'.$langs->trans("PasswordRetype").'</span></td><td><input type="password" maxlength="128" name="pass2" class="minwidth100" value="'.dol_escape_htmltag(GETPOST("pass2", "none", 2)).'"></td></tr>'."\n";
899 }
900
901 // Gender
902 print '<tr><td>'.$langs->trans("Gender").'</td>';
903 print '<td>';
904 $arraygender = array('man' => $langs->trans("Genderman"), 'woman' => $langs->trans("Genderwoman"), 'other' => $langs->trans("Genderother"));
905 print $form->selectarray('gender', $arraygender, GETPOST('gender', 'alphanohtml'), 1, 0, 0, '', 0, 0, 0, '', 'minwidth150 maxwidth300 widthcentpercentminusx', 1);
906 print '</td></tr>';
907
908 // Address
909 print '<tr><td>'.$langs->trans("Address").'</td><td>'."\n";
910 print '<textarea name="address" id="address" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.'">'.dol_escape_htmltag(GETPOST('address', 'restricthtml'), 0, 1).'</textarea></td></tr>'."\n";
911
912 // Zip / Town
913 print '<tr><td>'.$langs->trans('Zip').' / '.$langs->trans('Town').'</td><td>';
914 print $formcompany->select_ziptown(GETPOST('zipcode'), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 1, '', 'width75');
915 print ' / ';
916 print $formcompany->select_ziptown(GETPOST('town'), 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 1);
917 print '</td></tr>';
918
919 $country_id = GETPOSTINT('country_id');
920
921 // Country
922 print '<tr><td class="fieldrequired">'.$langs->trans('Country').'</td><td>';
923 print img_picto('', 'country', 'class="pictofixedwidth paddingright"');
924 if (!$country_id && getDolGlobalString('MEMBER_NEWFORM_FORCECOUNTRYCODE')) {
925 $country_id = (int) getCountry(getDolGlobalString('MEMBER_NEWFORM_FORCECOUNTRYCODE'), '3', $db, $langs);
926 }
927 if (!$country_id && !empty($conf->geoipmaxmind->enabled)) {
928 $country_code = dol_user_country();
929 //print $country_code;
930 if ($country_code) {
931 $new_country_id = getCountry($country_code, '3', $db, $langs);
932 //print 'xxx'.$country_code.' - '.$new_country_id;
933 if ($new_country_id) {
934 $country_id = $new_country_id;
935 }
936 }
937 }
938 $country_code = getCountry($country_id, '2', $db, $langs);
939 print $form->select_country($country_id, 'country_id', '', 0, 'minwidth150 maxwidth300 widthcentpercentminusx reposition');
940 print '</td></tr>';
941
942 // State
943 if (!getDolGlobalString('SOCIETE_DISABLE_STATE')) {
944 print '<tr><td>'.$langs->trans('State').'</td><td>';
945 if ($country_code) {
946 print img_picto('', 'state', 'class="pictofixedwidth paddingright"');
947 print $formcompany->select_state(GETPOSTINT("state_id"), $country_code, 'state_id', 'minwidth150 maxwidth300 widthcentpercentminusx');
948 }
949 print '</td></tr>';
950 }
951
952 // Pro phone
953 print '<tr><td>'.$langs->trans("PhonePro").'</td>';
954 print '<td>'.$form->showPhoneInput(GETPOST('phone'), 'phone', $country_id, 'object_phoning', 'maxwidth300 widthcentpercentminusx').'</td></tr>';
955
956 // Personal phone
957 print '<tr><td>'.$langs->trans("PhonePerso").'</td>';
958 print '<td>'.$form->showPhoneInput(GETPOST('phone_perso'), 'phone_perso', $country_id, 'object_phoning', 'maxwidth300 widthcentpercentminusx').'</td></tr>';
959
960 // Mobile phone
961 print '<tr><td>'.$langs->trans("PhoneMobile").'</td>';
962 print '<td>'.$form->showPhoneInput(GETPOST('phone_mobile'), 'phone_mobile', $country_id, 'object_phoning_mobile', 'maxwidth300 widthcentpercentminusx').'</td></tr>';
963
964 // Birthday
965 print '<tr id="trbirth" class="trbirth"><td>'.$langs->trans("DateOfBirth").'</td><td>';
966 print $form->selectDate(!empty($birthday) ? $birthday : "", 'birth', 0, 0, 1, "newmember", 1, 0);
967 print '</td></tr>'."\n";
968
969 // Photo
970 print '<tr><td>'.$langs->trans("URLPhoto").'</td><td><input type="text" name="photo" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('photo')).'"></td></tr>'."\n";
971
972 // Public
973 if (getDolGlobalString('MEMBER_PUBLIC_ENABLED')) {
974 $linkofpubliclist = DOL_MAIN_URL_ROOT.'/public/members/public_list.php'.((isModEnabled('multicompany')) ? '?entity='.$conf->entity : '');
975 $publiclabel = $langs->trans("Public", getDolGlobalString('MAIN_INFO_SOCIETE_NOM'), $linkofpubliclist);
976 print '<tr><td>'.$form->textwithpicto($langs->trans("MembershipPublic"), $publiclabel).'</td><td><input type="checkbox" name="public"></td></tr>'."\n";
977 }
978
979 // Other attributes
980 $parameters['tpl_context'] = 'public'; // define template context to public
981 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
982
983 // Comments
984 print '<tr>';
985 print '<td class="tdtop"></td>';
986 print '<td class="tdtop"><textarea placeholder="'.dolPrintHTML($langs->trans("Comments")).'" name="note_private" id="note_private" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.'">'.dol_escape_htmltag(GETPOST('note_private', 'restricthtml'), 0, 1).'</textarea></td>';
987 print '</tr>'."\n";
988
989
990 // Define amount by default to suggest
991 $typeid = getDolGlobalInt('MEMBER_NEWFORM_FORCETYPE', GETPOSTINT('typeid'));
992 $adht = new AdherentType($db);
993 $adht->fetch($typeid);
994 $caneditamount = $adht->caneditamount;
995 $amountbytype = $adht->amountByType(1); // Load the array of amount per type
996 $minimumamountbytype = $adht->minimumamountbytype(1); // Load the array of minimum amount per type
997 foreach ($amountbytype as $k => $v) {
998 $amount = max(0, (float) $v, (float) getDolGlobalInt("MEMBER_MIN_AMOUNT"), $minimumamountbytype[$k]);
999 $amountbytype[$k] = $amount;
1000 }
1001
1002 $caneditamountbytype = $adht->caneditamountByType(1); // Load the array of caneditamount per type
1003 $amountformuladescriptionbytype = $adht->amountformuladescriptionbytype(1); // Load the array of amount ormula description per type
1004
1005 // Set amount for the subscription from the type and options:
1006 // - First check the amount of the member type.
1007 $amount = empty($amountbytype[$typeid]) ? 0 : $amountbytype[$typeid];
1008 // - If not set, we accept to have amount defined as parameter (for backward compatibility).
1009 if (empty($amount)) {
1010 $amount = (GETPOST('amount') ? price2num(GETPOST('amount', 'alpha'), 'MT', 2) : '');
1011 }
1012 // - If a min is set, we take it into account
1013 $minimumamount = empty($minimumamountbytype[$typeid]) ? 0 : $minimumamountbytype[$typeid];
1014 $amount = max(0, (float) $amount, (float) getDolGlobalInt("MEMBER_MIN_AMOUNT"), (float) $minimumamount);
1015
1016 // Clean the amount
1017 $amount = price2num($amount);
1018
1019
1020 // Add hook to complete the form
1021 $parameters = array('country_id' => $country_id, 'mode' => 'new');
1022 $reshook = $hookmanager->executeHooks('membershipNewSubscriptionPublicForm', $parameters, $object, $action);
1023 if ($reshook < 0) {
1024 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1025 $error++;
1026 }
1027 // TODO Move this into previous hook
1028 if (getDolGlobalString('MEMBER_NEWFORM_DOLIBARRTURNOVER')) {
1029 $s = $langs->trans("AreYouAPreferredPartner", '<a href="https://partners.dolibarr.org" target="_blank">{s1}</a>');
1030 $s = str_replace('{s1}', 'Preferred Partner', $s);
1031 print '<tr id="trbudget" class="trcompany"><td class="paddingrightonly"><label for="pp" class="small">'.$s.'</label></td><td>';
1032 print '<input type="checkbox" name="pp" id="pp" value="1"'.(GETPOST('pp') ? ' checked="checked"' : '').' class="reposition">';
1033 print '</td></tr>';
1034
1035 print '<tr id="trbudget" class="trcompany"><td class="fieldrequired paddingrightonly"><span class="small">'.$langs->trans("TurnoverOrBudget").'</span></td><td>';
1036
1037 $country_code = dol_getIdFromCode($db, $country_id, 'c_country', 'rowid', 'code');
1038 if ($country_code === 'FR' && $checkednature === 'mor' && GETPOST('pp')) {
1039 print '<input type="text" name="budget" id="budget" class="flat turnover right width100" value="'.GETPOST('budget').'" required>';
1040 } else {
1041 $arraybudget = array('50' => '<= 100 000', '100' => '<= 200 000', '200' => '<= 500 000', '300' => '<= 1 500 000', '600' => '<= 3 000 000', '1000' => '<= 5 000 000', '2000' => '5 000 000+');
1042 print $form->selectarray('budget', $arraybudget, GETPOSTINT('budget'), 1, 0, 0, '', 0, 0, 0, '');
1043 }
1044 print ' € or $';
1045
1046 print '<script type="text/javascript">
1047 jQuery(document).ready(function() {
1048 firstload = true;
1049
1050 newamount = initturnover();
1051 jQuery("#amount").val(newamount);
1052
1053 firstload = false;
1054
1055 jQuery("#selectcountry_id").change(function() {
1056 console.log("We change country (code added for association, replace common code), so we reload page");
1057 jQuery("#budget").val(\'\');
1058 jQuery("#amount").val(\'\');
1059 jQuery("#amounthidden").val(\'\');
1060 });
1061 jQuery("#phisicalinput,#moralinput").click(function() {
1062 console.log("We change the nature of membership");
1063 newamount = initturnover();
1064 jQuery("#amount").val(newamount);
1065 });
1066 jQuery("#pp").change(function() {
1067 console.log("We change the preferred partner status");
1068 selectcountry_id = jQuery("#selectcountry_id").val();
1069 morphy = jQuery("#moralinput").is(\':checked\') ? \'mor\' : \'phy\';
1070 jQuery("#budget").val(\'\');
1071 jQuery("#amount").val(\'\');
1072 jQuery("#amounthidden").val(\'\');
1073 document.newmember.action.value="create";
1074 jQuery("#newmember").submit();
1075 });
1076 jQuery("#budget").change(function() {
1077 console.log("Turnover amount has been modified on change");
1078 newamount = initturnover();
1079 jQuery("#amount").val(newamount);
1080 jQuery("#amounthidden").val(newamount);
1081 });
1082 jQuery("#budget").keyup(function() {
1083 console.log("Turnover amount has been modified on keyup");
1084 newamount = initturnover();
1085 jQuery("#amount").val(newamount);
1086 jQuery("#amounthidden").val(newamount);
1087 });
1088
1089 function initturnover() {
1090 newamount = 0;
1091
1092 morphy = jQuery("#moralinput").is(\':checked\') ? \'mor\' : \'phy\';
1093 selectcountry_id = jQuery("#selectcountry_id").val();
1094 pp = jQuery("#pp").is(\':checked\') ? true : false;
1095 console.log("Set fields according to nature and other properties");
1096 console.log("morphy="+morphy);
1097 console.log("selectcountry_id="+selectcountry_id);
1098 console.log("pp="+pp);
1099
1100 if (morphy == \'phy\') {
1101 jQuery(".amount").val('.((float) $amount).');
1102 jQuery("#trbirth").show();
1103 jQuery(".trcompany").hide();
1104 jQuery(".trbudget").hide();
1105 newamount = '.((float) $amount).';
1106 } else {
1107 jQuery(".amount").val(\'\');
1108 jQuery("#trbirth").hide();
1109 jQuery(".trcompany").show();
1110 jQuery(".trbudget").show();
1111 jQuery(".hideifautoturnover").hide();
1112 if (firstload) {
1113 jQuery("#budget").val(\'\');
1114 }
1115
1116 if (selectcountry_id == 1) {
1117 if (pp) {
1118 console.log("value selected in input text field is "+jQuery("#budget").val());
1119 newamount = Math.max(Math.round(price2numjs(jQuery("#budget").val()) * 0.005), 50);
1120 console.log("newamount = "+newamount);
1121 } else {
1122 console.log("not a pp");
1123 if (jQuery("#budget").val() > 0) {
1124 console.log("value found in budget is "+jQuery("#budget").val());
1125 newamount = jQuery("#budget").val();
1126 } else {
1127 jQuery("#budget").val(\'\');
1128 newamount = \'\';
1129 }
1130 }
1131 } else {
1132 if (jQuery("#budget").val() > 0) {
1133 newamount = jQuery("#budget").val();
1134 } else {
1135 jQuery("#budget").val(\'\');
1136 newamount = \'\';
1137 }
1138 console.log("newamount="+newamount);
1139 }
1140 }
1141
1142 return newamount;
1143 }
1144 });
1145 </script>';
1146 print '</td></tr>'."\n";
1147 }
1148
1149 if (getDolGlobalString('MEMBER_NEWFORM_PAYONLINE')) { // Can be 'all', 'paypal', 'paybox', 'stripe'...
1150 print '<tr><td>'.$langs->trans("Subscription");
1151 if (getDolGlobalString('MEMBER_EXT_URL_SUBSCRIPTION_INFO')) {
1152 print '<br>';
1153 print '<a href="' . getDolGlobalString('MEMBER_EXT_URL_SUBSCRIPTION_INFO').'" rel="external" target="_blank" rel="noopener noreferrer">';
1154 print img_picto('', 'url', 'class="pictofixedwidth"').$langs->trans("SeeHere");
1155 print '</a>';
1156 }
1157 print '</td><td class="nowrap">';
1158
1159 $amountformuladescription = $amountformuladescriptionbytype[$typeid];
1160
1161 $showedamount = $amount > 0 ? $amount : 0;
1162 if ($caneditamount === "1") {
1163 print '<input type="text" name="amount" id="amount" class="flat amount right width75" value="'.$showedamount.'">';
1164 print '<input type="text" name="amount" id="amounthidden" class="flat amount width75 hidden" disabled value="'.$showedamount.'">';
1165 print ' '.$langs->getCurrencySymbol($conf->currency).'<span class="opacitymedium amountdescription hideifautoturnover small">';
1166 if (!getDolGlobalString('MEMBER_NEWFORM_DOLIBARRTURNOVER')) {
1167 print ' - ';
1168 if (empty($amountformuladescription)) {
1169 print $amount > 0 ? $langs->trans("AnyAmountWithAdvisedAmount", price($amount, 0, $langs, 1, -1, -1, $conf->currency)) : $langs->trans("AnyAmountWithoutAdvisedAmount");
1170 } else {
1171 print $amountformuladescription;
1172 }
1173 }
1174 if (getDolGlobalInt("MEMBER_MIN_AMOUNT") > 0 || $minimumamount > 0) {
1175 print '</span><br><span id="minimumamount" class="opacitymedium small">'.$langs->trans("MinimumAmountShort").' : '.price(max(getDolGlobalInt("MEMBER_MIN_AMOUNT"), $minimumamount), 0, $langs, 1, -1, -1, $conf->currency);
1176 }
1177 print '</span>';
1178 } else {
1179 print '<input type="text" name="amount" id="amount" class="flat amount width75 right hidden" value="'.$showedamount.'">';
1180 print '<input type="text" name="amount" id="amounthidden" class="flat amount width75" disabled value="'.$showedamount.'">';
1181 print ' '.$langs->getCurrencySymbol($conf->currency).'<span class="opacitymedium amountdescription hideifautoturnover hidden small">';
1182 if (!getDolGlobalString('MEMBER_NEWFORM_DOLIBARRTURNOVER')) {
1183 print ' - ';
1184 print $amount > 0 ? $langs->trans("AnyAmountWithAdvisedAmount", price($amount, 0, $langs, 1, -1, -1, $conf->currency)) : $langs->trans("AnyAmountWithoutAdvisedAmount");
1185 }
1186 print '</span>';
1187 }
1188 print '</td></tr>';
1189 }
1190
1191 // Display Captcha code if is enabled
1192 if (getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA_MEMBER') && is_object($captchaobj)) {
1193 print '<tr><td><label><span class="fieldrequired">'.$langs->trans("SecurityCode").'</span></label></td><td><br>';
1194 if (method_exists($captchaobj, 'getCaptchaCodeForForm')) {
1195 print $captchaobj->getCaptchaCodeForForm(''); // @phan-suppress-current-line PhanUndeclaredMethod
1196 } else {
1197 print 'Error, the captcha handler '.get_class($captchaobj).' does not have any method getCaptchaCodeForForm()';
1198 }
1199 print '<br></td></tr>';
1200 }
1201
1202 print "</table>\n";
1203
1204 print dol_get_fiche_end();
1205
1206 // Save / Submit
1207 print '<div class="center">';
1208 print '<input type="submit" value="'.$langs->trans("GetMembershipButtonLabel").'" id="submitsave" class="button">';
1209 if (!empty($backtopage)) {
1210 print ' &nbsp; &nbsp; <input type="submit" value="'.$langs->trans("Cancel").'" id="submitcancel" class="button button-cancel">';
1211 }
1212 print '</div>';
1213
1214 // Add JS to manage the background of amount depending on type
1215 $typeid = getDolGlobalInt('MEMBER_NEWFORM_FORCETYPE', GETPOSTINT('typeid'));
1216 $adht = new AdherentType($db);
1217 $adht->fetch($typeid);
1218 $caneditamountbytype = $adht->caneditamountByType(1); // Load the array of caneditamount per type
1219 $minimumamountbytype = $adht->minimumamountbytype(1); // Load the array of minimum amount per type
1220 $amountbytype = $adht->amountByType(1); // Load the array of amount per type
1221 $amountformuladescriptionbytype = $adht->amountformuladescriptionbytype(1); // Load the array of amount ormula description per type
1222 // Common PHP → JS variables
1223 $caneditamountbytype_json = json_encode($caneditamountbytype);
1224 $minimumamountbytype_json = json_encode($minimumamountbytype);
1225 $amountbytype_json = json_encode($amountbytype);
1226 $amountformuladescriptionbytype_json = json_encode($amountformuladescriptionbytype);
1227 $currencysymbol = $langs->getCurrencySymbol($conf->currency);
1228
1229 if ($conf->use_javascript_ajax) {
1230 print '<script>
1231 // ----- Shared data -----
1232 var amountByType = ' . $amountbytype_json . ';
1233 var canEditAmountByType = ' . $caneditamountbytype_json . ';
1234 var amountFormulaDescriptionByType = ' . $amountformuladescriptionbytype_json . ';
1235 var minimumAmountByType = ' . $minimumamountbytype_json . ';
1236 var memberMinAmount = ' . getDolGlobalInt("MEMBER_MIN_AMOUNT") . ';
1237 var currencySymbol = ' . json_encode($currencysymbol) . ';
1238
1239 // Translations prepared by PHP
1240 var langs = {
1241 AnyAmountWithAdvisedAmount: ' . json_encode($langs->trans("AnyAmountWithAdvisedAmount", "__VAL__")) . ',
1242 AnyAmountWithoutAdvisedAmount: ' . json_encode($langs->trans("AnyAmountWithoutAdvisedAmount")) . ',
1243 MinimumAmountShort: ' . json_encode($langs->trans("MinimumAmountShort", "__VAL__")) . ',
1244 trans: function(key, val) {
1245 if (!this[key]) return key;
1246 return this[key].replace("__VAL__", val || "");
1247 }
1248 };
1249
1250 jQuery(function($) {
1251 // ----- Helpers -----
1252 function getCurrentMin() {
1253 let typeId = $("#typeid").val() || 0;
1254 let minimumAmount = minimumAmountByType[typeId] || 0;
1255 return Math.max(memberMinAmount, minimumAmount);
1256 }
1257
1258 function checkAmount() {
1259 let raw = $("#amount").val() || "";
1260 let val = parseFloat(raw.replace(",", ".")) || 0;
1261 let minimum = getCurrentMin();
1262 if (val < minimum) {
1263 $("#submitsave").prop("disabled", true);
1264 } else {
1265 $("#submitsave").prop("disabled", false);
1266 }
1267 }
1268
1269 function updateAmountAndTexts() {
1270 let typeId = $("#typeid").val();
1271 let amountVal = amountByType[typeId] || 0;
1272 let formattedAmount = parseFloat(amountVal);
1273 let canEdit = canEditAmountByType[typeId] === "1";
1274 let amountFormulaDescription = amountFormulaDescriptionByType[typeId] || "";
1275 let minimumAmount = minimumAmountByType[typeId] || 0;
1276 let minimum = Math.max(memberMinAmount, minimumAmount);
1277
1278 if (canEdit) {
1279 // Editable mode
1280 $("#amount").val(formattedAmount).prop("disabled", false).removeClass("hidden");
1281 $("#amounthidden").addClass("hidden");
1282 $(".hideifautoturnover").removeClass("hidden");
1283
1284 // Description formula or default text
1285 if (amountFormulaDescription.trim() !== "") {
1286 $(".amountdescription").html(" - " + amountFormulaDescription);
1287 } else {
1288 if (amountVal > 0) {
1289 $(".amountdescription").html(" - " + langs.trans("AnyAmountWithAdvisedAmount", formattedAmount + " " + currencySymbol));
1290 } else {
1291 $(".amountdescription").html(" - " + langs.trans("AnyAmountWithoutAdvisedAmount"));
1292 }
1293 }
1294
1295 // Minimum amount label
1296 if (minimum > 0) {
1297 $("#minimumamount")
1298 .html(langs.trans("MinimumAmountShort") + " : " + minimum + " " + currencySymbol)
1299 .removeClass("hidden");
1300 } else {
1301 $("#minimumamount").addClass("hidden");
1302 }
1303 } else {
1304 // Read-only mode
1305 $("#amounthidden").val(formattedAmount).prop("disabled", true).removeClass("hidden");
1306 $("#amount").addClass("hidden");
1307 $(".hideifautoturnover").addClass("hidden");
1308 $("#minimumamount").addClass("hidden");
1309 }
1310
1311 // After updating fields, re‑check the amount validity
1312 checkAmount();
1313 }
1314
1315 // ----- Bind events -----
1316 $("#typeid").on("change", function() {
1317 console.log("Type of membership changed, update amount, description and minimum");
1318 updateAmountAndTexts();
1319 });
1320
1321 $("#amount").on("keyup change", function() {
1322 checkAmount();
1323 });
1324 });
1325 </script>';
1326 }
1327
1328 print "</form>\n";
1329 print "<br>";
1330 print '</div></div>';
1331} else { // Show the table of membership types
1332 // Get units
1333 $measuringUnits = new CUnits($db);
1334 $result = $measuringUnits->fetchAll('', '', 0, 0, array('t.active' => 1));
1335 $units = array();
1336 foreach ($measuringUnits->records as $lines) {
1337 $units[$lines->short_label] = $langs->trans(ucfirst((string) $lines->label));
1338 }
1339
1340 $publiccounters = getDolGlobalString("MEMBER_COUNTERS_ARE_PUBLIC");
1341 $hidevoteallowed = getDolGlobalString("MEMBER_HIDE_VOTE_ALLOWED");
1342
1343 $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.amount, d.caneditamount, d.vote, d.note, d.duration, d.statut as status, d.morphy,";
1344 $sql .= " COUNT(a.rowid) AS membercount";
1345 $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
1346 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as a";
1347 $sql .= " ON d.rowid = a.fk_adherent_type AND a.statut > 0";
1348 $sql .= " WHERE d.entity IN (".getEntity('member_type').")";
1349 $sql .= " AND d.statut=1";
1350 $sql .= " GROUP BY d.rowid, d.libelle, d.subscription, d.amount, d.caneditamount, d.vote, d.note, d.duration, d.statut, d.morphy";
1351
1352 $result = $db->query($sql);
1353 if ($result) {
1354 $num = $db->num_rows($result);
1355
1356 print '<br><div class="div-table-responsive">';
1357 print '<table class="tagtable liste noborder">'."\n";
1358 print '<input type="hidden" name="action" value="create">';
1359
1360 print '<tr class="liste_titre">';
1361 print '<th>'.$langs->trans("Label").'</th>';
1362 print '<th class="center">'.$langs->trans("MembershipDuration").'</th>';
1363 print '<th class="center">'.$langs->trans("RecommendedAmount").'</th>';
1364 print '<th class="center">'.$langs->trans("MembersNature").'</th>';
1365 if (empty($hidevoteallowed)) {
1366 print '<th class="center">'.$langs->trans("VoteAllowed").'</th>';
1367 }
1368 if ($publiccounters) {
1369 print '<th class="center">'.$langs->trans("Members").'</th>';
1370 }
1371 print '<th class="center"></th>';
1372 print "</tr>\n";
1373
1374 $i = 0;
1375 while ($i < $num) {
1376 $objp = $db->fetch_object($result); // Load the member type and information on it
1377
1378 $caneditamount = $objp->caneditamount;
1379 $amountbytype = $adht->amountByType(1); // Load the array of amount per type
1380 $minimumamountbytype = $adht->minimumamountbytype(1); // Load the array of amount per type
1381
1382 print '<tr class="oddeven">';
1383
1384 // Label
1385 print '<td>';
1386 print '<div class="twolinesmax-normallineheight minwidth200onall">';
1387 print dolPrintHTML($objp->label);
1388 print '</div>';
1389 print '</td>';
1390
1391 // Duration
1392 print '<td class="center">';
1393 $unit = preg_replace("/[^a-zA-Z]+/", "", $objp->duration);
1394 print '<span class="badge badge-primary">';
1395 print max(1, intval($objp->duration)).' '.$units[$unit];
1396 print '</span>';
1397 print '</td>';
1398
1399 // Amount
1400 print '<td class="center"><span class="amount nowrap">';
1401
1402 // Set amount for the subscription from the the type and options:
1403 // - First check the amount of the member type.
1404 $amount = empty($amountbytype[$objp->rowid]) ? 0 : $amountbytype[$objp->rowid];
1405 $minimumamount = empty($minimumamountbytype[$objp->rowid]) ? 0 : $minimumamountbytype[$objp->rowid];
1406 // - If not set, we accept to have amount defined as parameter (for backward compatibility).
1407 if (empty($amount)) {
1408 $amount = (GETPOST('amount') ? price2num(GETPOST('amount', 'alpha'), 'MT', 2) : '');
1409 }
1410 // - If a min is set, we take it into account
1411 $amount = max(0, (float) $amount, (float) getDolGlobalInt("MEMBER_MIN_AMOUNT"), (float) $minimumamount);
1412
1413 $displayedamount = $amount;
1414
1415 if ($objp->subscription) {
1416 if ($displayedamount > 0 || !$caneditamount) {
1417 print price($displayedamount, 1, $langs, 1, 0, -1, $conf->currency);
1418 }
1419 if ($caneditamount && $displayedamount > 0) {
1420 print $form->textwithpicto('', $langs->transnoentities("CanEditAmountShortForValues"), 1, 'help', '', 0, 3);
1421 } elseif ($caneditamount) {
1422 print $langs->transnoentities("CanEditAmountShort");
1423 }
1424 } else {
1425 print "–"; // No subscription required
1426 }
1427 print '</span></td>';
1428
1429 print '<td class="center minwidth100">';
1430 if ($objp->morphy == 'phy') {
1431 print $langs->trans("Physical");
1432 } elseif ($objp->morphy == 'mor') {
1433 print $langs->trans("Moral");
1434 } else {
1435 print $langs->trans("MorAndPhy");
1436 }
1437 print '</td>';
1438
1439 if (empty($hidevoteallowed)) {
1440 print '<td class="center">'.yn($objp->vote).'</td>';
1441 }
1442 $membercount = $objp->membercount > 0 ? $objp->membercount : "–";
1443 if ($publiccounters) {
1444 print '<td class="center">'.$membercount.'</td>';
1445 }
1446 print '<td class="center"><button class="button button-save reposition" name="typeid" type="submit" name="submit" value="'.$objp->rowid.'">'.$langs->trans("GetMembershipButtonLabel").'</button></td>';
1447 print "</tr>";
1448 $i++;
1449 }
1450
1451 // If no record found
1452 if ($num == 0) {
1453 $colspan = 8;
1454 print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
1455 }
1456
1457 print "</table>";
1458 print '</div>';
1459
1460 print '</form>';
1461 } else {
1462 dol_print_error($db);
1463 }
1464}
1465
1466//htmlPrintOnlineFooter($mysoc, $langs);
1468
1469$db->close();
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage members of a foundation.
Class to manage members type.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Class of dictionary type of thirdparty (used by imports)
Class to manage standard extra fields.
Class to build HTML component for third parties management Only common components are here.
Class to manage generation of HTML components Only common components must be here.
Class to manage a HTML form to send a unitary email Usage: $formail = new FormMail($db) $formmail->pr...
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
llxHeaderVierge($title, $head="", $disablejs=0, $disablehead=0, $arrayofjs=[], $arrayofcss=[], $ws='')
Show header for new prospect.
Definition new.php:123
llxFooterVierge()
Show footer for new societe.
Definition new.php:144
htmlPrintOnlineHeader($mysoc, $langs, $showlogo=1, $alttext='', $subimageconst='', $altlogo1='', $altlogo2='')
Show the header of a company in HTML public pages.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
global $mysoc
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0, $tz='')
Add a delay to a date.
Definition date.lib.php:127
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
price2num($amount, $rounding='', $option=0, $currencycode='')
Function that return a number with universal decimal format (decimal separator is '.
dol_user_country()
Return country code for current user.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
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...
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getUserRemoteIP($trusted=0)
Return the real IP of remote user.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
Definition html.lib.php:542
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition html.lib.php:740
printCommonFooter($zone='private')
Print common footer : conf->global->MAIN_HTML_FOOTER js for switch of menu hider js for conf->global-...
dol_htmloutput_events($disabledoutputofmessages=0)
Print formatted messages to output (Used to show messages on html output).
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0)
Print formatted error messages to output (Used to show messages on html output).
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Definition html.lib.php:183
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs=array(), $arrayofcss=array(), $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Output html header of a page.
if(getDolGlobalString( 'MAIN_SECURITY_ENABLECAPTCHA_MEMBER')) force_switch_entity($newEntity)
Force switching conf of entity, even if user is connected Fox example when trying to go on public for...
Definition new.php:153
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.