From 5457d3116acd08cb285d4a983eafce4ab223f845 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 Dec 2014 16:01:01 +0100 Subject: [PATCH] Fix: Maxi debug of module productbatch. --- htdocs/admin/stock.php | 93 ++++++++++--------- htdocs/core/class/conf.class.php | 12 ++- htdocs/core/modules/modProductBatch.class.php | 2 +- htdocs/expedition/card.php | 68 ++++++++++---- htdocs/expedition/index.php | 12 ++- htdocs/expedition/shipment.php | 5 +- htdocs/langs/en_US/productbatch.lang | 5 +- htdocs/langs/fr_FR/productbatch.lang | 2 +- htdocs/product/card.php | 2 +- 9 files changed, 130 insertions(+), 71 deletions(-) diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index a3109647939..6b2c626da39 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -113,35 +113,20 @@ $linkback=''.$langs->trans("BackToM print_fiche_titre($langs->trans("StockSetup"),$linkback,'setup'); $form=new Form($db); -$var=true; -print ''; -print ''; -print " \n"; -print " \n"; -print ''."\n"; -/* - * Formulaire parametres divers - */ +$disabled=''; +if (! empty($conf->productbatch->enabled)) +{ + $langs->load("productbatch"); + $disabled=' disabled="disabled"'; + print info_admin($langs->trans("WhenProductBatchModuleOnOptionAreForced")); +} -$var=!$var; - -print ""; -print ''; - -print '\n"; -print "\n"; -print '
'; -print '
".$langs->trans("Parameters")." 
'.$langs->trans("UserWarehouseAutoCreate").''; -print "
"; -print ''; -print ""; -print $form->selectyesno("STOCK_USERSTOCK_AUTOCREATE",$conf->global->STOCK_USERSTOCK_AUTOCREATE,1); -print ''; -print '
'; -print "
'; -print '
'; +//if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) || ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) +//{ +print info_admin($langs->trans("IfYouUsePointOfSaleCheckModule")); +//} // Title rule for stock decrease print ''; @@ -160,8 +145,8 @@ if (! empty($conf->facture->enabled)) print ""; print ''; print ""; - print $form->selectyesno("STOCK_CALCULATE_ON_BILL",$conf->global->STOCK_CALCULATE_ON_BILL,1); - print ''; + print $form->selectyesno("STOCK_CALCULATE_ON_BILL",$conf->global->STOCK_CALCULATE_ON_BILL,1,$disabled); + print ''; print "\n\n\n"; } @@ -174,8 +159,8 @@ if (! empty($conf->commande->enabled)) print ""; print ''; print ""; - print $form->selectyesno("STOCK_CALCULATE_ON_VALIDATE_ORDER",$conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER,1); - print ''; + print $form->selectyesno("STOCK_CALCULATE_ON_VALIDATE_ORDER",$conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER,1,$disabled); + print ''; print "\n\n\n"; } @@ -188,16 +173,12 @@ if (! empty($conf->expedition->enabled)) print ""; print ''; print ""; - print $form->selectyesno("STOCK_CALCULATE_ON_SHIPMENT",$conf->global->STOCK_CALCULATE_ON_SHIPMENT,1); - print ''; + print $form->selectyesno("STOCK_CALCULATE_ON_SHIPMENT",$conf->global->STOCK_CALCULATE_ON_SHIPMENT,1,$disabled); + print ''; print "\n\n\n"; } print '
'; -//if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) || ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) -//{ -print info_admin($langs->trans("IfYouUsePointOfSaleCheckModule")); -//} print '
'; // Title rule for stock increase @@ -217,8 +198,8 @@ if (! empty($conf->fournisseur->enabled)) print "
"; print ''; print ""; - print $form->selectyesno("STOCK_CALCULATE_ON_SUPPLIER_BILL",$conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL,1); - print ''; + print $form->selectyesno("STOCK_CALCULATE_ON_SUPPLIER_BILL",$conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL,1,$disabled); + print ''; print "
\n\n\n"; } @@ -231,8 +212,8 @@ if (! empty($conf->fournisseur->enabled)) print "
"; print ''; print ""; - print $form->selectyesno("STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER",$conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER,1); - print ''; + print $form->selectyesno("STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER",$conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER,1,$disabled); + print ''; print "
\n\n\n"; } if (! empty($conf->fournisseur->enabled)) @@ -244,8 +225,8 @@ if (! empty($conf->fournisseur->enabled)) print "
"; print ''; print ""; - print $form->selectyesno("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER",$conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER,1); - print ''; + print $form->selectyesno("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER",$conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER,1,$disabled); + print ''; print "
\n\n\n"; } @@ -334,6 +315,34 @@ if ($virtualdiffersfromphysical) print ''; } + +$var=true; +print ''; + +print ''; +print " \n"; +print " \n"; +print ''."\n"; + +$var=!$var; + +print ""; +print ''; + +print '\n"; +print "\n"; +print '
'; +print '
".$langs->trans("Other")." 
'.$langs->trans("UserWarehouseAutoCreate").''; +print "
"; +print ''; +print ""; +print $form->selectyesno("STOCK_USERSTOCK_AUTOCREATE",$conf->global->STOCK_USERSTOCK_AUTOCREATE,1); +print ''; +print '
'; +print "
'; +print '
'; + + llxFooter(); $db->close(); diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index e079efb8ecc..ac0899c286e 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -367,6 +367,16 @@ class Conf unset($this->global->PROJECT_USE_SEARCH_TO_SELECT); } + if (! empty($conf->productbatch->enabled)) + { + $this->global->STOCK_CALCULATE_ON_BILL=0; + $this->global->STOCK_CALCULATE_ON_VALIDATE_ORDER=0; + $this->global->STOCK_CALCULATE_ON_SHIPMENT=1; + $this->global->STOCK_CALCULATE_ON_SUPPLIER_BILL=0; + $this->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER=0; + $this->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER=1; + } + // conf->currency if (empty($this->global->MAIN_MONNAIE)) $this->global->MAIN_MONNAIE='EUR'; $this->currency=$this->global->MAIN_MONNAIE; @@ -376,7 +386,7 @@ class Conf // By default, suppliers ojbects can be linked to all projects $conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS = 1; - + // conf->liste_limit = constante de taille maximale des listes if (empty($this->global->MAIN_SIZE_LISTE_LIMIT)) $this->global->MAIN_SIZE_LISTE_LIMIT=25; $this->liste_limit=$this->global->MAIN_SIZE_LISTE_LIMIT; diff --git a/htdocs/core/modules/modProductBatch.class.php b/htdocs/core/modules/modProductBatch.class.php index 0cd30f04d22..6eb358aa99d 100644 --- a/htdocs/core/modules/modProductBatch.class.php +++ b/htdocs/core/modules/modProductBatch.class.php @@ -67,7 +67,7 @@ class modProductBatch extends DolibarrModules $this->config_page_url = array(); // Dependencies - $this->depends = array("modProduct","modStock"); // List of modules id that must be enabled if this module is enabled + $this->depends = array("modProduct","modStock","modExpedition","modSupplier"); // List of modules id that must be enabled if this module is enabled. modExpedition is required to manage batch exit (by manual stock decrease on shipment), modSupplier to manage batch entry (after supplier order). $this->requiredby = array(); // List of modules id to disable if this one is disabled $this->phpmin = array(5,0); // Minimum version of PHP required by module $this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index b4ca3504347..d90d4a4c80c 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -84,9 +84,24 @@ if ($id > 0 || ! empty($ref)) // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('expeditioncard','globalcard')); + /* * Actions */ + +$warehousecanbeselectedlater=1; +if (! empty($conf->productbatch->enabled)) +{ + if (! (GETPOST('entrepot_id','int') > 0)) + { + $langs->load("errors"); + setEventMessage($langs->trans("WarhouseMustBeSelectedAtFirstStepWhenProductBatchModuleOn"),'errors'); + header("Location: ".DOL_URL_ROOT.'/expedition/shipment.php?id='.$id); + exit; + } +} + + $parameters=array(); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -593,7 +608,7 @@ if ($action == 'create') print_fiche_titre($langs->trans("CreateASending")); if (! $origin) { - $mesg='
'.$langs->trans("ErrorBadParameters").'
'; + setEventMessage($langs->trans("ErrorBadParameters"),'errors'); } dol_htmloutput_mesg($mesg); @@ -771,10 +786,13 @@ if ($action == 'create') print ''; if (! empty($conf->stock->enabled)) { - if (empty($conf->productbatch->enabled)) { - print ''.$langs->trans("Warehouse").' / '.$langs->trans("Stock").''; - } else { - print ''.$langs->trans("Warehouse").' / '.$langs->trans("Batch").' / '.$langs->trans("Stock").''; + if (empty($conf->productbatch->enabled)) + { + print ''.$langs->trans("Warehouse").' ('.$langs->trans("Stock").')'; + } + else + { + print ''.$langs->trans("Warehouse").' / '.$langs->trans("Batch").' ('.$langs->trans("Stock").')'; } } print "\n"; @@ -828,7 +846,7 @@ if ($action == 'create') print ''; } else - { + { print ""; if ($type==1) $text = img_object($langs->trans('Service'),'service'); else $text = img_object($langs->trans('Product'),'product'); @@ -861,17 +879,19 @@ if ($action == 'create') $quantityAsked = $line->qty; $quantityToBeDelivered = $quantityAsked - $quantityDelivered; + $warehouse_id = GETPOST('entrepot_id','int'); + $defaultqty=0; - if (GETPOST('entrepot_id','int') > 0) + if ($warehouse_id > 0) { //var_dump($product); - $stock = $product->stock_warehouse[GETPOST('entrepot_id','int')]->real; + $stock = $product->stock_warehouse[$warehouse_id]->real; $stock+=0; // Convertit en numerique $defaultqty=min($quantityToBeDelivered, $stock); if (($line->product_type == 1 && empty($conf->global->STOCK_SUPPORTS_SERVICES)) || $defaultqty < 0) $defaultqty=0; } - if (empty($conf->productbatch->enabled) || ! ($product->hasbatch() and is_object($product->stock_warehouse[GETPOST('entrepot_id','int')]))) + if (empty($conf->productbatch->enabled) || ! ($product->hasbatch() and is_object($product->stock_warehouse[$warehouse_id]))) { // Quantity to send print ''; @@ -892,14 +912,14 @@ if ($action == 'create') // Show warehouse combo list $ent = "entl".$indiceAsked; $idl = "idl".$indiceAsked; - $tmpentrepot_id = is_numeric(GETPOST($ent,'int'))?GETPOST($ent,'int'):GETPOST('entrepot_id','int'); + $tmpentrepot_id = is_numeric(GETPOST($ent,'int'))?GETPOST($ent,'int'):$warehouse_id; print $formproduct->selectWarehouses($tmpentrepot_id,'entl'.$indiceAsked,'',1,0,$line->fk_product); - if ($tmpentrepot_id > 0 && $tmpentrepot_id == GETPOST('entrepot_id','int')) + if ($tmpentrepot_id > 0 && $tmpentrepot_id == $warehouse_id) { //print $stock.' '.$quantityToBeDelivered; if ($stock < $quantityToBeDelivered) { - print ' '.img_warning($langs->trans("StockTooLow")); // Stock too low for entrepot_id but we may have change warehouse + print ' '.img_warning($langs->trans("StockTooLow")); // Stock too low for this $warehouse_id but you can change warehouse } } } @@ -934,11 +954,14 @@ if ($action == 'create') } } } - } else { + } + else + { print ''; $subj=0; print ''; - foreach ($product->stock_warehouse[GETPOST('entrepot_id','int')]->detail_batch as $dbatch) { + foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) + { //var_dump($dbatch); $substock=$dbatch->qty +0 ; print ''; @@ -946,8 +969,13 @@ if ($action == 'create') print ''; print ''; + + $staticwarehouse=new Entrepot($db); + $staticwarehouse->fetch($warehouse_id); + print $staticwarehouse->getNomUrl(0).' / '; + print ''; - print $langs->trans("DetailBatchFormat", dol_print_date($dbatch->eatby,"day"), dol_print_date($dbatch->sellby,"day"), $dbatch->batch, $dbatch->qty); + print $langs->trans("DetailBatchFormat", $dbatch->batch, dol_print_date($dbatch->eatby,"day"), dol_print_date($dbatch->sellby,"day"), $dbatch->qty); if ($defaultqty<=0) { $defaultqty=0; } else { @@ -1451,12 +1479,14 @@ else if ($id || $ref) } // Batch number managment - if (! empty($conf->productbatch->enabled)) { - if (isset($lines[$i]->detail_batch) ) { - print ''; + if (! empty($conf->productbatch->enabled)) + { + if (isset($lines[$i]->detail_batch)) + { + print ''; $detail = ''; foreach ($lines[$i]->detail_batch as $dbatch) { - $detail.= $langs->trans("DetailBatchFormat",dol_print_date($dbatch->eatby,"day"),dol_print_date($dbatch->sellby,"day"),$dbatch->batch,$dbatch->dluo_qty).'
'; + $detail.= $langs->trans("DetailBatchFormat",$dbatch->batch,dol_print_date($dbatch->eatby,"day"),dol_print_date($dbatch->sellby,"day"),$dbatch->dluo_qty).'
'; } print $form->textwithtooltip($langs->trans("DetailBatchNumber"),$detail); print ''; diff --git a/htdocs/expedition/index.php b/htdocs/expedition/index.php index e3cb8305562..2b41a939c7b 100644 --- a/htdocs/expedition/index.php +++ b/htdocs/expedition/index.php @@ -114,7 +114,7 @@ if ($resql) /* * Commandes a traiter */ -$sql = "SELECT c.rowid, c.ref, s.nom as name, s.rowid as socid"; +$sql = "SELECT c.rowid, c.ref, c.fk_statut, s.nom as name, s.rowid as socid"; $sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -136,7 +136,7 @@ if ($resql) $i = 0; print ''; print ''; - print ''; + print ''; $var = True; while ($i < $num) { @@ -146,13 +146,19 @@ if ($resql) print ''; print ''; + print ''; + print ''; + print ''; $i++; } print "
'.$langs->trans("OrdersToProcess").'
'.$langs->trans("OrdersToProcess").'
'; $orderstatic->id=$obj->rowid; $orderstatic->ref=$obj->ref; + $orderstatic->statut=$obj->fk_statut; + $orderstatic->facturee=0; print $orderstatic->getNomUrl(1); print ''; $companystatic->name=$obj->name; $companystatic->id=$obj->socid; print $companystatic->getNomUrl(1,'customer',32); - print '
'; + print $orderstatic->getLibStatut(3); + print '

"; diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index f1be4b07021..bce365447e1 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -643,7 +643,10 @@ if ($id > 0 || ! empty($ref)) if (! empty($conf->stock->enabled)) { - print ''.$langs->trans("WarehouseSource").''; + $warehousecanbeselectedlater=1; + if (! empty($conf->productbatch->enabled)) $warehousecanbeselectedlater=0; + + print ''.$langs->trans("WarehouseSource").''; print ''; print $formproduct->selectWarehouses(-1,'entrepot_id','',1); if (count($formproduct->cache_warehouses) <= 0) diff --git a/htdocs/langs/en_US/productbatch.lang b/htdocs/langs/en_US/productbatch.lang index 3bc492db8e2..658258af128 100644 --- a/htdocs/langs/en_US/productbatch.lang +++ b/htdocs/langs/en_US/productbatch.lang @@ -10,10 +10,11 @@ batch_number=Batch/Serial number l_eatby=Eat-by date l_sellby=Sell-by date DetailBatchNumber=Batch/Serial details -DetailBatchFormat=E:%s S: %s BATCH: %s (Qty : %d) +DetailBatchFormat=Batch/Serial: %s - E:%s - S: %s (Qty : %d) printBatch=Batch: %s printEatby=Eat-by: %s printSellby=Sell-by: %s printQty=Qty: %d AddDispatchBatchLine=Add a line for Shelf Life dispatching -BatchDefaultNumber=Undefined \ No newline at end of file +BatchDefaultNumber=Undefined +WhenProductBatchModuleOnOptionAreForced=When module Batch/Serial is on, increase/decrease stock mode is forced to last choice and can't be edited. Other options can be defined as you want. \ No newline at end of file diff --git a/htdocs/langs/fr_FR/productbatch.lang b/htdocs/langs/fr_FR/productbatch.lang index 68e76dca46b..83f37508b8d 100644 --- a/htdocs/langs/fr_FR/productbatch.lang +++ b/htdocs/langs/fr_FR/productbatch.lang @@ -10,7 +10,7 @@ batch_number= Numéro de lot l_eatby= DLC l_sellby= DLUO DetailBatchNumber= Détails des lots -DetailBatchFormat= C:%s UO: %s LOT: %s (Qté : %d) +DetailBatchFormat= Lot/Serie: %s - C:%s - UO: %s (Qté : %d) printBatch= Lot: %s printEatby= DLC: %s printSellby= DLUO: %s diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 7cfb6441c06..057aecc6847 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1122,7 +1122,7 @@ else // Batch number managment if ($conf->productbatch->enabled) { - print ''.$langs->trans("ManageLotSerial").''; + print ''.$langs->trans("ManageLotSerial").''; $statutarray=array('0' => $langs->trans("ProductStatusNotOnBatch"), '1' => $langs->trans("ProductStatusOnBatch")); print $form->selectarray('status_batch',$statutarray,$object->status_batch); print '';