Fix: Maxi debug of module productbatch.

This commit is contained in:
Laurent Destailleur 2014-12-05 16:01:01 +01:00
parent 6729544782
commit 5457d3116a
9 changed files with 130 additions and 71 deletions

View File

@ -113,35 +113,20 @@ $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToM
print_fiche_titre($langs->trans("StockSetup"),$linkback,'setup');
$form=new Form($db);
$var=true;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print " <td>".$langs->trans("Parameters")."</td>\n";
print " <td align=\"right\" width=\"160\">&nbsp;</td>\n";
print '</tr>'."\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 "<tr ".$bc[$var].">";
print '<td width="60%">'.$langs->trans("UserWarehouseAutoCreate").'</td>';
print '<td width="160" align="right">';
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_USERSTOCK_AUTOCREATE\">";
print $form->selectyesno("STOCK_USERSTOCK_AUTOCREATE",$conf->global->STOCK_USERSTOCK_AUTOCREATE,1);
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</form>';
print "</td>\n";
print "</tr>\n";
print '<br>';
print '</table>';
print '<br>';
//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 '<table class="noborder" width="100%">';
@ -160,8 +145,8 @@ if (! empty($conf->facture->enabled))
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_BILL\">";
print $form->selectyesno("STOCK_CALCULATE_ON_BILL",$conf->global->STOCK_CALCULATE_ON_BILL,1);
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print $form->selectyesno("STOCK_CALCULATE_ON_BILL",$conf->global->STOCK_CALCULATE_ON_BILL,1,$disabled);
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"'.$disabled.'>';
print "</form>\n</td>\n</tr>\n";
}
@ -174,8 +159,8 @@ if (! empty($conf->commande->enabled))
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_VALIDATE_ORDER\">";
print $form->selectyesno("STOCK_CALCULATE_ON_VALIDATE_ORDER",$conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER,1);
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print $form->selectyesno("STOCK_CALCULATE_ON_VALIDATE_ORDER",$conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER,1,$disabled);
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"'.$disabled.'>';
print "</form>\n</td>\n</tr>\n";
}
@ -188,16 +173,12 @@ if (! empty($conf->expedition->enabled))
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_SHIPMENT\">";
print $form->selectyesno("STOCK_CALCULATE_ON_SHIPMENT",$conf->global->STOCK_CALCULATE_ON_SHIPMENT,1);
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print $form->selectyesno("STOCK_CALCULATE_ON_SHIPMENT",$conf->global->STOCK_CALCULATE_ON_SHIPMENT,1,$disabled);
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"'.$disabled.'>';
print "</form>\n</td>\n</tr>\n";
}
print '</table>';
//if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) || ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT))
//{
print info_admin($langs->trans("IfYouUsePointOfSaleCheckModule"));
//}
print '<br>';
// Title rule for stock increase
@ -217,8 +198,8 @@ if (! empty($conf->fournisseur->enabled))
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_SUPPLIER_BILL\">";
print $form->selectyesno("STOCK_CALCULATE_ON_SUPPLIER_BILL",$conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL,1);
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print $form->selectyesno("STOCK_CALCULATE_ON_SUPPLIER_BILL",$conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL,1,$disabled);
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"'.$disabled.'>';
print "</form>\n</td>\n</tr>\n";
}
@ -231,8 +212,8 @@ if (! empty($conf->fournisseur->enabled))
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER\">";
print $form->selectyesno("STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER",$conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER,1);
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print $form->selectyesno("STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER",$conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER,1,$disabled);
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"'.$disabled.'>';
print "</form>\n</td>\n</tr>\n";
}
if (! empty($conf->fournisseur->enabled))
@ -244,8 +225,8 @@ if (! empty($conf->fournisseur->enabled))
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER\">";
print $form->selectyesno("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER",$conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER,1);
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print $form->selectyesno("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER",$conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER,1,$disabled);
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"'.$disabled.'>';
print "</form>\n</td>\n</tr>\n";
}
@ -334,6 +315,34 @@ if ($virtualdiffersfromphysical)
print '</table>';
}
$var=true;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print " <td>".$langs->trans("Other")."</td>\n";
print " <td align=\"right\" width=\"160\">&nbsp;</td>\n";
print '</tr>'."\n";
$var=!$var;
print "<tr ".$bc[$var].">";
print '<td width="60%">'.$langs->trans("UserWarehouseAutoCreate").'</td>';
print '<td width="160" align="right">';
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_USERSTOCK_AUTOCREATE\">";
print $form->selectyesno("STOCK_USERSTOCK_AUTOCREATE",$conf->global->STOCK_USERSTOCK_AUTOCREATE,1);
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</form>';
print "</td>\n";
print "</tr>\n";
print '<br>';
print '</table>';
print '<br>';
llxFooter();
$db->close();

