dolibarr  16.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-2019 Frédéric France <frederic.france@netlogic.fr>
8  * Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
9  * Copyright (C) 2021 Waël Almoman <info@almoman.com>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program. If not, see <https://www.gnu.org/licenses/>.
23  */
24 
42 if (!defined('NOLOGIN')) {
43  define("NOLOGIN", 1); // This means this output page does not require to be logged.
44 }
45 if (!defined('NOCSRFCHECK')) {
46  define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
47 }
48 if (!defined('NOIPCHECK')) {
49  define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
50 }
51 if (!defined('NOBROWSERNOTIF')) {
52  define('NOBROWSERNOTIF', '1');
53 }
54 if (!defined('NOIPCHECK')) {
55  define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
56 }
57 
58 // For MultiCompany module.
59 // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php
60 $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
61 if (is_numeric($entity)) {
62  define("DOLENTITY", $entity);
63 }
64 
65 require '../../main.inc.php';
66 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
67 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
68 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
69 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
70 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
71 
72 // Init vars
73 $errmsg = '';
74 $num = 0;
75 $error = 0;
76 $backtopage = GETPOST('backtopage', 'alpha');
77 $action = GETPOST('action', 'aZ09');
78 
79 // Load translation files
80 $langs->loadLangs(array("main", "members", "companies", "install", "other"));
81 
82 // Security check
83 if (empty($conf->adherent->enabled)) {
84  accessforbidden('', 0, 0, 1);
85 }
86 
87 if (empty($conf->global->MEMBER_ENABLE_PUBLIC)) {
88  print $langs->trans("Auto subscription form for public visitors has not been enabled");
89  exit;
90 }
91 
92 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
93 $hookmanager->initHooks(array('publicnewmembercard', 'globalcard'));
94 
95 $extrafields = new ExtraFields($db);
96 
97 $object = new Adherent($db);
98 
99 $user->loadDefaultValues();
100 
101 
113 function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $arrayofjs = '', $arrayofcss = '')
114 {
115  global $user, $conf, $langs, $mysoc;
116 
117  top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers
118 
119  print '<body id="mainbody" class="publicnewmemberform">';
120 
121  // Define urllogo
122  $urllogo = DOL_URL_ROOT.'/theme/common/login_logo.png';
123 
124  if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) {
125  $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_small);
126  } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) {
127  $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/'.$mysoc->logo);
128  } elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.svg')) {
129  $urllogo = DOL_URL_ROOT.'/theme/dolibarr_logo.svg';
130  }
131 
132  print '<div class="center">';
133 
134  // Output html code for logo
135  if ($urllogo) {
136  print '<div class="backgreypublicpayment">';
137  print '<div class="logopublicpayment">';
138  print '<img id="dolpaymentlogo" src="'.$urllogo.'">';
139  print '</div>';
140  if (empty($conf->global->MAIN_HIDE_POWERED_BY)) {
141  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>';
142  }
143  print '</div>';
144  }
145 
146  if (!empty($conf->global->MEMBER_IMAGE_PUBLIC_REGISTRATION)) {
147  print '<div class="backimagepublicregistration">';
148  print '<img id="idEVENTORGANIZATION_IMAGE_PUBLIC_INTERFACE" src="'.$conf->global->MEMBER_IMAGE_PUBLIC_REGISTRATION.'">';
149  print '</div>';
150  }
151 
152  print '</div>';
153 
154  print '<div class="divmainbodylarge">';
155 }
156 
162 function llxFooterVierge()
163 {
164  print '</div>';
165 
166  printCommonFooter('public');
167 
168  print "</body>\n";
169  print "</html>\n";
170 }
171 
172 
173 
174 /*
175  * Actions
176  */
177 
178 $parameters = array();
179 // Note that $action and $object may have been modified by some hooks
180 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);
181 if ($reshook < 0) {
182  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
183 }
184 
185 // Action called when page is submitted
186 if (empty($reshook) && $action == 'add') {
187  $error = 0;
188  $urlback = '';
189 
190  $db->begin();
191 
192  // test if login already exists
193  if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
194  if (!GETPOST('login')) {
195  $error++;
196  $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login"))."<br>\n";
197  }
198  $sql = "SELECT login FROM ".MAIN_DB_PREFIX."adherent WHERE login='".$db->escape(GETPOST('login'))."'";
199  $result = $db->query($sql);
200  if ($result) {
201  $num = $db->num_rows($result);
202  }
203  if ($num != 0) {
204  $error++;
205  $langs->load("errors");
206  $errmsg .= $langs->trans("ErrorLoginAlreadyExists")."<br>\n";
207  }
208  if (!GETPOSTISSET("pass1") || !GETPOSTISSET("pass2") || GETPOST("pass1", 'none') == '' || GETPOST("pass2", 'none') == '' || GETPOST("pass1", 'none') != GETPOST("pass2", 'none')) {
209  $error++;
210  $langs->load("errors");
211  $errmsg .= $langs->trans("ErrorPasswordsMustMatch")."<br>\n";
212  }
213  if (!GETPOST('email')) {
214  $error++;
215  $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("EMail"))."<br>\n";
216  }
217  }
218  if (GETPOST('typeid') <= 0) {
219  $error++;
220  $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type"))."<br>\n";
221  }
222  if (!in_array(GETPOST('morphy'), array('mor', 'phy'))) {
223  $error++;
224  $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv('Nature'))."<br>\n";
225  }
226  if (!GETPOST('lastname')) {
227  $error++;
228  $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Lastname"))."<br>\n";
229  }
230  if (!GETPOST('firstname')) {
231  $error++;
232  $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Firstname"))."<br>\n";
233  }
234  if (!empty($conf->global->ADHERENT_MAIL_REQUIRED) && empty(GETPOST('email'))) {
235  $error++;
236  $errmsg .= $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Email'))."<br>\n";
237  } elseif (GETPOST("email") && !isValidEmail(GETPOST("email"))) {
238  $langs->load('errors');
239  $error++;
240  $errmsg .= $langs->trans("ErrorBadEMail", GETPOST("email"))."<br>\n";
241  }
242  $birthday = dol_mktime(GETPOST("birthhour", 'int'), GETPOST("birthmin", 'int'), GETPOST("birthsec", 'int'), GETPOST("birthmonth", 'int'), GETPOST("birthday", 'int'), GETPOST("birthyear", 'int'));
243  if (GETPOST("birthmonth") && empty($birthday)) {
244  $error++;
245  $langs->load("errors");
246  $errmsg .= $langs->trans("ErrorBadDateFormat")."<br>\n";
247  }
248  if (!empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER)) {
249  if (GETPOST("morphy") == 'mor' && GETPOST('budget') <= 0) {
250  $error++;
251  $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("TurnoverOrBudget"))."<br>\n";
252  }
253  }
254 
255  $public = GETPOSTISSET('public') ? 1 : 0;
256 
257  if (!$error) {
258  // email a peu pres correct et le login n'existe pas
259  $adh = new Adherent($db);
260  $adh->statut = -1;
261  $adh->public = $public;
262  $adh->firstname = GETPOST('firstname');
263  $adh->lastname = GETPOST('lastname');
264  $adh->gender = GETPOST('gender');
265  $adh->civility_id = GETPOST('civility_id');
266  $adh->societe = GETPOST('societe');
267  $adh->address = GETPOST('address');
268  $adh->zip = GETPOST('zipcode');
269  $adh->town = GETPOST('town');
270  $adh->email = GETPOST('email');
271  if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
272  $adh->login = GETPOST('login');
273  $adh->pass = GETPOST('pass1');
274  }
275  $adh->photo = GETPOST('photo');
276  $adh->country_id = $conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE ? $conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE : GETPOST('country_id', 'int');
277  $adh->state_id = GETPOST('state_id', 'int');
278  $adh->typeid = $conf->global->MEMBER_NEWFORM_FORCETYPE ? $conf->global->MEMBER_NEWFORM_FORCETYPE : GETPOST('typeid', 'int');
279  $adh->note_private = GETPOST('note_private');
280  $adh->morphy = $conf->global->MEMBER_NEWFORM_FORCEMORPHY ? $conf->global->MEMBER_NEWFORM_FORCEMORPHY : GETPOST('morphy');
281  $adh->birth = $birthday;
282 
283 
284  // Fill array 'array_options' with data from add form
285  $extrafields->fetch_name_optionals_label($adh->table_element);
286  $ret = $extrafields->setOptionalsFromPost(null, $adh);
287  if ($ret < 0) {
288  $error++;
289  }
290 
291  if (!$error) {
292  $result = $adh->create($user);
293  if ($result > 0) {
294  require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
295  $object = $adh;
296 
297  $adht = new AdherentType($db);
298  $adht->fetch($object->typeid);
299 
300  if ($object->email) {
301  $subject = '';
302  $msg = '';
303 
304  // Send subscription email
305  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
306  $formmail = new FormMail($db);
307  // Set output language
308  $outputlangs = new Translate('', $conf);
309  $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
310  // Load traductions files required by page
311  $outputlangs->loadLangs(array("main", "members"));
312  // Get email content from template
313  $arraydefaultmessage = null;
314  $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER;
315 
316  if (!empty($labeltouse)) {
317  $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
318  }
319 
320  if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
321  $subject = $arraydefaultmessage->topic;
322  $msg = $arraydefaultmessage->content;
323  }
324 
325  $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
326  complete_substitutions_array($substitutionarray, $outputlangs, $object);
327  $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
328  $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs);
329 
330  if ($subjecttosend && $texttosend) {
331  $moreinheader = 'X-Dolibarr-Info: send_an_email by public/members/new.php'."\r\n";
332 
333  $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader);
334  }
335  /*if ($result < 0) {
336  $error++;
337  setEventMessages($object->error, $object->errors, 'errors');
338  }*/
339  }
340 
341  // Send email to the foundation to say a new member subscribed with autosubscribe form
342  if (!empty($conf->global->MAIN_INFO_SOCIETE_MAIL) && !empty($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT) &&
343  !empty($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL)) {
344  // Define link to login card
345  $appli = constant('DOL_APPLICATION_TITLE');
346  if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
347  $appli = $conf->global->MAIN_APPLICATION_TITLE;
348  if (preg_match('/\d\.\d/', $appli)) {
349  if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) {
350  $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core
351  }
352  } else {
353  $appli .= " ".DOL_VERSION;
354  }
355  } else {
356  $appli .= " ".DOL_VERSION;
357  }
358 
359  $to = $adh->makeSubstitution($conf->global->MAIN_INFO_SOCIETE_MAIL);
360  $from = $conf->global->ADHERENT_MAIL_FROM;
361  $mailfile = new CMailFile(
362  '['.$appli.'] '.$conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT,
363  $to,
364  $from,
365  $adh->makeSubstitution($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL),
366  array(),
367  array(),
368  array(),
369  "",
370  "",
371  0,
372  -1
373  );
374 
375  if (!$mailfile->sendfile()) {
376  dol_syslog($langs->trans("ErrorFailedToSendMail", $from, $to), LOG_ERR);
377  }
378  }
379 
380  if (!empty($backtopage)) {
381  $urlback = $backtopage;
382  } elseif (!empty($conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION)) {
383  $urlback = $conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION;
384  // TODO Make replacement of __AMOUNT__, etc...
385  } else {
386  $urlback = $_SERVER["PHP_SELF"]."?action=added&token=".newToken();
387  }
388 
389  if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE) && $conf->global->MEMBER_NEWFORM_PAYONLINE != '-1') {
390  if (empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { // If edition of amount not allowed
391  // TODO Check amount is same than the amount required for the type of member or if not defined as the defeault amount into $conf->global->MEMBER_NEWFORM_AMOUNT
392  // It is not so important because a test is done on return of payment validation.
393  }
394 
395  $urlback = getOnlinePaymentUrl(0, 'member', $adh->ref, price2num(GETPOST('amount', 'alpha'), 'MT'), '', 0);
396 
397  if (GETPOST('email')) {
398  $urlback .= '&email='.urlencode(GETPOST('email'));
399  }
400  if ($conf->global->MEMBER_NEWFORM_PAYONLINE != '-1' && $conf->global->MEMBER_NEWFORM_PAYONLINE != 'all') {
401  $urlback .= '&paymentmethod='.urlencode($conf->global->MEMBER_NEWFORM_PAYONLINE);
402  }
403  } else {
404  if (!empty($entity)) {
405  $urlback .= '&entity='.((int) $entity);
406  }
407  }
408 
409  dol_syslog("member ".$adh->ref." was created, we redirect to ".$urlback);
410  } else {
411  $error++;
412  $errmsg .= join('<br>', $adh->errors);
413  }
414  }
415  }
416 
417  if (!$error) {
418  $db->commit();
419 
420  Header("Location: ".$urlback);
421  exit;
422  } else {
423  $db->rollback();
424  }
425 }
426 
427 // Action called after a submitted was send and member created successfully
428 // If MEMBER_URL_REDIRECT_SUBSCRIPTION is set to url we never go here because a redirect was done to this url.
429 // backtopage parameter with an url was set on member submit page, we never go here because a redirect was done to this url.
430 if (empty($reshook) && $action == 'added') {
431  llxHeaderVierge($langs->trans("NewMemberForm"));
432 
433  // Si on a pas ete redirige
434  print '<br><br>';
435  print '<div class="center">';
436  print $langs->trans("NewMemberbyWeb");
437  print '</div>';
438 
439  llxFooterVierge();
440  exit;
441 }
442 
443 
444 
445 /*
446  * View
447  */
448 
449 $form = new Form($db);
450 $formcompany = new FormCompany($db);
451 $adht = new AdherentType($db);
452 $extrafields->fetch_name_optionals_label($object->table_element); // fetch optionals attributes and labels
453 
454 
455 llxHeaderVierge($langs->trans("NewSubscription"));
456 
457 
458 print load_fiche_titre($langs->trans("NewSubscription"), '', '', 0, 0, 'center');
459 
460 
461 print '<div align="center">';
462 print '<div id="divsubscribe">';
463 
464 print '<div class="center subscriptionformhelptext justify">';
465 if (!empty($conf->global->MEMBER_NEWFORM_TEXT)) {
466  print $langs->trans($conf->global->MEMBER_NEWFORM_TEXT)."<br>\n";
467 } else {
468  print $langs->trans("NewSubscriptionDesc", $conf->global->MAIN_INFO_SOCIETE_MAIL)."<br>\n";
469 }
470 print '</div>';
471 
472 dol_htmloutput_errors($errmsg);
474 
475 // Print form
476 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" name="newmember">'."\n";
477 print '<input type="hidden" name="token" value="'.newToken().'" / >';
478 print '<input type="hidden" name="entity" value="'.$entity.'" />';
479 print '<input type="hidden" name="action" value="add" />';
480 print '<input type="hidden" name="page_y" value="" />';
481 
482 print '<br>';
483 
484 print '<br><span class="opacitymedium">'.$langs->trans("FieldsWithAreMandatory", '*').'</span><br>';
485 //print $langs->trans("FieldsWithIsForPublic",'**').'<br>';
486 
487 print dol_get_fiche_head('');
488 
489 print '<script type="text/javascript">
490 jQuery(document).ready(function () {
491  jQuery(document).ready(function () {
492  function initmorphy()
493  {
494  console.log("Call initmorphy");
495  if (jQuery("#morphy").val() == \'phy\') {
496  jQuery("#trcompany").hide();
497  }
498  if (jQuery("#morphy").val() == \'mor\') {
499  jQuery("#trcompany").show();
500  }
501  };
502  initmorphy();
503  jQuery("#morphy").change(function() {
504  initmorphy();
505  });
506  jQuery("#selectcountry_id").change(function() {
507  document.newmember.action.value="create";
508  document.newmember.submit();
509  });
510  jQuery("#typeid").change(function() {
511  document.newmember.action.value="create";
512  document.newmember.submit();
513  });
514  });
515 });
516 </script>';
517 
518 
519 print '<table class="border" summary="form to subscribe" id="tablesubscribe">'."\n";
520 
521 // Type
522 if (empty($conf->global->MEMBER_NEWFORM_FORCETYPE)) {
523  $listoftype = $adht->liste_array();
524  $tmp = array_keys($listoftype);
525  $defaulttype = '';
526  $isempty = 1;
527  if (count($listoftype) == 1) {
528  $defaulttype = $tmp[0];
529  $isempty = 0;
530  }
531  print '<tr><td class="titlefield">'.$langs->trans("Type").' <span style="color: red">*</span></td><td>';
532  print $form->selectarray("typeid", $adht->liste_array(1), GETPOST('typeid') ? GETPOST('typeid') : $defaulttype, $isempty);
533  print '</td></tr>'."\n";
534 } else {
535  $adht->fetch($conf->global->MEMBER_NEWFORM_FORCETYPE);
536  print '<input type="hidden" id="typeid" name="typeid" value="'.$conf->global->MEMBER_NEWFORM_FORCETYPE.'">';
537 }
538 
539 // Moral/Physic attribute
540 $morphys["phy"] = $langs->trans("Physical");
541 $morphys["mor"] = $langs->trans("Moral");
542 if (empty($conf->global->MEMBER_NEWFORM_FORCEMORPHY)) {
543  print '<tr class="morphy"><td class="titlefield">'.$langs->trans('MemberNature').' <span style="color: red">*</span></td><td>'."\n";
544  print $form->selectarray("morphy", $morphys, GETPOST('morphy'), 1);
545  print '</td></tr>'."\n";
546 } else {
547  print '<input type="hidden" id="morphy" name="morphy" value="'.$conf->global->MEMBER_NEWFORM_FORCEMORPHY.'">';
548 }
549 
550 // Company
551 print '<tr id="trcompany" class="trcompany"><td>'.$langs->trans("Company").'</td><td>';
552 print img_picto('', 'company', 'class="pictofixedwidth"');
553 print '<input type="text" name="societe" class="minwidth150 widthcentpercentminusx" value="'.dol_escape_htmltag(GETPOST('societe')).'"></td></tr>'."\n";
554 // Title
555 print '<tr><td class="titlefield">'.$langs->trans('UserTitle').'</td><td>';
556 print $formcompany->select_civility(GETPOST('civility_id'), 'civility_id').'</td></tr>'."\n";
557 // Lastname
558 print '<tr><td>'.$langs->trans("Lastname").' <span style="color: red">*</span></td><td><input type="text" name="lastname" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('lastname')).'"></td></tr>'."\n";
559 // Firstname
560 print '<tr><td>'.$langs->trans("Firstname").' <span style="color: red">*</span></td><td><input type="text" name="firstname" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('firstname')).'"></td></tr>'."\n";
561 // EMail
562 print '<tr><td>'.$langs->trans("Email").($conf->global->ADHERENT_MAIL_REQUIRED ? ' <span style="color:red;">*</span>' : '').'</td><td>';
563 //print img_picto('', 'email', 'class="pictofixedwidth"');
564 print '<input type="text" name="email" maxlength="255" class="minwidth200" value="'.dol_escape_htmltag(GETPOST('email')).'"></td></tr>'."\n";
565 // Login
566 if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
567  print '<tr><td>'.$langs->trans("Login").' <span style="color: red">*</span></td><td><input type="text" name="login" maxlength="50" class="minwidth100"value="'.dol_escape_htmltag(GETPOST('login')).'"></td></tr>'."\n";
568  print '<tr><td>'.$langs->trans("Password").' <span style="color: red">*</span></td><td><input type="password" maxlength="128" name="pass1" class="minwidth100" value="'.dol_escape_htmltag(GETPOST("pass1", "none", 2)).'"></td></tr>'."\n";
569  print '<tr><td>'.$langs->trans("PasswordRetype").' <span style="color: red">*</span></td><td><input type="password" maxlength="128" name="pass2" class="minwidth100" value="'.dol_escape_htmltag(GETPOST("pass2", "none", 2)).'"></td></tr>'."\n";
570 }
571 // Gender
572 print '<tr><td>'.$langs->trans("Gender").'</td>';
573 print '<td>';
574 $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman"));
575 print $form->selectarray('gender', $arraygender, GETPOST('gender') ?GETPOST('gender') : $object->gender, 1);
576 print '</td></tr>';
577 // Address
578 print '<tr><td>'.$langs->trans("Address").'</td><td>'."\n";
579 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";
580 // Zip / Town
581 print '<tr><td>'.$langs->trans('Zip').' / '.$langs->trans('Town').'</td><td>';
582 print $formcompany->select_ziptown(GETPOST('zipcode'), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 1, '', 'width75');
583 print ' / ';
584 print $formcompany->select_ziptown(GETPOST('town'), 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 1);
585 print '</td></tr>';
586 // Country
587 print '<tr><td>'.$langs->trans('Country').'</td><td>';
588 print img_picto('', 'country', 'class="pictofixedwidth"');
589 $country_id = GETPOST('country_id', 'int');
590 if (!$country_id && !empty($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE)) {
591  $country_id = getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs);
592 }
593 if (!$country_id && !empty($conf->geoipmaxmind->enabled)) {
594  $country_code = dol_user_country();
595  //print $country_code;
596  if ($country_code) {
597  $new_country_id = getCountry($country_code, 3, $db, $langs);
598  //print 'xxx'.$country_code.' - '.$new_country_id;
599  if ($new_country_id) {
600  $country_id = $new_country_id;
601  }
602  }
603 }
604 $country_code = getCountry($country_id, 2, $db, $langs);
605 print $form->select_country($country_id, 'country_id');
606 print '</td></tr>';
607 // State
608 if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
609  print '<tr><td>'.$langs->trans('State').'</td><td>';
610  if ($country_code) {
611  print $formcompany->select_state(GETPOST("state_id"), $country_code);
612  }
613  print '</td></tr>';
614 }
615 // Birthday
616 print '<tr id="trbirth" class="trbirth"><td>'.$langs->trans("DateOfBirth").'</td><td>';
617 print $form->selectDate($birthday, 'birth', 0, 0, 1, "newmember", 1, 0);
618 print '</td></tr>'."\n";
619 // Photo
620 print '<tr><td>'.$langs->trans("URLPhoto").'</td><td><input type="text" name="photo" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('photo')).'"></td></tr>'."\n";
621 // Public
622 print '<tr><td>'.$langs->trans("Public").'</td><td><input type="checkbox" name="public"></td></tr>'."\n";
623 // Other attributes
624 $tpl_context = 'public'; // define template context to public
625 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
626 // Comments
627 print '<tr>';
628 print '<td class="tdtop">'.$langs->trans("Comments").'</td>';
629 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>';
630 print '</tr>'."\n";
631 
632 // Add specific fields used by Dolibarr foundation for example
633 // TODO Move this into generic feature.
634 if (!empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER)) {
635  $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+');
636  print '<tr id="trbudget" class="trcompany"><td>'.$langs->trans("TurnoverOrBudget").' <span style="color: red">*</span></td><td>';
637  print $form->selectarray('budget', $arraybudget, GETPOST('budget'), 1);
638  print ' € or $';
639 
640  print '<script type="text/javascript">
641  jQuery(document).ready(function () {
642  initturnover();
643  jQuery("#morphy").click(function() {
644  initturnover();
645  });
646  jQuery("#budget").change(function() {
647  if (jQuery("#budget").val() > 0) { jQuery(".amount").val(jQuery("#budget").val()); }
648  else { jQuery("#budget").val(\'\'); }
649  });
650  /*jQuery("#typeid").change(function() {
651  if (jQuery("#typeid").val()==1) { jQuery("#morphy").val(\'mor\'); }
652  if (jQuery("#typeid").val()==2) { jQuery("#morphy").val(\'phy\'); }
653  if (jQuery("#typeid").val()==3) { jQuery("#morphy").val(\'mor\'); }
654  if (jQuery("#typeid").val()==4) { jQuery("#morphy").val(\'mor\'); }
655  initturnover();
656  });*/
657  function initturnover() {
658  if (jQuery("#morphy").val()==\'phy\') {
659  jQuery(".amount").val(20);
660  jQuery("#trbudget").hide();
661  jQuery("#trcompany").hide();
662  }
663  if (jQuery("#morphy").val()==\'mor\') {
664  jQuery(".amount").val(\'\');
665  jQuery("#trcompany").show();
666  jQuery("#trbirth").hide();
667  jQuery("#trbudget").show();
668  if (jQuery("#budget").val() > 0) { jQuery(".amount").val(jQuery("#budget").val()); }
669  else { jQuery("#budget").val(\'\'); }
670  }
671  }
672  });
673  </script>';
674  print '</td></tr>'."\n";
675 }
676 
677 if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) {
678  $amount = 0;
679  $typeid = $conf->global->MEMBER_NEWFORM_FORCETYPE ? $conf->global->MEMBER_NEWFORM_FORCETYPE : GETPOST('typeid', 'int');
680 
681  // Set amount for the subscription:
682  // - First check the amount of the member type.
683  $amountbytype = $adht->amountByType(1); // Load the array of amount per type
684  $amount = empty($amountbytype[$typeid]) ? (isset($amount) ? $amount : 0) : $amountbytype[$typeid];
685  // - If not found, take the default amount
686  if (empty($amount) && !empty($conf->global->MEMBER_NEWFORM_AMOUNT)) {
687  $amount = $conf->global->MEMBER_NEWFORM_AMOUNT;
688  }
689  // - If not set, we accept ot have amount defined as parameter (for backward compatibility).
690  if (empty($amount)) {
691  $amount = (GETPOST('amount') ? price2num(GETPOST('amount', 'alpha'), 'MT', 2) : '');
692  }
693 
694  // Clean the amount
695  $amount = price2num($amount);
696 
697  // $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe'
698  print '<tr><td>'.$langs->trans("Subscription").'</td><td class="nowrap">';
699  if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) {
700  print '<input type="text" name="amount" id="amount" class="flat amount width50" value="'.$amount.'">';
701  } else {
702  print '<input type="text" name="amount" id="amounthidden" class="flat amount width50" disabled value="'.$amount.'">';
703  print '<input type="hidden" name="amount" id="amount" class="flat amount" value="'.$amount.'">';
704  }
705  print ' '.$langs->trans("Currency".$conf->currency);
706  print '</td></tr>';
707 }
708 
709 print "</table>\n";
710 
711 print dol_get_fiche_end();
712 
713 // Save
714 print '<div class="center">';
715 print '<input type="submit" value="'.$langs->trans("Submit").'" id="submitsave" class="button">';
716 if (!empty($backtopage)) {
717  print ' &nbsp; &nbsp; <input type="submit" value="'.$langs->trans("Cancel").'" id="submitcancel" class="button button-cancel">';
718 }
719 print '</div>';
720 
721 
722 print "</form>\n";
723 print "<br>";
724 print '</div></div>';
725 
726 
728 
729 $db->close();
make_substitutions
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
Definition: functions.lib.php:7839
AdherentType
Class to manage members type.
Definition: adherent_type.class.php:35
dol_escape_htmltag
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
Definition: functions.lib.php:1468
dol_htmloutput_events
dol_htmloutput_events($disabledoutputofmessages=0)
Print formated messages to output (Used to show messages on html output).
Definition: functions.lib.php:8172
dol_htmloutput_errors
dol_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0)
Print formated error messages to output (Used to show messages on html output).
Definition: functions.lib.php:8367
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
Translate
Class to manage translations.
Definition: translate.class.php:30
top_htmlhead
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Ouput html header of a page.
Definition: main.inc.php:1482
CMailFile
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Definition: CMailFile.class.php:38
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
printCommonFooter
printCommonFooter($zone='private')
Print common footer : conf->global->MAIN_HTML_FOOTER js for switch of menu hider js for conf->global-...
Definition: functions.lib.php:9150
price2num
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
Definition: functions.lib.php:5661
dol_concatdesc
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...
Definition: functions.lib.php:7248
FormCompany
Class to build HTML component for third parties management Only common components are here.
Definition: html.formcompany.class.php:40
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
dol_user_country
dol_user_country()
Return country code for current user.
Definition: functions.lib.php:3584
llxHeaderVierge
llxHeaderVierge($title, $head="", $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='')
Show header for new member.
Definition: new.php:113
isValidEmail
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
Definition: functions.lib.php:3681
getCommonSubstitutionArray
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null)
Return array of possible common substitutions.
Definition: functions.lib.php:7275
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1603
Adherent
Class to manage members of a foundation.
Definition: adherent.class.php:46
llxFooterVierge
llxFooterVierge()
Show footer for new member.
Definition: new.php:162
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:10878
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
ExtraFields
Class to manage standard extra fields.
Definition: extrafields.class.php:39
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
getCountry
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
Definition: company.lib.php:489
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
FormMail
Classe permettant la generation du formulaire html d'envoi de mail unitaire Usage: $formail = new For...
Definition: html.formmail.class.php:38
dol_mktime
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
Definition: functions.lib.php:2757
complete_substitutions_array
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...
Definition: functions.lib.php:7961