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');
48 $entity = (!empty($_GET[
'entity']) ? (int) $_GET[
'entity'] : (!empty($_POST[
'entity']) ? (int) $_POST[
'entity'] : 1));
49 if (is_numeric($entity)) {
50 define(
"DOLENTITY", $entity);
54 require
'../../main.inc.php';
55 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
56 require_once DOL_DOCUMENT_ROOT.
'/partnership/class/partnership.class.php';
57 require_once DOL_DOCUMENT_ROOT.
'/partnership/class/partnership_type.class.php';
58 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
59 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
60 require_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"));
73 if (empty($conf->partnership->enabled)) {
77 if (empty($conf->global->PARTNERSHIP_ENABLE_PUBLIC)) {
82 $hookmanager->initHooks(array(
'publicnewpartnershipcard',
'globalcard'));
88 $user->loadDefaultValues();
102 function 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">';
166 $parameters = array();
168 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
174 if (empty($reshook) && $action ==
'add') {
180 if (
GETPOST(
'partnershiptype',
'int') <= 0) {
182 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")).
"<br>\n";
186 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"societe")).
"<br>\n";
190 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Lastname")).
"<br>\n";
194 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Firstname")).
"<br>\n";
199 $errmsg .= $langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Email')).
"<br>\n";
201 $langs->load(
'errors');
203 $errmsg .= $langs->trans(
"ErrorBadEMail",
GETPOST(
"email")).
"<br>\n";
213 $partnership->fk_member = 0;
214 } elseif (
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR',
'thirdparty') ==
'member') {
215 $partnership->fk_soc = 0;
218 $partnership->status = 0;
219 $partnership->note_private =
GETPOST(
'note_private');
220 $partnership->date_creation =
dol_now();
221 $partnership->date_partnership_start =
dol_now();
222 $partnership->fk_user_creat = 0;
223 $partnership->fk_type =
GETPOST(
'partnershiptype',
'int');
227 $nb_post_max =
getDolGlobalInt(
"MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
232 if ($nb_post_max > 0) {
233 $sql =
"SELECT COUNT(ref) as nb_partnerships";
234 $sql .=
" FROM ".MAIN_DB_PREFIX.
"partnership";
235 $sql .=
" WHERE ip = '".$db->escape($partnership->ip).
"'";
236 $sql .=
" AND date_creation > '".$db->idate($minmonthpost).
"'";
237 $resql = $db->query($sql);
239 $num = $db->num_rows(
$resql);
243 $obj = $db->fetch_object(
$resql);
244 $nb_post_ip = $obj->nb_partnerships;
250 $result = $company->fetch(0,
GETPOST(
'societe'));
252 $result1 = $company->fetch(0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
GETPOST(
'email'));
255 $errmsg = $langs->trans(
"EmailAlreadyExistsPleaseRewriteYourCompanyName");
260 $company->name =
GETPOST(
'societe');
261 $company->address =
GETPOST(
'address');
262 $company->zip =
GETPOST(
'zipcode');
263 $company->town =
GETPOST(
'town');
264 $company->email =
GETPOST(
'email');
265 $company->country_id =
GETPOST(
'country_id',
'int');
266 $company->state_id =
GETPOST(
'state_id',
'int');
269 $resultat=$company->create($user);
272 $errmsg .= join(
'<br>', $company->errors);
275 $partnership->fk_soc = $company->id;
277 } elseif ($result == -2) {
279 $errmsg = $langs->trans(
"TwoRecordsOfCompanyName");
281 $partnership->fk_soc = $company->id;
283 if (empty($company->address)) {
284 $company->address =
GETPOST(
'address');
286 if (empty($company->zip)) {
287 $company->zip =
GETPOST(
'zipcode');
289 if (empty($company->town)) {
290 $company->town =
GETPOST(
'town');
292 if (empty($company->country_id)) {
293 $company->country_id =
GETPOST(
'country_id',
'int');
295 if (empty($company->email)) {
296 $company->email =
GETPOST(
'email');
298 if (empty($company->state_id)) {
299 $company->state_id =
GETPOST(
'state_id',
'int');
301 if (empty($company->name_alias)) {
308 $extrafields->fetch_name_optionals_label($partnership->table_element);
309 $ret = $extrafields->setOptionalsFromPost(
null, $partnership);
314 if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
316 $errmsg = $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress");
317 array_push($partnership->errors, $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress"));
320 $result = $partnership->create($user);
408 if (!empty($backtopage)) {
409 $urlback = $backtopage;
410 } elseif (!empty($conf->global->PARTNERSHIP_URL_REDIRECT_SUBSCRIPTION)) {
411 $urlback = $conf->global->PARTNERSHIP_URL_REDIRECT_SUBSCRIPTION;
414 $urlback = $_SERVER[
"PHP_SELF"].
"?action=added&token=".
newToken();
485 if (!empty($entity)) {
486 $urlback .=
'&entity='.$entity;
488 dol_syslog(
"partnership ".$partnership->ref.
" was created, we redirect to ".$urlback);
491 $errmsg .= join(
'<br>', $partnership->errors);
501 Header(
"Location: ".$urlback);
511 if (empty($reshook) && $action ==
'added') {
516 print
'<div class="center">';
517 print $langs->trans(
"NewPartnershipbyWeb");
533 $extrafields->fetch_name_optionals_label($object->table_element);
539 print
load_fiche_titre($langs->trans(
"NewPartnershipRequest"),
'',
'', 0, 0,
'center');
542 print
'<div align="center">';
543 print
'<div id="divsubscribe">';
545 print
'<div class="center subscriptionformhelptext justify">';
546 if (!empty($conf->global->PARTNERSHIP_NEWFORM_TEXT)) {
547 print $langs->trans($conf->global->PARTNERSHIP_NEWFORM_TEXT).
"<br>\n";
549 print $langs->trans(
"NewPartnershipRequestDesc",
getDolGlobalString(
"MAIN_INFO_SOCIETE_MAIL")).
"<br>\n";
556 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="newmember">'.
"\n";
557 print
'<input type="hidden" name="token" value="'.newToken().
'" / >';
558 print
'<input type="hidden" name="entity" value="'.$entity.
'" />';
559 print
'<input type="hidden" name="action" value="add" />';
563 print
'<br><span class="opacitymedium">'.$langs->trans(
"FieldsWithAreMandatory",
'*').
'</span><br>';
568 print
'<script type="text/javascript">
569 jQuery(document).ready(function () {
570 jQuery(document).ready(function () {
571 jQuery("#selectcountry_id").change(function() {
572 document.newmember.action.value="create";
573 document.newmember.submit();
580 print
'<table class="border" summary="form to subscribe" id="tablesubscribe">'.
"\n";
603 $listofpartnershipobj = $partnershiptype->fetchAll(
'',
'', 1000);
604 $listofpartnership = array();
605 foreach ($listofpartnershipobj as $partnershipobj) {
606 $listofpartnership[$partnershipobj->id] = $partnershipobj->label;
609 if (empty($conf->global->PARTNERSHIP_NEWFORM_FORCETYPE)) {
610 print
'<tr class="morphy"><td class="titlefield">'.$langs->trans(
'PartnershipType').
' <span style="color: red">*</span></td><td>'.
"\n";
611 print
$form->selectarray(
"partnershiptype", $listofpartnership,
GETPOSTISSET(
'partnershiptype') ?
GETPOST(
'partnershiptype',
'int') :
'ifone', 1);
612 print
'</td></tr>'.
"\n";
614 print $listofpartnership[$conf->global->PARTNERSHIP_NEWFORM_FORCETYPE];
615 print
'<input type="hidden" id="partnershiptype" name="partnershiptype" value="'.$conf->global->PARTNERSHIP_NEWFORM_FORCETYPE.
'">';
619 print
'<tr id="trcompany" class="trcompany"><td>'.$langs->trans(
"Company").
' <span style="color:red;">*</span></td><td>';
620 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
621 print
'<input type="text" name="societe" class="minwidth150" value="'.dol_escape_htmltag(
GETPOST(
'societe')).
'"></td></tr>'.
"\n";
623 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";
625 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";
627 print
'<tr><td>'.$langs->trans(
"Email").
' <span style="color:red;">*</span></td><td>';
629 print
'<input type="text" name="email" maxlength="255" class="minwidth200" value="'.dol_escape_htmltag(
GETPOST(
'email')).
'"></td></tr>'.
"\n";
631 print
'<tr><td>'.$langs->trans(
"Address").
'</td><td>'.
"\n";
632 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";
634 print
'<tr><td>'.$langs->trans(
'Zip').
' / '.$langs->trans(
'Town').
'</td><td>';
635 print $formcompany->select_ziptown(
GETPOST(
'zipcode'),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6, 1);
637 print $formcompany->select_ziptown(
GETPOST(
'town'),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'), 0, 1);
640 print
'<tr><td>'.$langs->trans(
'Country').
'</td><td>';
641 print
img_picto(
'',
'country',
'class="pictofixedwidth"');
642 $country_id =
GETPOST(
'country_id',
'int');
643 if (!$country_id && !empty($conf->global->PARTNERSHIP_NEWFORM_FORCECOUNTRYCODE)) {
644 $country_id =
getCountry($conf->global->PARTNERSHIP_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs);
646 if (!$country_id && !empty($conf->geoipmaxmind->enabled)) {
650 $new_country_id =
getCountry($country_code, 3, $db, $langs);
652 if ($new_country_id) {
653 $country_id = $new_country_id;
657 $country_code =
getCountry($country_id, 2, $db, $langs);
658 print
$form->select_country($country_id,
'country_id');
661 if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
662 print
'<tr><td>'.$langs->trans(
'State').
'</td><td>';
664 print $formcompany->select_state(
GETPOST(
"state_id"), $country_code);
671 $tpl_context =
'public';
672 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
675 print
'<td class="tdtop">'.$langs->trans(
"Comments").
'</td>';
676 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>';
684 print
'<div class="center">';
685 print
'<input type="submit" value="'.$langs->trans(
"Submit").
'" id="submitsave" class="button">';
686 if (!empty($backtopage)) {
687 print
' <input type="submit" value="'.$langs->trans(
"Cancel").
'" id="submitcancel" class="button button-cancel">';
694 print
'</div></div>';
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.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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='')
Show tabs of a record.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
dol_user_country()
Return country code for current user.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages 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)
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.
setEventMessage($mesgs, $style='mesgs')
Set event message in dol_events session object.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
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.
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Ouput html header of a page.
llxHeaderVierge($title, $head="", $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='')
Show header for new member.
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.