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 
31 if (!defined('NOLOGIN')) {
32  define("NOLOGIN", 1); // This means this output page does not require to be logged.
33 }
34 if (!defined('NOCSRFCHECK')) {
35  define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
36 }
37 if (!defined('NOIPCHECK')) {
38  define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
39 }
40 if (!defined('NOBROWSERNOTIF')) {
41  define('NOBROWSERNOTIF', '1');
42 }
43 if (!defined('NOIPCHECK')) {
44  define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
45 }
46 
47 // For MultiCompany module.
48 // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php
49 // TODO This should be useless. Because entity must be retrieve from object ref and not from url.
50 $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
51 if (is_numeric($entity)) {
52  define("DOLENTITY", $entity);
53 }
54 
55 require '../../main.inc.php';
56 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
57 require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php';
58 require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership_type.class.php';
59 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
60 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
61 
62 // Init vars
63 $errmsg = '';
64 $num = 0;
65 $error = 0;
66 $backtopage = GETPOST('backtopage', 'alpha');
67 $action = GETPOST('action', 'aZ09');
68 
69 // Load translation files
70 $langs->loadLangs(array("main", "members", "companies", "install", "other"));
71 
72 // Security check
73 if (empty($conf->partnership->enabled)) {
74  accessforbidden('', 0, 0, 1);
75 }
76 
77 if (empty($conf->global->PARTNERSHIP_ENABLE_PUBLIC)) {
78  print $langs->trans("Auto subscription form for public visitors has not been enabled");
79  exit;
80 }
81 
82 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
83 $hookmanager->initHooks(array('publicnewpartnershipcard', 'globalcard'));
84 
85 $extrafields = new ExtraFields($db);
86 
87 $object = new Partnership($db);
88 
89 $user->loadDefaultValues();
90 
91 
103 function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $arrayofjs = '', $arrayofcss = '')
104 {
105  global $user, $conf, $langs, $mysoc;
106 
107  top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers
108 
109  print '<body id="mainbody" class="publicnewmemberform">';
110 
111  // Define urllogo
112  $urllogo = DOL_URL_ROOT.'/theme/common/login_logo.png';
113 
114  if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) {
115  $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_small);
116  } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) {
117  $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/'.$mysoc->logo);
118  } elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.svg')) {
119  $urllogo = DOL_URL_ROOT.'/theme/dolibarr_logo.svg';
120  }
121 
122  print '<div class="center">';
123 
124  // Output html code for logo
125  if ($urllogo) {
126  print '<div class="backgreypublicpayment">';
127  print '<div class="logopublicpayment">';
128  print '<img id="dolpaymentlogo" src="'.$urllogo.'">';
129  print '</div>';
130  if (empty($conf->global->MAIN_HIDE_POWERED_BY)) {
131  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>';
132  }
133  print '</div>';
134  }
135 
136  if (!empty($conf->global->PARTNERSHIP_IMAGE_PUBLIC_REGISTRATION)) {
137  print '<div class="backimagepublicregistration">';
138  print '<img id="idPARTNERSHIP_IMAGE_PUBLIC_INTERFACE" src="'.$conf->global->PARTNERSHIP_IMAGE_PUBLIC_REGISTRATION.'">';
139  print '</div>';
140  }
141 
142  print '</div>';
143 
144  print '<div class="divmainbodylarge">';
145 }
146 
152 function llxFooterVierge()
153 {
154  print '</div>';
155 
156  printCommonFooter('public');
157 
158  print "</body>\n";
159  print "</html>\n";
160 }
161 
162 
163 
164 /*
165  * Actions
166  */
167 $parameters = array();
168 // Note that $action and $object may have been modified by some hooks
169 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);
170 if ($reshook < 0) {
171  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
172 }
173 
174 // Action called when page is submitted
175 if (empty($reshook) && $action == 'add') {
176  $error = 0;
177  $urlback = '';
178 
179  $db->begin();
180 
181  /*if (GETPOST('typeid') <= 0) {
182  $error++;
183  $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type"))."<br>\n";
184  }*/
185  if (!GETPOST('lastname')) {
186  $error++;
187  $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Lastname"))."<br>\n";
188  }
189  if (!GETPOST('firstname')) {
190  $error++;
191  $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Firstname"))."<br>\n";
192  }
193  if (empty(GETPOST('email'))) {
194  $error++;
195  $errmsg .= $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Email'))."<br>\n";
196  } elseif (GETPOST("email") && !isValidEmail(GETPOST("email"))) {
197  $langs->load('errors');
198  $error++;
199  $errmsg .= $langs->trans("ErrorBadEMail", GETPOST("email"))."<br>\n";
200  }
201 
202  $public = GETPOSTISSET('public') ? 1 : 0;
203 
204  if (!$error) {
205  $partnership = new Partnership($db);
206 
207  // We try to find the thirdparty or the member
208  if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty') == 'thirdparty') {
209  $partnership->fk_member = 0;
210  } elseif (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty') == 'member') {
211  $partnership->fk_soc = 0;
212  }
213 
214  $partnership->statut = -1;
215  $partnership->firstname = GETPOST('firstname');
216  $partnership->lastname = GETPOST('lastname');
217  $partnership->address = GETPOST('address');
218  $partnership->zip = GETPOST('zipcode');
219  $partnership->town = GETPOST('town');
220  $partnership->email = GETPOST('email');
221  $partnership->country_id = GETPOST('country_id', 'int');
222  $partnership->state_id = GETPOST('state_id', 'int');
223  //$partnership->typeid = $conf->global->PARTNERSHIP_NEWFORM_FORCETYPE ? $conf->global->PARTNERSHIP_NEWFORM_FORCETYPE : GETPOST('typeid', 'int');
224  $partnership->note_private = GETPOST('note_private');
225 
226  // Fill array 'array_options' with data from add form
227  $extrafields->fetch_name_optionals_label($partnership->table_element);
228  $ret = $extrafields->setOptionalsFromPost(null, $partnership);
229  if ($ret < 0) {
230  $error++;
231  }
232 
233  $result = $partnership->create($user);
234  if ($result > 0) {
235  require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
236  $object = $partnership;
237 
238  /*
239  $partnershipt = new PartnershipType($db);
240  $partnershipt->fetch($object->typeid);
241 
242  if ($object->email) {
243  $subject = '';
244  $msg = '';
245 
246  // Send subscription email
247  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
248  $formmail = new FormMail($db);
249  // Set output language
250  $outputlangs = new Translate('', $conf);
251  $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
252  // Load traductions files required by page
253  $outputlangs->loadLangs(array("main", "members"));
254  // Get email content from template
255  $arraydefaultmessage = null;
256  $labeltouse = $conf->global->PARTNERSHIP_EMAIL_TEMPLATE_AUTOREGISTER;
257 
258  if (!empty($labeltouse)) {
259  $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
260  }
261 
262  if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
263  $subject = $arraydefaultmessage->topic;
264  $msg = $arraydefaultmessage->content;
265  }
266 
267  $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
268  complete_substitutions_array($substitutionarray, $outputlangs, $object);
269  $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
270  $texttosend = make_substitutions(dol_concatdesc($msg, $partnershipt->getMailOnValid()), $substitutionarray, $outputlangs);
271 
272  if ($subjecttosend && $texttosend) {
273  $moreinheader = 'X-Dolibarr-Info: send_an_email by public/members/new.php'."\r\n";
274 
275  $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader);
276  }
277  }
278  */
279 
280  // Send email to the foundation to say a new member subscribed with autosubscribe form
281  if (getDolGlobalString('MAIN_INFO_SOCIETE_MAIL') && !empty($conf->global->PARTNERSHIP_AUTOREGISTER_NOTIF_MAIL_SUBJECT) &&
282  !empty($conf->global->PARTNERSHIP_AUTOREGISTER_NOTIF_MAIL)) {
283  // Define link to login card
284  $appli = constant('DOL_APPLICATION_TITLE');
285  if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
286  $appli = $conf->global->MAIN_APPLICATION_TITLE;
287  if (preg_match('/\d\.\d/', $appli)) {
288  if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) {
289  $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core
290  }
291  } else {
292  $appli .= " ".DOL_VERSION;
293  }
294  } else {
295  $appli .= " ".DOL_VERSION;
296  }
297 
298  $to = $partnership->makeSubstitution(getDolGlobalString('MAIN_INFO_SOCIETE_MAIL'));
299  $from = getDolGlobalString('PARTNERSHIP_MAIL_FROM');
300  $mailfile = new CMailFile(
301  '['.$appli.'] '.getDolGlobalString('PARTNERSHIP_AUTOREGISTER_NOTIF_MAIL_SUBJECT', 'Partnership request'),
302  $to,
303  $from,
304  $partnership->makeSubstitution(getDolGlobalString('PARTNERSHIP_AUTOREGISTER_NOTIF_MAIL')),
305  array(),
306  array(),
307  array(),
308  "",
309  "",
310  0,
311  -1
312  );
313 
314  if (!$mailfile->sendfile()) {
315  dol_syslog($langs->trans("ErrorFailedToSendMail", $from, $to), LOG_ERR);
316  }
317  }
318 
319  if (!empty($backtopage)) {
320  $urlback = $backtopage;
321  } elseif (!empty($conf->global->PARTNERSHIP_URL_REDIRECT_SUBSCRIPTION)) {
322  $urlback = $conf->global->PARTNERSHIP_URL_REDIRECT_SUBSCRIPTION;
323  // TODO Make replacement of __AMOUNT__, etc...
324  } else {
325  $urlback = $_SERVER["PHP_SELF"]."?action=added&token=".newToken();
326  }
327 
328  if (!empty($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE) && $conf->global->PARTNERSHIP_NEWFORM_PAYONLINE != '-1') {
329  if ($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE == 'all') {
330  $urlback = DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?from=partnershipnewform&source=membersubscription&ref='.urlencode($partnership->ref);
331  if (price2num(GETPOST('amount', 'alpha'))) {
332  $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha'));
333  }
334  if (GETPOST('email')) {
335  $urlback .= '&email='.urlencode(GETPOST('email'));
336  }
337  if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
338  if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
339  $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$partnership->ref, 2));
340  } else {
341  $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
342  }
343  }
344  } elseif ($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE == 'paybox') {
345  $urlback = DOL_MAIN_URL_ROOT.'/public/paybox/newpayment.php?from=partnershipnewform&source=membersubscription&ref='.urlencode($partnership->ref);
346  if (price2num(GETPOST('amount', 'alpha'))) {
347  $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha'));
348  }
349  if (GETPOST('email')) {
350  $urlback .= '&email='.urlencode(GETPOST('email'));
351  }
352  if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
353  if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
354  $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$partnership->ref, 2));
355  } else {
356  $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
357  }
358  }
359  } elseif ($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE == 'paypal') {
360  $urlback = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?from=partnershipnewform&source=membersubscription&ref='.urlencode($partnership->ref);
361  if (price2num(GETPOST('amount', 'alpha'))) {
362  $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha'));
363  }
364  if (GETPOST('email')) {
365  $urlback .= '&email='.urlencode(GETPOST('email'));
366  }
367  if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
368  if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
369  $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$partnership->ref, 2));
370  } else {
371  $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
372  }
373  }
374  } elseif ($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE == 'stripe') {
375  $urlback = DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?from=partnershipnewform&source=membersubscription&ref='.$partnership->ref;
376  if (price2num(GETPOST('amount', 'alpha'))) {
377  $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha'));
378  }
379  if (GETPOST('email')) {
380  $urlback .= '&email='.urlencode(GETPOST('email'));
381  }
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'.$partnership->ref, 2));
385  } else {
386  $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
387  }
388  }
389  } else {
390  dol_print_error('', "Autosubscribe form is setup to ask an online payment for a not managed online payment");
391  exit;
392  }
393  }
394 
395  if (!empty($entity)) {
396  $urlback .= '&entity='.$entity;
397  }
398  dol_syslog("partnership ".$partnership->ref." was created, we redirect to ".$urlback);
399  } else {
400  $error++;
401  $errmsg .= join('<br>', $partnership->errors);
402  }
403  }
404 
405  if (!$error) {
406  $db->commit();
407 
408  Header("Location: ".$urlback);
409  exit;
410  } else {
411  $db->rollback();
412  }
413 }
414 
415 // Action called after a submitted was send and member created successfully
416 // If PARTNERSHIP_URL_REDIRECT_SUBSCRIPTION is set to url we never go here because a redirect was done to this url.
417 // backtopage parameter with an url was set on member submit page, we never go here because a redirect was done to this url.
418 if (empty($reshook) && $action == 'added') {
419  llxHeaderVierge($langs->trans("NewPartnershipForm"));
420 
421  // Si on a pas ete redirige
422  print '<br><br>';
423  print '<div class="center">';
424  print $langs->trans("NewPartnershipbyWeb");
425  print '</div>';
426 
427  llxFooterVierge();
428  exit;
429 }
430 
431 
432 
433 /*
434  * View
435  */
436 
437 $form = new Form($db);
438 $formcompany = new FormCompany($db);
439 
440 $extrafields->fetch_name_optionals_label($partnership->table_element); // fetch optionals attributes and labels
441 
442 
443 llxHeaderVierge($langs->trans("NewPartnershipRequest"));
444 
445 
446 print load_fiche_titre($langs->trans("NewPartnershipRequest"), '', '', 0, 0, 'center');
447 
448 
449 print '<div align="center">';
450 print '<div id="divsubscribe">';
451 
452 print '<div class="center subscriptionformhelptext justify">';
453 if (!empty($conf->global->PARTNERSHIP_NEWFORM_TEXT)) {
454  print $langs->trans($conf->global->PARTNERSHIP_NEWFORM_TEXT)."<br>\n";
455 } else {
456  print $langs->trans("NewPartnershipRequestDesc", $conf->global->MAIN_INFO_SOCIETE_MAIL)."<br>\n";
457 }
458 print '</div>';
459 
460 dol_htmloutput_errors($errmsg);
461 
462 // Print form
463 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" name="newmember">'."\n";
464 print '<input type="hidden" name="token" value="'.newToken().'" / >';
465 print '<input type="hidden" name="entity" value="'.$entity.'" />';
466 print '<input type="hidden" name="action" value="add" />';
467 
468 print '<br>';
469 
470 print '<br><span class="opacitymedium">'.$langs->trans("FieldsWithAreMandatory", '*').'</span><br>';
471 //print $langs->trans("FieldsWithIsForPublic",'**').'<br>';
472 
473 print dol_get_fiche_head('');
474 
475 print '<script type="text/javascript">
476 jQuery(document).ready(function () {
477  jQuery(document).ready(function () {
478  jQuery("#selectcountry_id").change(function() {
479  document.newmember.action.value="create";
480  document.newmember.submit();
481  });
482  });
483 });
484 </script>';
485 
486 
487 print '<table class="border" summary="form to subscribe" id="tablesubscribe">'."\n";
488 
489 // Type
490 /*
491 if (empty($conf->global->PARTNERSHIP_NEWFORM_FORCETYPE)) {
492  $listoftype = $partnershipt->liste_array();
493  $tmp = array_keys($listoftype);
494  $defaulttype = '';
495  $isempty = 1;
496  if (count($listoftype) == 1) {
497  $defaulttype = $tmp[0];
498  $isempty = 0;
499  }
500  print '<tr><td class="titlefield">'.$langs->trans("Type").' <span style="color: red">*</span></td><td>';
501  print $form->selectarray("typeid", $partnershipt->liste_array(1), GETPOST('typeid') ? GETPOST('typeid') : $defaulttype, $isempty);
502  print '</td></tr>'."\n";
503 } else {
504  $partnershipt->fetch($conf->global->PARTNERSHIP_NEWFORM_FORCETYPE);
505  print '<input type="hidden" id="typeid" name="typeid" value="'.$conf->global->PARTNERSHIP_NEWFORM_FORCETYPE.'">';
506 }
507 */
508 
509 $partnershiptype = new PartnershipType($db);
510 $listofpartnershipobj = $partnershiptype->fetchAll('', '', 1000);
511 $listofpartnership = array();
512 foreach ($listofpartnershipobj as $partnershipobj) {
513  $listofpartnership[$partnershipobj->id] = $partnershipobj->label;
514 }
515 
516 if (empty($conf->global->PARTNERSHIP_NEWFORM_FORCETYPE)) {
517  print '<tr class="morphy"><td class="titlefield">'.$langs->trans('PartnershipType').' <span style="color: red">*</span></td><td>'."\n";
518  print $form->selectarray("partnershiptype", $listofpartnership, GETPOSTISSET('partnershiptype') ? GETPOST('partnershiptype', 'int') : 'ifone', 1);
519  print '</td></tr>'."\n";
520 } else {
521  print $listofpartnership[$conf->global->PARTNERSHIP_NEWFORM_FORCETYPE];
522  print '<input type="hidden" id="partnershiptype" name="partnershiptype" value="'.$conf->global->PARTNERSHIP_NEWFORM_FORCETYPE.'">';
523 }
524 
525 // Company
526 print '<tr id="trcompany" class="trcompany"><td>'.$langs->trans("Company").' <span style="color:red;">*</span></td><td>';
527 print img_picto('', 'company', 'class="pictofixedwidth"');
528 print '<input type="text" name="societe" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('societe')).'"></td></tr>'."\n";
529 // Lastname
530 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";
531 // Firstname
532 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";
533 // EMail
534 print '<tr><td>'.$langs->trans("Email").' <span style="color:red;">*</span></td><td>';
535 //print img_picto('', 'email', 'class="pictofixedwidth"');
536 print '<input type="text" name="email" maxlength="255" class="minwidth200" value="'.dol_escape_htmltag(GETPOST('email')).'"></td></tr>'."\n";
537 // Address
538 print '<tr><td>'.$langs->trans("Address").'</td><td>'."\n";
539 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";
540 // Zip / Town
541 print '<tr><td>'.$langs->trans('Zip').' / '.$langs->trans('Town').'</td><td>';
542 print $formcompany->select_ziptown(GETPOST('zipcode'), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6, 1);
543 print ' / ';
544 print $formcompany->select_ziptown(GETPOST('town'), 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 1);
545 print '</td></tr>';
546 // Country
547 print '<tr><td>'.$langs->trans('Country').'</td><td>';
548 print img_picto('', 'country', 'class="pictofixedwidth"');
549 $country_id = GETPOST('country_id', 'int');
550 if (!$country_id && !empty($conf->global->PARTNERSHIP_NEWFORM_FORCECOUNTRYCODE)) {
551  $country_id = getCountry($conf->global->PARTNERSHIP_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs);
552 }
553 if (!$country_id && !empty($conf->geoipmaxmind->enabled)) {
554  $country_code = dol_user_country();
555  //print $country_code;
556  if ($country_code) {
557  $new_country_id = getCountry($country_code, 3, $db, $langs);
558  //print 'xxx'.$country_code.' - '.$new_country_id;
559  if ($new_country_id) {
560  $country_id = $new_country_id;
561  }
562  }
563 }
564 $country_code = getCountry($country_id, 2, $db, $langs);
565 print $form->select_country($country_id, 'country_id');
566 print '</td></tr>';
567 // State
568 if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
569  print '<tr><td>'.$langs->trans('State').'</td><td>';
570  if ($country_code) {
571  print $formcompany->select_state(GETPOST("state_id"), $country_code);
572  }
573  print '</td></tr>';
574 }
575 // Logo
576 //print '<tr><td>'.$langs->trans("URLPhoto").'</td><td><input type="text" name="photo" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('photo')).'"></td></tr>'."\n";
577 // Other attributes
578 $tpl_context = 'public'; // define template context to public
579 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
580 // Comments
581 print '<tr>';
582 print '<td class="tdtop">'.$langs->trans("Comments").'</td>';
583 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>';
584 print '</tr>'."\n";
585 
586 print "</table>\n";
587 
588 print dol_get_fiche_end();
589 
590 // Save
591 print '<div class="center">';
592 print '<input type="submit" value="'.$langs->trans("Submit").'" id="submitsave" class="button">';
593 if (!empty($backtopage)) {
594  print ' &nbsp; &nbsp; <input type="submit" value="'.$langs->trans("Cancel").'" id="submitcancel" class="button button-cancel">';
595 }
596 print '</div>';
597 
598 
599 print "</form>\n";
600 print "<br>";
601 print '</div></div>';
602 
603 
605 
606 $db->close();
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_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
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
Partnership
Class for Partnership.
Definition: partnership.class.php:34
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
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
dol_hash
dol_hash($chain, $type='0')
Returns a hash of a string.
Definition: security.lib.php:104
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
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1603
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
getDolGlobalString
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
Definition: functions.lib.php:80
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
PartnershipType
Class to manage partnership type.
Definition: partnership_type.class.php:35