diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 1a682636077..c8cb62cd7e0 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -395,8 +395,8 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; @@ -406,9 +406,9 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $sql .= $db->plimit($limit + 1, $offset); dol_syslog("/accountancy/admin/productaccount.php", LOG_DEBUG); -$result = $db->query($sql); -if ($result) { - $num = $db->num_rows($result); +$resql = $db->query($sql); +if ($resql) { + $num = $db->num_rows($resql); $i = 0; $param = ''; @@ -608,7 +608,7 @@ if ($result) { $i = 0; while ($i < min($num, $limit)) { - $obj = $db->fetch_object($result); + $obj = $db->fetch_object($resql); // Ref produit as link $product_static->ref = $obj->ref; @@ -891,7 +891,7 @@ if ($result) { print ''; - $db->free($result); + $db->free($resql); } else { dol_print_error($db); } diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index ac943180b58..72efffc2b49 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -586,11 +586,11 @@ class AccountingAccount extends CommonObject $sql .= ' WHERE a.rowid = ' . ((int) $id); dol_syslog(get_class($this) . '::info sql=' . $sql); - $result = $this->db->query($sql); + $resql = $this->db->query($sql); - if ($result) { - if ($this->db->num_rows($result)) { - $obj = $this->db->fetch_object($result); + if ($resql) { + if ($this->db->num_rows($resql)) { + $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; if ($obj->fk_user_author) { $cuser = new User($this->db); @@ -605,7 +605,7 @@ class AccountingAccount extends CommonObject $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->tms); } - $this->db->free($result); + $this->db->free($resql); } else { dol_print_error($this->db); } diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php index a2718973185..81caaa05358 100644 --- a/htdocs/accountancy/class/lettering.class.php +++ b/htdocs/accountancy/class/lettering.class.php @@ -266,14 +266,14 @@ class Lettering extends BookKeeping $sql .= " ORDER BY ab2.lettering_code DESC"; $sql .= " LIMIT 1 "; - $result = $this->db->query($sql); - if ($result) { - $obj = $this->db->fetch_object($result); + $resqla = $this->db->query($sql); + if ($resqla) { + $obj = $this->db->fetch_object($resqla); $lettre = (empty($obj->lettering_code) ? 'AAA' : $obj->lettering_code); if (!empty($obj->lettering_code)) { $lettre++; } - $this->db->free($result); + $this->db->free($resqla); } else { $this->errors[] = 'Error'.$this->db->lasterror(); $error++; @@ -281,14 +281,14 @@ class Lettering extends BookKeeping $sql = "SELECT SUM(ABS(debit)) as deb, SUM(ABS(credit)) as cred FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE "; $sql .= " rowid IN (".$this->db->sanitize(implode(',', $ids)).") AND lettering_code IS NULL AND subledger_account != ''"; - $result = $this->db->query($sql); - if ($result) { - $obj = $this->db->fetch_object($result); + $resqlb = $this->db->query($sql); + if ($resqlb) { + $obj = $this->db->fetch_object($resqlb); if (!(round(abs($obj->deb), 2) === round(abs($obj->cred), 2))) { $this->errors[] = 'Total not exacts '.round(abs($obj->deb), 2).' vs '.round(abs($obj->cred), 2); $error++; } - $this->db->free($result); + $this->db->free($resqlb); } else { $this->errors[] = 'Erreur sql'.$this->db->lasterror(); $error++; diff --git a/htdocs/adherents/admin/member.php b/htdocs/adherents/admin/member.php index d51dd8ef730..64197636d0e 100644 --- a/htdocs/adherents/admin/member.php +++ b/htdocs/adherents/admin/member.php @@ -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); } } diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php index ed09c206abf..6199991f29c 100644 --- a/htdocs/adherents/admin/website.php +++ b/htdocs/adherents/admin/website.php @@ -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 = ''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans("MembersSetup"), $linkback, 'title_setup'); +print load_fiche_titre($title, $linkback, 'title_setup'); $head = member_admin_prepare_head(); diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 9aef78174de..b3cfe027197 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -490,17 +490,17 @@ class Subscription extends CommonObject $sql .= ' FROM '.MAIN_DB_PREFIX.'subscription as c'; $sql .= ' WHERE c.rowid = '.((int) $id); - $result = $this->db->query($sql); - if ($result) { - if ($this->db->num_rows($result)) { - $obj = $this->db->fetch_object($result); + $resql = $this->db->query($sql); + if ($resql) { + if ($this->db->num_rows($resql)) { + $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->datem); } - $this->db->free($result); + $this->db->free($resql); } else { dol_print_error($this->db); } diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index 2b0c295afbd..1ef98dddb6d 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -99,12 +99,12 @@ $sql .= " WHERE t.entity IN (".getEntity('member_type').")"; $sql .= " GROUP BY t.rowid, t.libelle, t.subscription, d.statut"; dol_syslog("index.php::select nb of members per type", LOG_DEBUG); -$result = $db->query($sql); -if ($result) { - $num = $db->num_rows($result); +$resql = $db->query($sql); +if ($resql) { + $num = $db->num_rows($resql); $i = 0; while ($i < $num) { - $objp = $db->fetch_object($result); + $objp = $db->fetch_object($resql); $adhtype = new AdherentType($db); $adhtype->id = $objp->rowid; @@ -127,7 +127,7 @@ if ($result) { $i++; } - $db->free($result); + $db->free($resql); } $now = dol_now(); @@ -143,16 +143,16 @@ $sql .= " AND t.rowid = d.fk_adherent_type"; $sql .= " GROUP BY d.fk_adherent_type"; dol_syslog("index.php::select nb of uptodate members by type", LOG_DEBUG); -$result = $db->query($sql); -if ($result) { - $num = $db->num_rows($result); +$resql = $db->query($sql); +if ($resql) { + $num = $db->num_rows($resql); $i = 0; while ($i < $num) { - $objp = $db->fetch_object($result); + $objp = $db->fetch_object($resql); $MembersUpToDate[$objp->fk_adherent_type] = $objp->somme; $i++; } - $db->free(); + $db->free($resql); } /* diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 9d122cfce7e..f22cea8d04e 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1598,7 +1598,7 @@ class ActionComm extends CommonObject //$tooltip .= '
'.img_picto('', 'email').' '.$langs->trans("Email").''; $tooltip .= '
'.$langs->trans('MailTopic').': '.$this->email_subject; $tooltip .= '
'.$langs->trans('MailFrom').': '.str_replace(array('<', '>'), array('&lt', '&gt'), $this->email_from); - $tooltip .= '
'.$langs->trans('MailTo').':, '.str_replace(array('<', '>'), array('&lt', '&gt'), $this->email_to); + $tooltip .= '
'.$langs->trans('MailTo').': '.str_replace(array('<', '>'), array('&lt', '&gt'), $this->email_to); if (!empty($this->email_tocc)) { $tooltip .= '
'.$langs->trans('MailCC').': '.str_replace(array('<', '>'), array('&lt', '&gt'), $this->email_tocc); } diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 316254b0398..583626f0220 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -310,9 +310,9 @@ if ($object->id > 0) { $sql .= " AND pfd.ext_payment_id IS NULL"; $sql .= " ORDER BY pfd.date_demande DESC"; - $result_sql = $db->query($sql); - if ($result_sql) { - $num = $db->num_rows($result_sql); + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); $numopen = $num; } else { dol_print_error($db); @@ -695,9 +695,9 @@ if ($object->id > 0) { $sql .= " AND pfd.traite = 0"; $sql .= " AND pfd.ext_payment_id IS NULL"; - $result_sql = $db->query($sql); - if ($result_sql) { - $obj = $db->fetch_object($result_sql); + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); if ($obj) { $pending = $obj->amount; } @@ -797,17 +797,17 @@ if ($object->id > 0) { $sql .= " AND pfd.ext_payment_id IS NULL"; $sql .= " ORDER BY pfd.date_demande DESC"; - $result_sql = $db->query($sql); + $resql = $db->query($sql); $num = 0; - if ($result_sql) { + if ($resql) { $i = 0; $tmpuser = new User($db); $num = $db->num_rows($result); while ($i < $num) { - $obj = $db->fetch_object($result_sql); + $obj = $db->fetch_object($resql); $tmpuser->id = $obj->user_id; $tmpuser->login = $obj->login; @@ -840,7 +840,7 @@ if ($object->id > 0) { $i++; } - $db->free($result_sql); + $db->free($resql); } else { dol_print_error($db); } diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php index 7cd49a9427c..640ffc78d99 100644 --- a/htdocs/compta/paiement_charge.php +++ b/htdocs/compta/paiement_charge.php @@ -198,7 +198,7 @@ if ($action == 'create') { if ($resql) { $obj = $db->fetch_object($resql); $sumpaid = $obj->total; - $db->free(); + $db->free($resql); } /*print ''.$langs->trans("AlreadyPaid").''.price($sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).''; print ''.$langs->trans("RemainderToPay").''.price($total-$sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'';*/ diff --git a/htdocs/compta/paiement_vat.php b/htdocs/compta/paiement_vat.php index 28bc838c296..84d2765b278 100644 --- a/htdocs/compta/paiement_vat.php +++ b/htdocs/compta/paiement_vat.php @@ -194,7 +194,7 @@ if ($action == 'create') { if ($resql) { $obj = $db->fetch_object($resql); $sumpaid = $obj->total; - $db->free(); + $db->free($resql); } /*print ''.$langs->trans("AlreadyPaid").''.price($sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).''; print ''.$langs->trans("RemainderToPay").''.price($total-$sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'';*/ diff --git a/htdocs/compta/prelevement/stats.php b/htdocs/compta/prelevement/stats.php index 9c30db6e08a..8ee4c854600 100644 --- a/htdocs/compta/prelevement/stats.php +++ b/htdocs/compta/prelevement/stats.php @@ -143,7 +143,8 @@ if ($resql) { print price($total); print ' '; print ""; - $db->free(); + + $db->free($resql); } else { dol_print_error($db); } diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index d85ad51946a..0befd4820ff 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -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(); diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index 99739260b36..db0f515273c 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -346,22 +346,27 @@ if ($result) { while ($i < $num) { $obj = $db->fetch_object($result); + $datem = $db->jdate($obj->tms); + + $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->cid); + $staticcontrat->id = $obj->cid; + + $staticcompany->id = $obj->socid; + $staticcompany->name = $obj->name; print ''; print ''; - $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->cid); - $staticcontrat->id = $obj->cid; print $staticcontrat->getNomUrl(1, 16); if ($obj->nb_late) { print img_warning($langs->trans("Late")); } print ''; print ''; - $staticcompany->id = $obj->socid; - $staticcompany->name = $obj->name; print $staticcompany->getNomUrl(1, '', 20); print ''; - print ''.dol_print_date($db->jdate($obj->tms), 'dayhour').''; + print ''; + print dol_print_date($datem, 'dayhour'); + print ''; //print ''.$staticcontrat->LibStatut($obj->statut,2).''; print ''.($obj->nb_initial > 0 ? ''.$obj->nb_initial.''.$staticcontratligne->LibStatut(0, 3, -1, 'class="paddingleft"') : '').''; print ''.($obj->nb_running > 0 ? ''.$obj->nb_running.''.$staticcontratligne->LibStatut(4, 3, 0, 'class="marginleft"') : '').''; @@ -451,7 +456,7 @@ if ($resql) { print "\n"; $i++; } - $db->free(); + $db->free($resql); print ""; } else { @@ -532,7 +537,8 @@ if ($resql) { print "\n"; $i++; } - $db->free(); + + $db->free($resql); print ""; } else { @@ -614,7 +620,7 @@ if ($resql) { print "\n"; $i++; } - $db->free(); + $db->free($resql); print ""; } else { diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index f97d4aa94ee..cec127eeac4 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -121,7 +121,7 @@ if ($action == 'add' && !empty($permissiontoadd)) { // Fill array 'array_options' with data from add form if (!$error) { - $ret = $extrafields->setOptionalsFromPost(null, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object, '', 1); if ($ret < 0) { $error++; } diff --git a/htdocs/core/boxes/box_boms.php b/htdocs/core/boxes/box_boms.php index d96fac8bc76..a9a4f8746da 100644 --- a/htdocs/core/boxes/box_boms.php +++ b/htdocs/core/boxes/box_boms.php @@ -147,7 +147,7 @@ class box_boms extends ModeleBoxes } $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', + 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'"', 'text' => dol_print_date($datem, 'day', 'tzuserrel'), ); diff --git a/htdocs/core/boxes/box_clients.php b/htdocs/core/boxes/box_clients.php index 2afa630860b..4a7ea965006 100644 --- a/htdocs/core/boxes/box_clients.php +++ b/htdocs/core/boxes/box_clients.php @@ -140,7 +140,7 @@ class box_clients extends ModeleBoxes ); $this->info_box_contents[$line][] = array( - 'td' => 'class="center nowraponall"', + 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'"', 'text' => dol_print_date($datem, "day", 'tzuserrel') ); diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index b2ba608d689..ea35a080d0e 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -177,7 +177,7 @@ class box_contacts extends ModeleBoxes ); $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', + 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'"', 'text' => dol_print_date($datem, "day", 'tzuserrel'), ); diff --git a/htdocs/core/boxes/box_contracts.php b/htdocs/core/boxes/box_contracts.php index 8eeb1b93323..dddafffdc02 100644 --- a/htdocs/core/boxes/box_contracts.php +++ b/htdocs/core/boxes/box_contracts.php @@ -83,8 +83,8 @@ class box_contracts extends ModeleBoxes $thirdpartytmp = new Societe($this->db); $sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; - $sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture"; - $sql .= ", c.ref_customer, c.ref_supplier"; + $sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.tms as date_modification, c.fin_validite, c.date_cloture,"; + $sql .= " c.ref_customer, c.ref_supplier"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; if (empty($user->rights->societe->client->voir) && !$user->socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -117,6 +117,7 @@ class box_contracts extends ModeleBoxes $objp = $this->db->fetch_object($resql); $datec = $this->db->jdate($objp->datec); + $datem = $this->db->jdate($objp->date_modification); $dateterm = $this->db->jdate($objp->fin_validite); $dateclose = $this->db->jdate($objp->date_cloture); $late = ''; @@ -155,8 +156,8 @@ class box_contracts extends ModeleBoxes ); $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datec, 'day', 'tzuserrel'), + 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'"', + 'text' => dol_print_date($datem, 'day', 'tzuserrel'), ); $this->info_box_contents[$line][] = array( diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php index 5865cba2530..e091d58643b 100644 --- a/htdocs/core/boxes/box_members.php +++ b/htdocs/core/boxes/box_members.php @@ -145,7 +145,7 @@ class box_members extends ModeleBoxes ); $this->info_box_contents[$line][] = array( - 'td' => 'class="center nowraponall"', + 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'"', 'text' => dol_print_date($datem, "day", 'tzuserrel'), ); diff --git a/htdocs/core/boxes/box_mos.php b/htdocs/core/boxes/box_mos.php index 6436fb8e34e..cff19388c17 100644 --- a/htdocs/core/boxes/box_mos.php +++ b/htdocs/core/boxes/box_mos.php @@ -144,7 +144,7 @@ class box_mos extends ModeleBoxes } $this->info_box_contents[$line][] = array( - 'td' => 'class="center nowraponall"', + 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'"', 'text' => dol_print_date($datem, 'day', 'tzuserrel'), ); diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index f3f9496325f..97b7bd5fd51 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -165,7 +165,7 @@ class box_propales extends ModeleBoxes ); $this->info_box_contents[$line][] = array( - 'td' => 'class="center nowraponall"', + 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("Date").': '.dol_print_date($datem, 'day', 'tzuserrel')).'"', 'text' => dol_print_date($date, 'day', 'tzuserrel'), ); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index e1ed8855378..6466754f241 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -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 .= ' '; $out .= "\n"; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 3a396e365d7..768031467bc 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1948,14 +1948,15 @@ class ExtraFields /** * Fill array_options property of object by extrafields value (using for data sent by forms) * - * @param array $extralabels Deprecated (old $array of extrafields, now set this to null) - * @param object $object Object - * @param string $onlykey Only some keys are filled: - * 'string' => When we make update of only one extrafield ($action = 'update_extras'), calling page can set this to avoid to have other extrafields being reset. - * '@GETPOSTISSET' => When we make update of several extrafields ($action = 'update'), calling page can set this to avoid to have fields not into POST being reset. - * @return int 1 if array_options set, 0 if no value, -1 if error (field required missing for example) + * @param array $extralabels Deprecated (old $array of extrafields, now set this to null) + * @param object $object Object + * @param string $onlykey Only some keys are filled: + * 'string' => When we make update of only one extrafield ($action = 'update_extras'), calling page can set this to avoid to have other extrafields being reset. + * '@GETPOSTISSET' => When we make update of several extrafields ($action = 'update'), calling page can set this to avoid to have fields not into POST being reset. + * @param int $todefaultifmissing 1=Set value to the default value in database if value is mandatory and missing + * @return int 1 if array_options set, 0 if no value, -1 if error (field required missing for example) */ - public function setOptionalsFromPost($extralabels, &$object, $onlykey = '') + public function setOptionalsFromPost($extralabels, &$object, $onlykey = '', $todefaultifmissing = 0) { global $_POST, $langs; @@ -2015,8 +2016,10 @@ class ExtraFields || (!is_array($_POST["options_".$key]) && isset($_POST["options_".$key]) && $this->attributes[$object->table_element]['type'][$key] == 'sellist' && $_POST['options_'.$key] == '0') || (is_array($_POST["options_".$key]) && empty($_POST["options_".$key]))) { //print 'ccc'.$value.'-'.$this->attributes[$object->table_element]['required'][$key]; + + // Field is not defined. We mark this as a problem. We may fix it later if there is a default value and $todefaultifmissing is set. $nofillrequired++; - $error_field_required[] = $langs->transnoentitiesnoconv($value); + $error_field_required[$key] = $langs->transnoentitiesnoconv($value); } } @@ -2047,12 +2050,22 @@ class ExtraFields } } + if (!empty($error_field_required[$key]) && $todefaultifmissing) { + // Value is required but we have a default value and we asked to set empty value to the default value + if (!empty($this->attributes[$object->table_element]['default']) && !is_null($this->attributes[$object->table_element]['default'][$key])) { + $value_key = $this->attributes[$object->table_element]['default'][$key]; + unset($error_field_required[$key]); + $nofillrequired--; + } + } + $object->array_options["options_".$key] = $value_key; } if ($nofillrequired) { $langs->load('errors'); - setEventMessages($langs->trans('ErrorFieldsRequired').' : '.implode(', ', $error_field_required), null, 'errors'); + $this->error = $langs->trans('ErrorFieldsRequired').' : '.implode(', ', $error_field_required); + setEventMessages($this->error, null, 'errors'); return -1; } else { return 1; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 244da59b5ff..19ea745c8e1 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -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]; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 8776381b922..8772cd55714 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2257,7 +2257,7 @@ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs $ret = ''; $countriesusingstate = array('AU', 'CA', 'US', 'IN', 'GB', 'ES', 'UK', 'TR', 'CN'); // See also MAIN_FORCE_STATE_INTO_ADDRESS - $sep = "\n"; + // See format of addresses on https://en.wikipedia.org/wiki/Address // Address if (empty($mode)) { diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 15162c8b273..56aa24a8523 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -509,7 +509,7 @@ function project_admin_prepare_head() $head[$h][2] = 'attributes_task'; $h++; - if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { $langs->load("members"); $head[$h][0] = DOL_URL_ROOT.'/projet/admin/website.php'; @@ -2819,7 +2819,7 @@ function getTaskProgressView($task, $label = true, $progressNumber = true, $hide $out .= ' '; } else { // bad - $out .= '
'; + $out .= '
'; $out .= '
'; $out .= '
'; } diff --git a/htdocs/core/tpl/extrafields_add.tpl.php b/htdocs/core/tpl/extrafields_add.tpl.php index 2f44bbe9c48..fa150d6a27b 100644 --- a/htdocs/core/tpl/extrafields_add.tpl.php +++ b/htdocs/core/tpl/extrafields_add.tpl.php @@ -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); } diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 187e3f5a156..0e018514353 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -924,7 +924,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } } - // If trackid is not defined, we set it + // If trackid is not defined, we set it. + // Note that it should be set by caller. This is for compatibility purpose only. if (empty($object->trackid)) { // See also similar list into emailcollector.class.php if (preg_match('/^COMPANY_/', $action)) { @@ -1039,15 +1040,17 @@ class InterfaceActionsAuto extends DolibarrTriggers $actioncomm->contact_id = $contactforaction->id; // deprecated, use ->socpeopleassigned instead $actioncomm->authorid = $user->id; // User saving action $actioncomm->userownerid = $user->id; // Owner of action - // Fields defined when action is an email (content should be into object->actionmsg to be added into note, subject into object->actionms2 to be added into label) - $actioncomm->email_msgid = empty($object->email_msgid) ? null : $object->email_msgid; - $actioncomm->email_from = empty($object->email_from) ? null : $object->email_from; - $actioncomm->email_sender = empty($object->email_sender) ? null : $object->email_sender; - $actioncomm->email_to = empty($object->email_to) ? null : $object->email_to; - $actioncomm->email_tocc = empty($object->email_tocc) ? null : $object->email_tocc; - $actioncomm->email_tobcc = empty($object->email_tobcc) ? null : $object->email_tobcc; - $actioncomm->email_subject = empty($object->email_subject) ? null : $object->email_subject; - $actioncomm->errors_to = empty($object->errors_to) ? null : $object->errors_to; + // Fields defined when action is an email (content should be into object->actionmsg to be added into event note, subject should be into object->actionms2 to be added into event label) + if (!property_exists($object, 'email_fields_no_propagate_in_actioncomm') || empty($object->email_fields_no_propagate_in_actioncomm)) { + $actioncomm->email_msgid = empty($object->email_msgid) ? null : $object->email_msgid; + $actioncomm->email_from = empty($object->email_from) ? null : $object->email_from; + $actioncomm->email_sender = empty($object->email_sender) ? null : $object->email_sender; + $actioncomm->email_to = empty($object->email_to) ? null : $object->email_to; + $actioncomm->email_tocc = empty($object->email_tocc) ? null : $object->email_tocc; + $actioncomm->email_tobcc = empty($object->email_tobcc) ? null : $object->email_tobcc; + $actioncomm->email_subject = empty($object->email_subject) ? null : $object->email_subject; + $actioncomm->errors_to = empty($object->errors_to) ? null : $object->errors_to; + } // Object linked (if link is for thirdparty, contact, project it is a recording error. We should not have links in link table // for such objects because there is already a dedicated field into table llx_actioncomm or llx_actioncomm_resources. diff --git a/htdocs/don/payment/payment.php b/htdocs/don/payment/payment.php index 5128509c88c..6cc37303346 100644 --- a/htdocs/don/payment/payment.php +++ b/htdocs/don/payment/payment.php @@ -149,7 +149,7 @@ $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); $sumpaid = $obj->total; - $db->free(); + $db->free($resql); } diff --git a/htdocs/expensereport/payment/payment.php b/htdocs/expensereport/payment/payment.php index ee80c9bc24a..185b3cdc139 100644 --- a/htdocs/expensereport/payment/payment.php +++ b/htdocs/expensereport/payment/payment.php @@ -212,7 +212,7 @@ if ($action == 'create' || empty($action)) { if ($resql) { $obj = $db->fetch_object($resql); $sumpaid = $obj->total; - $db->free(); + $db->free($resql); } print ''.$langs->trans("AlreadyPaid").''.price($sumpaid, 0, $outputlangs, 1, -1, -1, $conf->currency).''; print ''.$langs->trans("RemainderToPay").''.price($total - $sumpaid, 0, $outputlangs, 1, -1, -1, $conf->currency).''; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 1d26fb5cfab..b08e31381a1 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -3523,7 +3523,7 @@ class CommandeFournisseur extends CommonOrder empty($this->receptions[$obj->rowid]) ? $this->receptions[$obj->rowid] = $obj->qty : $this->receptions[$obj->rowid] += $obj->qty; $i++; } - $this->db->free(); + $this->db->free($resql); return $num; } else { diff --git a/htdocs/install/mysql/data/llx_10_c_regions.sql b/htdocs/install/mysql/data/llx_10_c_regions.sql index df4f0dabee8..752bc7de395 100644 --- a/htdocs/install/mysql/data/llx_10_c_regions.sql +++ b/htdocs/install/mysql/data/llx_10_c_regions.sql @@ -146,6 +146,27 @@ INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 5 INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 56, 5601, '', 0, 'Brasil'); +-- Burundi Regions (id country=61) -- https://fr.wikipedia.org/wiki/Provinces_du_Burundi +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6101, '', 0, 'Bubanza'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6102, '', 0, 'Bujumbura Mairie'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6103, '', 0, 'Bujumbura Rural'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6104, '', 0, 'Bururi'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6105, '', 0, 'Cankuzo'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6106, '', 0, 'Cibitoke'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6107, '', 0, 'Gitega'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6108, '', 0, 'Karuzi'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6109, '', 0, 'Kayanza'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6110, '', 0, 'Kirundo'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6111, '', 0, 'Makamba'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6112, '', 0, 'Muramvya'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6113, '', 0, 'Muyinga'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6114, '', 0, 'Mwaro'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6115, '', 0, 'Ngozi'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6116, '', 0, 'Rumonge'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6117, '', 0, 'Rutana'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6118, '', 0, 'Ruyigi'); + + -- Canada Region (id country=14) INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 14, 1401, '', 0, 'Canada'); @@ -512,25 +533,3 @@ INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 2 INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 232, 23208, '', 0, 'Nor-Oriental'); INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 232, 23209, '', 0, 'Zuliana'); - - --- Burundi Regions (id country=61) -- https://fr.wikipedia.org/wiki/Provinces_du_Burundi -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6101, '', 0, 'Bubanza'); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6102, '', 0, 'Bujumbura Mairie'); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6103, '', 0, 'Bujumbura Rural'); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6104, '', 0, 'Bururi'); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6105, '', 0, 'Cankuzo'); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6106, '', 0, 'Cibitoke'); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6107, '', 0, 'Gitega'); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6108, '', 0, 'Karuzi'); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6109, '', 0, 'Kayanza'); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6110, '', 0, 'Kirundo'); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6111, '', 0, 'Makamba'); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6112, '', 0, 'Muramvya'); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6113, '', 0, 'Muyinga'); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6114, '', 0, 'Mwaro'); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6115, '', 0, 'Ngozi'); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6116, '', 0, 'Rumonge'); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6117, '', 0, 'Rutana'); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 61, 6118, '', 0, 'Ruyigi'); - diff --git a/htdocs/install/mysql/tables/llx_webhook_target-webhook.sql b/htdocs/install/mysql/tables/llx_webhook_target-webhook.sql index 1e0cc0fdbac..28802156847 100644 --- a/htdocs/install/mysql/tables/llx_webhook_target-webhook.sql +++ b/htdocs/install/mysql/tables/llx_webhook_target-webhook.sql @@ -28,7 +28,9 @@ CREATE TABLE llx_webhook_target( fk_user_modif integer, import_key varchar(14), status integer DEFAULT 0 NOT NULL, - url varchar(255) NOT NULL, - trigger_codes text NOT NULL + url varchar(255) NOT NULL, + connection_method varchar(255) NULL, -- to store the way to authenticate to the webhook + connection_data varchar(255) NULL, -- to store the data to use to authenticate to the webhook + trigger_codes text NULL -- list of selected trigger that must call the webhook -- END MODULEBUILDER FIELDS ) ENGINE=innodb; diff --git a/htdocs/intracommreport/list.php b/htdocs/intracommreport/list.php index b6bfd45c91a..1478dbea83f 100644 --- a/htdocs/intracommreport/list.php +++ b/htdocs/intracommreport/list.php @@ -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_'); */ diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 3a0e96d58da..8dcd1f9f93d 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2253,4 +2253,5 @@ HashForPing=Hash used for ping ReadOnlyMode=Is instance in "Read Only" mode DEBUGBAR_USE_LOG_FILE=Use the dolibarr.log 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') \ No newline at end of file +FixedOrPercent=Fixed (use keyword 'fixed') or percent (use keyword 'percent') +DefaultOpportunityStatus=Default opportunity status (first status when lead is created) \ No newline at end of file diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 530f3b6af0e..97111df74cd 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -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. \ No newline at end of file diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 1e0ed42d3e3..739a35dcebf 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -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 \ No newline at end of file diff --git a/htdocs/loan/payment/payment.php b/htdocs/loan/payment/payment.php index 47fa5b37846..ac2b967593c 100644 --- a/htdocs/loan/payment/payment.php +++ b/htdocs/loan/payment/payment.php @@ -244,7 +244,7 @@ if ($action == 'create') { if ($resql) { $obj = $db->fetch_object($resql); $sumpaid = $obj->total; - $db->free(); + $db->free($resql); } print '
'; diff --git a/htdocs/product/dynamic_price/class/price_parser.class.php b/htdocs/product/dynamic_price/class/price_parser.class.php index 9bd986a3c73..764ff919cc7 100644 --- a/htdocs/product/dynamic_price/class/price_parser.class.php +++ b/htdocs/product/dynamic_price/class/price_parser.class.php @@ -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) { diff --git a/htdocs/projet/admin/project.php b/htdocs/projet/admin/project.php index 4bfb899cffe..36ef3a501ff 100644 --- a/htdocs/projet/admin/project.php +++ b/htdocs/projet/admin/project.php @@ -265,7 +265,7 @@ print ' '."\n"; print ''; print ''.$langs->trans("ManageOpportunitiesStatus").''; print ''; -print ajax_constantonoff("PROJECT_USE_OPPORTUNITIES"); +print ajax_constantonoff("PROJECT_USE_OPPORTUNITIES", null, null, 0, 0, 1); print ''; print ""; print ''; diff --git a/htdocs/projet/admin/website.php b/htdocs/projet/admin/website.php index 25497fef436..37b858757ca 100644 --- a/htdocs/projet/admin/website.php +++ b/htdocs/projet/admin/website.php @@ -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 = ''.$langs->trans("BackToModuleList").''; -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 ''; print ''; print ''; -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 ''.$langs->trans("LeadPublicFormDesc").'

