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