Travis correction.

This commit is contained in:
KreizIT 2014-03-05 11:13:23 +01:00
parent bdb3aa0a69
commit feae560aa3
3 changed files with 19 additions and 14 deletions

View File

@ -31,7 +31,7 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
class Productbatch extends CommonObject class Productbatch extends CommonObject
{ {
var $element='productbatch'; //!< Id that identify managed objects 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; var $id;
@ -77,7 +77,7 @@ class Productbatch extends CommonObject
// Put here code to add control on parameters values // Put here code to add control on parameters values
// Insert request // 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.= "fk_product_stock,";
$sql.= "sellby,"; $sql.= "sellby,";
$sql.= "eatby,"; $sql.= "eatby,";
@ -102,7 +102,7 @@ class Productbatch extends CommonObject
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (! $error) 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) if (! $notrigger)
{ {
@ -158,7 +158,7 @@ class Productbatch extends CommonObject
$sql.= " t.import_key"; $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; $sql.= " WHERE t.rowid = ".$id;
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
@ -206,7 +206,7 @@ class Productbatch extends CommonObject
$this->clean_param(); $this->clean_param();
// Update request // 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.= " 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.= " 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').","; $sql.= " eatby=".(dol_strlen($this->eatby)!=0 ? "'".$this->db->idate($this->eatby)."'" : 'null').",";
@ -286,7 +286,7 @@ class Productbatch extends CommonObject
if (! $error) 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; $sql.= " WHERE rowid=".$this->id;
dol_syslog(get_class($this)."::delete sql=".$sql); dol_syslog(get_class($this)."::delete sql=".$sql);
@ -388,6 +388,9 @@ class Productbatch extends CommonObject
} }
/**
* Clean fields (triming)
*/
private function clean_param() { 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->batch)) $this->batch=trim($this->batch);
@ -398,7 +401,7 @@ class Productbatch extends CommonObject
/** /**
* Find first detail record that match eather eat-by or sell-by or batch within given warehouse * 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 $eatby eat-by date for objet
* @param date $sellby sell-by date for objet * @param date $sellby sell-by date for objet
* @param string $batch_number batch number for objet * @param string $batch_number batch number for objet
@ -417,7 +420,7 @@ class Productbatch extends CommonObject
$sql.= " t.batch,"; $sql.= " t.batch,";
$sql.= " t.qty,"; $sql.= " t.qty,";
$sql.= " t.import_key"; $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; $sql.= " WHERE fk_product_stock=".$fk_product_stock;
if (! empty($eatby)) array_push($where," eatby = '".$this->db->idate($eatby)."'"); if (! empty($eatby)) array_push($where," eatby = '".$this->db->idate($eatby)."'");
@ -459,7 +462,7 @@ class Productbatch extends CommonObject
* Return all batch detail records for given product and warehouse * Return all batch detail records for given product and warehouse
* *
* @param obj $db database object * @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 * @param int $with_qty doesn't return line with 0 quantity
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
@ -478,7 +481,7 @@ class Productbatch extends CommonObject
$sql.= " t.import_key"; $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; $sql.= " WHERE fk_product_stock=".$fk_product_stock;
if ($with_qty) $sql.= " AND qty<>0"; if ($with_qty) $sql.= " AND qty<>0";

View File

@ -59,6 +59,7 @@ class MouvementStock
* @param date $eatby eat-by date * @param date $eatby eat-by date
* @param date $sellby sell-by date * @param date $sellby sell-by date
* @param string $batch batch number * @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 * @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) function _create($user, $fk_product, $entrepot_id, $qty, $type, $price=0, $label='', $datem='',$eatby='',$sellby='',$batch='',$skip_sellby=false)
@ -420,6 +421,7 @@ class MouvementStock
* *
* @param variant $dluo Could be either int if id of product_batch or array with at leat fk_product_stock * @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 * @param int $qty Quantity of product with batch number
* @return int <0 if KO, else return productbatch id
*/ */
function _create_batch($dluo, $qty ) { function _create_batch($dluo, $qty ) {
$pdluo=New Productbatch($this->db); $pdluo=New Productbatch($this->db);