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';
75$backtopage =
GETPOST(
'backtopage',
'alpha');
76$action =
GETPOST(
'action',
'aZ09');
79$langs->loadLangs(array(
"main",
"members",
"partnership",
"companies",
"install",
"other"));
82if (!isModEnabled(
'partnership')) {
91$hookmanager->initHooks(array(
'publicnewpartnershipcard',
'globalcard'));
97$user->loadDefaultValues();
111function llxHeaderVierge($title, $head =
"", $disablejs = 0, $disablehead = 0, $arrayofjs = [], $arrayofcss = [])
113 global
$conf, $langs, $mysoc;
115 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
117 print
'<body id="mainbody" class="publicnewmemberform">';
120 $urllogo = DOL_URL_ROOT.
'/theme/common/login_logo.png';
122 if (!empty($mysoc->logo_small) && is_readable(
$conf->mycompany->dir_output.
'/logos/thumbs/'.$mysoc->logo_small)) {
123 $urllogo = DOL_URL_ROOT.
'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode(
'logos/thumbs/'.$mysoc->logo_small);
124 } elseif (!empty($mysoc->logo) && is_readable(
$conf->mycompany->dir_output.
'/logos/'.$mysoc->logo)) {
125 $urllogo = DOL_URL_ROOT.
'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode(
'logos/'.$mysoc->logo);
126 } elseif (is_readable(DOL_DOCUMENT_ROOT.
'/theme/dolibarr_logo.svg')) {
127 $urllogo = DOL_URL_ROOT.
'/theme/dolibarr_logo.svg';
130 print
'<div class="center">';
134 print
'<div class="backgreypublicpayment">';
135 print
'<div class="logopublicpayment">';
136 print
'<img id="dolpaymentlogo" src="'.$urllogo.
'">';
139 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>';
145 print
'<div class="backimagepublicregistration">';
146 print
'<img id="idPARTNERSHIP_IMAGE_PUBLIC_INTERFACE" src="' .
getDolGlobalString(
'PARTNERSHIP_IMAGE_PUBLIC_REGISTRATION').
'">';
152 print
'<div class="divmainbodylarge">';
162 global
$conf, $langs;
168 if (!empty(
$conf->use_javascript_ajax)) {
169 print
"\n".
'<!-- Includes JS Footer of Dolibarr -->'.
"\n";
170 print
'<script src="'.DOL_URL_ROOT.
'/core/js/lib_foot.js.php?lang='.$langs->defaultlang.
'"></script>'.
"\n";
183$parameters = array();
185$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
191if (empty($reshook) && $action ==
'add') {
199 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")).
"<br>\n";
203 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"societe")).
"<br>\n";
207 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Lastname")).
"<br>\n";
211 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Firstname")).
"<br>\n";
216 $errmsg .= $langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Email')).
"<br>\n";
218 $langs->load(
'errors');
220 $errmsg .= $langs->trans(
"ErrorBadEMail",
GETPOST(
"email")).
"<br>\n";
223 $public = GETPOSTISSET(
'public') ? 1 : 0;
230 $partnership->fk_member = 0;
231 } elseif (
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR',
'thirdparty') ==
'member') {
232 $partnership->fk_soc = 0;
235 $partnership->status = 0;
236 $partnership->note_private =
GETPOST(
'note_private');
237 $partnership->date_creation =
dol_now();
238 $partnership->date_partnership_start =
dol_now();
239 $partnership->fk_user_creat = 0;
240 $partnership->fk_type =
GETPOSTINT(
'partnershiptype');
241 $partnership->url =
GETPOST(
'url');
245 $nb_post_max =
getDolGlobalInt(
"MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
250 if ($nb_post_max > 0) {
251 $sql =
"SELECT COUNT(ref) as nb_partnerships";
252 $sql .=
" FROM ".MAIN_DB_PREFIX.
"partnership";
253 $sql .=
" WHERE ip = '".$db->escape($partnership->ip).
"'";
254 $sql .=
" AND date_creation > '".$db->idate($minmonthpost).
"'";
255 $resql = $db->query($sql);
257 $num = $db->num_rows($resql);
261 $obj = $db->fetch_object($resql);
262 $nb_post_ip = $obj->nb_partnerships;
268 $result = $company->fetch(0,
GETPOST(
'societe'));
270 $result1 = $company->fetch(0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
GETPOST(
'email'));
273 $errmsg = $langs->trans(
"EmailAlreadyExistsPleaseRewriteYourCompanyName");
278 $company->name =
GETPOST(
'societe');
279 $company->address =
GETPOST(
'address');
280 $company->zip =
GETPOST(
'zipcode');
281 $company->town =
GETPOST(
'town');
282 $company->email =
GETPOST(
'email');
283 $company->url =
GETPOST(
'url');
284 $company->country_id =
GETPOSTINT(
'country_id');
288 $resultat = $company->create($user);
291 $errmsg .= implode(
'<br>', $company->errors);
294 $partnership->fk_soc = $company->id;
296 } elseif ($result == -2) {
298 $errmsg = $langs->trans(
"TwoRecordsOfCompanyName");
300 $partnership->fk_soc = $company->id;
302 if (empty($company->address)) {
303 $company->address =
GETPOST(
'address');
305 if (empty($company->zip)) {
306 $company->zip =
GETPOST(
'zipcode');
308 if (empty($company->town)) {
309 $company->town =
GETPOST(
'town');
311 if (empty($company->country_id)) {
312 $company->country_id =
GETPOSTINT(
'country_id');
314 if (empty($company->email)) {
315 $company->email =
GETPOST(
'email');
317 if (empty($company->url)) {
318 $company->url =
GETPOST(
'url');
320 if (empty($company->state_id)) {
323 if (empty($company->name_alias)) {
327 $res = $company->update(0, $user);
334 $extrafields->fetch_name_optionals_label($partnership->table_element);
335 $ret = $extrafields->setOptionalsFromPost(
null, $partnership);
340 if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
342 $errmsg = $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress");
343 array_push($partnership->errors, $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress"));
346 $result = $partnership->create($user);
434 if (!empty($backtopage)) {
435 $urlback = $backtopage;
440 $urlback = $_SERVER[
"PHP_SELF"].
"?action=added&token=".
newToken();
511 if (!empty($entity)) {
512 $urlback .=
'&entity='.$entity;
514 dol_syslog(
"partnership ".$partnership->ref.
" was created, we redirect to ".$urlback);
517 $errmsg .= implode(
'<br>', $partnership->errors);
527 header(
"Location: ".$urlback);
537if (empty($reshook) && $action ==
'added') {
542 print
'<div class="center">';
543 print $langs->trans(
"NewPartnershipbyWeb");
556$form =
new Form($db);
559$extrafields->fetch_name_optionals_label(
$object->table_element);
565print
load_fiche_titre(
img_picto(
'',
'hands-helping',
'class="pictofixedwidth"').
' '.$langs->trans(
"NewPartnershipRequest"),
'',
'', 0,
'',
'center');
568print
'<div align="center">';
569print
'<div id="divsubscribe">';
571print
'<div class="center subscriptionformhelptext opacitymedium justify">';
575 print $langs->trans(
"NewPartnershipRequestDesc",
getDolGlobalString(
"MAIN_INFO_SOCIETE_MAIL")).
"<br>\n";
582print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="newmember">'.
"\n";
583print
'<input type="hidden" name="token" value="'.newToken().
'" / >';
584print
'<input type="hidden" name="entity" value="'.$entity.
'" />';
585print
'<input type="hidden" name="action" value="add" />';
589$messagemandatory =
'<span class="">'.$langs->trans(
"FieldsWithAreMandatory",
'*').
'</span>';
595print
'<script type="text/javascript">
596jQuery(document).ready(function () {
597 jQuery(document).ready(function () {
598 jQuery("#selectcountry_id").change(function() {
599 document.newmember.action.value="create";
600 document.newmember.submit();
609$listofpartnershipobj = $partnershiptype->fetchAll(
'',
'', 1000, 0,
'(active:=:1)');
610$listofpartnership = array();
611foreach ($listofpartnershipobj as $partnershipobj) {
612 $listofpartnership[$partnershipobj->id] = $partnershipobj->label;
616 print $listofpartnership[
getDolGlobalInt(
'PARTNERSHIP_NEWFORM_FORCETYPE')];
617 print
'<input type="hidden" id="partnershiptype" name="partnershiptype" value="' .
getDolGlobalInt(
'PARTNERSHIP_NEWFORM_FORCETYPE').
'">';
620print
'<table class="border" summary="form to subscribe" id="tablesubscribe">'.
"\n";
622 print
'<tr class="morphy"><td class="classfortooltip" title="'.dol_escape_htmltag($messagemandatory).
'">'.$langs->trans(
'PartnershipType').
' <span class="star">*</span></td><td>'.
"\n";
623 print $form->selectarray(
"partnershiptype", $listofpartnership, GETPOSTISSET(
'partnershiptype') ?
GETPOSTINT(
'partnershiptype') :
'ifone', 1);
624 print
'</td></tr>'.
"\n";
627print
'<tr id="trcompany" class="trcompany"><td class="classfortooltip" title="'.dol_escape_htmltag($messagemandatory).
'">'.$langs->trans(
"Company").
' <span class="star">*</span></td><td>';
628print
img_picto(
'',
'company',
'class="pictofixedwidth"');
629print
'<input type="text" name="societe" class="minwidth150 maxwidth300 widthcentpercentminusxx" value="'.dol_escape_htmltag(
GETPOST(
'societe')).
'"></td></tr>'.
"\n";
631print
'<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";
633print
'<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";
635print
'<tr><td class="classfortooltip" title="'.dol_escape_htmltag($messagemandatory).
'">'.$langs->trans(
"Email").
' <span class="star">*</span></td><td>';
637print
'<input type="text" name="email" maxlength="255" class="minwidth150" value="'.dol_escape_htmltag(
GETPOST(
'email')).
'"></td></tr>'.
"\n";
639print
'<tr><td class="tdtop">'.$langs->trans(
"Url").
' <span class="star">*</span></td><td>';
640print
'<input type="text" name="url" maxlength="255" class="minwidth150" value="'.dol_escape_htmltag(
GETPOST(
'url')).
'">';
642 $listofkeytocheck = explode(
'|',
getDolGlobalString(
'PARTNERSHIP_BACKLINKS_TO_CHECK'));
645 foreach ($listofkeytocheck as $val) {
647 $s .= ($s ? ($i == count($listofkeytocheck) ?
' '.$langs->trans(
"or").
' ' :
', ') :
'').$val;
649 print
'<br><span class="opacitymedium small">'.$langs->trans(
"ThisUrlMustContainsAtLeastOneLinkToWebsite", $s).
'</small>';
651print
'</td></tr>'.
"\n";
653print
'<tr><td class="tdtop">'.$langs->trans(
"Address").
'</td><td>'.
"\n";
654print
'<textarea name="address" id="address" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.
'">'.
dol_escape_htmltag(
GETPOST(
'address',
'restricthtml'), 0, 1).
'</textarea></td></tr>'.
"\n";
656print
'<tr><td>'.$langs->trans(
'Zip').
' / '.$langs->trans(
'Town').
'</td><td>';
657print $formcompany->select_ziptown(
GETPOST(
'zipcode'),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6, 1);
659print $formcompany->select_ziptown(
GETPOST(
'town'),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'), 0, 1);
662print
'<tr><td>'.$langs->trans(
'Country').
'</td><td>';
663print
img_picto(
'',
'country',
'class="pictofixedwidth"');
666 $country_id =
getCountry(
$conf->global->PARTNERSHIP_NEWFORM_FORCECOUNTRYCODE,
'2', $db, $langs);
668if (!$country_id && !empty(
$conf->geoipmaxmind->enabled)) {
672 $new_country_id =
getCountry($country_code,
'3', $db, $langs);
674 if ($new_country_id) {
675 $country_id = $new_country_id;
679$country_code =
getCountry($country_id,
'2', $db, $langs);
680print $form->select_country($country_id,
'country_id');
684 print
'<tr><td class="wordbreak">'.$langs->trans(
'State').
'</td><td>';
686 print $formcompany->select_state(
GETPOST(
"state_id"), $country_code);
693$parameters[
'tdclass'] =
'titlefieldauto';
694$parameters[
'tpl_context'] =
'public';
695include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
698print
'<td class="tdtop wordbreak">'.$langs->trans(
"Comments").
'</td>';
699print
'<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>';
707print
'<div class="center">';
708print
'<input type="submit" value="'.$langs->trans(
"Submit").
'" id="submitsave" class="button">';
709if (!empty($backtopage)) {
710 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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.