36 public $element =
'stockmouvement';
41 public $table_element =
'stock_mouvement';
70 public $fk_user_author;
84 public $inventorycode;
92 public $fields = array(
93 'rowid' =>array(
'type'=>
'integer',
'label'=>
'TechnicalID',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>10,
'showoncombobox'=>1),
94 'tms' =>array(
'type'=>
'timestamp',
'label'=>
'DateModification',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>15),
95 'datem' =>array(
'type'=>
'datetime',
'label'=>
'Datem',
'enabled'=>1,
'visible'=>-1,
'position'=>20),
96 'fk_product' =>array(
'type'=>
'integer:Product:product/class/product.class.php:1',
'label'=>
'Product',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>25),
97 'fk_entrepot' =>array(
'type'=>
'integer:Entrepot:product/stock/class/entrepot.class.php',
'label'=>
'Warehouse',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>30),
98 'value' =>array(
'type'=>
'double',
'label'=>
'Value',
'enabled'=>1,
'visible'=>-1,
'position'=>35),
99 'price' =>array(
'type'=>
'double(24,8)',
'label'=>
'Price',
'enabled'=>1,
'visible'=>-1,
'position'=>40),
100 'type_mouvement' =>array(
'type'=>
'smallint(6)',
'label'=>
'Type mouvement',
'enabled'=>1,
'visible'=>-1,
'position'=>45),
101 'fk_user_author' =>array(
'type'=>
'integer:User:user/class/user.class.php',
'label'=>
'Fk user author',
'enabled'=>1,
'visible'=>-1,
'position'=>50),
102 'label' =>array(
'type'=>
'varchar(255)',
'label'=>
'Label',
'enabled'=>1,
'visible'=>-1,
'position'=>55),
103 'fk_origin' =>array(
'type'=>
'integer',
'label'=>
'Fk origin',
'enabled'=>1,
'visible'=>-1,
'position'=>60),
104 'origintype' =>array(
'type'=>
'varchar(32)',
'label'=>
'Origintype',
'enabled'=>1,
'visible'=>-1,
'position'=>65),
105 'model_pdf' =>array(
'type'=>
'varchar(255)',
'label'=>
'Model pdf',
'enabled'=>1,
'visible'=>0,
'position'=>70),
106 'fk_projet' =>array(
'type'=>
'integer:Project:projet/class/project.class.php:1:fk_statut=1',
'label'=>
'Project',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>75),
107 'inventorycode' =>array(
'type'=>
'varchar(128)',
'label'=>
'InventoryCode',
'enabled'=>1,
'visible'=>-1,
'position'=>80),
108 'batch' =>array(
'type'=>
'varchar(30)',
'label'=>
'Batch',
'enabled'=>1,
'visible'=>-1,
'position'=>85),
109 'eatby' =>array(
'type'=>
'date',
'label'=>
'Eatby',
'enabled'=>1,
'visible'=>-1,
'position'=>90),
110 'sellby' =>array(
'type'=>
'date',
'label'=>
'Sellby',
'enabled'=>1,
'visible'=>-1,
'position'=>95),
111 'fk_project' =>array(
'type'=>
'integer:Project:projet/class/project.class.php:1:fk_statut=1',
'label'=>
'Fk project',
'enabled'=>1,
'visible'=>-1,
'position'=>100),
151 public function _create($user, $fk_product, $entrepot_id, $qty, $type, $price = 0, $label =
'', $inventorycode =
'', $datem =
'', $eatby =
'', $sellby =
'', $batch =
'', $skip_batch =
false, $id_product_batch = 0, $disablestockchangeforsubproduct = 0)
154 global $conf, $langs;
156 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
157 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
160 dol_syslog(get_class($this).
"::_create start userid=$user->id, fk_product=$fk_product, warehouse_id=$entrepot_id, qty=$qty, type=$type, price=$price, label=$label, inventorycode=$inventorycode, datem=".$datem.
", eatby=".$eatby.
", sellby=".$sellby.
", batch=".$batch.
", skip_batch=".$skip_batch);
164 if (empty($price)) $price = 0;
165 $now = (!empty($datem) ? $datem :
dol_now());
168 if (empty($fk_product))
return 0;
170 if (is_numeric($eatby) && $eatby < 0) {
171 dol_syslog(get_class($this).
"::_create start ErrorBadValueForParameterEatBy eatby = ".$eatby);
172 $this->errors[] =
'ErrorBadValueForParameterEatBy';
175 if (is_numeric($sellby) && $sellby < 0) {
176 dol_syslog(get_class($this).
"::_create start ErrorBadValueForParameterSellBy sellby = ".$sellby);
177 $this->errors[] =
'ErrorBadValueForParameterSellBy';
182 $this->product_id = $fk_product;
183 $this->entrepot_id = $entrepot_id;
184 $this->warehouse_id = $entrepot_id;
188 $this->label = $label;
189 $this->inventorycode = $inventorycode;
191 $this->batch = $batch;
197 $result = $product->fetch($fk_product);
199 $this->error = $product->error;
200 $this->errors = $product->errors;
204 if ($product->id <= 0) {
210 $product->load_stock(
'novirtual');
213 if (!empty($conf->productbatch->enabled) && $product->hasbatch() && !$skip_batch)
217 $langs->load(
"errors");
218 $this->errors[] = $langs->transnoentitiesnoconv(
"ErrorTryToMakeMoveOnProductRequiringBatchData", $product->ref);
219 dol_syslog(
"Try to make a movement of a product with status_batch on without any batch data");
221 $this->
db->rollback();
231 $sql =
"SELECT pb.rowid, pb.batch, pb.eatby, pb.sellby FROM ".MAIN_DB_PREFIX.
"product_lot as pb";
232 $sql .=
" WHERE pb.fk_product = ".$fk_product.
" AND pb.batch = '".$this->
db->escape($batch).
"'";
233 dol_syslog(get_class($this).
"::_create scan serial for this product to check if eatby and sellby match", LOG_DEBUG);
243 $obj = $this->
db->fetch_object(
$resql);
249 $eatbywithouthour =
dol_mktime(0, 0, 0, $tmparray[
'mon'], $tmparray[
'mday'], $tmparray[
'year']);
250 if ($this->
db->jdate($obj->eatby) != $eatby && $this->
db->jdate($obj->eatby) != $eatbywithouthour)
253 $langs->load(
"stocks");
254 $this->errors[] = $langs->transnoentitiesnoconv(
"ThisSerialAlreadyExistWithDifferentDate", $batch,
dol_print_date($this->
db->jdate($obj->eatby),
'dayhour'),
dol_print_date($eatbywithouthour,
'dayhour'));
255 dol_syslog(
"ThisSerialAlreadyExistWithDifferentDate batch=".$batch.
", eatby found into product_lot = ".$obj->eatby.
" = ".
dol_print_date($this->
db->jdate($obj->eatby),
'dayhourrfc').
" so eatbywithouthour = ".$eatbywithouthour.
" = ".
dol_print_date($eatbywithouthour).
" - eatby provided = ".$eatby.
" = ".
dol_print_date($eatby,
'dayhourrfc'), LOG_ERR);
256 $this->
db->rollback();
260 $eatby = $obj->eatby;
266 $result = $productlot->fetch($obj->rowid);
267 $productlot->eatby = $eatby;
268 $result = $productlot->update($user);
271 $this->error = $productlot->error;
272 $this->errors = $productlot->errors;
273 $this->
db->rollback();
283 $sellbywithouthour =
dol_mktime(0, 0, 0, $tmparray[
'mon'], $tmparray[
'mday'], $tmparray[
'year']);
284 if ($this->
db->jdate($obj->sellby) != $sellby && $this->
db->jdate($obj->sellby) != $sellbywithouthour)
287 $this->errors[] = $langs->transnoentitiesnoconv(
"ThisSerialAlreadyExistWithDifferentDate", $batch,
dol_print_date($this->
db->jdate($obj->sellby)),
dol_print_date($sellby));
289 $this->
db->rollback();
293 $sellby = $obj->sellby;
301 $result = $productlot->fetch($obj->rowid);
302 $productlot->sellby = $sellby;
303 $result = $productlot->update($user);
306 $this->error = $productlot->error;
307 $this->errors = $productlot->errors;
308 $this->
db->rollback();
320 $productlot->entity = $conf->entity;
321 $productlot->fk_product = $fk_product;
322 $productlot->batch = $batch;
324 $productlot->eatby = $eatby;
325 $productlot->sellby = $sellby;
326 $result = $productlot->create($user);
329 $this->error = $productlot->error;
330 $this->errors = $productlot->errors;
331 $this->
db->rollback();
339 $this->
db->rollback();
346 if ($product->type !=
Product::TYPE_SERVICE || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) $movestock = 1;
350 if ($movestock && $qty < 0 && empty($conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER))
352 if (!empty($conf->productbatch->enabled) && $product->hasbatch() && !$skip_batch)
356 foreach ($product->stock_warehouse[$entrepot_id]->detail_batch as $batchcursor => $prodbatch)
358 if ($batch != $batchcursor)
continue;
360 if ($prodbatch->qty < abs($qty)) $qtyisnotenough = $prodbatch->qty;
363 if (!$foundforbatch || $qtyisnotenough)
365 $langs->load(
"stocks");
366 include_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
368 $tmpwarehouse->fetch($entrepot_id);
370 $this->error = $langs->trans(
'qtyToTranferLotIsNotEnough', $product->ref, $batch, $qtyisnotenough, $tmpwarehouse->ref);
371 $this->errors[] = $langs->trans(
'qtyToTranferLotIsNotEnough', $product->ref, $batch, $qtyisnotenough, $tmpwarehouse->ref);
372 $this->
db->rollback();
378 if (empty($product->stock_warehouse[$entrepot_id]->real) || $product->stock_warehouse[$entrepot_id]->real < abs($qty))
380 $langs->load(
"stocks");
381 $this->error = $langs->trans(
'qtyToTranferIsNotEnough').
' : '.$product->ref;
382 $this->errors[] = $langs->trans(
'qtyToTranferIsNotEnough').
' : '.$product->ref;
383 $this->
db->rollback();
389 if ($movestock && $entrepot_id > 0)
393 if (!empty($this->origin)) {
394 $origintype = empty($this->origin->origin_type) ? $this->origin->element : $this->origin->origin_type;
395 $fk_origin = $this->origin->id;
396 if ($origintype ==
'project') {
397 $fk_project = $fk_origin;
399 $res = $this->origin->fetch($fk_origin);
402 if (!empty($this->origin->fk_project))
404 $fk_project = $this->origin->fk_project;
414 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"stock_mouvement(";
415 $sql .=
" datem, fk_product, batch, eatby, sellby,";
416 $sql .=
" fk_entrepot, value, type_mouvement, fk_user_author, label, inventorycode, price, fk_origin, origintype, fk_projet";
418 $sql .=
" VALUES ('".$this->db->idate($now).
"', ".$this->product_id.
", ";
419 $sql .=
" ".($batch ?
"'".$this->db->escape($batch).
"'" :
"null").
", ";
420 $sql .=
" ".($eatby ?
"'".$this->db->idate($eatby).
"'" :
"null").
", ";
421 $sql .=
" ".($sellby ?
"'".$this->db->idate($sellby).
"'" :
"null").
", ";
422 $sql .=
" ".$this->entrepot_id.
", ".$this->qty.
", ".((int) $this->
type).
",";
423 $sql .=
" ".$user->id.
",";
424 $sql .=
" '".$this->db->escape($label).
"',";
425 $sql .=
" ".($inventorycode ?
"'".$this->db->escape($inventorycode).
"'" :
"null").
",";
426 $sql .=
" ".price2num($price).
",";
427 $sql .=
" ".$fk_origin.
",";
428 $sql .=
" '".$this->db->escape($origintype).
"',";
429 $sql .=
" ".$fk_project;
432 dol_syslog(get_class($this).
"::_create insert record into stock_mouvement", LOG_DEBUG);
437 $mvid = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"stock_mouvement");
442 $this->error = $this->
db->lasterror();
443 $this->errors[] = $this->error;
448 $oldqty = $product->stock_reel;
449 $oldpmp = $product->pmp;
450 $oldqtywarehouse = 0;
456 $sql =
"SELECT rowid, reel FROM ".MAIN_DB_PREFIX.
"product_stock";
457 $sql .=
" WHERE fk_entrepot = ".$entrepot_id.
" AND fk_product = ".$fk_product;
459 dol_syslog(get_class($this).
"::_create check if a record already exists in product_stock", LOG_DEBUG);
463 $obj = $this->
db->fetch_object(
$resql);
467 $oldqtywarehouse = $obj->reel;
468 $fk_product_stock = $obj->rowid;
472 $this->errors[] = $this->
db->lasterror();
481 if ($type == 0 || $type == 3)
486 if ($price > 0 || (!empty($conf->global->STOCK_UPDATE_AWP_EVEN_WHEN_ENTRY_PRICE_IS_NULL) && $price == 0)) {
487 $oldqtytouse = ($oldqty >= 0 ? $oldqty : 0);
490 $newpmp =
price2num((($oldqtytouse * $oldpmp) + ($qty * $price)) / ($oldqtytouse + $qty),
'MU');
500 } elseif ($type == 1 || $type == 2) {
511 if ($alreadyarecord > 0)
513 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product_stock SET reel = reel + ".$qty;
514 $sql .=
" WHERE fk_entrepot = ".$entrepot_id.
" AND fk_product = ".$fk_product;
516 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"product_stock";
517 $sql .=
" (reel, fk_entrepot, fk_product) VALUES ";
518 $sql .=
" (".$qty.
", ".$entrepot_id.
", ".$fk_product.
")";
521 dol_syslog(get_class($this).
"::_create update stock value", LOG_DEBUG);
525 $this->errors[] = $this->
db->lasterror();
528 elseif (empty($fk_product_stock))
530 $fk_product_stock = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"product_stock");
535 if (!$error && !empty($conf->productbatch->enabled) && $product->hasbatch() && !$skip_batch)
537 if ($id_product_batch > 0)
539 $result = $this->
createBatch($id_product_batch, $qty);
541 $param_batch = array(
'fk_product_stock' =>$fk_product_stock,
'batchnumber'=>$batch);
544 if ($result < 0) $error++;
555 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product as p SET pmp = ".$newpmp.
",";
556 $sql .=
" stock=(SELECT SUM(ps.reel) FROM ".MAIN_DB_PREFIX.
"product_stock as ps WHERE ps.fk_product = p.rowid)";
557 $sql .=
" WHERE rowid = ".$fk_product;
559 dol_syslog(get_class($this).
"::_create update AWP", LOG_DEBUG);
563 $this->errors[] = $this->
db->lasterror();
570 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"product_stock WHERE reel = 0 AND rowid NOT IN (SELECT fk_product_stock FROM ".MAIN_DB_PREFIX.
"product_batch as pb)";
576 if (!$error && !empty($conf->global->PRODUIT_SOUSPRODUITS) && empty($conf->global->INDEPENDANT_SUBPRODUCT_STOCK) && empty($disablestockchangeforsubproduct))
578 $error = $this->
_createSubProduct($user, $fk_product, $entrepot_id, $qty, $type, 0, $label, $inventorycode);
581 if ($movestock && !$error)
585 if ($result < 0) $error++;
596 $this->
db->rollback();
597 dol_syslog(get_class($this).
"::_create error code=".$error, LOG_ERR);
619 $sql .=
" t.fk_product,";
620 $sql .=
" t.fk_entrepot,";
623 $sql .=
" t.type_mouvement,";
624 $sql .=
" t.fk_user_author,";
626 $sql .=
" t.fk_origin,";
627 $sql .=
" t.origintype,";
628 $sql .=
" t.inventorycode,";
631 $sql .=
" t.sellby,";
632 $sql .=
" t.fk_projet as fk_project";
633 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
634 $sql .=
' WHERE 1 = 1';
638 $sql .=
' AND t.rowid = '.$id;
643 $numrows = $this->
db->num_rows(
$resql);
645 $obj = $this->
db->fetch_object(
$resql);
647 $this->
id = $obj->rowid;
649 $this->product_id = $obj->fk_product;
650 $this->warehouse_id = $obj->fk_entrepot;
651 $this->qty = $obj->value;
652 $this->
type = $obj->type_mouvement;
654 $this->tms = $this->
db->jdate($obj->tms);
655 $this->datem = $this->
db->jdate($obj->datem);
656 $this->
price = $obj->price;
657 $this->fk_user_author = $obj->fk_user_author;
658 $this->label = $obj->label;
659 $this->fk_origin = $obj->fk_origin;
660 $this->origintype = $obj->origintype;
661 $this->inventorycode = $obj->inventorycode;
662 $this->batch = $obj->batch;
663 $this->eatby = $this->
db->jdate($obj->eatby);
664 $this->sellby = $this->
db->jdate($obj->sellby);
665 $this->fk_project = $obj->fk_project;
682 $this->errors[] =
'Error '.$this->db->lasterror();
683 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
705 private function _createSubProduct($user, $idProduct, $entrepot_id, $qty, $type, $price = 0, $label =
'', $inventorycode =
'')
713 $sql =
"SELECT fk_product_pere, fk_product_fils, qty";
714 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_association";
715 $sql .=
" WHERE fk_product_pere = ".$idProduct;
716 $sql .=
" AND incdec = 1";
718 dol_syslog(get_class($this).
"::_createSubProduct for parent product ".$idProduct, LOG_DEBUG);
723 while ($obj = $this->
db->fetch_object(
$resql))
725 $pids[$i] = $obj->fk_product_fils;
726 $pqtys[$i] = $obj->qty;
737 foreach ($pids as $key => $value)
742 $result = $tmpmove->_create($user, $pids[$key], $entrepot_id, ($qty * $pqtys[$key]), $type, 0, $label, $inventorycode);
745 $this->error = $tmpmove->error;
746 $this->errors = array_merge($this->errors, $tmpmove->errors);
749 $this->errors[] = $langs->trans(
"ErrorNoteAlsoThatSubProductCantBeFollowedByLot");
778 public function livraison($user, $fk_product, $entrepot_id, $qty, $price = 0, $label =
'', $datem =
'', $eatby =
'', $sellby =
'', $batch =
'', $id_product_batch = 0, $inventorycode =
'')
782 $skip_batch = empty($conf->productbatch->enabled);
784 return $this->
_create($user, $fk_product, $entrepot_id, (0 - $qty), 2, $price, $label, $inventorycode, $datem, $eatby, $sellby, $batch, $skip_batch, $id_product_batch);
804 public function reception($user, $fk_product, $entrepot_id, $qty, $price = 0, $label =
'', $eatby =
'', $sellby =
'', $batch =
'', $datem =
'', $id_product_batch = 0, $inventorycode =
'')
808 $skip_batch = empty($conf->productbatch->enabled);
810 return $this->
_create($user, $fk_product, $entrepot_id, $qty, 3, $price, $label, $inventorycode, $datem, $eatby, $sellby, $batch, $skip_batch, $id_product_batch);
847 $sql =
'SELECT SUM(value) as nb from '.MAIN_DB_PREFIX.
'stock_mouvement';
848 $sql .=
' WHERE fk_product = '.$productidselected;
849 $sql .=
" AND datem < '".$this->db->idate($datebefore).
"'";
851 dol_syslog(get_class($this).__METHOD__.
'', LOG_DEBUG);
855 $obj = $this->
db->fetch_object(
$resql);
856 if ($obj) $nb = $obj->nb;
857 return (empty($nb) ? 0 : $nb);
882 if (is_numeric($dluo))
884 $result = $pdluo->fetch($dluo);
885 if (empty($pdluo->id))
888 $this->error =
'Error. You ask a move on a record for a serial that does not exists anymore. May be you take the same serial on same warehouse several times in same shipment or it was used by another shipment. Remove this shipment and prepare another one.';
889 $this->errors[] = $this->error;
892 } elseif (is_array($dluo)) {
893 if (isset($dluo[
'fk_product_stock']))
895 $vfk_product_stock = $dluo[
'fk_product_stock'];
896 $vbatchnumber = $dluo[
'batchnumber'];
898 $result = $pdluo->find($vfk_product_stock,
'',
'', $vbatchnumber);
900 dol_syslog(get_class($this).
"::createBatch array param dluo must contain at least key fk_product_stock", LOG_ERR);
904 dol_syslog(get_class($this).
"::createBatch error invalid param dluo", LOG_ERR);
911 if ($pdluo->id > 0) {
914 if ($pdluo->qty == 0) {
915 $result = $pdluo->delete($user, 1);
917 $result = $pdluo->update($user, 1);
920 $pdluo->fk_product_stock = $vfk_product_stock;
922 $pdluo->eatby = empty($dluo[
'eatby']) ?
'' : $dluo[
'eatby'];
923 $pdluo->sellby = empty($dluo[
'sellby']) ?
'' : $dluo[
'sellby'];
924 $pdluo->batch = $vbatchnumber;
926 $result = $pdluo->create($user, 1);
929 $this->error = $pdluo->error;
930 $this->errors = $pdluo->errors;
951 switch ($origintype) {
953 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
957 require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
961 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
964 case 'order_supplier':
965 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
968 case 'invoice_supplier':
969 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
973 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
977 require_once DOL_DOCUMENT_ROOT.
'/mrp/class/mo.class.php';
978 $origin =
new Mo($this->
db);
981 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
982 $origin =
new User($this->
db);
985 require_once DOL_DOCUMENT_ROOT.
'/reception/class/reception.class.php';
993 $origintype_array = explode(
'@', $origintype);
994 $classname = ucfirst($origintype_array[0]);
995 $modulename = empty($origintype_array[1]) ? $classname : $origintype_array[1];
996 $result =
dol_include_once(
'/'.$modulename.
'/class/'.strtolower($classname).
'.class.php');
999 $classname = ucfirst($classname);
1000 $origin =
new $classname($this->
db);
1006 if (empty($origin) || !is_object($origin))
return '';
1008 if ($origin->fetch($fk_origin) > 0) {
1009 return $origin->getNomUrl(1);
1025 if (!empty($origin_element) && $origin_id > 0)
1028 if ($origin_element ==
'project')
1030 if (!class_exists(
'Project')) require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
1034 if (!empty($origin))
1036 $this->origin = $origin;
1037 $this->origin->id = $origin_id;
1052 global $user, $langs, $conf, $mysoc;
1071 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $maxlen = 24, $morecss =
'')
1073 global $langs, $conf, $db;
1078 $label =
'<u>'.$langs->trans(
"Movement").
' '.$this->
id.
'</u>';
1079 $label .=
'<div width="100%">';
1080 $label .=
'<b>'.$langs->trans(
'Label').
':</b> '.$this->label;
1081 $label .=
'<br><b>'.$langs->trans(
'Qty').
':</b> '.$this->qty;
1084 $link =
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?id='.$this->warehouse_id.
'&msid='.$this->
id.
'"';
1085 $link .= ($notooltip ?
'' :
' title="'.dol_escape_htmltag($label, 1).
'" class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"');
1091 $result .= ($link.img_object(($notooltip ?
'' : $label),
'stock', ($notooltip ?
'' :
'class="classfortooltip"')).$linkend);
1092 if ($withpicto != 2) $result .=
' ';
1094 $result .= $link.$this->id.$linkend;
1121 if ($mode == 0 || $mode == 1) {
1122 return $langs->trans(
'StatusNotApplicable');
1123 } elseif ($mode == 2) {
1124 return img_picto($langs->trans(
'StatusNotApplicable'),
'statut9').
' '.$langs->trans(
'StatusNotApplicable');
1125 } elseif ($mode == 3) {
1126 return img_picto($langs->trans(
'StatusNotApplicable'),
'statut9');
1127 } elseif ($mode == 4) {
1128 return img_picto($langs->trans(
'StatusNotApplicable'),
'statut9').
' '.$langs->trans(
'StatusNotApplicable');
1129 } elseif ($mode == 5) {
1130 return $langs->trans(
'StatusNotApplicable').
' '.
img_picto($langs->trans(
'StatusNotApplicable'),
'statut9');
1144 public function generateDocument($modele, $outputlangs =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1146 global $conf, $user, $langs;
1148 $langs->load(
"stocks");
1149 $outputlangs->load(
"products");
1152 $modele =
'stdmovement';
1154 if ($this->model_pdf) {
1155 $modele = $this->model_pdf;
1156 } elseif (!empty($conf->global->MOUVEMENT_ADDON_PDF)) {
1157 $modele = $conf->global->MOUVEMENT_ADDON_PDF;
1161 $modelpath =
"core/modules/stock/doc/";
1163 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
1173 public function delete(
User $user, $notrigger =
false)
_create($user, $fk_product, $entrepot_id, $qty, $type, $price=0, $label= '', $inventorycode= '', $datem= '', $eatby= '', $sellby= '', $batch= '', $skip_batch=false, $id_product_batch=0, $disablestockchangeforsubproduct=0)
Add a movement of stock (in one direction only).
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname= '')
Make an include_once using default root and alternate root if it fails.
getLibStatut($mode=0)
Return label statut.
deleteCommon(User $user, $notrigger=false, $forcechilddeletion=0)
Delete object in database.
Class to manage stock movements.
__construct($db)
Constructor.
Class with list of lots and properties.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
reception($user, $fk_product, $entrepot_id, $qty, $price=0, $label= '', $eatby= '', $sellby= '', $batch= '', $datem= '', $id_product_batch=0, $inventorycode= '')
Increase stock for product and subproducts.
Class to manage products or services.
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
_createSubProduct($user, $idProduct, $entrepot_id, $qty, $type, $price=0, $label= '', $inventorycode= '')
Create movement in database for all subproducts.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for properties) With native = 0: P...
commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null)
Common function for all objects extending CommonObject for generating documents.
const TYPE_SERVICE
Service.
Class to manage suppliers invoices.
calculateBalanceForProductBefore($productidselected, $datebefore)
Return nb of subproducts lines for a product.
$conf db
API class for accounts.
LibStatut($mode=0)
Renvoi le libelle d'un status donne.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
livraison($user, $fk_product, $entrepot_id, $qty, $price=0, $label= '', $datem= '', $eatby= '', $sellby= '', $batch= '', $id_product_batch=0, $inventorycode= '')
Decrease stock for product and subproducts.
Class to manage projects.
initAsSpecimen()
Initialise an instance with random values.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
Class to manage shipments.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Class to manage receptions.
Class to manage customers orders.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
getNomUrl($withpicto=0, $option= '', $notooltip=0, $maxlen=24, $morecss= '')
Return a link (with optionaly the picto) Use this->id,this->lastname, this->firstname.
dol_getdate($timestamp, $fast=false, $forcetimezone= '')
Return an array with locale date info.
setOrigin($origin_element, $origin_id)
Set attribute origin to object.
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...
Class to manage predefined suppliers products.
fetch($id)
Load object in memory from the database.
Manage record for batch number management.
generateDocument($modele, $outputlangs= '', $hidedetails=0, $hidedesc=0, $hideref=0)
Create object on disk.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
call_trigger($triggerName, $user)
Call trigger based on this instance.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $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...
Class to manage invoices.
createBatch($dluo, $qty)
Create or update batch record (update table llx_product_batch).
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Parent class of all other business classes (invoices, contracts, proposals, orders, ...)
get_origin($fk_origin, $origintype)
Return Url link of origin object.
Class to manage warehouses.