'; +$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 ''; +print '
'; + +if (!empty($conf->global->PROJECT_ENABLE_PUBLIC)) { + print '
'; + + print '
'; + print ''; + + print ''; + print ''; + print ''; + print "\n"; + + // Default opportunity status + print '\n"; + + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; + print $langs->trans("DefaultOpportunityStatus"); + print ''; + 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 "
'; + print '
'; + + print '
'; + print ''; + print '
'; +} print dol_get_fiche_end(); @@ -120,8 +157,8 @@ print '
'; if (!empty($conf->global->PROJECT_ENABLE_PUBLIC)) { print '
'; //print $langs->trans('FollowingLinksArePublic').'
'; - print img_picto('', 'globe').' '.$langs->trans('BlankSubscriptionForm').':
'; - if ($conf->multicompany->enabled) { + print img_picto('', 'globe').' '.$langs->trans('BlankSubscriptionForm').'
'; + 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 ''.$urlwithroot.'/public/project/new.php'.$entity_qr.''; + print ''; + print ajax_autoselect('publicurlmember'); } // End of page diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 98f2fed52b4..cadeb278ae7 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -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; @@ -236,14 +238,14 @@ class Project extends CommonObject 'datee' =>array('type'=>'date', 'label'=>'DateEnd', 'enabled'=>1, 'visible'=>1, 'position'=>35), 'description' =>array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>3, 'position'=>55, 'searchall'=>1), 'public' =>array('type'=>'integer', 'label'=>'Visibility', 'enabled'=>1, 'visible'=>1, 'position'=>65), - 'fk_opp_status' =>array('type'=>'integer', 'label'=>'OpportunityStatusShort', 'enabled'=>1, 'visible'=>1, 'position'=>75), - 'opp_percent' =>array('type'=>'double(5,2)', 'label'=>'OpportunityProbabilityShort', 'enabled'=>1, 'visible'=>1, 'position'=>80), + 'fk_opp_status' =>array('type'=>'integer', 'label'=>'OpportunityStatusShort', 'enabled'=>'!empty($conf->global->PROJECT_USE_OPPORTUNITIES)', 'visible'=>1, 'position'=>75), + 'opp_percent' =>array('type'=>'double(5,2)', 'label'=>'OpportunityProbabilityShort', 'enabled'=>'!empty($conf->global->PROJECT_USE_OPPORTUNITIES)', 'visible'=>1, 'position'=>80), 'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>85, 'searchall'=>1), 'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>90, 'searchall'=>1), 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'ModelPdf', 'enabled'=>1, 'visible'=>0, 'position'=>95), 'date_close' =>array('type'=>'datetime', 'label'=>'DateClosing', 'enabled'=>1, 'visible'=>0, 'position'=>105), 'fk_user_close' =>array('type'=>'integer', 'label'=>'UserClosing', 'enabled'=>1, 'visible'=>0, 'position'=>110), - 'opp_amount' =>array('type'=>'double(24,8)', 'label'=>'OpportunityAmountShort', 'enabled'=>1, 'visible'=>1, 'position'=>115), + 'opp_amount' =>array('type'=>'double(24,8)', 'label'=>'OpportunityAmountShort', 'enabled'=>1, 'visible'=>'!empty($conf->global->PROJECT_USE_OPPORTUNITIES)', 'position'=>115), 'budget_amount' =>array('type'=>'double(24,8)', 'label'=>'Budget', 'enabled'=>1, 'visible'=>1, 'position'=>119), 'usage_bill_time' =>array('type'=>'integer', 'label'=>'UsageBillTimeShort', 'enabled'=>1, 'visible'=>-1, 'position'=>130), 'usage_opportunity' =>array('type'=>'integer', 'label'=>'UsageOpportunity', 'enabled'=>1, 'visible'=>-1, 'position'=>135), diff --git a/htdocs/projet/class/projectstats.class.php b/htdocs/projet/class/projectstats.class.php index efd8ecc3424..9b2314deacc 100644 --- a/htdocs/projet/class/projectstats.class.php +++ b/htdocs/projet/class/projectstats.class.php @@ -28,6 +28,10 @@ class ProjectStats extends Stats public $userid; public $socid; public $year; + public $yearmonth; + public $status; + public $opp_status; + /** * Constructor @@ -180,7 +184,25 @@ class ProjectStats extends Stats } if (!empty($this->status)) { - $sqlwhere[] = " t.fk_opp_status IN (".$this->db->sanitize($this->status).")"; + $sqlwhere[] = " t.fk_statut IN (".$this->db->sanitize($this->status).")"; + } + + if (!empty($this->opp_status)) { + if (is_numeric($this->opp_status) && $this->opp_status > 0) { + $sqlwhere[] = " t.fk_opp_status = ".((int) $this->opp_status); + } + if ($this->opp_status == 'all') { + $sqlwhere[] = " (t.fk_opp_status IS NOT NULL AND t.fk_opp_status <> -1)"; + } + if ($this->opp_status == 'openedopp') { + $sqlwhere[] = " (t.fk_opp_status IS NOT NULL AND t.fk_opp_status <> -1 AND t.fk_opp_status NOT IN (SELECT rowid FROM ".MAIN_DB_PREFIX."c_lead_status WHERE code IN ('WON','LOST')))"; + } + if ($this->opp_status == 'notopenedopp') { + $sqlwhere[] = " (t.fk_opp_status IS NULL OR t.fk_opp_status = -1 OR t.fk_opp_status IN (SELECT rowid FROM ".MAIN_DB_PREFIX."c_lead_status WHERE code = 'WON'))"; + } + if ($this->opp_status == 'none') { + $sqlwhere[] = " (t.fk_opp_status IS NULL OR t.fk_opp_status = -1)"; + } } if (empty($user->rights->projet->all->lire)) { diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 0d5c4964003..0e6df96a8ed 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -932,7 +932,7 @@ if (!empty($arrayfields['p.public']['checked'])) { // Opp status if (!empty($arrayfields['p.fk_opp_status']['checked'])) { print ''; - 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 ''; } if (!empty($arrayfields['p.opp_amount']['checked'])) { @@ -1174,8 +1174,8 @@ while ($i < min($num, $limit)) { } // Title if (!empty($arrayfields['p.title']['checked'])) { - print ''; - print dol_trunc($obj->title, 80); + print ''; + print $obj->title; print ''; if (!$i) { $totalarray['nbfield']++; diff --git a/htdocs/projet/stats/index.php b/htdocs/projet/stats/index.php index f41651e15d8..5926451e321 100644 --- a/htdocs/projet/stats/index.php +++ b/htdocs/projet/stats/index.php @@ -24,18 +24,15 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/projectstats.class.php'; -// Security check -if (!$user->rights->projet->lire) { - accessforbidden(); -} - - $WIDTH = DolGraph::getDefaultGraphSizeForStats('width'); $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); +$search_opp_status = GETPOST("search_opp_status", 'alpha'); + $userid = GETPOST('userid', 'int'); $socid = GETPOST('socid', 'int'); // Security check @@ -44,19 +41,25 @@ if ($user->socid > 0) { $socid = $user->socid; } $nowyear = strftime("%Y", dol_now()); -$year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear; +$year = GETPOST('year', 'int') > 0 ? GETPOST('year', 'int') : $nowyear; $startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS))); $endyear = $year; // Load translation files required by the page $langs->loadLangs(array('companies', 'projects')); +// Security check +if (!$user->rights->projet->lire) { + accessforbidden(); +} + /* * View */ $form = new Form($db); +$formproject = new FormProjets($db); $includeuserlist = array(); @@ -82,66 +85,11 @@ if (!empty($year)) { $stats_project->year = $year; } -/* -if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) -{ - // Current stats of project amount per status - $data1 = $stats_project->getAllProjectByStatus(); - - if (!is_array($data1) && $data1 < 0) { - setEventMessages($stats_project->error, null, 'errors'); +if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { + if ($search_opp_status) { + $stats_project->opp_status = $search_opp_status; } - if (empty($data1)) - { - $showpointvalue = 0; - $nocolor = 1; - $data1 = array(array(0=>$langs->trans("None"), 1=>1)); - } - - $filenamenb = $conf->project->dir_output."/stats/projectbystatus.png"; - $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=projectstats&file=projectbystatus.png'; - $px = new DolGraph(); - $mesg = $px->isGraphKo(); - if (empty($mesg)) { - $i = 0; $tot = count($data1); $legend = array(); - while ($i <= $tot) - { - $legend[] = $data1[$i][0]; - $i++; - } - - $px->SetData($data1); - unset($data1); - - if ($nocolor) - $px->SetDataColor(array( - array( - 220, - 220, - 220 - ) - )); - - $px->SetLegend($legend); - $px->setShowLegend(0); - $px->setShowPointValue($showpointvalue); - $px->setShowPercent(1); - $px->SetMaxValue($px->GetCeilMaxValue()); - $px->SetWidth($WIDTH); - $px->SetHeight($HEIGHT); - $px->SetShading(3); - $px->SetHorizTickIncrement(1); - $px->SetCssPrefix("cssboxes"); - $px->SetType(array('pie')); - $px->SetTitle($langs->trans('OpportunitiesStatusForProjects')); - $result = $px->draw($filenamenb, $fileurlnb); - if ($result < 0) { - setEventMessages($px->error, null, 'errors'); - } - } else { - setEventMessages(null, $mesg, 'errors'); - } -}*/ +} // Build graphic number of object @@ -285,12 +233,19 @@ print ''.$langs->trans("ThirdParty").''; print img_picto('', 'company', 'class="pictofixedwidth"'); print $form->select_company($socid, 'socid', '', 1, 0, 0, array(), 0, 'widthcentpercentminusx maxwidth300', ''); print ''; +// Opportunity status +if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { + print ''.$langs->trans("OpportunityStatusShort").''; + print $formproject->selectOpportunityStatus('search_opp_status', $search_opp_status, 1, 0, 1, 0, 'maxwidth300', 1, 1); + print ''; +} + // User /*print ''.$langs->trans("ProjectCommercial").''; print $form->select_dolusers($userid, 'userid', 1, array(),0,$includeuserlist); print '';*/ // Year -print ''.$langs->trans("Year").''; +print ''.$langs->trans("Year").' ('.$langs->trans("DateCreation").')'; if (!in_array($year, $arrayyears)) { $arrayyears[$year] = $year; } diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 055ffec56f9..7a27ae14b62 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -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 '
'; + print '

