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