From 43ce1543d8f482d9cf4125e9bbbe915b201eade8 Mon Sep 17 00:00:00 2001 From: TuxGasy Date: Wed, 16 Oct 2019 17:37:20 +0200 Subject: [PATCH 01/58] Fix width unit label in product import --- htdocs/core/modules/modProduct.class.php | 2 +- htdocs/core/modules/modService.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 2b41a76ea45..f3b3cde38e5 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -383,7 +383,7 @@ class modProduct extends DolibarrModules 'p.length' => "Length", 'p.length_units' => "LengthUnit", 'p.width' => "Width", - 'p.width_units' => "VolumeUnits", + 'p.width_units' => "WidthUnits", 'p.height' => "Height", 'p.height_units' => "HeightUnit", 'p.surface' => "Surface", diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index 2f3e62903a4..20db49d5e69 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -360,7 +360,7 @@ class modService extends DolibarrModules 'p.length' => "Length", 'p.length_units' => "LengthUnit", 'p.width' => "Width", - 'p.width_units' => "VolumeUnits", + 'p.width_units' => "WidthUnits", 'p.height' => "Height", 'p.height_units' => "HeightUnit", 'p.surface' => "Surface", From 8a7a0b80e2728d910fcf8cdffce1742cf89af5e6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Oct 2019 19:08:31 +0200 Subject: [PATCH 02/58] Fix remove warnings --- htdocs/core/class/conf.class.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index e3b6ac4e524..c595dd17938 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -226,10 +226,7 @@ class Conf $filesList = explode(":", $this->global->LOCAL_CONSTS_FILES); foreach ($filesList as $file) { $file=dol_sanitizeFileName($file); - include_once DOL_DOCUMENT_ROOT . "/".$file."/".$file."_consts.php"; - foreach ($file2bddconsts as $key=>$value) { - $this->global->$key=$value; - } + include_once DOL_DOCUMENT_ROOT . "/".$file."/".$file."_consts.php"; // This file can run code like setting $this->global->XXX vars. } } From 084ab53b4b87e918e591df998f93d952959633ba Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Oct 2019 12:14:38 +0200 Subject: [PATCH 03/58] Fix translation --- htdocs/core/class/discount.class.php | 27 ++++++++++++++++----------- htdocs/langs/en_US/bills.lang | 3 ++- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index bf00f5bc91a..df25a619e9e 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -91,13 +91,15 @@ class DiscountAbsolute public $fk_facture; /** - * @var int ID credit note having caused the discount + * @var int ID credit note or deposit used to create the discount */ public $fk_facture_source; + public $ref_facture_source; // Ref credit note or deposit used to create the discount + public $type_facture_source; - public $ref_facture_source; // Ref credit note having caused the discount - - public $ref_invoice_supplier_source; + public $fk_invoice_supplier_source; + public $ref_invoice_supplier_source; // Ref credit note or deposit used to create the discount + public $type_invoice_supplier_source; /** * Constructor @@ -135,11 +137,12 @@ class DiscountAbsolute $sql.= " sr.multicurrency_amount_ht, sr.multicurrency_amount_tva, sr.multicurrency_amount_ttc,"; $sql.= " sr.fk_facture_line, sr.fk_facture, sr.fk_facture_source, sr.fk_invoice_supplier_line, sr.fk_invoice_supplier, sr.fk_invoice_supplier_source, sr.description,"; $sql.= " sr.datec,"; - $sql.= " f.ref as ref_facture_source, fsup.ref as ref_invoice_supplier_source"; + $sql.= " f.ref as ref_facture_source, f.type as type_facture_source,"; + $sql.= " fsup.ref as ref_invoice_supplier_source, fsup.type as type_invoice_supplier_source"; $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as sr"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON sr.fk_facture_source = f.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fsup ON sr.fk_invoice_supplier_source = fsup.rowid"; - $sql.= " WHERE sr.entity IN (".getEntity('invoice').")"; + $sql.= " WHERE sr.entity IN (".getEntity('invoice').")"; if ($rowid) $sql.= " AND sr.rowid=".$rowid; if ($fk_facture_source) $sql.= " AND sr.fk_facture_source=".$fk_facture_source; if ($fk_invoice_supplier_source) $sql.= " AND sr.fk_invoice_supplier_source=".$fk_invoice_supplier_source; @@ -168,12 +171,14 @@ class DiscountAbsolute $this->fk_user = $obj->fk_user; $this->fk_facture_line = $obj->fk_facture_line; $this->fk_facture = $obj->fk_facture; - $this->fk_facture_source = $obj->fk_facture_source; // Id avoir source - $this->ref_facture_source = $obj->ref_facture_source; // Ref avoir source + $this->fk_facture_source = $obj->fk_facture_source; // Id credit note or deposit source + $this->ref_facture_source = $obj->ref_facture_source; // Ref credit note or deposit source + $this->type_facture_source = $obj->type_facture_source; // Type credit note or deposit source $this->fk_invoice_supplier_line = $obj->fk_invoice_supplier_line; $this->fk_invoice_supplier = $obj->fk_invoice_supplier; - $this->fk_invoice_supplier_source = $obj->fk_invoice_supplier_source; // Id avoir source - $this->ref_invoice_supplier_source = $obj->ref_invoice_supplier_source; // Ref avoir source + $this->fk_invoice_supplier_source = $obj->fk_invoice_supplier_source; // Id credit note or deposit source + $this->ref_invoice_supplier_source = $obj->ref_invoice_supplier_source; // Ref credit note or deposit source + $this->type_invoice_supplier_source = $obj->type_invoice_supplier_source; // Type credit note or deposit source $this->description = $obj->description; $this->datec = $this->db->jdate($obj->datec); @@ -689,7 +694,7 @@ class DiscountAbsolute if ($option == 'invoice') { $facid=! empty($this->discount_type)?$this->fk_invoice_supplier_source:$this->fk_facture_source; $link=! empty($this->discount_type)?'/fourn/facture/card.php':'/compta/facture/card.php'; - $label=$langs->trans("ShowDiscount").': '.$this->ref_facture_source; + $label=$langs->trans("ShowSourceInvoice").': '.$this->ref_facture_source; $link = ''; $linkend=''; $ref=! empty($this->discount_type)?$this->ref_invoice_supplier_source:$this->ref_facture_source; diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index ab4d9096df2..8e922506b23 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -281,7 +281,8 @@ AddGlobalDiscount=Create absolute discount EditGlobalDiscounts=Edit absolute discounts AddCreditNote=Create credit note ShowDiscount=Show discount -ShowReduc=Show the deduction +ShowReduc=Show the discount +ShowSourceInvoice=Show the source invoice RelativeDiscount=Relative discount GlobalDiscount=Global discount CreditNote=Credit note From e709c005a084ec7ac6d09b9185d48a6eecf7c430 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Oct 2019 12:28:48 +0200 Subject: [PATCH 04/58] FIX Payment was not saved on TakePOS module. --- htdocs/takepos/invoice.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 1f3d4a22563..2b8b0f21921 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -115,7 +115,7 @@ if ($action == 'valid' && $user->rights->facture->creer) $invoice = new Facture($db); $invoice->fetch($placeid); - if($invoice->total_ttc<0){ + if ($invoice->total_ttc < 0) { $invoice->type= $invoice::TYPE_CREDIT_NOTE; $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."facture WHERE "; $sql.="fk_soc = '".$invoice->socid."' "; @@ -153,8 +153,10 @@ if ($action == 'valid' && $user->rights->facture->creer) $res = $invoice->validate($user); } + $remaintopay = $invoice->getRemainToPay(); + // Add the payment - if ($res > 0) { + if ($res >= 0 && $remaintopay > 0) { $payment = new Paiement($db); $payment->datepaye = $now; $payment->fk_account = $bankaccount; @@ -166,9 +168,9 @@ if ($action == 'valid' && $user->rights->facture->creer) $payment->create($user); $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', ''); - $remaintopay = $invoice->getRemainToPay(); + $remaintopay = $invoice->getRemainToPay(); // Recalculate remain to pay after the payment is recorded if ($remaintopay == 0) { - dol_syslog("Invoice is paid, so we set it to pay"); + dol_syslog("Invoice is paid, so we set it to status Paid"); $result = $invoice->set_paid($user); if ($result > 0) $invoice->paye = 1; } else { From 1a419a6eb67bf9222f61d76dbc1b926861bdd2b8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Oct 2019 15:15:16 +0200 Subject: [PATCH 05/58] Fix translation --- htdocs/langs/en_US/bills.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 8e922506b23..ddef01b17c1 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -151,7 +151,7 @@ ErrorBillNotFound=Invoice %s does not exist ErrorInvoiceAlreadyReplaced=Error, you tried to validate an invoice to replace invoice %s. But this one has already been replaced by invoice %s. ErrorDiscountAlreadyUsed=Error, discount already used ErrorInvoiceAvoirMustBeNegative=Error, correct invoice must have a negative amount -ErrorInvoiceOfThisTypeMustBePositive=Error, this type of invoice must have a positive amount +ErrorInvoiceOfThisTypeMustBePositive=Error, this type of invoice must have an amount excluding tax positive (or null) ErrorCantCancelIfReplacementInvoiceNotValidated=Error, can't cancel an invoice that has been replaced by another invoice that is still in draft status ErrorThisPartOrAnotherIsAlreadyUsedSoDiscountSerieCantBeRemoved=This part or another is already used so discount series cannot be removed. BillFrom=From From 5e12dcc6b14f51c2766aa9c8d2db63cbf64ea2a5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Oct 2019 15:40:02 +0200 Subject: [PATCH 06/58] Fix on FACTURE_ENABLE_NEGATIVE --- htdocs/compta/facture/card.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 1b6b4a50e01..cf5d3477527 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -278,8 +278,11 @@ if (empty($reshook)) $action = ''; } } else { - // Si non avoir, le signe doit etre positif - if (empty($conf->global->FACTURE_ENABLE_NEGATIVE) && $object->total_ht < 0) { + // If not a credit note, amount with tax must be positive or nul. + // Note that amount excluding tax can be negative because you can have a invoice of 100 with vat of 20 that + // consumes a credit note of 100 with vat 0 (total with tax is 0 but without tax is -20). + // For some cases, credit notes can have a vat of 0 (for example when selling goods in France). + if (empty($conf->global->FACTURE_ENABLE_NEGATIVE) && $object->total_ttc < 0) { setEventMessages($langs->trans("ErrorInvoiceOfThisTypeMustBePositive"), null, 'errors'); $action = ''; } From d388c0b0a3ed8f610394ec4684976027a00b6084 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Oct 2019 16:03:07 +0200 Subject: [PATCH 07/58] Doc --- ChangeLog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog b/ChangeLog index d4e1356b493..5093894d86b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -67,6 +67,8 @@ FIX: Update of leave request when CSRF with token is on FIX: Var not enough sanitized FIX: wrong test FIX: XSS +FIX: Can validate invoice with amount including tax of zero for the case of having a final invoice with + VAT that includes a deposit without vat. ***** ChangeLog for 10.0.2 compared to 10.0.1 ***** FIX: #10460 compatibility with MariaDB 10.4 From 3267c224ff1d99c16a68e4bd4fff73734e15ce55 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Oct 2019 16:03:56 +0200 Subject: [PATCH 08/58] doc --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 5093894d86b..14838c1281d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,7 +5,7 @@ English Dolibarr ChangeLog ***** ChangeLog for 10.0.3 compared to 10.0.2 ***** IMPORTANT : This version fixes a serious bug in saving the units of weight, size, surface and volume on product card. The unit were not saved correctly in database making calculation on shipments wrong. -Update to this version must be done if you use them and have installed version 10.0.0, 10.0.1 or 10.0.2 and set some products after installing or upgrading to this version. +Update to this version must be done if you use them and have installed version 10.0.0, 10.0.1 or 10.0.2 and set some products after installing or upgrading to one of this version. Once update is done you must then edit (manually) the product that has bad unit to set the correct unit to have features restored. FIX: #11702 From ac46d2c9185df86b28fcddffb136c6375c22b77d Mon Sep 17 00:00:00 2001 From: Gildas Date: Thu, 17 Oct 2019 15:10:05 +0200 Subject: [PATCH 09/58] Fix filtering ticket bug (Fixes #12081) --- htdocs/ticket/list.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 2bfc1719360..a62120f6e55 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -524,15 +524,15 @@ foreach($object->fields as $key => $val) if (! empty($arrayfields['t.'.$key]['checked'])) { if ($key == 'type_code') { print ''; - $formTicket->selectTypesTickets(dol_escape_htmltag($search[$key]), 'search_'.$key.'', '', 0, 1, 1, 0, ($val['css']?$val['css']:'maxwidth150')); + $formTicket->selectTypesTickets(dol_escape_htmltag($search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, ($val['css']?$val['css']:'maxwidth150')); print ''; } elseif ($key == 'category_code') { print ''; - $formTicket->selectGroupTickets(dol_escape_htmltag($search[$key]), 'search_'.$key.'', '', 0, 1, 1, 0, ($val['css']?$val['css']:'maxwidth150')); + $formTicket->selectGroupTickets(dol_escape_htmltag($search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, ($val['css']?$val['css']:'maxwidth150')); print ''; } elseif ($key == 'severity_code') { print ''; - $formTicket->selectSeveritiesTickets(dol_escape_htmltag($search[$key]), 'search_'.$key.'', '', 0, 1, 1, 0, ($val['css']?$val['css']:'maxwidth150')); + $formTicket->selectSeveritiesTickets(dol_escape_htmltag($search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, ($val['css']?$val['css']:'maxwidth150')); print ''; } elseif ($key == 'fk_user_assign') { print ''; From eaffe4d1eb0eaec5f2ca0a8c1355261113f556c2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Oct 2019 20:13:10 +0200 Subject: [PATCH 10/58] doc --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 14838c1281d..d1c8b22d96f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -67,6 +67,7 @@ FIX: Update of leave request when CSRF with token is on FIX: Var not enough sanitized FIX: wrong test FIX: XSS +FIX: Payment from POS ware not recorded. FIX: Can validate invoice with amount including tax of zero for the case of having a final invoice with VAT that includes a deposit without vat. From acef3fb169ed31f947589939f68e401d2f3425ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 17 Oct 2019 20:59:42 +0200 Subject: [PATCH 11/58] clean top menu xxx --- htdocs/bookmarks/bookmarks.lib.php | 20 +++++------------ htdocs/main.inc.php | 36 +++++++++++++----------------- 2 files changed, 20 insertions(+), 36 deletions(-) diff --git a/htdocs/bookmarks/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php index 8128815ef3b..8a26b12f15b 100644 --- a/htdocs/bookmarks/bookmarks.lib.php +++ b/htdocs/bookmarks/bookmarks.lib.php @@ -24,16 +24,11 @@ /** * Add area with bookmarks in menu * - * @param DoliDb $aDb Database handler - * @param Translate $aLangs Object lang * @return string */ -function printBookmarksList($aDb, $aLangs) +function printBookmarksList() { - global $conf, $user; - - $db = $aDb; - $langs = $aLangs; + global $conf, $user, $db, $langs; $ret = ''."\n"; @@ -155,16 +150,11 @@ function printBookmarksList($aDb, $aLangs) /** * Add area with bookmarks in top menu * - * @param DoliDb $aDb Database handler - * @param Translate $aLangs Object lang * @return string */ -function printDropdownBookmarksList($aDb, $aLangs) +function printDropdownBookmarksList() { - global $conf, $user; - - $db = $aDb; - $langs = $aLangs; + global $conf, $user, $db, $langs; require_once DOL_DOCUMENT_ROOT.'/bookmarks/class/bookmark.class.php'; if (! isset($conf->global->BOOKMARKS_SHOW_IN_MENU)) $conf->global->BOOKMARKS_SHOW_IN_MENU=5; @@ -271,7 +261,7 @@ function printDropdownBookmarksList($aDb, $aLangs) var filter = $(this).val(), count = 0; $("#dropdown-bookmarks-list .bookmark-item").each(function () { - + if ($(this).text().search(new RegExp(filter, "i")) < 0) { $(this).addClass("hidden-search-result"); } else { diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 4fc94feb1f4..f522ad29fa8 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1625,16 +1625,16 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead if (!empty($conf->global->MAIN_USE_TOP_MENU_SEARCH_DROPDOWN)){ // Add search dropdown - $toprightmenu.= top_menu_search($user, $langs); + $toprightmenu.= top_menu_search(); } if (!empty($conf->global->MAIN_USE_TOP_MENU_BOOKMARK_DROPDOWN)) { // Add bookmark dropdown - $toprightmenu .= top_menu_bookmark($user, $langs); + $toprightmenu .= top_menu_bookmark(); } // Add user dropdown - $toprightmenu.= top_menu_user($user, $langs); + $toprightmenu.= top_menu_user(); $toprightmenu.=''; @@ -1747,11 +1747,9 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead /** * Build the tooltip on user login * - * @param user $user User object - * @param Translate $langs Language object * @return string HTML content */ -function top_menu_user(User $user, Translate $langs) +function top_menu_user() { global $langs, $conf, $db, $hookmanager, $user; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -1916,15 +1914,13 @@ function top_menu_user(User $user, Translate $langs) /** * Build the tooltip on top menu bookmark * - * @param user $user User object - * @param Translate $langs Language object * @return string HTML content */ -function top_menu_bookmark(User $user, Translate $langs) +function top_menu_bookmark() { - global $langs, $conf, $db, $hookmanager, $user; - global $menumanager; - $html = ''; + global $langs, $conf, $db, $user; + + $html = ''; // Define $bookmarks if (! empty($conf->bookmark->enabled) && $user->rights->bookmark->lire) @@ -1938,7 +1934,7 @@ function top_menu_bookmark(User $user, Translate $langs) '; @@ -1984,15 +1980,13 @@ function top_menu_bookmark(User $user, Translate $langs) /** * Build the tooltip on top menu tsearch * - * @param user $user User object - * @param Translate $langs Language object * @return string HTML content */ -function top_menu_search(User $user, Translate $langs) +function top_menu_search() { - global $langs, $conf, $db, $hookmanager, $user; - global $menumanager; - $html = ''; + global $langs, $conf, $db, $user; + + $html = ''; $usedbyinclude=1; $arrayresult=null; @@ -2003,7 +1997,7 @@ function top_menu_search(User $user, Translate $langs) // Menu with all bookmarks foreach ($arrayresult as $keyItem => $item) { - if(empty($defaultAction)){ + if (empty($defaultAction)) { $defaultAction= $item['url']; } $buttonList.='