dolibarr  19.0.0-dev
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  global $conf;
154 
155  print '</div>';
156 
157  printCommonFooter('public');
158 
159  if (!empty($conf->use_javascript_ajax)) {
160  print "\n".'<!-- Includes JS Footer of Dolibarr -->'."\n";
161  print '<script src="'.DOL_URL_ROOT.'/core/js/lib_foot.js.php?lang='.$langs->defaultlang.'"></script>'."\n";
162  }
163 
164  print "</body>\n";
165  print "</html>\n";
166 }
167 
168 
169 
170 /*
171  * Actions
172  */
173 
174 $parameters = array();
175 // Note that $action and $object may have been modified by some hooks
176 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);
177 if ($reshook < 0) {
178  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
179 }
180 
181 // Action called when page is submitted
182 if (empty($reshook) && $action == 'add') {
183  $error = 0;
184  $urlback = '';
185 
186  $db->begin();
187 
188  if (GETPOST('partnershiptype', 'int') <= 0) {
189  $error++;
190  $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type"))."<br>\n";
191  }
192  if (!GETPOST('societe')) {
193  $error++;
194  $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("societe"))."<br>\n";
195  }
196  if (!GETPOST('lastname')) {
197  $error++;
198  $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Lastname"))."<br>\n";
199  }
200  if (!GETPOST('firstname')) {
201  $error++;
202  $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Firstname"))."<br>\n";
203  }
204 
205  if (empty(GETPOST('email'))) {
206  $error++;
207  $errmsg .= $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Email'))."<br>\n";
208  } elseif (GETPOST("email") && !isValidEmail(GETPOST("email"))) {
209  $langs->load('errors');
210  $error++;
211  $errmsg .= $langs->trans("ErrorBadEMail", GETPOST("email"))."<br>\n";
212  }
213 
214  $public = GETPOSTISSET('public') ? 1 : 0;
215 
216  if (!$error) {
217  $partnership = new Partnership($db);
218 
219  // We try to find the thirdparty or the member
220  if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty') == 'thirdparty') {
221  $partnership->fk_member = 0;
222  } elseif (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty') == 'member') {
223  $partnership->fk_soc = 0;
224  }
225 
226  $partnership->status = 0;
227  $partnership->note_private = GETPOST('note_private');
228  $partnership->date_creation = dol_now();
229  $partnership->date_partnership_start = dol_now();
230  $partnership->fk_user_creat = 0;
231  $partnership->fk_type = GETPOST('partnershiptype', 'int');
232  //$partnership->typeid = $conf->global->PARTNERSHIP_NEWFORM_FORCETYPE ? $conf->global->PARTNERSHIP_NEWFORM_FORCETYPE : GETPOST('typeid', 'int');
233  $partnership->ip = getUserRemoteIP();
234 
235  $nb_post_max = getDolGlobalInt("MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
236  $now = dol_now();
237  $minmonthpost = dol_time_plus_duree($now, -1, "m");
238  // Calculate nb of post for IP
239  $nb_post_ip = 0;
240  if ($nb_post_max > 0) { // Calculate only if there is a limit to check
241  $sql = "SELECT COUNT(ref) as nb_partnerships";
242  $sql .= " FROM ".MAIN_DB_PREFIX."partnership";
243  $sql .= " WHERE ip = '".$db->escape($partnership->ip)."'";
244  $sql .= " AND date_creation > '".$db->idate($minmonthpost)."'";
245  $resql = $db->query($sql);
246  if ($resql) {
247  $num = $db->num_rows($resql);
248  $i = 0;
249  while ($i < $num) {
250  $i++;
251  $obj = $db->fetch_object($resql);
252  $nb_post_ip = $obj->nb_partnerships;
253  }
254  }
255  }
256  // test if societe already exist
257  $company = new Societe($db);
258  $result = $company->fetch(0, GETPOST('societe'));
259  if ($result == 0) { // si il ya pas d'entree sur le nom on teste l'email
260  $result1 = $company->fetch(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, GETPOST('email'));
261  if ($result1 > 0) {
262  $error++;
263  $errmsg = $langs->trans("EmailAlreadyExistsPleaseRewriteYourCompanyName");
264  } else {
265  //create thirdparty
266  $company = new Societe($db);
267 
268  $company->name = GETPOST('societe');
269  $company->address = GETPOST('address');
270  $company->zip = GETPOST('zipcode');
271  $company->town = GETPOST('town');
272  $company->email = GETPOST('email');
273  $company->url = GETPOST('url');
274  $company->country_id = GETPOST('country_id', 'int');
275  $company->state_id = GETPOST('state_id', 'int');
276  $company->name_alias = dolGetFirstLastname(GETPOST('firstname'), GETPOST('lastname'));
277 
278  $resultat=$company->create($user);
279  if ($resultat < 0) {
280  $error++;
281  $errmsg .= join('<br>', $company->errors);
282  }
283 
284  $partnership->fk_soc = $company->id;
285  }
286  } elseif ($result == -2) {
287  $error++;
288  $errmsg = $langs->trans("TwoRecordsOfCompanyName");
289  } else {
290  $partnership->fk_soc = $company->id;
291  // update thirdparty fields
292  if (empty($company->address)) {
293  $company->address = GETPOST('address');
294  }
295  if (empty($company->zip)) {
296  $company->zip = GETPOST('zipcode');
297  }
298  if (empty($company->town)) {
299  $company->town = GETPOST('town');
300  }
301  if (empty($company->country_id)) {
302  $company->country_id = GETPOST('country_id', 'int');
303  }
304  if (empty($company->email)) {
305  $company->email = GETPOST('email');
306  }
307  if (empty($company->url)) {
308  $company->url = GETPOST('url');
309  }
310  if (empty($company->state_id)) {
311  $company->state_id = GETPOST('state_id', 'int');
312  }
313  if (empty($company->name_alias)) {
314  $company->name_alias = dolGetFirstLastname(GETPOST('firstname'), GETPOST('lastname'));
315  }
316 
317  $company->update(0);
318  }
319 
320  // Fill array 'array_options' with data from add form
321  $extrafields->fetch_name_optionals_label($partnership->table_element);
322  $ret = $extrafields->setOptionalsFromPost(null, $partnership);
323  if ($ret < 0) {
324  $error++;
325  }
326 
327  if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
328  $error++;
329  $errmsg = $langs->trans("AlreadyTooMuchPostOnThisIPAdress");
330  array_push($partnership->errors, $langs->trans("AlreadyTooMuchPostOnThisIPAdress"));
331  }
332  if (!$error) {
333  $result = $partnership->create($user);
334  if ($result > 0) {
335  /*
336  require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
337  $object = $partnership;
338 
339 
340  $partnershipt = new PartnershipType($db);
341  $partnershipt->fetch($object->typeid);
342 
343  if ($object->email) {
344  $subject = '';
345  $msg = '';
346 
347  // Send subscription email
348  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
349  $formmail = new FormMail($db);
350  // Set output language
351  $outputlangs = new Translate('', $conf);
352  $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
353  // Load traductions files required by page
354  $outputlangs->loadLangs(array("main", "members"));
355  // Get email content from template
356  $arraydefaultmessage = null;
357  $labeltouse = $conf->global->PARTNERSHIP_EMAIL_TEMPLATE_AUTOREGISTER;
358 
359  if (!empty($labeltouse)) {
360  $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
361  }
362 
363  if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
364  $subject = $arraydefaultmessage->topic;
365  $msg = $arraydefaultmessage->content;
366  }
367 
368  $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
369  complete_substitutions_array($substitutionarray, $outputlangs, $object);
370  $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
371  $texttosend = make_substitutions(dol_concatdesc($msg, $partnershipt->getMailOnValid()), $substitutionarray, $outputlangs);
372 
373  if ($subjecttosend && $texttosend) {
374  $moreinheader = 'X-Dolibarr-Info: send_an_email by public/members/new.php'."\r\n";
375 
376  $result = $object->sendEmail($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader);
377  }
378  }
379 
380 
381  // Send email to the foundation to say a new member subscribed with autosubscribe form
382  /*
383  if (getDolGlobalString('MAIN_INFO_SOCIETE_MAIL') && !empty($conf->global->PARTNERSHIP_AUTOREGISTER_NOTIF_MAIL_SUBJECT) &&
384  !empty($conf->global->PARTNERSHIP_AUTOREGISTER_NOTIF_MAIL)) {
385  // Define link to login card
386  $appli = constant('DOL_APPLICATION_TITLE');
387  if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
388  $appli = $conf->global->MAIN_APPLICATION_TITLE;
389  if (preg_match('/\d\.\d/', $appli)) {
390  if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) {
391  $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core
392  }
393  } else {
394  $appli .= " ".DOL_VERSION;
395  }
396  } else {
397  $appli .= " ".DOL_VERSION;
398  }
399 
400  $to = $partnership->makeSubstitution(getDolGlobalString('MAIN_INFO_SOCIETE_MAIL'));
401  $from = getDolGlobalString('PARTNERSHIP_MAIL_FROM');
402  $mailfile = new CMailFile(
403  '['.$appli.'] '.getDolGlobalString('PARTNERSHIP_AUTOREGISTER_NOTIF_MAIL_SUBJECT', 'Partnership request'),
404  $to,
405  $from,
406  $partnership->makeSubstitution(getDolGlobalString('PARTNERSHIP_AUTOREGISTER_NOTIF_MAIL')),
407  array(),
408  array(),
409  array(),
410  "",
411  "",
412  0,
413  -1
414  );
415 
416  if (!$mailfile->sendfile()) {
417  dol_syslog($langs->trans("ErrorFailedToSendMail", $from, $to), LOG_ERR);
418  }
419  }*/
420 
421  if (!empty($backtopage)) {
422  $urlback = $backtopage;
423  } elseif (!empty($conf->global->PARTNERSHIP_URL_REDIRECT_SUBSCRIPTION)) {
424  $urlback = $conf->global->PARTNERSHIP_URL_REDIRECT_SUBSCRIPTION;
425  // TODO Make replacement of __AMOUNT__, etc...
426  } else {
427  $urlback = $_SERVER["PHP_SELF"]."?action=added&token=".newToken();
428  }
429 
430  /*
431  if (!empty($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE) && $conf->global->PARTNERSHIP_NEWFORM_PAYONLINE != '-1') {
432  if ($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE == 'all') {
433  $urlback = DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?from=partnershipnewform&source=membersubscription&ref='.urlencode($partnership->ref);
434  if (price2num(GETPOST('amount', 'alpha'))) {
435  $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha'));
436  }
437  if (GETPOST('email')) {
438  $urlback .= '&email='.urlencode(GETPOST('email'));
439  }
440  if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
441  if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
442  $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$partnership->ref, 2));
443  } else {
444  $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
445  }
446  }
447  } elseif ($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE == 'paybox') {
448  $urlback = DOL_MAIN_URL_ROOT.'/public/paybox/newpayment.php?from=partnershipnewform&source=membersubscription&ref='.urlencode($partnership->ref);
449  if (price2num(GETPOST('amount', 'alpha'))) {
450  $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha'));
451  }
452  if (GETPOST('email')) {
453  $urlback .= '&email='.urlencode(GETPOST('email'));
454  }
455  if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
456  if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
457  $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$partnership->ref, 2));
458  } else {
459  $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
460  }
461  }
462  } elseif ($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE == 'paypal') {
463  $urlback = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?from=partnershipnewform&source=membersubscription&ref='.urlencode($partnership->ref);
464  if (price2num(GETPOST('amount', 'alpha'))) {
465  $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha'));
466  }
467  if (GETPOST('email')) {
468  $urlback .= '&email='.urlencode(GETPOST('email'));
469  }
470  if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
471  if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
472  $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$partnership->ref, 2));
473  } else {
474  $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
475  }
476  }
477  } elseif ($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE == 'stripe') {
478  $urlback = DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?from=partnershipnewform&source=membersubscription&ref='.$partnership->ref;
479  if (price2num(GETPOST('amount', 'alpha'))) {
480  $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha'));
481  }
482  if (GETPOST('email')) {
483  $urlback .= '&email='.urlencode(GETPOST('email'));
484  }
485  if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
486  if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
487  $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$partnership->ref, 2));
488  } else {
489  $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
490  }
491  }
492  } else {
493  dol_print_error('', "Autosubscribe form is setup to ask an online payment for a not managed online payment");
494  exit;
495  }
496  }*/
497 
498  if (!empty($entity)) {
499  $urlback .= '&entity='.$entity;
500  }
501  dol_syslog("partnership ".$partnership->ref." was created, we redirect to ".$urlback);
502  } else {
503  $error++;
504  $errmsg .= join('<br>', $partnership->errors);
505  }
506  } else {
507  setEventMessage($errmsg, 'errors');
508  }
509  }
510 
511  if (!$error) {
512  $db->commit();
513 
514  Header("Location: ".$urlback);
515  exit;
516  } else {
517  $db->rollback();
518  }
519 }
520 
521 // Action called after a submitted was send and member created successfully
522 // If PARTNERSHIP_URL_REDIRECT_SUBSCRIPTION is set to url we never go here because a redirect was done to this url.
523 // backtopage parameter with an url was set on member submit page, we never go here because a redirect was done to this url.
524 if (empty($reshook) && $action == 'added') {
525  llxHeaderVierge($langs->trans("NewPartnershipForm"));
526 
527  // Si on a pas ete redirige
528  print '<br><br>';
529  print '<div class="center">';
530  print $langs->trans("NewPartnershipbyWeb");
531  print '</div>';
532 
533  llxFooterVierge();
534  exit;
535 }
536 
537 
538 
539 /*
540  * View
541  */
542 
543 $form = new Form($db);
544 $formcompany = new FormCompany($db);
545 
546 $extrafields->fetch_name_optionals_label($object->table_element); // fetch optionals attributes and labels
547 
548 
549 llxHeaderVierge($langs->trans("NewPartnershipRequest"));
550 
551 print '<br>';
552 print load_fiche_titre(img_picto('', 'hands-helping', 'class="pictofixedwidth"').' &nbsp; '.$langs->trans("NewPartnershipRequest"), '', '', 0, 0, 'center');
553 
554 
555 print '<div align="center">';
556 print '<div id="divsubscribe">';
557 
558 print '<div class="center subscriptionformhelptext opacitymedium justify">';
559 if (!empty($conf->global->PARTNERSHIP_NEWFORM_TEXT)) {
560  print $langs->trans($conf->global->PARTNERSHIP_NEWFORM_TEXT)."<br>\n";
561 } else {
562  print $langs->trans("NewPartnershipRequestDesc", getDolGlobalString("MAIN_INFO_SOCIETE_MAIL"))."<br>\n";
563 }
564 print '</div>';
565 
566 dol_htmloutput_errors($errmsg);
567 
568 // Print form
569 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" name="newmember">'."\n";
570 print '<input type="hidden" name="token" value="'.newToken().'" / >';
571 print '<input type="hidden" name="entity" value="'.$entity.'" />';
572 print '<input type="hidden" name="action" value="add" />';
573 
574 print '<br>';
575 
576 $messagemandatory = '<span class="">'.$langs->trans("FieldsWithAreMandatory", '*').'</span>';
577 //print '<br><span class="opacitymedium small">'.$langs->trans("FieldsWithAreMandatory", '*').'</span><br>';
578 //print $langs->trans("FieldsWithIsForPublic",'**').'<br>';
579 
580 print dol_get_fiche_head('');
581 
582 print '<script type="text/javascript">
583 jQuery(document).ready(function () {
584  jQuery(document).ready(function () {
585  jQuery("#selectcountry_id").change(function() {
586  document.newmember.action.value="create";
587  document.newmember.submit();
588  });
589  });
590 });
591 </script>';
592 
593 
594 // Type
595 $partnershiptype = new PartnershipType($db);
596 $listofpartnershipobj = $partnershiptype->fetchAll('', '', 1000, 0, array('active'=>1));
597 $listofpartnership = array();
598 foreach ($listofpartnershipobj as $partnershipobj) {
599  $listofpartnership[$partnershipobj->id] = $partnershipobj->label;
600 }
601 
602 if (getDolGlobalString('PARTNERSHIP_NEWFORM_FORCETYPE')) {
603  print $listofpartnership[$conf->global->PARTNERSHIP_NEWFORM_FORCETYPE];
604  print '<input type="hidden" id="partnershiptype" name="partnershiptype" value="'.$conf->global->PARTNERSHIP_NEWFORM_FORCETYPE.'">';
605 }
606 
607 print '<table class="border" summary="form to subscribe" id="tablesubscribe">'."\n";
608 if (!getDolGlobalString('PARTNERSHIP_NEWFORM_FORCETYPE')) {
609  print '<tr class="morphy"><td class="classfortooltip" title="'.dol_escape_htmltag($messagemandatory).'">'.$langs->trans('PartnershipType').' <span class="star">*</span></td><td>'."\n";
610  print $form->selectarray("partnershiptype", $listofpartnership, GETPOSTISSET('partnershiptype') ? GETPOST('partnershiptype', 'int') : 'ifone', 1);
611  print '</td></tr>'."\n";
612 }
613 // Company
614 print '<tr id="trcompany" class="trcompany"><td class="classfortooltip" title="'.dol_escape_htmltag($messagemandatory).'">'.$langs->trans("Company").' <span class="star">*</span></td><td>';
615 print img_picto('', 'company', 'class="pictofixedwidth"');
616 print '<input type="text" name="societe" class="minwidth150 maxwidth300 widthcentpercentminusxx" value="'.dol_escape_htmltag(GETPOST('societe')).'"></td></tr>'."\n";
617 // Lastname
618 print '<tr><td class="classfortooltip" title="'.dol_escape_htmltag($messagemandatory).'">'.$langs->trans("Lastname").' <span class="star">*</span></td><td><input type="text" name="lastname" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('lastname')).'"></td></tr>'."\n";
619 // Firstname
620 print '<tr><td class="classfortooltip" title="'.dol_escape_htmltag($messagemandatory).'">'.$langs->trans("Firstname").' <span class="star">*</span></td><td><input type="text" name="firstname" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('firstname')).'"></td></tr>'."\n";
621 // EMail
622 print '<tr><td class="classfortooltip" title="'.dol_escape_htmltag($messagemandatory).'">'.$langs->trans("Email").' <span class="star">*</span></td><td>';
623 //print img_picto('', 'email', 'class="pictofixedwidth"');
624 print '<input type="text" name="email" maxlength="255" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('email')).'"></td></tr>'."\n";
625 // Url
626 print '<tr><td class="tdtop">'.$langs->trans("Url").' <span class="star">*</span></td><td>';
627 print '<input type="text" name="url" maxlength="255" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('url')).'">';
628 if (getDolGlobalString('PARTNERSHIP_BACKLINKS_TO_CHECK')) {
629  $listofkeytocheck = explode('|', getDolGlobalString('PARTNERSHIP_BACKLINKS_TO_CHECK'));
630  $i = 0;
631  $s = '';
632  foreach ($listofkeytocheck as $val) {
633  $i++;
634  $s .= ($s ? ($i == count($listofkeytocheck) ? ' '.$langs->trans("or").' ' : ', ') : '').$val;
635  }
636  print '<br><span class="opacitymedium small">'.$langs->trans("ThisUrlMustContainsAtLeastOneLinkToWebsite", $s).'</small>';
637 }
638 print '</td></tr>'."\n";
639 // Address
640 print '<tr><td class="tdtop">'.$langs->trans("Address").'</td><td>'."\n";
641 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";
642 // Zip / Town
643 print '<tr><td>'.$langs->trans('Zip').' / '.$langs->trans('Town').'</td><td>';
644 print $formcompany->select_ziptown(GETPOST('zipcode'), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6, 1);
645 print ' / ';
646 print $formcompany->select_ziptown(GETPOST('town'), 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 1);
647 print '</td></tr>';
648 // Country
649 print '<tr><td>'.$langs->trans('Country').'</td><td>';
650 print img_picto('', 'country', 'class="pictofixedwidth"');
651 $country_id = GETPOST('country_id', 'int');
652 if (!$country_id && !empty($conf->global->PARTNERSHIP_NEWFORM_FORCECOUNTRYCODE)) {
653  $country_id = getCountry($conf->global->PARTNERSHIP_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs);
654 }
655 if (!$country_id && !empty($conf->geoipmaxmind->enabled)) {
656  $country_code = dol_user_country();
657  //print $country_code;
658  if ($country_code) {
659  $new_country_id = getCountry($country_code, 3, $db, $langs);
660  //print 'xxx'.$country_code.' - '.$new_country_id;
661  if ($new_country_id) {
662  $country_id = $new_country_id;
663  }
664  }
665 }
666 $country_code = getCountry($country_id, 2, $db, $langs);
667 print $form->select_country($country_id, 'country_id');
668 print '</td></tr>';
669 // State
670 if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
671  print '<tr><td class="wordbreak">'.$langs->trans('State').'</td><td>';
672  if ($country_code) {
673  print $formcompany->select_state(GETPOST("state_id"), $country_code);
674  }
675  print '</td></tr>';
676 }
677 // Logo
678 //print '<tr><td>'.$langs->trans("URLPhoto").'</td><td><input type="text" name="photo" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('photo')).'"></td></tr>'."\n";
679 // Other attributes
680 $parameters['tdclass']='titlefieldauto';
681 $parameters['tpl_context']='public'; // define template context to public
682 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
683 // Comments
684 print '<tr>';
685 print '<td class="tdtop wordbreak">'.$langs->trans("Comments").'</td>';
686 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>';
687 print '</tr>'."\n";
688 
689 print "</table>\n";
690 
691 print dol_get_fiche_end();
692 
693 // Save
694 print '<div class="center">';
695 print '<input type="submit" value="'.$langs->trans("Submit").'" id="submitsave" class="button">';
696 if (!empty($backtopage)) {
697  print ' &nbsp; &nbsp; <input type="submit" value="'.$langs->trans("Cancel").'" id="submitcancel" class="button button-cancel">';
698 }
699 print '</div>';
700 
701 
702 print "</form>\n";
703 print "<br>";
704 print '</div></div>';
705 
706 
708 
709 $db->close();
Societe
Class to manage third parties objects (customers, suppliers, prospects...)
Definition: societe.class.php:51
httponly_accessforbidden
httponly_accessforbidden($message=1, $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.
Definition: security.lib.php:1142
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:8903
dol_escape_htmltag
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
Definition: functions.lib.php:1600
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5477
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:609
Partnership
Class for Partnership.
Definition: partnership.class.php:32
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:1625
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
setEventMessage
setEventMessage($mesgs, $style='mesgs', $noduplicate=0)
Set event message in dol_events session object.
Definition: functions.lib.php:8637
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:9740
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:4135
dol_user_country
dol_user_country()
Return country code for current user.
Definition: functions.lib.php:3811
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:3908
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1741
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
Definition: functions.lib.php:8673
llxFooterVierge
llxFooterVierge()
Show footer for new member.
Definition: new.php:162
$sql
if(isModEnabled('facture') && $user->hasRight('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') && $user->hasRight('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)) $sql
Social contributions to pay.
Definition: index.php:746
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:11654
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2177
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
Definition: functions.lib.php:1979
dolGetFirstLastname
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
Definition: functions.lib.php:8590
getDolGlobalString
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
Definition: functions.lib.php:142
dol_time_plus_duree
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
Definition: date.lib.php:122
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:509
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:53
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:3056
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:515
getDolGlobalInt
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
Definition: functions.lib.php:156
getUserRemoteIP
getUserRemoteIP()
Return the IP of remote user.
Definition: functions.lib.php:3742
PartnershipType
Class to manage partnership type.
Definition: partnership_type.class.php:35