From eb55b307c01602d31982c42c7fa9247fed03e2b3 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 25 Sep 2022 06:04:27 +0200 Subject: [PATCH] Use isModEnabled --- htdocs/expedition/card.php | 30 +++++++++---------- htdocs/expedition/class/expedition.class.php | 8 ++--- htdocs/expedition/shipment.php | 16 +++++----- htdocs/fourn/ajax/getSupplierPrices.php | 2 +- .../class/fournisseur.commande.class.php | 4 +-- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index d83b5bd75f5..6b819f58e83 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -391,7 +391,7 @@ if (empty($reshook)) { } } elseif (!$error) { $labelfieldmissing = $langs->transnoentitiesnoconv("QtyToShip"); - if (!empty($conf->stock->enabled)) { + if (isModEnabled('stock')) { $labelfieldmissing .= '/'.$langs->transnoentitiesnoconv("Warehouse"); } setEventMessages($langs->trans("ErrorFieldRequired", $labelfieldmissing), null, 'errors'); @@ -739,7 +739,7 @@ if (empty($reshook)) { unset($_POST[$qty]); } } - } elseif (empty($conf->stock->enabled) && empty($conf->productbatch->enabled)) { // both product batch and stock are not activated. + } elseif (!isModEnabled('stock') && empty($conf->productbatch->enabled)) { // both product batch and stock are not activated. $qty = "qtyl".$line_id; $line->id = $line_id; $line->qty = GETPOST($qty, 'int'); @@ -865,7 +865,7 @@ if ($action == 'create') { $author = new User($db); $author->fetch($object->user_author_id); - if (!empty($conf->stock->enabled)) { + if (isModEnabled('stock')) { $entrepot = new Entrepot($db); } @@ -1077,7 +1077,7 @@ if ($action == 'create') { } print ''.img_picto($langs->trans("Reset"), 'eraser').''; print ''; - if (!empty($conf->stock->enabled)) { + if (isModEnabled('stock')) { if (empty($conf->productbatch->enabled)) { print ''.$langs->trans("Warehouse").' ('.$langs->trans("Stock").')'; } else { @@ -1212,7 +1212,7 @@ if ($action == 'create') { } $warehouseObject = null; - if (count($warehousePicking) == 1 || !($line->fk_product > 0) || empty($conf->stock->enabled)) { // If warehouse was already selected or if product is not a predefined, we go into this part with no multiwarehouse selection + if (count($warehousePicking) == 1 || !($line->fk_product > 0) || !isModEnabled('stock')) { // If warehouse was already selected or if product is not a predefined, we go into this part with no multiwarehouse selection print ''; //ship from preselected location $stock = + (isset($product->stock_warehouse[$warehouse_id]->real) ? $product->stock_warehouse[$warehouse_id]->real : 0); // Convert to number @@ -1240,7 +1240,7 @@ if ($action == 'create') { print ''; // Stock - if (!empty($conf->stock->enabled)) { + if (isModEnabled('stock')) { print ''; if ($line->product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { // Type of product need stock change ? // Show warehouse combo list @@ -1423,7 +1423,7 @@ if ($action == 'create') { print ''; // Stock - if (!empty($conf->stock->enabled)) { + if (isModEnabled('stock')) { print ''; if ($line->product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { print $tmpwarehouseObject->getNomUrl(0).' '; @@ -2045,7 +2045,7 @@ if ($action == 'create') { } if ($action == 'editline') { $editColspan = 3; - if (empty($conf->stock->enabled)) { + if (!isModEnabled('stock')) { $editColspan--; } if (empty($conf->productbatch->enabled)) { @@ -2057,7 +2057,7 @@ if ($action == 'create') { } else { print $langs->trans("QtyShipped").' - '; } - if (!empty($conf->stock->enabled)) { + if (isModEnabled('stock')) { print $langs->trans("WarehouseSource").' - '; } if (isModEnabled('productbatch')) { @@ -2070,7 +2070,7 @@ if ($action == 'create') { } else { print ''.$langs->trans("QtyShipped").''; } - if (!empty($conf->stock->enabled)) { + if (isModEnabled('stock')) { print ''.$langs->trans("WarehouseSource").''; } @@ -2255,7 +2255,7 @@ if ($action == 'create') { print $shipment_static->getNomUrl(1); print ' - '.$shipmentline_var['qty_shipped']; $htmltext = $langs->trans("DateValidation").' : '.(empty($shipmentline_var['date_valid']) ? $langs->trans("Draft") : dol_print_date($shipmentline_var['date_valid'], 'dayhour')); - if (!empty($conf->stock->enabled) && $shipmentline_var['warehouse'] > 0) { + if (isModEnabled('stock') && $shipmentline_var['warehouse'] > 0) { $warehousestatic->fetch($shipmentline_var['warehouse']); $htmltext .= '
'.$langs->trans("FromLocation").' : '.$warehousestatic->getNomUrl(1, '', 0, 1); } @@ -2292,7 +2292,7 @@ if ($action == 'create') { // Batch number managment print ''.$formproduct->selectLotStock('', 'batchl'.$line_id.'_0', '', 1, 0, $lines[$i]->fk_product).''; print ''; - } elseif (!empty($conf->stock->enabled)) { + } elseif (isModEnabled('stock')) { if ($lines[$i]->fk_product > 0) { if ($lines[$i]->entrepot_id > 0) { print ''; @@ -2331,7 +2331,7 @@ if ($action == 'create') { print ''; print ''; } - } elseif (empty($conf->stock->enabled) && empty($conf->productbatch->enabled)) { // both product batch and stock are not activated. + } elseif (!isModEnabled('stock') && empty($conf->productbatch->enabled)) { // both product batch and stock are not activated. print ''; print ''; // Qty to ship or shipped @@ -2349,7 +2349,7 @@ if ($action == 'create') { print ''.$lines[$i]->qty_shipped.' '.$unit_order.''; // Warehouse source - if (!empty($conf->stock->enabled)) { + if (isModEnabled('stock')) { print ''; if ($lines[$i]->entrepot_id > 0) { $entrepot = new Entrepot($db); @@ -2452,7 +2452,7 @@ if ($action == 'create') { if (isModEnabled('productbatch')) { $colspan++; } - if (!empty($conf->stock->enabled)) { + if (isModEnabled('stock')) { $colspan++; } diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index b1f3df3bbaf..4fcb145d62a 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -707,7 +707,7 @@ class Expedition extends CommonObject } // If stock increment is done on sending (recommanded choice) - if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) { + if (!$error && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); @@ -913,7 +913,7 @@ class Expedition extends CommonObject $line->rang = $orderline->rang; $line->product_type = $orderline->product_type; - if (!empty($conf->stock->enabled) && !empty($orderline->fk_product)) { + if (isModEnabled('stock') && !empty($orderline->fk_product)) { $fk_product = $orderline->fk_product; if (!($entrepot_id > 0) && empty($conf->global->STOCK_WAREHOUSE_NOT_REQUIRED_FOR_SHIPMENTS)) { @@ -2150,7 +2150,7 @@ class Expedition extends CommonObject $this->status = self::STATUS_CLOSED; // Will be revert to STATUS_VALIDATED at end if there is a rollback // If stock increment is done on closing - if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { + if (!$error && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); @@ -2327,7 +2327,7 @@ class Expedition extends CommonObject $this->billed = 0; // If stock increment is done on closing - if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { + if (!$error && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 33ee4a761bb..7619ef140f8 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -38,7 +38,7 @@ if (isModEnabled('project')) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } -if (!empty($conf->stock->enabled)) { +if (isModEnabled('stock')) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; } if (isModEnabled("propal")) { @@ -431,7 +431,7 @@ if ($id > 0 || !empty($ref)) { print ''; // Warehouse - if (!empty($conf->stock->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { + if (isModEnabled('stock') && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); print ''; @@ -642,7 +642,7 @@ if ($id > 0 || !empty($ref)) { print ''.$langs->trans("QtyOrdered").''; print ''.$langs->trans("QtyShipped").''; print ''.$langs->trans("KeepToShip").''; - if (!empty($conf->stock->enabled)) { + if (isModEnabled('stock')) { print ''.$langs->trans("RealStock").''; } else { print ' '; @@ -794,7 +794,7 @@ if ($id > 0 || !empty($ref)) { $product->load_stock('warehouseopen'); } - if ($objp->fk_product > 0 && ($type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) && !empty($conf->stock->enabled)) { + if ($objp->fk_product > 0 && ($type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) && isModEnabled('stock')) { print ''; print $product->stock_reel; if ($product->stock_reel < $toBeShipped[$objp->fk_product]) { @@ -858,7 +858,7 @@ if ($id > 0 || !empty($ref)) { print '
'; // Bouton expedier sans gestion des stocks - if (empty($conf->stock->enabled) && ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED)) { + if (!isModEnabled('stock') && ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED)) { if ($user->rights->expedition->creer) { print ''.$langs->trans("CreateShipment").''; if ($toBeShippedTotal <= 0) { @@ -874,11 +874,11 @@ if ($id > 0 || !empty($ref)) { // Bouton expedier avec gestion des stocks - if (!empty($conf->stock->enabled) && $object->statut == Commande::STATUS_DRAFT) { + if (isModEnabled('stock') && $object->statut == Commande::STATUS_DRAFT) { print $langs->trans("ValidateOrderFirstBeforeShipment"); } - if (!empty($conf->stock->enabled) && ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED)) { + if (isModEnabled('stock') && ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED)) { if ($user->rights->expedition->creer) { //print load_fiche_titre($langs->trans("CreateShipment")); print '
'; @@ -896,7 +896,7 @@ if ($id > 0 || !empty($ref)) { //print ''; - if (!empty($conf->stock->enabled)) { + if (isModEnabled('stock')) { //print ''; print $langs->trans("WarehouseSource"); //print ''; diff --git a/htdocs/fourn/ajax/getSupplierPrices.php b/htdocs/fourn/ajax/getSupplierPrices.php index 632a8fcb6cb..29cf421059e 100644 --- a/htdocs/fourn/ajax/getSupplierPrices.php +++ b/htdocs/fourn/ajax/getSupplierPrices.php @@ -93,7 +93,7 @@ if ($idprod > 0) { } // After best supplier prices and before costprice - if (!empty($conf->stock->enabled)) { + if (isModEnabled('stock')) { // Add price for pmp $price = $producttmp->pmp; if (empty($price) && !empty($conf->global->PRODUCT_USE_SUB_COST_PRICES_IF_COST_PRICE_EMPTY)) { diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 6a8e8e360b3..f5be521dd3b 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1097,7 +1097,7 @@ class CommandeFournisseur extends CommonOrder } // If stock is incremented on validate order, we must increment it - if (!$error && $movetoapprovestatus && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)) { + if (!$error && $movetoapprovestatus && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); @@ -2085,7 +2085,7 @@ class CommandeFournisseur extends CommonOrder } // If module stock is enabled and the stock increase is done on purchase order dispatching - if (!$error && $entrepot > 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { + if (!$error && $entrepot > 0 && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { $mouv = new MouvementStock($this->db); if ($product > 0) { // $price should take into account discount (except if option STOCK_EXCLUDE_DISCOUNT_FOR_PMP is on)