From a0f1a60780be54caa61daac028e186fa2a9d9323 Mon Sep 17 00:00:00 2001 From: KreizIT Date: Fri, 7 Mar 2014 11:35:16 +0100 Subject: [PATCH 01/21] 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 From f0be1f7c21ddc2a0f3e5cde1adff60c079ad615d Mon Sep 17 00:00:00 2001 From: KreizIT Date: Fri, 7 Mar 2014 11:51:26 +0100 Subject: [PATCH 02/21] Fix: Typo on class name --- htdocs/expedition/class/expedition.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 8c103603fbe..914ec871951 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -873,7 +873,7 @@ class Expedition extends CommonObject $this->db->begin(); if ($conf->productbatch->enabled) { - if ( ExpeditionLignebatch::deletefromexp($this->db,$this->id)<0) + if ( ExpeditionLigneBatch::deletefromexp($this->db,$this->id)<0) {$error++;$this->errors[]="Error ".$this->db->lasterror();} } // Stock control From 18e4703438a52385ca2d64c8f2ab6d7b43c43ab4 Mon Sep 17 00:00:00 2001 From: KreizIT Date: Fri, 7 Mar 2014 12:21:35 +0100 Subject: [PATCH 03/21] Travis fix --- htdocs/expedition/class/expeditionbatch.class.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/expedition/class/expeditionbatch.class.php b/htdocs/expedition/class/expeditionbatch.class.php index 9721db2eeb6..cf57929ca0f 100644 --- a/htdocs/expedition/class/expeditionbatch.class.php +++ b/htdocs/expedition/class/expeditionbatch.class.php @@ -23,6 +23,10 @@ * with batch record */ + /** + * CRUD class for batch number management within shipment + */ + class ExpeditionLigneBatch extends CommonObject { var $element='expeditionlignebatch'; //!< Id that identify managed objects @@ -77,7 +81,7 @@ class ExpeditionLigneBatch extends CommonObject $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->fk_origin_stock=(int) $id_stockdluo; } $this->db->free($resql); @@ -141,7 +145,7 @@ class ExpeditionLigneBatch extends CommonObject * Delete batch record attach to a shipment * * @param object $db Database object - * @param int $id_expedtion rowid of shipment + * @param int $id_expedition rowid of shipment * * @return int -1 if KO, 1 if OK */ From 096a446b7fcfe221613b0f350d8fa60eceb240db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Tue, 11 Mar 2014 11:15:15 +0100 Subject: [PATCH 04/21] Changed style of contract creation form to the 3.5 style --- htdocs/contrat/fiche.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index 59a23bebd91..59ed152de77 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -767,7 +767,7 @@ $objectlignestatic=new ContratLigne($db); *********************************************************************/ if ($action == 'create') { - dol_fiche_head('', '', $langs->trans("AddContract"), 0, 'contract'); + print_fiche_titre($langs->trans('AddContract')); dol_htmloutput_errors($mesg,''); From 371f0cbb8ec433939b157ddce0fd2cf36d50140a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Tue, 11 Mar 2014 11:15:35 +0100 Subject: [PATCH 05/21] Fixed module name in contract admin setup page --- htdocs/admin/contract.php | 2 +- htdocs/contrat/admin/contract_extrafields.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index b059fa34bec..00f6c7af825 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -204,7 +204,7 @@ print "
"; $head=contract_admin_prepare_head(); -dol_fiche_head($head, 'contract', $langs->trans("ModuleSetup")); +dol_fiche_head($head, 'contract', $langs->trans("Contracts"), 0, 'contract'); /* * Contracts Numbering model diff --git a/htdocs/contrat/admin/contract_extrafields.php b/htdocs/contrat/admin/contract_extrafields.php index c50872beee4..e6fa44e5594 100644 --- a/htdocs/contrat/admin/contract_extrafields.php +++ b/htdocs/contrat/admin/contract_extrafields.php @@ -72,7 +72,7 @@ print_fiche_titre($langs->trans("ContractsSetup"),$linkback,'setup'); print '
'; $head=contract_admin_prepare_head(); -dol_fiche_head($head, 'attributes', $langs->trans("ModuleSetup"), 0, 'contrat'); +dol_fiche_head($head, 'attributes', $langs->trans("Contracts"), 0, 'contract'); print $langs->trans("DefineHereComplementaryAttributes",$textobject).'
'."\n"; From 0a603777ae74395a097e5cb0fbf66951e10cd0a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Tue, 11 Mar 2014 11:27:06 +0100 Subject: [PATCH 06/21] Added missing spacing --- htdocs/compta/facture/admin/facture_cust_extrafields.php | 2 +- htdocs/compta/facture/admin/facturedet_cust_extrafields.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/admin/facture_cust_extrafields.php b/htdocs/compta/facture/admin/facture_cust_extrafields.php index 0efcb94d079..1056d3148c6 100644 --- a/htdocs/compta/facture/admin/facture_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facture_cust_extrafields.php @@ -75,7 +75,7 @@ $head = invoice_admin_prepare_head(null); dol_fiche_head($head, 'attributes', $langs->trans("Invoices"), 0, 'invoice'); -print $langs->trans("DefineHereComplementaryAttributes",$textobject).'
'."\n"; +print $langs->trans("DefineHereComplementaryAttributes",$textobject).'

