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