View File

@ -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;

View File

@ -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

View File

@ -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='<div class="error">'.$langs->trans("ErrorBadParameters").'</div>';
setEventMessage($langs->trans("ErrorBadParameters"),'errors');
}
dol_htmloutput_mesg($mesg);
@ -771,10 +786,13 @@ if ($action == 'create')
print '</td>';
if (! empty($conf->stock->enabled))
{
if (empty($conf->productbatch->enabled)) {
print '<td align="left">'.$langs->trans("Warehouse").' / '.$langs->trans("Stock").'</td>';
} else {
print '<td align="left">'.$langs->trans("Warehouse").' / '.$langs->trans("Batch").' / '.$langs->trans("Stock").'</td>';
if (empty($conf->productbatch->enabled))
{
print '<td align="left">'.$langs->trans("Warehouse").' ('.$langs->trans("Stock").')</td>';
}
else
{
print '<td align="left">'.$langs->trans("Warehouse").' / '.$langs->trans("Batch").' ('.$langs->trans("Stock").')</td>';
}
}
print "</tr>\n";
@ -828,7 +846,7 @@ if ($action == 'create')
print '</td>';
}
else
{
{
print "<td>";
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 '<td align="center">';
@ -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 '<td></td><td></td></tr>';
$subj=0;
print '<input name="idl'.$indiceAsked.'" type="hidden" value="'.$line->id.'">';
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 '<tr><td colspan="3" ></td><td align="center">';
@ -946,8 +969,13 @@ if ($action == 'create')
print '</td>';
print '<td align="left">';
$staticwarehouse=new Entrepot($db);
$staticwarehouse->fetch($warehouse_id);
print $staticwarehouse->getNomUrl(0).' / ';
print '<input name="batchl'.$indiceAsked.'_'.$subj.'" type="hidden" value="'.$dbatch->id.'">';
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 '<td align="center">';
if (! empty($conf->productbatch->enabled))
{
if (isset($lines[$i]->detail_batch))
{
print '<td>';
$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).'<br/>';
$detail.= $langs->trans("DetailBatchFormat",$dbatch->batch,dol_print_date($dbatch->eatby,"day"),dol_print_date($dbatch->sellby,"day"),$dbatch->dluo_qty).'<br/>';
}
print $form->textwithtooltip($langs->trans("DetailBatchNumber"),$detail);
print '</td>';

View File

@ -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 '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="2">'.$langs->trans("OrdersToProcess").'</td></tr>';
print '<td colspan="3">'.$langs->trans("OrdersToProcess").'</td></tr>';
$var = True;
while ($i < $num)
{
@ -146,13 +146,19 @@ if ($resql)
print '<td class="nowrap">';
$orderstatic->id=$obj->rowid;
$orderstatic->ref=$obj->ref;
$orderstatic->statut=$obj->fk_statut;
$orderstatic->facturee=0;
print $orderstatic->getNomUrl(1);
print '</td>';
print '<td>';
$companystatic->name=$obj->name;
$companystatic->id=$obj->socid;
print $companystatic->getNomUrl(1,'customer',32);
print '</td></tr>';
print '</td>';
print '<td align="right">';
print $orderstatic->getLibStatut(3);
print '</td>';
print '</tr>';
$i++;
}
print "</table><br>";

View File

@ -643,7 +643,10 @@ if ($id > 0 || ! empty($ref))
if (! empty($conf->stock->enabled))
{
print '<td>'.$langs->trans("WarehouseSource").'</td>';
$warehousecanbeselectedlater=1;
if (! empty($conf->productbatch->enabled)) $warehousecanbeselectedlater=0;
print '<td'.($warehousecanbeselectedlater?'':' class="fieldrequired"').'>'.$langs->trans("WarehouseSource").'</td>';
print '<td>';
print $formproduct->selectWarehouses(-1,'entrepot_id','',1);
if (count($formproduct->cache_warehouses) <= 0)

View File

@ -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
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.

View File

@ -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

View File

@ -1122,7 +1122,7 @@ else
// Batch number managment
if ($conf->productbatch->enabled) {
print '<tr><td>'.$langs->trans("ManageLotSerial").'</td><td colspan="2">';
print '<tr><td>'.$langs->trans("ManageLotSerial").'</td><td colspan="3">';
$statutarray=array('0' => $langs->trans("ProductStatusNotOnBatch"), '1' => $langs->trans("ProductStatusOnBatch"));
print $form->selectarray('status_batch',$statutarray,$object->status_batch);
print '</td></tr>';