'; print '
'; print $langs->trans("NewMemberbyWeb"); print '
'; @@ -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")); diff --git a/htdocs/public/partnership/new.php b/htdocs/public/partnership/new.php index cbc1b849115..f6f0efc4fb2 100644 --- a/htdocs/public/partnership/new.php +++ b/htdocs/public/partnership/new.php @@ -419,7 +419,7 @@ if (empty($reshook) && $action == 'added') { llxHeaderVierge($langs->trans("NewPartnershipForm")); // Si on a pas ete redirige - print '
'; + print '

'; print '
'; print $langs->trans("NewPartnershipbyWeb"); print '
'; @@ -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")); diff --git a/htdocs/public/project/new.php b/htdocs/public/project/new.php index 971031e7a80..4838c88c5a1 100644 --- a/htdocs/public/project/new.php +++ b/htdocs/public/project/new.php @@ -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 '
'; } - if (!empty($conf->global->PROJECT_IMAGE_PUBLIC_ORGANIZEDEVENT)) { - print '
'; - print ''; + if (!empty($conf->global->PROJECT_IMAGE_PUBLIC_NEWLEAD)) { + print '
'; + print ''; print '
'; } @@ -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"))."
\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")."
\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")."
\n"; - } - if (!GETPOST("email")) { - $error++; - $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("EMail"))."
\n"; - } - } - */ - if (GETPOST('type') <= 0) { - $error++; - $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type"))."
\n"; - } - if (!in_array(GETPOST('morphy'), array('mor', 'phy'))) { - $error++; - $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv('Nature'))."
\n"; - } if (!GETPOST("lastname")) { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Lastname"))."
\n"; @@ -238,27 +185,124 @@ if (empty($reshook) && $action == 'add') { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Firstname"))."
\n"; } + if (!GETPOST("email")) { + $error++; + $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Email"))."
\n"; + } + if (!GETPOST("description")) { + $error++; + $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Message"))."
\n"; + } if (GETPOST("email") && !isValidEmail(GETPOST("email"))) { $error++; $langs->load("errors"); $errmsg .= $langs->trans("ErrorBadEMail", GETPOST("email"))."
\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"))."
\n"; + } + + $proj = new Project($db); + $thirdparty = new Societe($db); if (!$error) { - // email a peu pres correct et le login n'existe pas - $proj = new Project($db); - $proj->statut = -1; + // 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; + } else { + // Create the prospect + if (GETPOST('societe')) { + $thirdparty->name = GETPOST('societe'); + $thirdparty->name_alias = dolGetFirstLastname(GETPOST('firstname'), GETPOST('lastname')); + } else { + $thirdparty->name = dolGetFirstLastname(GETPOST('firstname'), GETPOST('lastname')); + } + $thirdparty->address = GETPOST('address'); + $thirdparty->zip = GETPOST('zip'); + $thirdparty->town = GETPOST('town'); + $thirdparty->country_id = GETPOST('country_id', 'int'); + $thirdparty->state_id = GETPOST('state_id'); + $thirdparty->client = $thirdparty::PROSPECT; + $thirdparty->code_client = 'auto'; + $thirdparty->code_fournisseur = 'auto'; + + // Fill array 'array_options' with data from the form + $extrafields->fetch_name_optionals_label($thirdparty->table_element); + $ret = $extrafields->setOptionalsFromPost(null, $thirdparty, '', 1); + //var_dump($thirdparty->array_options);exit; + if ($ret < 0) { + $error++; + $errmsg = ($extrafields->error ? $extrafields->error.'
' : '').join('
', $extrafields->errors); + } + + if (!$error) { + $result = $thirdparty->create($user); + if ($result <= 0) { + $error++; + $errmsg = ($thirdparty->error ? $thirdparty->error.'
' : '').join('
', $thirdparty->errors); + } else { + $proj->socid = $thirdparty->id; + } + } + } + } + + if (!$error) { + // 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 +319,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 +332,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 +365,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('
', $proj->errors); + $errmsg .= $proj->error.'
'.join('
', $proj->errors); } } @@ -334,23 +383,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 '
'; + print '

