34 public $element =
'expeditionlignebatch';
39 public $table_element =
'expeditiondet_batch';
47 public $fk_origin_stock;
48 public $fk_expeditiondet;
71 $sql .=
" pl.sellby,";
73 $sql .=
" ps.fk_entrepot";
75 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_batch as pb";
76 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"product_stock as ps on pb.fk_product_stock=ps.rowid";
77 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
"product_lot as pl on pl.batch = pb.batch AND pl.fk_product = ps.fk_product";
78 $sql .=
" WHERE pb.rowid = ".(int) $id_stockdluo;
80 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
85 $obj = $this->
db->fetch_object(
$resql);
87 $this->sellby = $this->
db->jdate($obj->sellby);
88 $this->eatby = $this->
db->jdate($obj->eatby);
89 $this->batch = $obj->batch;
90 $this->entrepot_id = $obj->fk_entrepot;
91 $this->fk_origin_stock = (int) $id_stockdluo;
97 $this->error =
"Error ".$this->db->lasterror();
112 $id_line_expdet = (int) $id_line_expdet;
114 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.$this->table_element.
" (";
115 $sql .=
"fk_expeditiondet";
120 $sql .=
", fk_origin_stock";
121 $sql .=
") VALUES (";
122 $sql .= $id_line_expdet.
",";
123 $sql .=
" ".(!isset($this->sellby) ||
dol_strlen($this->sellby) == 0 ?
'NULL' : (
"'".$this->db->idate($this->sellby)).
"'").
",";
124 $sql .=
" ".(!isset($this->eatby) ||
dol_strlen($this->eatby) == 0 ?
'NULL' : (
"'".$this->db->idate($this->eatby)).
"'").
",";
125 $sql .=
" ".(!isset($this->batch) ?
'NULL' : (
"'".$this->db->escape($this->batch).
"'")).
",";
126 $sql .=
" ".(!isset($this->qty) ? ((!isset($this->dluo_qty)) ?
'NULL' : $this->dluo_qty) : $this->qty).
",";
127 $sql .=
" ".(!isset($this->fk_origin_stock) ?
'NULL' : $this->fk_origin_stock);
133 $error++; $this->errors[] =
"Error ".$this->db->lasterror();
137 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
139 $this->fk_expeditiondet = $id_line_expdet;
142 foreach ($this->errors as $errmsg) {
143 dol_syslog(get_class($this).
"::create ".$errmsg, LOG_ERR);
144 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
146 $this->
db->rollback();
159 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.$this->table_element;
160 $sql .=
" WHERE fk_expeditiondet in (SELECT rowid FROM ".MAIN_DB_PREFIX.
"expeditiondet WHERE fk_expedition=".((int) $id_expedition).
")";
163 if ($this->
db->query($sql)) {
177 public function fetchAll($id_line_expdet, $fk_product = 0)
180 $sql .=
" eb.rowid,";
181 $sql .=
" eb.fk_expeditiondet,";
182 $sql .=
" eb.sellby as oldsellby,";
183 $sql .=
" eb.eatby as oldeatby,";
184 $sql .=
" eb.batch,";
186 $sql .=
" eb.fk_origin_stock";
187 if ($fk_product > 0) {
188 $sql .=
", pl.sellby";
189 $sql .=
", pl.eatby";
191 $sql .=
" FROM ".MAIN_DB_PREFIX.$this->table_element.
" as eb";
192 if ($fk_product > 0) {
193 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_lot as pl ON pl.batch = eb.batch AND pl.fk_product = ".((int) $fk_product);
195 $sql .=
" WHERE fk_expeditiondet=".(int) $id_line_expdet;
204 $obj = $this->
db->fetch_object(
$resql);
206 $tmp =
new self($this->db);
207 $tmp->sellby = $this->
db->jdate($obj->sellby ? $obj->sellby : $obj->oldsellby);
208 $tmp->eatby = $this->
db->jdate($obj->eatby ? $obj->eatby : $obj->oldeatby);
209 $tmp->batch = $obj->batch;
210 $tmp->id = $obj->rowid;
211 $tmp->fk_origin_stock = $obj->fk_origin_stock;
212 $tmp->fk_expeditiondet = $obj->fk_expeditiondet;
213 $tmp->dluo_qty = $obj->qty;
214 $tmp->qty = $obj->qty;
Parent class of all other business classes (invoices, contracts, proposals, orders,...
CRUD class for batch number management within shipment.
__construct($db)
Constructor.
fetchFromStock($id_stockdluo)
Fill object based on a product-warehouse-batch's record.
create($id_line_expdet)
Create an expeditiondet_batch DB record link to an expedtiondet record.
deleteFromShipment($id_expedition)
Delete batch record attach to a shipment.
fetchAll($id_line_expdet, $fk_product=0)
Retrieve all batch number detailed information of a shipment line.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$conf db
API class for accounts.