From 2cc635fd096c93e06ea677608672748b27075904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 27 Feb 2021 08:00:02 +0100 Subject: [PATCH 1/7] FIX https://github.com/Dolibarr/dolibarr/issues/16465 --- htdocs/core/class/commonobject.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 730546e0e6b..605df1397b0 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2190,7 +2190,8 @@ abstract class CommonObject $this->updateline( $line->id, ($line->description ? $line->description : $line->desc), $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, false, - $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice + $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice, + $line->ref_supplier ); break; case 'invoice_supplier': From 8bfa7565bdd8c14f90881ed96cd89f1b7ebc1b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 27 Feb 2021 08:52:40 +0100 Subject: [PATCH 2/7] Update commonobject.class.php --- htdocs/core/class/commonobject.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 605df1397b0..e2005dad7d8 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2198,7 +2198,8 @@ abstract class CommonObject $this->updateline( $line->id, ($line->description ? $line->description : $line->desc), $line->subprice, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->qty, 0, 'HT', $line->info_bits, $line->product_type, $line->remise_percent, false, - $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice + $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice, + $line->ref_supplier ); break; default: From 4cf2d2317faa72b404c1165214f3fce3c9198ad4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Feb 2021 19:16:14 +0100 Subject: [PATCH 3/7] FIX Status in popup of member in widget --- htdocs/core/boxes/box_members.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php index 2d0ad45a266..8bc47731325 100644 --- a/htdocs/core/boxes/box_members.php +++ b/htdocs/core/boxes/box_members.php @@ -117,6 +117,10 @@ class box_members extends ModeleBoxes $memberstatic->morphy = $objp->morphy; $memberstatic->company = $objp->company; $memberstatic->statut = $objp->status; + $memberstatic->date_creation = $datec; + $memberstatic->date_modification = $datem; + $memberstatic->need_subscription = $objp->subscription; + $memberstatic->datefin = $this->db->jdate($objp->date_end_subscription); if (!empty($objp->fk_soc)) { $memberstatic->socid = $objp->fk_soc; From 753b1d1e116fee2794f1c5b855098d5b7a39c4a4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Feb 2021 19:43:56 +0100 Subject: [PATCH 4/7] FIX status on tooltip on widgets --- htdocs/core/boxes/box_factures.php | 8 +++++--- htdocs/core/boxes/box_factures_fourn.php | 10 +++++++--- htdocs/core/boxes/box_factures_fourn_imp.php | 11 +++++++---- htdocs/core/boxes/box_factures_imp.php | 8 +++++--- htdocs/core/boxes/box_ficheinter.php | 5 +++-- htdocs/core/boxes/box_propales.php | 8 +++++--- htdocs/core/boxes/box_supplier_orders.php | 5 +++-- .../boxes/box_supplier_orders_awaiting_reception.php | 7 +++---- htdocs/core/class/commonobject.class.php | 4 ++++ htdocs/core/lib/functions.lib.php | 6 +++--- htdocs/fourn/class/fournisseur.facture.class.php | 4 ++++ 11 files changed, 49 insertions(+), 27 deletions(-) diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php index 011342d8a30..12875bd914c 100644 --- a/htdocs/core/boxes/box_factures.php +++ b/htdocs/core/boxes/box_factures.php @@ -93,7 +93,7 @@ class box_factures extends ModeleBoxes $sql .= ", f.tva as total_tva"; $sql .= ", f.total_ttc"; $sql .= ", f.datef as df"; - $sql .= ", f.paye, f.fk_statut, f.datec, f.tms"; + $sql .= ", f.paye, f.fk_statut as status, f.datec, f.tms"; $sql .= ", f.date_lim_reglement as datelimite"; $sql .= ", s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_client, s.code_compta, s.client"; @@ -131,8 +131,10 @@ class box_factures extends ModeleBoxes $facturestatic->total_ht = $objp->total_ht; $facturestatic->total_tva = $objp->total_tva; $facturestatic->total_ttc = $objp->total_ttc; - $facturestatic->statut = $objp->fk_statut; + $facturestatic->statut = $objp->status; + $facturestatic->status = $objp->status; $facturestatic->date_lim_reglement = $this->db->jdate($objp->datelimite); + $facturestatic->alreadypaid = $objp->paye; $societestatic->id = $objp->socid; $societestatic->name = $objp->name; @@ -181,7 +183,7 @@ class box_factures extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="right" width="18"', - 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3), + 'text' => $facturestatic->LibStatut($objp->paye, $objp->status, 3, $objp->paye), ); $line++; diff --git a/htdocs/core/boxes/box_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php index 26f24d41ab3..ba8873280f8 100644 --- a/htdocs/core/boxes/box_factures_fourn.php +++ b/htdocs/core/boxes/box_factures_fourn.php @@ -86,6 +86,8 @@ class box_factures_fourn extends ModeleBoxes if ($user->rights->fournisseur->facture->lire) { + $langs->load("bills"); + $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur"; $sql .= ", s.logo, s.email, s.entity"; @@ -93,7 +95,7 @@ class box_factures_fourn extends ModeleBoxes $sql .= ", f.total_ht"; $sql .= ", f.total_tva"; $sql .= ", f.total_ttc"; - $sql .= ", f.paye, f.fk_statut"; + $sql .= ", f.paye, f.fk_statut as status"; $sql .= ', f.datef as df'; $sql .= ', f.datec as datec'; $sql .= ', f.date_lim_reglement as datelimite, f.tms, f.type'; @@ -118,6 +120,7 @@ class box_factures_fourn extends ModeleBoxes while ($line < $num) { $objp = $this->db->fetch_object($result); + $datelimite = $this->db->jdate($objp->datelimite); $date = $this->db->jdate($objp->df); $datem = $this->db->jdate($objp->tms); @@ -128,7 +131,8 @@ class box_factures_fourn extends ModeleBoxes $facturestatic->total_tva = $objp->total_tva; $facturestatic->total_ttc = $objp->total_ttc; $facturestatic->date_echeance = $datelimite; - $facturestatic->statut = $objp->fk_statut; + $facturestatic->statut = $objp->status; + $facturestatic->status = $objp->status; $facturestatic->ref_supplier = $objp->ref_supplier; $thirdpartystatic->id = $objp->socid; @@ -182,7 +186,7 @@ class box_factures_fourn extends ModeleBoxes $alreadypaid = $fac->getSommePaiement(); $this->info_box_contents[$line][] = array( 'td' => 'class="right" width="18"', - 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $alreadypaid, $objp->type), + 'text' => $facturestatic->LibStatut($objp->paye, $objp->status, 3, $alreadypaid, $objp->type), ); $line++; diff --git a/htdocs/core/boxes/box_factures_fourn_imp.php b/htdocs/core/boxes/box_factures_fourn_imp.php index 99848d916f4..585566b78e3 100644 --- a/htdocs/core/boxes/box_factures_fourn_imp.php +++ b/htdocs/core/boxes/box_factures_fourn_imp.php @@ -82,6 +82,8 @@ class box_factures_fourn_imp extends ModeleBoxes if ($user->rights->fournisseur->facture->lire) { + $langs->load("bills"); + $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur"; $sql .= ", s.logo, s.email, s.entity"; @@ -90,13 +92,13 @@ class box_factures_fourn_imp extends ModeleBoxes $sql .= ", f.total_ht as total_ht"; $sql .= ", f.tva as total_tva"; $sql .= ", f.total_ttc"; - $sql .= ", f.paye, f.fk_statut, f.type"; + $sql .= ", f.paye, f.fk_statut as status, f.type"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ",".MAIN_DB_PREFIX."facture_fourn as f"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= " AND f.entity = ".$conf->entity; - $sql .= " AND f.paye=0"; + $sql .= " AND f.paye = 0"; $sql .= " AND fk_statut = 1"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; @@ -126,7 +128,8 @@ class box_factures_fourn_imp extends ModeleBoxes $facturestatic->total_tva = $objp->total_tva; $facturestatic->total_ttc = $objp->total_ttc; $facturestatic->date_echeance = $datelimite; - $facturestatic->statut = $objp->fk_statut; + $facturestatic->statut = $objp->status; + $facturestatic->status = $objp->status; $thirdpartystatic->id = $objp->socid; $thirdpartystatic->name = $objp->name; @@ -173,7 +176,7 @@ class box_factures_fourn_imp extends ModeleBoxes $alreadypaid = $fac->getSommePaiement(); $this->info_box_contents[$line][] = array( 'td' => 'class="right" width="18"', - 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $alreadypaid, $objp->type), + 'text' => $facturestatic->LibStatut($objp->paye, $objp->status, 3, $alreadypaid, $objp->type), ); $line++; diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index b47f948f4ca..0b93ea3267c 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -98,7 +98,7 @@ class box_factures_imp extends ModeleBoxes $sql .= ", f.total as total_ht"; $sql .= ", f.tva as total_tva"; $sql .= ", f.total_ttc"; - $sql .= ", f.paye, f.fk_statut, f.rowid as facid"; + $sql .= ", f.paye, f.fk_statut as status, f.rowid as facid"; $sql .= ", sum(pf.amount) as am"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -136,8 +136,10 @@ class box_factures_imp extends ModeleBoxes $facturestatic->total_ht = $objp->total_ht; $facturestatic->total_tva = $objp->total_tva; $facturestatic->total_ttc = $objp->total_ttc; - $facturestatic->statut = $objp->fk_statut; + $facturestatic->statut = $objp->status; + $facturestatic->status = $objp->status; $facturestatic->date_lim_reglement = $this->db->jdate($objp->datelimite); + $facturestatic->alreadypaid = $objp->paye; $societestatic->id = $objp->socid; $societestatic->name = $objp->name; @@ -186,7 +188,7 @@ class box_factures_imp extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="right" width="18"', - 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $objp->am), + 'text' => $facturestatic->LibStatut($objp->paye, $objp->status, 3, $objp->am), ); $line++; diff --git a/htdocs/core/boxes/box_ficheinter.php b/htdocs/core/boxes/box_ficheinter.php index 6cc213f98cb..186d57b831a 100644 --- a/htdocs/core/boxes/box_ficheinter.php +++ b/htdocs/core/boxes/box_ficheinter.php @@ -82,7 +82,7 @@ class box_ficheinter extends ModeleBoxes if (!empty($user->rights->ficheinter->lire)) { - $sql = "SELECT f.rowid, f.ref, f.fk_soc, f.fk_statut"; + $sql = "SELECT f.rowid, f.ref, f.fk_soc, f.fk_statut as status"; $sql .= ", f.datec"; $sql .= ", f.date_valid as datev"; $sql .= ", f.tms as datem"; @@ -113,7 +113,8 @@ class box_ficheinter extends ModeleBoxes $objp = $this->db->fetch_object($resql); $datec = $this->db->jdate($objp->datec); - $ficheinterstatic->statut = $objp->fk_statut; + $ficheinterstatic->statut = $objp->status; + $ficheinterstatic->status = $objp->status; $ficheinterstatic->id = $objp->rowid; $ficheinterstatic->ref = $objp->ref; diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index f98e0f1e347..a8b7c0190dd 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -88,7 +88,7 @@ class box_propales extends ModeleBoxes $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_client, s.code_compta, s.client"; $sql .= ", s.logo, s.email, s.entity"; - $sql .= ", p.rowid, p.ref, p.fk_statut, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.tva as total_tva, p.total as total_ttc, p.tms"; + $sql .= ", p.rowid, p.ref, p.fk_statut as status, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.tva as total_tva, p.total as total_ttc, p.tms"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."propal as p"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -121,6 +121,8 @@ class box_propales extends ModeleBoxes $propalstatic->total_ht = $objp->total_ht; $propalstatic->total_tva = $objp->total_tva; $propalstatic->total_ttc = $objp->total_ttc; + $propalstatic->statut = $objp->status; + $propalstatic->status = $objp->status; $societestatic->id = $objp->socid; $societestatic->name = $objp->name; @@ -133,7 +135,7 @@ class box_propales extends ModeleBoxes $societestatic->entity = $objp->entity; $late = ''; - if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->propal->cloture->warning_delay)) { + if ($objp->status == 1 && $dateterm < ($now - $conf->propal->cloture->warning_delay)) { $late = img_warning($langs->trans("Late")); } @@ -162,7 +164,7 @@ class box_propales extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="right" width="18"', - 'text' => $propalstatic->LibStatut($objp->fk_statut, 3), + 'text' => $propalstatic->LibStatut($objp->status, 3), ); $line++; diff --git a/htdocs/core/boxes/box_supplier_orders.php b/htdocs/core/boxes/box_supplier_orders.php index 151c1df6bcb..dd555edaa96 100644 --- a/htdocs/core/boxes/box_supplier_orders.php +++ b/htdocs/core/boxes/box_supplier_orders.php @@ -90,7 +90,7 @@ class box_supplier_orders extends ModeleBoxes $sql .= ", c.total_ht"; $sql .= ", c.tva as total_tva"; $sql .= ", c.total_ttc"; - $sql .= ", c.fk_statut"; + $sql .= ", c.fk_statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -115,6 +115,7 @@ class box_supplier_orders extends ModeleBoxes $supplierorderstatic->id = $objp->rowid; $supplierorderstatic->ref = $objp->ref; + $supplierorderstatic->statut = $objp->status; $thirdpartystatic->id = $objp->socid; $thirdpartystatic->name = $objp->name; @@ -150,7 +151,7 @@ class box_supplier_orders extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="right" width="18"', - 'text' => $supplierorderstatic->LibStatut($objp->fk_statut, 3), + 'text' => $supplierorderstatic->LibStatut($objp->status, 3), ); $line++; diff --git a/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php b/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php index 80fdbc2f4a2..7744a96530f 100644 --- a/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php +++ b/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php @@ -90,7 +90,7 @@ class box_supplier_orders_awaiting_reception extends ModeleBoxes $sql .= ", c.total_ht"; $sql .= ", c.tva as total_tva"; $sql .= ", c.total_ttc"; - $sql .= ", c.fk_statut"; + $sql .= ", c.fk_statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -115,11 +115,10 @@ class box_supplier_orders_awaiting_reception extends ModeleBoxes $delivery_date = $this->db->jdate($objp->delivery_date); $datem = $this->db->jdate($objp->tms); - $supplierorderstatic->delivery_date = $delivery_date; - $supplierorderstatic->statut = $objp->fk_statut; - $supplierorderstatic->id = $objp->rowid; $supplierorderstatic->ref = $objp->ref; + $supplierorderstatic->delivery_date = $delivery_date; + $supplierorderstatic->statut = $objp->status; $thirdpartystatic->id = $objp->socid; $thirdpartystatic->name = $objp->name; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 0b4565ab08f..013e4670775 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -485,6 +485,10 @@ abstract class CommonObject */ public $sendtoid; + /** + * @var float Amount already paid (used to show correct status) + */ + public $alreadypaid; /** * @var array List of child tables. To test if we can delete object. diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e2889c4d6d3..21457b37848 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3272,7 +3272,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'help', 'holiday', 'intervention', 'label', 'language', 'link', 'list', 'listlight', 'lot', 'map-marker-alt', 'member', 'money-bill-alt', 'mrp', 'note', 'next', - 'object_accounting', 'object_account', 'object_accountline', 'object_action', 'object_barcode', 'object_bill', 'object_billa', 'object_billd', 'object_bom', + 'object_accounting', 'object_account', 'object_accountline', 'object_action', 'object_barcode', 'object_bill', 'object_billa', 'object_billr', 'object_billd', 'object_bom', 'object_category', 'object_conversation', 'object_bookmark', 'object_bug', 'object_clock', 'object_dolly', 'object_dollyrevert', 'object_generic', 'object_folder', 'object_list-alt', 'object_calendar', 'object_calendarweek', 'object_calendarmonth', 'object_calendarday', 'object_calendarperuser', 'object_cash-register', 'object_company', 'object_contact', 'object_contract', 'object_donation', 'object_dynamicprice', @@ -3312,7 +3312,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ $arrayconvpictotofa = array( 'account'=>'university', 'accountline'=>'receipt', 'accountancy'=>'money-check-alt', 'action'=>'calendar-alt', 'add'=>'plus-circle', 'address'=> 'address-book', - 'bank_account'=>'university', 'bill'=>'file-invoice-dollar', 'billa'=>'file-excel', 'supplier_invoicea'=>'file-excel', 'billd'=>'file-medical', 'supplier_invoiced'=>'file-medical', 'bom'=>'cubes', + 'bank_account'=>'university', 'bill'=>'file-invoice-dollar', 'billa'=>'file-excel', 'billr'=>'file-invoice-dollar', 'supplier_invoicea'=>'file-excel', 'billd'=>'file-medical', 'supplier_invoiced'=>'file-medical', 'bom'=>'cubes', 'company'=>'building', 'contact'=>'address-book', 'contract'=>'suitcase', 'conversation'=>'comments', 'donation'=>'file-alt', 'dynamicprice'=>'hand-holding-usd', 'setup'=>'cog', 'companies'=>'building', 'products'=>'cube', 'commercial'=>'suitcase', 'invoicing'=>'coins', 'accounting'=>'chart-line', 'category'=>'tag', 'dollyrevert'=>'dolly', @@ -3381,7 +3381,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ $arrayconvpictotomorcess = array( 'action'=>'infobox-action', 'account'=>'infobox-bank_account', 'accountline'=>'infobox-bank_account', 'accountancy'=>'infobox-bank_account', 'bank_account'=>'bg-infobox-bank_account', - 'bill'=>'infobox-commande', 'billa'=>'infobox-commande', 'billd'=>'infobox-commande', + 'bill'=>'infobox-commande', 'billa'=>'infobox-commande', 'billr'=>'infobox-commande', 'billd'=>'infobox-commande', 'cash-register'=>'infobox-bank_account', 'contract'=>'infobox-contrat', 'check'=>'font-status4', 'conversation'=>'infobox-contrat', 'donation'=>'infobox-commande', 'dollyrevert'=>'flip', 'ecm'=>'infobox-action', 'hrm'=>'infobox-adherent', 'group'=>'infobox-adherent', 'intervention'=>'infobox-contrat', diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 74be7bcf762..d8d9aa7a4a3 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2299,6 +2299,10 @@ class FactureFournisseur extends CommonInvoice if ($this->type == self::TYPE_REPLACEMENT) $label = ''.$langs->transnoentitiesnoconv("InvoiceReplace").''; elseif ($this->type == self::TYPE_CREDIT_NOTE) $label = ''.$langs->transnoentitiesnoconv("CreditNote").''; elseif ($this->type == self::TYPE_DEPOSIT) $label = ''.$langs->transnoentitiesnoconv("Deposit").''; + if (isset($this->status)) { + $alreadypaid = -1; + $label .= ' '.$this->getLibStatut(5, $alreadypaid); + } if (!empty($this->ref)) $label .= '
'.$langs->trans('Ref').': '.$this->ref; if (!empty($this->ref_supplier)) From 3a19cbb062550b3edf054ab655c36071da7848c0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 28 Feb 2021 12:47:24 +0100 Subject: [PATCH 5/7] FIX #16420 #16423 #16488 #16477 --- htdocs/admin/mails_templates.php | 2 + htdocs/core/class/html.formmail.class.php | 137 +++++++++++++--------- 2 files changed, 86 insertions(+), 53 deletions(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 6538d5c3011..615dd7041e3 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -840,6 +840,7 @@ if ($resql) print "\n"; } else { + // If template is for a module, check module is enabled. if ($obj->module) { $tempmodulekey = $obj->module; if (empty($conf->$tempmodulekey) || empty($conf->$tempmodulekey->enabled)) { @@ -847,6 +848,7 @@ if ($resql) continue; } } + $keyforobj = 'type_template'; if (!in_array($obj->$keyforobj, array_keys($elementList))) { diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 46fcd5e331b..14e0d9c02d1 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -329,9 +329,8 @@ class FormMail extends Form // Load translation files required by the page $langs->loadLangs(array('other', 'mails')); - // Clear temp files. Must be done at beginning, before call of triggers - if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1')) - { + // Clear temp files. Must be done before call of triggers, at beginning (mode = init), or when we select a new template + if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelselected') && GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1')) { $this->clear_attached_files(); } @@ -1201,6 +1200,8 @@ class FormMail extends Form */ public function getEMailTemplate($db, $type_template, $user, $outputlangs, $id = 0, $active = 1, $label = '') { + global $conf; + $ret = new ModelMail(); if ($id == -2 && empty($label)) { @@ -1214,7 +1215,7 @@ class FormMail extends Form $languagetosearchmain = $tmparray[0].'_'.strtoupper($tmparray[0]); if ($languagetosearchmain == $languagetosearch) $languagetosearchmain = ''; - $sql = "SELECT rowid, label, topic, joinfiles, content, content_lines, lang"; + $sql = "SELECT rowid, module, label, type_template, topic, joinfiles, content, content_lines, lang"; $sql .= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; $sql .= " WHERE (type_template='".$db->escape($type_template)."' OR type_template='all')"; $sql .= " AND entity IN (".getEntity('c_email_templates').")"; @@ -1226,72 +1227,92 @@ class FormMail extends Form if ($id == -1) $sql .= " AND position=0"; if ($languagetosearch) $sql .= $db->order("position,lang,label", "ASC,DESC,ASC"); // We want line with lang set first, then with lang null or '' else $sql .= $db->order("position,lang,label", "ASC,ASC,ASC"); // If no language provided, we give priority to lang not defined - $sql .= $db->plimit(1); + //$sql .= $db->plimit(1); //print $sql; $resql = $db->query($sql); - if ($resql) + if (!$resql) { - // Get first found + dol_print_error($db); + return -1; + } + + // Get first found + while (1) { $obj = $db->fetch_object($resql); if ($obj) { + // If template is for a module, check module is enabled; if not, take next template + if ($obj->module) { + $tempmodulekey = $obj->module; + if (empty($conf->$tempmodulekey) || empty($conf->$tempmodulekey->enabled)) { + continue; + } + } + + // If a record was found $ret->id = $obj->rowid; + $ret->module = $obj->module; $ret->label = $obj->label; $ret->lang = $obj->lang; $ret->topic = $obj->topic; $ret->content = $obj->content; $ret->content_lines = $obj->content_lines; $ret->joinfiles = $obj->joinfiles; - } elseif ($id == -2) { - // Not found with the provided label - return -1; - } else { // If there is no template at all - $defaultmessage = ''; - if ($type_template == 'body') { - // Special case to use this->withbody as content - $defaultmessage = $this->withbody; - } elseif ($type_template == 'facture_send') { - $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendInvoice"); - } elseif ($type_template == 'facture_relance') { - $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendInvoiceReminder"); - } elseif ($type_template == 'propal_send') { - $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendProposal"); - } elseif ($type_template == 'supplier_proposal_send') { - $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendSupplierProposal"); - } elseif ($type_template == 'order_send') { - $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendOrder"); - } elseif ($type_template == 'order_supplier_send') { - $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendSupplierOrder"); - } elseif ($type_template == 'invoice_supplier_send') { - $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendSupplierInvoice"); - } elseif ($type_template == 'shipping_send') { - $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendShipping"); - } elseif ($type_template == 'fichinter_send') { - $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendFichInter"); - } elseif ($type_template == 'actioncomm_send') { - $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendActionComm"); - } elseif ($type_template == 'thirdparty') { - $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentThirdparty"); - } elseif (!empty($type_template)) { - $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentGeneric"); + break; + } else { + // If no record found + if ($id == -2) { + // Not found with the provided label + return -1; + } else { + // If there is no template at all + $defaultmessage = ''; + + if ($type_template == 'body') { + // Special case to use this->withbody as content + $defaultmessage = $this->withbody; + } elseif ($type_template == 'facture_send') { + $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendInvoice"); + } elseif ($type_template == 'facture_relance') { + $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendInvoiceReminder"); + } elseif ($type_template == 'propal_send') { + $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendProposal"); + } elseif ($type_template == 'supplier_proposal_send') { + $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendSupplierProposal"); + } elseif ($type_template == 'order_send') { + $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendOrder"); + } elseif ($type_template == 'order_supplier_send') { + $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendSupplierOrder"); + } elseif ($type_template == 'invoice_supplier_send') { + $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendSupplierInvoice"); + } elseif ($type_template == 'shipping_send') { + $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendShipping"); + } elseif ($type_template == 'fichinter_send') { + $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendFichInter"); + } elseif ($type_template == 'actioncomm_send') { + $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendActionComm"); + } elseif ($type_template == 'thirdparty') { + $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentThirdparty"); + } elseif (!empty($type_template)) { + $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentGeneric"); + } + + $ret->label = 'default'; + $ret->lang = $outputlangs->defaultlang; + $ret->topic = ''; + $ret->joinfiles = 1; + $ret->content = $defaultmessage; + $ret->content_lines = ''; + + break; } - - $ret->label = 'default'; - $ret->lang = $outputlangs->defaultlang; - $ret->topic = ''; - $ret->joinfiles = 1; - $ret->content = $defaultmessage; - $ret->content_lines = ''; } - - $db->free($resql); - return $ret; - } else { - dol_print_error($db); - return -1; } + + $db->free($resql); + return $ret; } /** @@ -1338,7 +1359,9 @@ class FormMail extends Form */ public function fetchAllEMailTemplate($type_template, $user, $outputlangs, $active = 1) { - $sql = "SELECT rowid, label, topic, content, content_lines, lang, fk_user, private, position"; + global $conf; + + $sql = "SELECT rowid, module, label, topic, content, content_lines, lang, fk_user, private, position"; $sql .= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; $sql .= " WHERE type_template IN ('".$this->db->escape($type_template)."', 'all')"; $sql .= " AND entity IN (".getEntity('c_email_templates').")"; @@ -1355,6 +1378,14 @@ class FormMail extends Form $this->lines_model = array(); while ($obj = $this->db->fetch_object($resql)) { + // If template is for a module, check module is enabled. + if ($obj->module) { + $tempmodulekey = $obj->module; + if (empty($conf->$tempmodulekey) || empty($conf->$tempmodulekey->enabled)) { + continue; + } + } + $line = new ModelMail(); $line->id = $obj->rowid; $line->label = $obj->label; From 2ce76133f4e6611ed36013b975b72ce4398b2e07 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 28 Feb 2021 12:59:58 +0100 Subject: [PATCH 6/7] FIX #16487 --- htdocs/comm/propal/card.php | 2 +- htdocs/commande/card.php | 2 +- htdocs/compta/facture/card.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index a018438bc48..3d06d3cc0e0 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -784,7 +784,7 @@ if (empty($reshook)) } } } - } elseif ($action == 'addline' && GETPOST('submitforalllines', 'aZ09') && GETPOST('vatforalllines', 'alpha')) { + } elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('vatforalllines', 'alpha') !== '') { // Define vat_rate $vat_rate = (GETPOST('vatforalllines') ? GETPOST('vatforalllines') : 0); $vat_rate = str_replace('*', '', $vat_rate); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index d50cbbeeb25..3a519e9801a 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -615,7 +615,7 @@ if (empty($reshook)) $result = $object->set_remise($user, GETPOST('remise_percent')); } elseif ($action == 'setremiseabsolue' && $usercancreate) { $result = $object->set_remise_absolue($user, GETPOST('remise_absolue')); - } elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('vatforalllines', 'alpha')) { + } elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('vatforalllines', 'alpha') !== '') { // Define vat_rate $vat_rate = (GETPOST('vatforalllines') ? GETPOST('vatforalllines') : 0); $vat_rate = str_replace('*', '', $vat_rate); diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index c871304905f..77c64f26b72 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1878,7 +1878,7 @@ if (empty($reshook)) $_GET["originid"] = $_POST["originid"]; setEventMessages($object->error, $object->errors, 'errors'); } - } elseif ($action == 'addline' && GETPOST('submitforalllines', 'aZ09') && GETPOST('vatforalllines', 'alpha')) { + } elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('vatforalllines', 'alpha') !== '') { // Define vat_rate $vat_rate = (GETPOST('vatforalllines') ? GETPOST('vatforalllines') : 0); $vat_rate = str_replace('*', '', $vat_rate); From 1149de1aca062a7ffd90600d7e6b5b2540ac1970 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 28 Feb 2021 13:15:24 +0100 Subject: [PATCH 7/7] FIX #16485 --- htdocs/core/tpl/objectline_title.tpl.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/htdocs/core/tpl/objectline_title.tpl.php b/htdocs/core/tpl/objectline_title.tpl.php index 8a7c38f8ada..096c52500da 100644 --- a/htdocs/core/tpl/objectline_title.tpl.php +++ b/htdocs/core/tpl/objectline_title.tpl.php @@ -69,13 +69,15 @@ if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) || !empty($conf->global->FA if (in_array($object->element, array('propal', 'commande', 'facture')) && $object->status == $object::STATUS_DRAFT) { global $mysoc; - print img_edit($langs->trans("UpdateForAllLines"), 0, 'class="clickvatforalllines opacitymedium paddingleft cursorpointer"'); - print ''; - print ''; + + print 'id.'">'.img_edit($langs->trans("UpdateForAllLines"), 0, 'class="clickvatforalllines opacitymedium paddingleft cursorpointer"').''; + //print ''; + if (GETPOST('mode', 'aZ09') == 'vatforalllines') { + print '
'; + print $form->load_tva('vatforalllines', '', $mysoc, $object->thirdparty, 0, 0, '', false, 1); + print ''; + print '
'; + } } print '';