31 if (!defined(
'NOLOGIN')) {
34 if (!defined(
'NOCSRFCHECK')) {
35 define(
"NOCSRFCHECK", 1);
37 if (!defined(
'NOIPCHECK')) {
38 define(
'NOIPCHECK',
'1');
40 if (!defined(
'NOBROWSERNOTIF')) {
41 define(
'NOBROWSERNOTIF',
'1');
43 if (!defined(
'NOIPCHECK')) {
44 define(
'NOIPCHECK',
'1');
50 $entity = (!empty($_GET[
'entity']) ? (int) $_GET[
'entity'] : (!empty($_POST[
'entity']) ? (int) $_POST[
'entity'] : 1));
51 if (is_numeric($entity)) {
52 define(
"DOLENTITY", $entity);
56 require
'../../main.inc.php';
57 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
58 require_once DOL_DOCUMENT_ROOT.
'/partnership/class/partnership.class.php';
59 require_once DOL_DOCUMENT_ROOT.
'/partnership/class/partnership_type.class.php';
60 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
61 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
62 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
68 $backtopage =
GETPOST(
'backtopage',
'alpha');
69 $action =
GETPOST(
'action',
'aZ09');
72 $langs->loadLangs(array(
"main",
"members",
"partnership",
"companies",
"install",
"other"));
75 if (empty($conf->partnership->enabled)) {
79 if (empty($conf->global->PARTNERSHIP_ENABLE_PUBLIC)) {
84 $hookmanager->initHooks(array(
'publicnewpartnershipcard',
'globalcard'));
90 $user->loadDefaultValues();
104 function llxHeaderVierge($title, $head =
"", $disablejs = 0, $disablehead = 0, $arrayofjs =
'', $arrayofcss =
'')
106 global $user, $conf, $langs, $mysoc;
108 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
110 print
'<body id="mainbody" class="publicnewmemberform">';
113 $urllogo = DOL_URL_ROOT.
'/theme/common/login_logo.png';
115 if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.
'/logos/thumbs/'.$mysoc->logo_small)) {
116 $urllogo = DOL_URL_ROOT.
'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode(
'logos/thumbs/'.$mysoc->logo_small);
117 } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.
'/logos/'.$mysoc->logo)) {
118 $urllogo = DOL_URL_ROOT.
'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode(
'logos/'.$mysoc->logo);
119 } elseif (is_readable(DOL_DOCUMENT_ROOT.
'/theme/dolibarr_logo.svg')) {
120 $urllogo = DOL_URL_ROOT.
'/theme/dolibarr_logo.svg';
123 print
'<div class="center">';
127 print
'<div class="backgreypublicpayment">';
128 print
'<div class="logopublicpayment">';
129 print
'<img id="dolpaymentlogo" src="'.$urllogo.
'">';
131 if (empty($conf->global->MAIN_HIDE_POWERED_BY)) {
132 print
'<div class="poweredbypublicpayment opacitymedium right"><a class="poweredbyhref" href="https://www.dolibarr.org?utm_medium=website&utm_source=poweredby" target="dolibarr" rel="noopener">'.$langs->trans(
"PoweredBy").
'<br><img class="poweredbyimg" src="'.DOL_URL_ROOT.
'/theme/dolibarr_logo.svg" width="80px"></a></div>';
137 if (!empty($conf->global->PARTNERSHIP_IMAGE_PUBLIC_REGISTRATION)) {
138 print
'<div class="backimagepublicregistration">';
139 print
'<img id="idPARTNERSHIP_IMAGE_PUBLIC_INTERFACE" src="'.$conf->global->PARTNERSHIP_IMAGE_PUBLIC_REGISTRATION.
'">';
145 print
'<div class="divmainbodylarge">';
168 $parameters = array();
170 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
176 if (empty($reshook) && $action ==
'add') {
182 if (
GETPOST(
'partnershiptype',
'int') <= 0) {
184 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")).
"<br>\n";
188 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"societe")).
"<br>\n";
192 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Lastname")).
"<br>\n";
196 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Firstname")).
"<br>\n";
201 $errmsg .= $langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Email')).
"<br>\n";
203 $langs->load(
'errors');
205 $errmsg .= $langs->trans(
"ErrorBadEMail",
GETPOST(
"email")).
"<br>\n";
215 $partnership->fk_member = 0;
216 } elseif (
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR',
'thirdparty') ==
'member') {
217 $partnership->fk_soc = 0;
220 $partnership->status = 0;
221 $partnership->note_private =
GETPOST(
'note_private');
222 $partnership->date_creation =
dol_now();
223 $partnership->date_partnership_start =
dol_now();
224 $partnership->fk_user_creat = 0;
225 $partnership->fk_type =
GETPOST(
'partnershiptype',
'int');
229 $nb_post_max =
getDolGlobalInt(
"MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
234 if ($nb_post_max > 0) {
235 $sql =
"SELECT COUNT(ref) as nb_partnerships";
236 $sql .=
" FROM ".MAIN_DB_PREFIX.
"partnership";
237 $sql .=
" WHERE ip = '".$db->escape($partnership->ip).
"'";
238 $sql .=
" AND date_creation > '".$db->idate($minmonthpost).
"'";
239 $resql = $db->query($sql);
241 $num = $db->num_rows(
$resql);
245 $obj = $db->fetch_object(
$resql);
246 $nb_post_ip = $obj->nb_partnerships;
252 $result = $company->fetch(0,
GETPOST(
'societe'));
254 $result1 = $company->fetch(0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
GETPOST(
'email'));
257 $errmsg = $langs->trans(
"EmailAlreadyExistsPleaseRewriteYourCompanyName");
262 $company->name =
GETPOST(
'societe');
263 $company->address =
GETPOST(
'address');
264 $company->zip =
GETPOST(
'zipcode');
265 $company->town =
GETPOST(
'town');
266 $company->email =
GETPOST(
'email');
267 $company->url =
GETPOST(
'url');
268 $company->country_id =
GETPOST(
'country_id',
'int');
269 $company->state_id =
GETPOST(
'state_id',
'int');
272 $resultat=$company->create($user);
275 $errmsg .= join(
'<br>', $company->errors);
278 $partnership->fk_soc = $company->id;
280 } elseif ($result == -2) {
282 $errmsg = $langs->trans(
"TwoRecordsOfCompanyName");
284 $partnership->fk_soc = $company->id;
286 if (empty($company->address)) {
287 $company->address =
GETPOST(
'address');
289 if (empty($company->zip)) {
290 $company->zip =
GETPOST(
'zipcode');
292 if (empty($company->town)) {
293 $company->town =
GETPOST(
'town');
295 if (empty($company->country_id)) {
296 $company->country_id =
GETPOST(
'country_id',
'int');
298 if (empty($company->email)) {
299 $company->email =
GETPOST(
'email');
301 if (empty($company->url)) {
302 $company->url =
GETPOST(
'url');
304 if (empty($company->state_id)) {
305 $company->state_id =
GETPOST(
'state_id',
'int');
307 if (empty($company->name_alias)) {
315 $extrafields->fetch_name_optionals_label($partnership->table_element);
316 $ret = $extrafields->setOptionalsFromPost(
null, $partnership);
321 if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
323 $errmsg = $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress");
324 array_push($partnership->errors, $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress"));
327 $result = $partnership->create($user);
415 if (!empty($backtopage)) {
416 $urlback = $backtopage;
417 } elseif (!empty($conf->global->PARTNERSHIP_URL_REDIRECT_SUBSCRIPTION)) {
418 $urlback = $conf->global->PARTNERSHIP_URL_REDIRECT_SUBSCRIPTION;
421 $urlback = $_SERVER[
"PHP_SELF"].
"?action=added&token=".
newToken();
492 if (!empty($entity)) {
493 $urlback .=
'&entity='.$entity;
495 dol_syslog(
"partnership ".$partnership->ref.
" was created, we redirect to ".$urlback);
498 $errmsg .= join(
'<br>', $partnership->errors);
508 Header(
"Location: ".$urlback);
518 if (empty($reshook) && $action ==
'added') {
523 print
'<div class="center">';
524 print $langs->trans(
"NewPartnershipbyWeb");
540 $extrafields->fetch_name_optionals_label($object->table_element);
546 print
load_fiche_titre($langs->trans(
"NewPartnershipRequest"),
'',
'', 0, 0,
'center');
549 print
'<div align="center">';
550 print
'<div id="divsubscribe">';
552 print
'<div class="center subscriptionformhelptext opacitymedium justify">';
553 if (!empty($conf->global->PARTNERSHIP_NEWFORM_TEXT)) {
554 print $langs->trans($conf->global->PARTNERSHIP_NEWFORM_TEXT).
"<br>\n";
556 print $langs->trans(
"NewPartnershipRequestDesc",
getDolGlobalString(
"MAIN_INFO_SOCIETE_MAIL")).
"<br>\n";
563 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="newmember">'.
"\n";
564 print
'<input type="hidden" name="token" value="'.newToken().
'" / >';
565 print
'<input type="hidden" name="entity" value="'.$entity.
'" />';
566 print
'<input type="hidden" name="action" value="add" />';
570 print
'<br><span class="opacitymedium">'.$langs->trans(
"FieldsWithAreMandatory",
'*').
'</span><br>';
575 print
'<script type="text/javascript">
576 jQuery(document).ready(function () {
577 jQuery(document).ready(function () {
578 jQuery("#selectcountry_id").change(function() {
579 document.newmember.action.value="create";
580 document.newmember.submit();
589 $listofpartnershipobj = $partnershiptype->fetchAll(
'',
'', 1000, 0, array(
'active'=>1));
590 $listofpartnership = array();
591 foreach ($listofpartnershipobj as $partnershipobj) {
592 $listofpartnership[$partnershipobj->id] = $partnershipobj->label;
596 print $listofpartnership[$conf->global->PARTNERSHIP_NEWFORM_FORCETYPE];
597 print
'<input type="hidden" id="partnershiptype" name="partnershiptype" value="'.$conf->global->PARTNERSHIP_NEWFORM_FORCETYPE.
'">';
600 print
'<table class="border" summary="form to subscribe" id="tablesubscribe">'.
"\n";
602 print
'<tr class="morphy"><td>'.$langs->trans(
'PartnershipType').
' <span style="color: red">*</span></td><td>'.
"\n";
603 print
$form->selectarray(
"partnershiptype", $listofpartnership,
GETPOSTISSET(
'partnershiptype') ?
GETPOST(
'partnershiptype',
'int') :
'ifone', 1);
604 print
'</td></tr>'.
"\n";
607 print
'<tr id="trcompany" class="trcompany"><td>'.$langs->trans(
"Company").
' <span style="color:red;">*</span></td><td>';
608 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
609 print
'<input type="text" name="societe" class="minwidth150" value="'.dol_escape_htmltag(
GETPOST(
'societe')).
'"></td></tr>'.
"\n";
611 print
'<tr><td>'.$langs->trans(
"Lastname").
' <span style="color: red">*</span></td><td><input type="text" name="lastname" class="minwidth150" value="'.
dol_escape_htmltag(
GETPOST(
'lastname')).
'"></td></tr>'.
"\n";
613 print
'<tr><td>'.$langs->trans(
"Firstname").
' <span style="color: red">*</span></td><td><input type="text" name="firstname" class="minwidth150" value="'.
dol_escape_htmltag(
GETPOST(
'firstname')).
'"></td></tr>'.
"\n";
615 print
'<tr><td>'.$langs->trans(
"Email").
' <span style="color:red;">*</span></td><td>';
617 print
'<input type="text" name="email" maxlength="255" class="minwidth200" value="'.dol_escape_htmltag(
GETPOST(
'email')).
'"></td></tr>'.
"\n";
619 print
'<tr><td>'.$langs->trans(
"Url").
' <span style="color:red;">*</span></td><td>';
620 print
'<input type="text" name="url" maxlength="255" class="minwidth200" value="'.dol_escape_htmltag(
GETPOST(
'url')).
'">';
622 $listofkeytocheck = explode(
'|',
getDolGlobalString(
'PARTNERSHIP_BACKLINKS_TO_CHECK'));
625 foreach ($listofkeytocheck as $val) {
627 $s .= ($s ? ($i == count($listofkeytocheck) ?
' '.$langs->trans(
"or").
' ' :
', ') :
'').$val;
629 print
'<br><span class="opacitymedium small">'.$langs->trans(
"ThisUrlMustContainsAtLeastOneLinkToWebsite", $s).
'</small>';
631 print
'</td></tr>'.
"\n";
633 print
'<tr><td>'.$langs->trans(
"Address").
'</td><td>'.
"\n";
634 print
'<textarea name="address" id="address" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.
'">'.
dol_escape_htmltag(
GETPOST(
'address',
'restricthtml'), 0, 1).
'</textarea></td></tr>'.
"\n";
636 print
'<tr><td>'.$langs->trans(
'Zip').
' / '.$langs->trans(
'Town').
'</td><td>';
637 print $formcompany->select_ziptown(
GETPOST(
'zipcode'),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6, 1);
639 print $formcompany->select_ziptown(
GETPOST(
'town'),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'), 0, 1);
642 print
'<tr><td>'.$langs->trans(
'Country').
'</td><td>';
643 print
img_picto(
'',
'country',
'class="pictofixedwidth"');
644 $country_id =
GETPOST(
'country_id',
'int');
645 if (!$country_id && !empty($conf->global->PARTNERSHIP_NEWFORM_FORCECOUNTRYCODE)) {
646 $country_id =
getCountry($conf->global->PARTNERSHIP_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs);
648 if (!$country_id && !empty($conf->geoipmaxmind->enabled)) {
652 $new_country_id =
getCountry($country_code, 3, $db, $langs);
654 if ($new_country_id) {
655 $country_id = $new_country_id;
659 $country_code =
getCountry($country_id, 2, $db, $langs);
660 print
$form->select_country($country_id,
'country_id');
663 if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
664 print
'<tr><td>'.$langs->trans(
'State').
'</td><td>';
666 print $formcompany->select_state(
GETPOST(
"state_id"), $country_code);
673 $parameters[
'tdclass']=
'titlefieldauto';
674 $parameters[
'tpl_context']=
'public';
675 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
678 print
'<td class="tdtop">'.$langs->trans(
"Comments").
'</td>';
679 print
'<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>';
687 print
'<div class="center">';
688 print
'<input type="submit" value="'.$langs->trans(
"Submit").
'" id="submitsave" class="button">';
689 if (!empty($backtopage)) {
690 print
' <input type="submit" value="'.$langs->trans(
"Cancel").
'" id="submitcancel" class="button button-cancel">';
697 print
'</div></div>';