dolibarr 19.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-2023 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
31if (!defined('NOLOGIN')) {
32 define("NOLOGIN", 1); // This means this output page does not require to be logged.
33}
34if (!defined('NOCSRFCHECK')) {
35 define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
36}
37if (!defined('NOIPCHECK')) {
38 define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
39}
40if (!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));
49if (is_numeric($entity)) {
50 define("DOLENTITY", $entity);
51}
52
53// Load Dolibarr environment
54require '../../main.inc.php';
55require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
56require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php';
57require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership_type.class.php';
58require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
59require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
60require_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
73if (empty($conf->partnership->enabled)) {
74 httponly_accessforbidden('Module Partnership not enabled');
75}
76
77if (!getDolGlobalString('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
102function 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 (!getDolGlobalString('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 (getDolGlobalString('PARTNERSHIP_IMAGE_PUBLIC_REGISTRATION')) {
136 print '<div class="backimagepublicregistration">';
137 print '<img id="idPARTNERSHIP_IMAGE_PUBLIC_INTERFACE" src="' . getDolGlobalString('PARTNERSHIP_IMAGE_PUBLIC_REGISTRATION').'">';
138 print '</div>';
139 }
140
141 print '</div>';
142
143 print '<div class="divmainbodylarge">';
144}
145
152{
153 global $conf, $langs;
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);
177if ($reshook < 0) {
178 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
179}
180
181// Action called when page is submitted
182if (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->url = GETPOST('url');
233 //$partnership->typeid = $conf->global->PARTNERSHIP_NEWFORM_FORCETYPE ? $conf->global->PARTNERSHIP_NEWFORM_FORCETYPE : GETPOST('typeid', 'int');
234 $partnership->ip = getUserRemoteIP();
235
236 $nb_post_max = getDolGlobalInt("MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
237 $now = dol_now();
238 $minmonthpost = dol_time_plus_duree($now, -1, "m");
239 // Calculate nb of post for IP
240 $nb_post_ip = 0;
241 if ($nb_post_max > 0) { // Calculate only if there is a limit to check
242 $sql = "SELECT COUNT(ref) as nb_partnerships";
243 $sql .= " FROM ".MAIN_DB_PREFIX."partnership";
244 $sql .= " WHERE ip = '".$db->escape($partnership->ip)."'";
245 $sql .= " AND date_creation > '".$db->idate($minmonthpost)."'";
246 $resql = $db->query($sql);
247 if ($resql) {
248 $num = $db->num_rows($resql);
249 $i = 0;
250 while ($i < $num) {
251 $i++;
252 $obj = $db->fetch_object($resql);
253 $nb_post_ip = $obj->nb_partnerships;
254 }
255 }
256 }
257 // test if thirdparty already exists
258 $company = new Societe($db);
259 $result = $company->fetch(0, GETPOST('societe'));
260 if ($result == 0) { // if entry with name not found, we search using the email
261 $result1 = $company->fetch(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, GETPOST('email'));
262 if ($result1 > 0) {
263 $error++;
264 $errmsg = $langs->trans("EmailAlreadyExistsPleaseRewriteYourCompanyName");
265 } else {
266 // create thirdparty
267 $company = new Societe($db);
268
269 $company->name = GETPOST('societe');
270 $company->address = GETPOST('address');
271 $company->zip = GETPOST('zipcode');
272 $company->town = GETPOST('town');
273 $company->email = GETPOST('email');
274 $company->url = GETPOST('url');
275 $company->country_id = GETPOST('country_id', 'int');
276 $company->state_id = GETPOST('state_id', 'int');
277 $company->name_alias = dolGetFirstLastname(GETPOST('firstname'), GETPOST('lastname'));
278
279 $resultat=$company->create($user);
280 if ($resultat < 0) {
281 $error++;
282 $errmsg .= join('<br>', $company->errors);
283 }
284
285 $partnership->fk_soc = $company->id;
286 }
287 } elseif ($result == -2) {
288 $error++;
289 $errmsg = $langs->trans("TwoRecordsOfCompanyName");
290 } else {
291 $partnership->fk_soc = $company->id;
292 // update thirdparty fields
293 if (empty($company->address)) {
294 $company->address = GETPOST('address');
295 }
296 if (empty($company->zip)) {
297 $company->zip = GETPOST('zipcode');
298 }
299 if (empty($company->town)) {
300 $company->town = GETPOST('town');
301 }
302 if (empty($company->country_id)) {
303 $company->country_id = GETPOST('country_id', 'int');
304 }
305 if (empty($company->email)) {
306 $company->email = GETPOST('email');
307 }
308 if (empty($company->url)) {
309 $company->url = GETPOST('url');
310 }
311 if (empty($company->state_id)) {
312 $company->state_id = GETPOST('state_id', 'int');
313 }
314 if (empty($company->name_alias)) {
315 $company->name_alias = dolGetFirstLastname(GETPOST('firstname'), GETPOST('lastname'));
316 }
317
318 $company->update(0);
319 }
320
321 // Fill array 'array_options' with data from add form
322 $extrafields->fetch_name_optionals_label($partnership->table_element);
323 $ret = $extrafields->setOptionalsFromPost(null, $partnership);
324 if ($ret < 0) {
325 $error++;
326 }
327
328 if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
329 $error++;
330 $errmsg = $langs->trans("AlreadyTooMuchPostOnThisIPAdress");
331 array_push($partnership->errors, $langs->trans("AlreadyTooMuchPostOnThisIPAdress"));
332 }
333 if (!$error) {
334 $result = $partnership->create($user);
335 if ($result > 0) {
336 /*
337 require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
338 $object = $partnership;
339
340
341 $partnershipt = new PartnershipType($db);
342 $partnershipt->fetch($object->typeid);
343
344 if ($object->email) {
345 $subject = '';
346 $msg = '';
347
348 // Send subscription email
349 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
350 $formmail = new FormMail($db);
351 // Set output language
352 $outputlangs = new Translate('', $conf);
353 $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
354 // Load traductions files required by page
355 $outputlangs->loadLangs(array("main", "members"));
356 // Get email content from template
357 $arraydefaultmessage = null;
358 $labeltouse = $conf->global->PARTNERSHIP_EMAIL_TEMPLATE_AUTOREGISTER;
359
360 if (!empty($labeltouse)) {
361 $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
362 }
363
364 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
365 $subject = $arraydefaultmessage->topic;
366 $msg = $arraydefaultmessage->content;
367 }
368
369 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
370 complete_substitutions_array($substitutionarray, $outputlangs, $object);
371 $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
372 $texttosend = make_substitutions(dol_concatdesc($msg, $partnershipt->getMailOnValid()), $substitutionarray, $outputlangs);
373
374 if ($subjecttosend && $texttosend) {
375 $moreinheader = 'X-Dolibarr-Info: send_an_email by public/members/new.php'."\r\n";
376
377 $result = $object->sendEmail($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader);
378 }
379 }
380
381
382 // Send email to the foundation to say a new member subscribed with autosubscribe form
383 /*
384 if (getDolGlobalString('MAIN_INFO_SOCIETE_MAIL') && !empty($conf->global->PARTNERSHIP_AUTOREGISTER_NOTIF_MAIL_SUBJECT) &&
385 !empty($conf->global->PARTNERSHIP_AUTOREGISTER_NOTIF_MAIL)) {
386 // Define link to login card
387 $appli = constant('DOL_APPLICATION_TITLE');
388 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
389 $appli = $conf->global->MAIN_APPLICATION_TITLE;
390 if (preg_match('/\d\.\d/', $appli)) {
391 if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) {
392 $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core
393 }
394 } else {
395 $appli .= " ".DOL_VERSION;
396 }
397 } else {
398 $appli .= " ".DOL_VERSION;
399 }
400
401 $to = $partnership->makeSubstitution(getDolGlobalString('MAIN_INFO_SOCIETE_MAIL'));
402 $from = getDolGlobalString('PARTNERSHIP_MAIL_FROM');
403 $mailfile = new CMailFile(
404 '['.$appli.'] '.getDolGlobalString('PARTNERSHIP_AUTOREGISTER_NOTIF_MAIL_SUBJECT', 'Partnership request'),
405 $to,
406 $from,
407 $partnership->makeSubstitution(getDolGlobalString('PARTNERSHIP_AUTOREGISTER_NOTIF_MAIL')),
408 array(),
409 array(),
410 array(),
411 "",
412 "",
413 0,
414 -1
415 );
416
417 if (!$mailfile->sendfile()) {
418 dol_syslog($langs->trans("ErrorFailedToSendMail", $from, $to), LOG_ERR);
419 }
420 }*/
421
422 if (!empty($backtopage)) {
423 $urlback = $backtopage;
424 } elseif (getDolGlobalString('PARTNERSHIP_URL_REDIRECT_SUBSCRIPTION')) {
425 $urlback = $conf->global->PARTNERSHIP_URL_REDIRECT_SUBSCRIPTION;
426 // TODO Make replacement of __AMOUNT__, etc...
427 } else {
428 $urlback = $_SERVER["PHP_SELF"]."?action=added&token=".newToken();
429 }
430
431 /*
432 if (!empty($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE) && $conf->global->PARTNERSHIP_NEWFORM_PAYONLINE != '-1') {
433 if ($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE == 'all') {
434 $urlback = DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?from=partnershipnewform&source=membersubscription&ref='.urlencode($partnership->ref);
435 if (price2num(GETPOST('amount', 'alpha'))) {
436 $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha'));
437 }
438 if (GETPOST('email')) {
439 $urlback .= '&email='.urlencode(GETPOST('email'));
440 }
441 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
442 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
443 $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$partnership->ref, 2));
444 } else {
445 $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
446 }
447 }
448 } elseif ($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE == 'paybox') {
449 $urlback = DOL_MAIN_URL_ROOT.'/public/paybox/newpayment.php?from=partnershipnewform&source=membersubscription&ref='.urlencode($partnership->ref);
450 if (price2num(GETPOST('amount', 'alpha'))) {
451 $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha'));
452 }
453 if (GETPOST('email')) {
454 $urlback .= '&email='.urlencode(GETPOST('email'));
455 }
456 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
457 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
458 $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$partnership->ref, 2));
459 } else {
460 $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
461 }
462 }
463 } elseif ($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE == 'paypal') {
464 $urlback = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?from=partnershipnewform&source=membersubscription&ref='.urlencode($partnership->ref);
465 if (price2num(GETPOST('amount', 'alpha'))) {
466 $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha'));
467 }
468 if (GETPOST('email')) {
469 $urlback .= '&email='.urlencode(GETPOST('email'));
470 }
471 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
472 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
473 $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$partnership->ref, 2));
474 } else {
475 $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
476 }
477 }
478 } elseif ($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE == 'stripe') {
479 $urlback = DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?from=partnershipnewform&source=membersubscription&ref='.$partnership->ref;
480 if (price2num(GETPOST('amount', 'alpha'))) {
481 $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha'));
482 }
483 if (GETPOST('email')) {
484 $urlback .= '&email='.urlencode(GETPOST('email'));
485 }
486 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
487 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
488 $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$partnership->ref, 2));
489 } else {
490 $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
491 }
492 }
493 } else {
494 dol_print_error('', "Autosubscribe form is setup to ask an online payment for a not managed online payment");
495 exit;
496 }
497 }*/
498
499 if (!empty($entity)) {
500 $urlback .= '&entity='.$entity;
501 }
502 dol_syslog("partnership ".$partnership->ref." was created, we redirect to ".$urlback);
503 } else {
504 $error++;
505 $errmsg .= join('<br>', $partnership->errors);
506 }
507 } else {
508 setEventMessage($errmsg, 'errors');
509 }
510 }
511
512 if (!$error) {
513 $db->commit();
514
515 Header("Location: ".$urlback);
516 exit;
517 } else {
518 $db->rollback();
519 }
520}
521
522// Action called after a submitted was send and member created successfully
523// If PARTNERSHIP_URL_REDIRECT_SUBSCRIPTION is set to url we never go here because a redirect was done to this url.
524// backtopage parameter with an url was set on member submit page, we never go here because a redirect was done to this url.
525if (empty($reshook) && $action == 'added') {
526 llxHeaderVierge($langs->trans("NewPartnershipForm"));
527
528 // Si on a pas ete redirige
529 print '<br><br>';
530 print '<div class="center">';
531 print $langs->trans("NewPartnershipbyWeb");
532 print '</div>';
533
535 exit;
536}
537
538
539
540/*
541 * View
542 */
543
544$form = new Form($db);
545$formcompany = new FormCompany($db);
546
547$extrafields->fetch_name_optionals_label($object->table_element); // fetch optionals attributes and labels
548
549
550llxHeaderVierge($langs->trans("NewPartnershipRequest"));
551
552print '<br>';
553print load_fiche_titre(img_picto('', 'hands-helping', 'class="pictofixedwidth"').' &nbsp; '.$langs->trans("NewPartnershipRequest"), '', '', 0, 0, 'center');
554
555
556print '<div align="center">';
557print '<div id="divsubscribe">';
558
559print '<div class="center subscriptionformhelptext opacitymedium justify">';
560if (getDolGlobalString('PARTNERSHIP_NEWFORM_TEXT')) {
561 print $langs->trans($conf->global->PARTNERSHIP_NEWFORM_TEXT)."<br>\n";
562} else {
563 print $langs->trans("NewPartnershipRequestDesc", getDolGlobalString("MAIN_INFO_SOCIETE_MAIL"))."<br>\n";
564}
565print '</div>';
566
567dol_htmloutput_errors($errmsg);
568
569// Print form
570print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" name="newmember">'."\n";
571print '<input type="hidden" name="token" value="'.newToken().'" / >';
572print '<input type="hidden" name="entity" value="'.$entity.'" />';
573print '<input type="hidden" name="action" value="add" />';
574
575print '<br>';
576
577$messagemandatory = '<span class="">'.$langs->trans("FieldsWithAreMandatory", '*').'</span>';
578//print '<br><span class="opacitymedium small">'.$langs->trans("FieldsWithAreMandatory", '*').'</span><br>';
579//print $langs->trans("FieldsWithIsForPublic",'**').'<br>';
580
581print dol_get_fiche_head('');
582
583print '<script type="text/javascript">
584jQuery(document).ready(function () {
585 jQuery(document).ready(function () {
586 jQuery("#selectcountry_id").change(function() {
587 document.newmember.action.value="create";
588 document.newmember.submit();
589 });
590 });
591});
592</script>';
593
594
595// Type
596$partnershiptype = new PartnershipType($db);
597$listofpartnershipobj = $partnershiptype->fetchAll('', '', 1000, 0, array('active'=>1));
598$listofpartnership = array();
599foreach ($listofpartnershipobj as $partnershipobj) {
600 $listofpartnership[$partnershipobj->id] = $partnershipobj->label;
601}
602
603if (getDolGlobalString('PARTNERSHIP_NEWFORM_FORCETYPE')) {
604 print $listofpartnership[getDolGlobalString('PARTNERSHIP_NEWFORM_FORCETYPE')];
605 print '<input type="hidden" id="partnershiptype" name="partnershiptype" value="' . getDolGlobalString('PARTNERSHIP_NEWFORM_FORCETYPE').'">';
606}
607
608print '<table class="border" summary="form to subscribe" id="tablesubscribe">'."\n";
609if (!getDolGlobalString('PARTNERSHIP_NEWFORM_FORCETYPE')) {
610 print '<tr class="morphy"><td class="classfortooltip" title="'.dol_escape_htmltag($messagemandatory).'">'.$langs->trans('PartnershipType').' <span class="star">*</span></td><td>'."\n";
611 print $form->selectarray("partnershiptype", $listofpartnership, GETPOSTISSET('partnershiptype') ? GETPOST('partnershiptype', 'int') : 'ifone', 1);
612 print '</td></tr>'."\n";
613}
614// Company
615print '<tr id="trcompany" class="trcompany"><td class="classfortooltip" title="'.dol_escape_htmltag($messagemandatory).'">'.$langs->trans("Company").' <span class="star">*</span></td><td>';
616print img_picto('', 'company', 'class="pictofixedwidth"');
617print '<input type="text" name="societe" class="minwidth150 maxwidth300 widthcentpercentminusxx" value="'.dol_escape_htmltag(GETPOST('societe')).'"></td></tr>'."\n";
618// Lastname
619print '<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";
620// Firstname
621print '<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";
622// EMail
623print '<tr><td class="classfortooltip" title="'.dol_escape_htmltag($messagemandatory).'">'.$langs->trans("Email").' <span class="star">*</span></td><td>';
624//print img_picto('', 'email', 'class="pictofixedwidth"');
625print '<input type="text" name="email" maxlength="255" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('email')).'"></td></tr>'."\n";
626// Url
627print '<tr><td class="tdtop">'.$langs->trans("Url").' <span class="star">*</span></td><td>';
628print '<input type="text" name="url" maxlength="255" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('url')).'">';
629if (getDolGlobalString('PARTNERSHIP_BACKLINKS_TO_CHECK')) {
630 $listofkeytocheck = explode('|', getDolGlobalString('PARTNERSHIP_BACKLINKS_TO_CHECK'));
631 $i = 0;
632 $s = '';
633 foreach ($listofkeytocheck as $val) {
634 $i++;
635 $s .= ($s ? ($i == count($listofkeytocheck) ? ' '.$langs->trans("or").' ' : ', ') : '').$val;
636 }
637 print '<br><span class="opacitymedium small">'.$langs->trans("ThisUrlMustContainsAtLeastOneLinkToWebsite", $s).'</small>';
638}
639print '</td></tr>'."\n";
640// Address
641print '<tr><td class="tdtop">'.$langs->trans("Address").'</td><td>'."\n";
642print '<textarea name="address" id="address" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.'">'.dol_escape_htmltag(GETPOST('address', 'restricthtml'), 0, 1).'</textarea></td></tr>'."\n";
643// Zip / Town
644print '<tr><td>'.$langs->trans('Zip').' / '.$langs->trans('Town').'</td><td>';
645print $formcompany->select_ziptown(GETPOST('zipcode'), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6, 1);
646print ' / ';
647print $formcompany->select_ziptown(GETPOST('town'), 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 1);
648print '</td></tr>';
649// Country
650print '<tr><td>'.$langs->trans('Country').'</td><td>';
651print img_picto('', 'country', 'class="pictofixedwidth"');
652$country_id = GETPOST('country_id', 'int');
653if (!$country_id && getDolGlobalString('PARTNERSHIP_NEWFORM_FORCECOUNTRYCODE')) {
654 $country_id = getCountry($conf->global->PARTNERSHIP_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs);
655}
656if (!$country_id && !empty($conf->geoipmaxmind->enabled)) {
657 $country_code = dol_user_country();
658 //print $country_code;
659 if ($country_code) {
660 $new_country_id = getCountry($country_code, 3, $db, $langs);
661 //print 'xxx'.$country_code.' - '.$new_country_id;
662 if ($new_country_id) {
663 $country_id = $new_country_id;
664 }
665 }
666}
667$country_code = getCountry($country_id, 2, $db, $langs);
668print $form->select_country($country_id, 'country_id');
669print '</td></tr>';
670// State
671if (!getDolGlobalString('SOCIETE_DISABLE_STATE')) {
672 print '<tr><td class="wordbreak">'.$langs->trans('State').'</td><td>';
673 if ($country_code) {
674 print $formcompany->select_state(GETPOST("state_id"), $country_code);
675 }
676 print '</td></tr>';
677}
678// Logo
679//print '<tr><td>'.$langs->trans("URLPhoto").'</td><td><input type="text" name="photo" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('photo')).'"></td></tr>'."\n";
680// Other attributes
681$parameters['tdclass']='titlefieldauto';
682$parameters['tpl_context']='public'; // define template context to public
683include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
684// Comments
685print '<tr>';
686print '<td class="tdtop wordbreak">'.$langs->trans("Comments").'</td>';
687print '<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>';
688print '</tr>'."\n";
689
690print "</table>\n";
691
692print dol_get_fiche_end();
693
694// Save
695print '<div class="center">';
696print '<input type="submit" value="'.$langs->trans("Submit").'" id="submitsave" class="button">';
697if (!empty($backtopage)) {
698 print ' &nbsp; &nbsp; <input type="submit" value="'.$langs->trans("Cancel").'" id="submitcancel" class="button button-cancel">';
699}
700print '</div>';
701
702
703print "</form>\n";
704print "<br>";
705print '</div></div>';
706
707
709
710$db->close();
if(!defined( 'NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined( 'NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) if(!defined( 'NOLOGIN')) if(!defined('NOCSRFCHECK')) if(!defined( 'NOIPCHECK')) llxHeaderVierge()
Header function.
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...)
llxFooterVierge()
Show footer for new societe.
Definition new.php:158
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
Definition date.lib.php:125
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='', $dragdropfile=0)
Show tabs of a record.
dol_user_country()
Return country code for current user.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0)
Set event message 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 a 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)
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.
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...
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs=array(), $arrayofcss=array(), $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Ouput html header of a page.
httponly_accessforbidden($message=1, $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.