From f23f16da861d128c7f1e2e355fbfd151a0c7b4ac Mon Sep 17 00:00:00 2001 From: frederic34 Date: Sat, 1 Nov 2014 21:38:50 +0100 Subject: [PATCH] Try to improve stock display for all stock increase/decrease options --- htdocs/langs/en_US/sendings.lang | 2 + htdocs/langs/fr_FR/sendings.lang | 2 + htdocs/product/class/product.class.php | 78 ++++++++++++--------- htdocs/product/stock/product.php | 95 ++++++++++++++------------ 4 files changed, 100 insertions(+), 77 deletions(-) diff --git a/htdocs/langs/en_US/sendings.lang b/htdocs/langs/en_US/sendings.lang index 2ae43f39766..855fced7310 100644 --- a/htdocs/langs/en_US/sendings.lang +++ b/htdocs/langs/en_US/sendings.lang @@ -61,6 +61,8 @@ ShipmentCreationIsDoneFromOrder=For the moment, creation of a new shipment is do RelatedShippings=Related shippings ShipmentLine=Shipment line CarrierList=List of transporters +SendingRunning=Product from customer order already sent +SuppliersReceiptRunning=Product from supplier order alrady received # Sending methods SendingMethodCATCH=Catch by customer diff --git a/htdocs/langs/fr_FR/sendings.lang b/htdocs/langs/fr_FR/sendings.lang index 47b359318e4..59c937c97b6 100644 --- a/htdocs/langs/fr_FR/sendings.lang +++ b/htdocs/langs/fr_FR/sendings.lang @@ -61,6 +61,8 @@ ShipmentCreationIsDoneFromOrder=Pour le moment, la création d'une nouvelle exp RelatedShippings=Expédition(s) associée(s) ShipmentLine=Ligne d'expédition CarrierList=Liste des transporteurs +SendingRunning=Produits de commandes clients déjà expédiés +SuppliersReceiptRunning=Produit de commandes fournisseurs déjà réceptionnés # Sending methods SendingMethodCATCH=Enlèvement par le client diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 226a3501652..98b5d155ba7 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3032,42 +3032,56 @@ class Product extends CommonObject * * @return int < 0 if KO, > 0 if OK */ - function load_virtual_stock() - { - global $conf; + function load_virtual_stock() + { + global $conf; - if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) - { - $stock_commande_client=$stock_commande_fournisseur=0; - $stock_sending_client=$stock_reception_fournisseur=0; + $stock_commande_client=0; + $stock_commande_fournisseur=0; + $stock_sending_client=0; + $stock_reception_fournisseur=0; - if (! empty($conf->commande->enabled)) - { - $result=$this->load_stats_commande(0,'1,2'); - if ($result < 0) dol_print_error($db,$this->error); - $stock_commande_client=$this->stats_commande['qty']; - } - if (! empty($conf->expedition->enabled)) - { - $result=$this->load_stats_sending(0,'1,2'); - if ($result < 0) dol_print_error($db,$this->error); - $stock_sending_client=$this->stats_expedition['qty']; - } - if (! empty($conf->fournisseur->enabled)) - { - $result=$this->load_stats_commande_fournisseur(0,'3'); - if ($result < 0) dol_print_error($db,$this->error); - $stock_commande_fournisseur=$this->stats_commande_fournisseur['qty']; + if (! empty($conf->commande->enabled)) { + $result=$this->load_stats_commande(0,'1,2'); + if ($result < 0) dol_print_error($db,$this->error); + $stock_commande_client=$this->stats_commande['qty']; + } + if (! empty($conf->expedition->enabled)) { + $result=$this->load_stats_sending(0,'1,2'); + if ($result < 0) dol_print_error($db,$this->error); + $stock_sending_client=$this->stats_expedition['qty']; + } + if (! empty($conf->fournisseur->enabled)) { + $result=$this->load_stats_commande_fournisseur(0,'3,4'); + if ($result < 0) dol_print_error($db,$this->error); + $stock_commande_fournisseur=$this->stats_commande_fournisseur['qty']; - $result=$this->load_stats_reception(0,'3'); - if ($result < 0) dol_print_error($db,$this->error); - $stock_reception_fournisseur=$this->stats_reception['qty']; - } + $result=$this->load_stats_reception(0,'4'); + if ($result < 0) dol_print_error($db,$this->error); + $stock_reception_fournisseur=$this->stats_reception['qty']; + } - $this->stock_theorique=$this->stock_reel-($stock_commande_client-$stock_sending_client)+($stock_commande_fournisseur-$stock_reception_fournisseur); - //echo $this->stock_theorique.' = '.$this->stock_reel.' - ('.$stock_commande_client.' - '.$stock_sending_client.') + ('.$stock_commande_fournisseur.' - '.$stock_reception_fournisseur.')'; - } - } + // Stock decrease mode + if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) { + $this->stock_theorique=$this->stock_reel-$stock_commande_client+$stock_sending_client; + } + if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER)) { + $this->stock_theorique=$this->stock_reel; + } + if (! empty($conf->global->STOCK_CALCULATE_ON_BILL)) { + $this->stock_theorique=$this->stock_reel-$stock_commande_client; + } + // Stock Increase mode + if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { + $this->stock_theorique+=$stock_commande_fournisseur-$stock_reception_fournisseur; + } + if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)) { + $this->stock_theorique-=$stock_reception_fournisseur; + } + if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) { + $this->stock_theorique+=$stock_commande_fournisseur-$stock_reception_fournisseur; + } + } /** * Move an uploaded file described into $file array into target directory $sdir. diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 7885553095e..22dc080d6e2 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -39,6 +39,7 @@ $langs->load("products"); $langs->load("orders"); $langs->load("bills"); $langs->load("stocks"); +$langs->load("sendings"); if (! empty($conf->productbatch->enabled)) $langs->load("productbatch"); @@ -331,58 +332,62 @@ if ($id > 0 || $ref) print ''; print ''; - // Calculating a theorical value + // Calculating a theorical value + print ''.$langs->trans("VirtualStock").''; + print "".$product->stock_theorique; + if ($product->stock_theorique < $product->seuil_stock_alerte) { + print ' '.img_warning($langs->trans("StockLowerThanLimit")); + } + print ''; + print ''; - // If stock if stock increment is done on real sending - if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) - { - // Stock theorique - print ''.$langs->trans("VirtualStock").''; - print "".$product->stock_theorique; - if ($product->stock_theorique < $product->seuil_stock_alerte) - { - print ' '.img_warning($langs->trans("StockLowerThanLimit")); - } - print ''; - print ''; + print ''; + $text_stock_options = (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)?$langs->trans("DeStockOnShipment").'
':''); + $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER)?$langs->trans("DeStockOnValidateOrder").'
':''); + $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_BILL)?$langs->trans("DeStockOnBill").'
':''); + $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)?$langs->trans("ReStockOnBill").'
':''); + $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)?$langs->trans("ReStockOnValidateOrder").'
':''); + $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)?$langs->trans("ReStockOnDispatchOrder").'
':''); + print $form->textwithtooltip($langs->trans("StockDiffPhysicTeoric"),$text_stock_options,2,1,img_picto('', 'info'),'',0);; + print ''; + print ''; - print ''; - if ($product->stock_theorique != $product->stock_reel) print $langs->trans("StockDiffPhysicTeoric"); - else print $langs->trans("RunningOrders"); - print ''; - print ''; + $found=0; - $found=0; + // Number of customer orders running + if (! empty($conf->commande->enabled)) + { + if ($found) print '
'; else $found=1; + print $langs->trans("CustomersOrdersRunning").': '.$product->stats_commande['qty']; + $result=$product->load_stats_commande(0,'0'); + if ($result < 0) dol_print_error($db,$product->error); + print ' ('.$langs->trans("Draft").': '.$product->stats_commande['qty'].')'; + } - // Nbre de commande clients en cours - if (! empty($conf->commande->enabled)) - { - if ($found) print '
'; else $found=1; - print $langs->trans("CustomersOrdersRunning").': '.($product->stats_commande['qty']-$product->stats_sendings['qty']); - $result=$product->load_stats_commande(0,'0'); - if ($result < 0) dol_print_error($db,$product->error); - print ' ('.$langs->trans("Draft").': '.$product->stats_commande['qty'].')'; - //print '
'; - //print $langs->trans("CustomersSendingRunning").': '.$stock_sending_client; - } + // Number of product from customer order already sent (partial shipping) + if (! empty($conf->expedition->enabled)) { + if ($found) print '
'; else $found=1; + $result=$product->load_stats_sending(0,'2'); + print $langs->trans("SendingRunning").': '.$product->stats_expedition['qty']; + } - // Nbre de commande fournisseurs en cours - if (! empty($conf->fournisseur->enabled)) - { - if ($found) print '
'; else $found=1; - print $langs->trans("SuppliersOrdersRunning").': '.($product->stats_commande_fournisseur['qty']-$product->stats_reception['qty']); - $result=$product->load_stats_commande_fournisseur(0,'0,1,2'); - if ($result < 0) dol_print_error($db,$product->error); - print ' ('.$langs->trans("DraftOrWaitingApproved").': '.$product->stats_commande_fournisseur['qty'].')'; - } - print ''; - } + // Number of supplier order running + if (! empty($conf->fournisseur->enabled)) { + if ($found) print '
'; else $found=1; + $result=$product->load_stats_commande_fournisseur(0,'3,4'); + print $langs->trans("SuppliersOrdersRunning").': '.$product->stats_commande_fournisseur['qty']; + $result=$product->load_stats_commande_fournisseur(0,'0,1,2'); + if ($result < 0) dol_print_error($db,$product->error); + print ' ('.$langs->trans("DraftOrWaitingApproved").': '.$product->stats_commande_fournisseur['qty'].')'; + } - // If stock if stock increment is done on - // TODO Add information when stock increment is done on other option - - // TODO Add also information on possible decrease stock accroding to stock decrease option + // Number of product from supplier order already received (partial receipt) + if (! empty($conf->fournisseur->enabled)) { + if ($found) print '
'; else $found=1; + print $langs->trans("SuppliersReceiptRunning").': '.$product->stats_reception['qty']; + } + print ''; // Last movement $sql = "SELECT max(m.datem) as datem";