30require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
42 public $element =
'productlot';
47 public $table_element =
'product_lot';
52 public $picto =
'lot';
58 public $ismultientitymanaged = 1;
60 public $stats_propale;
61 public $stats_commande;
62 public $stats_contrat;
63 public $stats_facture;
64 public $stats_commande_fournisseur;
65 public $stats_expedition;
66 public $stats_reception;
69 public $stats_mrptoconsume;
70 public $stats_mrptoproduce;
71 public $stats_facturerec;
72 public $stats_facture_fournisseur;
103 public $fields = array(
104 'rowid' => array(
'type'=>
'integer',
'label'=>
'TechnicalID',
'enabled'=>1,
'visible'=>-2,
'noteditable'=>1,
'notnull'=> 1,
'index'=>1,
'position'=>1,
'comment'=>
'Id',
'css'=>
'left'),
105 'fk_product' => array(
'type'=>
'integer:Product:product/class/product.class.php',
'label'=>
'Product',
'enabled'=>1,
'visible'=>1,
'position'=>5,
'notnull'=>1,
'index'=>1,
'searchall'=>1,
'picto' =>
'product',
'css'=>
'maxwidth500 widthcentpercentminusxx',
'csslist'=>
'maxwidth150'),
106 'batch' => array(
'type'=>
'varchar(30)',
'label'=>
'Batch',
'enabled'=>1,
'visible'=>1,
'notnull'=>1,
'showoncombobox'=>1,
'index'=>1,
'position'=>10,
'comment'=>
'Batch',
'searchall'=>1,
'picto'=>
'lot'),
107 'entity' => array(
'type'=>
'integer',
'label'=>
'Entity',
'enabled'=>1,
'visible'=>0,
'default'=>1,
'notnull'=>1,
'index'=>1,
'position'=>20),
108 'sellby' => array(
'type'=>
'date',
'label'=>
'SellByDate',
'enabled'=>
'empty($conf->global->PRODUCT_DISABLE_SELLBY)?1:0',
'visible'=>5,
'position'=>60),
109 'eol_date' => array(
'type'=>
'date',
'label'=>
'EndOfLife',
'enabled'=>
'empty($conf->global->PRODUCT_ENABLE_TRACEABILITY)?0:1',
'visible'=>5,
'position'=>70),
110 'manufacturing_date' => array(
'type'=>
'date',
'label'=>
'ManufacturingDate',
'enabled'=>
'empty($conf->global->PRODUCT_ENABLE_TRACEABILITY)?0:1',
'visible'=>5,
'position'=>80),
111 'scrapping_date' => array(
'type'=>
'date',
'label'=>
'DestructionDate',
'enabled'=>
'empty($conf->global->PRODUCT_ENABLE_TRACEABILITY)?0:1',
'visible'=>5,
'position'=>90),
114 'eatby' => array(
'type'=>
'date',
'label'=>
'EatByDate',
'enabled'=>
'empty($conf->global->PRODUCT_DISABLE_EATBY)?1:0',
'visible'=>5,
'position'=>62),
115 'model_pdf' => array(
'type' =>
'varchar(255)',
'label' =>
'Model pdf',
'enabled' => 1,
'visible' => 0,
'position' => 215),
116 'last_main_doc' => array(
'type' =>
'varchar(255)',
'label' =>
'LastMainDoc',
'enabled' => 1,
'visible' => -2,
'position' => 310),
117 'datec' => array(
'type'=>
'datetime',
'label'=>
'DateCreation',
'enabled'=>1,
'visible'=>1,
'notnull'=>1,
'position'=>500),
118 'tms' => array(
'type'=>
'timestamp',
'label'=>
'DateModification',
'enabled'=>1,
'visible'=>-2,
'notnull'=>1,
'position'=>501),
119 'fk_user_creat' => array(
'type'=>
'integer:User:user/class/user.class.php',
'label'=>
'UserAuthor',
'enabled'=>1,
'visible'=>-2,
'notnull'=>1,
'position'=>510,
'foreignkey'=>
'llx_user.rowid'),
120 'fk_user_modif' => array(
'type'=>
'integer:User:user/class/user.class.php',
'label'=>
'UserModif',
'enabled'=>1,
'visible'=>-2,
'notnull'=>-1,
'position'=>511),
121 'import_key' => array(
'type'=>
'varchar(14)',
'label'=>
'ImportId',
'enabled'=>1,
'visible'=>-2,
'notnull'=>-1,
'index'=>0,
'position'=>1000)
140 public $eol_date =
'';
141 public $manufacturing_date =
'';
142 public $scrapping_date =
'';
151 public $fk_user_creat;
156 public $fk_user_modif;
184 global $conf, $langs;
192 if (isset($this->entity)) {
193 $this->entity = (int) $this->entity;
195 if (isset($this->fk_product)) {
196 $this->fk_product = (int) $this->fk_product;
198 if (isset($this->batch)) {
199 $this->batch = trim($this->batch);
201 if (isset($this->fk_user_creat)) {
202 $this->fk_user_creat = (int) $this->fk_user_creat;
204 if (isset($this->fk_user_modif)) {
205 $this->fk_user_modif = (int) $this->fk_user_modif;
207 if (isset($this->import_key)) {
208 $this->import_key = trim($this->import_key);
212 if ($this->batch ===
'') {
213 $this->errors[] = $langs->trans(
"ErrorBadValueForBatch");
214 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
220 $sql =
'INSERT INTO '.$this->db->prefix().$this->table_element.
'(';
222 $sql .=
'fk_product,';
227 $sql .=
'manufacturing_date,';
228 $sql .=
'scrapping_date,';
232 $sql .=
'fk_user_creat,';
233 $sql .=
'fk_user_modif,';
234 $sql .=
'import_key';
235 $sql .=
') VALUES (';
236 $sql .=
' '.(!isset($this->entity) ? $conf->entity : $this->entity).
',';
237 $sql .=
' '.(!isset($this->fk_product) ?
'NULL' : $this->fk_product).
',';
238 $sql .=
' '.(!isset($this->batch) ?
'NULL' :
"'".$this->db->escape($this->batch).
"'").
',';
239 $sql .=
' '.(!isset($this->eatby) ||
dol_strlen($this->eatby) == 0 ?
'NULL' :
"'".$this->db->idate($this->eatby).
"'").
',';
240 $sql .=
' '.(!isset($this->sellby) ||
dol_strlen($this->sellby) == 0 ?
'NULL' :
"'".$this->db->idate($this->sellby).
"'").
',';
241 $sql .=
' '.(!isset($this->eol_date) ||
dol_strlen($this->eol_date) == 0 ?
'NULL' :
"'".$this->db->idate($this->eol_date).
"'").
',';
242 $sql .=
' '.(!isset($this->manufacturing_date) ||
dol_strlen($this->manufacturing_date) == 0 ?
'NULL' :
"'".$this->db->idate($this->manufacturing_date).
"'").
',';
243 $sql .=
' '.(!isset($this->scrapping_date) ||
dol_strlen($this->scrapping_date) == 0 ?
'NULL' :
"'".$this->db->idate($this->scrapping_date).
"'").
',';
246 $sql .=
' '.
"'".$this->db->idate(
dol_now()).
"'".
',';
247 $sql .=
' '.(!isset($this->fk_user_creat) ?
'NULL' : $this->fk_user_creat).
',';
248 $sql .=
' '.(!isset($this->fk_user_modif) ?
'NULL' : $this->fk_user_modif).
',';
249 $sql .=
' '.(!isset($this->import_key) ?
'NULL' : $this->import_key);
254 $resql = $this->db->query($sql);
257 $this->errors[] =
'Error '.$this->db->lasterror();
258 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
262 $this->
id = $this->db->last_insert_id($this->db->prefix().$this->table_element);
272 if (!$error && !$notrigger) {
274 $result = $this->
call_trigger(
'PRODUCTLOT_CREATE', $user);
284 $this->db->rollback();
303 public function fetch($id = 0, $product_id = 0, $batch =
'')
310 $sql .=
" t.entity,";
311 $sql .=
" t.fk_product,";
314 $sql .=
" t.sellby,";
315 $sql .=
" t.eol_date,";
316 $sql .=
" t.manufacturing_date,";
317 $sql .=
" t.scrapping_date,";
320 $sql .=
" t.model_pdf,";
321 $sql .=
" t.last_main_doc,";
324 $sql .=
" t.fk_user_creat,";
325 $sql .=
" t.fk_user_modif,";
326 $sql .=
" t.import_key,";
327 $sql .=
" t.note_public,";
328 $sql .=
" t.note_private";
329 $sql .=
" FROM ".$this->db->prefix().$this->table_element.
" as t";
330 if ($product_id > 0 && $batch !=
'') {
331 $sql .=
" WHERE t.batch = '".$this->db->escape($batch).
"' AND t.fk_product = ".((int) $product_id);
333 $sql .=
" WHERE t.rowid = ".((int) $id);
336 $resql = $this->db->query($sql);
338 $numrows = $this->db->num_rows($resql);
340 $obj = $this->db->fetch_object($resql);
342 $this->
id = $obj->rowid;
343 $this->
ref = $obj->rowid;
346 $this->batch = $obj->batch;
347 $this->entity = (!empty($obj->entity) ? $obj->entity : $conf->entity);
348 $this->fk_product = $obj->fk_product;
349 $this->eatby = $this->db->jdate($obj->eatby);
350 $this->sellby = $this->db->jdate($obj->sellby);
351 $this->eol_date = $this->db->jdate($obj->eol_date);
352 $this->manufacturing_date = $this->db->jdate($obj->manufacturing_date);
353 $this->scrapping_date = $this->db->jdate($obj->scrapping_date);
356 $this->model_pdf = $obj->model_pdf;
357 $this->last_main_doc = $obj->last_main_doc;
359 $this->datec = $this->db->jdate($obj->datec);
360 $this->tms = $this->db->jdate($obj->tms);
361 $this->fk_user_creat = $obj->fk_user_creat;
362 $this->fk_user_modif = $obj->fk_user_modif;
363 $this->import_key = $obj->import_key;
364 $this->note_public = $obj->note_public;
365 $this->note_private = $obj->note_private;
371 $this->db->free($resql);
379 $this->errors[] =
'Error '.$this->db->lasterror();
380 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
402 if (isset($this->entity)) {
403 $this->entity = (int) $this->entity;
405 if (isset($this->fk_product)) {
406 $this->fk_product = (int) $this->fk_product;
408 if (isset($this->batch)) {
409 $this->batch = trim($this->batch);
411 if (isset($this->fk_user_creat)) {
412 $this->fk_user_creat = (int) $this->fk_user_creat;
414 if (isset($this->fk_user_modif)) {
415 $this->fk_user_modif = (int) $this->fk_user_modif;
417 if (isset($this->import_key)) {
418 $this->import_key = trim($this->import_key);
422 if (empty($this->oldcopy)) {
427 $sql =
'UPDATE '.$this->db->prefix().$this->table_element.
' SET';
428 $sql .=
' entity = '.(isset($this->entity) ? $this->entity :
"null").
',';
429 $sql .=
' fk_product = '.(isset($this->fk_product) ? $this->fk_product :
"null").
',';
430 $sql .=
' batch = '.(isset($this->batch) ?
"'".$this->db->escape($this->batch).
"'" :
"null").
',';
431 $sql .=
' eatby = '.(!isset($this->eatby) ||
dol_strlen($this->eatby) != 0 ?
"'".$this->db->idate($this->eatby).
"'" :
'null').
',';
432 $sql .=
' sellby = '.(!isset($this->sellby) ||
dol_strlen($this->sellby) != 0 ?
"'".$this->db->idate($this->sellby).
"'" :
'null').
',';
433 $sql .=
' eol_date = '.(!isset($this->eol_date) ||
dol_strlen($this->eol_date) != 0 ?
"'".$this->db->idate($this->eol_date).
"'" :
'null').
',';
434 $sql .=
' manufacturing_date = '.(!isset($this->manufacturing_date) ||
dol_strlen($this->manufacturing_date) != 0 ?
"'".$this->db->idate($this->manufacturing_date).
"'" :
'null').
',';
435 $sql .=
' scrapping_date = '.(!isset($this->scrapping_date) ||
dol_strlen($this->scrapping_date) != 0 ?
"'".$this->db->idate($this->scrapping_date).
"'" :
'null').
',';
438 $sql .=
' datec = '.(!isset($this->datec) ||
dol_strlen($this->datec) != 0 ?
"'".$this->db->idate($this->datec).
"'" :
'null').
',';
439 $sql .=
' tms = '.(dol_strlen($this->tms) != 0 ?
"'".$this->db->idate($this->tms).
"'" :
"'".$this->db->idate(
dol_now()).
"'").
',';
440 $sql .=
' fk_user_creat = '.(isset($this->fk_user_creat) ? $this->fk_user_creat :
"null").
',';
441 $sql .=
' fk_user_modif = '.(isset($this->fk_user_modif) ? $this->fk_user_modif :
"null").
',';
442 $sql .=
' import_key = '.(isset($this->import_key) ? $this->import_key :
"null");
443 $sql .=
' WHERE rowid='.((int) $this->
id);
447 $resql = $this->db->query($sql);
450 $this->errors[] =
'Error '.$this->db->lasterror();
451 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
462 if (!$error && !$notrigger) {
464 $result = $this->
call_trigger(
'PRODUCTLOT_MODIFY', $user);
473 $this->db->rollback();
491 public function delete(
User $user, $notrigger =
false)
500 $sql =
"SELECT pb.rowid FROM ".$this->db->prefix().
"product_batch as pb, ".$this->db->prefix().
"product_stock as ps";
501 $sql .=
" WHERE pb.fk_product_stock = ps.rowid AND pb.batch = '".$this->db->escape($this->batch).
"'";
502 $sql .=
" AND ps.fk_product = ".((int) $this->fk_product);
503 $sql .= $this->db->plimit(1);
505 $resql = $this->db->query($sql);
507 $obj = $this->db->fetch_object($resql);
510 $this->errors[] =
'Error Lot is used in stock (ID = '.$obj->rowid.
'). Deletion not possible.';
511 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
515 $this->errors[] =
'Error '.$this->db->lasterror();
516 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
520 $sql =
"SELECT sm.rowid FROM ".$this->db->prefix().
"stock_mouvement as sm";
521 $sql .=
" WHERE sm.batch = '".$this->db->escape($this->batch).
"'";
522 $sql .=
" AND sm.fk_product = ".((int) $this->fk_product);
523 $sql .= $this->db->plimit(1);
525 $resql = $this->db->query($sql);
527 $obj = $this->db->fetch_object($resql);
530 $this->errors[] =
'Error Lot was used in a stock movement (ID '.$obj->rowid.
'). Deletion not possible.';
531 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
535 $this->errors[] =
'Error '.$this->db->lasterror();
536 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
553 $sql =
'DELETE FROM '.$this->db->prefix().$this->table_element;
554 $sql .=
' WHERE rowid='.((int) $this->
id);
556 $resql = $this->db->query($sql);
559 $this->errors[] =
'Error '.$this->db->lasterror();
560 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
566 $this->db->rollback();
593 $object->fetch($fromid);
601 $object->context[
'createfromclone'] =
'createfromclone';
602 $result = $object->create($user);
607 $this->errors = $object->errors;
608 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
611 unset($object->context[
'createfromclone']);
619 $this->db->rollback();
634 global $db, $conf, $user, $hookmanager, $action;
636 $sql =
"SELECT COUNT(DISTINCT exp.fk_soc) as nb_customers, COUNT(DISTINCT exp.rowid) as nb,";
637 $sql .=
" COUNT(ed.rowid) as nb_rows, SUM(edb.qty) as qty";
638 $sql .=
" FROM ".$this->db->prefix().
"expeditiondet_batch as edb";
639 $sql .=
" INNER JOIN ".$this->db->prefix().
"expeditiondet as ed ON (ed.rowid = edb.fk_expeditiondet)";
640 $sql .=
" INNER JOIN ".$this->db->prefix().
"expedition as exp ON (exp.rowid = ed.fk_expedition)";
642 if (empty($user->rights->societe->client->voir) && !$socid) {
643 $sql .=
", ".$this->db->prefix().
"societe_commerciaux as sc";
645 $sql .=
" WHERE exp.entity IN (".getEntity(
'expedition').
")";
646 $sql .=
" AND edb.batch = '".($this->db->escape($this->batch)).
"'";
647 if (empty($user->rights->societe->client->voir) && !$socid) {
648 $sql .=
" AND exp.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
652 $sql .=
" AND exp.fk_soc = ".((int) $socid);
655 $result = $this->db->query($sql);
657 $obj = $this->db->fetch_object($result);
658 $this->stats_expedition[
'customers'] = $obj->nb_customers;
659 $this->stats_expedition[
'nb'] = $obj->nb;
660 $this->stats_expedition[
'rows'] = $obj->nb_rows;
661 $this->stats_expedition[
'qty'] = $obj->qty ? $obj->qty : 0;
687 $parameters = array(
'socid' => $socid);
688 $reshook = $hookmanager->executeHooks(
'loadStatsLotExpedition', $parameters, $this, $action);
690 $this->stats_expedition = $hookmanager->resArray[
'stats_expedition'];
695 $this->error = $this->db->error();
709 global $db, $conf, $user, $hookmanager, $action;
711 $sql =
"SELECT COUNT(DISTINCT cf.fk_soc) as nb_customers, COUNT(DISTINCT cf.rowid) as nb,";
712 $sql .=
" COUNT(cfd.rowid) as nb_rows, SUM(cfdi.qty) as qty";
713 $sql .=
" FROM ".$this->db->prefix().
"commande_fournisseur_dispatch as cfdi";
714 $sql .=
" INNER JOIN ".$this->db->prefix().
"commande_fournisseurdet as cfd ON (cfd.rowid = cfdi.fk_commandefourndet)";
715 $sql .=
" INNER JOIN ".$this->db->prefix().
"commande_fournisseur as cf ON (cf.rowid = cfd.fk_commande)";
717 if (empty($user->rights->societe->client->voir) && !$socid) {
718 $sql .=
", ".$this->db->prefix().
"societe_commerciaux as sc";
720 $sql .=
" WHERE cf.entity IN (".getEntity(
'expedition').
")";
721 $sql .=
" AND cfdi.batch = '".($this->db->escape($this->batch)).
"'";
722 if (empty($user->rights->societe->client->voir) && !$socid) {
723 $sql .=
" AND cf.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
727 $sql .=
" AND cf.fk_soc = ".((int) $socid);
730 $result = $this->db->query($sql);
732 $obj = $this->db->fetch_object($result);
733 $this->stats_supplier_order[
'customers'] = $obj->nb_customers;
734 $this->stats_supplier_order[
'nb'] = $obj->nb;
735 $this->stats_supplier_order[
'rows'] = $obj->nb_rows;
736 $this->stats_supplier_order[
'qty'] = $obj->qty ? $obj->qty : 0;
762 $parameters = array(
'socid' => $socid);
763 $reshook = $hookmanager->executeHooks(
'loadStatsLotSupplierOrder', $parameters, $this, $action);
765 $this->stats_supplier_order = $hookmanager->resArray[
'stats_supplier_order'];
770 $this->error = $this->db->error();
784 global $db, $conf, $user, $hookmanager, $action;
786 $sql =
"SELECT COUNT(DISTINCT recep.fk_soc) as nb_customers, COUNT(DISTINCT recep.rowid) as nb,";
787 $sql .=
" COUNT(cfdi.rowid) as nb_rows, SUM(cfdi.qty) as qty";
788 $sql .=
" FROM ".$this->db->prefix().
"commande_fournisseur_dispatch as cfdi";
789 $sql .=
" INNER JOIN ".$this->db->prefix().
"reception as recep ON (recep.rowid = cfdi.fk_reception)";
791 if (empty($user->rights->societe->client->voir) && !$socid) {
792 $sql .=
", ".$this->db->prefix().
"societe_commerciaux as sc";
794 $sql .=
" WHERE recep.entity IN (".getEntity(
'reception').
")";
795 $sql .=
" AND cfdi.batch = '".($this->db->escape($this->batch)).
"'";
796 if (empty($user->rights->societe->client->voir) && !$socid) {
797 $sql .=
" AND recep.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
801 $sql .=
" AND recep.fk_soc = ".((int) $socid);
804 $result = $this->db->query($sql);
806 $obj = $this->db->fetch_object($result);
807 $this->stats_reception[
'customers'] = $obj->nb_customers;
808 $this->stats_reception[
'nb'] = $obj->nb;
809 $this->stats_reception[
'rows'] = $obj->nb_rows;
810 $this->stats_reception[
'qty'] = $obj->qty ? $obj->qty : 0;
836 $parameters = array(
'socid' => $socid);
837 $reshook = $hookmanager->executeHooks(
'loadStatsLotReception', $parameters, $this, $action);
839 $this->stats_expedition = $hookmanager->resArray[
'stats_expedition'];
844 $this->error = $this->db->error();
858 global $user, $hookmanager, $action;
862 foreach (array(
'toconsume',
'consumed',
'toproduce',
'produced') as $role) {
863 $this->stats_mo[
'customers_'.$role] = 0;
864 $this->stats_mo[
'nb_'.$role] = 0;
865 $this->stats_mo[
'qty_'.$role] = 0;
867 $sql =
"SELECT COUNT(DISTINCT c.fk_soc) as nb_customers, COUNT(DISTINCT c.rowid) as nb,";
868 $sql .=
" SUM(mp.qty) as qty";
869 $sql .=
" FROM ".$this->db->prefix().
"mrp_mo as c";
870 $sql .=
" INNER JOIN ".$this->db->prefix().
"mrp_production as mp ON mp.fk_mo=c.rowid";
871 if (empty($user->rights->societe->client->voir) && !$socid) {
872 $sql .=
"INNER JOIN ".$this->db->prefix().
"societe_commerciaux as sc ON sc.fk_soc=c.fk_soc AND sc.fk_user = ".((int) $user->id);
875 $sql .=
" c.entity IN (".getEntity(
'mo').
")";
877 $sql .=
" AND mp.batch = '".($this->db->escape($this->batch)).
"'";
878 $sql .=
" AND mp.role ='".$this->db->escape($role).
"'";
880 $sql .=
" AND c.fk_soc = ".((int) $socid);
883 $result = $this->db->query($sql);
885 $obj = $this->db->fetch_object($result);
886 $this->stats_mo[
'customers_'.$role] = $obj->nb_customers ? $obj->nb_customers : 0;
887 $this->stats_mo[
'nb_'.$role] = $obj->nb ? $obj->nb : 0;
888 $this->stats_mo[
'qty_'.$role] = $obj->qty ?
price2num($obj->qty,
'MS') : 0;
890 $this->error = $this->db->error();
895 if (!empty($error)) {
899 $parameters = array(
'socid' => $socid);
900 $reshook = $hookmanager->executeHooks(
'loadStatsCustomerMO', $parameters, $this, $action);
902 $this->stats_mo = $hookmanager->resArray[
'stats_mo'];
948 global $conf, $langs, $user;
950 $langs->loadLangs([
'stocks',
'productbatch']);
952 $option = $params[
'option'] ??
'';
955 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"Batch").
'</u>';
957 $datas[
'batch'] =
'<br><b>'.$langs->trans(
'Batch').
':</b> '.$this->batch;
958 if ($this->eatby && empty($conf->global->PRODUCT_DISABLE_EATBY)) {
959 $datas[
'eatby'] =
'<br><b>'.$langs->trans(
'EatByDate').
':</b> '.
dol_print_date($this->db->jdate($this->eatby),
'day');
961 if ($this->sellby && empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
962 $datas[
'sellby'] =
'<br><b>'.$langs->trans(
'SellByDate').
':</b> '.
dol_print_date($this->db->jdate($this->sellby),
'day');
981 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $maxlen = 24, $morecss =
'', $save_lastsearch_value = -1)
983 global $langs, $conf, $hookmanager;
988 'objecttype' => $this->element,
991 $classfortooltip =
'classfortooltip';
994 $classfortooltip =
'classforajaxtooltip';
995 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
1001 $url = DOL_URL_ROOT.
'/product/stock/productlot_card.php?id='.$this->id;
1003 if ($option !=
'nolink') {
1005 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1006 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1007 $add_save_lastsearch_values = 1;
1009 if ($add_save_lastsearch_values) {
1010 $url .=
'&save_lastsearch_values=1';
1015 if (empty($notooltip)) {
1016 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
1017 $label = $langs->trans(
"ShowMyObject");
1018 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
1020 $linkclose .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
1021 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
1023 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1026 if ($option ==
'nolink') {
1027 $linkstart =
'<span';
1029 $linkstart =
'<a href="'.$url.
'"';
1031 $linkstart .= $linkclose.
'>';
1032 if ($option ==
'nolink') {
1033 $linkend =
'</span>';
1038 $result .= $linkstart;
1040 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'"'), 0, 0, $notooltip ? 0 : 1);
1042 if ($withpicto != 2) {
1043 $result .= $this->batch;
1045 $result .= $linkend;
1048 $hookmanager->initHooks(array(
'productlotdao'));
1049 $parameters = array(
'id' => $this->
id,
'getnomurl' => $result);
1050 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1052 $result = $hookmanager->resPrint;
1054 $result .= $hookmanager->resPrint;
1073 $this->
ref =
'SPECIMEN';
1074 $this->specimen = 1;
1076 $this->entity = $conf->entity;
1077 $this->fk_product =
null;
1083 $this->fk_user_creat =
null;
1084 $this->fk_user_modif =
null;
1085 $this->import_key =
'';
1098 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1100 global $conf, $user, $langs;
1102 $langs->loadLangs(array(
'stocks',
'productbatch',
"products"));
1103 $outputlangs->loadLangs(array(
'stocks',
'productbatch',
"products"));
1109 if (!empty($this->model_pdf)) {
1110 $modele = $this->model_pdf;
1111 } elseif (!empty($conf->global->PRODUCT_BATCH_ADDON_PDF)) {
1112 $modele = $conf->global->PRODUCT_BATCH_ADDON_PDF;
1116 $modelpath =
"core/modules/product_batch/doc/";
1118 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
Parent class of all other business classes (invoices, contracts, proposals, orders,...
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this->array_options This method is in most cases call...
commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null)
Common function for all objects extending CommonObject for generating documents.
insertExtraFields($trigger='', $userused=null)
Add/Update all extra fields values for the current object.
call_trigger($triggerName, $user)
Call trigger based on this instance.
Class to manage Dolibarr database access.
Class with list of lots and properties.
loadStatsReception($socid=0)
Charge tableau des stats expedition pour le lot/numéro de série.
getLibStatut($mode=0)
Return label of status of object.
getTooltipContentArray($params)
getTooltipContentArray
fetch($id=0, $product_id=0, $batch='')
Load object in memory from the database.
loadStatsExpedition($socid=0)
Charge tableau des stats expedition pour le lot/numéro de série.
LibStatut($status, $mode=0)
Return label of a given status.
getNomUrl($withpicto=0, $option='', $notooltip=0, $maxlen=24, $morecss='', $save_lastsearch_value=-1)
Return a link to the a lot card (with optionaly the picto) Use this->id,this->lastname,...
generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Create a document onto disk according to template module.
loadStatsMo($socid=0)
Charge tableau des stats expedition pour le lot/numéro de série.
__construct(DoliDB $db)
Constructor.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
createFromClone(User $user, $fromid)
Load an object from its id and create a new one in database.
create(User $user, $notrigger=false)
Create object into database.
loadStatsSupplierOrder($socid=0)
Charge tableau des stats commande fournisseur pour le lot/numéro de série.
update(User $user, $notrigger=false)
Update object into database.
Class to manage Dolibarr users.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.