31if (!defined(
'NOLOGIN')) {
34if (!defined(
'NOCSRFCHECK')) {
35 define(
"NOCSRFCHECK", 1);
37if (!defined(
'NOIPCHECK')) {
38 define(
'NOIPCHECK',
'1');
40if (!defined(
'NOBROWSERNOTIF')) {
41 define(
'NOBROWSERNOTIF',
'1');
48$entity = (!empty($_GET[
'entity']) ? (int) $_GET[
'entity'] : (!empty($_POST[
'entity']) ? (int) $_POST[
'entity'] : 1));
49if (is_numeric($entity)) {
50 define(
"DOLENTITY", $entity);
54require
'../../main.inc.php';
55require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
56require_once DOL_DOCUMENT_ROOT.
'/partnership/class/partnership.class.php';
57require_once DOL_DOCUMENT_ROOT.
'/partnership/class/partnership_type.class.php';
58require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
59require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
60require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
66$backtopage =
GETPOST(
'backtopage',
'alpha');
67$action =
GETPOST(
'action',
'aZ09');
70$langs->loadLangs(array(
"main",
"members",
"partnership",
"companies",
"install",
"other"));
73if (empty($conf->partnership->enabled)) {
77if (empty($conf->global->PARTNERSHIP_ENABLE_PUBLIC)) {
82$hookmanager->initHooks(array(
'publicnewpartnershipcard',
'globalcard'));
88$user->loadDefaultValues();
102function llxHeaderVierge($title, $head =
"", $disablejs = 0, $disablehead = 0, $arrayofjs =
'', $arrayofcss =
'')
104 global $user, $conf, $langs, $mysoc;
106 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
108 print
'<body id="mainbody" class="publicnewmemberform">';
111 $urllogo = DOL_URL_ROOT.
'/theme/common/login_logo.png';
113 if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.
'/logos/thumbs/'.$mysoc->logo_small)) {
114 $urllogo = DOL_URL_ROOT.
'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode(
'logos/thumbs/'.$mysoc->logo_small);
115 } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.
'/logos/'.$mysoc->logo)) {
116 $urllogo = DOL_URL_ROOT.
'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode(
'logos/'.$mysoc->logo);
117 } elseif (is_readable(DOL_DOCUMENT_ROOT.
'/theme/dolibarr_logo.svg')) {
118 $urllogo = DOL_URL_ROOT.
'/theme/dolibarr_logo.svg';
121 print
'<div class="center">';
125 print
'<div class="backgreypublicpayment">';
126 print
'<div class="logopublicpayment">';
127 print
'<img id="dolpaymentlogo" src="'.$urllogo.
'">';
129 if (empty($conf->global->MAIN_HIDE_POWERED_BY)) {
130 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>';
135 if (!empty($conf->global->PARTNERSHIP_IMAGE_PUBLIC_REGISTRATION)) {
136 print
'<div class="backimagepublicregistration">';
137 print
'<img id="idPARTNERSHIP_IMAGE_PUBLIC_INTERFACE" src="'.$conf->global->PARTNERSHIP_IMAGE_PUBLIC_REGISTRATION.
'">';
143 print
'<div class="divmainbodylarge">';
159 if (!empty($conf->use_javascript_ajax)) {
160 print
"\n".
'<!-- Includes JS Footer of Dolibarr -->'.
"\n";
161 print
'<script src="'.DOL_URL_ROOT.
'/core/js/lib_foot.js.php?lang='.$langs->defaultlang.
'"></script>'.
"\n";
174$parameters = array();
176$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
182if (empty($reshook) && $action ==
'add') {
188 if (
GETPOST(
'partnershiptype',
'int') <= 0) {
190 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")).
"<br>\n";
194 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"societe")).
"<br>\n";
198 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Lastname")).
"<br>\n";
202 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Firstname")).
"<br>\n";
207 $errmsg .= $langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Email')).
"<br>\n";
209 $langs->load(
'errors');
211 $errmsg .= $langs->trans(
"ErrorBadEMail",
GETPOST(
"email")).
"<br>\n";
214 $public = GETPOSTISSET(
'public') ? 1 : 0;
221 $partnership->fk_member = 0;
222 } elseif (
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR',
'thirdparty') ==
'member') {
223 $partnership->fk_soc = 0;
226 $partnership->status = 0;
227 $partnership->note_private =
GETPOST(
'note_private');
228 $partnership->date_creation =
dol_now();
229 $partnership->date_partnership_start =
dol_now();
230 $partnership->fk_user_creat = 0;
231 $partnership->fk_type =
GETPOST(
'partnershiptype',
'int');
232 $partnership->url =
GETPOST(
'url');
236 $nb_post_max =
getDolGlobalInt(
"MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
241 if ($nb_post_max > 0) {
242 $sql =
"SELECT COUNT(ref) as nb_partnerships";
243 $sql .=
" FROM ".MAIN_DB_PREFIX.
"partnership";
244 $sql .=
" WHERE ip = '".$db->escape($partnership->ip).
"'";
245 $sql .=
" AND date_creation > '".$db->idate($minmonthpost).
"'";
246 $resql = $db->query($sql);
248 $num = $db->num_rows($resql);
252 $obj = $db->fetch_object($resql);
253 $nb_post_ip = $obj->nb_partnerships;
259 $result = $company->fetch(0,
GETPOST(
'societe'));
261 $result1 = $company->fetch(0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
GETPOST(
'email'));
264 $errmsg = $langs->trans(
"EmailAlreadyExistsPleaseRewriteYourCompanyName");
269 $company->name =
GETPOST(
'societe');
270 $company->address =
GETPOST(
'address');
271 $company->zip =
GETPOST(
'zipcode');
272 $company->town =
GETPOST(
'town');
273 $company->email =
GETPOST(
'email');
274 $company->url =
GETPOST(
'url');
275 $company->country_id =
GETPOST(
'country_id',
'int');
276 $company->state_id =
GETPOST(
'state_id',
'int');
279 $resultat=$company->create($user);
282 $errmsg .= join(
'<br>', $company->errors);
285 $partnership->fk_soc = $company->id;
287 } elseif ($result == -2) {
289 $errmsg = $langs->trans(
"TwoRecordsOfCompanyName");
291 $partnership->fk_soc = $company->id;
293 if (empty($company->address)) {
294 $company->address =
GETPOST(
'address');
296 if (empty($company->zip)) {
297 $company->zip =
GETPOST(
'zipcode');
299 if (empty($company->town)) {
300 $company->town =
GETPOST(
'town');
302 if (empty($company->country_id)) {
303 $company->country_id =
GETPOST(
'country_id',
'int');
305 if (empty($company->email)) {
306 $company->email =
GETPOST(
'email');
308 if (empty($company->url)) {
309 $company->url =
GETPOST(
'url');
311 if (empty($company->state_id)) {
312 $company->state_id =
GETPOST(
'state_id',
'int');
314 if (empty($company->name_alias)) {
322 $extrafields->fetch_name_optionals_label($partnership->table_element);
323 $ret = $extrafields->setOptionalsFromPost(
null, $partnership);
328 if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
330 $errmsg = $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress");
331 array_push($partnership->errors, $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress"));
334 $result = $partnership->create($user);
422 if (!empty($backtopage)) {
423 $urlback = $backtopage;
424 } elseif (!empty($conf->global->PARTNERSHIP_URL_REDIRECT_SUBSCRIPTION)) {
425 $urlback = $conf->global->PARTNERSHIP_URL_REDIRECT_SUBSCRIPTION;
428 $urlback = $_SERVER[
"PHP_SELF"].
"?action=added&token=".newToken();
499 if (!empty($entity)) {
500 $urlback .=
'&entity='.$entity;
502 dol_syslog(
"partnership ".$partnership->ref.
" was created, we redirect to ".$urlback);
505 $errmsg .= join(
'<br>', $partnership->errors);
515 Header(
"Location: ".$urlback);
525if (empty($reshook) && $action ==
'added') {
530 print
'<div class="center">';
531 print $langs->trans(
"NewPartnershipbyWeb");
544$form =
new Form($db);
547$extrafields->fetch_name_optionals_label($object->table_element);
553print
load_fiche_titre(
img_picto(
'',
'hands-helping',
'class="pictofixedwidth"').
' '.$langs->trans(
"NewPartnershipRequest"),
'',
'', 0, 0,
'center');
556print
'<div align="center">';
557print
'<div id="divsubscribe">';
559print
'<div class="center subscriptionformhelptext opacitymedium justify">';
560if (!empty($conf->global->PARTNERSHIP_NEWFORM_TEXT)) {
561 print $langs->trans($conf->global->PARTNERSHIP_NEWFORM_TEXT).
"<br>\n";
563 print $langs->trans(
"NewPartnershipRequestDesc",
getDolGlobalString(
"MAIN_INFO_SOCIETE_MAIL")).
"<br>\n";
570print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="newmember">'.
"\n";
571print
'<input type="hidden" name="token" value="'.newToken().
'" / >';
572print
'<input type="hidden" name="entity" value="'.$entity.
'" />';
573print
'<input type="hidden" name="action" value="add" />';
577$messagemandatory =
'<span class="">'.$langs->trans(
"FieldsWithAreMandatory",
'*').
'</span>';
583print
'<script type="text/javascript">
584jQuery(document).ready(function () {
585 jQuery(document).ready(function () {
586 jQuery("#selectcountry_id").change(function() {
587 document.newmember.action.value="create";
588 document.newmember.submit();
597$listofpartnershipobj = $partnershiptype->fetchAll(
'',
'', 1000, 0, array(
'active'=>1));
598$listofpartnership = array();
599foreach ($listofpartnershipobj as $partnershipobj) {
600 $listofpartnership[$partnershipobj->id] = $partnershipobj->label;
604 print $listofpartnership[$conf->global->PARTNERSHIP_NEWFORM_FORCETYPE];
605 print
'<input type="hidden" id="partnershiptype" name="partnershiptype" value="'.$conf->global->PARTNERSHIP_NEWFORM_FORCETYPE.
'">';
608print
'<table class="border" summary="form to subscribe" id="tablesubscribe">'.
"\n";
610 print
'<tr class="morphy"><td class="classfortooltip" title="'.dol_escape_htmltag($messagemandatory).
'">'.$langs->trans(
'PartnershipType').
' <span class="star">*</span></td><td>'.
"\n";
611 print $form->selectarray(
"partnershiptype", $listofpartnership, GETPOSTISSET(
'partnershiptype') ?
GETPOST(
'partnershiptype',
'int') :
'ifone', 1);
612 print
'</td></tr>'.
"\n";
615print
'<tr id="trcompany" class="trcompany"><td class="classfortooltip" title="'.dol_escape_htmltag($messagemandatory).
'">'.$langs->trans(
"Company").
' <span class="star">*</span></td><td>';
616print
img_picto(
'',
'company',
'class="pictofixedwidth"');
617print
'<input type="text" name="societe" class="minwidth150 maxwidth300 widthcentpercentminusxx" value="'.dol_escape_htmltag(
GETPOST(
'societe')).
'"></td></tr>'.
"\n";
619print
'<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";
621print
'<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";
623print
'<tr><td class="classfortooltip" title="'.dol_escape_htmltag($messagemandatory).
'">'.$langs->trans(
"Email").
' <span class="star">*</span></td><td>';
625print
'<input type="text" name="email" maxlength="255" class="minwidth150" value="'.dol_escape_htmltag(
GETPOST(
'email')).
'"></td></tr>'.
"\n";
627print
'<tr><td class="tdtop">'.$langs->trans(
"Url").
' <span class="star">*</span></td><td>';
628print
'<input type="text" name="url" maxlength="255" class="minwidth150" value="'.dol_escape_htmltag(
GETPOST(
'url')).
'">';
630 $listofkeytocheck = explode(
'|',
getDolGlobalString(
'PARTNERSHIP_BACKLINKS_TO_CHECK'));
633 foreach ($listofkeytocheck as $val) {
635 $s .= ($s ? ($i == count($listofkeytocheck) ?
' '.$langs->trans(
"or").
' ' :
', ') :
'').$val;
637 print
'<br><span class="opacitymedium small">'.$langs->trans(
"ThisUrlMustContainsAtLeastOneLinkToWebsite", $s).
'</small>';
639print
'</td></tr>'.
"\n";
641print
'<tr><td class="tdtop">'.$langs->trans(
"Address").
'</td><td>'.
"\n";
642print
'<textarea name="address" id="address" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.
'">'.
dol_escape_htmltag(
GETPOST(
'address',
'restricthtml'), 0, 1).
'</textarea></td></tr>'.
"\n";
644print
'<tr><td>'.$langs->trans(
'Zip').
' / '.$langs->trans(
'Town').
'</td><td>';
645print $formcompany->select_ziptown(
GETPOST(
'zipcode'),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6, 1);
647print $formcompany->select_ziptown(
GETPOST(
'town'),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'), 0, 1);
650print
'<tr><td>'.$langs->trans(
'Country').
'</td><td>';
651print
img_picto(
'',
'country',
'class="pictofixedwidth"');
652$country_id =
GETPOST(
'country_id',
'int');
653if (!$country_id && !empty($conf->global->PARTNERSHIP_NEWFORM_FORCECOUNTRYCODE)) {
654 $country_id =
getCountry($conf->global->PARTNERSHIP_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs);
656if (!$country_id && !empty($conf->geoipmaxmind->enabled)) {
660 $new_country_id =
getCountry($country_code, 3, $db, $langs);
662 if ($new_country_id) {
663 $country_id = $new_country_id;
667$country_code =
getCountry($country_id, 2, $db, $langs);
668print $form->select_country($country_id,
'country_id');
671if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
672 print
'<tr><td class="wordbreak">'.$langs->trans(
'State').
'</td><td>';
674 print $formcompany->select_state(
GETPOST(
"state_id"), $country_code);
681$parameters[
'tdclass']=
'titlefieldauto';
682$parameters[
'tpl_context']=
'public';
683include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
686print
'<td class="tdtop wordbreak">'.$langs->trans(
"Comments").
'</td>';
687print
'<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>';
695print
'<div class="center">';
696print
'<input type="submit" value="'.$langs->trans(
"Submit").
'" id="submitsave" class="button">';
697if (!empty($backtopage)) {
698 print
' <input type="submit" value="'.$langs->trans(
"Cancel").
'" id="submitcancel" class="button button-cancel">';
if(!defined( 'NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined( 'NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) if(!defined( 'NOLOGIN')) if(!defined('NOCSRFCHECK')) if(!defined( 'NOIPCHECK')) llxHeaderVierge()
Header function.
Class to manage partnership type.
Class to manage third parties objects (customers, suppliers, prospects...)
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $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.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_user_country()
Return country code for current user.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0)
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 dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
getUserRemoteIP()
Return the IP of remote user.
dol_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0)
Print formated 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='', $arrayofcss='', $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Ouput html header of a page.
llxFooterVierge()
Show footer for new member.
httponly_accessforbidden($message=1, $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.