Skip to content

Commit

Permalink
Travis correction.
Browse files Browse the repository at this point in the history
  • Loading branch information
KreizIT committed Mar 5, 2014
1 parent bdb3aa0 commit feae560
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
27 changes: 15 additions & 12 deletions htdocs/product/class/productbatch.class.php
Expand Up @@ -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;

Expand Down Expand Up @@ -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,";
Expand All @@ -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)
{
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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').",";
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand All @@ -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)."'");
Expand Down Expand Up @@ -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
*/
Expand All @@ -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";
Expand Down
2 changes: 2 additions & 0 deletions htdocs/product/stock/class/mouvementstock.class.php
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions htdocs/product/stock/product.php
Expand Up @@ -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"),
Expand Down

0 comments on commit feae560

Please sign in to comment.