dolibarr  x.y.z
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 
44 
45 // For MultiCompany module.
46 // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php
47 // TODO This should be useless. Because entity must be retrieve from object ref and not from url.
48 $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
49 if (is_numeric($entity)) {
50  define("DOLENTITY", $entity);
51 }
52 
53 // Load Dolibarr environment
54 require '../../main.inc.php';
55 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
56 require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php';
57 require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership_type.class.php';
58 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
59 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
60 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.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", "partnership", "companies", "install", "other"));
71 
72 // Security check
73 if (empty($conf->partnership->enabled)) {
74  httponly_accessforbidden('Module Partnership not enabled');
75 }
76 
77 if (empty($conf->global->PARTNERSHIP_ENABLE_PUBLIC)) {
78  httponly_accessforbidden("Auto subscription form for public visitors has not been enabled");
79 }
80 
81 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
82 $hookmanager->initHooks(array('publicnewpartnershipcard', 'globalcard'));
83 
84 $extrafields = new ExtraFields($db);
85 
86 $object = new Partnership($db);
87 
88 $user->loadDefaultValues();
89 
90 
102 function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $arrayofjs = '', $arrayofcss = '')
103 {
104  global $user, $conf, $langs, $mysoc;
105 
106  top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers
107 
108  print '<body id="mainbody" class="publicnewmemberform">';
109 
110  // Define urllogo
111  $urllogo = DOL_URL_ROOT.'/theme/common/login_logo.png';
112 
113  if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) {
114  $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_small);
115  } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) {
116  $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/'.$mysoc->logo);
117  } elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.svg')) {
118  $urllogo = DOL_URL_ROOT.'/theme/dolibarr_logo.svg';
119  }
120 
121  print '<div class="center">';
122 
123  // Output html code for logo
124  if ($urllogo) {
125  print '<div class="backgreypublicpayment">';
126  print '<div class="logopublicpayment">';
127  print '<img id="dolpaymentlogo" src="'.$urllogo.'">';
128  print '</div>';
129  if (empty($conf->global->MAIN_HIDE_POWERED_BY)) {
130  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>';
131  }
132  print '</div>';
133  }
134 
135  if (!empty($conf->global->PARTNERSHIP_IMAGE_PUBLIC_REGISTRATION)) {
136  print '<div class="backimagepublicregistration">';
137  print '<img id="idPARTNERSHIP_IMAGE_PUBLIC_INTERFACE" src="'.$conf->global->PARTNERSHIP_IMAGE_PUBLIC_REGISTRATION.'">';
138  print '</div>';
139  }
140 
141  print '</div>';
142 
143  print '<div class="divmainbodylarge">';
144 }
145 
151 function llxFooterVierge()
152 {
153  print '</div>';
154 
155  printCommonFooter('public');
156 
157  print "</body>\n";
158  print "</html>\n";
159 }
160 
161 
162 
163 /*
164  * Actions
165  */
166 $parameters = array();
167 // Note that $action and $object may have been modified by some hooks
168 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);
169 if ($reshook < 0) {
170  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
171 }
172 
173 // Action called when page is submitted
174 if (empty($reshook) && $action == 'add') {
175  $error = 0;
176  $urlback = '';
177 
178  $db->begin();
179 
180  if (GETPOST('partnershiptype', 'int') <= 0) {
181  $error++;
182  $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type"))."<br>\n";
183  }
184  if (!GETPOST('societe')) {
185  $error++;
186  $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("societe"))."<br>\n";
187  }
188  if (!GETPOST('lastname')) {
189  $error++;
190  $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Lastname"))."<br>\n";
191  }
192  if (!GETPOST('firstname')) {
193  $error++;
194  $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Firstname"))."<br>\n";
195  }
196 
197  if (empty(GETPOST('email'))) {
198  $error++;
199  $errmsg .= $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Email'))."<br>\n";
200  } elseif (GETPOST("email") && !isValidEmail(GETPOST("email"))) {
201  $langs->load('errors');
202  $error++;
203  $errmsg .= $langs->trans("ErrorBadEMail", GETPOST("email"))."<br>\n";
204  }
205 
206  $public = GETPOSTISSET('public') ? 1 : 0;
207 
208  if (!$error) {
209  $partnership = new Partnership($db);
210 
211  // We try to find the thirdparty or the member
212  if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty') == 'thirdparty') {
213  $partnership->fk_member = 0;
214  } elseif (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty') == 'member') {
215  $partnership->fk_soc = 0;
216  }
217 
218  $partnership->status = 0;
219  $partnership->note_private = GETPOST('note_private');
220  $partnership->date_creation = dol_now();
221  $partnership->date_partnership_start = dol_now();
222  $partnership->fk_user_creat = 0;
223  $partnership->fk_type = GETPOST('partnershiptype', 'int');
224  //$partnership->typeid = $conf->global->PARTNERSHIP_NEWFORM_FORCETYPE ? $conf->global->PARTNERSHIP_NEWFORM_FORCETYPE : GETPOST('typeid', 'int');
225  $partnership->ip = getUserRemoteIP();
226 
227  $nb_post_max = getDolGlobalInt("MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
228  $now = dol_now();
229  $minmonthpost = dol_time_plus_duree($now, -1, "m");
230  // Calculate nb of post for IP
231  $nb_post_ip = 0;
232  if ($nb_post_max > 0) { // Calculate only if there is a limit to check
233  $sql = "SELECT COUNT(ref) as nb_partnerships";
234  $sql .= " FROM ".MAIN_DB_PREFIX."partnership";
235  $sql .= " WHERE ip = '".$db->escape($partnership->ip)."'";
236  $sql .= " AND date_creation > '".$db->idate($minmonthpost)."'";
237  $resql = $db->query($sql);
238  if ($resql) {
239  $num = $db->num_rows($resql);
240  $i = 0;
241  while ($i < $num) {
242  $i++;
243  $obj = $db->fetch_object($resql);
244  $nb_post_ip = $obj->nb_partnerships;
245  }
246  }
247  }
248  // test if societe already exist
249  $company = new Societe($db);
250  $result = $company->fetch(0, GETPOST('societe'));
251  if ($result == 0) { // si il ya pas d'entree sur le nom on teste l'email
252  $result1 = $company->fetch(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, GETPOST('email'));
253  if ($result1 > 0) {
254  $error++;
255  $errmsg = $langs->trans("EmailAlreadyExistsPleaseRewriteYourCompanyName");
256  } else {
257  //create thirdparty
258  $company = new Societe($db);
259 
260  $company->name = GETPOST('societe');
261  $company->address = GETPOST('address');
262  $company->zip = GETPOST('zipcode');
263  $company->town = GETPOST('town');
264  $company->email = GETPOST('email');
265  $company->country_id = GETPOST('country_id', 'int');
266  $company->state_id = GETPOST('state_id', 'int');
267  $company->name_alias = dolGetFirstLastname(GETPOST('firstname'), GETPOST('lastname'));
268 
269  $resultat=$company->create($user);
270  if ($resultat < 0) {
271  $error++;
272  $errmsg .= join('<br>', $company->errors);
273  }
274 
275  $partnership->fk_soc = $company->id;
276  }
277  } elseif ($result == -2) {
278  $error++;
279  $errmsg = $langs->trans("TwoRecordsOfCompanyName");
280  } else {
281  $partnership->fk_soc = $company->id;
282  // update thirdparty fields
283  if (empty($company->address)) {
284  $company->address = GETPOST('address');
285  }
286  if (empty($company->zip)) {
287  $company->zip = GETPOST('zipcode');
288  }
289  if (empty($company->town)) {
290  $company->town = GETPOST('town');
291  }
292  if (empty($company->country_id)) {
293  $company->country_id = GETPOST('country_id', 'int');
294  }
295  if (empty($company->email)) {
296  $company->email = GETPOST('email');
297  }
298  if (empty($company->state_id)) {
299  $company->state_id = GETPOST('state_id', 'int');
300  }
301  if (empty($company->name_alias)) {
302  $company->name_alias = dolGetFirstLastname(GETPOST('firstname'), GETPOST('lastname'));
303  }
304  $company->update(0);
305  }
306 
307  // Fill array 'array_options' with data from add form
308  $extrafields->fetch_name_optionals_label($partnership->table_element);
309  $ret = $extrafields->setOptionalsFromPost(null, $partnership);
310  if ($ret < 0) {
311  $error++;
312  }
313 
314  if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
315  $error++;
316  $errmsg = $langs->trans("AlreadyTooMuchPostOnThisIPAdress");
317  array_push($partnership->errors, $langs->trans("AlreadyTooMuchPostOnThisIPAdress"));
318  }
319  if (!$error) {
320  $result = $partnership->create($user);
321  if ($result > 0) {
322  /*
323  require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
324  $object = $partnership;
325 
326 
327  $partnershipt = new PartnershipType($db);
328  $partnershipt->fetch($object->typeid);
329 
330  if ($object->email) {
331  $subject = '';
332  $msg = '';
333 
334  // Send subscription email
335  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
336  $formmail = new FormMail($db);
337  // Set output language
338  $outputlangs = new Translate('', $conf);
339  $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
340  // Load traductions files required by page
341  $outputlangs->loadLangs(array("main", "members"));
342  // Get email content from template
343  $arraydefaultmessage = null;
344  $labeltouse = $conf->global->PARTNERSHIP_EMAIL_TEMPLATE_AUTOREGISTER;
345 
346  if (!empty($labeltouse)) {
347  $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
348  }
349 
350  if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
351  $subject = $arraydefaultmessage->topic;
352  $msg = $arraydefaultmessage->content;
353  }
354 
355  $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
356  complete_substitutions_array($substitutionarray, $outputlangs, $object);
357  $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
358  $texttosend = make_substitutions(dol_concatdesc($msg, $partnershipt->getMailOnValid()), $substitutionarray, $outputlangs);
359 
360  if ($subjecttosend && $texttosend) {
361  $moreinheader = 'X-Dolibarr-Info: send_an_email by public/members/new.php'."\r\n";
362 
363  $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader);
364  }
365  }
366 
367 
368  // Send email to the foundation to say a new member subscribed with autosubscribe form
369  /*
370  if (getDolGlobalString('MAIN_INFO_SOCIETE_MAIL') && !empty($conf->global->PARTNERSHIP_AUTOREGISTER_NOTIF_MAIL_SUBJECT) &&
371  !empty($conf->global->PARTNERSHIP_AUTOREGISTER_NOTIF_MAIL)) {
372  // Define link to login card
373  $appli = constant('DOL_APPLICATION_TITLE');
374  if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
375  $appli = $conf->global->MAIN_APPLICATION_TITLE;
376  if (preg_match('/\d\.\d/', $appli)) {
377  if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) {
378  $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core
379  }
380  } else {
381  $appli .= " ".DOL_VERSION;
382  }
383  } else {
384  $appli .= " ".DOL_VERSION;
385  }
386 
387  $to = $partnership->makeSubstitution(getDolGlobalString('MAIN_INFO_SOCIETE_MAIL'));
388  $from = getDolGlobalString('PARTNERSHIP_MAIL_FROM');
389  $mailfile = new CMailFile(
390  '['.$appli.'] '.getDolGlobalString('PARTNERSHIP_AUTOREGISTER_NOTIF_MAIL_SUBJECT', 'Partnership request'),
391  $to,
392  $from,
393  $partnership->makeSubstitution(getDolGlobalString('PARTNERSHIP_AUTOREGISTER_NOTIF_MAIL')),
394  array(),
395  array(),
396  array(),
397  "",
398  "",
399  0,
400  -1
401  );
402 
403  if (!$mailfile->sendfile()) {
404  dol_syslog($langs->trans("ErrorFailedToSendMail", $from, $to), LOG_ERR);
405  }
406  }*/
407 
408  if (!empty($backtopage)) {
409  $urlback = $backtopage;
410  } elseif (!empty($conf->global->PARTNERSHIP_URL_REDIRECT_SUBSCRIPTION)) {
411  $urlback = $conf->global->PARTNERSHIP_URL_REDIRECT_SUBSCRIPTION;
412  // TODO Make replacement of __AMOUNT__, etc...
413  } else {
414  $urlback = $_SERVER["PHP_SELF"]."?action=added&token=".newToken();
415  }
416 
417  /*
418  if (!empty($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE) && $conf->global->PARTNERSHIP_NEWFORM_PAYONLINE != '-1') {
419  if ($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE == 'all') {
420  $urlback = DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?from=partnershipnewform&source=membersubscription&ref='.urlencode($partnership->ref);
421  if (price2num(GETPOST('amount', 'alpha'))) {
422  $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha'));
423  }
424  if (GETPOST('email')) {
425  $urlback .= '&email='.urlencode(GETPOST('email'));
426  }
427  if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
428  if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
429  $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$partnership->ref, 2));
430  } else {
431  $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
432  }
433  }
434  } elseif ($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE == 'paybox') {
435  $urlback = DOL_MAIN_URL_ROOT.'/public/paybox/newpayment.php?from=partnershipnewform&source=membersubscription&ref='.urlencode($partnership->ref);
436  if (price2num(GETPOST('amount', 'alpha'))) {
437  $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha'));
438  }
439  if (GETPOST('email')) {
440  $urlback .= '&email='.urlencode(GETPOST('email'));
441  }
442  if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
443  if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
444  $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$partnership->ref, 2));
445  } else {
446  $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
447  }
448  }
449  } elseif ($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE == 'paypal') {
450  $urlback = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?from=partnershipnewform&source=membersubscription&ref='.urlencode($partnership->ref);
451  if (price2num(GETPOST('amount', 'alpha'))) {
452  $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha'));
453  }
454  if (GETPOST('email')) {
455  $urlback .= '&email='.urlencode(GETPOST('email'));
456  }
457  if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
458  if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
459  $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$partnership->ref, 2));
460  } else {
461  $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
462  }
463  }
464  } elseif ($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE == 'stripe') {
465  $urlback = DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?from=partnershipnewform&source=membersubscription&ref='.$partnership->ref;
466  if (price2num(GETPOST('amount', 'alpha'))) {
467  $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha'));
468  }
469  if (GETPOST('email')) {
470  $urlback .= '&email='.urlencode(GETPOST('email'));
471  }
472  if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
473  if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
474  $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$partnership->ref, 2));
475  } else {
476  $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
477  }
478  }
479  } else {
480  dol_print_error('', "Autosubscribe form is setup to ask an online payment for a not managed online payment");
481  exit;
482  }
483  }*/
484 
485  if (!empty($entity)) {
486  $urlback .= '&entity='.$entity;
487  }
488  dol_syslog("partnership ".$partnership->ref." was created, we redirect to ".$urlback);
489  } else {
490  $error++;
491  $errmsg .= join('<br>', $partnership->errors);
492  }
493  } else {
494  setEventMessage($errmsg, 'errors');
495  }
496  }
497 
498  if (!$error) {
499  $db->commit();
500 
501  Header("Location: ".$urlback);
502  exit;
503  } else {
504  $db->rollback();
505  }
506 }
507 
508 // Action called after a submitted was send and member created successfully
509 // If PARTNERSHIP_URL_REDIRECT_SUBSCRIPTION is set to url we never go here because a redirect was done to this url.
510 // backtopage parameter with an url was set on member submit page, we never go here because a redirect was done to this url.
511 if (empty($reshook) && $action == 'added') {
512  llxHeaderVierge($langs->trans("NewPartnershipForm"));
513 
514  // Si on a pas ete redirige
515  print '<br><br>';
516  print '<div class="center">';
517  print $langs->trans("NewPartnershipbyWeb");
518  print '</div>';
519 
520  llxFooterVierge();
521  exit;
522 }
523 
524 
525 
526 /*
527  * View
528  */
529 
530 $form = new Form($db);
531 $formcompany = new FormCompany($db);
532 
533 $extrafields->fetch_name_optionals_label($object->table_element); // fetch optionals attributes and labels
534 
535 
536 llxHeaderVierge($langs->trans("NewPartnershipRequest"));
537 
538 
539 print load_fiche_titre($langs->trans("NewPartnershipRequest"), '', '', 0, 0, 'center');
540 
541 
542 print '<div align="center">';
543 print '<div id="divsubscribe">';
544 
545 print '<div class="center subscriptionformhelptext justify">';
546 if (!empty($conf->global->PARTNERSHIP_NEWFORM_TEXT)) {
547  print $langs->trans($conf->global->PARTNERSHIP_NEWFORM_TEXT)."<br>\n";
548 } else {
549  print $langs->trans("NewPartnershipRequestDesc", getDolGlobalString("MAIN_INFO_SOCIETE_MAIL"))."<br>\n";
550 }
551 print '</div>';
552 
553 dol_htmloutput_errors($errmsg);
554 
555 // Print form
556 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" name="newmember">'."\n";
557 print '<input type="hidden" name="token" value="'.newToken().'" / >';
558 print '<input type="hidden" name="entity" value="'.$entity.'" />';
559 print '<input type="hidden" name="action" value="add" />';
560 
561 print '<br>';
562 
563 print '<br><span class="opacitymedium">'.$langs->trans("FieldsWithAreMandatory", '*').'</span><br>';
564 //print $langs->trans("FieldsWithIsForPublic",'**').'<br>';
565 
566 print dol_get_fiche_head('');
567 
568 print '<script type="text/javascript">
569 jQuery(document).ready(function () {
570  jQuery(document).ready(function () {
571  jQuery("#selectcountry_id").change(function() {
572  document.newmember.action.value="create";
573  document.newmember.submit();
574  });
575  });
576 });
577 </script>';
578 
579 
580 print '<table class="border" summary="form to subscribe" id="tablesubscribe">'."\n";
581 
582 // Type
583 /*
584 if (empty($conf->global->PARTNERSHIP_NEWFORM_FORCETYPE)) {
585  $listoftype = $partnershipt->liste_array();
586  $tmp = array_keys($listoftype);
587  $defaulttype = '';
588  $isempty = 1;
589  if (count($listoftype) == 1) {
590  $defaulttype = $tmp[0];
591  $isempty = 0;
592  }
593  print '<tr><td class="titlefield">'.$langs->trans("Type").' <span style="color: red">*</span></td><td>';
594  print $form->selectarray("typeid", $partnershipt->liste_array(1), GETPOST('typeid') ? GETPOST('typeid') : $defaulttype, $isempty);
595  print '</td></tr>'."\n";
596 } else {
597  $partnershipt->fetch($conf->global->PARTNERSHIP_NEWFORM_FORCETYPE);
598  print '<input type="hidden" id="typeid" name="typeid" value="'.$conf->global->PARTNERSHIP_NEWFORM_FORCETYPE.'">';
599 }
600 */
601 
602 $partnershiptype = new PartnershipType($db);
603 $listofpartnershipobj = $partnershiptype->fetchAll('', '', 1000);
604 $listofpartnership = array();
605 foreach ($listofpartnershipobj as $partnershipobj) {
606  $listofpartnership[$partnershipobj->id] = $partnershipobj->label;
607 }
608 
609 if (empty($conf->global->PARTNERSHIP_NEWFORM_FORCETYPE)) {
610  print '<tr class="morphy"><td class="titlefield">'.$langs->trans('PartnershipType').' <span style="color: red">*</span></td><td>'."\n";
611  print $form->selectarray("partnershiptype", $listofpartnership, GETPOSTISSET('partnershiptype') ? GETPOST('partnershiptype', 'int') : 'ifone', 1);
612  print '</td></tr>'."\n";
613 } else {
614  print $listofpartnership[$conf->global->PARTNERSHIP_NEWFORM_FORCETYPE];
615  print '<input type="hidden" id="partnershiptype" name="partnershiptype" value="'.$conf->global->PARTNERSHIP_NEWFORM_FORCETYPE.'">';
616 }
617 
618 // Company
619 print '<tr id="trcompany" class="trcompany"><td>'.$langs->trans("Company").' <span style="color:red;">*</span></td><td>';
620 print img_picto('', 'company', 'class="pictofixedwidth"');
621 print '<input type="text" name="societe" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('societe')).'"></td></tr>'."\n";
622 // Lastname
623 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";
624 // Firstname
625 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";
626 // EMail
627 print '<tr><td>'.$langs->trans("Email").' <span style="color:red;">*</span></td><td>';
628 //print img_picto('', 'email', 'class="pictofixedwidth"');
629 print '<input type="text" name="email" maxlength="255" class="minwidth200" value="'.dol_escape_htmltag(GETPOST('email')).'"></td></tr>'."\n";
630 // Address
631 print '<tr><td>'.$langs->trans("Address").'</td><td>'."\n";
632 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";
633 // Zip / Town
634 print '<tr><td>'.$langs->trans('Zip').' / '.$langs->trans('Town').'</td><td>';
635 print $formcompany->select_ziptown(GETPOST('zipcode'), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6, 1);
636 print ' / ';
637 print $formcompany->select_ziptown(GETPOST('town'), 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 1);
638 print '</td></tr>';
639 // Country
640 print '<tr><td>'.$langs->trans('Country').'</td><td>';
641 print img_picto('', 'country', 'class="pictofixedwidth"');
642 $country_id = GETPOST('country_id', 'int');
643 if (!$country_id && !empty($conf->global->PARTNERSHIP_NEWFORM_FORCECOUNTRYCODE)) {
644  $country_id = getCountry($conf->global->PARTNERSHIP_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs);
645 }
646 if (!$country_id && !empty($conf->geoipmaxmind->enabled)) {
647  $country_code = dol_user_country();
648  //print $country_code;
649  if ($country_code) {
650  $new_country_id = getCountry($country_code, 3, $db, $langs);
651  //print 'xxx'.$country_code.' - '.$new_country_id;
652  if ($new_country_id) {
653  $country_id = $new_country_id;
654  }
655  }
656 }
657 $country_code = getCountry($country_id, 2, $db, $langs);
658 print $form->select_country($country_id, 'country_id');
659 print '</td></tr>';
660 // State
661 if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
662  print '<tr><td>'.$langs->trans('State').'</td><td>';
663  if ($country_code) {
664  print $formcompany->select_state(GETPOST("state_id"), $country_code);
665  }
666  print '</td></tr>';
667 }
668 // Logo
669 //print '<tr><td>'.$langs->trans("URLPhoto").'</td><td><input type="text" name="photo" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('photo')).'"></td></tr>'."\n";
670 // Other attributes
671 $tpl_context = 'public'; // define template context to public
672 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
673 // Comments
674 print '<tr>';
675 print '<td class="tdtop">'.$langs->trans("Comments").'</td>';
676 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>';
677 print '</tr>'."\n";
678 
679 print "</table>\n";
680 
681 print dol_get_fiche_end();
682 
683 // Save
684 print '<div class="center">';
685 print '<input type="submit" value="'.$langs->trans("Submit").'" id="submitsave" class="button">';
686 if (!empty($backtopage)) {
687  print ' &nbsp; &nbsp; <input type="submit" value="'.$langs->trans("Cancel").'" id="submitcancel" class="button button-cancel">';
688 }
689 print '</div>';
690 
691 
692 print "</form>\n";
693 print "<br>";
694 print '</div></div>';
695 
696 
698 
699 $db->close();
Class to manage standard extra fields.
Class to build HTML component for third parties management Only common components are here.
Class to manage generation of HTML components Only common components must be here.
Class for Partnership.
Class to manage partnership type.
Class to manage third parties objects (customers, suppliers, prospects...)
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:745
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
Definition: date.lib.php:121
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
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_user_country()
Return country code for current user.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
printCommonFooter($zone='private')
Print common footer : conf->global->MAIN_HTML_FOOTER js for switch of menu hider js for conf->global-...
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessage($mesgs, $style='mesgs')
Set event message in dol_events session object.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getUserRemoteIP()
Return the IP of remote user.
dol_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0)
Print formated error messages to output (Used to show messages on html output).
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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:1530
llxHeaderVierge($title, $head="", $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='')
Show header for new member.
Definition: new.php:116
llxFooterVierge()
Show footer for new member.
Definition: new.php:165
httponly_accessforbidden($message=1, $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.