From 9d234a854158f979f88b4e5119569dc8ca6c9ff3 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Tue, 3 Aug 2021 18:32:22 +0200 Subject: [PATCH 01/28] FIX: multicurrency: fields in discount unitialized when creating deposit --- htdocs/compta/facture/card.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index fe5d5c3ab0a..9501d34277e 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1668,6 +1668,11 @@ if (empty($reshook)) $discount->tva_tx = $lines[$i]->tva_tx; $discount->fk_user = $user->id; $discount->description = $desc; + $discount->multicurrency_subprice = abs($lines[$i]->multicurrency_subprice); + $discount->multicurrency_amount_ht = abs($lines[$i]->multicurrency_total_ht); + $discount->multicurrency_amount_tva = abs($lines[$i]->multicurrency_total_tva); + $discount->multicurrency_amount_ttc = abs($lines[$i]->multicurrency_total_ttc); + $discountid = $discount->create($user); if ($discountid > 0) { $result = $object->insert_discount($discountid); // This include link_to_invoice From 2da16ade6c722e1464a6c8f571beaba150f194d9 Mon Sep 17 00:00:00 2001 From: atm-florian Date: Fri, 8 Oct 2021 17:24:52 +0200 Subject: [PATCH 02/28] FIX: consistent UX when calling a tab from the invoice card with empty ref / id --- htdocs/compta/facture/card.php | 11 +++++++++++ htdocs/compta/facture/contact.php | 11 +++++++++++ htdocs/compta/facture/document.php | 11 +++++++++++ htdocs/compta/facture/info.php | 11 +++++++++++ htdocs/compta/facture/note.php | 11 +++++++++++ 5 files changed, 55 insertions(+) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index e15b2722800..ab568332dd8 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2756,6 +2756,17 @@ if (empty($reshook)) * View */ +if (empty($object->id)) { + llxHeader(); + $head = facture_prepare_head($object); + $langs->load('errors'); + echo dol_get_fiche_head($head, 'compta', $langs->trans("InvoiceCustomer"), -1, 'bill'), + '
' . $langs->trans("ErrorRecordNotFound") . '
'; + llxFooter(); + dol_shutdown(); + exit; +} + $form = new Form($db); $formother = new FormOther($db); $formfile = new FormFile($db); diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index c340d68242e..c0e0a40c2c5 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -118,6 +118,17 @@ elseif ($action == 'deletecontact' && $user->rights->facture->creer) * View */ +if (empty($object->id)) { + llxHeader(); + $head = facture_prepare_head($object); + $langs->load('errors'); + echo dol_get_fiche_head($head, 'contact', $langs->trans("InvoiceCustomer"), -1, 'bill'), + '
' . $langs->trans("ErrorRecordNotFound") . '
'; + llxFooter(); + dol_shutdown(); + exit; +} + $title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('ContactsAddresses'); $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $helpurl); diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index e880d77db74..64ebed251d3 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -85,6 +85,17 @@ require_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; * View */ +if (empty($object->id)) { + llxHeader(); + $head = facture_prepare_head($object); + $langs->load('errors'); + echo dol_get_fiche_head($head, 'documents', $langs->trans("InvoiceCustomer"), -1, 'bill'), + '
' . $langs->trans("ErrorRecordNotFound") . '
'; + llxFooter(); + dol_shutdown(); + exit; +} + $title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Documents'); $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $helpurl); diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php index bad63cf1f61..9e40fd8b5a8 100644 --- a/htdocs/compta/facture/info.php +++ b/htdocs/compta/facture/info.php @@ -43,6 +43,17 @@ $ref = GETPOST("ref", 'alpha'); * View */ +if (empty($object->id)) { + llxHeader(); + $head = facture_prepare_head($object); + $langs->load('errors'); + echo dol_get_fiche_head($head, 'info', $langs->trans("InvoiceCustomer"), -1, 'bill'), + '
' . $langs->trans("ErrorRecordNotFound") . '
'; + llxFooter(); + dol_shutdown(); + exit; +} + $form = new Form($db); $title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Info'); diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php index 07084a0cf2c..428383b4907 100644 --- a/htdocs/compta/facture/note.php +++ b/htdocs/compta/facture/note.php @@ -64,6 +64,17 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, * View */ +if (empty($object->id)) { + llxHeader(); + $head = facture_prepare_head($object); + $langs->load('errors'); + echo dol_get_fiche_head($head, 'note', $langs->trans("InvoiceCustomer"), -1, 'bill'), + '
' . $langs->trans("ErrorRecordNotFound") . '
'; + llxFooter(); + dol_shutdown(); + exit; +} + $title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Notes'); $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $helpurl); From 57052e2fbabffa16b25a25fe02a1966e117d09db Mon Sep 17 00:00:00 2001 From: atm-florian Date: Mon, 11 Oct 2021 11:10:14 +0200 Subject: [PATCH 03/28] FIX PR#18931 Remove useless explicit call to dol_shutdown --- htdocs/compta/facture/card.php | 1 - htdocs/compta/facture/contact.php | 1 - htdocs/compta/facture/document.php | 1 - htdocs/compta/facture/info.php | 1 - htdocs/compta/facture/note.php | 1 - 5 files changed, 5 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index ab568332dd8..c772fd0ad7b 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2763,7 +2763,6 @@ if (empty($object->id)) { echo dol_get_fiche_head($head, 'compta', $langs->trans("InvoiceCustomer"), -1, 'bill'), '
' . $langs->trans("ErrorRecordNotFound") . '
'; llxFooter(); - dol_shutdown(); exit; } diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index c0e0a40c2c5..7177463c30e 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -125,7 +125,6 @@ if (empty($object->id)) { echo dol_get_fiche_head($head, 'contact', $langs->trans("InvoiceCustomer"), -1, 'bill'), '
' . $langs->trans("ErrorRecordNotFound") . '
'; llxFooter(); - dol_shutdown(); exit; } diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index 64ebed251d3..0818b944705 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -92,7 +92,6 @@ if (empty($object->id)) { echo dol_get_fiche_head($head, 'documents', $langs->trans("InvoiceCustomer"), -1, 'bill'), '
' . $langs->trans("ErrorRecordNotFound") . '
'; llxFooter(); - dol_shutdown(); exit; } diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php index 9e40fd8b5a8..955c41693c0 100644 --- a/htdocs/compta/facture/info.php +++ b/htdocs/compta/facture/info.php @@ -50,7 +50,6 @@ if (empty($object->id)) { echo dol_get_fiche_head($head, 'info', $langs->trans("InvoiceCustomer"), -1, 'bill'), '
' . $langs->trans("ErrorRecordNotFound") . '
'; llxFooter(); - dol_shutdown(); exit; } diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php index 428383b4907..dadb61b551d 100644 --- a/htdocs/compta/facture/note.php +++ b/htdocs/compta/facture/note.php @@ -71,7 +71,6 @@ if (empty($object->id)) { echo dol_get_fiche_head($head, 'note', $langs->trans("InvoiceCustomer"), -1, 'bill'), '
' . $langs->trans("ErrorRecordNotFound") . '
'; llxFooter(); - dol_shutdown(); exit; } From 17773f84143a13419edef2c48b40b88ba5c598fe Mon Sep 17 00:00:00 2001 From: atm-florian Date: Fri, 22 Oct 2021 18:26:23 +0200 Subject: [PATCH 04/28] FIX tcpdf vulnerability to roman numeral bomb, cf. tecnickom/TCPDF issue #315 --- dev/dolibarr_changes.txt | 12 ++++++++++++ .../tecnickcom/tcpdf/include/tcpdf_static.php | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/dev/dolibarr_changes.txt b/dev/dolibarr_changes.txt index ecd25ce692b..8cb0e002d16 100644 --- a/dev/dolibarr_changes.txt +++ b/dev/dolibarr_changes.txt @@ -175,6 +175,18 @@ In htdocs/includes/tecnickcom/tcpdf/tcpdf.php - protected $default_monospaced_font = 'courier'; + protected $default_monospaced_font = 'freemono'; +* In tecnickcom/tcpdf/include/tcpdf_static, in function intToRoman, right at the beginning + of the function, replace: + + $roman = ''; + +with: + + $roman = ''; + if ($number >= 4000) { + // do not represent numbers above 4000 in Roman numerals + return strval($number); + } diff --git a/htdocs/includes/tecnickcom/tcpdf/include/tcpdf_static.php b/htdocs/includes/tecnickcom/tcpdf/include/tcpdf_static.php index 67bb255d187..9ed6233b46c 100644 --- a/htdocs/includes/tecnickcom/tcpdf/include/tcpdf_static.php +++ b/htdocs/includes/tecnickcom/tcpdf/include/tcpdf_static.php @@ -1440,6 +1440,10 @@ class TCPDF_STATIC { */ public static function intToRoman($number) { $roman = ''; + if ($number >= 4000) { + // do not represent numbers above 4000 in Roman numerals + return strval($number); + } while ($number >= 1000) { $roman .= 'M'; $number -= 1000; From 00b617d17fee7ea93897da8f7dd958e08c785506 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 23 Oct 2021 22:22:45 +0200 Subject: [PATCH 05/28] Fix #18961 : no_email field has been replaced by mailing_unsubscribe table --- htdocs/contact/list.php | 20 ++++++++----- .../modules/mailings/contacts1.modules.php | 30 ++++++++----------- .../modules/mailings/modules_mailings.php | 18 ----------- .../public/emailing/mailing-unsubscribe.php | 14 --------- 4 files changed, 24 insertions(+), 58 deletions(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 295e63c9606..935e90e6085 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -175,7 +175,7 @@ $arrayfields = array( 'p.phone_mobile'=>array('label'=>"PhoneMobile", 'position'=>32, 'checked'=>1), 'p.fax'=>array('label'=>"Fax", 'position'=>33, 'checked'=>0), 'p.email'=>array('label'=>"EMail", 'position'=>40, 'checked'=>1), - 'p.no_email'=>array('label'=>"No_Email", 'position'=>41, 'checked'=>0, 'enabled'=>(!empty($conf->mailing->enabled))), + 'mu.rowid'=>array('label'=>"No_Email", 'position'=>41, 'checked'=>0, 'enabled'=>(!empty($conf->mailing->enabled))), 'p.thirdparty'=>array('label'=>"ThirdParty", 'position'=>50, 'checked'=>1, 'enabled'=>empty($conf->global->SOCIETE_DISABLE_CONTACTS)), 'p.priv'=>array('label'=>"ContactVisibility", 'checked'=>1, 'position'=>200), 'p.datec'=>array('label'=>"DateCreationShort", 'checked'=>0, 'position'=>500), @@ -298,7 +298,7 @@ $contactstatic = new Contact($db); $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); $sql = "SELECT s.rowid as socid, s.nom as name,"; -$sql .= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.zip, p.town, p.poste, p.email, p.no_email,"; +$sql .= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.zip, p.town, p.poste, p.email,"; $sql .= " p.socialnetworks, p.photo,"; $sql .= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.datec as date_creation, p.tms as date_update,"; $sql .= " co.label as country, co.code as country_code"; @@ -306,6 +306,9 @@ $sql .= " co.label as country, co.code as country_code"; if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } +if(!empty($conf->mailing->enabled)) { + $sql .= ", mu.rowid as no_email"; +} // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook @@ -318,6 +321,7 @@ if (!empty($search_categ)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_conta if (!empty($search_categ_thirdparty)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; // We need this table joined to the select in order to filter by categ if (!empty($search_categ_supplier)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs2 ON s.rowid = cs2.fk_soc"; // We need this table joined to the select in order to filter by categ if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; +if(!empty($conf->mailing->enabled)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."mailing_unsubscribe as mu ON mu.email = p.email"; $sql .= ' WHERE p.entity IN ('.getEntity('socpeople').')'; if (!$user->rights->societe->client->voir && !$socid) //restriction { @@ -374,8 +378,8 @@ if (strlen($search_town)) $sql .= natural_search("p.town", $search_town); if (count($search_roles) > 0) { $sql .= " AND p.rowid IN (SELECT sc.fk_socpeople FROM ".MAIN_DB_PREFIX."societe_contacts as sc WHERE sc.fk_c_type_contact IN (".implode(',', $search_roles)."))"; } - -if ($search_no_email != '' && $search_no_email >= 0) $sql .= " AND p.no_email = ".$db->escape($search_no_email); +if ($search_no_email != -1 && $search_no_email > 0) $sql .= " AND mu.rowid IS NOT NULL"; +if ($search_no_email != -1 && $search_no_email == 0) $sql .= " AND mu.rowid IS NULL"; if ($search_status != '' && $search_status >= 0) $sql .= " AND p.statut = ".$db->escape($search_status); if ($search_import_key) $sql .= natural_search("p.import_key", $search_import_key); if ($type == "o") // filtre sur type @@ -662,7 +666,7 @@ if (!empty($arrayfields['p.email']['checked'])) print ''; print ''; } -if (!empty($arrayfields['p.no_email']['checked'])) +if (!empty($arrayfields['mu.rowid']['checked'])) { print ''; print $form->selectarray('search_no_email', array('-1'=>'', '0'=>$langs->trans('No'), '1'=>$langs->trans('Yes')), $search_no_email); @@ -751,7 +755,7 @@ if (!empty($arrayfields['p.phone_perso']['checked'])) print_liste_field_ if (!empty($arrayfields['p.phone_mobile']['checked'])) print_liste_field_titre($arrayfields['p.phone_mobile']['label'], $_SERVER["PHP_SELF"], "p.phone_mobile", $begin, $param, '', $sortfield, $sortorder); if (!empty($arrayfields['p.fax']['checked'])) print_liste_field_titre($arrayfields['p.fax']['label'], $_SERVER["PHP_SELF"], "p.fax", $begin, $param, '', $sortfield, $sortorder); if (!empty($arrayfields['p.email']['checked'])) print_liste_field_titre($arrayfields['p.email']['label'], $_SERVER["PHP_SELF"], "p.email", $begin, $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['p.no_email']['checked'])) print_liste_field_titre($arrayfields['p.no_email']['label'], $_SERVER["PHP_SELF"], "p.no_email", $begin, $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['mu.rowid']['checked'])) print_liste_field_titre($arrayfields['mu.rowid']['label'], $_SERVER["PHP_SELF"], "mu.rowid", $begin, $param, '', $sortfield, $sortorder, 'center '); if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active'] && !empty($arrayfields['p.'.$key]['checked'])) { @@ -905,9 +909,9 @@ while ($i < min($num, $limit)) if (!$i) $totalarray['nbfield']++; } // No EMail - if (!empty($arrayfields['p.no_email']['checked'])) + if (!empty($arrayfields['mu.rowid']['checked'])) { - print ''.yn($obj->no_email).''; + print ''.yn(!is_null($obj->no_email) ? 1 : 0).''; if (!$i) $totalarray['nbfield']++; } if (!empty($conf->socialnetworks->enabled)) { diff --git a/htdocs/core/modules/mailings/contacts1.modules.php b/htdocs/core/modules/mailings/contacts1.modules.php index 9d7a23ce9fd..bc370f5552e 100644 --- a/htdocs/core/modules/mailings/contacts1.modules.php +++ b/htdocs/core/modules/mailings/contacts1.modules.php @@ -80,7 +80,7 @@ class mailing_contacts1 extends MailingTargets $statssql[0] .= " FROM ".MAIN_DB_PREFIX."socpeople as c"; $statssql[0] .= " WHERE c.entity IN (".getEntity('socpeople').")"; $statssql[0] .= " AND c.email != ''"; // Note that null != '' is false - $statssql[0] .= " AND c.no_email = 0"; + $statssql[0] .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = c.email) = 0"; $statssql[0] .= " AND c.statut = 1"; return $statssql; @@ -104,7 +104,6 @@ class mailing_contacts1 extends MailingTargets $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = c.fk_soc"; $sql .= " WHERE c.entity IN (".getEntity('socpeople').")"; $sql .= " AND c.email != ''"; // Note that null != '' is false - $sql .= " AND c.no_email = 0"; $sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = c.email) = 0"; // exclude unsubscribed users $sql .= " AND c.statut = 1"; @@ -132,9 +131,8 @@ class mailing_contacts1 extends MailingTargets $sql = "SELECT sp.poste, count(distinct(sp.email)) AS nb"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; $sql .= " WHERE sp.entity IN (".getEntity('socpeople').")"; - /*$sql.= " AND sp.email != ''"; // Note that null != '' is false - $sql.= " AND sp.no_email = 0"; - $sql.= " AND sp.statut = 1";*/ + $sql .= " AND sp.email != ''"; // Note that null != '' is false + $sql .= " AND sp.statut = 1"; $sql .= " AND (sp.poste IS NOT NULL AND sp.poste != '')"; $sql .= " GROUP BY sp.poste"; $sql .= " ORDER BY sp.poste"; @@ -166,10 +164,9 @@ class mailing_contacts1 extends MailingTargets $sql .= " ".MAIN_DB_PREFIX."socpeople as sp,"; $sql .= " ".MAIN_DB_PREFIX."categorie as c,"; $sql .= " ".MAIN_DB_PREFIX."categorie_contact as cs"; - $sql .= " WHERE sp.statut = 1"; // Note that null != '' is false - //$sql.= " AND sp.no_email = 0"; - //$sql.= " AND sp.email != ''"; - //$sql.= " AND sp.entity IN (".getEntity('socpeople').")"; + $sql .= " WHERE sp.entity IN (".getEntity('socpeople').")"; + $sql .= " AND sp.email != ''"; // Note that null != '' is false + $sql .= " AND sp.statut = 1"; $sql .= " AND cs.fk_categorie = c.rowid"; $sql .= " AND cs.fk_socpeople = sp.rowid"; $sql .= " GROUP BY c.label"; @@ -241,10 +238,9 @@ class mailing_contacts1 extends MailingTargets $sql .= " ".MAIN_DB_PREFIX."socpeople as sp,"; $sql .= " ".MAIN_DB_PREFIX."categorie as c,"; $sql .= " ".MAIN_DB_PREFIX."categorie_societe as cs"; - $sql .= " WHERE sp.statut = 1"; // Note that null != '' is false - //$sql.= " AND sp.no_email = 0"; - //$sql.= " AND sp.email != ''"; - //$sql.= " AND sp.entity IN (".getEntity('socpeople').")"; + $sql .= " WHERE sp.entity IN (".getEntity('socpeople').")"; + $sql .= " AND sp.email != ''"; // Note that null != '' is false + $sql .= " AND sp.statut = 1"; $sql .= " AND cs.fk_categorie = c.rowid"; $sql .= " AND cs.fk_soc = sp.fk_soc"; $sql .= " GROUP BY c.label"; @@ -283,10 +279,9 @@ class mailing_contacts1 extends MailingTargets $sql .= " ".MAIN_DB_PREFIX."socpeople as sp,"; $sql .= " ".MAIN_DB_PREFIX."categorie as c,"; $sql .= " ".MAIN_DB_PREFIX."categorie_fournisseur as cs"; - $sql .= " WHERE sp.statut = 1"; // Note that null != '' is false - //$sql.= " AND sp.no_email = 0"; - //$sql.= " AND sp.email != ''"; - //$sql.= " AND sp.entity IN (".getEntity('socpeople').")"; + $sql .= " WHERE sp.entity IN (".getEntity('socpeople').")"; + $sql .= " AND sp.email != ''"; // Note that null != '' is false + $sql .= " AND sp.statut = 1"; $sql .= " AND cs.fk_categorie = c.rowid"; $sql .= " AND cs.fk_soc = sp.fk_soc"; $sql .= " GROUP BY c.label"; @@ -385,7 +380,6 @@ class mailing_contacts1 extends MailingTargets if ($filter_category_supplier <> 'all') $sql .= ", ".MAIN_DB_PREFIX."categorie_fournisseur as c3s"; $sql .= " WHERE sp.entity IN (".getEntity('socpeople').")"; $sql .= " AND sp.email <> ''"; - $sql .= " AND sp.no_email = 0"; $sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = sp.email) = 0"; // Exclude unsubscribed email adresses $sql .= " AND sp.statut = 1"; diff --git a/htdocs/core/modules/mailings/modules_mailings.php b/htdocs/core/modules/mailings/modules_mailings.php index ffba2571d23..d4ccc3ddb38 100644 --- a/htdocs/core/modules/mailings/modules_mailings.php +++ b/htdocs/core/modules/mailings/modules_mailings.php @@ -209,24 +209,6 @@ class MailingTargets // This can't be abstract as it is used for some method dol_syslog(__METHOD__.": mailing ".$j." targets added"); - /* - //Update the status to show thirdparty mail that don't want to be contacted anymore' - $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; - $sql .= " SET statut=3"; - $sql .= " WHERE fk_mailing=".$mailing_id." AND email in (SELECT email FROM ".MAIN_DB_PREFIX."societe where fk_stcomm=-1)"; - $sql .= " AND source_type='thirdparty'"; - dol_syslog(__METHOD__.": mailing update status to display thirdparty mail that do not want to be contacted"); - $result=$this->db->query($sql); - - //Update the status to show contact mail that don't want to be contacted anymore' - $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; - $sql .= " SET statut=3"; - $sql .= " WHERE fk_mailing=".$mailing_id." AND source_type='contact' AND (email in (SELECT sc.email FROM ".MAIN_DB_PREFIX."socpeople AS sc "; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe s ON s.rowid=sc.fk_soc WHERE s.fk_stcomm=-1 OR no_email=1))"; - dol_syslog(__METHOD__.": mailing update status to display contact mail that do not want to be contacted",LOG_DEBUG); - $result=$this->db->query($sql); - */ - $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; $sql .= " SET statut=3"; $sql .= " WHERE fk_mailing=".$mailing_id." AND email IN (SELECT mu.email FROM ".MAIN_DB_PREFIX."mailing_unsubscribe AS mu WHERE mu.entity IN ('".getEntity('mailing')."'))"; diff --git a/htdocs/public/emailing/mailing-unsubscribe.php b/htdocs/public/emailing/mailing-unsubscribe.php index d26bae234db..7b0fbf0ef72 100644 --- a/htdocs/public/emailing/mailing-unsubscribe.php +++ b/htdocs/public/emailing/mailing-unsubscribe.php @@ -100,20 +100,6 @@ if (!empty($tag) && ($unsuscrib == '1')) $resql = $db->query($sql); if (!$resql) dol_print_error($db); - /* - // Update status communication of thirdparty prospect (old usage) - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=-1 WHERE rowid IN (SELECT source_id FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE tag = '".$db->escape($tag)."' AND source_type='thirdparty' AND source_id is not null)"; - - $resql=$db->query($sql); - if (! $resql) dol_print_error($db); - - // Update status communication of contact prospect (old usage) - $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET no_email=1 WHERE rowid IN (SELECT source_id FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE tag = '".$db->escape($tag)."' AND source_type='contact' AND source_id is not null)"; - - $resql=$db->query($sql); - if (! $resql) dol_print_error($db); - */ - // Update status communication of email (new usage) $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe (date_creat, entity, email) VALUES ('".$db->idate(dol_now())."', ".$db->escape($obj->entity).", '".$db->escape($obj->email)."')"; From 29950a6afa83f3df3330d8e29c137302e1481999 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 23 Oct 2021 22:27:29 +0200 Subject: [PATCH 06/28] Replace != by <> in SQL requests --- htdocs/core/modules/mailings/contacts1.modules.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/core/modules/mailings/contacts1.modules.php b/htdocs/core/modules/mailings/contacts1.modules.php index bc370f5552e..bd4300ea71d 100644 --- a/htdocs/core/modules/mailings/contacts1.modules.php +++ b/htdocs/core/modules/mailings/contacts1.modules.php @@ -79,7 +79,7 @@ class mailing_contacts1 extends MailingTargets $statssql[0] .= " count(distinct(c.email)) as nb"; $statssql[0] .= " FROM ".MAIN_DB_PREFIX."socpeople as c"; $statssql[0] .= " WHERE c.entity IN (".getEntity('socpeople').")"; - $statssql[0] .= " AND c.email != ''"; // Note that null != '' is false + $statssql[0] .= " AND c.email <> ''"; // Note that null != '' is false $statssql[0] .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = c.email) = 0"; $statssql[0] .= " AND c.statut = 1"; @@ -103,7 +103,7 @@ class mailing_contacts1 extends MailingTargets $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = c.fk_soc"; $sql .= " WHERE c.entity IN (".getEntity('socpeople').")"; - $sql .= " AND c.email != ''"; // Note that null != '' is false + $sql .= " AND c.email <> ''"; // Note that null != '' is false $sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = c.email) = 0"; // exclude unsubscribed users $sql .= " AND c.statut = 1"; @@ -131,9 +131,9 @@ class mailing_contacts1 extends MailingTargets $sql = "SELECT sp.poste, count(distinct(sp.email)) AS nb"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; $sql .= " WHERE sp.entity IN (".getEntity('socpeople').")"; - $sql .= " AND sp.email != ''"; // Note that null != '' is false + $sql .= " AND sp.email <> ''"; // Note that null != '' is false $sql .= " AND sp.statut = 1"; - $sql .= " AND (sp.poste IS NOT NULL AND sp.poste != '')"; + $sql .= " AND (sp.poste IS NOT NULL AND sp.poste <> '')"; $sql .= " GROUP BY sp.poste"; $sql .= " ORDER BY sp.poste"; $resql = $this->db->query($sql); @@ -165,7 +165,7 @@ class mailing_contacts1 extends MailingTargets $sql .= " ".MAIN_DB_PREFIX."categorie as c,"; $sql .= " ".MAIN_DB_PREFIX."categorie_contact as cs"; $sql .= " WHERE sp.entity IN (".getEntity('socpeople').")"; - $sql .= " AND sp.email != ''"; // Note that null != '' is false + $sql .= " AND sp.email <> ''"; // Note that null != '' is false $sql .= " AND sp.statut = 1"; $sql .= " AND cs.fk_categorie = c.rowid"; $sql .= " AND cs.fk_socpeople = sp.rowid"; @@ -239,7 +239,7 @@ class mailing_contacts1 extends MailingTargets $sql .= " ".MAIN_DB_PREFIX."categorie as c,"; $sql .= " ".MAIN_DB_PREFIX."categorie_societe as cs"; $sql .= " WHERE sp.entity IN (".getEntity('socpeople').")"; - $sql .= " AND sp.email != ''"; // Note that null != '' is false + $sql .= " AND sp.email <> ''"; // Note that null != '' is false $sql .= " AND sp.statut = 1"; $sql .= " AND cs.fk_categorie = c.rowid"; $sql .= " AND cs.fk_soc = sp.fk_soc"; @@ -280,7 +280,7 @@ class mailing_contacts1 extends MailingTargets $sql .= " ".MAIN_DB_PREFIX."categorie as c,"; $sql .= " ".MAIN_DB_PREFIX."categorie_fournisseur as cs"; $sql .= " WHERE sp.entity IN (".getEntity('socpeople').")"; - $sql .= " AND sp.email != ''"; // Note that null != '' is false + $sql .= " AND sp.email <> ''"; // Note that null != '' is false $sql .= " AND sp.statut = 1"; $sql .= " AND cs.fk_categorie = c.rowid"; $sql .= " AND cs.fk_soc = sp.fk_soc"; From 983e28691bbd2186dda67a6a325e2b49f2a5d52d Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 24 Oct 2021 00:02:55 +0200 Subject: [PATCH 07/28] Use a subselect instead of a join --- htdocs/contact/list.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 935e90e6085..64207863c79 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -175,7 +175,7 @@ $arrayfields = array( 'p.phone_mobile'=>array('label'=>"PhoneMobile", 'position'=>32, 'checked'=>1), 'p.fax'=>array('label'=>"Fax", 'position'=>33, 'checked'=>0), 'p.email'=>array('label'=>"EMail", 'position'=>40, 'checked'=>1), - 'mu.rowid'=>array('label'=>"No_Email", 'position'=>41, 'checked'=>0, 'enabled'=>(!empty($conf->mailing->enabled))), + 'unsubscribed'=>array('label'=>"No_Email", 'position'=>41, 'checked'=>0, 'enabled'=>(!empty($conf->mailing->enabled))), 'p.thirdparty'=>array('label'=>"ThirdParty", 'position'=>50, 'checked'=>1, 'enabled'=>empty($conf->global->SOCIETE_DISABLE_CONTACTS)), 'p.priv'=>array('label'=>"ContactVisibility", 'checked'=>1, 'position'=>200), 'p.datec'=>array('label'=>"DateCreationShort", 'checked'=>0, 'position'=>500), @@ -307,7 +307,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } if(!empty($conf->mailing->enabled)) { - $sql .= ", mu.rowid as no_email"; + $sql .= ", (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = p.email) as unsubscribed"; } // Add fields from hooks $parameters = array(); @@ -321,7 +321,6 @@ if (!empty($search_categ)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_conta if (!empty($search_categ_thirdparty)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; // We need this table joined to the select in order to filter by categ if (!empty($search_categ_supplier)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs2 ON s.rowid = cs2.fk_soc"; // We need this table joined to the select in order to filter by categ if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; -if(!empty($conf->mailing->enabled)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."mailing_unsubscribe as mu ON mu.email = p.email"; $sql .= ' WHERE p.entity IN ('.getEntity('socpeople').')'; if (!$user->rights->societe->client->voir && !$socid) //restriction { @@ -378,8 +377,8 @@ if (strlen($search_town)) $sql .= natural_search("p.town", $search_town); if (count($search_roles) > 0) { $sql .= " AND p.rowid IN (SELECT sc.fk_socpeople FROM ".MAIN_DB_PREFIX."societe_contacts as sc WHERE sc.fk_c_type_contact IN (".implode(',', $search_roles)."))"; } -if ($search_no_email != -1 && $search_no_email > 0) $sql .= " AND mu.rowid IS NOT NULL"; -if ($search_no_email != -1 && $search_no_email == 0) $sql .= " AND mu.rowid IS NULL"; +if ($search_no_email != -1 && $search_no_email > 0) $sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = p.email) > 0"; +if ($search_no_email != -1 && $search_no_email == 0) $sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = p.email) = 0"; if ($search_status != '' && $search_status >= 0) $sql .= " AND p.statut = ".$db->escape($search_status); if ($search_import_key) $sql .= natural_search("p.import_key", $search_import_key); if ($type == "o") // filtre sur type @@ -666,7 +665,7 @@ if (!empty($arrayfields['p.email']['checked'])) print ''; print ''; } -if (!empty($arrayfields['mu.rowid']['checked'])) +if (!empty($arrayfields['unsubscribed']['checked'])) { print ''; print $form->selectarray('search_no_email', array('-1'=>'', '0'=>$langs->trans('No'), '1'=>$langs->trans('Yes')), $search_no_email); @@ -755,7 +754,7 @@ if (!empty($arrayfields['p.phone_perso']['checked'])) print_liste_field_ if (!empty($arrayfields['p.phone_mobile']['checked'])) print_liste_field_titre($arrayfields['p.phone_mobile']['label'], $_SERVER["PHP_SELF"], "p.phone_mobile", $begin, $param, '', $sortfield, $sortorder); if (!empty($arrayfields['p.fax']['checked'])) print_liste_field_titre($arrayfields['p.fax']['label'], $_SERVER["PHP_SELF"], "p.fax", $begin, $param, '', $sortfield, $sortorder); if (!empty($arrayfields['p.email']['checked'])) print_liste_field_titre($arrayfields['p.email']['label'], $_SERVER["PHP_SELF"], "p.email", $begin, $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['mu.rowid']['checked'])) print_liste_field_titre($arrayfields['mu.rowid']['label'], $_SERVER["PHP_SELF"], "mu.rowid", $begin, $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['unsubscribed']['checked'])) print_liste_field_titre($arrayfields['unsubscribed']['label'], $_SERVER["PHP_SELF"], "unsubscribed", $begin, $param, '', $sortfield, $sortorder, 'center '); if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active'] && !empty($arrayfields['p.'.$key]['checked'])) { @@ -909,9 +908,9 @@ while ($i < min($num, $limit)) if (!$i) $totalarray['nbfield']++; } // No EMail - if (!empty($arrayfields['mu.rowid']['checked'])) + if (!empty($arrayfields['unsubscribed']['checked'])) { - print ''.yn(!is_null($obj->no_email) ? 1 : 0).''; + print ''.yn(($obj->unsubscribed > 0) ? 1 : 0).''; if (!$i) $totalarray['nbfield']++; } if (!empty($conf->socialnetworks->enabled)) { From c998abe54e36977b8144936c4587919eff2dab21 Mon Sep 17 00:00:00 2001 From: Administrator Date: Wed, 27 Oct 2021 11:09:00 +0200 Subject: [PATCH 08/28] FIX: resource list : Use standard code to handle list filters --- htdocs/resource/list.php | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index 033d49ae8c8..a4721b2d174 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -75,22 +75,16 @@ if ($search_type != '') { } // Add $param from extra fields -foreach ($search_array_options as $key => $val) -{ - $crit = $val; - $tmpkey = preg_replace('/search_options_/', '', $key); - $typ = $extrafields->attributes[$object->table_element]['type'][$tmpkey]; - if ($val != '') { - $param .= '&search_options_'.$tmpkey.'='.urlencode($val); - } - $mode_search = 0; - if (in_array($typ, array('int', 'double', 'real'))) $mode_search = 1; // Search on a numeric - if (in_array($typ, array('sellist', 'link')) && $crit != '0' && $crit != '-1') $mode_search = 2; // Search on a foreign key int - if ($crit != '' && (!in_array($typ, array('select', 'sellist')) || $crit != '0') && (!in_array($typ, array('link')) || $crit != '-1')) - { - $filter['ef.'.$tmpkey] = natural_search('ef.'.$tmpkey, $crit, $mode_search); - } -} +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; +$sql= null; +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; + +// Including the previous script generate the correct SQL filter for all the extrafields +// we are playing with the behaviour of the Dolresource::fetch_all() by generating a fake +// extrafields filter key to make it works +$filter['ef.resource'] = $sql; + + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); From eb8d7f92c3abb79c0bb394633fd7a8e8c8dbdf23 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Thu, 28 Oct 2021 15:26:40 +0200 Subject: [PATCH 09/28] FIX: invoice: inpossible to create an invoice because of very bad check + warnings when trying to print tabs for invoice with no ID --- htdocs/compta/facture/card.php | 18 +++++++++--------- htdocs/compta/facture/contact.php | 5 ++--- htdocs/compta/facture/document.php | 5 ++--- htdocs/compta/facture/info.php | 5 ++--- htdocs/compta/facture/note.php | 5 ++--- 5 files changed, 17 insertions(+), 21 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index c772fd0ad7b..f18bc9e6c00 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2756,15 +2756,6 @@ if (empty($reshook)) * View */ -if (empty($object->id)) { - llxHeader(); - $head = facture_prepare_head($object); - $langs->load('errors'); - echo dol_get_fiche_head($head, 'compta', $langs->trans("InvoiceCustomer"), -1, 'bill'), - '
' . $langs->trans("ErrorRecordNotFound") . '
'; - llxFooter(); - exit; -} $form = new Form($db); $formother = new FormOther($db); @@ -3679,6 +3670,15 @@ if ($action == 'create') } elseif ($id > 0 || !empty($ref)) { + if (empty($object->id)) { + llxHeader(); + $langs->load('errors'); + echo '
'.$langs->trans("ErrorRecordNotFound"); + echo ' '.$langs->trans('GoBack').'
'; + llxFooter(); + exit; + } + /* * Show object in view mode */ diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index 7177463c30e..8395409cbd6 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -120,10 +120,9 @@ elseif ($action == 'deletecontact' && $user->rights->facture->creer) if (empty($object->id)) { llxHeader(); - $head = facture_prepare_head($object); $langs->load('errors'); - echo dol_get_fiche_head($head, 'contact', $langs->trans("InvoiceCustomer"), -1, 'bill'), - '
' . $langs->trans("ErrorRecordNotFound") . '
'; + echo '
'; llxFooter(); exit; } diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index 0818b944705..e6cf3551738 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -87,10 +87,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; if (empty($object->id)) { llxHeader(); - $head = facture_prepare_head($object); $langs->load('errors'); - echo dol_get_fiche_head($head, 'documents', $langs->trans("InvoiceCustomer"), -1, 'bill'), - '
' . $langs->trans("ErrorRecordNotFound") . '
'; + echo '
'; llxFooter(); exit; } diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php index 955c41693c0..51b2ce8f4e3 100644 --- a/htdocs/compta/facture/info.php +++ b/htdocs/compta/facture/info.php @@ -45,10 +45,9 @@ $ref = GETPOST("ref", 'alpha'); if (empty($object->id)) { llxHeader(); - $head = facture_prepare_head($object); $langs->load('errors'); - echo dol_get_fiche_head($head, 'info', $langs->trans("InvoiceCustomer"), -1, 'bill'), - '
' . $langs->trans("ErrorRecordNotFound") . '
'; + echo '
'; llxFooter(); exit; } diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php index dadb61b551d..089d01b4a1f 100644 --- a/htdocs/compta/facture/note.php +++ b/htdocs/compta/facture/note.php @@ -66,10 +66,9 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, if (empty($object->id)) { llxHeader(); - $head = facture_prepare_head($object); $langs->load('errors'); - echo dol_get_fiche_head($head, 'note', $langs->trans("InvoiceCustomer"), -1, 'bill'), - '
' . $langs->trans("ErrorRecordNotFound") . '
'; + echo '
'; llxFooter(); exit; } From 1336d3e7910904a79d910671d3420c973d453266 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Fri, 29 Oct 2021 12:25:50 +0200 Subject: [PATCH 10/28] Fix: Import don't work if extrafield is separator --- htdocs/core/modules/modAdherent.class.php | 2 +- htdocs/core/modules/modProduct.class.php | 2 +- htdocs/core/modules/modProjet.class.php | 2 +- htdocs/core/modules/modResource.class.php | 2 +- htdocs/core/modules/modService.class.php | 2 +- htdocs/core/modules/modSociete.class.php | 4 ++-- htdocs/core/modules/modUser.class.php | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index 911a4bbd5b9..deaa1bd70b7 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -329,7 +329,7 @@ class modAdherent extends DolibarrModules 'a.datec'=>'DateCreation', 'a.datefin'=>'DateEndSubscription' ); // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'adherent' AND entity IN (0,".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'adherent' AND entity IN (0,".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index b029448cd58..a560bb3ee46 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -491,7 +491,7 @@ class modProduct extends DolibarrModules if (!empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit'; // Add extra fields $import_extrafield_sample = array(); - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0, ".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'product' AND entity IN (0, ".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index 77d339da035..7f71c30a6ac 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -293,7 +293,7 @@ class modProjet extends DolibarrModules $this->import_tables_array[$r] = array('t'=>MAIN_DB_PREFIX.'projet_task', 'extra'=>MAIN_DB_PREFIX.'projet_task_extrafields'); // List of tables to insert into (insert done in same order) $this->import_fields_array[$r] = array('t.fk_projet'=>'ProjectRef*', 't.ref'=>'RefTask*', 't.label'=>'LabelTask*', 't.dateo'=>"DateStart", 't.datee'=>"DateEnd", 't.planned_workload'=>"PlannedWorkload", 't.progress'=>"Progress", 't.note_private'=>"NotePrivate", 't.note_public'=>"NotePublic", 't.datec'=>"DateCreation"); // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'projet_task' AND entity IN (0,".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'projet_task' AND entity IN (0,".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { diff --git a/htdocs/core/modules/modResource.class.php b/htdocs/core/modules/modResource.class.php index 0d1353076ec..62c86e2e2a8 100644 --- a/htdocs/core/modules/modResource.class.php +++ b/htdocs/core/modules/modResource.class.php @@ -265,7 +265,7 @@ class modResource extends DolibarrModules $this->import_tables_array[$r] = array('r'=>MAIN_DB_PREFIX.'resource', 'extra'=>MAIN_DB_PREFIX.'resource_extrafields'); // List of tables to insert into (insert done in same order) $this->import_fields_array[$r] = array('r.ref'=>"ResourceFormLabel_ref*", 'r.fk_code_type_resource'=>'ResourceTypeCode', 'r.description'=>'ResourceFormLabel_description', 'r.note_private'=>"NotePrivate", 'r.note_public'=>"NotePublic", 'r.asset_number'=>'AssetNumber', 'r.datec'=>'DateCreation'); // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'resource' AND entity IN (0,".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'resource' AND entity IN (0,".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index b7933bcf3f4..dd8e211ce13 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -459,7 +459,7 @@ class modService extends DolibarrModules if (!empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit'; // Add extra fields $import_extrafield_sample = array(); - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0,".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'product' AND entity IN (0,".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index b0346054323..bd947b59fd7 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -453,7 +453,7 @@ class modSociete extends DolibarrModules ); if (!empty($conf->global->PRODUIT_MULTIPRICES)) $this->import_fields_array[$r]['s.price_level'] = 'PriceLevel'; // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe' AND entity IN (0, ".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'societe' AND entity IN (0, ".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { @@ -602,7 +602,7 @@ class modSociete extends DolibarrModules 's.note_public' => "NotePublic" ); // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople' AND entity IN (0, ".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'socpeople' AND entity IN (0, ".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on an old database (during a migration for example) { diff --git a/htdocs/core/modules/modUser.class.php b/htdocs/core/modules/modUser.class.php index e5ba3289d05..9859d0e4830 100644 --- a/htdocs/core/modules/modUser.class.php +++ b/htdocs/core/modules/modUser.class.php @@ -291,7 +291,7 @@ class modUser extends DolibarrModules 'u.statut'=>'Status' ); // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'user' AND entity IN (0,".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'user' AND entity IN (0,".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { From 54b81312b59b88e9d40497017f28eb93d667ff21 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 30 Oct 2021 22:49:32 +0200 Subject: [PATCH 11/28] FIX Ticket - Duplicate field project when we create ticket from project --- htdocs/core/class/html.formticket.class.php | 24 +++++++++++---------- htdocs/ticket/card.php | 19 ++++++++++------ 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 8dcd4965c65..e2f9ba48687 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -1,16 +1,17 @@ - * Copyright (C) 2016 Christophe Battarel - * Copyright (C) 2019 Frédéric France +/* Copyright (C) 2013-2015 Jean-François FERRY + * Copyright (C) 2016 Christophe Battarel + * Copyright (C) 2019 Frédéric France + * Copyright (C) 2021 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License @@ -351,12 +352,13 @@ class FormTicket } } - if (!empty($conf->projet->enabled) && !$this->ispublic) - { - $formproject = new FormProjets($this->db); - print ''; - print $formproject->select_projects(-1, GETPOST('projectid', 'int'), 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth500'); - print ''; + if($subelement != 'project') { + if (!empty($conf->projet->enabled) && !$this->ispublic) { + $formproject = new FormProjets($this->db); + print ''; + print $formproject->select_projects(-1, GETPOST('projectid', 'int'), 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth500'); + print ''; + } } // Attached files diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 08d9330a4c6..32d9cdfbb78 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -1,7 +1,8 @@ - * Copyright (C) 2016 Christophe Battarel - * Copyright (C) 2018 Laurent Destailleur +/* Copyright (C) 2013-2016 Jean-François FERRY + * Copyright (C) 2016 Christophe Battarel + * Copyright (C) 2018 Laurent Destailleur + * Copyright (C) 2021 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -192,9 +193,15 @@ if (empty($reshook)) { $result = $object->add_contact($contactid, GETPOST("type"), 'external'); } - // altairis: link ticket to project - if (GETPOST('projectid') > 0) { - $object->setProject(GETPOST('projectid')); + // Link ticket to project + if(GETPOST('origin', 'alpha') == 'projet') { + $projectid = GETPOST('originid', 'int'); + } else { + $projectid = GETPOST('projectid', 'int'); + } + + if ($projectid > 0) { + $object->setProject($projectid); } // Auto assign user From 0e2e8fe27fb453b34da4fe0fb22a744bddef6fc4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Oct 2021 14:01:40 +0100 Subject: [PATCH 12/28] Update contact.php --- htdocs/compta/facture/contact.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index 8395409cbd6..60fdeaf3e64 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -121,8 +121,7 @@ elseif ($action == 'deletecontact' && $user->rights->facture->creer) if (empty($object->id)) { llxHeader(); $langs->load('errors'); - echo ''; + echo '
'.$langs->trans("ErrorRecordNotFound").'
'; llxFooter(); exit; } From 65d59405da76a97d906fa49e54432d946ea71af6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Oct 2021 14:01:56 +0100 Subject: [PATCH 13/28] Update document.php --- htdocs/compta/facture/document.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index e6cf3551738..33e651d833d 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -88,8 +88,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; if (empty($object->id)) { llxHeader(); $langs->load('errors'); - echo '
'; + echo '
'.$langs->trans("ErrorRecordNotFound").'
'; llxFooter(); exit; } From 8dfe4fe05fb49e58309a3d02b92b0133a74c5b9d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Oct 2021 14:02:14 +0100 Subject: [PATCH 14/28] Update note.php --- htdocs/compta/facture/note.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php index 089d01b4a1f..8e2e8829d1a 100644 --- a/htdocs/compta/facture/note.php +++ b/htdocs/compta/facture/note.php @@ -67,8 +67,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, if (empty($object->id)) { llxHeader(); $langs->load('errors'); - echo '
'; + echo '
'.$langs->trans("ErrorRecordNotFound").'
'; llxFooter(); exit; } From 3dcd1aa05d4f8bdde463a110bd3a4bfa71ec27dd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Oct 2021 14:02:34 +0100 Subject: [PATCH 15/28] Update info.php --- htdocs/compta/facture/info.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php index 51b2ce8f4e3..820793c14d7 100644 --- a/htdocs/compta/facture/info.php +++ b/htdocs/compta/facture/info.php @@ -46,8 +46,7 @@ $ref = GETPOST("ref", 'alpha'); if (empty($object->id)) { llxHeader(); $langs->load('errors'); - echo '
'; + echo '
'.$langs->trans("ErrorRecordNotFound").'
'; llxFooter(); exit; } From dd8d4e9e983c5650f31db1386fdb698ee668f315 Mon Sep 17 00:00:00 2001 From: ATM john Date: Thu, 4 Nov 2021 12:10:19 +0100 Subject: [PATCH 16/28] Fix missing return status --- htdocs/core/db/DoliDB.class.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 8f2a9dc315e..af470ac62d6 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -308,7 +308,7 @@ abstract class DoliDB implements Database * Note : This method executes a given SQL query and retrieves the first row of results as an object. It should only be used with SELECT queries * Dont add LIMIT to your query, it will be added by this method * @param string $sql the sql query string - * @return bool| object + * @return bool|int|object false on failure, 0 on empty, object on success */ public function getRow($sql) { @@ -317,7 +317,13 @@ abstract class DoliDB implements Database $res = $this->query($sql); if ($res) { - return $this->fetch_object($res); + $obj = $this->fetch_object($res); + if(!$obj){ + return 0; + } + else{ + return $obj; + } } return false; From 3959d12a39bf5022c6436b493b6de4be77f754fb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 Nov 2021 12:42:42 +0100 Subject: [PATCH 17/28] Update DoliDB.class.php --- htdocs/core/db/DoliDB.class.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index af470ac62d6..68e29f22481 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -312,17 +312,15 @@ abstract class DoliDB implements Database */ public function getRow($sql) { - $sql .= ' LIMIT 1;'; + $sql .= ' LIMIT 1'; $res = $this->query($sql); - if ($res) - { + if ($res) { $obj = $this->fetch_object($res); - if(!$obj){ - return 0; - } - else{ + if ($obj) { return $obj; + } else { + return 0; } } From 19b9412c1357299940c14be206bf464fc774cd61 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 Nov 2021 12:49:33 +0100 Subject: [PATCH 18/28] FIX #19305 --- htdocs/core/modules/modPropale.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php index 007e92e4277..12835530bf9 100644 --- a/htdocs/core/modules/modPropale.class.php +++ b/htdocs/core/modules/modPropale.class.php @@ -156,7 +156,8 @@ class modPropale extends DolibarrModules $this->rights[$r][1] = 'Close commercial proposals'; // libelle de la permission $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut - $this->rights[$r][4] = 'cloturer'; + $this->rights[$r][4] = 'propal_advance'; + $this->rights[$r][5] = 'close'; $r++; $this->rights[$r][0] = 27; // id de la permission From 33e40c12c8e5552f568f8c70f620b53f2dfa168a Mon Sep 17 00:00:00 2001 From: lvessiller Date: Tue, 9 Nov 2021 14:12:28 +0100 Subject: [PATCH 19/28] FIX close cash with some terminals in TakePOS --- htdocs/takepos/index.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 344955a9167..f3b9991061e 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -732,6 +732,7 @@ $( document ).ready(function() { if ($conf->global->TAKEPOS_CONTROL_CASH_OPENING) { $sql = "SELECT rowid, status FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE"; $sql .= " entity = ".$conf->entity." AND "; + $sql .= " posnumber = ".$_SESSION["takeposterminal"]." AND "; $sql .= " date(date_creation) = CURDATE()"; $resql = $db->query($sql); if ($resql) { @@ -918,6 +919,7 @@ if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter") { $sql = "SELECT rowid, status, entity FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE"; $sql .= " entity = ".$conf->entity." AND "; +$sql .= " posnumber = ".$_SESSION["takeposterminal"]." AND "; $sql .= " date(date_creation) = CURDATE()"; $resql = $db->query($sql); if ($resql) From ba724204a430cc841a068b777ebf1d6e2ca727cc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Nov 2021 15:50:32 +0100 Subject: [PATCH 20/28] FIX Bad use of dol_concatdesc() --- htdocs/datapolicy/class/datapolicy.class.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/datapolicy/class/datapolicy.class.php b/htdocs/datapolicy/class/datapolicy.class.php index bf1033084d5..7383e059ae3 100644 --- a/htdocs/datapolicy/class/datapolicy.class.php +++ b/htdocs/datapolicy/class/datapolicy.class.php @@ -259,11 +259,11 @@ class DataPolicy { if ($sendtocc) { - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); } - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); - $actionmsg .= dol_concatdesc($actionmsg, $message); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); + $actionmsg = dol_concatdesc($actionmsg, $message); } // Send mail @@ -329,11 +329,11 @@ class DataPolicy $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto; if ($message) { if ($sendtocc) { - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); } - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); - $actionmsg .= dol_concatdesc($actionmsg, $message); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); + $actionmsg = dol_concatdesc($actionmsg, $message); } From e365a14b5a8d17b2d441279563a1139049bde5e3 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Mon, 15 Nov 2021 14:41:16 +0100 Subject: [PATCH 21/28] FIX filter on region in company list --- htdocs/societe/list.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 1df7c38d6c5..5299b4ece95 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -294,6 +294,7 @@ if (empty($reshook)) $search_town = ""; $search_zip = ""; $search_state = ""; + $search_region = ""; $search_country = ''; $search_email = ''; $search_phone = ''; @@ -421,7 +422,7 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_effectif as staff on (staff.id = s.fk_effectif)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as region on (region. code_region = state.fk_region)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as region on (region.code_region = state.fk_region)"; // We'll need this table joined to the select in order to filter by categ if (!empty($search_categ_cus)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ if (!empty($search_categ_sup)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs ON s.rowid = cs.fk_soc"; // We'll need this table joined to the select in order to filter by categ @@ -554,6 +555,7 @@ if ($search_fax != '') $param .= "&search_fax=".urlencode($search_fax); if ($search_email != '') $param .= "&search_email=".urlencode($search_email); if ($search_url != '') $param .= "&search_url=".urlencode($search_url); if ($search_state != '') $param .= "&search_state=".urlencode($search_state); +if ($search_region != '') $param .= "&search_region=".urlencode($search_region); if ($search_country != '') $param .= "&search_country=".urlencode($search_country); if ($search_customer_code != '') $param .= "&search_customer_code=".urlencode($search_customer_code); if ($search_supplier_code != '') $param .= "&search_supplier_code=".urlencode($search_supplier_code); From 7af883abc1641e65944009b5fc938233978aaaef Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Mon, 15 Nov 2021 16:43:54 +0100 Subject: [PATCH 22/28] Fix: Bad date conversion --- htdocs/fourn/class/fournisseur.commande.class.php | 12 ++++++------ htdocs/fourn/class/fournisseur.facture.class.php | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 08516fbc7d2..f31d5c174f1 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -10,7 +10,7 @@ * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018-2019 Frédéric France - * Copyright (C) 2018 Ferran Marcet + * Copyright (C) 2018-2021 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -2904,11 +2904,11 @@ class CommandeFournisseur extends CommonOrder if ($obj->fk_user_approve) $this->user_approve_id = $obj->fk_user_approve; if ($obj->fk_user_approve2) $this->user_approve_id2 = $obj->fk_user_approve2; - $this->date_creation = $this->db->idate($obj->datec); - $this->date_modification = $this->db->idate($obj->datem); - $this->date_approve = $this->db->idate($obj->datea); - $this->date_approve2 = $this->db->idate($obj->datea2); - $this->date_validation = $this->db->idate($obj->date_validation); + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); + $this->date_approve = $this->db->jdate($obj->datea); + $this->date_approve2 = $this->db->jdate($obj->datea2); + $this->date_validation = $this->db->jdate($obj->date_validation); } $this->db->free($result); } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 72d040583b2..599e923baa5 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -9,7 +9,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2016 Marcos García * Copyright (C) 2015 Bahfir Abbes - * Copyright (C) 2015-2019 Ferran Marcet + * Copyright (C) 2015-2021 Ferran Marcet * Copyright (C) 2016 Alexandre Spangaro * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018-2020 Frédéric France @@ -2144,8 +2144,8 @@ class FactureFournisseur extends CommonInvoice $muser->fetch($obj->fk_user_modif); $this->user_modification = $muser; } - $this->date_creation = $this->db->idate($obj->datec); - $this->date_modification = $this->db->idate($obj->datem); + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); //$this->date_validation = $obj->datev; // This field is not available. Should be store into log table and using this function should be replaced with showing content of log (like for supplier orders) } $this->db->free($result); From db975bbcc2847d0f7853fd5ee3af4722f1d14f87 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Thu, 18 Nov 2021 17:17:00 +0100 Subject: [PATCH 23/28] Fix: The error not correctly collected on insertation line failure --- htdocs/expedition/class/expedition.class.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index d14a34515c4..845aaa194fa 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -9,7 +9,7 @@ * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2014-2017 Francis Appels * Copyright (C) 2015 Claudio Aschieri - * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2016-2021 Ferran Marcet * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018 Frédéric France * Copyright (C) 2020 Lenin Rivas @@ -364,14 +364,14 @@ class Expedition extends CommonObject { if (!isset($this->lines[$i]->detail_batch)) { // no batch management - if (!$this->create_line($this->lines[$i]->entrepot_id, $this->lines[$i]->origin_line_id, $this->lines[$i]->qty, $this->lines[$i]->rang, $this->lines[$i]->array_options) > 0) + if ($this->create_line($this->lines[$i]->entrepot_id, $this->lines[$i]->origin_line_id, $this->lines[$i]->qty, $this->lines[$i]->rang, $this->lines[$i]->array_options) < 0) { $error++; } } else { // with batch management - if (!$this->create_line_batch($this->lines[$i], $this->lines[$i]->array_options) > 0) + if ($this->create_line_batch($this->lines[$i], $this->lines[$i]->array_options) < 0) { $error++; } @@ -423,7 +423,6 @@ class Expedition extends CommonObject else { $error++; - $this->error = $this->db->lasterror()." - sql=$sql"; $this->db->rollback(); return -3; } From 8f9638318647a690fc634ceb23c26ea74cf5d628 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 18 Nov 2021 20:10:04 +0100 Subject: [PATCH 24/28] Update expedition.class.php --- htdocs/expedition/class/expedition.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 845aaa194fa..bcccd2aee2a 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -364,14 +364,14 @@ class Expedition extends CommonObject { if (!isset($this->lines[$i]->detail_batch)) { // no batch management - if ($this->create_line($this->lines[$i]->entrepot_id, $this->lines[$i]->origin_line_id, $this->lines[$i]->qty, $this->lines[$i]->rang, $this->lines[$i]->array_options) < 0) + if ($this->create_line($this->lines[$i]->entrepot_id, $this->lines[$i]->origin_line_id, $this->lines[$i]->qty, $this->lines[$i]->rang, $this->lines[$i]->array_options) <= 0) { $error++; } } else { // with batch management - if ($this->create_line_batch($this->lines[$i], $this->lines[$i]->array_options) < 0) + if ($this->create_line_batch($this->lines[$i], $this->lines[$i]->array_options) <= 0) { $error++; } From 632147ad889c2ea7c73eec0c90e2cf8e781b2310 Mon Sep 17 00:00:00 2001 From: Quentin VIAL-GOUTEYRON Date: Wed, 24 Nov 2021 12:04:18 +0100 Subject: [PATCH 25/28] object->id is always empty --- htdocs/compta/facture/contact.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index 60fdeaf3e64..c340d68242e 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -118,14 +118,6 @@ elseif ($action == 'deletecontact' && $user->rights->facture->creer) * View */ -if (empty($object->id)) { - llxHeader(); - $langs->load('errors'); - echo '
'.$langs->trans("ErrorRecordNotFound").'
'; - llxFooter(); - exit; -} - $title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('ContactsAddresses'); $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $helpurl); From 9d2fb782fafb8207f56204f0dda5efbf3ead0ceb Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 25 Nov 2021 15:41:28 +0100 Subject: [PATCH 26/28] FIX Option MAIN_DIRECT_STATUS_UPDATE broken. Ajax on/off not saving value in DB after updating to version >=12 --- htdocs/core/ajax/objectonoff.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/ajax/objectonoff.php b/htdocs/core/ajax/objectonoff.php index f7bf1d6299c..20256da94d7 100644 --- a/htdocs/core/ajax/objectonoff.php +++ b/htdocs/core/ajax/objectonoff.php @@ -80,5 +80,9 @@ if (($action == 'set') && !empty($id)) { $format = 'int'; + $object->table_element = $tablename; + $object->id = $id; + $object->fields[$field] = array('type' => $format, 'enabled' => 1); + $object->setValueFrom($field, $value, $tablename, $id, $format, '', $user, $triggerkey); } From 1361abffe515722631dafbfba68ff0c20f553a10 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Fri, 26 Nov 2021 18:22:31 +0100 Subject: [PATCH 27/28] FIX: holiday list: only mass delete if leave request is not in draft, canceled or refused, like in card --- htdocs/core/actions_massactions.inc.php | 6 ++++++ htdocs/langs/en_US/holiday.lang | 1 + 2 files changed, 7 insertions(+) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index abcdd690d5c..0c84b2d3781 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1280,6 +1280,12 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == ' continue; } + if ($objectclass == 'Holiday' && ! in_array($objecttmp->statut, array(Holiday::STATUS_DRAFT, Holiday::STATUS_CANCELED, Holiday::STATUS_REFUSED))) { + $nbignored++; + setEventMessage($langs->trans('ErrorLeaveRequestMustBeDraftCanceledOrRefusedToBeDeleted', $objecttmp->ref)); + continue; + } + if ($objectclass == "Task" && $objecttmp->hasChildren() > 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET fk_task_parent = 0 WHERE fk_task_parent = ".$objecttmp->id; diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang index eb2cd89adf1..ef96e72cc9d 100644 --- a/htdocs/langs/en_US/holiday.lang +++ b/htdocs/langs/en_US/holiday.lang @@ -132,3 +132,4 @@ FreeLegalTextOnHolidays=Free text on PDF WatermarkOnDraftHolidayCards=Watermarks on draft leave requests HolidaysToApprove=Holidays to approve NobodyHasPermissionToValidateHolidays=Nobody has permission to validate holidays +ErrorLeaveRequestMustBeDraftCanceledOrRefusedToBeDeleted=Leave request %s must be draft, canceled or refused to be deleted From f5343c55c39791f4351afedc6669bf7483db6957 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Fri, 26 Nov 2021 18:23:31 +0100 Subject: [PATCH 28/28] FIX: holiday mass deletion: correct return of record deleted --- htdocs/core/actions_massactions.inc.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 0c84b2d3781..2ce94cad8ed 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1320,7 +1320,8 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == ' if (!$error) { if ($nbok > 1) setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs'); - else setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs'); + elseif ($nbok > 0) setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs'); + else setEventMessages($langs->trans("NoRecordDeleted"), null, 'mesgs'); $db->commit(); } else