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