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';
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';
76$backtopage =
GETPOST(
'backtopage',
'alpha');
77$action =
GETPOST(
'action',
'aZ09');
80$langs->loadLangs(array(
"main",
"members",
"partnership",
"companies",
"install",
"other"));
92$hookmanager->initHooks(array(
'publicnewpartnershipcard',
'globalcard'));
98$user->loadDefaultValues();
100if (!is_object($user)) {
118function llxHeaderVierge($title, $head =
"", $disablejs = 0, $disablehead = 0, $arrayofjs = [], $arrayofcss = [], $ws =
'')
122 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
124 print
'<body id="mainbody" class="publicnewmemberform">';
126 include_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
129 print
'<div class="divmainbodylarge">';
141 global
$conf, $langs;
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";
162$parameters = array();
164$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
170if (empty($reshook) && $action ==
'add') {
178 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")).
"<br>\n";
182 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ThirdParty")).
"<br>\n";
186 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Lastname")).
"<br>\n";
190 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Firstname")).
"<br>\n";
195 $errmsg .= $langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Email')).
"<br>\n";
197 $langs->load(
'errors');
199 $errmsg .= $langs->trans(
"ErrorBadEMail",
GETPOST(
"email")).
"<br>\n";
202 $public = GETPOSTISSET(
'public') ? 1 : 0;
209 $partnership->fk_member = 0;
210 } elseif (
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR',
'thirdparty') ==
'member') {
211 $partnership->fk_soc = 0;
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');
224 $nb_post_max =
getDolGlobalInt(
"MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
229 if ($nb_post_max > 0) {
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);
236 $num =
$db->num_rows($resql);
240 $obj =
$db->fetch_object($resql);
241 $nb_post_ip = $obj->nb_partnerships;
247 $result = $company->fetch(0,
GETPOST(
'societe'));
249 $result1 = $company->fetch(0,
'',
'',
'',
'',
'',
'',
'',
'',
'',
GETPOST(
'email'));
252 $errmsg = $langs->trans(
"EmailAlreadyExistsPleaseRewriteYourCompanyName");
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');
267 $resultat = $company->create($user);
270 $errmsg .= implode(
'<br>', $company->errors);
273 $partnership->fk_soc = $company->id;
275 } elseif ($result == -2) {
277 $errmsg = $langs->trans(
"TwoRecordsOfCompanyName");
279 $partnership->fk_soc = $company->id;
281 if (empty($company->address)) {
282 $company->address =
GETPOST(
'address');
284 if (empty($company->zip)) {
285 $company->zip =
GETPOST(
'zipcode');
287 if (empty($company->town)) {
288 $company->town =
GETPOST(
'town');
290 if (empty($company->country_id)) {
291 $company->country_id =
GETPOSTINT(
'country_id');
293 if (empty($company->email)) {
294 $company->email =
GETPOST(
'email');
296 if (empty($company->url)) {
297 $company->url =
GETPOST(
'url');
299 if (empty($company->state_id)) {
302 if (empty($company->name_alias)) {
306 $res = $company->update(0, $user);
313 $extrafields->fetch_name_optionals_label($partnership->table_element);
314 $ret = $extrafields->setOptionalsFromPost(
null, $partnership);
319 if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
321 $errmsg = $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress");
322 array_push($partnership->errors, $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress"));
325 $result = $partnership->create($user);
413 if (!empty($backtopage)) {
414 $urlback = $backtopage;
419 $urlback = $_SERVER[
"PHP_SELF"].
"?action=added&token=".newToken();
474 if (!empty($entity)) {
475 $urlback .=
'&entity='.$entity;
477 dol_syslog(
"partnership ".$partnership->ref.
" was created, we redirect to ".$urlback);
480 $errmsg .= implode(
'<br>', $partnership->errors);
490 header(
"Location: ".$urlback);
500if (empty($reshook) && $action ==
'added') {
505 print
'<div class="center">';
506 print $langs->trans(
"NewPartnershipbyWeb");
522$extrafields->fetch_name_optionals_label(
$object->table_element);
528print
load_fiche_titre(
img_picto(
'',
'hands-helping',
'class="pictofixedwidth"').
' '.$langs->trans(
"NewPartnershipRequest"),
'',
'', 0,
'',
'center');
531print
'<div align="center">';
532print
'<div id="divsubscribe">';
534print
'<div class="center subscriptionformhelptext opacitymedium justify">';
538 print $langs->trans(
"NewPartnershipRequestDesc",
getDolGlobalString(
"MAIN_INFO_SOCIETE_MAIL")).
"<br>\n";
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" />';
552$messagemandatory =
'<span class="">'.$langs->trans(
"FieldsWithAreMandatory",
'*').
'</span>';
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();
572$listofpartnershipobj = $partnershiptype->fetchAll(
'',
'', 1000, 0,
'(active:=:1)');
573$listofpartnership = array();
574foreach ($listofpartnershipobj as $partnershipobj) {
575 $listofpartnership[$partnershipobj->id] = $partnershipobj->label;
579 print $listofpartnership[
getDolGlobalInt(
'PARTNERSHIP_NEWFORM_FORCETYPE')];
580 print
'<input type="hidden" id="partnershiptype" name="partnershiptype" value="' .
getDolGlobalInt(
'PARTNERSHIP_NEWFORM_FORCETYPE').
'">';
583print
'<table class="border" summary="form to subscribe" id="tablesubscribe">'.
"\n";
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";
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";
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";
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";
598print
'<tr><td class="classfortooltip" title="'.dol_escape_htmltag($messagemandatory).
'">'.$langs->trans(
"Email").
' <span class="star">*</span></td><td>';
600print
'<input type="text" name="email" maxlength="255" class="minwidth150" value="'.dol_escape_htmltag(
GETPOST(
'email')).
'"></td></tr>'.
"\n";
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')).
'">';
605 $listofkeytocheck = explode(
'|',
getDolGlobalString(
'PARTNERSHIP_BACKLINKS_TO_CHECK'));
608 foreach ($listofkeytocheck as $val) {
610 $s .= ($s ? ($i == count($listofkeytocheck) ?
' '.$langs->trans(
"or").
' ' :
', ') :
'').$val;
612 print
'<br><span class="opacitymedium small">'.$langs->trans(
"ThisUrlMustContainsAtLeastOneLinkToWebsite", $s).
'</small>';
614print
'</td></tr>'.
"\n";
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";
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);
622print $formcompany->select_ziptown(
GETPOST(
'town'),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'), 0, 1);
625print
'<tr><td>'.$langs->trans(
'Country').
'</td><td>';
626print
img_picto(
'',
'country',
'class="pictofixedwidth"');
629 $country_id =
getCountry(
$conf->global->PARTNERSHIP_NEWFORM_FORCECOUNTRYCODE,
'2',
$db, $langs);
631if (!$country_id && !empty(
$conf->geoipmaxmind->enabled)) {
635 $new_country_id =
getCountry($country_code,
'3',
$db, $langs);
637 if ($new_country_id) {
638 $country_id = $new_country_id;
643print $form->select_country($country_id,
'country_id');
647 print
'<tr><td class="wordbreak">'.$langs->trans(
'State').
'</td><td>';
649 print $formcompany->select_state(
GETPOSTINT(
"state_id"), $country_code);
656$parameters[
'tdclass'] =
'titlefieldauto';
657$parameters[
'tpl_context'] =
'public';
658include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
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>';
670print
'<div class="center">';
671print
'<input type="submit" value="'.$langs->trans(
"Submit").
'" id="submitsave" class="button">';
672if (!empty($backtopage)) {
673 print
' <input type="submit" value="'.$langs->trans(
"Cancel").
'" id="submitcancel" class="button button-cancel">';
if(! $sortfield) if(! $sortorder) $object
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.
llxFooterVierge()
Show footer for new societe.
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.
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.