dolibarr 24.0.0-beta
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", "errors"));
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 {
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 {
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 {
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 }
350
351 if ($morphy && $morphy != 'mor' && empty($lastname)) {
352 $error++;
353 $langs->load("errors");
354 $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname"));
355 }
356 if ($morphy && $morphy != 'mor' && (!isset($firstname) || $firstname == '')) {
357 $error++;
358 $langs->load("errors");
359 $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentities("Firstname"));
360 }
361 if ($morphy == 'mor' && empty($societe)) {
362 $error++;
363 $langs->load("errors");
364 $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentities("Company"));
365 }
366 if (empty($country_id)) {
367 $error++;
368 $langs->load("errors");
369 $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentities("Country"));
370 }
371 if (getDolGlobalString('ADHERENT_MAIL_REQUIRED') && $email && !isValidEmail($email)) {
372 $error++;
373 $langs->load("errors");
374 $errmsg .= $langs->trans("ErrorBadEMail", $email);
375 }
376 $birthday = dol_mktime(GETPOSTINT("birthhour"), GETPOSTINT("birthmin"), GETPOSTINT("birthsec"), GETPOSTINT("birthmonth"), GETPOSTINT("birthday"), GETPOSTINT("birthyear"));
377 if (GETPOST("birthmonth") && empty($birthday)) {
378 $error++;
379 $langs->load("errors");
380 $errmsg .= $langs->trans("ErrorBadDateFormat")."<br>\n";
381 }
382
383 // TODO Add this in a hook
384 if (getDolGlobalString('MEMBER_NEWFORM_DOLIBARRTURNOVER')) {
385 if (GETPOST("morphy") == 'mor' && GETPOSTFLOAT('budget') <= 0) {
386 $error++;
387 $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("TurnoverOrBudget"))."<br>\n";
388 }
389 }
390
391 // Check Captcha code if is enabled
392 $ok = false;
393 if (getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA_MEMBER') && is_object($captchaobj)) {
394 if (method_exists($captchaobj, 'validateCodeAfterLoginSubmit')) {
395 $ok = $captchaobj->validateCodeAfterLoginSubmit(); // @phan-suppress-current-line PhanUndeclaredMethod
396 } else {
397 print 'Error, the captcha handler '.get_class($captchaobj).' does not have any method validateCodeAfterLoginSubmit()';
398 }
399 if (!$ok) {
400 $error++;
401 $langs->load("errors");
402 $errmsg .= $langs->trans("ErrorBadValueForCode")."<br>\n";
403 $action = '';
404 }
405 }
406
407 $public = GETPOSTISSET('public') ? 1 : 0;
408
409 if (!$error) {
410 // E-mail looks OK and login does not exist
411 $adh = new Adherent($db);
412 $adh->statut = -1;
413 $adh->status = -1;
414 $adh->public = $public;
415 $adh->firstname = GETPOST('firstname');
416 $adh->lastname = GETPOST('lastname');
417 $adh->gender = GETPOST('gender');
418 $adh->civility_id = GETPOST('civility_id');
419 $adh->company = GETPOST('societe');
420 $adh->societe = $adh->company;
421 $adh->address = GETPOST('address');
422 $adh->zip = GETPOST('zipcode');
423 $adh->town = GETPOST('town');
424 $adh->email = GETPOST('member_email', 'aZ09arobase');
425 if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
426 $adh->login = GETPOST('login');
427 $adh->pass = GETPOST('pass1', 'password');
428 }
429 $adh->photo = GETPOST('photo');
430 $adh->country_id = $country_id;
431 $adh->state_id = GETPOSTINT('state_id');
432 $adh->typeid = getDolGlobalInt("MEMBER_NEWFORM_FORCETYPE", GETPOSTINT('typeid'));
433 $adh->note_private = GETPOST('note_private');
434 $adh->morphy = getDolGlobalString("MEMBER_NEWFORM_FORCEMORPHY", GETPOST('morphy'));
435 $adh->birth = $birthday;
436 $adh->phone = GETPOST('phone');
437 $adh->phone_perso = GETPOST('phone_perso');
438 $adh->phone_mobile = GETPOST('phone_mobile');
439
440 $adh->ip = getUserRemoteIP();
441
442 $nb_post_max = getDolGlobalInt("MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
443 $now = dol_now();
444 $minmonthpost = dol_time_plus_duree($now, -1, "m");
445 // Calculate nb of post for IP
446 $nb_post_ip = 0;
447 if ($nb_post_max > 0) { // Calculate only if there is a limit to check
448 $sql = "SELECT COUNT(ref) as nb_adh";
449 $sql .= " FROM ".MAIN_DB_PREFIX."adherent";
450 $sql .= " WHERE ip = '".$db->escape($adh->ip)."'";
451 $sql .= " AND datec > '".$db->idate($minmonthpost)."'";
452 $resql = $db->query($sql);
453 if ($resql) {
454 $num = $db->num_rows($resql);
455 $i = 0;
456 while ($i < $num) {
457 $i++;
458 $obj = $db->fetch_object($resql);
459 $nb_post_ip = $obj->nb_adh;
460 }
461 }
462 }
463
464
465 // Fill array 'array_options' with data from add form
466 $extrafields->fetch_name_optionals_label($adh->table_element);
467 $ret = $extrafields->setOptionalsFromPost(null, $adh);
468 if ($ret < 0) {
469 $error++;
470 $errmsg .= $adh->error;
471 }
472
473 if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
474 $error++;
475 $errmsg .= $langs->trans("AlreadyTooMuchPostOnThisIPAdress");
476 array_push($adh->errors, $langs->trans("AlreadyTooMuchPostOnThisIPAdress"));
477 }
478
479 if (!$error) {
480 $result = $adh->create($user);
481 if ($result > 0) {
482 require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
483 $object = $adh;
484
485 $adht = new AdherentType($db);
486 $adht->fetch($object->typeid);
487
488 if ($object->email) {
489 $subject = '';
490 $msg = '';
491
492 // Send subscription email
493 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
494 $formmail = new FormMail($db);
495 // Set output language
496 $outputlangs = new Translate('', $conf);
497 $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
498 // Load traductions files required by page
499 $outputlangs->loadLangs(array("main", "members"));
500 // Get email content from template
501 $arraydefaultmessage = null;
502 $labeltouse = getDolGlobalString('ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER');
503
504 if (!empty($labeltouse)) {
505 $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
506 }
507
508 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
509 $subject = $arraydefaultmessage->topic;
510 $msg = $arraydefaultmessage->content;
511 }
512
513 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
514 complete_substitutions_array($substitutionarray, $outputlangs, $object);
515 $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
516 $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs);
517
518 if ($subjecttosend && $texttosend) {
519 $moreinheader = 'X-Dolibarr-Info: send_an_email by public/members/new.php'."\r\n";
520
521 $result = $object->sendEmail($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader);
522 }
523 /*if ($result < 0) {
524 $error++;
525 setEventMessages($object->error, $object->errors, 'errors');
526 }*/
527 }
528
529 // Send email to the foundation to say a new member subscribed with autosubscribe form
530 if (getDolGlobalString('MAIN_INFO_SOCIETE_MAIL') && getDolGlobalString('ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT') &&
531 getDolGlobalString('ADHERENT_AUTOREGISTER_NOTIF_MAIL')) {
532 // Define link to login card
533 $appli = constant('DOL_APPLICATION_TITLE');
534 if (getDolGlobalString('MAIN_APPLICATION_TITLE')) {
535 $appli = getDolGlobalString('MAIN_APPLICATION_TITLE');
536 if (preg_match('/\d\.\d/', $appli)) {
537 if (!preg_match('/'.preg_quote(DOL_VERSION, '/').'/', $appli)) {
538 $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core
539 }
540 } else {
541 $appli .= " ".DOL_VERSION;
542 }
543 } else {
544 $appli .= " ".DOL_VERSION;
545 }
546
547 $to = $adh->makeSubstitution(getDolGlobalString('MAIN_INFO_SOCIETE_MAIL'));
548 $from = getDolGlobalString('ADHERENT_MAIL_FROM', $conf->email_from);
549 $mailfile = new CMailFile(
550 '['.$appli.'] ' . getDolGlobalString('ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT'),
551 $to,
552 $from,
553 $adh->makeSubstitution(getDolGlobalString('ADHERENT_AUTOREGISTER_NOTIF_MAIL')),
554 array(),
555 array(),
556 array(),
557 "",
558 "",
559 0,
560 -1
561 );
562
563 if (!$mailfile->sendfile()) {
564 dol_syslog($langs->trans("ErrorFailedToSendMail", $from, $to), LOG_ERR);
565 }
566 }
567
568 // Auto-create thirdparty on member creation
569 if (getDolGlobalString('ADHERENT_DEFAULT_CREATE_THIRDPARTY')) {
570 $company = new Societe($db);
571 $result = $company->create_from_member($adh);
572 if ($result < 0) {
573 $error++;
574 $errmsg .= implode('<br>', $company->errors);
575 }
576 }
577
578 if (!empty($backtopage)) {
579 $urlback = $backtopage;
580 } elseif (getDolGlobalString('MEMBER_URL_REDIRECT_SUBSCRIPTION')) {
581 $urlback = getDolGlobalString('MEMBER_URL_REDIRECT_SUBSCRIPTION');
582 // TODO Make replacement of __AMOUNT__, etc...
583 } else {
584 $urlback = $_SERVER["PHP_SELF"]."?action=added&token=".newToken();
585 }
586
587 if (getDolGlobalString('MEMBER_NEWFORM_PAYONLINE') && getDolGlobalString('MEMBER_NEWFORM_PAYONLINE') != '-1') {
588 if (empty($adht->caneditamount)) { // If edition of amount not allowed
589 // TODO Check amount is same than the amount required for the type of member
590 // It is not so important because a test is done on return of payment validation.
591 }
592
593 $minimumamountbytype = $adht->minimumamountbytype(1); // Load the array of minimum amount per type
594 $minimumamount = empty($minimumamountbytype[$adh->typeid]) ? 0 : $minimumamountbytype[$adh->typeid];
595 $amount = price2num(GETPOST('amount', 'alpha'), 'MT');
596 $urlback = getOnlinePaymentUrl(0, 'member', $adh->ref, (float) $amount, '', 0);
597 if ($amount < max(getDolGlobalInt("MEMBER_MIN_AMOUNT"), $minimumamount)) {
598 $error++;
599 $errmsg .= $langs->trans("MinimumAmountShort")." : ".price(max(getDolGlobalInt("MEMBER_MIN_AMOUNT"), $minimumamount), 0, $langs, 1, -1, -1, $conf->currency)."<br>\n";
600 }
601
602 if (GETPOST('member_email')) {
603 $urlback .= '&email='.urlencode(GETPOST('member_email'));
604 }
605 if (getDolGlobalString('MEMBER_NEWFORM_PAYONLINE') != '-1' && getDolGlobalString('MEMBER_NEWFORM_PAYONLINE') != 'all') {
606 $urlback .= '&paymentmethod='.urlencode(getDolGlobalString('MEMBER_NEWFORM_PAYONLINE'));
607 }
608 } else {
609 if (!empty($entity)) {
610 $urlback .= '&entity='.((int) $entity);
611 }
612 }
613 } else {
614 $error++;
615 $errmsg .= implode('<br>', $adh->errors);
616 }
617 }
618 }
619
620 if (!$error) {
621 $db->commit();
622
623 header("Location: ".$urlback);
624 exit;
625 } else {
626 $db->rollback();
627 $action = "create";
628 }
629}
630
631// Action called after a submitted was send and member created successfully
632// 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.
633// backtopage parameter with an url was set on member submit page, we never go here because a redirect was done to this url.
634
635if (empty($reshook) && $action == 'added') { // Test on permission not required here
636 llxHeaderVierge($langs->trans("NewMemberForm"));
637
638 // If we have not been redirected
639 print '<br><br>';
640 print '<div class="center">';
641 print $langs->trans("NewMemberbyWeb");
642 print '</div>';
643
645 exit;
646}
647
648
649/*
650 * View
651 */
652
653$form = new Form($db);
654$formcompany = new FormCompany($db);
655$adht = new AdherentType($db);
656$extrafields->fetch_name_optionals_label($object->table_element); // fetch optionals attributes and labels
657
658
659llxHeaderVierge($langs->trans("NewSubscription"));
660
661print '<br>';
662print load_fiche_titre(img_picto('', 'member_nocolor', 'class="pictofixedwidth"').' &nbsp; '.$langs->trans("NewSubscription"), '', '', 0, '', 'center');
663
664
665print '<div align="center">';
666print '<div id="divsubscribe">';
667
668print '<div class="center subscriptionformhelptext opacitylow justify small margintoponly"><br>';
669if (getDolGlobalString('MEMBER_NEWFORM_TEXT')) {
670 print $langs->trans(getDolGlobalString('MEMBER_NEWFORM_TEXT'))."<br>\n";
671} else {
672 print $langs->trans("NewSubscriptionDesc", getDolGlobalString("MAIN_INFO_SOCIETE_MAIL"))."<br>\n";
673}
674print '</div>';
675print '<br>';
676
677dol_htmloutput_errors($errmsg);
679
680if ($action == "subscription") {
681 $urltocall = DOL_URL_ROOT.'/public/payment/newpayment.php?source=member&ref='.$object->id;
682 print $form->formconfirm($urltocall, $langs->trans("CorrespondingMemberFound"), $langs->trans("CorrespondingMemberFoundQuestion"), "confirm_subscription", '', 'no', 1);
683}
684
685// Print form
686print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" name="newmember" id="newmember">'."\n";
687print '<input type="hidden" name="token" value="'.newToken().'" />';
688print '<input type="hidden" name="entity" value="'.$entity.'" />';
689print '<input type="hidden" name="page_y" value="" />';
690
691if (getDolGlobalString('MEMBER_SKIP_TABLE') || getDolGlobalString('MEMBER_NEWFORM_FORCETYPE') || in_array($action, array('create', 'subscription'))) {
692 if ($action == 'subscription') {
693 print '<input type="hidden" name="nofetchmember" value="nofetchmember" />';
694 }
695 print '<input type="hidden" name="action" value="add" />';
696 print '<br>';
697
698 //$messagemandatory = '<span class="">'.$langs->trans("FieldsWithAreMandatory", '*').'</span>';
699 //print '<br>'.$messagemandatory.'<br>';
700 //print $langs->trans("FieldsWithIsForPublic",'**').'<br>';
701
702 print dol_get_fiche_head();
703
704 if ($conf->use_javascript_ajax) {
705 print "\n".'<script type="text/javascript">'."\n";
706 print 'jQuery(document).ready(function () {
707 jQuery("#selectcountry_id").change(function() {
708 console.log("We change country, so we reload page");
709 document.newmember.action.value="create";
710 jQuery("#newmember").submit();
711 });
712 function initfieldrequired() {
713 console.log("initfieldrequired");
714 jQuery("#tdcompany").removeClass("fieldrequired");
715 jQuery("#tdlastname").removeClass("fieldrequired");
716 jQuery("#tdfirstname").removeClass("fieldrequired");
717 if (jQuery(\'input[name="morphy"]:checked\').val() == \'mor\') {
718 jQuery("#tdcompany").addClass("fieldrequired");
719 }
720 if (jQuery(\'input[name="morphy"]:checked\').val() == \'phy\') {
721 jQuery("#tdlastname").addClass("fieldrequired");
722 jQuery("#tdfirstname").addClass("fieldrequired");
723 }
724 }
725 jQuery(\'input[name="morphy"]\').change(function() {
726 initfieldrequired();
727 });
728 initfieldrequired();
729 })';
730 print '</script>'."\n";
731 }
732
733 print '<table class="border" summary="form to subscribe" id="tablesubscribe">'."\n";
734
735 // Type
736 if (!getDolGlobalString('MEMBER_NEWFORM_FORCETYPE')) {
737 $typeid = GETPOSTINT("typeid");
738 print '<tr><td class="fieldrequired titlefieldmiddle">'.$langs->trans("MemberType").'</td><td>';
739 $listetype = $adht->liste_array(1);
740 print img_picto('', $adht->picto, 'class="pictofixedwidth"');
741 if (count($listetype)) {
742 print $form->selectarray("typeid", $listetype, (GETPOSTINT('typeid') ? GETPOSTINT('typeid') : $typeid), (count($listetype) > 1 ? 1 : 0), 0, 0, '', 0, 0, 0, '', 'minwidth150 maxwidth300 widthcentpercentminusx', 1);
743 } else {
744 print '<span class="error">'.$langs->trans("NoTypeDefinedGoToSetup").'</span>';
745 }
746 print '</td></tr>'."\n";
747 } else {
748 $adht->fetch(getDolGlobalInt('MEMBER_NEWFORM_FORCETYPE'));
749 print '<input type="hidden" id="typeid" name="typeid" value="' . getDolGlobalString('MEMBER_NEWFORM_FORCETYPE').'">';
750 }
751
752 // Moral/Physic attribute
753 $morphys = [
754 "phy" => $langs->trans("Physical"),
755 "mor" => $langs->trans("Moral"),
756 ];
757 $checkednature = GETPOST("morphy", 'alpha');
758 $listetype_natures = $adht->morphyByType(1); // Load the array of morphy per typeof membership
759 $listetype_natures_json = json_encode($listetype_natures);
760
761 if (!getDolGlobalString('MEMBER_NEWFORM_FORCEMORPHY')) {
762 if (empty($checkednature) && !empty($listetype_natures[GETPOSTINT('typeid')])) {
763 $checkednature = $listetype_natures[GETPOSTINT('typeid')];
764 }
765
766 print '<tr><td class="fieldrequired titlefieldmiddle">'.$langs->trans("MemberNature")."</td><td>\n";
767
768 $disabledphy = '';
769 $disabledmor = '';
770 //$disabledphy = ($checkednature == "mor" ? ' disabled="disabled"' : '');
771 //$disabledmor = ($checkednature == "phy" ? ' disabled="disabled"' : '');
772 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>';
773 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>';
774
775 // Add JS to manage the background of nature
776 if ($conf->use_javascript_ajax) {
777 print '<script>
778 var listetype_natures = '.$listetype_natures_json.';
779
780 jQuery(function($) {
781 function refreshNatureCss() {
782 $(".spannature").each(function(index) {
783 let $span = $("#spannature" + (index + 1));
784 let checked = $span.find(".checkforselect").is(":checked");
785
786 if (checked) {
787 if (index === 0) {
788 $span.addClass("member-individual-back").removeClass("nonature-back member-company-back");
789 } else if (index === 1) {
790 $span.addClass("member-company-back").removeClass("nonature-back member-individual-back");
791 }
792 } else {
793 $span.removeClass("member-individual-back member-company-back")
794 .addClass("nonature-back");
795 }
796 });
797 }
798
799 $(".spannature").on("click", function() {
800 console.log("Nature clicked");
801 refreshNatureCss();
802 });
803
804 $("#typeid").on("change", function() {
805 console.log("Type of membership is modified");
806 let morphy = listetype_natures[$(this).val()];
807 console.log("morphy="+morphy);
808
809 let $phyInput = $("#phisicalinput");
810 let $morInput = $("#moralinput");
811 let $tdLast = $("#tdlastname");
812 let $tdFirst = $("#tdfirstname");
813 let $tdCompany = $("#tdcompany");
814 let $span1 = $("#spannature1");
815 let $span2 = $("#spannature2");
816
817 switch (morphy) {
818 case "phy":
819 $phyInput.prop({disabled: false, checked: true});
820 $morInput.prop({disabled: true, checked: false});
821 $span1.addClass("member-individual-back").removeClass("nonature-back");
822 $span2.removeClass("member-company-back").addClass("nonature-back");
823 $("#phisicalinput").prop("checked", true);
824 $tdLast.addClass("fieldrequired");
825 $tdFirst.addClass("fieldrequired");
826 $tdCompany.removeClass("fieldrequired");
827 break;
828
829 case "mor":
830 $phyInput.prop({disabled: true, checked: false});
831 $morInput.prop({disabled: false, checked: true});
832 $span2.addClass("member-company-back").removeClass("nonature-back");
833 $span1.removeClass("member-individual-back").addClass("nonature-back");
834 $("#moralinput").prop("checked", true);
835 $tdCompany.addClass("fieldrequired");
836 $tdLast.removeClass("fieldrequired");
837 $tdFirst.removeClass("fieldrequired");
838 break;
839
840 default:
841 $phyInput.prop({disabled: false});
842 $morInput.prop({disabled: false});';
843 if ($action != "subscription" && !GETPOST('morphy')) {
844 print '
845 $phyInput.prop({checked: false});
846 $morInput.prop({checked: false});
847 $span1.removeClass("member-individual-back").addClass("nonature-back");
848 $span2.removeClass("member-company-back").addClass("nonature-back");';
849 }
850 print'}
851 });
852
853 // Initial state
854 refreshNatureCss();
855 });
856 </script>';
857 }
858 print '</td></tr>'."\n";
859 } else {
860 //print $morphys[$conf->global->MEMBER_NEWFORM_FORCEMORPHY];
861 print '<input type="hidden" id="morphy" name="morphy" value="' . getDolGlobalString('MEMBER_NEWFORM_FORCEMORPHY').'">';
862 }
863
864 // Company // TODO : optional hide
865 print '<tr id="trcompany" class="trcompany"><td id="tdcompany" class="titlefieldmiddle paddingrightonly'.($checkednature == "mor" ? ' fieldrequired"' : '').'">'.$langs->trans("Company").'</td><td>';
866 print img_picto('', 'company', 'class="pictofixedwidth paddingright"');
867 print '<input type="text" name="societe" class="minwidth150 widthcentpercentminusx" value="'.dol_escape_htmltag(GETPOST('societe')).'"></td></tr>'."\n";
868
869 // Title
870 if (getDolGlobalString('MEMBER_NEWFORM_ASK_TITLE')) {
871 print '<tr><td>'.$langs->trans('UserTitle').'</td><td>';
872 print $formcompany->select_civility(GETPOST('civility_id'), 'civility_id').'</td></tr>'."\n";
873 }
874
875 // Firstname
876 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";
877
878 // Lastname
879 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";
880
881 // EMail
882 print '<tr><td>'.(getDolGlobalString('ADHERENT_MAIL_REQUIRED') ? '<span class="fieldrequired">' : '').$langs->trans("EMail").(getDolGlobalString('ADHERENT_MAIL_REQUIRED') ? '</span>' : '').'</td>';
883 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";
884
885 // Login
886 if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
887 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";
888 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";
889 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";
890 }
891
892 // Gender
893 print '<tr><td>'.$langs->trans("Gender").'</td>';
894 print '<td>';
895 $arraygender = array('man' => $langs->trans("Genderman"), 'woman' => $langs->trans("Genderwoman"), 'other' => $langs->trans("Genderother"));
896 print $form->selectarray('gender', $arraygender, GETPOST('gender', 'alphanohtml'), 1, 0, 0, '', 0, 0, 0, '', 'minwidth150 maxwidth300 widthcentpercentminusx', 1);
897 print '</td></tr>';
898
899 // Address
900 print '<tr><td>'.$langs->trans("Address").'</td><td>'."\n";
901 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";
902
903 // Zip / Town
904 print '<tr><td>'.$langs->trans('Zip').' / '.$langs->trans('Town').'</td><td>';
905 print $formcompany->select_ziptown(GETPOST('zipcode'), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 1, '', 'width75');
906 print ' / ';
907 print $formcompany->select_ziptown(GETPOST('town'), 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 1);
908 print '</td></tr>';
909
910 $country_id = GETPOSTINT('country_id');
911
912 // Country
913 print '<tr><td class="fieldrequired">'.$langs->trans('Country').'</td><td>';
914 print img_picto('', 'country', 'class="pictofixedwidth paddingright"');
915 if (!$country_id && getDolGlobalString('MEMBER_NEWFORM_FORCECOUNTRYCODE')) {
916 $country_id = (int) getCountry(getDolGlobalString('MEMBER_NEWFORM_FORCECOUNTRYCODE'), '3', $db, $langs);
917 }
918 if (!$country_id && !empty($conf->geoipmaxmind->enabled)) {
919 $country_code = dol_user_country();
920 //print $country_code;
921 if ($country_code) {
922 $new_country_id = getCountry($country_code, '3', $db, $langs);
923 //print 'xxx'.$country_code.' - '.$new_country_id;
924 if ($new_country_id) {
925 $country_id = $new_country_id;
926 }
927 }
928 }
929 $country_code = getCountry($country_id, '2', $db, $langs);
930 print $form->select_country($country_id, 'country_id', '', 0, 'minwidth150 maxwidth300 widthcentpercentminusx reposition');
931 print '</td></tr>';
932
933 // State
934 if (!getDolGlobalString('SOCIETE_DISABLE_STATE')) {
935 print '<tr><td>'.$langs->trans('State').'</td><td>';
936 if ($country_code) {
937 print img_picto('', 'state', 'class="pictofixedwidth paddingright"');
938 print $formcompany->select_state(GETPOSTINT("state_id"), $country_code, 'state_id', 'minwidth150 maxwidth300 widthcentpercentminusx');
939 }
940 print '</td></tr>';
941 }
942
943 // Pro phone
944 print '<tr><td>'.$langs->trans("PhonePro").'</td>';
945 print '<td>'.img_picto('', 'object_phoning', 'class="pictofixedwidth"').'<input type="text" name="phone" class="maxwidth300 widthcentpercentminusx" value="'.dol_escape_htmltag(GETPOST('phone')).'"></td></tr>';
946
947 // Personal phone
948 print '<tr><td>'.$langs->trans("PhonePerso").'</td>';
949 print '<td>'.img_picto('', 'object_phoning', 'class="pictofixedwidth"').'<input type="text" name="phone_perso" class="maxwidth300 widthcentpercentminusx" value="'.dol_escape_htmltag(GETPOST('phone_perso')).'"></td></tr>';
950
951 // Mobile phone
952 print '<tr><td>'.$langs->trans("PhoneMobile").'</td>';
953 print '<td>'.img_picto('', 'object_phoning_mobile', 'class="pictofixedwidth"').'<input type="text" name="phone_mobile" class="maxwidth300 widthcentpercentminusx" value="'.dol_escape_htmltag(GETPOST('phone_mobile')).'"></td></tr>';
954
955 // Birthday
956 print '<tr id="trbirth" class="trbirth"><td>'.$langs->trans("DateOfBirth").'</td><td>';
957 print $form->selectDate(!empty($birthday) ? $birthday : "", 'birth', 0, 0, 1, "newmember", 1, 0);
958 print '</td></tr>'."\n";
959
960 // Photo
961 print '<tr><td>'.$langs->trans("URLPhoto").'</td><td><input type="text" name="photo" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('photo')).'"></td></tr>'."\n";
962
963 // Public
964 if (getDolGlobalString('MEMBER_PUBLIC_ENABLED')) {
965 $linkofpubliclist = DOL_MAIN_URL_ROOT.'/public/members/public_list.php'.((isModEnabled('multicompany')) ? '?entity='.$conf->entity : '');
966 $publiclabel = $langs->trans("Public", getDolGlobalString('MAIN_INFO_SOCIETE_NOM'), $linkofpubliclist);
967 print '<tr><td>'.$form->textwithpicto($langs->trans("MembershipPublic"), $publiclabel).'</td><td><input type="checkbox" name="public"></td></tr>'."\n";
968 }
969
970 // Other attributes
971 $parameters['tpl_context'] = 'public'; // define template context to public
972 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
973
974 // Comments
975 print '<tr>';
976 print '<td class="tdtop"></td>';
977 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>';
978 print '</tr>'."\n";
979
980
981 // Define amount by default to suggest
982 $typeid = getDolGlobalInt('MEMBER_NEWFORM_FORCETYPE', GETPOSTINT('typeid'));
983 $adht = new AdherentType($db);
984 $adht->fetch($typeid);
985 $caneditamount = $adht->caneditamount;
986 $amountbytype = $adht->amountByType(1); // Load the array of amount per type
987 $minimumamountbytype = $adht->minimumamountbytype(1); // Load the array of minimum amount per type
988 foreach ($amountbytype as $k => $v) {
989 $amount = max(0, (float) $v, (float) getDolGlobalInt("MEMBER_MIN_AMOUNT"), $minimumamountbytype[$k]);
990 $amountbytype[$k] = $amount;
991 }
992
993 $caneditamountbytype = $adht->caneditamountByType(1); // Load the array of caneditamount per type
994 $amountformuladescriptionbytype = $adht->amountformuladescriptionbytype(1); // Load the array of amount ormula description per type
995
996 // Set amount for the subscription from the type and options:
997 // - First check the amount of the member type.
998 $amount = empty($amountbytype[$typeid]) ? 0 : $amountbytype[$typeid];
999 // - If not set, we accept to have amount defined as parameter (for backward compatibility).
1000 if (empty($amount)) {
1001 $amount = (GETPOST('amount') ? price2num(GETPOST('amount', 'alpha'), 'MT', 2) : '');
1002 }
1003 // - If a min is set, we take it into account
1004 $minimumamount = empty($minimumamountbytype[$typeid]) ? 0 : $minimumamountbytype[$typeid];
1005 $amount = max(0, (float) $amount, (float) getDolGlobalInt("MEMBER_MIN_AMOUNT"), (float) $minimumamount);
1006
1007 // Clean the amount
1008 $amount = price2num($amount);
1009
1010
1011 // Add hook to complete the form
1012 $parameters = array('country_id' => $country_id, 'mode' => 'new');
1013 $reshook = $hookmanager->executeHooks('membershipNewSubscriptionPublicForm', $parameters, $object, $action);
1014 if ($reshook < 0) {
1015 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1016 $error++;
1017 }
1018 // TODO Move this into previous hook
1019 if (getDolGlobalString('MEMBER_NEWFORM_DOLIBARRTURNOVER')) {
1020 $s = $langs->trans("AreYouAPreferredPartner", '<a href="https://partners.dolibarr.org" target="_blank">{s1}</a>');
1021 $s = str_replace('{s1}', 'Preferred Partner', $s);
1022 print '<tr id="trbudget" class="trcompany"><td class="paddingrightonly"><label for="pp" class="small">'.$s.'</label></td><td>';
1023 print '<input type="checkbox" name="pp" id="pp" value="1"'.(GETPOST('pp') ? ' checked="checked"' : '').' class="reposition">';
1024 print '</td></tr>';
1025
1026 print '<tr id="trbudget" class="trcompany"><td class="fieldrequired paddingrightonly"><span class="small">'.$langs->trans("TurnoverOrBudget").'</span></td><td>';
1027
1028 $country_code = dol_getIdFromCode($db, $country_id, 'c_country', 'rowid', 'code');
1029 if ($country_code === 'FR' && $checkednature === 'mor' && GETPOST('pp')) {
1030 print '<input type="text" name="budget" id="budget" class="flat turnover right width100" value="'.GETPOST('budget').'" required>';
1031 } else {
1032 $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+');
1033 print $form->selectarray('budget', $arraybudget, GETPOSTINT('budget'), 1, 0, 0, '', 0, 0, 0, '');
1034 }
1035 print ' € or $';
1036
1037 print '<script type="text/javascript">
1038 jQuery(document).ready(function() {
1039 firstload = true;
1040
1041 newamount = initturnover();
1042 jQuery("#amount").val(newamount);
1043
1044 firstload = false;
1045
1046 jQuery("#selectcountry_id").change(function() {
1047 console.log("We change country (code added for association, replace common code), so we reload page");
1048 jQuery("#budget").val(\'\');
1049 jQuery("#amount").val(\'\');
1050 jQuery("#amounthidden").val(\'\');
1051 });
1052 jQuery("#phisicalinput,#moralinput").click(function() {
1053 console.log("We change the nature of membership");
1054 newamount = initturnover();
1055 jQuery("#amount").val(newamount);
1056 });
1057 jQuery("#pp").change(function() {
1058 console.log("We change the preferred partner status");
1059 selectcountry_id = jQuery("#selectcountry_id").val();
1060 morphy = jQuery("#moralinput").is(\':checked\') ? \'mor\' : \'phy\';
1061 jQuery("#budget").val(\'\');
1062 jQuery("#amount").val(\'\');
1063 jQuery("#amounthidden").val(\'\');
1064 document.newmember.action.value="create";
1065 jQuery("#newmember").submit();
1066 });
1067 jQuery("#budget").change(function() {
1068 console.log("Turnover amount has been modified on change");
1069 newamount = initturnover();
1070 jQuery("#amount").val(newamount);
1071 jQuery("#amounthidden").val(newamount);
1072 });
1073 jQuery("#budget").keyup(function() {
1074 console.log("Turnover amount has been modified on keyup");
1075 newamount = initturnover();
1076 jQuery("#amount").val(newamount);
1077 jQuery("#amounthidden").val(newamount);
1078 });
1079
1080 function initturnover() {
1081 newamount = 0;
1082
1083 morphy = jQuery("#moralinput").is(\':checked\') ? \'mor\' : \'phy\';
1084 selectcountry_id = jQuery("#selectcountry_id").val();
1085 pp = jQuery("#pp").is(\':checked\') ? true : false;
1086 console.log("Set fields according to nature and other properties");
1087 console.log("morphy="+morphy);
1088 console.log("selectcountry_id="+selectcountry_id);
1089 console.log("pp="+pp);
1090
1091 if (morphy == \'phy\') {
1092 jQuery(".amount").val('.((float) $amount).');
1093 jQuery("#trbirth").show();
1094 jQuery(".trcompany").hide();
1095 jQuery(".trbudget").hide();
1096 newamount = '.((float) $amount).';
1097 } else {
1098 jQuery(".amount").val(\'\');
1099 jQuery("#trbirth").hide();
1100 jQuery(".trcompany").show();
1101 jQuery(".trbudget").show();
1102 jQuery(".hideifautoturnover").hide();
1103 if (firstload) {
1104 jQuery("#budget").val(\'\');
1105 }
1106
1107 if (selectcountry_id == 1) {
1108 if (pp) {
1109 console.log("value selected in input text field is "+jQuery("#budget").val());
1110 newamount = Math.max(Math.round(price2numjs(jQuery("#budget").val()) * 0.005), 50);
1111 console.log("newamount = "+newamount);
1112 } else {
1113 console.log("not a pp");
1114 if (jQuery("#budget").val() > 0) {
1115 console.log("value found in budget is "+jQuery("#budget").val());
1116 newamount = jQuery("#budget").val();
1117 } else {
1118 jQuery("#budget").val(\'\');
1119 newamount = \'\';
1120 }
1121 }
1122 } else {
1123 if (jQuery("#budget").val() > 0) {
1124 newamount = jQuery("#budget").val();
1125 } else {
1126 jQuery("#budget").val(\'\');
1127 newamount = \'\';
1128 }
1129 console.log("newamount="+newamount);
1130 }
1131 }
1132
1133 return newamount;
1134 }
1135 });
1136 </script>';
1137 print '</td></tr>'."\n";
1138 }
1139
1140 if (getDolGlobalString('MEMBER_NEWFORM_PAYONLINE')) { // Can be 'all', 'paypal', 'paybox', 'stripe'...
1141 print '<tr><td>'.$langs->trans("Subscription");
1142 if (getDolGlobalString('MEMBER_EXT_URL_SUBSCRIPTION_INFO')) {
1143 print '<br>';
1144 print '<a href="' . getDolGlobalString('MEMBER_EXT_URL_SUBSCRIPTION_INFO').'" rel="external" target="_blank" rel="noopener noreferrer">';
1145 print img_picto('', 'url', 'class="pictofixedwidth"').$langs->trans("SeeHere");
1146 print '</a>';
1147 }
1148 print '</td><td class="nowrap">';
1149
1150 $amountformuladescription = $amountformuladescriptionbytype[$typeid];
1151
1152 $showedamount = $amount > 0 ? $amount : 0;
1153 if ($caneditamount === "1") {
1154 print '<input type="text" name="amount" id="amount" class="flat amount right width75" value="'.$showedamount.'">';
1155 print '<input type="text" name="amount" id="amounthidden" class="flat amount width75 hidden" disabled value="'.$showedamount.'">';
1156 print ' '.$langs->getCurrencySymbol($conf->currency).'<span class="opacitymedium amountdescription hideifautoturnover small">';
1157 if (!getDolGlobalString('MEMBER_NEWFORM_DOLIBARRTURNOVER')) {
1158 print ' - ';
1159 if (empty($amountformuladescription)) {
1160 print $amount > 0 ? $langs->trans("AnyAmountWithAdvisedAmount", price($amount, 0, $langs, 1, -1, -1, $conf->currency)) : $langs->trans("AnyAmountWithoutAdvisedAmount");
1161 } else {
1162 print $amountformuladescription;
1163 }
1164 }
1165 if (getDolGlobalInt("MEMBER_MIN_AMOUNT") > 0 || $minimumamount > 0) {
1166 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);
1167 }
1168 print '</span>';
1169 } else {
1170 print '<input type="text" name="amount" id="amount" class="flat amount width75 right hidden" value="'.$showedamount.'">';
1171 print '<input type="text" name="amount" id="amounthidden" class="flat amount width75" disabled value="'.$showedamount.'">';
1172 print ' '.$langs->getCurrencySymbol($conf->currency).'<span class="opacitymedium amountdescription hideifautoturnover hidden small">';
1173 if (!getDolGlobalString('MEMBER_NEWFORM_DOLIBARRTURNOVER')) {
1174 print ' - ';
1175 print $amount > 0 ? $langs->trans("AnyAmountWithAdvisedAmount", price($amount, 0, $langs, 1, -1, -1, $conf->currency)) : $langs->trans("AnyAmountWithoutAdvisedAmount");
1176 }
1177 print '</span>';
1178 }
1179 print '</td></tr>';
1180 }
1181
1182 // Display Captcha code if is enabled
1183 if (getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA_MEMBER') && is_object($captchaobj)) {
1184 print '<tr><td><label><span class="fieldrequired">'.$langs->trans("SecurityCode").'</span></label></td><td><br>';
1185 if (method_exists($captchaobj, 'getCaptchaCodeForForm')) {
1186 print $captchaobj->getCaptchaCodeForForm(''); // @phan-suppress-current-line PhanUndeclaredMethod
1187 } else {
1188 print 'Error, the captcha handler '.get_class($captchaobj).' does not have any method getCaptchaCodeForForm()';
1189 }
1190 print '<br></td></tr>';
1191 }
1192
1193 print "</table>\n";
1194
1195 print dol_get_fiche_end();
1196
1197 // Save / Submit
1198 print '<div class="center">';
1199 print '<input type="submit" value="'.$langs->trans("GetMembershipButtonLabel").'" id="submitsave" class="button">';
1200 if (!empty($backtopage)) {
1201 print ' &nbsp; &nbsp; <input type="submit" value="'.$langs->trans("Cancel").'" id="submitcancel" class="button button-cancel">';
1202 }
1203 print '</div>';
1204
1205 // Add JS to manage the background of amount depending on type
1206 $typeid = getDolGlobalInt('MEMBER_NEWFORM_FORCETYPE', GETPOSTINT('typeid'));
1207 $adht = new AdherentType($db);
1208 $adht->fetch($typeid);
1209 $caneditamountbytype = $adht->caneditamountByType(1); // Load the array of caneditamount per type
1210 $minimumamountbytype = $adht->minimumamountbytype(1); // Load the array of minimum amount per type
1211 $amountbytype = $adht->amountByType(1); // Load the array of amount per type
1212 $amountformuladescriptionbytype = $adht->amountformuladescriptionbytype(1); // Load the array of amount ormula description per type
1213 // Common PHP → JS variables
1214 $caneditamountbytype_json = json_encode($caneditamountbytype);
1215 $minimumamountbytype_json = json_encode($minimumamountbytype);
1216 $amountbytype_json = json_encode($amountbytype);
1217 $amountformuladescriptionbytype_json = json_encode($amountformuladescriptionbytype);
1218 $currencysymbol = $langs->getCurrencySymbol($conf->currency);
1219
1220 if ($conf->use_javascript_ajax) {
1221 print '<script>
1222 // ----- Shared data -----
1223 var amountByType = ' . $amountbytype_json . ';
1224 var canEditAmountByType = ' . $caneditamountbytype_json . ';
1225 var amountFormulaDescriptionByType = ' . $amountformuladescriptionbytype_json . ';
1226 var minimumAmountByType = ' . $minimumamountbytype_json . ';
1227 var memberMinAmount = ' . getDolGlobalInt("MEMBER_MIN_AMOUNT") . ';
1228 var currencySymbol = ' . json_encode($currencysymbol) . ';
1229
1230 // Translations prepared by PHP
1231 var langs = {
1232 AnyAmountWithAdvisedAmount: ' . json_encode($langs->trans("AnyAmountWithAdvisedAmount", "__VAL__")) . ',
1233 AnyAmountWithoutAdvisedAmount: ' . json_encode($langs->trans("AnyAmountWithoutAdvisedAmount")) . ',
1234 MinimumAmountShort: ' . json_encode($langs->trans("MinimumAmountShort", "__VAL__")) . ',
1235 trans: function(key, val) {
1236 if (!this[key]) return key;
1237 return this[key].replace("__VAL__", val || "");
1238 }
1239 };
1240
1241 jQuery(function($) {
1242 // ----- Helpers -----
1243 function getCurrentMin() {
1244 let typeId = $("#typeid").val() || 0;
1245 let minimumAmount = minimumAmountByType[typeId] || 0;
1246 return Math.max(memberMinAmount, minimumAmount);
1247 }
1248
1249 function checkAmount() {
1250 let raw = $("#amount").val() || "";
1251 let val = parseFloat(raw.replace(",", ".")) || 0;
1252 let minimum = getCurrentMin();
1253 if (val < minimum) {
1254 $("#submitsave").prop("disabled", true);
1255 } else {
1256 $("#submitsave").prop("disabled", false);
1257 }
1258 }
1259
1260 function updateAmountAndTexts() {
1261 let typeId = $("#typeid").val();
1262 let amountVal = amountByType[typeId] || 0;
1263 let formattedAmount = parseFloat(amountVal);
1264 let canEdit = canEditAmountByType[typeId] === "1";
1265 let amountFormulaDescription = amountFormulaDescriptionByType[typeId] || "";
1266 let minimumAmount = minimumAmountByType[typeId] || 0;
1267 let minimum = Math.max(memberMinAmount, minimumAmount);
1268
1269 if (canEdit) {
1270 // Editable mode
1271 $("#amount").val(formattedAmount).prop("disabled", false).removeClass("hidden");
1272 $("#amounthidden").addClass("hidden");
1273 $(".hideifautoturnover").removeClass("hidden");
1274
1275 // Description formula or default text
1276 if (amountFormulaDescription.trim() !== "") {
1277 $(".amountdescription").html(" - " + amountFormulaDescription);
1278 } else {
1279 if (amountVal > 0) {
1280 $(".amountdescription").html(" - " + langs.trans("AnyAmountWithAdvisedAmount", formattedAmount + " " + currencySymbol));
1281 } else {
1282 $(".amountdescription").html(" - " + langs.trans("AnyAmountWithoutAdvisedAmount"));
1283 }
1284 }
1285
1286 // Minimum amount label
1287 if (minimum > 0) {
1288 $("#minimumamount")
1289 .html(langs.trans("MinimumAmountShort") + " : " + minimum + " " + currencySymbol)
1290 .removeClass("hidden");
1291 } else {
1292 $("#minimumamount").addClass("hidden");
1293 }
1294 } else {
1295 // Read-only mode
1296 $("#amounthidden").val(formattedAmount).prop("disabled", true).removeClass("hidden");
1297 $("#amount").addClass("hidden");
1298 $(".hideifautoturnover").addClass("hidden");
1299 $("#minimumamount").addClass("hidden");
1300 }
1301
1302 // After updating fields, re‑check the amount validity
1303 checkAmount();
1304 }
1305
1306 // ----- Bind events -----
1307 $("#typeid").on("change", function() {
1308 console.log("Type of membership changed, update amount, description and minimum");
1309 updateAmountAndTexts();
1310 });
1311
1312 $("#amount").on("keyup change", function() {
1313 checkAmount();
1314 });
1315 });
1316 </script>';
1317 }
1318
1319 print "</form>\n";
1320 print "<br>";
1321 print '</div></div>';
1322} else { // Show the table of membership types
1323 // Get units
1324 $measuringUnits = new CUnits($db);
1325 $result = $measuringUnits->fetchAll('', '', 0, 0, array('t.active' => 1));
1326 $units = array();
1327 foreach ($measuringUnits->records as $lines) {
1328 $units[$lines->short_label] = $langs->trans(ucfirst((string) $lines->label));
1329 }
1330
1331 $publiccounters = getDolGlobalString("MEMBER_COUNTERS_ARE_PUBLIC");
1332 $hidevoteallowed = getDolGlobalString("MEMBER_HIDE_VOTE_ALLOWED");
1333
1334 $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,";
1335 $sql .= " COUNT(a.rowid) AS membercount";
1336 $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
1337 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as a";
1338 $sql .= " ON d.rowid = a.fk_adherent_type AND a.statut > 0";
1339 $sql .= " WHERE d.entity IN (".getEntity('member_type').")";
1340 $sql .= " AND d.statut=1";
1341 $sql .= " GROUP BY d.rowid, d.libelle, d.subscription, d.amount, d.caneditamount, d.vote, d.note, d.duration, d.statut, d.morphy";
1342
1343 $result = $db->query($sql);
1344 if ($result) {
1345 $num = $db->num_rows($result);
1346
1347 print '<br><div class="div-table-responsive">';
1348 print '<table class="tagtable liste noborder">'."\n";
1349 print '<input type="hidden" name="action" value="create">';
1350
1351 print '<tr class="liste_titre">';
1352 print '<th>'.$langs->trans("Label").'</th>';
1353 print '<th class="center">'.$langs->trans("MembershipDuration").'</th>';
1354 print '<th class="center">'.$langs->trans("RecommendedAmount").'</th>';
1355 print '<th class="center">'.$langs->trans("MembersNature").'</th>';
1356 if (empty($hidevoteallowed)) {
1357 print '<th class="center">'.$langs->trans("VoteAllowed").'</th>';
1358 }
1359 if ($publiccounters) {
1360 print '<th class="center">'.$langs->trans("Members").'</th>';
1361 }
1362 print '<th class="center"></th>';
1363 print "</tr>\n";
1364
1365 $i = 0;
1366 while ($i < $num) {
1367 $objp = $db->fetch_object($result); // Load the member type and information on it
1368
1369 $caneditamount = $objp->caneditamount;
1370 $amountbytype = $adht->amountByType(1); // Load the array of amount per type
1371 $minimumamountbytype = $adht->minimumamountbytype(1); // Load the array of amount per type
1372
1373 print '<tr class="oddeven">';
1374
1375 // Label
1376 print '<td>';
1377 print '<div class="twolinesmax-normallineheight minwidth200onall">';
1378 print dolPrintHTML($objp->label);
1379 print '</div>';
1380 print '</td>';
1381
1382 // Duration
1383 print '<td class="center">';
1384 $unit = preg_replace("/[^a-zA-Z]+/", "", $objp->duration);
1385 print '<span class="badge badge-primary">';
1386 print max(1, intval($objp->duration)).' '.$units[$unit];
1387 print '</span>';
1388 print '</td>';
1389
1390 // Amount
1391 print '<td class="center"><span class="amount nowrap">';
1392
1393 // Set amount for the subscription from the the type and options:
1394 // - First check the amount of the member type.
1395 $amount = empty($amountbytype[$objp->rowid]) ? 0 : $amountbytype[$objp->rowid];
1396 $minimumamount = empty($minimumamountbytype[$objp->rowid]) ? 0 : $minimumamountbytype[$objp->rowid];
1397 // - If not set, we accept to have amount defined as parameter (for backward compatibility).
1398 if (empty($amount)) {
1399 $amount = (GETPOST('amount') ? price2num(GETPOST('amount', 'alpha'), 'MT', 2) : '');
1400 }
1401 // - If a min is set, we take it into account
1402 $amount = max(0, (float) $amount, (float) getDolGlobalInt("MEMBER_MIN_AMOUNT"), (float) $minimumamount);
1403
1404 $displayedamount = $amount;
1405
1406 if ($objp->subscription) {
1407 if ($displayedamount > 0 || !$caneditamount) {
1408 print price($displayedamount, 1, $langs, 1, 0, -1, $conf->currency);
1409 }
1410 if ($caneditamount && $displayedamount > 0) {
1411 print $form->textwithpicto('', $langs->transnoentities("CanEditAmountShortForValues"), 1, 'help', '', 0, 3);
1412 } elseif ($caneditamount) {
1413 print $langs->transnoentities("CanEditAmountShort");
1414 }
1415 } else {
1416 print "–"; // No subscription required
1417 }
1418 print '</span></td>';
1419
1420 print '<td class="center minwidth100">';
1421 if ($objp->morphy == 'phy') {
1422 print $langs->trans("Physical");
1423 } elseif ($objp->morphy == 'mor') {
1424 print $langs->trans("Moral");
1425 } else {
1426 print $langs->trans("MorAndPhy");
1427 }
1428 print '</td>';
1429
1430 if (empty($hidevoteallowed)) {
1431 print '<td class="center">'.yn($objp->vote).'</td>';
1432 }
1433 $membercount = $objp->membercount > 0 ? $objp->membercount : "–";
1434 if ($publiccounters) {
1435 print '<td class="center">'.$membercount.'</td>';
1436 }
1437 print '<td class="center"><button class="button button-save reposition" name="typeid" type="submit" name="submit" value="'.$objp->rowid.'">'.$langs->trans("GetMembershipButtonLabel").'</button></td>';
1438 print "</tr>";
1439 $i++;
1440 }
1441
1442 // If no record found
1443 if ($num == 0) {
1444 $colspan = 8;
1445 print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
1446 }
1447
1448 print "</table>";
1449 print '</div>';
1450
1451 print '</form>';
1452 } else {
1454 }
1455}
1456
1457//htmlPrintOnlineFooter($mysoc, $langs);
1459
1460$db->close();
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
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)
Add a delay to a date.
Definition date.lib.php:126
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolPrintHTML($s, $allowiframe=0, $moreallowedtags=array())
Return a string (that can be on several lines) ready to be output on a HTML page.
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.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_user_country()
Return country code for current user.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
printCommonFooter($zone='private')
Print common footer : conf->global->MAIN_HTML_FOOTER js for switch of menu hider js for conf->global-...
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'.
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...
dol_htmloutput_events($disabledoutputofmessages=0)
Print formatted messages to output (Used to show messages on html output).
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...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getUserRemoteIP($trusted=0)
Return the real IP of remote user.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
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_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0)
Print formatted error messages to output (Used to show messages on html output).
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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...
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.