diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index b4dda563397..76b201b51ef 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -902,7 +902,7 @@ if ($action == 'create') // Description print ''.$langs->trans("Description").''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('note',(GETPOST('note','none')?GETPOST('note','none'):$object->note),'',180,'dolibarr_notes','In',true,true,$conf->fckeditor->enabled,ROWS_5,'90%'); + $doleditor=new DolEditor('note',(GETPOST('note','none')?GETPOST('note','none'):$object->note),'',180,'dolibarr_notes','In',true,true,$conf->fckeditor->enabled,ROWS_4,'90%'); $doleditor->Create(); print ''; diff --git a/htdocs/core/actions_fetchobject.inc.php b/htdocs/core/actions_fetchobject.inc.php index 6a2d7196d0f..b9cefe45306 100644 --- a/htdocs/core/actions_fetchobject.inc.php +++ b/htdocs/core/actions_fetchobject.inc.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2014-2017 Laurent Destailleur * Copyright (C) 2015 Frederic France * * This program is free software; you can redistribute it and/or modify diff --git a/htdocs/core/lib/sendings.lib.php b/htdocs/core/lib/sendings.lib.php index 78de61a729f..0e2599e853a 100644 --- a/htdocs/core/lib/sendings.lib.php +++ b/htdocs/core/lib/sendings.lib.php @@ -53,9 +53,9 @@ function shipping_prepare_head($object) $object->fetchObjectLinked($object->id,$object->element); if (count($object->linkedObjectsIds['delivery']) > 0) // If there is a delivery { - // Take first one element of array + // Take first one element of array $tmp = reset($object->linkedObjectsIds['delivery']); - + $head[$h][0] = DOL_URL_ROOT."/livraison/card.php?id=".$tmp; $head[$h][1] = $langs->trans("DeliveryCard"); $head[$h][2] = 'delivery'; @@ -78,7 +78,7 @@ function shipping_prepare_head($object) $head[$h][2] = 'contact'; $h++; } - + $nbNote = 0; if (!empty($object->note_private)) $nbNote++; if (!empty($object->note_public)) $nbNote++; @@ -171,7 +171,7 @@ function show_list_sending_receive($origin,$origin_id,$filter='') $product_static=new Product($db); $expedition=new Expedition($db); $warehousestatic=new Entrepot($db); - + $sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.date_start, obj.date_end,"; $sql.= " ed.rowid as edrowid, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot as warehouse_id,"; $sql.= " e.rowid as sendingid, e.ref as exp_ref, e.date_creation, e.date_delivery, e.date_expedition,"; @@ -233,7 +233,7 @@ function show_list_sending_receive($origin,$origin_id,$filter='') $var=True; while ($i < $num) { - + $objp = $db->fetch_object($resql); print ''; @@ -336,7 +336,7 @@ function show_list_sending_receive($origin,$origin_id,$filter='') } print ''; } - + // Batch number managment /*TODO Add link to expeditiondet_batch if (! empty($conf->productbatch->enabled)) @@ -351,7 +351,11 @@ function show_list_sending_receive($origin,$origin_id,$filter='') $detail = ''; foreach ($lines[$i]->detail_batch as $dbatch) { - $detail.= $langs->trans("DetailBatchFormat",$dbatch->batch,dol_print_date($dbatch->eatby,"day"),dol_print_date($dbatch->sellby,"day"),$dbatch->dluo_qty).'
'; + $detail.= $langs->trans("Batch").': '.$dbatch->batch; + $detail.= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby,"day"); + $detail.= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby,"day"); + $detail.= ' - '.$langs->trans("Qty").': '.$dbatch->dluo_qty; + $detail.= '
'; } print $form->textwithtooltip(img_picto('', 'object_barcode').' '.$langs->trans("DetailBatchNumber"),$detail); } @@ -363,8 +367,8 @@ function show_list_sending_receive($origin,$origin_id,$filter='') } else { print ''; } - }*/ - + }*/ + // Informations on receipt if (! empty($conf->livraison_bon->enabled)) { diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 04d895fd015..8a127534a40 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -52,14 +52,8 @@ if (! empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } -$langs->load("sendings"); -$langs->load("companies"); -$langs->load("bills"); -$langs->load('deliveries'); -$langs->load('orders'); -$langs->load('stocks'); -$langs->load('other'); -$langs->load('propal'); +$langs->loadLangs(array("sendings","companies","bills",'deliveries','orders','stocks','other','propal')); + if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); if (! empty($conf->productbatch->enabled)) $langs->load('productbatch'); @@ -108,6 +102,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be inclu $hookmanager->initHooks(array('expeditioncard','globalcard')); $permissiondellink=$user->rights->expedition->livraison->creer; // Used by the include of actions_dellink.inc.php +//var_dump($object->lines[0]->detail_batch); /* @@ -1191,7 +1186,8 @@ if ($action == 'create') if ($line->fk_product > 0) // If predefined product { $product->fetch($line->fk_product); - $product->load_stock('warehouseopen'); + $product->load_stock('warehouseopen'); // Load all $product->stock_warehouse[idwarehouse]->detail_batch + //var_dump($product->stock_warehouse[1]); print ''; print ''; // ancre pour retourner sur la ligne @@ -1368,13 +1364,21 @@ if ($action == 'create') print ''; print ''; + print ''; print ''; print $staticwarehouse->getNomUrl(0).' / '; - print ''; print ''; - print $langs->trans("DetailBatchFormat", $dbatch->batch, dol_print_date($dbatch->eatby,"day"), dol_print_date($dbatch->sellby,"day"), $dbatch->qty); + + $detail=''; + $detail.= $langs->trans("Batch").': '.$dbatch->batch; + $detail.= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby,"day"); + $detail.= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby,"day"); + $detail.= ' - '.$langs->trans("Qty").': '.$dbatch->dluo_qty; + $detail.= '
'; + print $detail; + $quantityToBeDelivered -= $deliverableQty; if ($quantityToBeDelivered < 0) { @@ -1530,14 +1534,12 @@ if ($action == 'create') print ''; print ''; - //print $langs->trans("DetailBatchFormat", $dbatch->batch, dol_print_date($dbatch->eatby,"day"), dol_print_date($dbatch->sellby,"day"), $dbatch->qty); //print $line->fk_product.' - '.$dbatch->batch; print $langs->trans("Batch").': '; $result = $productlotObject->fetch(0, $line->fk_product, $dbatch->batch); if ($result > 0) print $productlotObject->getNomUrl(1); else print 'TableLotIncompleteRunRepair'; print ' ('.$dbatch->qty.')'; - //print $langs->trans("DetailBatchFormat", 'ee'.$dbatch->batch, dol_print_date($dbatch->eatby,"day"), dol_print_date($dbatch->sellby,"day"), $dbatch->qty); $quantityToBeDelivered -= $deliverableQty; if ($quantityToBeDelivered < 0) { @@ -2378,13 +2380,18 @@ else if ($id || $ref) { if (isset($lines[$i]->detail_batch)) { + print ''; print ''; if ($lines[$i]->product_tobatch) { $detail = ''; foreach ($lines[$i]->detail_batch as $dbatch) { - $detail.= $langs->trans("DetailBatchFormat",$dbatch->batch,dol_print_date($dbatch->eatby,"day"),dol_print_date($dbatch->sellby,"day"),$dbatch->dluo_qty).'
'; + $detail.= $langs->trans("Batch").': '.$dbatch->batch; + $detail.= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby,"day"); + $detail.= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby,"day"); + $detail.= ' - '.$langs->trans("Qty").': '.$dbatch->dluo_qty; + $detail.= '
'; } print $form->textwithtooltip(img_picto('', 'object_barcode').' '.$langs->trans("DetailBatchNumber"),$detail); } diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index c0cd5896e2d..88d43335603 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1295,8 +1295,7 @@ class Expedition extends CommonObject $sql.= ", ed.rowid as line_id, 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, p.tobatch as product_tobatch"; - $sql.= " FROM (".MAIN_DB_PREFIX."expeditiondet as ed,"; - $sql.= " ".MAIN_DB_PREFIX."commandedet as cd)"; + $sql.= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."commandedet as cd"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = cd.fk_product"; $sql.= " WHERE ed.fk_expedition = ".$this->id; $sql.= " AND ed.fk_origin_line = cd.rowid"; @@ -1411,12 +1410,13 @@ class Expedition extends CommonObject { $line->detail_batch = array(); } - // Eat-by date - if (! empty($conf->productbatch->enabled) && $obj->line_id > 0) + + // Detail of batch + if (! empty($conf->productbatch->enabled) && $obj->line_id > 0 && $obj->product_tobatch > 0) { require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php'; - $newdetailbatch = ExpeditionLineBatch::fetchAll($this->db,$obj->line_id); + $newdetailbatch = ExpeditionLineBatch::fetchAll($this->db, $obj->line_id, $obj->fk_product); if (is_array($newdetailbatch)) { if ($originline != $obj->fk_origin_line) diff --git a/htdocs/expedition/class/expeditionbatch.class.php b/htdocs/expedition/class/expeditionbatch.class.php index 5253156e32a..a4b3b17a98a 100644 --- a/htdocs/expedition/class/expeditionbatch.class.php +++ b/htdocs/expedition/class/expeditionbatch.class.php @@ -169,22 +169,33 @@ class ExpeditionLineBatch extends CommonObject } /** - * Retrieve all batch number details link to a shipment line + * Retrieve all batch number detailed information of a shipment line * - * @param DoliDB $db Database object - * @param int $id_line_expdet id of shipment line - * @return variant -1 if KO, array of ExpeditionLineBatch if OK + * @param DoliDB $db Database object + * @param int $id_line_expdet id of shipment line + * @param int $fk_product If provided, load also detailed information of lot + * @return int|array -1 if KO, array of ExpeditionLineBatch if OK */ - static function fetchAll($db,$id_line_expdet) + static function fetchAll($db, $id_line_expdet, $fk_product=0) { - $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="SELECT"; + $sql.= " eb.rowid,"; + $sql.= " eb.fk_expeditiondet,"; + $sql.= " eb.sellby as oldsellby,"; // deprecated + $sql.= " eb.eatby as oldeatby,"; // deprecated + $sql.= " eb.batch,"; + $sql.= " eb.qty,"; + $sql.= " eb.fk_origin_stock"; + if ($fk_product > 0) + { + $sql.= ", pl.sellby"; + $sql.= ", pl.eatby"; + } + $sql.= " FROM ".MAIN_DB_PREFIX.self::$_table_element." as eb"; + if ($fk_product > 0) + { + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON pl.batch = eb.batch AND pl.fk_product = ".$fk_product; + } $sql.= " WHERE fk_expeditiondet=".(int) $id_line_expdet; dol_syslog(__METHOD__ ."", LOG_DEBUG); @@ -200,8 +211,8 @@ class ExpeditionLineBatch extends CommonObject $obj = $db->fetch_object($resql); - $tmp->sellby = $db->jdate($obj->sellby); - $tmp->eatby = $db->jdate($obj->eatby); + $tmp->sellby = $db->jdate($obj->sellby ? $obj->sellby : $obj->oldsellby); + $tmp->eatby = $db->jdate($obj->eatby ? $obj->eatby : $obj->oldeatby); $tmp->batch = $obj->batch; $tmp->id = $obj->rowid; $tmp->fk_origin_stock = $obj->fk_origin_stock; @@ -216,6 +227,7 @@ class ExpeditionLineBatch extends CommonObject } else { + dol_print_error($db); return -1; } } diff --git a/htdocs/langs/en_US/productbatch.lang b/htdocs/langs/en_US/productbatch.lang index 8cb99590d54..6acd1c9245c 100644 --- a/htdocs/langs/en_US/productbatch.lang +++ b/htdocs/langs/en_US/productbatch.lang @@ -11,7 +11,6 @@ BatchNumberShort=Lot/Serial EatByDate=Eat-by date SellByDate=Sell-by date DetailBatchNumber=Lot/Serial details -DetailBatchFormat=Lot/Serial: %s - Eat by: %s - Sell by: %s (Qty : %d) printBatch=Lot/Serial: %s printEatby=Eat-by: %s printSellby=Sell-by: %s diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index ff4ea131c85..0d6d6f815be 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3873,7 +3873,7 @@ class Product extends CommonObject $this->stock_warehouse[$row->fk_entrepot] = new stdClass(); $this->stock_warehouse[$row->fk_entrepot]->real = $row->reel; $this->stock_warehouse[$row->fk_entrepot]->id = $row->rowid; - if ((! preg_match('/nobatch/', $option)) && $this->hasbatch()) $this->stock_warehouse[$row->fk_entrepot]->detail_batch=Productbatch::findAll($this->db,$row->rowid,1); + if ((! preg_match('/nobatch/', $option)) && $this->hasbatch()) $this->stock_warehouse[$row->fk_entrepot]->detail_batch=Productbatch::findAll($this->db, $row->rowid, 1, $this->id); $this->stock_reel+=$row->reel; $i++; } diff --git a/htdocs/product/class/productbatch.class.php b/htdocs/product/class/productbatch.class.php index 64a43485604..48afbcc9dbb 100644 --- a/htdocs/product/class/productbatch.class.php +++ b/htdocs/product/class/productbatch.class.php @@ -469,7 +469,7 @@ class Productbatch extends CommonObject } } /** - * Return all batch detail records for given product and warehouse + * Return all batch detail records for a given product and warehouse * * @param DoliDB $db database object * @param int $fk_product_stock id product_stock for objet