dolibarr 22.0.5
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-2024 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-2025 MDW <mdeweerd@users.noreply.github.com>
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <https://www.gnu.org/licenses/>.
25 */
26
43if (!defined('NOLOGIN')) {
44 define("NOLOGIN", 1); // This means this output page does not require to be logged.
45}
46if (!defined('NOCSRFCHECK')) {
47 define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
48}
49if (!defined('NOBROWSERNOTIF')) {
50 define('NOBROWSERNOTIF', '1');
51}
52
53
54// For MultiCompany module.
55// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php
56// Because 2 entities can have the same ref.
57$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
58// if (is_numeric($entity)) { // $entity is casted to int
59define("DOLENTITY", $entity);
60// }
61
62
63// Load Dolibarr environment
64require '../../main.inc.php';
65require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
66require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
67require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
68require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
69require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
70require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
71require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php';
72require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
73
74// Init vars
75$backtopage = GETPOST('backtopage', 'alpha');
76$action = GETPOST('action', 'aZ09');
77
78$errmsg = '';
79$num = 0;
80$error = 0;
81
91// Load translation files
92$langs->loadLangs(array("main", "members", "companies", "install", "other", "errors"));
93
94if (isModEnabled('multicompany')) {
95 force_switch_entity($entity);
96}
97
98// Security check
99if (!isModEnabled('member')) {
100 httponly_accessforbidden('Module Membership not enabled');
101}
102
103if (!getDolGlobalString('MEMBER_ENABLE_PUBLIC')) {
104 httponly_accessforbidden("Auto subscription form for public visitors has not been enabled");
105}
106
107// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
108$hookmanager->initHooks(array('publicnewmembercard', 'globalcard'));
109
110$extrafields = new ExtraFields($db);
111
112$object = new Adherent($db);
113
114$user->loadDefaultValues();
115
123function force_switch_entity($newEntity)
124{
125 global $db, $conf;
126
127 if ($newEntity != $conf->entity) {
128 $conf->entity = $newEntity;
129 $conf->setValues($db);
130 }
131}
132
146function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $arrayofjs = [], $arrayofcss = []) // @phan-suppress-current-line PhanRedefineFunction
147{
148 global $conf, $langs, $mysoc;
149
150 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers
151
152 print '<body id="mainbody" class="publicnewmemberform">';
153
154 include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
155 htmlPrintOnlineHeader($mysoc, $langs, 1, getDolGlobalString('MEMBER_PUBLIC_INTERFACE'), 'MEMBER_IMAGE_PUBLIC_REGISTRATION');
156
157 print '<div class="divmainbodylarge">';
158}
159
167function llxFooterVierge() // @phan-suppress-current-line PhanRedefineFunction
168{
169 global $conf, $langs;
170
171 print '</div>';
172
173 printCommonFooter('public');
174
175 if (!empty($conf->use_javascript_ajax)) {
176 print "\n".'<!-- Includes JS Footer of Dolibarr -->'."\n";
177 print '<script src="'.DOL_URL_ROOT.'/core/js/lib_foot.js.php?lang='.$langs->defaultlang.'"></script>'."\n";
178 }
179
180 print "</body>\n";
181 print "</html>\n";
182}
183
184
185
186/*
187 * Actions
188 */
189
190$parameters = array();
191// Note that $action and $object may have been modified by some hooks
192$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);
193if ($reshook < 0) {
194 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
195}
196
197// Action called when page is submitted
198if (empty($reshook) && $action == 'add') { // Test on permission not required here. This is an anonymous form. Check is done on constant to enable and mitigation.
199 $error = 0;
200 $urlback = '';
201
202 $db->begin();
203
204 // test if login already exists
205 if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
206 if (!GETPOST('login')) {
207 $error++;
208 $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login"))."<br>\n";
209 }
210 $sql = "SELECT login FROM ".MAIN_DB_PREFIX."adherent WHERE login = '".$db->escape(GETPOST('login'))."'";
211 $result = $db->query($sql);
212 if ($result) {
213 $num = $db->num_rows($result);
214 }
215 if ($num != 0) {
216 $error++;
217 $langs->load("errors");
218 $errmsg .= $langs->trans("ErrorLoginAlreadyExists")."<br>\n";
219 }
220 if (!GETPOSTISSET("pass1") || !GETPOSTISSET("pass2") || GETPOST("pass1", 'none') == '' || GETPOST("pass2", 'none') == '' || GETPOST("pass1", 'none') != GETPOST("pass2", 'none')) {
221 $error++;
222 $langs->load("errors");
223 $errmsg .= $langs->trans("ErrorPasswordsMustMatch")."<br>\n";
224 }
225 if (!GETPOST('email')) {
226 $error++;
227 $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("EMail"))."<br>\n";
228 }
229 }
230 if (GETPOST('typeid') <= 0) {
231 $error++;
232 $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type"))."<br>\n";
233 } elseif (!getDolGlobalString('MEMBER_NEWFORM_FORCETYPE')) {
234 // The type must be one of the active types proposed by the form
235 // (when a type is forced by setup, the type posted is ignored and replaced by the forced one)
236 $tmpadht = new AdherentType($db);
237 if (!array_key_exists(GETPOSTINT('typeid'), $tmpadht->liste_array(1))) {
238 $error++;
239 $errmsg .= $langs->trans("ErrorBadValueForParameter", GETPOSTINT('typeid'), $langs->transnoentitiesnoconv("Type"))."<br>\n";
240 }
241 }
242 if (!in_array(GETPOST('morphy'), array('mor', 'phy'))) {
243 $error++;
244 $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv('Nature'))."<br>\n";
245 }
246 if (!GETPOST('lastname')) {
247 $error++;
248 $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Lastname"))."<br>\n";
249 }
250 if (!GETPOST('firstname')) {
251 $error++;
252 $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Firstname"))."<br>\n";
253 }
254 if (getDolGlobalString('ADHERENT_MAIL_REQUIRED') && empty(GETPOST('email'))) {
255 $error++;
256 $errmsg .= $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Email'))."<br>\n";
257 } elseif (GETPOST("email", "aZ09arobase") && !isValidEmail(GETPOST("email", "aZ09arobase"))) {
258 $langs->load('errors');
259 $error++;
260 $errmsg .= $langs->trans("ErrorBadEMail", GETPOST("email", "aZ09arobase"))."<br>\n";
261 }
262 $birthday = dol_mktime(GETPOSTINT("birthhour"), GETPOSTINT("birthmin"), GETPOSTINT("birthsec"), GETPOSTINT("birthmonth"), GETPOSTINT("birthday"), GETPOSTINT("birthyear"));
263 if (GETPOST("birthmonth") && empty($birthday)) {
264 $error++;
265 $langs->load("errors");
266 $errmsg .= $langs->trans("ErrorBadDateFormat")."<br>\n";
267 }
268 if (getDolGlobalString('MEMBER_NEWFORM_DOLIBARRTURNOVER')) {
269 if (GETPOST("morphy") == 'mor' && GETPOST('budget') <= 0) {
270 $error++;
271 $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("TurnoverOrBudget"))."<br>\n";
272 }
273 }
274
275 // Check Captcha code if is enabled
276 if (getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA_MEMBER')) {
277 $sessionkey = 'dol_antispam_value';
278 $ok = (array_key_exists($sessionkey, $_SESSION) && (strtolower($_SESSION[$sessionkey]) == strtolower(GETPOST('code'))));
279 if (!$ok) {
280 $error++;
281 $errmsg .= $langs->trans("ErrorBadValueForCode")."<br>\n";
282 $action = '';
283 }
284 }
285
286 $public = GETPOSTISSET('public') ? 1 : 0;
287
288 if (!$error) {
289 // E-mail looks OK and login does not exist
290 $adh = new Adherent($db);
291 $adh->statut = -1;
292 $adh->status = -1;
293 $adh->public = $public;
294 $adh->firstname = GETPOST('firstname');
295 $adh->lastname = GETPOST('lastname');
296 $adh->gender = GETPOST('gender');
297 $adh->civility_id = GETPOST('civility_id');
298 $adh->company = GETPOST('societe');
299 $adh->societe = $adh->company;
300 $adh->address = GETPOST('address');
301 $adh->zip = GETPOST('zipcode');
302 $adh->town = GETPOST('town');
303 $adh->email = GETPOST('email', 'aZ09arobase');
304 if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
305 $adh->login = GETPOST('login');
306 $adh->pass = GETPOST('pass1', 'password');
307 }
308 $adh->photo = GETPOST('photo');
309 $adh->country_id = getDolGlobalInt("MEMBER_NEWFORM_FORCECOUNTRYCODE", GETPOSTINT('country_id'));
310 $adh->state_id = GETPOSTINT('state_id');
311 $adh->typeid = getDolGlobalInt("MEMBER_NEWFORM_FORCETYPE", GETPOSTINT('typeid'));
312 $adh->note_private = GETPOST('note_private');
313 $adh->morphy = getDolGlobalString("MEMBER_NEWFORM_FORCEMORPHY", GETPOST('morphy'));
314 $adh->birth = $birthday;
315
316 $adh->ip = getUserRemoteIP();
317
318 $nb_post_max = getDolGlobalInt("MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
319 $now = dol_now();
320 $minmonthpost = dol_time_plus_duree($now, -1, "m");
321 // Calculate nb of post for IP
322 $nb_post_ip = 0;
323 if ($nb_post_max > 0) { // Calculate only if there is a limit to check
324 $sql = "SELECT COUNT(ref) as nb_adh";
325 $sql .= " FROM ".MAIN_DB_PREFIX."adherent";
326 $sql .= " WHERE ip = '".$db->escape($adh->ip)."'";
327 $sql .= " AND datec > '".$db->idate($minmonthpost)."'";
328 $resql = $db->query($sql);
329 if ($resql) {
330 $num = $db->num_rows($resql);
331 $i = 0;
332 while ($i < $num) {
333 $i++;
334 $obj = $db->fetch_object($resql);
335 $nb_post_ip = $obj->nb_adh;
336 }
337 }
338 }
339
340
341 // Fill array 'array_options' with data from add form
342 $extrafields->fetch_name_optionals_label($adh->table_element);
343 $ret = $extrafields->setOptionalsFromPost(null, $adh);
344 if ($ret < 0) {
345 $error++;
346 $errmsg .= $adh->error;
347 }
348
349 if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
350 $error++;
351 $errmsg .= $langs->trans("AlreadyTooMuchPostOnThisIPAdress");
352 array_push($adh->errors, $langs->trans("AlreadyTooMuchPostOnThisIPAdress"));
353 }
354
355 if (!$error) {
356 $result = $adh->create($user);
357 if ($result > 0) {
358 require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
359 $object = $adh;
360
361 $adht = new AdherentType($db);
362 $adht->fetch($object->typeid);
363
364 if ($object->email) {
365 $subject = '';
366 $msg = '';
367
368 // Send subscription email
369 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
370 $formmail = new FormMail($db);
371 // Set output language
372 $outputlangs = new Translate('', $conf);
373 $outputlangs->setDefaultLang(!empty($object->default_lang) ? $object->default_lang : (empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang));
374 // Load traductions files required by page
375 $outputlangs->loadLangs(array("main", "members"));
376 // Get email content from template
377 $arraydefaultmessage = null;
378 $labeltouse = getDolGlobalString('ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER');
379
380 if (!empty($labeltouse)) {
381 $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
382 }
383
384 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
385 $subject = $arraydefaultmessage->topic;
386 $msg = $arraydefaultmessage->content;
387 }
388
389 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
390 complete_substitutions_array($substitutionarray, $outputlangs, $object);
391 $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
392 $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs);
393
394 if ($subjecttosend && $texttosend) {
395 $moreinheader = 'X-Dolibarr-Info: send_an_email by public/members/new.php'."\r\n";
396
397 $result = $object->sendEmail($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader);
398 }
399 /*if ($result < 0) {
400 $error++;
401 setEventMessages($object->error, $object->errors, 'errors');
402 }*/
403 }
404
405 // Send email to the foundation to say a new member subscribed with autosubscribe form
406 if (getDolGlobalString('MAIN_INFO_SOCIETE_MAIL') && getDolGlobalString('ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT') &&
407 getDolGlobalString('ADHERENT_AUTOREGISTER_NOTIF_MAIL')) {
408 // Define link to login card
409 $appli = constant('DOL_APPLICATION_TITLE');
410 if (getDolGlobalString('MAIN_APPLICATION_TITLE')) {
411 $appli = getDolGlobalString('MAIN_APPLICATION_TITLE');
412 if (preg_match('/\d\.\d/', $appli)) {
413 if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) {
414 $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core
415 }
416 } else {
417 $appli .= " ".DOL_VERSION;
418 }
419 } else {
420 $appli .= " ".DOL_VERSION;
421 }
422
423 $to = $adh->makeSubstitution(getDolGlobalString('MAIN_INFO_SOCIETE_MAIL'));
424 $from = getDolGlobalString('ADHERENT_MAIL_FROM', $conf->email_from);
425 $mailfile = new CMailFile(
426 '['.$appli.'] ' . getDolGlobalString('ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT'),
427 $to,
428 $from,
429 $adh->makeSubstitution(getDolGlobalString('ADHERENT_AUTOREGISTER_NOTIF_MAIL')),
430 array(),
431 array(),
432 array(),
433 "",
434 "",
435 0,
436 -1
437 );
438
439 if (!$mailfile->sendfile()) {
440 dol_syslog($langs->trans("ErrorFailedToSendMail", $from, $to), LOG_ERR);
441 }
442 }
443
444 // Auto-create thirdparty on member creation
445 if (getDolGlobalString('ADHERENT_DEFAULT_CREATE_THIRDPARTY')) {
446 $company = new Societe($db);
447 $result = $company->create_from_member($adh);
448 if ($result < 0) {
449 $error++;
450 $errmsg .= implode('<br>', $company->errors);
451 }
452 }
453
454 if (!empty($backtopage)) {
455 $urlback = $backtopage;
456 } elseif (getDolGlobalString('MEMBER_URL_REDIRECT_SUBSCRIPTION')) {
457 $urlback = getDolGlobalString('MEMBER_URL_REDIRECT_SUBSCRIPTION');
458 // TODO Make replacement of __AMOUNT__, etc...
459 } else {
460 $urlback = $_SERVER["PHP_SELF"]."?action=added&token=".newToken();
461 }
462
463 if (getDolGlobalString('MEMBER_NEWFORM_PAYONLINE') && getDolGlobalString('MEMBER_NEWFORM_PAYONLINE') != '-1') {
464 if (empty($adht->caneditamount)) { // If edition of amount not allowed
465 // TODO Check amount is same than the amount required for the type of member or if not defined as the default amount into $conf->global->MEMBER_NEWFORM_AMOUNT
466 // It is not so important because a test is done on return of payment validation.
467 }
468
469 $urlback = getOnlinePaymentUrl(0, 'member', $adh->ref, (float) price2num(GETPOST('amount', 'alpha'), 'MT'), '', 0);
470
471 if (GETPOST('email')) {
472 $urlback .= '&email='.urlencode(GETPOST('email'));
473 }
474 if (getDolGlobalString('MEMBER_NEWFORM_PAYONLINE') != '-1' && getDolGlobalString('MEMBER_NEWFORM_PAYONLINE') != 'all') {
475 $urlback .= '&paymentmethod='.urlencode(getDolGlobalString('MEMBER_NEWFORM_PAYONLINE'));
476 }
477 } else {
478 if (!empty($entity)) {
479 $urlback .= '&entity='.((int) $entity);
480 }
481 }
482 } else {
483 $error++;
484 $errmsg .= implode('<br>', $adh->errors);
485 }
486 }
487 }
488
489 if (!$error) {
490 $db->commit();
491
492 header("Location: ".$urlback);
493 exit;
494 } else {
495 $db->rollback();
496 $action = "create";
497 }
498}
499
500// Action called after a submitted was send and member created successfully
501// 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.
502// backtopage parameter with an url was set on member submit page, we never go here because a redirect was done to this url.
503
504if (empty($reshook) && $action == 'added') { // Test on permission not required here
505 llxHeaderVierge($langs->trans("NewMemberForm"));
506
507 // If we have not been redirected
508 print '<br><br>';
509 print '<div class="center">';
510 print $langs->trans("NewMemberbyWeb");
511 print '</div>';
512
514 exit;
515}
516
517
518
519/*
520 * View
521 */
522
523$form = new Form($db);
524$formcompany = new FormCompany($db);
525$adht = new AdherentType($db);
526$extrafields->fetch_name_optionals_label($object->table_element); // fetch optionals attributes and labels
527
528
529llxHeaderVierge($langs->trans("NewSubscription"));
530
531print '<br>';
532print load_fiche_titre(img_picto('', 'member_nocolor', 'class="pictofixedwidth"').' &nbsp; '.$langs->trans("NewSubscription"), '', '', 0, '', 'center');
533
534
535print '<div align="center">';
536print '<div id="divsubscribe">';
537
538print '<div class="center subscriptionformhelptext opacitymedium justify">';
539if (getDolGlobalString('MEMBER_NEWFORM_TEXT')) {
540 print $langs->trans(getDolGlobalString('MEMBER_NEWFORM_TEXT'))."<br>\n";
541} else {
542 print $langs->trans("NewSubscriptionDesc", getDolGlobalString("MAIN_INFO_SOCIETE_MAIL"))."<br>\n";
543}
544print '</div>';
545
546dol_htmloutput_errors($errmsg);
548
549// Print form
550print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" name="newmember">'."\n";
551print '<input type="hidden" name="token" value="'.newToken().'" />';
552print '<input type="hidden" name="entity" value="'.$entity.'" />';
553print '<input type="hidden" name="page_y" value="" />';
554
555if (getDolGlobalString('MEMBER_SKIP_TABLE') || getDolGlobalString('MEMBER_NEWFORM_FORCETYPE') || $action == 'create') {
556 print '<input type="hidden" name="action" value="add" />';
557 print '<br>';
558
559 $messagemandatory = '<span class="">'.$langs->trans("FieldsWithAreMandatory", '*').'</span>';
560 //print '<br><span class="opacitymedium">'.$langs->trans("FieldsWithAreMandatory", '*').'</span><br>';
561 //print $langs->trans("FieldsWithIsForPublic",'**').'<br>';
562
563 print dol_get_fiche_head();
564
565 print '<script type="text/javascript">
566 jQuery(document).ready(function () {
567 jQuery(document).ready(function () {
568 function initmorphy()
569 {
570 console.log("Call initmorphy");
571 if (jQuery("#morphy").val() == \'phy\') {
572 jQuery("#trcompany").hide();
573 }
574 if (jQuery("#morphy").val() == \'mor\') {
575 jQuery("#trcompany").show();
576 }
577 }
578 initmorphy();
579 jQuery("#morphy").change(function() {
580 initmorphy();
581 });
582 jQuery("#selectcountry_id").change(function() {
583 document.newmember.action.value="create";
584 document.newmember.submit();
585 });
586 jQuery("#typeid").change(function() {
587 document.newmember.action.value="create";
588 document.newmember.submit();
589 });
590 });
591 });
592 </script>';
593
594
595 print '<table class="border" summary="form to subscribe" id="tablesubscribe">'."\n";
596
597 // Type
598 if (!getDolGlobalString('MEMBER_NEWFORM_FORCETYPE')) {
599 $listoftype = $adht->liste_array();
600 $tmp = array_keys($listoftype);
601 $defaulttype = '';
602 $isempty = 1;
603 if (count($listoftype) == 1) {
604 $defaulttype = $tmp[0];
605 $isempty = 0;
606 }
607 print '<tr><td class="titlefield classfortooltip" title="'.dol_escape_htmltag($messagemandatory).'">'.$langs->trans("Type").' <span class="star">*</span></td><td>';
608 print $form->selectarray("typeid", $adht->liste_array(1), GETPOST('typeid') ? GETPOST('typeid') : $defaulttype, $isempty);
609 print '</td></tr>'."\n";
610 } else {
611 $adht->fetch(getDolGlobalInt('MEMBER_NEWFORM_FORCETYPE'));
612 print '<input type="hidden" id="typeid" name="typeid" value="' . getDolGlobalString('MEMBER_NEWFORM_FORCETYPE').'">';
613 }
614
615 // Moral/Physic attribute
616 $morphys = array();
617 $morphys["phy"] = $langs->trans("Physical");
618 $morphys["mor"] = $langs->trans("Moral");
619 if (!getDolGlobalString('MEMBER_NEWFORM_FORCEMORPHY')) {
620 print '<tr class="morphy"><td class="titlefield classfortooltip" title="'.dol_escape_htmltag($messagemandatory).'">'.$langs->trans('MemberNature').' <span class="star">*</span></td><td>'."\n";
621 print $form->selectarray("morphy", $morphys, GETPOST('morphy'), 1);
622 print '</td></tr>'."\n";
623 } else {
624 //print $morphys[$conf->global->MEMBER_NEWFORM_FORCEMORPHY];
625 print '<input type="hidden" id="morphy" name="morphy" value="' . getDolGlobalString('MEMBER_NEWFORM_FORCEMORPHY').'">';
626 }
627
628 // Company // TODO : optional hide
629 print '<tr id="trcompany" class="trcompany"><td>'.$langs->trans("Company").'</td><td>';
630 print img_picto('', 'company', 'class="pictofixedwidth paddingright"');
631 print '<input type="text" name="societe" class="minwidth150 widthcentpercentminusx" value="'.dol_escape_htmltag(GETPOST('societe')).'"></td></tr>'."\n";
632
633 // Title
634 if (getDolGlobalString('MEMBER_NEWFORM_ASK_TITLE')) {
635 print '<tr><td class="titlefield">'.$langs->trans('UserTitle').'</td><td>';
636 print $formcompany->select_civility(GETPOST('civility_id'), 'civility_id').'</td></tr>'."\n";
637 }
638
639 // Firstname
640 print '<tr><td class="classfortooltip" title="'.dol_escape_htmltag($messagemandatory).'">'.$langs->trans("Firstname").' <span class="star">*</span></td><td><input type="text" name="firstname" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('firstname')).'"></td></tr>'."\n";
641
642 // Lastname
643 print '<tr><td class="classfortooltip" title="'.dol_escape_htmltag($messagemandatory).'">'.$langs->trans("Lastname").' <span class="star">*</span></td><td><input type="text" name="lastname" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('lastname')).'"></td></tr>'."\n";
644
645 // EMail
646 print '<tr><td class="'.(getDolGlobalString("ADHERENT_MAIL_REQUIRED") ? 'classfortooltip' : '').'" title="'.dol_escape_htmltag($messagemandatory).'">'.$langs->trans("Email").(getDolGlobalString("ADHERENT_MAIL_REQUIRED") ? ' <span class="star">*</span>' : '').'</td><td>';
647 //print img_picto('', 'email', 'class="pictofixedwidth"');
648 print '<input type="email" name="email" maxlength="255" class="minwidth200" value="'.dol_escape_htmltag(GETPOST('email', "aZ09arobase")).'"></td></tr>'."\n";
649
650 // Login
651 if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
652 print '<tr><td>'.$langs->trans("Login").' <span class="star">*</span></td><td><input type="text" name="login" maxlength="50" class="minwidth100"value="'.dol_escape_htmltag(GETPOST('login')).'"></td></tr>'."\n";
653 print '<tr><td>'.$langs->trans("Password").' <span class="star">*</span></td><td><input type="password" maxlength="128" name="pass1" class="minwidth100" value="'.dol_escape_htmltag(GETPOST("pass1", "none", 2)).'"></td></tr>'."\n";
654 print '<tr><td>'.$langs->trans("PasswordRetype").' <span class="star">*</span></td><td><input type="password" maxlength="128" name="pass2" class="minwidth100" value="'.dol_escape_htmltag(GETPOST("pass2", "none", 2)).'"></td></tr>'."\n";
655 }
656
657 // Gender
658 print '<tr><td>'.$langs->trans("Gender").'</td>';
659 print '<td>';
660 $arraygender = array('man' => $langs->trans("Genderman"), 'woman' => $langs->trans("Genderwoman"), 'other' => $langs->trans("Genderother"));
661 print $form->selectarray('gender', $arraygender, GETPOST('gender', 'alphanohtml'), 1, 0, 0, '', 0, 0, 0, '', '', 1);
662 print '</td></tr>';
663
664 // Address
665 print '<tr><td>'.$langs->trans("Address").'</td><td>'."\n";
666 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";
667
668 // Zip / Town
669 print '<tr><td>'.$langs->trans('Zip').' / '.$langs->trans('Town').'</td><td>';
670 print $formcompany->select_ziptown(GETPOST('zipcode'), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 1, '', 'width75');
671 print ' / ';
672 print $formcompany->select_ziptown(GETPOST('town'), 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 1);
673 print '</td></tr>';
674
675 // Country
676 print '<tr><td>'.$langs->trans('Country').'</td><td>';
677 print img_picto('', 'country', 'class="pictofixedwidth paddingright"');
678 $country_id = GETPOSTINT('country_id');
679 if (!$country_id && getDolGlobalString('MEMBER_NEWFORM_FORCECOUNTRYCODE')) {
680 $country_id = getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE, '2', $db, $langs);
681 }
682 if (!$country_id && !empty($conf->geoipmaxmind->enabled)) {
683 $country_code = dol_user_country();
684 //print $country_code;
685 if ($country_code) {
686 $new_country_id = getCountry($country_code, '3', $db, $langs);
687 //print 'xxx'.$country_code.' - '.$new_country_id;
688 if ($new_country_id) {
689 $country_id = $new_country_id;
690 }
691 }
692 }
693 $country_code = getCountry($country_id, '2', $db, $langs);
694 print $form->select_country($country_id, 'country_id');
695 print '</td></tr>';
696
697 // State
698 if (!getDolGlobalString('SOCIETE_DISABLE_STATE')) {
699 print '<tr><td>'.$langs->trans('State').'</td><td>';
700 if ($country_code) {
701 print img_picto('', 'state', 'class="pictofixedwidth paddingright"');
702 print $formcompany->select_state(GETPOSTINT("state_id"), $country_code);
703 }
704 print '</td></tr>';
705 }
706
707 // Birthday
708 print '<tr id="trbirth" class="trbirth"><td>'.$langs->trans("DateOfBirth").'</td><td>';
709 print $form->selectDate(!empty($birthday) ? $birthday : "", 'birth', 0, 0, 1, "newmember", 1, 0);
710 print '</td></tr>'."\n";
711
712 // Photo
713 print '<tr><td>'.$langs->trans("URLPhoto").'</td><td><input type="text" name="photo" class="minwidth200" value="'.dol_escape_htmltag(GETPOST('photo')).'"></td></tr>'."\n";
714
715 // Public
716 if (getDolGlobalString('MEMBER_PUBLIC_ENABLED')) {
717 $linkofpubliclist = DOL_MAIN_URL_ROOT.'/public/members/public_list.php'.((isModEnabled('multicompany')) ? '?entity='.$conf->entity : '');
718 $publiclabel = $langs->trans("Public", getDolGlobalString('MAIN_INFO_SOCIETE_NOM'), $linkofpubliclist);
719 print '<tr><td>'.$form->textwithpicto($langs->trans("MembershipPublic"), $publiclabel).'</td><td><input type="checkbox" name="public"></td></tr>'."\n";
720 }
721
722 // Other attributes
723 $parameters['tpl_context'] = 'public'; // define template context to public
724 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
725
726 // Comments
727 print '<tr>';
728 print '<td class="tdtop">'.$langs->trans("Comments").'</td>';
729 print '<td class="tdtop"><textarea name="note_private" id="note_private" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.'">'.dol_escape_htmltag(GETPOST('note_private', 'restricthtml'), 0, 1).'</textarea></td>';
730 print '</tr>'."\n";
731
732 // Add specific fields used by Dolibarr foundation for example
733 // TODO Move this into generic feature.
734 if (getDolGlobalString('MEMBER_NEWFORM_DOLIBARRTURNOVER')) {
735 $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+');
736 print '<tr id="trbudget" class="trcompany"><td>'.$langs->trans("TurnoverOrBudget").' <span class="star">*</span></td><td>';
737 print $form->selectarray('budget', $arraybudget, GETPOST('budget'), 1);
738 print ' € or $';
739
740 print '<script type="text/javascript">
741 jQuery(document).ready(function () {
742 initturnover();
743 jQuery("#morphy").change(function() {
744 initturnover();
745 });
746 jQuery("#budget").change(function() {
747 if (jQuery("#budget").val() > 0) { jQuery(".amount").val(jQuery("#budget").val()); }
748 else { jQuery("#budget").val(\'\'); }
749 });
750 /*jQuery("#typeid").change(function() {
751 if (jQuery("#typeid").val()==1) { jQuery("#morphy").val(\'mor\'); }
752 if (jQuery("#typeid").val()==2) { jQuery("#morphy").val(\'phy\'); }
753 if (jQuery("#typeid").val()==3) { jQuery("#morphy").val(\'mor\'); }
754 if (jQuery("#typeid").val()==4) { jQuery("#morphy").val(\'mor\'); }
755 initturnover();
756 });*/
757 function initturnover() {
758 console.log("Switch mor/phy");
759 if (jQuery("#morphy").val()==\'phy\') {
760 jQuery(".amount").val(20);
761 jQuery("#trbudget").hide();
762 jQuery("#trcompany").hide();
763 }
764 if (jQuery("#morphy").val()==\'mor\') {
765 jQuery(".amount").val(\'\');
766 jQuery("#trcompany").show();
767 jQuery("#trbirth").hide();
768 jQuery("#trbudget").show();
769 jQuery(".hideifautoturnover").hide();
770 if (jQuery("#budget").val() > 0) { jQuery(".amount").val(jQuery("#budget").val()); }
771 else { jQuery("#budget").val(\'\'); }
772 }
773 }
774 });
775 </script>';
776 print '</td></tr>'."\n";
777 }
778
779 if (getDolGlobalString('MEMBER_NEWFORM_PAYONLINE')) {
780 $typeid = getDolGlobalInt('MEMBER_NEWFORM_FORCETYPE', GETPOSTINT('typeid'));
781 $adht = new AdherentType($db);
782 $adht->fetch($typeid);
783 $caneditamount = $adht->caneditamount;
784 $amountbytype = $adht->amountByType(1); // Load the array of amount per type
785
786 // Set amount for the subscription from the the type and options:
787 // - First check the amount of the member type.
788 $amount = empty($amountbytype[$typeid]) ? 0 : $amountbytype[$typeid];
789 // - If not found, take the default amount only if the user is authorized to edit it
790 if (empty($amount) && getDolGlobalString('MEMBER_NEWFORM_AMOUNT')) {
791 $amount = getDolGlobalString('MEMBER_NEWFORM_AMOUNT');
792 }
793 // - If not set, we accept to have amount defined as parameter (for backward compatibility).
794 if (empty($amount)) {
795 $amount = (GETPOST('amount') ? price2num(GETPOST('amount', 'alpha'), 'MT', 2) : '');
796 }
797 // - If a min is set, we take it into account
798 $amount = max(0, (float) $amount, (float) getDolGlobalInt("MEMBER_MIN_AMOUNT"));
799
800 // Clean the amount
801 $amount = price2num($amount);
802 $showedamount = $amount > 0 ? $amount : 0;
803 // $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe'
804 print '<tr><td>'.$langs->trans("Subscription");
805 if (getDolGlobalString('MEMBER_EXT_URL_SUBSCRIPTION_INFO')) {
806 print ' - <a href="' . getDolGlobalString('MEMBER_EXT_URL_SUBSCRIPTION_INFO').'" rel="external" target="_blank" rel="noopener noreferrer">'.$langs->trans("SeeHere").'</a>';
807 }
808 print '</td><td class="nowrap">';
809
810 if (empty($amount) && getDolGlobalString('MEMBER_NEWFORM_AMOUNT')) {
811 $amount = getDolGlobalString('MEMBER_NEWFORM_AMOUNT');
812 }
813
814 if ($caneditamount) {
815 print '<input type="text" name="amount" id="amount" class="flat amount width50" value="'.$showedamount.'">';
816 print ' '.$langs->trans("Currency".$conf->currency).'<span class="opacitymedium hideifautoturnover"> - ';
817 print $amount > 0 ? $langs->trans("AnyAmountWithAdvisedAmount", price($amount, 0, $langs, 1, -1, -1, $conf->currency)) : $langs->trans("AnyAmountWithoutAdvisedAmount");
818 print '</span>';
819 } else {
820 print '<input type="hidden" name="amount" id="amount" class="flat amount" value="'.$showedamount.'">';
821 print '<input type="text" name="amount" id="amounthidden" class="flat amount width50" disabled value="'.$showedamount.'">';
822 print ' '.$langs->trans("Currency".$conf->currency);
823 }
824 print '</td></tr>';
825 }
826
827 // Display Captcha code if is enabled
828 if (getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA_MEMBER')) {
829 require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
830 print '<tr><td class="titlefield"><label><span class="fieldrequired">'.$langs->trans("SecurityCode").'</span></label></td><td>';
831 print '<span class="span-icon-security inline-block">';
832 print '<input id="securitycode" placeholder="'.$langs->trans("SecurityCode").'" class="flat input-icon-security width150" type="text" maxlength="5" name="code" tabindex="3" />';
833 print '</span>';
834 print '<span class="nowrap inline-block">';
835 print '<img class="inline-block valignmiddle" src="'.DOL_URL_ROOT.'/core/antispamimage.php" border="0" width="80" height="32" id="img_securitycode" />';
836 print '<a class="inline-block valignmiddle" href="'.$php_self.'" tabindex="4" data-role="button">'.img_picto($langs->trans("Refresh"), 'refresh', 'id="captcha_refresh_img"').'</a>';
837 print '</span>';
838 print '</td></tr>';
839 }
840
841 print "</table>\n";
842
843 print dol_get_fiche_end();
844
845 // Save / Submit
846 print '<div class="center">';
847 print '<input type="submit" value="'.$langs->trans("GetMembershipButtonLabel").'" id="submitsave" class="button">';
848 if (!empty($backtopage)) {
849 print ' &nbsp; &nbsp; <input type="submit" value="'.$langs->trans("Cancel").'" id="submitcancel" class="button button-cancel">';
850 }
851 print '</div>';
852
853
854 print "</form>\n";
855 print "<br>";
856 print '</div></div>';
857} else { // Show the table of membership types
858 // Get units
859 $measuringUnits = new CUnits($db);
860 $result = $measuringUnits->fetchAll('', '', 0, 0, array('t.active' => 1));
861 $units = array();
862 foreach ($measuringUnits->records as $lines) {
863 $units[$lines->short_label] = $langs->trans(ucfirst($lines->label));
864 }
865
866 $publiccounters = getDolGlobalString("MEMBER_COUNTERS_ARE_PUBLIC");
867 $hidevoteallowed = getDolGlobalString("MEMBER_HIDE_VOTE_ALLOWED");
868
869 $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,";
870 $sql .= " COUNT(a.rowid) AS membercount";
871 $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
872 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as a";
873 $sql .= " ON d.rowid = a.fk_adherent_type AND a.statut > 0";
874 $sql .= " WHERE d.entity IN (".getEntity('member_type').")";
875 $sql .= " AND d.statut=1";
876 $sql .= " GROUP BY d.rowid, d.libelle, d.subscription, d.amount, d.caneditamount, d.vote, d.note, d.duration, d.statut, d.morphy";
877
878 $result = $db->query($sql);
879 if ($result) {
880 $num = $db->num_rows($result);
881
882 print '<br><div class="div-table-responsive">';
883 print '<table class="tagtable liste">'."\n";
884 print '<input type="hidden" name="action" value="create">';
885
886 print '<tr class="liste_titre">';
887 print '<th>'.$langs->trans("Label").'</th>';
888 print '<th class="center">'.$langs->trans("MembershipDuration").'</th>';
889 print '<th class="center">'.$langs->trans("Amount").'</th>';
890 print '<th class="center">'.$langs->trans("MembersNature").'</th>';
891 if (empty($hidevoteallowed)) {
892 print '<th class="center">'.$langs->trans("VoteAllowed").'</th>';
893 }
894 if ($publiccounters) {
895 print '<th class="center">'.$langs->trans("Members").'</th>';
896 }
897 print '<th class="center">'.$langs->trans("NewSubscription").'</th>';
898 print "</tr>\n";
899
900 $i = 0;
901 while ($i < $num) {
902 $objp = $db->fetch_object($result); // Load the member type and information on it
903
904 $caneditamount = $objp->caneditamount;
905 $amountbytype = $adht->amountByType(1); // Load the array of amount per type
906
907 print '<tr class="oddeven">';
908 // Label
909 print '<td>'.dol_escape_htmltag($objp->label).'</td>';
910 // Duration
911 print '<td class="center">';
912 $unit = preg_replace("/[^a-zA-Z]+/", "", $objp->duration);
913 print max(1, intval($objp->duration)).' '.$units[$unit];
914 print '</td>';
915 // Amount
916 print '<td class="center"><span class="amount nowrap">';
917
918 // Set amount for the subscription from the the type and options:
919 // - First check the amount of the member type.
920 $amount = empty($amountbytype[$objp->rowid]) ? 0 : $amountbytype[$objp->rowid];
921 // - If not found, take the default amount only if the user is authorized to edit it
922 if (empty($amount) && getDolGlobalString('MEMBER_NEWFORM_AMOUNT')) {
923 $amount = getDolGlobalString('MEMBER_NEWFORM_AMOUNT');
924 }
925 // - If not set, we accept to have amount defined as parameter (for backward compatibility).
926 if (empty($amount)) {
927 $amount = (GETPOST('amount') ? price2num(GETPOST('amount', 'alpha'), 'MT', 2) : '');
928 }
929 // - If a min is set, we take it into account
930 $amount = max(0, (float) $amount, (float) getDolGlobalInt("MEMBER_MIN_AMOUNT"));
931
932 $displayedamount = $amount;
933
934 if ($objp->subscription) {
935 if ($displayedamount > 0 || !$caneditamount) {
936 print price($displayedamount, 1, $langs, 1, 0, -1, $conf->currency);
937 }
938 if ($caneditamount && $displayedamount > 0) {
939 print $form->textwithpicto('', $langs->transnoentities("CanEditAmountShortForValues"), 1, 'help', '', 0, 3);
940 } elseif ($caneditamount) {
941 print $langs->transnoentities("CanEditAmountShort");
942 }
943 } else {
944 print "–"; // No subscription required
945 }
946 print '</span></td>';
947 print '<td class="center">';
948 if ($objp->morphy == 'phy') {
949 print $langs->trans("Physical");
950 } elseif ($objp->morphy == 'mor') {
951 print $langs->trans("Moral");
952 } else {
953 print $langs->trans("MorAndPhy");
954 }
955 print '</td>';
956 if (empty($hidevoteallowed)) {
957 print '<td class="center">'.yn($objp->vote).'</td>';
958 }
959 $membercount = $objp->membercount > 0 ? $objp->membercount : "–";
960 if ($publiccounters) {
961 print '<td class="center">'.$membercount.'</td>';
962 }
963 print '<td class="center"><button class="button button-save reposition" name="typeid" type="submit" name="submit" value="'.$objp->rowid.'">'.$langs->trans("GetMembershipButtonLabel").'</button></td>';
964 print "</tr>";
965 $i++;
966 }
967
968 // If no record found
969 if ($num == 0) {
970 $colspan = 8;
971 print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
972 }
973
974 print "</table>";
975 print '</div>';
976
977 print '</form>';
978 } else {
979 dol_print_error($db);
980 }
981}
982
983//htmlPrintOnlineFooter($mysoc, $langs);
985
986$db->close();
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:67
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 permettant la generation du formulaire html d'envoi de mail unitaire Usage: $formail = new Form...
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
llxHeaderVierge($title, $head="", $disablejs=0, $disablehead=0, $arrayofjs=[], $arrayofcss=[])
Show header for new prospect.
Definition new.php:122
llxFooterVierge()
Show footer for new societe.
Definition new.php:143
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.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
Definition date.lib.php:125
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...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
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.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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.
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...
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
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:123
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.