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