'; print '
'; - print $langs->trans("NewMemberbyWeb"); + print $langs->trans("NewLeadbyWeb"); print '
'; llxFooterVierge(); @@ -365,8 +407,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 +457,16 @@ jQuery(document).ready(function () { print ''."\n"; // Lastname -print ''."\n"; +print ''."\n"; // Firstname -print ''."\n"; +print ''."\n"; +// EMail +print ''."\n"; // Company print ''."\n"; // Address print ''."\n"; +print ''."\n"; // Zip / Town print ''; if (empty($conf->global->SOCIETE_DISABLE_STATE)) { print ''; } -// EMail -print ''."\n"; + // Other attributes $tpl_context = 'public'; // define template context to public include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; // Comments print ''; -print ''; -print ''; +print ''; +print ''; print ''."\n"; print "
'.$langs->trans("Lastname").' *
'.$langs->trans("Lastname").' *
'.$langs->trans("Firstname").' *
'.$langs->trans("Firstname").' *
'.$langs->trans("Email").' *
'.$langs->trans("Company").'
'.$langs->trans("Address").''."\n"; -print '
'.$langs->trans('Zip').' / '.$langs->trans('Town').''; print $formcompany->select_ziptown(GETPOST('zipcode'), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6, 1); @@ -453,21 +497,20 @@ print '
'.$langs->trans('State').''; 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 '
'.$langs->trans("Email").' *
'.$langs->trans("Comments").''.$langs->trans("Message").' *
\n"; diff --git a/htdocs/recruitment/class/recruitmentcandidature.class.php b/htdocs/recruitment/class/recruitmentcandidature.class.php index 77b5b5b21ae..fb08409eb27 100644 --- a/htdocs/recruitment/class/recruitmentcandidature.class.php +++ b/htdocs/recruitment/class/recruitmentcandidature.class.php @@ -62,6 +62,11 @@ class RecruitmentCandidature extends CommonObject */ public $picto = 'recruitmentcandidature'; + /** + * @var int Do not exploit fields email_xxx into triggers. + */ + public $email_fields_no_propagate_in_actioncomm; + const STATUS_DRAFT = 0; const STATUS_VALIDATED = 1; diff --git a/htdocs/recruitment/recruitmentcandidature_card.php b/htdocs/recruitment/recruitmentcandidature_card.php index eca3a497e61..186864deb84 100644 --- a/htdocs/recruitment/recruitmentcandidature_card.php +++ b/htdocs/recruitment/recruitmentcandidature_card.php @@ -134,7 +134,9 @@ if (empty($reshook)) { $triggermodname = 'RECRUITMENTCANDIDATURE_MODIFY'; // Name of trigger action code to execute when we modify record // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen + $object->email_fields_no_propagate_in_actioncomm = 1; include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; + $object->email_fields_no_propagate_in_actioncomm = 0; // Actions when linking object each other include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 1d32063c27b..30f8515e92c 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -956,7 +956,7 @@ class Societe extends CommonObject $sql .= ", accountancy_code_sell"; $sql .= ") VALUES ("; $sql .= $this->id; - $sql .= ", ".$conf->entity; + $sql .= ", ".((int) $conf->entity); $sql .= ", '".$this->db->escape($this->accountancy_code_customer)."'"; $sql .= ", '".$this->db->escape($this->accountancy_code_supplier)."'"; $sql .= ", '".$this->db->escape($this->accountancy_code_buy)."'"; diff --git a/htdocs/theme/eldy/progress.inc.php b/htdocs/theme/eldy/progress.inc.php index e74c84cf89e..1bc40e2f2fc 100644 --- a/htdocs/theme/eldy/progress.inc.php +++ b/htdocs/theme/eldy/progress.inc.php @@ -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); -} \ No newline at end of file +} +.progress-bar-consumed-late { + background-color: ; +} + diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 72ec8625e0e..9e097e303c8 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -1372,7 +1372,12 @@ class Ticket extends CommonObject $label .= ''.$langs->trans('Ref').': '.$this->ref.'
'; $label .= ''.$langs->trans('TicketTrackId').': '.$this->track_id.'
'; $label .= ''.$langs->trans('Subject').': '.$this->subject; - + if ($this->date_creation) { + $label .= '
'.$langs->trans('DateCreation').': '.$this->date_creation; + } + if ($this->date_modification) { + $label .= '
'.$langs->trans('DateModification').': '.$this->date_modification; + } $url = DOL_URL_ROOT.'/ticket/card.php?id='.$this->id; if ($option != 'nolink') { diff --git a/htdocs/workstation/class/workstation.class.php b/htdocs/workstation/class/workstation.class.php index df6d697f73f..4131f074e85 100644 --- a/htdocs/workstation/class/workstation.class.php +++ b/htdocs/workstation/class/workstation.class.php @@ -101,12 +101,12 @@ class Workstation extends CommonObject public $fields=array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>1, 'noteditable'=>'0', 'default'=>'', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of object"), - 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'showoncombobox'=>'2',), + 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'csslist'=>'tdoverflowmax125', 'showoncombobox'=>'2',), 'type' => array('type'=>'varchar(8)', 'label'=>'Type', 'enabled'=>'1', 'position'=>32, 'default'=>1, 'notnull'=>1, 'visible'=>1, 'arrayofkeyval'=>array('HUMAN'=>'Human', 'MACHINE'=>'Machine', 'BOTH'=>'HumanMachine'),), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,), - 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), - 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,), + 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2, 'csslist'=>'nowraponall'), + 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2, 'csslist'=>'nowraponall'), 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',), 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>512, 'notnull'=>-1, 'visible'=>-2,),