'."\n"; // Load attribute_label $extrafields->fetch_name_optionals_label($elementtype); diff --git a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php index a0c560d52cb..5365cf2bee9 100644 --- a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php @@ -76,7 +76,7 @@ $head = invoice_admin_prepare_head(null); dol_fiche_head($head, 'attributeslines', $langs->trans("Invoices"), 0, 'invoice'); -print $langs->trans("DefineHereComplementaryAttributes",$textobject).'
'."\n"; +print $langs->trans("DefineHereComplementaryAttributes",$textobject).'

'."\n"; // Load attribute_label $extrafields->fetch_name_optionals_label($elementtype); From f9a451dbb9de09214fbf3cb94361b6c9e1a47183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Tue, 11 Mar 2014 11:27:25 +0100 Subject: [PATCH 07/21] Corrected intervention translation in module configuration page --- htdocs/fichinter/admin/fichinter_extrafields.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/fichinter/admin/fichinter_extrafields.php b/htdocs/fichinter/admin/fichinter_extrafields.php index 06fefb32fbe..04c05093d5b 100644 --- a/htdocs/fichinter/admin/fichinter_extrafields.php +++ b/htdocs/fichinter/admin/fichinter_extrafields.php @@ -33,6 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $langs->load("companies"); $langs->load("admin"); $langs->load("members"); +$langs->load('interventions'); $extrafields = new ExtraFields($db); $form = new Form($db); @@ -64,6 +65,7 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; llxHeader(); +$textobject=$langs->transnoentitiesnoconv("Interventions"); $linkback=''.$langs->trans("BackToModuleList").''; print_fiche_titre($langs->trans("InterventionsSetup"),$linkback,'setup'); From 54b9f72977ceae776acaf210afebc7f04e1d6399 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Tue, 11 Mar 2014 11:31:37 +0100 Subject: [PATCH 08/21] Unified module name in members admin page and added spacing before submit button --- htdocs/adherents/admin/adherent.php | 2 +- htdocs/adherents/admin/public.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/adherents/admin/adherent.php b/htdocs/adherents/admin/adherent.php index 6534ac09ac3..f285d9a8a3a 100644 --- a/htdocs/adherents/admin/adherent.php +++ b/htdocs/adherents/admin/adherent.php @@ -115,7 +115,7 @@ print_fiche_titre($langs->trans("MembersSetup"),$linkback,'setup'); $head = member_admin_prepare_head(); -dol_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user'); +dol_fiche_head($head, 'general', $langs->trans("Members"), 0, 'user'); dol_htmloutput_mesg($mesg); diff --git a/htdocs/adherents/admin/public.php b/htdocs/adherents/admin/public.php index 1bb11d41c40..9a1fceb9b4e 100644 --- a/htdocs/adherents/admin/public.php +++ b/htdocs/adherents/admin/public.php @@ -84,7 +84,7 @@ print_fiche_titre($langs->trans("MembersSetup"),$linkback,'setup'); $head = member_admin_prepare_head(); -dol_fiche_head($head, 'public', $langs->trans("Member"), 0, 'user'); +dol_fiche_head($head, 'public', $langs->trans("Members"), 0, 'user'); dol_htmloutput_mesg($mesg); @@ -206,7 +206,7 @@ if (! empty($conf->paybox->enabled) || ! empty($conf->paypal->enabled)) print ''; print '
'; -print ''; +print '
'; print '
'; print ''; From 64e76852c5c2dd9d1e5d78607acbaa55a4018a0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Tue, 11 Mar 2014 11:37:42 +0100 Subject: [PATCH 09/21] Corrected projects admin page translation --- htdocs/projet/admin/project.php | 6 +++--- htdocs/projet/admin/project_extrafields.php | 5 ++--- htdocs/projet/admin/project_task_extrafields.php | 7 ++----- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/htdocs/projet/admin/project.php b/htdocs/projet/admin/project.php index c50ddd1a290..7a4233754b9 100644 --- a/htdocs/projet/admin/project.php +++ b/htdocs/projet/admin/project.php @@ -288,7 +288,7 @@ print_fiche_titre($langs->trans("ProjectsSetup"),$linkback,'setup'); $head=project_admin_prepare_head(); -dol_fiche_head($head, 'project', $langs->trans("Project"), 0, 'project'); +dol_fiche_head($head, 'project', $langs->trans("Projects"), 0, 'project'); /* * Projects Numbering model @@ -403,7 +403,7 @@ print ''.$langs->trans("Name").''; print ''.$langs->trans("Description").''; print ''.$langs->trans("Example").''; print ''.$langs->trans("Activated").''; -print ''.$langs->trans("Infos").''; +print ''.$langs->trans("ShortInfo").''; print "\n"; clearstatcache(); @@ -671,7 +671,7 @@ print ' '.$langs->trans("Name")."\n"; print " ".$langs->trans("Description")."\n"; print ''.$langs->trans("Activated")."\n"; print ''.$langs->trans("Default")."\n"; -print ''.$langs->trans("Infos").''; +print ''.$langs->trans("ShortInfo").''; print "\n"; clearstatcache(); diff --git a/htdocs/projet/admin/project_extrafields.php b/htdocs/projet/admin/project_extrafields.php index 6b26e8bc8f5..9ed4381103a 100644 --- a/htdocs/projet/admin/project_extrafields.php +++ b/htdocs/projet/admin/project_extrafields.php @@ -59,8 +59,6 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; * View */ -$textobject=$langs->transnoentitiesnoconv("Project"); - llxHeader("",$langs->trans("ProjectsSetup")); @@ -70,8 +68,9 @@ print_fiche_titre($langs->trans("ProjectsSetup"),$linkback,'setup'); $head = project_admin_prepare_head(); -dol_fiche_head($head, 'attributes', $langs->trans("Project"), 0, 'project'); +dol_fiche_head($head, 'attributes', $langs->trans("Projects"), 0, 'project'); +$textobject=$langs->transnoentitiesnoconv("Project"); print $langs->trans("DefineHereComplementaryAttributes",$textobject).'
'."\n"; print '
'; diff --git a/htdocs/projet/admin/project_task_extrafields.php b/htdocs/projet/admin/project_task_extrafields.php index 0ab60425a19..9d85781084a 100644 --- a/htdocs/projet/admin/project_task_extrafields.php +++ b/htdocs/projet/admin/project_task_extrafields.php @@ -59,19 +59,16 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; * View */ -$textobject=$langs->transnoentitiesnoconv("Project"); - llxHeader("",$langs->trans("ProjectsSetup")); $linkback=''.$langs->trans("BackToModuleList").''; print_fiche_titre($langs->trans("ProjectsSetup"),$linkback,'setup'); - $head = project_admin_prepare_head(); -dol_fiche_head($head, 'attributes_task', $langs->trans("Project"), 0, 'project'); - +dol_fiche_head($head, 'attributes_task', $langs->trans("Projects"), 0, 'project'); +$textobject=$langs->transnoentitiesnoconv("Project"); print $langs->trans("DefineHereComplementaryAttributes",$textobject).'
'."\n"; print '
'; From 96143ff4a7510c6ef9f33da162e1cd5502fe64c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Tue, 11 Mar 2014 11:41:19 +0100 Subject: [PATCH 10/21] Added missing translation keys --- htdocs/langs/en_US/other.lang | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index f8f8a5fd87b..33626a001f5 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -22,6 +22,7 @@ Notify_WITHDRAW_CREDIT=Credit withdrawal Notify_WITHDRAW_EMIT=Perform withdrawal Notify_ORDER_SENTBYMAIL=Customer order sent by mail Notify_COMPANY_CREATE=Third party created +Notify_COMPANY_COMPANY_SENTBYMAIL=Mails sent from third party card Notify_PROPAL_SENTBYMAIL=Commercial proposal sent by mail Notify_ORDER_SENTBYMAIL=Envío pedido por e-mail Notify_BILL_PAYED=Customer invoice payed @@ -40,6 +41,7 @@ Notify_MEMBER_VALIDATE=Member validated Notify_MEMBER_SUBSCRIPTION=Member subscribed Notify_MEMBER_RESILIATE=Member resiliated Notify_MEMBER_DELETE=Member deleted +Notify_PROJECT_CREATE=Project creation NbOfAttachedFiles=Number of attached files/documents TotalSizeOfAttachedFiles=Total size of attached files/documents MaxSize=Maximum size From 1d357ec2f9952e9f16f3ee495fa1abd33f1fa71f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Tue, 11 Mar 2014 11:53:22 +0100 Subject: [PATCH 11/21] Removed odd tabs from some modules --- htdocs/admin/bank.php | 9 --------- htdocs/admin/compta.php | 10 ---------- htdocs/admin/dons.php | 12 ------------ htdocs/admin/ecm.php | 10 ---------- htdocs/admin/mailing.php | 10 ---------- htdocs/admin/prelevement.php | 10 ---------- htdocs/admin/stock.php | 11 ----------- htdocs/admin/taxes.php | 12 ------------ htdocs/externalsite/admin/externalsite.php | 10 ---------- htdocs/paybox/admin/paybox.php | 10 ---------- 10 files changed, 104 deletions(-) diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index 0fcf52b888a..34b7ece1cf2 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -88,15 +88,6 @@ $linkback=''.$langs->trans("BackToM print_fiche_titre($langs->trans("BankSetupModule"),$linkback,'setup'); print '
'; -$h = 0; - -$head[$h][0] = DOL_URL_ROOT."/admin/bank.php"; -$head[$h][1] = $langs->trans("Miscellaneous"); -$head[$h][2] = 'general'; -$hselected=$h; -$h++; - -dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); print ''; print ''; diff --git a/htdocs/admin/compta.php b/htdocs/admin/compta.php index a2abb070c3a..1e5828f55e2 100644 --- a/htdocs/admin/compta.php +++ b/htdocs/admin/compta.php @@ -104,16 +104,6 @@ print_fiche_titre($langs->trans('ComptaSetup'),$linkback,'setup'); print '
'; -$h = 0; - -$head[$h][0] = DOL_URL_ROOT."/admin/compta.php"; -$head[$h][1] = $langs->trans("Accountancy"); -$head[$h][2] = 'Compta'; -$hselected=$h; -$h++; - -dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); - print '
'; // Cas du parametre COMPTA_MODE diff --git a/htdocs/admin/dons.php b/htdocs/admin/dons.php index bb54f0ead67..c350cea531b 100644 --- a/htdocs/admin/dons.php +++ b/htdocs/admin/dons.php @@ -120,18 +120,6 @@ llxHeader('',$langs->trans("DonationsSetup"),'DonConfiguration'); $linkback=''.$langs->trans("BackToModuleList").''; print_fiche_titre($langs->trans("DonationsSetup"),$linkback,'setup'); -print '
'; - -$h = 0; - -$head[$h][0] = DOL_URL_ROOT."/admin/dons.php"; -$head[$h][1] = $langs->trans("Donations"); -$head[$h][2] = 'Donation'; -$hselected=$h; -$h++; - -dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); - // Document templates print '
'; diff --git a/htdocs/admin/ecm.php b/htdocs/admin/ecm.php index 68782a2620d..50ad5ce13e8 100644 --- a/htdocs/admin/ecm.php +++ b/htdocs/admin/ecm.php @@ -72,16 +72,6 @@ $linkback=''.$langs->trans("BackToM print_fiche_titre($langs->trans("ECMSetup"),$linkback,'setup'); print '
'; -$h = 0; - -$head[$h][0] = DOL_URL_ROOT."/admin/ecm.php"; -$head[$h][1] = $langs->trans("Miscellaneous"); -$head[$h][2] = 'general'; -$hselected=$h; -$h++; - -dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); - print '
'; print ''; print ''; diff --git a/htdocs/admin/mailing.php b/htdocs/admin/mailing.php index 3c9c2f5ad93..43fd62028fd 100644 --- a/htdocs/admin/mailing.php +++ b/htdocs/admin/mailing.php @@ -80,16 +80,6 @@ llxHeader('',$langs->trans("MailingSetup")); $linkback=''.$langs->trans("BackToModuleList").''; print_fiche_titre($langs->trans("MailingSetup"),$linkback,'setup'); -$h = 0; - -$head[$h][0] = DOL_URL_ROOT."/admin/mailing.php"; -$head[$h][1] = $langs->trans("Miscellaneous"); -$head[$h][2] = 'general'; -$hselected=$h; -$h++; - -dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); - if (! empty($conf->use_javascript_ajax)) { print "\n".'
'.$langs->trans("Description").'