diff --git a/htdocs/langs/en_US/sendings.lang b/htdocs/langs/en_US/sendings.lang index 2ae43f3976607147c1e8fc3a41898f572cee9868..f6111bac6841189e50c3c7fb9028962b56e3997e 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 already received # Sending methods SendingMethodCATCH=Catch by customer diff --git a/htdocs/langs/fr_FR/deliveries.lang b/htdocs/langs/fr_FR/deliveries.lang index 4f61426e83cdee643150ed38ece838e687685f97..02dd54275f6ebc0e7ca010c355a71947b7096f6d 100644 --- a/htdocs/langs/fr_FR/deliveries.lang +++ b/htdocs/langs/fr_FR/deliveries.lang @@ -24,3 +24,5 @@ Deliverer=Livreur(s) : Sender=Expéditeur Recipient=Destinataire ErrorStockIsNotEnough=Le stock est insuffisant +Shippable=Expédiable +NonShippable=Non Expédiable diff --git a/htdocs/langs/fr_FR/sendings.lang b/htdocs/langs/fr_FR/sendings.lang index 47b359318e41339aaf992bf0d16f1621750eb87b..3f839ba9416c66f9b78ac98d600560dc5c8e5724 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=Produits 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 226a3501652cc16fe7642bcb3b329468eabdb29f..98b5d155ba77c3c11af1678522eb5ba78cee4b61 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; - - if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) - { - $stock_commande_client=$stock_commande_fournisseur=0; - $stock_sending_client=$stock_reception_fournisseur=0; + function load_virtual_stock() + { + global $conf; - 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']; + $stock_commande_client=0; + $stock_commande_fournisseur=0; + $stock_sending_client=0; + $stock_reception_fournisseur=0; - $result=$this->load_stats_reception(0,'3'); - if ($result < 0) dol_print_error($db,$this->error); - $stock_reception_fournisseur=$this->stats_reception['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,'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 7885553095ee110bcbd4f8219fd115fdae18ffa9..22dc080d6e24bb4754e566533bc81e3782c76b1d 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 '</td>'; print '</tr>'; - // Calculating a theorical value - - // If stock if stock increment is done on real sending - if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) - { - // Stock theorique - print '<tr><td>'.$langs->trans("VirtualStock").'</td>'; - print "<td>".$product->stock_theorique; - if ($product->stock_theorique < $product->seuil_stock_alerte) - { - print ' '.img_warning($langs->trans("StockLowerThanLimit")); - } - print '</td>'; - print '</tr>'; + // Calculating a theorical value + print '<tr><td>'.$langs->trans("VirtualStock").'</td>'; + print "<td>".$product->stock_theorique; + if ($product->stock_theorique < $product->seuil_stock_alerte) { + print ' '.img_warning($langs->trans("StockLowerThanLimit")); + } + print '</td>'; + print '</tr>'; - print '<tr><td>'; - if ($product->stock_theorique != $product->stock_reel) print $langs->trans("StockDiffPhysicTeoric"); - else print $langs->trans("RunningOrders"); - print '</td>'; - print '<td>'; + print '<tr><td>'; + $text_stock_options = (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)?$langs->trans("DeStockOnShipment").'<br>':''); + $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER)?$langs->trans("DeStockOnValidateOrder").'<br>':''); + $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_BILL)?$langs->trans("DeStockOnBill").'<br>':''); + $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)?$langs->trans("ReStockOnBill").'<br>':''); + $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)?$langs->trans("ReStockOnValidateOrder").'<br>':''); + $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)?$langs->trans("ReStockOnDispatchOrder").'<br>':''); + print $form->textwithtooltip($langs->trans("StockDiffPhysicTeoric"),$text_stock_options,2,1,img_picto('', 'info'),'',0);; + print '</td>'; + print '<td>'; - $found=0; + $found=0; - // Nbre de commande clients en cours - if (! empty($conf->commande->enabled)) - { - if ($found) print '<br>'; 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 '<br>'; - //print $langs->trans("CustomersSendingRunning").': '.$stock_sending_client; - } + // Number of customer orders running + if (! empty($conf->commande->enabled)) + { + if ($found) print '<br>'; 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 fournisseurs en cours - if (! empty($conf->fournisseur->enabled)) - { - if ($found) print '<br>'; 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 '</td></tr>'; - } + // Number of product from customer order already sent (partial shipping) + if (! empty($conf->expedition->enabled)) { + if ($found) print '<br>'; else $found=1; + $result=$product->load_stats_sending(0,'2'); + print $langs->trans("SendingRunning").': '.$product->stats_expedition['qty']; + } - // If stock if stock increment is done on - // TODO Add information when stock increment is done on other option + // Number of supplier order running + if (! empty($conf->fournisseur->enabled)) { + if ($found) print '<br>'; 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'].')'; + } - // 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 '<br>'; else $found=1; + print $langs->trans("SuppliersReceiptRunning").': '.$product->stats_reception['qty']; + } + print '</td></tr>'; // Last movement $sql = "SELECT max(m.datem) as datem";