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