dolibarr  16.0.1
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  $result = $adh->create($user);
292  if ($result > 0) {
293  require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
294  $object = $adh;
295 
296  $adht = new AdherentType($db);
297  $adht->fetch($object->typeid);
298 
299  if ($object->email) {
300  $subject = '';
301  $msg = '';
302 
303  // Send subscription email
304  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
305  $formmail = new FormMail($db);
306  // Set output language
307  $outputlangs = new Translate('', $conf);
308  $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
309  // Load traductions files required by page
310  $outputlangs->loadLangs(array("main", "members"));
311  // Get email content from template
312  $arraydefaultmessage = null;
313  $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER;
314 
315  if (!empty($labeltouse)) {
316  $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
317  }
318 
319  if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
320  $subject = $arraydefaultmessage->topic;
321  $msg = $arraydefaultmessage->content;
322  }
323 
324  $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
325  complete_substitutions_array($substitutionarray, $outputlangs, $object);
326  $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
327  $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs);
328 
329  if ($subjecttosend && $texttosend) {
330  $moreinheader = 'X-Dolibarr-Info: send_an_email by public/members/new.php'."\r\n";
331 
332  $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader);
333  }
334  /*if ($result < 0) {
335  $error++;
336  setEventMessages($object->error, $object->errors, 'errors');
337  }*/
338  }
339 
340  // Send email to the foundation to say a new member subscribed with autosubscribe form
341  if (!empty($conf->global->MAIN_INFO_SOCIETE_MAIL) && !empty($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT) &&
342  !empty($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL)) {
343  // Define link to login card
344  $appli = constant('DOL_APPLICATION_TITLE');
345  if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
346  $appli = $conf->global->MAIN_APPLICATION_TITLE;
347  if (preg_match('/\d\.\d/', $appli)) {
348  if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) {
349  $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core
350  }
351  } else {
352  $appli .= " ".DOL_VERSION;
353  }
354  } else {
355  $appli .= " ".DOL_VERSION;
356  }
357 
358  $to = $adh->makeSubstitution($conf->global->MAIN_INFO_SOCIETE_MAIL);
359  $from = $conf->global->ADHERENT_MAIL_FROM;
360  $mailfile = new CMailFile(
361  '['.$appli.'] '.$conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT,
362  $to,
363  $from,
364  $adh->makeSubstitution($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL),
365  array(),
366  array(),
367  array(),
368  "",
369  "",
370  0,
371  -1
372  );
373 
374  if (!$mailfile->sendfile()) {
375  dol_syslog($langs->trans("ErrorFailedToSendMail", $from, $to), LOG_ERR);
376  }
377  }
378 
379  if (!empty($backtopage)) {
380  $urlback = $backtopage;
381  } elseif (!empty($conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION)) {
382  $urlback = $conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION;
383  // TODO Make replacement of __AMOUNT__, etc...
384  } else {
385  $urlback = $_SERVER["PHP_SELF"]."?action=added&token=".newToken();
386  }
387 
388  if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE) && $conf->global->MEMBER_NEWFORM_PAYONLINE != '-1') {
389  if (empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { // If edition of amount not allowed
390  // 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
391  // It is not so important because a test is done on return of payment validation.
392  }
393 
394  $urlback = getOnlinePaymentUrl(0, 'member', $adh->ref, price2num(GETPOST('amount', 'alpha'), 'MT'), '', 0);
395 
396  if (GETPOST('email')) {
397  $urlback .= '&email='.urlencode(GETPOST('email'));
398  }
399  if ($conf->global->MEMBER_NEWFORM_PAYONLINE != '-1' && $conf->global->MEMBER_NEWFORM_PAYONLINE != 'all') {
400  $urlback .= '&paymentmethod='.urlencode($conf->global->MEMBER_NEWFORM_PAYONLINE);
401  }
402  } else {
403  if (!empty($entity)) {
404  $urlback .= '&entity='.((int) $entity);
405  }
406  }
407 
408  dol_syslog("member ".$adh->ref." was created, we redirect to ".$urlback);
409  } else {
410  $error++;
411  $errmsg .= join('<br>', $adh->errors);
412  }
413  }
414 
415  if (!$error) {
416  $db->commit();
417 
418  Header("Location: ".$urlback);
419  exit;
420  } else {
421  $db->rollback();
422  }
423 }
424 
425 // Action called after a submitted was send and member created successfully
426 // If MEMBER_URL_REDIRECT_SUBSCRIPTION is set to url we never go here because a redirect was done to this url.
427 // backtopage parameter with an url was set on member submit page, we never go here because a redirect was done to this url.
428 if (empty($reshook) && $action == 'added') {
429  llxHeaderVierge($langs->trans("NewMemberForm"));
430 
431  // Si on a pas ete redirige
432  print '<br><br>';
433  print '<div class="center">';
434  print $langs->trans("NewMemberbyWeb");
435  print '</div>';
436 
437  llxFooterVierge();
438  exit;
439 }
440 
441 
442 
443 /*
444  * View
445  */
446 
447 $form = new Form($db);
448 $formcompany = new FormCompany($db);
449 $adht = new AdherentType($db);
450 $extrafields->fetch_name_optionals_label($object->table_element); // fetch optionals attributes and labels
451 
452 
453 llxHeaderVierge($langs->trans("NewSubscription"));
454 
455 
456 print load_fiche_titre($langs->trans("NewSubscription"), '', '', 0, 0, 'center');
457 
458 
459 print '<div align="center">';
460 print '<div id="divsubscribe">';
461 
462 print '<div class="center subscriptionformhelptext justify">';
463 if (!empty($conf->global->MEMBER_NEWFORM_TEXT)) {
464  print $langs->trans($conf->global->MEMBER_NEWFORM_TEXT)."<br>\n";
465 } else {
466  print $langs->trans("NewSubscriptionDesc", $conf->global->MAIN_INFO_SOCIETE_MAIL)."<br>\n";
467 }
468 print '</div>';
469 
470 dol_htmloutput_errors($errmsg);
471 
472 // Print form
473 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" name="newmember">'."\n";
474 print '<input type="hidden" name="token" value="'.newToken().'" / >';
475 print '<input type="hidden" name="entity" value="'.$entity.'" />';
476 print '<input type="hidden" name="action" value="add" />';
477 print '<input type="hidden" name="page_y" value="" />';
478 
479 print '<br>';
480 
481 print '<br><span class="opacitymedium">'.$langs->trans("FieldsWithAreMandatory", '*').'</span><br>';
482 //print $langs->trans("FieldsWithIsForPublic",'**').'<br>';
483 
484 print dol_get_fiche_head('');
485 
486 print '<script type="text/javascript">
487 jQuery(document).ready(function () {
488  jQuery(document).ready(function () {
489  function initmorphy()
490  {
491  console.log("Call initmorphy");
492  if (jQuery("#morphy").val() == \'phy\') {
493  jQuery("#trcompany").hide();
494  }
495  if (jQuery("#morphy").val() == \'mor\') {
496  jQuery("#trcompany").show();
497  }
498  };
499  initmorphy();
500  jQuery("#morphy").change(function() {
501  initmorphy();
502  });
503  jQuery("#selectcountry_id").change(function() {
504  document.newmember.action.value="create";
505  document.newmember.submit();
506  });
507  jQuery("#typeid").change(function() {
508  document.newmember.action.value="create";
509  document.newmember.submit();
510  });
511  });
512 });
513 </script>';
514 
515 
516 print '<table class="border" summary="form to subscribe" id="tablesubscribe">'."\n";
517 
518 // Type
519 if (empty($conf->global->MEMBER_NEWFORM_FORCETYPE)) {
520  $listoftype = $adht->liste_array();
521  $tmp = array_keys($listoftype);
522  $defaulttype = '';
523  $isempty = 1;
524  if (count($listoftype) == 1) {
525  $defaulttype = $tmp[0];
526  $isempty = 0;
527  }
528  print '<tr><td class="titlefield">'.$langs->trans("Type").' <span style="color: red">*</span></td><td>';
529  print $form->selectarray("typeid", $adht->liste_array(1), GETPOST('typeid') ? GETPOST('typeid') : $defaulttype, $isempty);
530  print '</td></tr>'."\n";
531 } else {
532  $adht->fetch($conf->global->MEMBER_NEWFORM_FORCETYPE);
533  print '<input type="hidden" id="typeid" name="typeid" value="'.$conf->global->MEMBER_NEWFORM_FORCETYPE.'">';
534 }
535 
536 // Moral/Physic attribute
537 $morphys["phy"] = $langs->trans("Physical");
538 $morphys["mor"] = $langs->trans("Moral");
539 if (empty($conf->global->MEMBER_NEWFORM_FORCEMORPHY)) {
540  print '<tr class="morphy"><td class="titlefield">'.$langs->trans('MemberNature').' <span style="color: red">*</span></td><td>'."\n";
541  print $form->selectarray("morphy", $morphys, GETPOST('morphy'), 1);
542  print '</td></tr>'."\n";
543 } else {
544  print $morphys[$conf->global->MEMBER_NEWFORM_FORCEMORPHY];
545  print '<input type="hidden" id="morphy" name="morphy" value="'.$conf->global->MEMBER_NEWFORM_FORCEMORPHY.'">';
546 }
547 
548 // Company
549 print '<tr id="trcompany" class="trcompany"><td>'.$langs->trans("Company").'</td><td>';
550 print img_picto('', 'company', 'class="pictofixedwidth"');
551 print '<input type="text" name="societe" class="minwidth150 widthcentpercentminusx" value="'.dol_escape_htmltag(GETPOST('societe')).'"></td></tr>'."\n";
552 // Title
553 print '<tr><td class="titlefield">'.$langs->trans('UserTitle').'</td><td>';
554 print $formcompany->select_civility(GETPOST('civility_id'), 'civility_id').'</td></tr>'."\n";
555 // Lastname
556 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";
557 // Firstname
558 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";
559 // EMail
560 print '<tr><td>'.$langs->trans("Email").($conf->global->ADHERENT_MAIL_REQUIRED ? ' <span style="color:red;">*</span>' : '').'</td><td>';
561 //print img_picto('', 'email', 'class="pictofixedwidth"');
562 print '<input type="text" name="email" maxlength="255" class="minwidth200" value="'.dol_escape_htmltag(GETPOST('email')).'"></td></tr>'."\n";
563 // Login
564 if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
565  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";
566  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";
567  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";
568 }
569 // Gender
570 print '<tr><td>'.$langs->trans("Gender").'</td>';
571 print '<td>';
572 $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman"));
573 print $form->selectarray('gender', $arraygender, GETPOST('gender') ?GETPOST('gender') : $object->gender, 1);
574 print '</td></tr>';
575 // Address
576 print '<tr><td>'.$langs->trans("Address").'</td><td>'."\n";
577 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";
578 // Zip / Town
579 print '<tr><td>'.$langs->trans('Zip').' / '.$langs->trans('Town').'</td><td>';
580 print $formcompany->select_ziptown(GETPOST('zipcode'), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 1, '', 'width75');
581 print ' / ';
582 print $formcompany->select_ziptown(GETPOST('town'), 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 1);
583 print '</td></tr>';
584 // Country
585 print '<tr><td>'.$langs->trans('Country').'</td><td>';
586 print img_picto('', 'country', 'class="pictofixedwidth"');
587 $country_id = GETPOST('country_id', 'int');
588 if (!$country_id && !empty($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE)) {
589  $country_id = getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs);
590 }
591 if (!$country_id && !empty($conf->geoipmaxmind->enabled)) {
592  $country_code = dol_user_country();
593  //print $country_code;
594  if ($country_code) {
595  $new_country_id = getCountry($country_code, 3, $db, $langs);
596  //print 'xxx'.$country_code.' - '.$new_country_id;
597  if ($new_country_id) {
598  $country_id = $new_country_id;
599  }
600  }
601 }
602 $country_code = getCountry($country_id, 2, $db, $langs);
603 print $form->select_country($country_id, 'country_id');
604 print '</td></tr>';
605 // State
606 if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
607  print '<tr><td>'.$langs->trans('State').'</td><td>';
608  if ($country_code) {
609  print $formcompany->select_state(GETPOST("state_id"), $country_code);
610  }
611  print '</td></tr>';
612 }
613 // Birthday
614 print '<tr id="trbirth" class="trbirth"><td>'.$langs->trans("DateOfBirth").'</td><td>';
615 print $form->selectDate($birthday, 'birth', 0, 0, 1, "newmember", 1, 0);
616 print '</td></tr>'."\n";
617 // Photo
618 print '<tr><td>'.$langs->trans("URLPhoto").'</td><td><input type="text" name="photo" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('photo')).'"></td></tr>'."\n";
619 // Public
620 print '<tr><td>'.$langs->trans("Public").'</td><td><input type="checkbox" name="public"></td></tr>'."\n";
621 // Other attributes
622 $tpl_context = 'public'; // define template context to public
623 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
624 // Comments
625 print '<tr>';
626 print '<td class="tdtop">'.$langs->trans("Comments").'</td>';
627 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>';
628 print '</tr>'."\n";
629 
630 // Add specific fields used by Dolibarr foundation for example
631 // TODO Move this into generic feature.
632 if (!empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER)) {
633  $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+');
634  print '<tr id="trbudget" class="trcompany"><td>'.$langs->trans("TurnoverOrBudget").' <span style="color: red">*</span></td><td>';
635  print $form->selectarray('budget', $arraybudget, GETPOST('budget'), 1);
636  print ' € or $';
637 
638  print '<script type="text/javascript">
639  jQuery(document).ready(function () {
640  initturnover();
641  jQuery("#morphy").click(function() {
642  initturnover();
643  });
644  jQuery("#budget").change(function() {
645  if (jQuery("#budget").val() > 0) { jQuery(".amount").val(jQuery("#budget").val()); }
646  else { jQuery("#budget").val(\'\'); }
647  });
648  /*jQuery("#typeid").change(function() {
649  if (jQuery("#typeid").val()==1) { jQuery("#morphy").val(\'mor\'); }
650  if (jQuery("#typeid").val()==2) { jQuery("#morphy").val(\'phy\'); }
651  if (jQuery("#typeid").val()==3) { jQuery("#morphy").val(\'mor\'); }
652  if (jQuery("#typeid").val()==4) { jQuery("#morphy").val(\'mor\'); }
653  initturnover();
654  });*/
655  function initturnover() {
656  if (jQuery("#morphy").val()==\'phy\') {
657  jQuery(".amount").val(20);
658  jQuery("#trbudget").hide();
659  jQuery("#trcompany").hide();
660  }
661  if (jQuery("#morphy").val()==\'mor\') {
662  jQuery(".amount").val(\'\');
663  jQuery("#trcompany").show();
664  jQuery("#trbirth").hide();
665  jQuery("#trbudget").show();
666  if (jQuery("#budget").val() > 0) { jQuery(".amount").val(jQuery("#budget").val()); }
667  else { jQuery("#budget").val(\'\'); }
668  }
669  }
670  });
671  </script>';
672  print '</td></tr>'."\n";
673 }
674 
675 if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) {
676  $amount = 0;
677  $typeid = $conf->global->MEMBER_NEWFORM_FORCETYPE ? $conf->global->MEMBER_NEWFORM_FORCETYPE : GETPOST('typeid', 'int');
678 
679  // Set amount for the subscription:
680  // - First check the amount of the member type.
681  $amountbytype = $adht->amountByType(1); // Load the array of amount per type
682  $amount = empty($amountbytype[$typeid]) ? (isset($amount) ? $amount : 0) : $amountbytype[$typeid];
683  // - If not found, take the default amount
684  if (empty($amount) && !empty($conf->global->MEMBER_NEWFORM_AMOUNT)) {
685  $amount = $conf->global->MEMBER_NEWFORM_AMOUNT;
686  }
687  // - If not set, we accept ot have amount defined as parameter (for backward compatibility).
688  if (empty($amount)) {
689  $amount = (GETPOST('amount') ? price2num(GETPOST('amount', 'alpha'), 'MT', 2) : '');
690  }
691 
692  // Clean the amount
693  $amount = price2num($amount);
694 
695  // $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe'
696  print '<tr><td>'.$langs->trans("Subscription").'</td><td class="nowrap">';
697  if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) {
698  print '<input type="text" name="amount" id="amount" class="flat amount width50" value="'.$amount.'">';
699  } else {
700  print '<input type="text" name="amount" id="amounthidden" class="flat amount width50" disabled value="'.$amount.'">';
701  print '<input type="hidden" name="amount" id="amount" class="flat amount" value="'.$amount.'">';
702  }
703  print ' '.$langs->trans("Currency".$conf->currency);
704  print '</td></tr>';
705 }
706 
707 print "</table>\n";
708 
709 print dol_get_fiche_end();
710 
711 // Save
712 print '<div class="center">';
713 print '<input type="submit" value="'.$langs->trans("Submit").'" id="submitsave" class="button">';
714 if (!empty($backtopage)) {
715  print ' &nbsp; &nbsp; <input type="submit" value="'.$langs->trans("Cancel").'" id="submitcancel" class="button button-cancel">';
716 }
717 print '</div>';
718 
719 
720 print "</form>\n";
721 print "<br>";
722 print '</div></div>';
723 
724 
726 
727 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Classe permettant la generation du formulaire html d&#39;envoi de mail unitaire Usage: $formail = new For...
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
Definition: card.php:142
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...
printCommonFooter($zone= 'private')
Print common footer : conf-&gt;global-&gt;MAIN_HTML_FOOTER js for switch of menu hider js for conf-&gt;global-...
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...
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...
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null)
Return array of possible common substitutions.
Class to build HTML component for third parties management Only common components are here...
Class to manage standard extra fields.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form...
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is &#39;...
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,$sendto,$replyto,$message,$filepath,$mimetype,$filename,$cc,$ccc,$deliveryreceipt,$msgishtml,$errors_to,$css,$trackid,$moreinheader,$sendcontext,$replyto); $mailfile-&gt;sendfile();.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it&#39;s its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
Class to manage members of a foundation.
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 ...
Class to manage translations.
dol_user_country()
Return country code for current user.
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 type.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
llxFooterVierge()
Footer function.
newToken()
Return the value of token currently saved into session with name &#39;newtoken&#39;.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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:1478
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=&gt;newva...
dol_htmloutput_errors($mesgstring= '', $mesgarray=array(), $keepembedded=0)
Print formated error messages to output (Used to show messages on html output).
getCountry($searchkey, $withcode= '', $dbtouse=0, $outputlangs= '', $entconv=1, $searchlabel= '')
Return country label, code or id from an id, code or label.
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 &quot;subst...