From feae560aa393fdfa36a0166f54ee8528351f7f6b Mon Sep 17 00:00:00 2001 From: KreizIT Date: Wed, 5 Mar 2014 11:13:23 +0100 Subject: [PATCH] Travis correction. --- htdocs/product/class/productbatch.class.php | 27 ++++++++++--------- .../stock/class/mouvementstock.class.php | 2 ++ htdocs/product/stock/product.php | 4 +-- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/htdocs/product/class/productbatch.class.php b/htdocs/product/class/productbatch.class.php index 413a7cf48380b..21e5fd39c6c0a 100644 --- a/htdocs/product/class/productbatch.class.php +++ b/htdocs/product/class/productbatch.class.php @@ -31,7 +31,7 @@ class Productbatch extends CommonObject { var $element='productbatch'; //!< Id that identify managed objects - private static $table_element='product_batch'; //!< Name of table without prefix where object is stored + private static $_table_element='product_batch'; //!< Name of table without prefix where object is stored var $id; @@ -77,7 +77,7 @@ function create($user, $notrigger=0) // Put here code to add control on parameters values // Insert request - $sql = "INSERT INTO ".MAIN_DB_PREFIX.self::$table_element." ("; + $sql = "INSERT INTO ".MAIN_DB_PREFIX.self::$_table_element." ("; $sql.= "fk_product_stock,"; $sql.= "sellby,"; $sql.= "eatby,"; @@ -102,7 +102,7 @@ function create($user, $notrigger=0) 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->id = $this->db->last_insert_id(MAIN_DB_PREFIX.self::$_table_element); if (! $notrigger) { @@ -158,7 +158,7 @@ function fetch($id) $sql.= " t.import_key"; - $sql.= " FROM ".MAIN_DB_PREFIX.self::$table_element." as t"; + $sql.= " FROM ".MAIN_DB_PREFIX.self::$_table_element." as t"; $sql.= " WHERE t.rowid = ".$id; dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); @@ -206,7 +206,7 @@ function update($user=0, $notrigger=0) $this->clean_param(); // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX.self::$table_element." SET"; + $sql = "UPDATE ".MAIN_DB_PREFIX.self::$_table_element." SET"; $sql.= " fk_product_stock=".(isset($this->fk_product_stock)?$this->fk_product_stock:"null").","; $sql.= " sellby=".(dol_strlen($this->sellby)!=0 ? "'".$this->db->idate($this->sellby)."'" : 'null').","; $sql.= " eatby=".(dol_strlen($this->eatby)!=0 ? "'".$this->db->idate($this->eatby)."'" : 'null').","; @@ -286,7 +286,7 @@ function delete($user, $notrigger=0) if (! $error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX.self::$table_element.""; + $sql = "DELETE FROM ".MAIN_DB_PREFIX.self::$_table_element.""; $sql.= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::delete sql=".$sql); @@ -388,17 +388,20 @@ function initAsSpecimen() } + /** + * Clean fields (triming) + */ private function clean_param() { - if (isset($this->fk_product_stock)) $this->fk_product_stock=(int)trim($this->fk_product_stock); + if (isset($this->fk_product_stock)) $this->fk_product_stock=(int) trim($this->fk_product_stock); if (isset($this->batch)) $this->batch=trim($this->batch); - if (isset($this->qty)) $this->qty=(float)trim($this->qty); + if (isset($this->qty)) $this->qty=(float) trim($this->qty); if (isset($this->import_key)) $this->import_key=trim($this->import_key); } /** * Find first detail record that match eather eat-by or sell-by or batch within given warehouse * - * @param int $fk_product_stck id product_stock for objet + * @param int $fk_product_stock id product_stock for objet * @param date $eatby eat-by date for objet * @param date $sellby sell-by date for objet * @param string $batch_number batch number for objet @@ -417,7 +420,7 @@ function find($fk_product_stock=0, $eatby='',$sellby='',$batch_number='') $sql.= " t.batch,"; $sql.= " t.qty,"; $sql.= " t.import_key"; - $sql.= " FROM ".MAIN_DB_PREFIX.self::$table_element." as t"; + $sql.= " FROM ".MAIN_DB_PREFIX.self::$_table_element." as t"; $sql.= " WHERE fk_product_stock=".$fk_product_stock; if (! empty($eatby)) array_push($where," eatby = '".$this->db->idate($eatby)."'"); @@ -459,7 +462,7 @@ function find($fk_product_stock=0, $eatby='',$sellby='',$batch_number='') * Return all batch detail records for given product and warehouse * * @param obj $db database object - * @param int $fk_product_stck id product_stock for objet + * @param int $fk_product_stock id product_stock for objet * @param int $with_qty doesn't return line with 0 quantity * @return int <0 if KO, >0 if OK */ @@ -478,7 +481,7 @@ public static function findAll($db,$fk_product_stock,$with_qty=0) $sql.= " t.import_key"; - $sql.= " FROM ".MAIN_DB_PREFIX.self::$table_element." as t"; + $sql.= " FROM ".MAIN_DB_PREFIX.self::$_table_element." as t"; $sql.= " WHERE fk_product_stock=".$fk_product_stock; if ($with_qty) $sql.= " AND qty<>0"; diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 01537e0be1863..143b9a8466cf1 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -59,6 +59,7 @@ function __construct($db) * @param date $eatby eat-by date * @param date $sellby sell-by date * @param string $batch batch number + * @param boolean $skip_sellby If set to true, stock mouvement is done without impacting batch record * @return int <0 if KO, 0 if fk_product is null, >0 if OK */ function _create($user, $fk_product, $entrepot_id, $qty, $type, $price=0, $label='', $datem='',$eatby='',$sellby='',$batch='',$skip_sellby=false) @@ -420,6 +421,7 @@ function calculateBalanceForProductBefore($productidselected, $datebefore) * * @param variant $dluo Could be either int if id of product_batch or array with at leat fk_product_stock * @param int $qty Quantity of product with batch number + * @return int <0 if KO, else return productbatch id */ function _create_batch($dluo, $qty ) { $pdluo=New Productbatch($this->db); diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 82e902c59c158..1fd34c65c2d70 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -125,8 +125,8 @@ $result=$product->fetch($id); } if ($product->hasbatch()) { - $d_eatby=dol_mktime(12, 0 , 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); - $d_sellby=dol_mktime(12, 0 , 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); + $d_eatby=dol_mktime(12, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); + $d_sellby=dol_mktime(12, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); $result=$product->correct_stock_batch( $user, GETPOST("id_entrepot"),