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