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