From 7080c8491d3ee0624d8ba4195b37a0b06badd2c3 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 24 Oct 2020 19:46:57 +0200 Subject: [PATCH 1/4] Fix var name in contract box --- htdocs/core/boxes/box_services_contracts.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index 50f18de82f5..00daf2f05ac 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -121,7 +121,7 @@ class box_services_contracts extends ModeleBoxes $contractlinestatic->label=$objp->label; $contractlinestatic->description=$objp->description; $contractlinestatic->type=$objp->type; - $contratlignestatic->product_type = $objp->product_type; + $contractlinestatic->product_type = $objp->product_type; $contractlinestatic->product_id=$objp->product_id; $contractlinestatic->product_ref=$objp->product_ref; From 680ae60b6f68d08bb5e2b054a67936f9e5850165 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 25 Oct 2020 08:56:34 +0100 Subject: [PATCH 2/4] Fix #15064 : error when supplier invoice numbering module is not configured --- .../fourn/class/fournisseur.facture.class.php | 2 +- htdocs/fourn/facture/card.php | 83 ++++++++++--------- 2 files changed, 44 insertions(+), 41 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 78615fc2cf6..f1f5c8fb969 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2469,7 +2469,7 @@ class FactureFournisseur extends CommonInvoice { $this->error=$obj->error; //dol_print_error($db,get_class($this)."::getNextNumRef ".$obj->error); - return false; + return -1; } } diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index a49bc2022fd..ba08e0db0d4 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -57,7 +57,7 @@ if (!empty($conf->variants->enabled)) { if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; -$langs->loadLangs(array('bills', 'compta', 'suppliers', 'companies', 'products', 'banks')); +$langs->loadLangs(array('bills', 'compta', 'suppliers', 'companies', 'products', 'banks', 'admin')); if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); $id = (GETPOST('facid', 'int') ? GETPOST('facid', 'int') : GETPOST('id', 'int')); @@ -2329,11 +2329,9 @@ else // Confirmation de la validation if ($action == 'valid') { - // on verifie si l'objet est en numerotation provisoire - $objectref = substr($object->ref, 1, 4); - if ($objectref == 'PROV') + // We check if number is temporary number + if (preg_match('/^[\(]?PROV/i', $object->ref) || empty($object->ref)) // empty should not happened, but when it occurs, the test save life { - $savdate = $object->date; $numref = $object->getNextNumRef($societe); } else @@ -2341,46 +2339,51 @@ else $numref = $object->ref; } - $text = $langs->trans('ConfirmValidateBill', $numref); - /*if (! empty($conf->notification->enabled)) - { - require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php'; - $notify=new Notify($db); - $text.='
'; - $text.=$notify->confirmMessage('BILL_SUPPLIER_VALIDATE',$object->socid, $object); - }*/ - $formquestion = array(); - - $qualified_for_stock_change = 0; - if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) + if ($numref < 0) { - $qualified_for_stock_change = $object->hasProductsOrServices(2); + setEventMessages($object->error, $object->errors, 'errors'); + $action = ''; } else { - $qualified_for_stock_change = $object->hasProductsOrServices(1); + + $text = $langs->trans('ConfirmValidateBill', $numref); + /*if (! empty($conf->notification->enabled)) + { + require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php'; + $notify=new Notify($db); + $text.='
'; + $text.=$notify->confirmMessage('BILL_SUPPLIER_VALIDATE',$object->socid, $object); + }*/ + $formquestion = array(); + + $qualified_for_stock_change = 0; + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { + $qualified_for_stock_change = $object->hasProductsOrServices(2); + } else { + $qualified_for_stock_change = $object->hasProductsOrServices(1); + } + + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change) { + $langs->load("stocks"); + require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php'; + $formproduct = new FormProduct($db); + $warehouse = new Entrepot($db); + $warehouse_array = $warehouse->list_array(); + if (count($warehouse_array) == 1) { + $label = $object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("WarehouseForStockDecrease", current($warehouse_array)) : $langs->trans("WarehouseForStockIncrease", current($warehouse_array)); + $value = ''; + } else { + $label = $object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("SelectWarehouseForStockDecrease") : $langs->trans("SelectWarehouseForStockIncrease"); + $value = $formproduct->selectWarehouses(GETPOST('idwarehouse') ? GETPOST('idwarehouse') : 'ifone', 'idwarehouse', '', 1); + } + $formquestion = array( + array('type' => 'other', 'name' => 'idwarehouse', 'label' => $label, 'value' => $value) + ); + } + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ValidateBill'), $text, 'confirm_valid', $formquestion, 1, 1); } - - if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change) - { - $langs->load("stocks"); - require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; - $formproduct = new FormProduct($db); - $warehouse = new Entrepot($db); - $warehouse_array = $warehouse->list_array(); - if (count($warehouse_array) == 1) { - $label = $object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("WarehouseForStockDecrease", current($warehouse_array)) : $langs->trans("WarehouseForStockIncrease", current($warehouse_array)); - $value = ''; - } else { - $label = $object->type == FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans("SelectWarehouseForStockDecrease") : $langs->trans("SelectWarehouseForStockIncrease"); - $value = $formproduct->selectWarehouses(GETPOST('idwarehouse') ?GETPOST('idwarehouse') : 'ifone', 'idwarehouse', '', 1); - } - $formquestion = array( - array('type' => 'other', 'name' => 'idwarehouse', 'label' => $label, 'value' => $value) - ); - } - - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateBill'), $text, 'confirm_valid', $formquestion, 1, 1); } // Confirmation edit (back to draft) From 309691f1e786e5efec06c2a56273b403ac68d096 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 25 Oct 2020 09:28:41 +0100 Subject: [PATCH 3/4] Fix #15143 selected lines on invoice creation --- htdocs/compta/facture/card.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index c0b6aff2d14..31c42e5ba9e 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -997,6 +997,7 @@ if (empty($reshook)) elseif ($action == 'add' && $usercancreate) { if ($socid > 0) $object->socid = GETPOST('socid', 'int'); + $selectedLines = GETPOST('toselect', 'array'); $db->begin(); @@ -1586,8 +1587,11 @@ if (empty($reshook)) $fk_parent_line = 0; $num = count($lines); + for ($i = 0; $i < $num; $i++) { + if (!in_array($lines[$i]->id, $selectedLines)) continue; // Skip unselected lines + // Don't add lines with qty 0 when coming from a shipment including all order lines if ($srcobject->element == 'shipping' && $conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS && $lines[$i]->qty == 0) continue; // Don't add closed lines when coming from a contract (Set constant to '0,5' to exclude also inactive lines) @@ -3647,8 +3651,6 @@ if ($action == 'create') print ''; print ''; - print "\n"; - // Show origin lines if (!empty($origin) && !empty($originid) && is_object($objectsrc)) { print '
'; @@ -3658,12 +3660,12 @@ if ($action == 'create') print ''; - $objectsrc->printOriginLinesList(); + $objectsrc->printOriginLinesList('', $selectedLines); print '
'; } - print '
'; + print "\n"; } elseif ($id > 0 || !empty($ref)) { From baa86d773bf3b40803981e1b790780a8e293ab54 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Oct 2020 21:07:37 +0100 Subject: [PATCH 4/4] Fix phpcs --- htdocs/fourn/facture/card.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index ba08e0db0d4..3fe9c3f34da 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2346,7 +2346,6 @@ else } else { - $text = $langs->trans('ConfirmValidateBill', $numref); /*if (! empty($conf->notification->enabled)) {