mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-08 09:01:40 +01:00
Debug v20
This commit is contained in:
@@ -66,23 +66,40 @@ class ReceptionLineBatch extends CommonObjectLine
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @var int ID
|
||||
* @var int ID of reception
|
||||
*/
|
||||
public $fk_reception;
|
||||
|
||||
/**
|
||||
* @var int ID Duplicate of origin_id (using origin_id is better)
|
||||
*/
|
||||
public $fk_element;
|
||||
|
||||
/**
|
||||
* @var int ID Duplicate of fk_element
|
||||
*/
|
||||
public $origin_id;
|
||||
|
||||
/**
|
||||
* @var int ID Duplicate of origin_line_id
|
||||
*/
|
||||
public $fk_elementdet;
|
||||
|
||||
/**
|
||||
* @var int ID Duplicate of fk_elementdet
|
||||
*/
|
||||
public $origin_line_id;
|
||||
|
||||
/**
|
||||
* @var string Type of object the fk_element refers to. Example: 'supplier_order'.
|
||||
*/
|
||||
public $element_type;
|
||||
|
||||
/**
|
||||
* @var int ID
|
||||
*/
|
||||
public $fk_product;
|
||||
|
||||
/**
|
||||
* @var int ID
|
||||
*/
|
||||
public $fk_elementdet;
|
||||
|
||||
public $fk_reception;
|
||||
|
||||
|
||||
public $qty;
|
||||
public $qty_asked;
|
||||
|
||||
@@ -147,11 +164,9 @@ class ReceptionLineBatch extends CommonObjectLine
|
||||
*/
|
||||
public function create($user, $notrigger = 0)
|
||||
{
|
||||
global $conf, $langs, $hookmanager;
|
||||
$error = 0;
|
||||
|
||||
// Clean parameters
|
||||
|
||||
if (isset($this->fk_element)) {
|
||||
$this->fk_element = (int) $this->fk_element;
|
||||
}
|
||||
@@ -183,15 +198,22 @@ class ReceptionLineBatch extends CommonObjectLine
|
||||
$this->datec = dol_now();
|
||||
}
|
||||
|
||||
|
||||
// Check parameters
|
||||
// Put here code to add control on parameters values
|
||||
if (empty($this->fk_product)) {
|
||||
$this->error = 'Error, property ->fk_product must not be empty to create a line of reception';
|
||||
return -1;
|
||||
}
|
||||
if (empty($this->fk_reception)) {
|
||||
$this->error = 'Error, property ->fk_reception must not be empty to create a line of reception';
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Insert request
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."(";
|
||||
$sql .= "fk_element,";
|
||||
$sql .= "fk_product,";
|
||||
$sql .= "fk_element,";
|
||||
$sql .= "fk_elementdet,";
|
||||
$sql .= "element_type,";
|
||||
$sql .= "qty,";
|
||||
$sql .= "fk_entrepot,";
|
||||
$sql .= "fk_user,";
|
||||
@@ -203,23 +225,22 @@ class ReceptionLineBatch extends CommonObjectLine
|
||||
$sql .= "sellby,";
|
||||
$sql .= "fk_reception,";
|
||||
$sql .= "cost_price";
|
||||
|
||||
|
||||
$sql .= ") VALUES (";
|
||||
$sql .= " ".(!isset($this->fk_element) ? 'NULL' : "'".$this->db->escape($this->fk_element)."'").",";
|
||||
$sql .= " ".(!isset($this->fk_product) ? 'NULL' : "'".$this->db->escape($this->fk_product)."'").",";
|
||||
$sql .= " ".(!isset($this->fk_elementdet) ? 'NULL' : "'".$this->db->escape($this->fk_elementdet)."'").",";
|
||||
$sql .= " ".(!isset($this->qty) ? 'NULL' : "'".$this->db->escape($this->qty)."'").",";
|
||||
$sql .= " ".(!isset($this->fk_entrepot) ? 'NULL' : "'".$this->db->escape($this->fk_entrepot)."'").",";
|
||||
$sql .= " ".(!isset($this->fk_user) ? 'NULL' : "'".$this->db->escape($this->fk_user)."'").",";
|
||||
$sql .= " ".(!isset($this->fk_product) ? 'NULL' : (int) $this->fk_product).",";
|
||||
$sql .= " ".(!isset($this->fk_element) ? 'NULL' : (int) $this->fk_element).",";
|
||||
$sql .= " ".(!isset($this->fk_elementdet) ? 'NULL' : (int) $this->fk_elementdet).",";
|
||||
$sql .= " '".(!isset($this->element_type) ? "supplier_order" : $this->db->escape($this->element_type))."',";
|
||||
$sql .= " ".(!isset($this->qty) ? 'NULL' : (float) $this->qty).",";
|
||||
$sql .= " ".(!isset($this->fk_entrepot) ? 'NULL' : (int) $this->fk_entrepot).",";
|
||||
$sql .= " ".(!isset($this->fk_user) ? 'NULL' : (int) $this->fk_user).",";
|
||||
$sql .= " ".(!isset($this->datec) || dol_strlen($this->datec) == 0 ? 'NULL' : "'".$this->db->idate($this->datec)."'").",";
|
||||
$sql .= " ".(!isset($this->comment) ? 'NULL' : "'".$this->db->escape($this->comment)."'").",";
|
||||
$sql .= " ".(!isset($this->status) ? 'NULL' : "'".$this->db->escape($this->status)."'").",";
|
||||
$sql .= " ".(!isset($this->status) ? 'NULL' : (int) $this->status).",";
|
||||
$sql .= " ".(!isset($this->batch) ? 'NULL' : "'".$this->db->escape($this->batch)."'").",";
|
||||
$sql .= " ".(!isset($this->eatby) || dol_strlen($this->eatby) == 0 ? 'NULL' : "'".$this->db->idate($this->eatby)."'").",";
|
||||
$sql .= " ".(!isset($this->sellby) || dol_strlen($this->sellby) == 0 ? 'NULL' : "'".$this->db->idate($this->sellby)."'").",";
|
||||
$sql .= " ".(!isset($this->fk_reception) ? 'NULL' : "'".$this->db->escape($this->fk_reception)."'").",";
|
||||
$sql .= " ".(!isset($this->cost_price) ? '0' : "'".$this->db->escape($this->cost_price)."'");
|
||||
$sql .= " ".((int) $this->fk_reception).",";
|
||||
$sql .= " ".(!isset($this->cost_price) ? '0' : (float) $this->cost_price);
|
||||
$sql .= ")";
|
||||
|
||||
$this->db->begin();
|
||||
@@ -276,13 +297,12 @@ class ReceptionLineBatch extends CommonObjectLine
|
||||
*/
|
||||
public function fetch($id, $ref = '')
|
||||
{
|
||||
global $langs;
|
||||
$sql = "SELECT";
|
||||
$sql .= " t.rowid,";
|
||||
|
||||
$sql .= " t.fk_element,";
|
||||
$sql .= " t.fk_product,";
|
||||
$sql .= " t.fk_elementdet,";
|
||||
$sql .= " t.element_type,";
|
||||
$sql .= " t.fk_product,";
|
||||
$sql .= " t.qty,";
|
||||
$sql .= " t.fk_entrepot,";
|
||||
$sql .= " t.fk_user,";
|
||||
@@ -294,8 +314,6 @@ class ReceptionLineBatch extends CommonObjectLine
|
||||
$sql .= " t.eatby,";
|
||||
$sql .= " t.sellby,";
|
||||
$sql .= " t.fk_reception";
|
||||
|
||||
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
|
||||
if ($ref) {
|
||||
$sql .= " WHERE t.ref = '".$this->db->escape($ref)."'";
|
||||
@@ -312,8 +330,13 @@ class ReceptionLineBatch extends CommonObjectLine
|
||||
$this->id = $obj->rowid;
|
||||
|
||||
$this->fk_element = $obj->fk_element;
|
||||
$this->fk_product = $obj->fk_product;
|
||||
$this->origin_id = $obj->fk_element;
|
||||
$this->fk_elementdet = $obj->fk_elementdet;
|
||||
$this->origin_line_id = $obj->fk_elementdet;
|
||||
$this->element_type = $obj->element_type;
|
||||
$this->origin_type = $obj->element_type;
|
||||
|
||||
$this->fk_product = $obj->fk_product;
|
||||
$this->qty = $obj->qty;
|
||||
$this->fk_entrepot = $obj->fk_entrepot;
|
||||
$this->fk_user = $obj->fk_user;
|
||||
|
||||
Reference in New Issue
Block a user