From a0f1a60780be54caa61daac028e186fa2a9d9323 Mon Sep 17 00:00:00 2001 From: KreizIT Date: Fri, 7 Mar 2014 11:35:16 +0100 Subject: [PATCH] Change on shipment for batch product --- htdocs/core/lib/pdf.lib.php | 16 ++ htdocs/expedition/class/expedition.class.php | 88 +++++++- .../class/expeditionbatch.class.php | 212 ++++++++++++++++++ htdocs/expedition/fiche.php | 118 ++++++++-- htdocs/langs/en_US/productbatch.lang | 6 + htdocs/langs/fr_FR/productbatch.lang | 6 + 6 files changed, 428 insertions(+), 18 deletions(-) create mode 100644 htdocs/expedition/class/expeditionbatch.class.php diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 90d685e80a8..f0da47862d7 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -5,6 +5,7 @@ * Copyright (C) 2010-2012 Regis Houssin * Copyright (C) 2010 Juanjo Menent * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2014 Cedric GROSS * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -946,6 +947,7 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl $desc=(! empty($object->lines[$i]->desc)?$object->lines[$i]->desc:(! empty($object->lines[$i]->description)?$object->lines[$i]->description:'')); $ref_supplier=(! empty($object->lines[$i]->ref_supplier)?$object->lines[$i]->ref_supplier:(! empty($object->lines[$i]->ref_fourn)?$object->lines[$i]->ref_fourn:'')); // TODO Not yet saved for supplier invoices, only supplier orders $note=(! empty($object->lines[$i]->note)?$object->lines[$i]->note:''); + $dbatch=(! empty($object->lines[$i]->detail_batch)?$object->lines[$i]->detail_batch:false); if ($issupplierline) $prodser = new ProductFournisseur($db); else $prodser = new Product($db); @@ -1079,6 +1081,20 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl //print $libelleproduitservice; } + if ($dbatch) + { + $format='day'; + foreach ($dbatch as $detail) + { + $dte=array(); + if ($detail->eatby) $dte[]=$outputlangs->transnoentitiesnoconv('printEatby',dol_print_date($detail->eatby, $format, false, $outputlangs)); + if ($detail->sellby) $dte[]=$outputlangs->transnoentitiesnoconv('printSellby',dol_print_date($detail->sellby, $format, false, $outputlangs)); + if ($detail->batch) $dte[]=$outputlangs->transnoentitiesnoconv('printBatch',$detail->batch); + $dte[]=$outputlangs->transnoentitiesnoconv('printQty',$detail->dluo_qty); + $libelleproduitservice.= "__N__ ".implode($dte,"-"); + } + } + // Now we convert \n into br if (dol_textishtml($libelleproduitservice)) $libelleproduitservice=preg_replace('/__N__/','
',$libelleproduitservice); else $libelleproduitservice=preg_replace('/__N__/',"\n",$libelleproduitservice); diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 136063d4552..8c103603fbe 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -5,6 +5,7 @@ * Copyright (C) 2006-2012 Laurent Destailleur * Copyright (C) 2011-2013 Juanjo Menent * Copyright (C) 2013 Florian Henry + * Copyright (C) 2014 Cedric GROSS * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,6 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +if (! empty($conf->productbatch->enabled)) require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php'; /** @@ -241,10 +243,17 @@ class Expedition extends CommonObject $num=count($this->lines); for ($i = 0; $i < $num; $i++) { + if (! isset($this->lines[$i]->detail_batch)) { if (! $this->create_line($this->lines[$i]->entrepot_id, $this->lines[$i]->origin_line_id, $this->lines[$i]->qty) > 0) { $error++; } + } else { + if (! $this->create_line_ext($this->lines[$i]) > 0) + { + $error++; + } + } } if (! $error && $this->id && $this->origin_id) @@ -333,6 +342,31 @@ class Expedition extends CommonObject if (! $error) return 1; else return -1; } + /** + * Create a expedition line with eat-by date + * + * @param object $line_ext full line informations + * @return int <0 if KO, >0 if OK + */ + function create_line_ext($line_ext) + { + $error = 0; + + if ( $this->create_line(($line_ext->entrepot_id?$line_ext->entrepot_id:'null'),$line_ext->origin_line_id,$line_ext->qty)<0) + { + $error++; + } else { + $line_id= $this->db->last_insert_id(MAIN_DB_PREFIX."expeditiondet"); + $tab=$line_ext->detail_batch; + foreach ($tab as $detbatch) { + if (! ($detbatch->create($line_id) >0)) { + $error++; + } + } + } + if (! $error) return 1; + else return -1; + } /** * Get object and lines from database @@ -528,7 +562,7 @@ class Expedition extends CommonObject // Loop on each product line to add a stock movement // TODO possibilite d'expedier a partir d'une propale ou autre origine - $sql = "SELECT cd.fk_product, cd.subprice, ed.qty, ed.fk_entrepot"; + $sql = "SELECT cd.fk_product, cd.subprice, ed.qty, ed.fk_entrepot, ed.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd,"; $sql.= " ".MAIN_DB_PREFIX."expeditiondet as ed"; $sql.= " WHERE ed.fk_expedition = ".$this->id; @@ -550,6 +584,14 @@ class Expedition extends CommonObject // We use warehouse selected for each line $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr",$numref)); if ($result < 0) { $error++; break; } + + if (! empty($conf->productbatch->enabled)) { + $details=ExpeditionLigneBatch::FetchAll($this->db,$obj->rowid); + foreach ($details as $dbatch) { + $result=$mouvS->livraison_batch($dbatch->fk_origin_stock,$dbatch->dluo_qty); + if ($result < 0) { $error++; $this->errors[]=$mouvS->$error; break 2; } + } + } } } else @@ -678,6 +720,38 @@ class Expedition extends CommonObject $this->lines[$num] = $line; } + /** + * Add a shipment line with batch record + * + * @param array $dbatch Array of value (key 'detail' -> Array, key 'qty' total quantity for line, key ix_l : original line index) + * @return int <0 if KO, >0 if OK + */ + function addline_batch($dbatch) + { + $num = count($this->lines); + if ($dbatch['qty']>0) { + $line = new ExpeditionLigne($this->db); + $tab=array(); + foreach ($dbatch['detail'] as $key=>$value) { + if ($value['q']>0) { + $linebatch = new ExpeditionLigneBatch($this->db); + $ret=$linebatch->fetchFromStock($value['id_batch']); + if ($ret<0) { + $this->error=$linebatch->error; + return -1; + } + $linebatch->dluo_qty=$value['q']; + $tab[]=$linebatch; + } + } + $line->entrepot_id = $linebatch->entrepot_id; + $line->origin_line_id = $dbatch['ix_l']; + $line->qty = $dbatch['qty']; + $line->detail_batch=$tab; + $this->lines[$num] = $line; + } + } + /** * Update database * @@ -798,6 +872,10 @@ class Expedition extends CommonObject $this->db->begin(); + if ($conf->productbatch->enabled) { + if ( ExpeditionLignebatch::deletefromexp($this->db,$this->id)<0) + {$error++;$this->errors[]="Error ".$this->db->lasterror();} + } // Stock control if ($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SHIPMENT && $this->statut > 0) { @@ -928,6 +1006,7 @@ class Expedition extends CommonObject */ function fetch_lines() { + global $conf; // TODO: recuperer les champs du document associe a part $sql = "SELECT cd.rowid, cd.fk_product, cd.label as custom_label, cd.description, cd.qty as qty_asked"; @@ -935,7 +1014,7 @@ class Expedition extends CommonObject $sql.= ", cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx, cd.price, cd.subprice, cd.remise_percent"; $sql.= ", ed.qty as qty_shipped, ed.fk_origin_line, ed.fk_entrepot"; $sql.= ", p.ref as product_ref, p.label as product_label, p.fk_product_type"; - $sql.= ", p.weight, p.weight_units, p.length, p.length_units, p.surface, p.surface_units, p.volume, p.volume_units"; + $sql.= ", p.weight, p.weight_units, p.length, p.length_units, p.surface, p.surface_units, p.volume, p.volume_units, ed.rowid as line_id"; $sql.= " FROM (".MAIN_DB_PREFIX."expeditiondet as ed,"; $sql.= " ".MAIN_DB_PREFIX."commandedet as cd)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = cd.fk_product"; @@ -1006,6 +1085,10 @@ class Expedition extends CommonObject $this->total_localtax1+= $tabprice[9]; $this->total_localtax2+= $tabprice[10]; + // Eat-by date + if (! empty($conf->productbatch->enabled)) { + $line->detail_batch=ExpeditionLigneBatch::FetchAll($this->db,$obj->line_id); + } $this->lines[$i] = $line; $i++; @@ -1412,6 +1495,7 @@ class ExpeditionLigne var $qty; var $qty_shipped; var $fk_product; + var $detail_batch; // From llx_commandedet or llx_propaldet var $qty_asked; diff --git a/htdocs/expedition/class/expeditionbatch.class.php b/htdocs/expedition/class/expeditionbatch.class.php new file mode 100644 index 00000000000..9721db2eeb6 --- /dev/null +++ b/htdocs/expedition/class/expeditionbatch.class.php @@ -0,0 +1,212 @@ + + * Copyright (C) 2013-2014 Cedric GROSS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file expedtion/class/productbatch.class.php + * \ingroup productbatch + * \brief This file implements CRUD method for managing product's shipment + * with batch record + */ + +class ExpeditionLigneBatch extends CommonObject +{ + var $element='expeditionlignebatch'; //!< Id that identify managed objects + private static $_table_element='expeditiondet_batch'; //!< Name of table without prefix where object is stored + + var $id; + var $sellby=''; + var $eatby=''; + var $batch=''; + var $dluo_qty; + var $entrepot_id; + var $fk_origin_stock; + var $fk_expeditiondet; + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + function __construct($db) + { + $this->db = $db; + return 1; + } + + /** + * Fill object based on a product-warehouse-batch's record + * + * @param int $id_stockdluo Rowid in product_batch table + * @return int -1 if KO, 1 if OK + */ + function fetchFromStock($id_stockdluo) { + $sql = "SELECT"; + $sql.= " t.sellby,"; + $sql.= " t.eatby,"; + $sql.= " t.batch,"; + $sql.= " e.fk_entrepot"; + + $sql.= " FROM ".MAIN_DB_PREFIX."product_batch as t inner join "; + $sql.= MAIN_DB_PREFIX."product_stock as e on t.fk_product_stock=e.rowid "; + $sql.= " WHERE t.rowid = ".(int) $id_stockdluo; + + dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); + + $this->sellby = $this->db->jdate($obj->sellby); + $this->eatby = $this->db->jdate($obj->eatby); + $this->batch = $obj->batch; + $this->entrepot_id= $obj->fk_entrepot; + $this->fk_origin_stock=(int)$id_stockdluo; + + } + $this->db->free($resql); + + return 1; + } + else + { + $this->error="Error ".$this->db->lasterror(); + dol_syslog(__METHOD__ .$this->error, LOG_ERR); + return -1; + } + } + + /** + * Create an expeditiondet_batch DB record link to an expedtiondet record + * + * @param int $id_line_expdet rowid of expedtiondet record + * @return int <0 if KO, Id of record (>0) if OK + */ + function create($id_line_expdet) { + $id_line_expdet = (int) $id_line_expdet; + + $sql = "INSERT INTO ".MAIN_DB_PREFIX.self::$_table_element." ("; + $sql.= "fk_expeditiondet"; + $sql.= ", sellby"; + $sql.= ", eatby"; + $sql.= ", batch"; + $sql.= ", qty"; + $sql.= ", fk_origin_stock"; + $sql.= ") VALUES ("; + $sql.= $id_line_expdet.","; + $sql.= " ".(! isset($this->sellby) || dol_strlen($this->sellby)==0?'NULL':$this->db->idate($this->sellby)).","; + $sql.= " ".(! isset($this->eatby) || dol_strlen($this->eatby)==0?'NULL':$this->db->idate($this->eatby)).","; + $sql.= " ".(! isset($this->batch)?'NULL':"'".$this->db->escape($this->batch)."'").","; + $sql.= " ".(! isset($this->dluo_qty)?'NULL':$this->dluo_qty).","; + $sql.= " ".(! isset($this->fk_origin_stock)?'NULL':$this->fk_origin_stock); + $sql.= ")"; + + dol_syslog(__METHOD__ ." sql=".$sql, LOG_DEBUG); + $resql=$this->db->query($sql); + + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + + if (! $error){ + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.self::$_table_element); + $this->fk_expeditiondet=$id_line_expdet; + return $this->id; + } else { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + } + + /** + * Delete batch record attach to a shipment + * + * @param object $db Database object + * @param int $id_expedtion rowid of shipment + * + * @return int -1 if KO, 1 if OK + */ + static function deletefromexp($db,$id_expedition) { + $id_expedition = (int) $id_expedition; + + $sql="DELETE FROM ".MAIN_DB_PREFIX.self::$_table_element; + $sql.=" WHERE fk_expeditiondet in (SELECT rowid FROM ".MAIN_DB_PREFIX."expeditiondet WHERE fk_expedition=".$id_expedition.")"; + + dol_syslog(__METHOD__ ." sql=".$sql, LOG_DEBUG); + if ( $db->query($sql) ) + { + return 1; + } else { + return -1; + } + } + + /** + * Retrieve all batch number details link to a shipment line + * + * @param object $db Database object + * @param int $id_line_expdet id of shipment line + * + * @return variant -1 if KO, array of ExpeditionLigneBatch if OK + */ + static function FetchAll($db,$id_line_expdet) { + $sql="SELECT rowid,"; + $sql.= "fk_expeditiondet"; + $sql.= ", sellby"; + $sql.= ", eatby"; + $sql.= ", batch"; + $sql.= ", qty"; + $sql.= ", fk_origin_stock"; + $sql.= " FROM ".MAIN_DB_PREFIX.self::$_table_element; + $sql.= " WHERE fk_expeditiondet=".(int) $id_line_expdet; + + dol_syslog(__METHOD__ ." sql=".$sql, LOG_DEBUG); + $resql=$db->query($sql); + if ($resql) + { + $num=$db->num_rows($resql); + $i=0; + while ($i<$num) { + $tmp=new self($db); + + $obj = $db->fetch_object($resql); + + $tmp->sellby = $db->jdate($obj->sellby); + $tmp->eatby = $db->jdate($obj->eatby); + $tmp->batch = $obj->batch; + $tmp->id = $obj->rowid; + $tmp->fk_origin_stock = $obj->fk_origin_stock; + $tmp->fk_expeditiondet = $obj->fk_expeditiondet; + $tmp->dluo_qty = $obj->qty; + + $ret[]=$tmp; + $i++; + } + $db->free($resql); + return $ret; + } else { + return -1; + } + } + +} +?> diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index c04c4966efe..bfc444faf56 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -6,6 +6,7 @@ * Copyright (C) 2011-2012 Juanjo Menent * Copyright (C) 2013 Florian Henry * Copyright (C) 2013 Marcos García + * Copyright (C) 2014 Cedric GROSS * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -39,6 +40,7 @@ if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) requi if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; if (! empty($conf->stock->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; +if (! empty($conf->productbatch->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; $langs->load("sendings"); $langs->load("companies"); @@ -48,6 +50,7 @@ $langs->load('orders'); $langs->load('stocks'); $langs->load('other'); $langs->load('propal'); +if (! empty($conf->productbatch->enabled)) $langs->load('productbatch'); $origin = GETPOST('origin','alpha')?GETPOST('origin','alpha'):'expedition'; // Example: commande, propal $origin_id = GETPOST('id','int')?GETPOST('id','int'):''; @@ -126,7 +129,31 @@ if ($action == 'add') for ($i = 0; $i < $num; $i++) { $qty = "qtyl".$i; - if (GETPOST($qty,'int') > 0) $totalqty+=GETPOST($qty,'int'); + $j=0; + $sub_qty=array(); + $subtotalqty=0; + $idl="idl".$i; + $batch="batchl".$i."_0"; + if (isset($_POST[$batch])) { + //shipment line with batch-enable product + $qty .= '_'.$j; + while (isset($_POST[$batch])) { + $sub_qty[$j]['q']=GETPOST($qty,'int'); + $sub_qty[$j]['id_batch']=GETPOST($batch,'int'); + $subtotalqty+=$sub_qty[$j]['q']; + $j++; + $batch="batchl".$i."_".$j; + $qty = "qtyl".$i.'_'.$j; + + } + $batch_line[$i]['detail']=$sub_qty; + $batch_line[$i]['qty']=$subtotalqty; + $batch_line[$i]['ix_l']=GETPOST($idl,'int'); + $totalqty+=$subtotalqty; + } else { + //Standard product + if (GETPOST($qty,'int') > 0) $totalqty+=GETPOST($qty,'int'); + } } if ($totalqty > 0) @@ -135,20 +162,31 @@ if ($action == 'add') for ($i = 0; $i < $num; $i++) { $qty = "qtyl".$i; - if (GETPOST($qty,'int') > 0) - { - $ent = "entl".$i; - $idl = "idl".$i; - $entrepot_id = is_numeric(GETPOST($ent,'int'))?GETPOST($ent,'int'):GETPOST('entrepot_id','int'); - if ($entrepot_id < 0) $entrepot_id=''; + if (! isset($batch_line[$i])) { + if (GETPOST($qty,'int') > 0) + { + $ent = "entl".$i; + $idl = "idl".$i; + $entrepot_id = is_numeric(GETPOST($ent,'int'))?GETPOST($ent,'int'):GETPOST('entrepot_id','int'); + if ($entrepot_id < 0) $entrepot_id=''; - $ret=$object->addline($entrepot_id,GETPOST($idl,'int'),GETPOST($qty,'int')); - if ($ret < 0) - { - $mesg='
'.$object->error.'
'; - $error++; - } - } + $ret=$object->addline($entrepot_id,GETPOST($idl,'int'),GETPOST($qty,'int')); + if ($ret < 0) + { + $mesg='
'.$object->error.'
'; + $error++; + } + } + } else { + if ($batch_line[$i]['qty']>0) { + $ret=$object->addline_batch($batch_line[$i]); + if ($ret < 0) + { + $mesg='
'.$object->error.'
'; + $error++; + } + } + } } if (! $error) @@ -653,7 +691,7 @@ if ($action == 'create') print ''; $expe->fetch_delivery_methods(); print $form->selectarray("shipping_method_id",$expe->meths,GETPOST('shipping_method_id','int'),1,0,0,"",1); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); print "\n"; // Tracking number @@ -711,12 +749,18 @@ if ($action == 'create') print ''.$langs->trans("QtyOrdered").''; print ''.$langs->trans("QtyShipped").''; print ''.$langs->trans("QtyToShip"); + if (empty($conf->productbatch->enabled)) { print '
('.$langs->trans("Fill").''; print ' / '.$langs->trans("Reset").')'; + } 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").''; + } } print "\n"; } @@ -812,6 +856,7 @@ if ($action == 'create') if (($line->product_type == 1 && empty($conf->global->STOCK_SUPPORTS_SERVICES)) || $defaultqty < 0) $defaultqty=0; } + if (empty($conf->productbatch->enabled) || ! $product->hasbatch()) { // Quantity to send print ''; if ($line->product_type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) @@ -873,6 +918,28 @@ if ($action == 'create') } } } + } else { + print ''; + $subj=0; + print ''; + foreach ($product->stock_warehouse[GETPOST('entrepot_id','int')]->detail_batch as $dbatch) { + //var_dump($dbatch); + $substock=$dbatch->qty +0 ; + print ''; + print ''; + print ''; + + print ''; + print ''; + print $langs->trans("DetailBatchFormat", dol_print_date($dbatch->eatby,"day"), dol_print_date($dbatch->sellby,"day"), $dbatch->batch, $dbatch->qty); + if ($defaultqty<=0) { + $defaultqty=0; + } else { + $defaultqty -=min($defaultqty,$substock); + } + $subj++; + } + } $indiceAsked++; } @@ -1152,7 +1219,7 @@ else if ($id || $ref) print ''; $object->fetch_delivery_methods(); print $form->selectarray("shipping_method_id",$object->meths,$object->shipping_method_id,1,0,0,"",1); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); print ''; print ''; } @@ -1208,6 +1275,11 @@ else if ($id || $ref) print ''.$langs->trans("WarehouseSource").''; } + if (! empty($conf->productbatch->enabled)) + { + print ''.$langs->trans("Batch").''; + } + print "\n"; $var=false; @@ -1315,6 +1387,20 @@ else if ($id || $ref) print ''; } + // Batch number managment + 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).'
'; + } + print $form->textwithtooltip($langs->trans("DetailBatchNumber"),$detail); + print ''; + } else { + print ''; + } + } print ""; $var=!$var; diff --git a/htdocs/langs/en_US/productbatch.lang b/htdocs/langs/en_US/productbatch.lang index 0d530722306..863506e0e57 100644 --- a/htdocs/langs/en_US/productbatch.lang +++ b/htdocs/langs/en_US/productbatch.lang @@ -9,3 +9,9 @@ atleast1batchfield= Eat-by date or Sell-by date or Batch number batch_number= Batch number l_eatby= Eat-by date l_sellby= Sell-by date +DetailBatchNumber= Batch details +DetailBatchFormat= E:%s S: %s BATCH: %s (Qty : %d) +printBatch= Batch: %s +printEatby= Eat-by: %s +printSellby= Sell-by: %s +printQty= Qty: %d diff --git a/htdocs/langs/fr_FR/productbatch.lang b/htdocs/langs/fr_FR/productbatch.lang index 0954e74ef16..081ea1ba291 100644 --- a/htdocs/langs/fr_FR/productbatch.lang +++ b/htdocs/langs/fr_FR/productbatch.lang @@ -9,4 +9,10 @@ atleast1batchfield= DLC ou DLUO ou Numéro de lot 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) +printBatch= Lot: %s +printEatby= DLC: %s +printSellby= DLUO: %s +printQty= Qté: %d