32if (!defined(
'NOLOGIN')) {
35if (!defined(
'NOCSRFCHECK')) {
36 define(
"NOCSRFCHECK", 1);
38if (!defined(
'NOIPCHECK')) {
39 define(
'NOIPCHECK',
'1');
41if (!defined(
'NOBROWSERNOTIF')) {
42 define(
'NOBROWSERNOTIF',
'1');
49$entity = (!empty($_GET[
'entity']) ? (int) $_GET[
'entity'] : (!empty($_POST[
'entity']) ? (int) $_POST[
'entity'] : 1));
50if (is_numeric($entity)) {
51 define(
"DOLENTITY", $entity);
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';
67$backtopage =
GETPOST(
'backtopage',
'alpha');
68$action =
GETPOST(
'action',
'aZ09');
71$langs->loadLangs(array(
"main",
"members",
"partnership",
"companies",
"install",
"other"));
74if (!isModEnabled(
'partnership')) {
83$hookmanager->initHooks(array(
'publicnewpartnershipcard',
'globalcard'));
89$user->loadDefaultValues();
103function llxHeaderVierge($title, $head =
"", $disablejs = 0, $disablehead = 0, $arrayofjs = [], $arrayofcss = [])
105 global $conf, $langs, $mysoc;
107 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
109 print
'<body id="mainbody" class="publicnewmemberform">';
112 $urllogo = DOL_URL_ROOT.
'/theme/common/login_logo.png';
114 if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.
'/logos/thumbs/'.$mysoc->logo_small)) {
115 $urllogo = DOL_URL_ROOT.
'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode(
'logos/thumbs/'.$mysoc->logo_small);
116 } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.
'/logos/'.$mysoc->logo)) {
117 $urllogo = DOL_URL_ROOT.
'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode(
'logos/'.$mysoc->logo);
118 } elseif (is_readable(DOL_DOCUMENT_ROOT.
'/theme/dolibarr_logo.svg')) {
119 $urllogo = DOL_URL_ROOT.
'/theme/dolibarr_logo.svg';
122 print
'<div class="center">';
126 print
'<div class="backgreypublicpayment">';
127 print
'<div class="logopublicpayment">';
128 print
'<img id="dolpaymentlogo" src="'.$urllogo.
'">';
131 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 print
'<div class="backimagepublicregistration">';
138 print
'<img id="idPARTNERSHIP_IMAGE_PUBLIC_INTERFACE" src="' .
getDolGlobalString(
'PARTNERSHIP_IMAGE_PUBLIC_REGISTRATION').
'">';
144 print
'<div class="divmainbodylarge">';
154 global $conf, $langs;
160 if (!empty($conf->use_javascript_ajax)) {
161 print
"\n".
'<!-- Includes JS Footer of Dolibarr -->'.
"\n";
162 print
'<script src="'.DOL_URL_ROOT.
'/core/js/lib_foot.js.php?lang='.$langs->defaultlang.
'"></script>'.
"\n";
175$parameters = array();
177$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
183if (empty($reshook) && $action ==
'add') {
191 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")).
"<br>\n";
195 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"societe")).
"<br>\n";
199 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Lastname")).
"<br>\n";
203 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Firstname")).
"<br>\n";
208 $errmsg .= $langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Email')).
"<br>\n";
210 $langs->load(
'errors');
212 $errmsg .= $langs->trans(
"ErrorBadEMail",
GETPOST(
"email")).
"<br>\n";
215 $public = GETPOSTISSET(
'public') ? 1 : 0;
222 $partnership->fk_member = 0;
223 } elseif (
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR',
'thirdparty') ==
'member') {
224 $partnership->fk_soc = 0;
227 $partnership->status = 0;
228 $partnership->note_private =
GETPOST(
'note_private');
229 $partnership->date_creation =
dol_now();
230 $partnership->date_partnership_start =
dol_now();
231 $partnership->fk_user_creat = 0;
232 $partnership->fk_type =
GETPOSTINT(
'partnershiptype');
233 $partnership->url =
GETPOST(
'url');
237 $nb_post_max =
getDolGlobalInt(
"MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
242 if ($nb_post_max > 0) {
243 $sql =
"SELECT COUNT(ref) as nb_partnerships";
244 $sql .=
" FROM ".MAIN_DB_PREFIX.
"partnership";
245 $sql .=
" WHERE ip = '".$db->escape($partnership->ip).
"'";
246 $sql .=
" AND date_creation > '".$db->idate($minmonthpost).
"'";
247 $resql = $db->query($sql);
249 $num = $db->num_rows($resql);
253 $obj = $db->fetch_object($resql);
254 $nb_post_ip = $obj->nb_partnerships;
260 $result = $company->fetch(0,
GETPOST(
'societe'));
262 $result1 = $company->fetch(0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
GETPOST(
'email'));
265 $errmsg = $langs->trans(
"EmailAlreadyExistsPleaseRewriteYourCompanyName");
270 $company->name =
GETPOST(
'societe');
271 $company->address =
GETPOST(
'address');
272 $company->zip =
GETPOST(
'zipcode');
273 $company->town =
GETPOST(
'town');
274 $company->email =
GETPOST(
'email');
275 $company->url =
GETPOST(
'url');
276 $company->country_id =
GETPOSTINT(
'country_id');
280 $resultat = $company->create($user);
283 $errmsg .= implode(
'<br>', $company->errors);
286 $partnership->fk_soc = $company->id;
288 } elseif ($result == -2) {
290 $errmsg = $langs->trans(
"TwoRecordsOfCompanyName");
292 $partnership->fk_soc = $company->id;
294 if (empty($company->address)) {
295 $company->address =
GETPOST(
'address');
297 if (empty($company->zip)) {
298 $company->zip =
GETPOST(
'zipcode');
300 if (empty($company->town)) {
301 $company->town =
GETPOST(
'town');
303 if (empty($company->country_id)) {
304 $company->country_id =
GETPOSTINT(
'country_id');
306 if (empty($company->email)) {
307 $company->email =
GETPOST(
'email');
309 if (empty($company->url)) {
310 $company->url =
GETPOST(
'url');
312 if (empty($company->state_id)) {
315 if (empty($company->name_alias)) {
319 $res = $company->update(0, $user);
326 $extrafields->fetch_name_optionals_label($partnership->table_element);
327 $ret = $extrafields->setOptionalsFromPost(
null, $partnership);
332 if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
334 $errmsg = $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress");
335 array_push($partnership->errors, $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress"));
338 $result = $partnership->create($user);
426 if (!empty($backtopage)) {
427 $urlback = $backtopage;
432 $urlback = $_SERVER[
"PHP_SELF"].
"?action=added&token=".
newToken();
503 if (!empty($entity)) {
504 $urlback .=
'&entity='.$entity;
506 dol_syslog(
"partnership ".$partnership->ref.
" was created, we redirect to ".$urlback);
509 $errmsg .= implode(
'<br>', $partnership->errors);
519 header(
"Location: ".$urlback);
529if (empty($reshook) && $action ==
'added') {
534 print
'<div class="center">';
535 print $langs->trans(
"NewPartnershipbyWeb");
548$form =
new Form($db);
551$extrafields->fetch_name_optionals_label(
$object->table_element);
557print
load_fiche_titre(
img_picto(
'',
'hands-helping',
'class="pictofixedwidth"').
' '.$langs->trans(
"NewPartnershipRequest"),
'',
'', 0,
'',
'center');
560print
'<div align="center">';
561print
'<div id="divsubscribe">';
563print
'<div class="center subscriptionformhelptext opacitymedium justify">';
567 print $langs->trans(
"NewPartnershipRequestDesc",
getDolGlobalString(
"MAIN_INFO_SOCIETE_MAIL")).
"<br>\n";
574print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="newmember">'.
"\n";
575print
'<input type="hidden" name="token" value="'.newToken().
'" / >';
576print
'<input type="hidden" name="entity" value="'.$entity.
'" />';
577print
'<input type="hidden" name="action" value="add" />';
581$messagemandatory =
'<span class="">'.$langs->trans(
"FieldsWithAreMandatory",
'*').
'</span>';
587print
'<script type="text/javascript">
588jQuery(document).ready(function () {
589 jQuery(document).ready(function () {
590 jQuery("#selectcountry_id").change(function() {
591 document.newmember.action.value="create";
592 document.newmember.submit();
601$listofpartnershipobj = $partnershiptype->fetchAll(
'',
'', 1000, 0,
'(active:=:1)');
602$listofpartnership = array();
603foreach ($listofpartnershipobj as $partnershipobj) {
604 $listofpartnership[$partnershipobj->id] = $partnershipobj->label;
608 print $listofpartnership[
getDolGlobalInt(
'PARTNERSHIP_NEWFORM_FORCETYPE')];
609 print
'<input type="hidden" id="partnershiptype" name="partnershiptype" value="' .
getDolGlobalInt(
'PARTNERSHIP_NEWFORM_FORCETYPE').
'">';
612print
'<table class="border" summary="form to subscribe" id="tablesubscribe">'.
"\n";
614 print
'<tr class="morphy"><td class="classfortooltip" title="'.dol_escape_htmltag($messagemandatory).
'">'.$langs->trans(
'PartnershipType').
' <span class="star">*</span></td><td>'.
"\n";
615 print $form->selectarray(
"partnershiptype", $listofpartnership, GETPOSTISSET(
'partnershiptype') ?
GETPOSTINT(
'partnershiptype') :
'ifone', 1);
616 print
'</td></tr>'.
"\n";
619print
'<tr id="trcompany" class="trcompany"><td class="classfortooltip" title="'.dol_escape_htmltag($messagemandatory).
'">'.$langs->trans(
"Company").
' <span class="star">*</span></td><td>';
620print
img_picto(
'',
'company',
'class="pictofixedwidth"');
621print
'<input type="text" name="societe" class="minwidth150 maxwidth300 widthcentpercentminusxx" value="'.dol_escape_htmltag(
GETPOST(
'societe')).
'"></td></tr>'.
"\n";
623print
'<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";
625print
'<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";
627print
'<tr><td class="classfortooltip" title="'.dol_escape_htmltag($messagemandatory).
'">'.$langs->trans(
"Email").
' <span class="star">*</span></td><td>';
629print
'<input type="text" name="email" maxlength="255" class="minwidth150" value="'.dol_escape_htmltag(
GETPOST(
'email')).
'"></td></tr>'.
"\n";
631print
'<tr><td class="tdtop">'.$langs->trans(
"Url").
' <span class="star">*</span></td><td>';
632print
'<input type="text" name="url" maxlength="255" class="minwidth150" value="'.dol_escape_htmltag(
GETPOST(
'url')).
'">';
634 $listofkeytocheck = explode(
'|',
getDolGlobalString(
'PARTNERSHIP_BACKLINKS_TO_CHECK'));
637 foreach ($listofkeytocheck as $val) {
639 $s .= ($s ? ($i == count($listofkeytocheck) ?
' '.$langs->trans(
"or").
' ' :
', ') :
'').$val;
641 print
'<br><span class="opacitymedium small">'.$langs->trans(
"ThisUrlMustContainsAtLeastOneLinkToWebsite", $s).
'</small>';
643print
'</td></tr>'.
"\n";
645print
'<tr><td class="tdtop">'.$langs->trans(
"Address").
'</td><td>'.
"\n";
646print
'<textarea name="address" id="address" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.
'">'.
dol_escape_htmltag(
GETPOST(
'address',
'restricthtml'), 0, 1).
'</textarea></td></tr>'.
"\n";
648print
'<tr><td>'.$langs->trans(
'Zip').
' / '.$langs->trans(
'Town').
'</td><td>';
649print $formcompany->select_ziptown(
GETPOST(
'zipcode'),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6, 1);
651print $formcompany->select_ziptown(
GETPOST(
'town'),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'), 0, 1);
654print
'<tr><td>'.$langs->trans(
'Country').
'</td><td>';
655print
img_picto(
'',
'country',
'class="pictofixedwidth"');
658 $country_id =
getCountry($conf->global->PARTNERSHIP_NEWFORM_FORCECOUNTRYCODE,
'2', $db, $langs);
660if (!$country_id && !empty($conf->geoipmaxmind->enabled)) {
664 $new_country_id =
getCountry($country_code,
'3', $db, $langs);
666 if ($new_country_id) {
667 $country_id = $new_country_id;
671$country_code =
getCountry($country_id,
'2', $db, $langs);
672print $form->select_country($country_id,
'country_id');
676 print
'<tr><td class="wordbreak">'.$langs->trans(
'State').
'</td><td>';
678 print $formcompany->select_state(
GETPOST(
"state_id"), $country_code);
685$parameters[
'tdclass'] =
'titlefieldauto';
686$parameters[
'tpl_context'] =
'public';
687include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
690print
'<td class="tdtop wordbreak">'.$langs->trans(
"Comments").
'</td>';
691print
'<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>';
699print
'<div class="center">';
700print
'<input type="submit" value="'.$langs->trans(
"Submit").
'" id="submitsave" class="button">';
701if (!empty($backtopage)) {
702 print
' <input type="submit" value="'.$langs->trans(
"Cancel").
'" id="submitcancel" class="button button-cancel">';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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.
llxFooterVierge()
Show footer for new societe.
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.
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)
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)
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.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
getUserRemoteIP()
Return the IP of remote user.
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.