NEW A public form for to send a message and create a lead is available

This commit is contained in:
Laurent Destailleur 2022-05-16 13:05:17 +02:00
parent ac60aa4711
commit c3673bfc3c
20 changed files with 185 additions and 126 deletions

View File

@ -64,7 +64,7 @@ if ($action == 'set_default') {
} elseif ($action == 'del_default') {
$ret = delDocumentModel($value, $type);
if ($ret > 0) {
if ($conf->global->MEMBER_ADDON_PDF_ODT == "$value") {
if (getDolGlobalString('MEMBER_ADDON_PDF_ODT') == "$value") {
dolibarr_del_const($db, 'MEMBER_ADDON_PDF_ODT', $conf->entity);
}
}

View File

@ -95,12 +95,13 @@ if ($action == 'update') {
$form = new Form($db);
$title = $langs->trans("MembersSetup");
$help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros';
llxHeader('', $langs->trans("MembersSetup"), $help_url);
llxHeader('', $title, $help_url);
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("MembersSetup"), $linkback, 'title_setup');
print load_fiche_titre($title, $linkback, 'title_setup');
$head = member_admin_prepare_head();

View File

@ -772,16 +772,6 @@ class Contrat extends CommonObject
$now = dol_now();
/*
if (!is_object($extrafields)) {
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafields = new ExtraFields($this->db);
}
$line = new ContratLigne($this->db);
$extrafields->fetch_name_optionals_label(ContratLigne::$table_element, true);
*/
$this->lines = array();
$pos = 0;
@ -875,7 +865,7 @@ class Contrat extends CommonObject
$line->date_fin_prevue = $this->db->jdate($objp->date_fin_validite);
$line->date_fin_reel = $this->db->jdate($objp->date_cloture);
// Retrieve all extrafields for contract
// Retrieve all extrafields for contract line
// fetch optionals attributes and labels
$line->fetch_optionals();

View File

@ -7805,7 +7805,7 @@ abstract class CommonObject
* @param string $keyprefix Prefix string to add before name and id of field (can be used to avoid duplicate names)
* @param string $onetrtd All fields in same tr td. Used by objectline_create.tpl.php for example.
* @param string $display_type "card" for form display, "line" for document line display (extrafields on propal line, order line, etc...)
* @return string
* @return string String with html content to show
*/
public function showOptionals($extrafields, $mode = 'view', $params = null, $keysuffix = '', $keyprefix = '', $onetrtd = 0, $display_type = 'card')
{
@ -7814,13 +7814,20 @@ abstract class CommonObject
if (!is_object($form)) {
$form = new Form($db);
}
if (!is_object($extrafields)) {
dol_syslog('Bad parameter extrafields for showOptionals', LOG_ERR);
return 'Bad parameter extrafields for showOptionals';
}
if (!is_array($extrafields->attributes[$this->table_element])) {
dol_syslog("extrafields->attributes was not loaded with extrafields->fetch_name_optionals_label(table_element);", LOG_WARNING);
}
$out = '';
$parameters = array();
$reshook = $hookmanager->executeHooks('showOptionals', $parameters, $this, $action); // Note that $action and $object may have been modified by hook
if (empty($reshook)) {
if (key_exists('label', $extrafields->attributes[$this->table_element]) && is_array($extrafields->attributes[$this->table_element]['label']) && count($extrafields->attributes[$this->table_element]['label']) > 0) {
if (is_array($extrafields->attributes[$this->table_element]) && key_exists('label', $extrafields->attributes[$this->table_element]) && is_array($extrafields->attributes[$this->table_element]['label']) && count($extrafields->attributes[$this->table_element]['label']) > 0) {
$out .= "\n";
$out .= '<!-- commonobject:showOptionals --> ';
$out .= "\n";

View File

@ -1533,10 +1533,12 @@ class FormMail extends Form
if (!is_object($extrafields)) {
$extrafields = new ExtraFields($this->db);
}
$extrafields->fetch_name_optionals_label('product', true);
$product = new Product($this->db);
$product->fetch($line->fk_product, '', '', 1);
$product->fetch_optionals();
$extrafields->fetch_name_optionals_label($product->table_element, true);
if (is_array($extrafields->attributes[$product->table_element]['label']) && count($extrafields->attributes[$product->table_element]['label']) > 0) {
foreach ($extrafields->attributes[$product->table_element]['label'] as $key => $label) {
$substit_line['__PRODUCT_EXTRAFIELD_'.strtoupper($key).'__'] = $product->array_options['options_'.$key];

View File

@ -509,14 +509,12 @@ function project_admin_prepare_head()
$head[$h][2] = 'attributes_task';
$h++;
if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
$langs->load("members");
$langs->load("members");
$head[$h][0] = DOL_URL_ROOT.'/projet/admin/website.php';
$head[$h][1] = $langs->trans("BlankSubscriptionForm");
$head[$h][2] = 'website';
$h++;
}
$head[$h][0] = DOL_URL_ROOT.'/projet/admin/website.php';
$head[$h][1] = $langs->trans("BlankSubscriptionForm");
$head[$h][2] = 'website';
$h++;
complete_head_from_modules($conf, $langs, null, $head, $h, 'project_admin', 'remove');
@ -2819,7 +2817,7 @@ function getTaskProgressView($task, $label = true, $progressNumber = true, $hide
$out .= ' </div>';
} else {
// bad
$out .= ' <div class="progress-bar progress-bar-consumed" style="width: '.floatval($progressCalculated).'%" title="'.floatval($progressCalculated).'%">';
$out .= ' <div class="progress-bar progress-bar-consumed-late" style="width: '.floatval($progressCalculated).'%" title="'.floatval($progressCalculated).'%">';
$out .= ' <div class="progress-bar '.$progressBarClass.'" style="width: '.($task->progress ? floatval($task->progress / $progressCalculated * 100).'%' : '1px').'" title="'.floatval($task->progress).'%"></div>';
$out .= ' </div>';
}

View File

@ -41,6 +41,7 @@ if (!isset($parameters)) {
}
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (empty($reshook)) {
$params = array();
@ -48,6 +49,7 @@ if (empty($reshook)) {
$params['tpl_context'] = $tpl_context;
}
$params['cols'] = key_exists('colspanvalue', $parameters) ? $parameters['colspanvalue'] : '';
print $object->showOptionals($extrafields, 'create', $params);
}

View File

@ -82,7 +82,7 @@ $form = new Form($db);
/*
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('intracommreport');
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
*/

View File

@ -2253,4 +2253,5 @@ HashForPing=Hash used for ping
ReadOnlyMode=Is instance in "Read Only" mode
DEBUGBAR_USE_LOG_FILE=Use the <b>dolibarr.log</b> file to trap Logs
UsingLogFileShowAllRecordOfSubrequestButIsSlower=Use the dolibarr.log file to trap Logs instead of live memory catching. It allows to catch all logs instead of only log of current process (so including the one of ajax subrequests pages) but will make your instance very very slow. Not recommended.
FixedOrPercent=Fixed (use keyword 'fixed') or percent (use keyword 'percent')
FixedOrPercent=Fixed (use keyword 'fixed') or percent (use keyword 'percent')
DefaultOpportunityStatus=Default opportunity status (first status when lead is created)

View File

@ -1174,3 +1174,5 @@ ConfirmAllocateCommercial=Assign sales representative confirmation
ConfirmAllocateCommercialQuestion=Are you sure you want to assign the %s selected record(s)?
CommercialsAffected=Sales representatives affected
CommercialAffected=Sales representative affected
YourMessage=Votre message
YourMessageHasBeenReceived=Your message has been received. We will answer or contact you as soon as possible.

View File

@ -289,3 +289,8 @@ FormForNewLeadDesc=Thanks to fill the following form to contact us. You can also
ProjectsHavingThisContact=Projects having this contact
StartDateCannotBeAfterEndDate=End date cannot be before start date
ErrorPROJECTLEADERRoleMissingRestoreIt=The "PROJECTLEADER" role is missing or has been de-activited, please restore in the dictionary of contact types
LeadPublicFormDesc=You can enable here a public page to allow your prospects to make a first contact to you from a public online form
EnablePublicLeadForm=Enable the public form for contact
NewLeadbyWeb=Your message or request has been recorded. We will answer or contact your soon.
NewLeadForm=New contact form
LeadFromPublicForm=Online lead from public form

View File

@ -154,7 +154,6 @@ class PriceParser
//Retrieve all extrafield for product and add it to values
$extrafields = new ExtraFields($this->db);
$extrafields->fetch_name_optionals_label('product', true);
$product->fetch_optionals();
if (is_array($extrafields->attributes[$product->table_element]['label'])) {
foreach ($extrafields->attributes[$product->table_element]['label'] as $key => $label) {

View File

@ -28,6 +28,7 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
// Load translation files required by the page
@ -35,10 +36,14 @@ $langs->loadLangs(array("admin", "members"));
$action = GETPOST('action', 'aZ09');
$defaultoppstatus = getDolGlobalInt('PROJECT_DEFAULT_OPPORTUNITY_STATUS_FOR_ONLINE_LEAD');
if (!$user->admin) {
accessforbidden();
}
$error = 0;
/*
* Actions
@ -54,8 +59,10 @@ if ($action == 'setPROJECT_ENABLE_PUBLIC') {
if ($action == 'update') {
$public = GETPOST('PROJECT_ENABLE_PUBLIC');
$defaultoppstatus = GETPOST('PROJECT_DEFAULT_OPPORTUNITY_STATUS_FOR_ONLINE_LEAD', 'int');
$res = dolibarr_set_const($db, "PROJECT_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "PROJECT_DEFAULT_OPPORTUNITY_STATUS_FOR_ONLINE_LEAD", $defaultoppstatus, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
@ -74,13 +81,15 @@ if ($action == 'update') {
*/
$form = new Form($db);
$formproject = new FormProjets($db);
$title = $langs->trans("ProjectsSetup");
$help_url = '';
llxHeader('', $langs->trans("ProjectsSetup"), $help_url);
llxHeader('', $title, $help_url);
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("ProjectsSetup"), $linkback, 'title_setup');
print load_fiche_titre($title, $linkback, 'title_setup');
$head = project_admin_prepare_head();
@ -90,11 +99,12 @@ print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print dol_get_fiche_head($head, 'website', $langs->trans("Projects"), -1, 'user');
print dol_get_fiche_head($head, 'website', $langs->trans("Projects"), -1, 'project');
print '<span class="opacitymedium">'.$langs->trans("LeadPublicFormDesc").'</span><br><br>';
$param = '';
$enabledisablehtml = $langs->trans("EnablePublicLeadForm").' ';
if (empty($conf->global->PROJECT_ENABLE_PUBLIC)) {
@ -111,6 +121,33 @@ if (empty($conf->global->PROJECT_ENABLE_PUBLIC)) {
print $enabledisablehtml;
print '<input type="hidden" id="PROJECT_ENABLE_PUBLIC" name="PROJECT_ENABLE_PUBLIC" value="'.(empty($conf->global->PROJECT_ENABLE_PUBLIC) ? 0 : 1).'">';
print '<br>';
if (!empty($conf->global->PROJECT_ENABLE_PUBLIC)) {
print '<br>';
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameter").'</td>';
print '<td class="right">'.$langs->trans("Value").'</td>';
print "</tr>\n";
// Default opportunity status
print '<tr class="oddeven drag" id="trforcetype"><td>';
print $langs->trans("DefaultOpportunityStatus");
print '</td><td class="right">';
print $formproject->selectOpportunityStatus('PROJECT_DEFAULT_OPPORTUNITY_STATUS_FOR_ONLINE_LEAD', GETPOSTISSET('PROJECT_DEFAULT_OPPORTUNITY_STATUS_FOR_ONLINE_LEAD') ? GETPOST('PROJECT_DEFAULT_OPPORTUNITY_STATUS_FOR_ONLINE_LEAD', 'int') : $defaultoppstatus, 1, 0, 0, 0, '', 0, 1);
print "</td></tr>\n";
print '</table>';
print '</div>';
print '<div class="center">';
print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
print '</div>';
}
print dol_get_fiche_end();
@ -120,8 +157,8 @@ print '</form>';
if (!empty($conf->global->PROJECT_ENABLE_PUBLIC)) {
print '<br>';
//print $langs->trans('FollowingLinksArePublic').'<br>';
print img_picto('', 'globe').' '.$langs->trans('BlankSubscriptionForm').':<br>';
if ($conf->multicompany->enabled) {
print img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans('BlankSubscriptionForm').'</span><br>';
if (!empty($conf->multicompany->enabled)) {
$entity_qr = '?entity='.$conf->entity;
} else {
$entity_qr = '';
@ -132,7 +169,11 @@ if (!empty($conf->global->PROJECT_ENABLE_PUBLIC)) {
$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
print '<a target="_blank" rel="noopener noreferrer" href="'.$urlwithroot.'/public/project/new.php'.$entity_qr.'">'.$urlwithroot.'/public/project/new.php'.$entity_qr.'</a>';
print '<div class="urllink">';
print '<input type="text" id="publicurlmember" class="quatrevingtpercentminusx" value="'.$urlwithroot.'/public/project/new.php'.$entity_qr.'">';
print '<a target="_blank" rel="noopener noreferrer" href="'.$urlwithroot.'/public/project/new.php'.$entity_qr.'">'.img_picto('', 'globe', 'class="paddingleft"').'</a>';
print '</div>';
print ajax_autoselect('publicurlmember');
}
// End of page

View File

@ -159,7 +159,9 @@ class Project extends CommonObject
public $statuts_long;
public $statut; // 0=draft, 1=opened, 2=closed
public $opp_status; // opportunity status, into table llx_c_lead_status
public $fk_opp_status; // opportunity status, into table llx_c_lead_status
public $opp_percent; // opportunity probability
public $email_msgid;

View File

@ -932,7 +932,7 @@ if (!empty($arrayfields['p.public']['checked'])) {
// Opp status
if (!empty($arrayfields['p.fk_opp_status']['checked'])) {
print '<td class="liste_titre nowrap center">';
print $formproject->selectOpportunityStatus('search_opp_status', $search_opp_status, 1, 0, 1, 0, 'maxwidth100', 1);
print $formproject->selectOpportunityStatus('search_opp_status', $search_opp_status, 1, 0, 1, 0, 'maxwidth100', 1, 0);
print '</td>';
}
if (!empty($arrayfields['p.opp_amount']['checked'])) {

View File

@ -236,7 +236,7 @@ print '</td></tr>';
// Opportunity status
if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
print '<tr><td>'.$langs->trans("OpportunityStatusShort").'</td><td>';
print $formproject->selectOpportunityStatus('search_opp_status', $search_opp_status, 1, 0, 1, 0, 'maxwidth300', 1);
print $formproject->selectOpportunityStatus('search_opp_status', $search_opp_status, 1, 0, 1, 0, 'maxwidth300', 1, 1);
print '</td></tr>';
}

View File

@ -57,7 +57,6 @@ if (!defined('NOIPCHECK')) {
// For MultiCompany module.
// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php
// TODO This should be useless. Because entity must be retrieve from object ref and not from url.
$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
if (is_numeric($entity)) {
define("DOLENTITY", $entity);
@ -430,7 +429,7 @@ if (empty($reshook) && $action == 'added') {
llxHeaderVierge($langs->trans("NewMemberForm"));
// Si on a pas ete redirige
print '<br>';
print '<br><br>';
print '<div class="center">';
print $langs->trans("NewMemberbyWeb");
print '</div>';
@ -448,7 +447,7 @@ if (empty($reshook) && $action == 'added') {
$form = new Form($db);
$formcompany = new FormCompany($db);
$adht = new AdherentType($db);
$extrafields->fetch_name_optionals_label('adherent'); // fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element); // fetch optionals attributes and labels
llxHeaderVierge($langs->trans("NewSubscription"));

View File

@ -419,7 +419,7 @@ if (empty($reshook) && $action == 'added') {
llxHeaderVierge($langs->trans("NewPartnershipForm"));
// Si on a pas ete redirige
print '<br>';
print '<br><br>';
print '<div class="center">';
print $langs->trans("NewPartnershipbyWeb");
print '</div>';
@ -437,7 +437,7 @@ if (empty($reshook) && $action == 'added') {
$form = new Form($db);
$formcompany = new FormCompany($db);
$extrafields->fetch_name_optionals_label('partnership'); // fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($partnership->table_element); // fetch optionals attributes and labels
llxHeaderVierge($langs->trans("NewPartnershipRequest"));

View File

@ -45,7 +45,6 @@ if (!defined('NOIPCHECK')) {
// For MultiCompany module.
// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php
// TODO This should be useless. Because entity must be retrieve from object ref and not from url.
$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
if (is_numeric($entity)) {
define("DOLENTITY", $entity);
@ -132,9 +131,9 @@ function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $
print '</div>';
}
if (!empty($conf->global->PROJECT_IMAGE_PUBLIC_ORGANIZEDEVENT)) {
print '<div class="backimagepublicorganizedevent">';
print '<img id="idPROJECT_IMAGE_PUBLIC_ORGANIZEDEVENT" src="'.$conf->global->PROJECT_IMAGE_PUBLIC_ORGANIZEDEVENT.'">';
if (!empty($conf->global->PROJECT_IMAGE_PUBLIC_NEWLEAD)) {
print '<div class="backimagepublicnewlead">';
print '<img id="idPROJECT_IMAGE_PUBLIC_NEWLEAD" src="'.$conf->global->PROJECT_IMAGE_PUBLIC_NEWLEAD.'">';
print '</div>';
}
@ -159,22 +158,6 @@ function llxFooterVierge()
}
$arrayofdata = array();
if (GETPOST('action') == 'addlead') {
// When a json request is sent
$entityBody = file_get_contents('php://input');
if ($entityBody) {
$arrayofdata = json_decode($entityBody, true);
}
print 'Date received and lead created';
$db->close();
exit;
}
/*
* Actions
@ -194,42 +177,6 @@ if (empty($reshook) && $action == 'add') {
$db->begin();
// test if lead already exists
/*
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
if (!GETPOST('login')) {
$error++;
$errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login"))."<br>\n";
}
$sql = "SELECT login FROM ".MAIN_DB_PREFIX."adherent WHERE login='".$db->escape(GETPOST('login'))."'";
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
}
if ($num != 0) {
$error++;
$langs->load("errors");
$errmsg .= $langs->trans("ErrorLoginAlreadyExists")."<br>\n";
}
if (!GETPOSTISSET("pass1") || !GETPOSTISSET("pass2") || GETPOST("pass1", 'none') == '' || GETPOST("pass2", 'none') == '' || GETPOST("pass1", 'none') != GETPOST("pass2", 'none')) {
$error++;
$langs->load("errors");
$errmsg .= $langs->trans("ErrorPasswordsMustMatch")."<br>\n";
}
if (!GETPOST("email")) {
$error++;
$errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("EMail"))."<br>\n";
}
}
*/
if (GETPOST('type') <= 0) {
$error++;
$errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type"))."<br>\n";
}
if (!in_array(GETPOST('morphy'), array('mor', 'phy'))) {
$error++;
$errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv('Nature'))."<br>\n";
}
if (!GETPOST("lastname")) {
$error++;
$errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Lastname"))."<br>\n";
@ -238,27 +185,87 @@ if (empty($reshook) && $action == 'add') {
$error++;
$errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Firstname"))."<br>\n";
}
if (!GETPOST("email")) {
$error++;
$errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Email"))."<br>\n";
}
if (!GETPOST("description")) {
$error++;
$errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Message"))."<br>\n";
}
if (GETPOST("email") && !isValidEmail(GETPOST("email"))) {
$error++;
$langs->load("errors");
$errmsg .= $langs->trans("ErrorBadEMail", GETPOST("email"))."<br>\n";
}
// Set default opportunity status
$defaultoppstatus = getDolGlobalString('PROJECT_DEFAULT_OPPORTUNITY_STATUS_FOR_ONLINE_LEAD');
if (empty($defaultoppstatus)) {
$error++;
$langs->load("errors");
$errmsg .= $langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Project"))."<br>\n";
}
if (!$error) {
// email a peu pres correct et le login n'existe pas
$proj = new Project($db);
$proj->statut = -1;
$thirdparty = new Societe($db);
// Search thirdparty and set it if found to the new created project
$result = $thirdparty->fetch(0, '', '', '', '', '', '', '', '', '', $object->email);
if ($result > 0) {
$proj->socid = $thirdparty->id;
}
// Defined the ref into $defaultref
$defaultref = '';
$modele = empty($conf->global->PROJECT_ADDON) ? 'mod_project_simple' : $conf->global->PROJECT_ADDON;
// Search template files
$file = ''; $classname = ''; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) {
$file = dol_buildpath($reldir."core/modules/project/".$modele.'.php', 0);
if (file_exists($file)) {
$filefound = 1;
$classname = $modele;
break;
}
}
if ($filefound) {
$result = dol_include_once($reldir."core/modules/project/".$modele.'.php');
$modProject = new $classname;
$defaultref = $modProject->getNextValue($thirdparty, $object);
}
if (is_numeric($defaultref) && $defaultref <= 0) {
$defaultref = '';
}
if (empty($defaultref)) {
$defaultref = 'PJ'.dol_print_date(dol_now(), 'dayrfc');
}
$proj->ref = $defaultref;
$proj->statut = $proj::STATUS_DRAFT;
$proj->status = $proj::STATUS_DRAFT;
$proj->email = GETPOST("email");
$proj->note_private = GETPOST("note_private");
$proj->public = 1;
$proj->usage_opportunity = 1;
$proj->title = $langs->trans("LeadFromPublicForm");
$proj->description = GETPOST("description", "alphanohtml");
$proj->opp_status = $defaultoppstatus;
$proj->fk_opp_status = $defaultoppstatus;
// Fill array 'array_options' with data from add form
// Fill array 'array_options' with data from the form
$extrafields->fetch_name_optionals_label($proj->table_element);
$ret = $extrafields->setOptionalsFromPost(null, $proj);
if ($ret < 0) {
$error++;
}
// Create the project
$result = $proj->create($user);
if ($result > 0) {
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
@ -275,7 +282,7 @@ if (empty($reshook) && $action == 'add') {
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
// Load traductions files required by page
$outputlangs->loadLangs(array("main", "members"));
$outputlangs->loadLangs(array("main", "members", "projects"));
// Get email content from template
$arraydefaultmessage = null;
$labeltouse = $conf->global->PROJECT_EMAIL_TEMPLATE_AUTOLEAD;
@ -288,11 +295,15 @@ if (empty($reshook) && $action == 'add') {
$subject = $arraydefaultmessage->topic;
$msg = $arraydefaultmessage->content;
}
if (empty($labeltosue)) {
$labeltouse = '['.$mysoc->name.'] '.$langs->trans("YourMessage");
$msg = $langs->trans("YourMessageHasBeenReceived");
}
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
$texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs);
$texttosend = make_substitutions($msg, $substitutionarray, $outputlangs);
if ($subjecttosend && $texttosend) {
$moreinheader = 'X-Dolibarr-Info: send_an_email by public/lead/new.php'."\r\n";
@ -317,10 +328,11 @@ if (empty($reshook) && $action == 'add') {
if (!empty($entity)) {
$urlback .= '&entity='.$entity;
}
dol_syslog("project lead ".$proj->ref." was created, we redirect to ".$urlback);
dol_syslog("project lead ".$proj->ref." has been created, we redirect to ".$urlback);
} else {
$error++;
$errmsg .= join('<br>', $proj->errors);
$errmsg .= $proj->error.'<br>'.join('<br>', $proj->errors);
}
}
@ -334,23 +346,16 @@ if (empty($reshook) && $action == 'add') {
}
}
// Create lead from $arrayofdata
if (empty($reshook) && !empty($arrayofdata)) {
// TODO
dol_syslog(var_export($arrayofdata, true));
// ...
}
// Action called after a submitted was send and member created successfully
// If MEMBER_URL_REDIRECT_SUBSCRIPTION is set to url we never go here because a redirect was done to this url.
// backtopage parameter with an url was set on member submit page, we never go here because a redirect was done to this url.
if (empty($reshook) && $action == 'added') {
llxHeaderVierge($langs->trans("NewMemberForm"));
llxHeaderVierge($langs->trans("NewLeadForm"));
// Si on a pas ete redirige
print '<br>';
print '<br><br>';
print '<div class="center">';
print $langs->trans("NewMemberbyWeb");
print $langs->trans("NewLeadbyWeb");
print '</div>';
llxFooterVierge();
@ -365,8 +370,8 @@ if (empty($reshook) && $action == 'added') {
$form = new Form($db);
$formcompany = new FormCompany($db);
$extrafields->fetch_name_optionals_label('project'); // fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element); // fetch optionals attributes and labels
llxHeaderVierge($langs->trans("NewContact"));
@ -415,14 +420,16 @@ jQuery(document).ready(function () {
print '<table class="border" summary="form to subscribe" id="tablesubscribe">'."\n";
// Lastname
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";
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";
// Firstname
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";
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";
// EMail
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";
// Company
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";
// Address
print '<tr><td>'.$langs->trans("Address").'</td><td>'."\n";
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";
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";
// Zip / Town
print '<tr><td>'.$langs->trans('Zip').' / '.$langs->trans('Town').'</td><td>';
print $formcompany->select_ziptown(GETPOST('zipcode'), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6, 1);
@ -453,21 +460,20 @@ print '</td></tr>';
if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
print '<tr><td>'.$langs->trans('State').'</td><td>';
if ($country_code) {
print $formcompany->select_state(GETPOST("state_id"), $country_code);
print $formcompany->select_state(GETPOST("state_id", 'int'), $country_code);
} else {
print '';
}
print '</td></tr>';
}
// EMail
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')).'"></td></tr>'."\n";
// Other attributes
$tpl_context = 'public'; // define template context to public
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
// Comments
print '<tr>';
print '<td class="tdtop">'.$langs->trans("Comments").'</td>';
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>';
print '<td class="tdtop">'.$langs->trans("Message").' <span style="color: red">*</span></td>';
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>';
print '</tr>'."\n";
print "</table>\n";

View File

@ -194,4 +194,8 @@ body[class*="colorblind-"] .progress-bar-red, body[class*="colorblind-"] .progre
}
.progress-bar-consumed {
background-color: rgb(0, 0, 0, 0.15);
}
}
.progress-bar-consumed-late {
background-color: <?php echo colorAgressiveness($badgeDanger, -95, +70) ?>;
}