30 if (!defined(
'NOLOGIN')) {
33 if (!defined(
'NOCSRFCHECK')) {
34 define(
"NOCSRFCHECK", 1);
36 if (!defined(
'NOIPCHECK')) {
37 define(
'NOIPCHECK',
'1');
39 if (!defined(
'NOBROWSERNOTIF')) {
40 define(
'NOBROWSERNOTIF',
'1');
42 if (!defined(
'NOIPCHECK')) {
43 define(
'NOIPCHECK',
'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.
'/core/lib/json.lib.php';
57 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.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';
65 $backtopage =
GETPOST(
'backtopage',
'alpha');
66 $action =
GETPOST(
'action',
'aZ09');
69 $langs->loadLangs(array(
"members",
"companies",
"install",
"other",
"projects"));
71 if (empty($conf->global->PROJECT_ENABLE_PUBLIC)) {
72 print $langs->trans(
"Form for public lead registration has not been enabled");
77 $hookmanager->initHooks(array(
'publicnewleadcard',
'globalcard'));
83 $user->loadDefaultValues();
86 if (empty($conf->project->enabled)) {
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.
'"';
130 if (empty($conf->global->MAIN_HIDE_POWERED_BY)) {
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>';
136 if (!empty($conf->global->PROJECT_IMAGE_PUBLIC_NEWLEAD)) {
137 print
'<div class="backimagepublicnewlead">';
138 print
'<img id="idPROJECT_IMAGE_PUBLIC_NEWLEAD" src="'.$conf->global->PROJECT_IMAGE_PUBLIC_NEWLEAD.
'">';
144 print
'<div class="divmainbodylarge">';
168 $parameters = array();
170 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
176 if (empty($reshook) && $action ==
'add') {
184 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Lastname")).
"<br>\n";
188 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Firstname")).
"<br>\n";
192 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Email")).
"<br>\n";
196 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Message")).
"<br>\n";
200 $langs->load(
"errors");
201 $errmsg .= $langs->trans(
"ErrorBadEMail",
GETPOST(
"email")).
"<br>\n";
204 $defaultoppstatus =
getDolGlobalString(
'PROJECT_DEFAULT_OPPORTUNITY_STATUS_FOR_ONLINE_LEAD');
205 if (empty($defaultoppstatus)) {
207 $langs->load(
"errors");
208 $errmsg .= $langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv(
"Project")).
"<br>\n";
212 $thirdparty =
new Societe($db);
216 $result = $thirdparty->fetch(0,
'',
'',
'',
'',
'',
'',
'',
'',
'', $object->email);
218 $proj->socid = $thirdparty->id;
222 $thirdparty->name =
GETPOST(
'societe');
227 $thirdparty->email =
GETPOST(
'email');
228 $thirdparty->address =
GETPOST(
'address');
229 $thirdparty->zip =
GETPOST(
'zip');
230 $thirdparty->town =
GETPOST(
'town');
231 $thirdparty->country_id =
GETPOST(
'country_id',
'int');
232 $thirdparty->state_id =
GETPOST(
'state_id');
233 $thirdparty->client = $thirdparty::PROSPECT;
234 $thirdparty->code_client =
'auto';
235 $thirdparty->code_fournisseur =
'auto';
238 $extrafields->fetch_name_optionals_label($thirdparty->table_element);
239 $ret = $extrafields->setOptionalsFromPost(
null, $thirdparty,
'', 1);
243 $errmsg = ($extrafields->error ? $extrafields->error.
'<br>' :
'').join(
'<br>', $extrafields->errors);
247 $result = $thirdparty->create($user);
250 $errmsg = ($thirdparty->error ? $thirdparty->error.
'<br>' :
'').join(
'<br>', $thirdparty->errors);
252 $proj->socid = $thirdparty->id;
261 $modele = empty($conf->global->PROJECT_ADDON) ?
'mod_project_simple' : $conf->global->PROJECT_ADDON;
264 $file =
''; $classname =
''; $filefound = 0;
265 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
266 foreach ($dirmodels as $reldir) {
267 $file =
dol_buildpath($reldir.
"core/modules/project/".$modele.
'.php', 0);
268 if (file_exists($file)) {
270 $classname = $modele;
277 $modProject =
new $classname;
279 $defaultref = $modProject->getNextValue($thirdparty, $object);
282 if (is_numeric($defaultref) && $defaultref <= 0) {
286 if (empty($defaultref)) {
287 $defaultref =
'PJ'.dol_print_date(
dol_now(),
'dayrfc');
290 $proj->ref = $defaultref;
291 $proj->statut = $proj::STATUS_DRAFT;
292 $proj->status = $proj::STATUS_DRAFT;
294 $proj->usage_opportunity = 1;
295 $proj->title = $langs->trans(
"LeadFromPublicForm");
296 $proj->description =
GETPOST(
"description",
"alphanohtml");
297 $proj->opp_status = $defaultoppstatus;
298 $proj->fk_opp_status = $defaultoppstatus;
301 $nb_post_max =
getDolGlobalInt(
"MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
305 if ($nb_post_max > 0) {
306 $sql =
"SELECT COUNT(rowid) as nb_projets";
307 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet";
308 $sql .=
" WHERE ip = '".$db->escape($proj->ip).
"'";
309 $sql .=
" AND datec > '".$db->idate($minmonthpost).
"'";
310 $resql = $db->query($sql);
312 $num = $db->num_rows(
$resql);
316 $obj = $db->fetch_object(
$resql);
317 $nb_post_ip = $obj->nb_projets;
323 $extrafields->fetch_name_optionals_label($proj->table_element);
324 $ret = $extrafields->setOptionalsFromPost(
null, $proj);
329 if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
331 $errmsg = $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress");
332 array_push($proj->errors, $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress"));
336 $result = $proj->create($user);
338 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
341 if ($object->email) {
346 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
350 $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
352 $outputlangs->loadLangs(array(
"main",
"members",
"projects"));
354 $arraydefaultmessage =
null;
355 $labeltouse = $conf->global->PROJECT_EMAIL_TEMPLATE_AUTOLEAD;
357 if (!empty($labeltouse)) {
358 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'project', $user, $outputlangs, 0, 1, $labeltouse);
361 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
362 $subject = $arraydefaultmessage->topic;
363 $msg = $arraydefaultmessage->content;
365 if (empty($labeltosue)) {
366 $labeltouse =
'['.$mysoc->name.
'] '.$langs->trans(
"YourMessage");
367 $msg = $langs->trans(
"YourMessageHasBeenReceived");
375 if ($subjecttosend && $texttosend) {
376 $moreinheader =
'X-Dolibarr-Info: send_an_email by public/lead/new.php'.
"\r\n";
378 $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(),
"",
"", 0, -1,
'', $moreinheader);
386 if (!empty($backtopage)) {
387 $urlback = $backtopage;
388 } elseif (!empty($conf->global->PROJECT_URL_REDIRECT_LEAD)) {
389 $urlback = $conf->global->PROJECT_URL_REDIRECT_LEAD;
392 $urlback = $_SERVER[
"PHP_SELF"].
"?action=added&token=".
newToken();
395 if (!empty($entity)) {
396 $urlback .=
'&entity='.$entity;
399 dol_syslog(
"project lead ".$proj->ref.
" has been created, we redirect to ".$urlback);
402 $errmsg .= $proj->error.
'<br>'.join(
'<br>', $proj->errors);
412 Header(
"Location: ".$urlback);
421 if (empty($reshook) && $action ==
'added') {
426 print
'<div class="center">';
427 print $langs->trans(
"NewLeadbyWeb");
443 $extrafields->fetch_name_optionals_label($object->table_element);
448 print
load_fiche_titre($langs->trans(
"NewContact"),
'',
'', 0, 0,
'center');
451 print
'<div align="center">';
452 print
'<div id="divsubscribe">';
454 print
'<div class="center subscriptionformhelptext opacitymedium justify">';
455 if (!empty($conf->global->PROJECT_NEWFORM_TEXT)) {
456 print $langs->trans($conf->global->PROJECT_NEWFORM_TEXT).
"<br>\n";
458 print $langs->trans(
"FormForNewLeadDesc",
getDolGlobalString(
"MAIN_INFO_SOCIETE_MAIL")).
"<br>\n";
465 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="newlead">'.
"\n";
466 print
'<input type="hidden" name="token" value="'.newToken().
'" / >';
467 print
'<input type="hidden" name="entity" value="'.$entity.
'" />';
468 print
'<input type="hidden" name="action" value="add" />';
472 print
'<br><span class="opacitymedium">'.$langs->trans(
"FieldsWithAreMandatory",
'*').
'</span><br>';
477 print
'<script type="text/javascript">
478 jQuery(document).ready(function () {
479 jQuery(document).ready(function () {
480 jQuery("#selectcountry_id").change(function() {
481 document.newlead.action.value="create";
482 document.newlead.submit();
489 print
'<table class="border" summary="form to subscribe" id="tablesubscribe">'.
"\n";
492 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')).
'" required></td></tr>'.
"\n";
494 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')).
'" required></td></tr>'.
"\n";
496 print
'<tr><td>'.$langs->trans(
"Email").
' <span style="color: red">*</span></td><td><input type="text" name="email" maxlength="255" class="minwidth150" value="'.
dol_escape_htmltag(
GETPOST(
'email')).
'" required></td></tr>'.
"\n";
498 print
'<tr id="trcompany" class="trcompany"><td>'.$langs->trans(
"Company").
'</td><td><input type="text" name="societe" class="minwidth150" value="'.
dol_escape_htmltag(
GETPOST(
'societe')).
'"></td></tr>'.
"\n";
500 print
'<tr><td>'.$langs->trans(
"Address").
'</td><td>'.
"\n";
501 print
'<textarea name="address" id="address" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_2.
'">'.
dol_escape_htmltag(
GETPOST(
'address',
'restricthtml'), 0, 1).
'</textarea></td></tr>'.
"\n";
503 print
'<tr><td>'.$langs->trans(
'Zip').
' / '.$langs->trans(
'Town').
'</td><td>';
504 print $formcompany->select_ziptown(
GETPOST(
'zipcode'),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6, 1);
506 print $formcompany->select_ziptown(
GETPOST(
'town'),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'), 0, 1);
509 print
'<tr><td>'.$langs->trans(
'Country').
'</td><td>';
510 $country_id =
GETPOST(
'country_id');
511 if (!$country_id && !empty($conf->global->PROJECT_NEWFORM_FORCECOUNTRYCODE)) {
512 $country_id =
getCountry($conf->global->PROJECT_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs);
514 if (!$country_id && !empty($conf->geoipmaxmind->enabled)) {
518 $new_country_id =
getCountry($country_code, 3, $db, $langs);
520 if ($new_country_id) {
521 $country_id = $new_country_id;
525 $country_code =
getCountry($country_id, 2, $db, $langs);
526 print
$form->select_country($country_id,
'country_id');
529 if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
530 print
'<tr><td>'.$langs->trans(
'State').
'</td><td>';
532 print $formcompany->select_state(
GETPOST(
"state_id",
'int'), $country_code);
540 $parameters[
'tpl_context']=
'public';
541 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
544 print
'<td class="tdtop">'.$langs->trans(
"Message").
' <span style="color: red">*</span></td>';
545 print
'<td class="tdtop"><textarea name="description" id="description" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_5.
'" required>'.
dol_escape_htmltag(
GETPOST(
'description',
'restricthtml'), 0, 1).
'</textarea></td>';
553 print
'<div class="center">';
554 print
'<input type="submit" value="'.$langs->trans(
"Submit").
'" id="submitsave" class="button">';
555 if (!empty($backtopage)) {
556 print
' <input type="submit" value="'.$langs->trans(
"Cancel").
'" id="submitcancel" class="button button-cancel">';
563 print
'</div></div>';
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
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-...
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return 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.
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
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.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null)
Return array of possible common substitutions.
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.