dolibarr 19.0.4
inventory.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2007-2019 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2014-2016 Juanjo Menent <jmenent@2byte.es>
4 * Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
5 * Copyright (C) 2015 Raphaƫl Doursenaud <rdoursenaud@gpcsolutions.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27// Put here all includes required by your class file
28require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
29require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
30//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
31//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
32
38{
42 public $element = 'inventory';
43
47 public $table_element = 'inventory';
48
52 public $ismultientitymanaged = 1;
53
57 public $isextrafieldmanaged = 0;
58
62 public $picto = 'inventory';
63
64 const STATUS_DRAFT = 0; // Draft
65 const STATUS_VALIDATED = 1; // Inventory is in process
66 const STATUS_RECORDED = 2; // Inventory is finisged. Stock movement has been recorded.
67 const STATUS_CANCELED = 9; // Canceled
68
95 // BEGIN MODULEBUILDER PROPERTIES
99 public $fields = array(
100 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>'Id',),
101 'ref' => array('type'=>'varchar(64)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>'Reference of object', 'css'=>'maxwidth150'),
102 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,),
103 'title' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>25, 'css'=>'minwidth300', 'csslist'=>'tdoverflowmax150', 'alwayseditable'=>1),
104 'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Warehouse', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'index'=>1, 'help'=>'InventoryForASpecificWarehouse', 'picto'=>'stock', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'csslist'=>'tdoverflowmax150'),
105 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'get_name_url_params' => '0::0:-1:0::1', 'visible'=>1, 'enabled'=>1, 'position'=>32, 'index'=>1, 'help'=>'InventoryForASpecificProduct', 'picto'=>'product', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'csslist'=>'tdoverflowmax150'),
106 'categories_product' => array('type'=>'chkbxlst:categorie:label:rowid::type=0:0:', 'label'=>'OrProductsWithCategories', 'visible'=>3, 'enabled'=>1, 'position'=>33, 'help'=>'', 'picto'=>'category', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx'),
107 'date_inventory' => array('type'=>'date', 'label'=>'DateValue', 'visible'=>1, 'enabled'=>'$conf->global->STOCK_INVENTORY_ADD_A_VALUE_DATE', 'position'=>35, 'csslist'=>'nowraponall'), // This date is not used so disabled by default.
108 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500, 'csslist'=>'nowraponall'),
109 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501, 'csslist'=>'nowraponall'),
110 'date_validation' => array('type'=>'datetime', 'label'=>'DateValidation', 'visible'=>-2, 'enabled'=>1, 'position'=>502, 'csslist'=>'nowraponall'),
111 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510, 'foreignkey'=>'user.rowid', 'csslist'=>'tdoverflowmax150'),
112 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511, 'csslist'=>'tdoverflowmax150'),
113 'fk_user_valid' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'visible'=>-2, 'enabled'=>1, 'position'=>512, 'csslist'=>'tdoverflowmax150'),
114 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000),
115 'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>4, 'enabled'=>1, 'position'=>1000, 'notnull'=>1, 'default'=>0, 'index'=>1, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 2=>'Closed', 9=>'Canceled'))
116 );
117
121 public $rowid;
122
126 public $ref;
127
131 public $entity;
132
136 public $fk_warehouse;
137
141 public $fk_product;
142
146 public $categories_product;
147 public $date_inventory;
148 public $title;
149
153 public $status;
154
158 public $date_creation;
159
163 public $date_validation;
164 public $tms;
165
169 public $fk_user_creat;
170
174 public $fk_user_modif;
175
179 public $fk_user_valid;
180
184 public $import_key;
185 // END MODULEBUILDER PROPERTIES
186
187
188
189 // If this object has a subtable with lines
190
194 public $table_element_line = 'inventorydet';
195
199 public $fk_element = 'fk_inventory';
200
204 public $class_element_line = 'Inventoryline';
205
209 protected $childtables = array();
213 protected $childtablesoncascade = array('inventorydet');
214
218 public $lines = array();
219
220
221
227 public function __construct(DoliDB $db)
228 {
229 global $conf;
230
231 $this->db = $db;
232
233 if (!getDolGlobalString('MAIN_SHOW_TECHNICAL_ID')) {
234 $this->fields['rowid']['visible'] = 0;
235 }
236 if (!isModEnabled('multicompany')) {
237 $this->fields['entity']['enabled'] = 0;
238 }
239 }
240
241
249 public function create(User $user, $notrigger = false)
250 {
251 $result = $this->createCommon($user, $notrigger);
252
253 return $result;
254 }
255
264 public function validate(User $user, $notrigger = false, $include_sub_warehouse = 0)
265 {
266 global $conf;
267 $this->db->begin();
268
269 $result = 0;
270
271 if ($this->status == self::STATUS_DRAFT) {
272 // Delete inventory
273 $sql = 'DELETE FROM '.$this->db->prefix().'inventorydet WHERE fk_inventory = '.((int) $this->id);
274 $resql = $this->db->query($sql);
275 if (!$resql) {
276 $this->error = $this->db->lasterror();
277 $this->db->rollback();
278 return -1;
279 }
280
281 // Scan existing stock to prefill the inventory
282 $sql = "SELECT ps.rowid, ps.fk_entrepot as fk_warehouse, ps.fk_product, ps.reel,";
283 $sql .= " pb.batch, pb.qty";
284 $sql .= " FROM ".$this->db->prefix()."product_stock as ps";
285 $sql .= " LEFT JOIN ".$this->db->prefix()."product_batch as pb ON pb.fk_product_stock = ps.rowid,";
286 $sql .= " ".$this->db->prefix()."product as p, ".$this->db->prefix()."entrepot as e";
287 $sql .= " WHERE p.entity IN (".getEntity('product').")";
288 $sql .= " AND ps.fk_product = p.rowid AND ps.fk_entrepot = e.rowid";
289 if (!getDolGlobalString('STOCK_SUPPORTS_SERVICES')) {
290 $sql .= " AND p.fk_product_type = 0";
291 }
292 if ($this->fk_product > 0) {
293 $sql .= " AND ps.fk_product = ".((int) $this->fk_product);
294 }
295 if ($this->fk_warehouse > 0) {
296 $sql .= " AND (ps.fk_entrepot = ".((int) $this->fk_warehouse);
297 if (!empty($include_sub_warehouse) && getDolGlobalInt('INVENTORY_INCLUDE_SUB_WAREHOUSE')) {
298 $TChildWarehouses = array();
299 $this->getChildWarehouse($this->fk_warehouse, $TChildWarehouses);
300 $sql .= " OR ps.fk_entrepot IN (".$this->db->sanitize(join(',', $TChildWarehouses)).")";
301 }
302 $sql .= ')';
303 }
304 if (!empty($this->categories_product)) {
305 $sql .= " AND EXISTS (";
306 $sql .= " SELECT cp.fk_product";
307 $sql .= " FROM ".$this->db->prefix()."categorie_product AS cp";
308 $sql .= " WHERE cp.fk_product = ps.fk_product";
309 $sql .= " AND cp.fk_categorie IN (".$this->db->sanitize($this->categories_product).")";
310 $sql .= ")";
311 }
312 if (getDolGlobalInt('PRODUIT_SOUSPRODUITS')) {
313 $sql .= " AND NOT EXISTS (";
314 $sql .= " SELECT pa.rowid";
315 $sql .= " FROM ".$this->db->prefix()."product_association as pa";
316 $sql .= " WHERE pa.fk_product_pere = ps.fk_product";
317 $sql .= ")";
318 }
319
320 $inventoryline = new InventoryLine($this->db);
321
322 $resql = $this->db->query($sql);
323 if ($resql) {
324 $num = $this->db->num_rows($resql);
325
326 $i = 0;
327 while ($i < $num) {
328 $obj = $this->db->fetch_object($resql);
329
330 $inventoryline->fk_inventory = $this->id;
331 $inventoryline->fk_warehouse = $obj->fk_warehouse;
332 $inventoryline->fk_product = $obj->fk_product;
333 $inventoryline->batch = $obj->batch;
334 $inventoryline->datec = dol_now();
335
336 if (isModEnabled('productbatch')) {
337 $inventoryline->qty_stock = ($obj->batch ? $obj->qty : $obj->reel); // If there is batch detail, we take qty for batch, else global qty
338 } else {
339 $inventoryline->qty_stock = $obj->reel;
340 }
341
342 $resultline = $inventoryline->create($user);
343 if ($resultline <= 0) {
344 $this->error = $inventoryline->error;
345 $this->errors = $inventoryline->errors;
346 $result = -1;
347 break;
348 }
349
350 $i++;
351 }
352 } else {
353 $result = -1;
354 $this->error = $this->db->lasterror();
355 }
356 }
357
358 if ($result >= 0) {
359 $result = $this->setStatut($this::STATUS_VALIDATED, null, '', 'INVENTORY_VALIDATED');
360 }
361
362 if ($result > 0) {
363 $this->db->commit();
364 } else {
365 $this->db->rollback();
366 }
367 return $result;
368 }
369
377 public function setDraft(User $user, $notrigger = false)
378 {
379 $this->db->begin();
380
381 // Delete inventory
382 $sql = 'DELETE FROM '.$this->db->prefix().'inventorydet WHERE fk_inventory = '.((int) $this->id);
383 $resql = $this->db->query($sql);
384 if (!$resql) {
385 $this->error = $this->db->lasterror();
386 $this->db->rollback();
387 return -1;
388 }
389
390 $result = $this->setStatut($this::STATUS_DRAFT, null, '', 'INVENTORY_DRAFT');
391
392 if ($result > 0) {
393 $this->db->commit();
394 } else {
395 $this->db->rollback();
396 }
397 return $result;
398 }
399
407 public function setRecorded(User $user, $notrigger = false)
408 {
409 $this->db->begin();
410
411 $result = $this->setStatut($this::STATUS_RECORDED, null, '', 'INVENTORY_RECORDED');
412
413 if ($result > 0) {
414 $this->db->commit();
415 } else {
416 $this->db->rollback();
417 return -1;
418 }
419 return $result;
420 }
421
429 public function setCanceled(User $user, $notrigger = false)
430 {
431 $this->db->begin();
432
433 $result = $this->setStatut($this::STATUS_CANCELED, null, '', 'INVENTORY_CANCELED');
434
435 if ($result > 0) {
436 $this->db->commit();
437 } else {
438 $this->db->rollback();
439 return -1;
440 }
441 return $result;
442 }
443
451 public function createFromClone(User $user, $fromid)
452 {
453 global $hookmanager, $langs;
454 $error = 0;
455
456 dol_syslog(__METHOD__, LOG_DEBUG);
457
458 $object = new self($this->db);
459
460 $this->db->begin();
461
462 // Load source object
463 $object->fetchCommon($fromid);
464 // Reset some properties
465 unset($object->id);
466 unset($object->fk_user_creat);
467 unset($object->import_key);
468
469 // Clear fields
470 $object->ref = "copy_of_".$object->ref;
471 $object->title = $langs->trans("CopyOf")." ".$object->title;
472 // ...
473
474 // Create clone
475 $object->context['createfromclone'] = 'createfromclone';
476 $result = $object->createCommon($user);
477 if ($result < 0) {
478 $error++;
479 $this->error = $object->error;
480 $this->errors = $object->errors;
481 }
482
483 unset($object->context['createfromclone']);
484
485 // End
486 if (!$error) {
487 $this->db->commit();
488 return $object;
489 } else {
490 $this->db->rollback();
491 return -1;
492 }
493 }
494
502 public function fetch($id, $ref = null)
503 {
504 $result = $this->fetchCommon($id, $ref);
505 //if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines();
506 return $result;
507 }
508
514 /*public function fetchLines()
515 {
516 $this->lines=array();
517
518 // Load lines with object MyObjectLine
519
520 return count($this->lines)?1:0;
521 }*/
522
530 public function update(User $user, $notrigger = false)
531 {
532 return $this->updateCommon($user, $notrigger);
533 }
534
542 public function delete(User $user, $notrigger = false)
543 {
544 return $this->deleteCommon($user, $notrigger);
545 }
546
555 public function deleteLine(User $user, $idline, $notrigger = false)
556 {
557 if ($this->status < 0) {
558 $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus';
559 return -2;
560 }
561
562 return $this->deleteLineCommon($user, $idline, $notrigger);
563 }
564
575 public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
576 {
577 global $db, $conf, $langs;
578 global $dolibarr_main_authentication, $dolibarr_main_demo;
579 global $menumanager;
580
581 if (!empty($conf->dol_no_mouse_hover)) {
582 $notooltip = 1; // Force disable tooltips
583 }
584
585 $result = '';
586 $companylink = '';
587
588 $label = '<u>'.$langs->trans("Inventory").'</u>';
589 $label .= '<br>';
590 $label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
591
592 $url = dol_buildpath('/product/inventory/card.php', 1).'?id='.$this->id;
593
594 $linkclose = '';
595 if (empty($notooltip)) {
596 if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
597 $label = $langs->trans("ShowInventory");
598 $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
599 }
600 $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
601 $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
602 } else {
603 $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
604 }
605
606 $linkstart = '<a href="'.$url.'"';
607 $linkstart .= $linkclose.'>';
608 $linkend = '</a>';
609
610 $result .= $linkstart;
611 if ($withpicto) {
612 $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
613 }
614 if ($withpicto != 2) {
615 $result .= $this->ref;
616 }
617 $result .= $linkend;
618 //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
619
620 return $result;
621 }
622
629 public function getLibStatut($mode = 0)
630 {
631 return $this->LibStatut($this->status, $mode);
632 }
633
634 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
642 public static function LibStatut($status, $mode = 0)
643 {
644 // phpcs:enable
645 global $langs;
646
647 $labelStatus = array();
648 $labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
649 $labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated').' ('.$langs->transnoentitiesnoconv('InventoryStartedShort').')';
650 $labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Canceled');
651 $labelStatus[self::STATUS_RECORDED] = $langs->transnoentitiesnoconv('Closed');
652 $labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
653 $labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('InventoryStartedShort');
654 $labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Canceled');
655 $labelStatusShort[self::STATUS_RECORDED] = $langs->transnoentitiesnoconv('Closed');
656
657 $statusType = 'status'.$status;
658 if ($status == self::STATUS_RECORDED) {
659 $statusType = 'status6';
660 }
661
662 return dolGetStatus($labelStatus[$status], $labelStatusShort[$status], '', $statusType, $mode);
663 }
664
672 public function getKanbanView($option = '', $arraydata = null)
673 {
674 global $conf, $langs;
675
676 $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
677
678 $return = '<div class="box-flex-item box-flex-grow-zero">';
679 $return .= '<div class="info-box info-box-sm">';
680 $return .= '<span class="info-box-icon bg-infobox-action">';
681 $return .= img_picto('', $this->picto);
682 $return .= '</span>';
683 $return .= '<div class="info-box-content">';
684 $return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).'</span>';
685 if ($selected >= 0) {
686 $return .= '<input id="cb'.$this->id.'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->id.'"'.($selected ? ' checked="checked"' : '').'>';
687 }
688 if (property_exists($this, 'label')) {
689 $return .= ' <div class="inline-block opacitymedium valignmiddle tdoverflowmax100">'.$this->label.'</div>';
690 }
691 if (property_exists($this, 'amount')) {
692 $return .= '<br>';
693 $return .= '<span class="info-box-label amount">'.price($this->amount, 0, $langs, 1, -1, -1, $conf->currency).'</span>';
694 }
695 if (method_exists($this, 'getLibStatut')) {
696 $return .= '<br><div class="info-box-status">'.$this->getLibStatut(3).'</div>';
697 }
698 $return .= '</div>';
699 $return .= '</div>';
700 $return .= '</div>';
701
702 return $return;
703 }
704
711 public function info($id)
712 {
713 $sql = "SELECT rowid, date_creation as datec, tms as datem, date_validation as datev,";
714 $sql .= " fk_user_creat, fk_user_modif, fk_user_valid";
715 $sql .= " FROM ".$this->db->prefix().$this->table_element." as t";
716 $sql .= " WHERE t.rowid = ".((int) $id);
717 $result = $this->db->query($sql);
718 if ($result) {
719 if ($this->db->num_rows($result)) {
720 $obj = $this->db->fetch_object($result);
721
722 $this->id = $obj->rowid;
723
724 $this->user_creation_id = $obj->fk_user_creat;
725 $this->user_modification_id = $obj->fk_user_modif;
726 $this->user_validation_id = $obj->fk_user_valid;
727
728 $this->date_creation = $this->db->jdate($obj->datec);
729 $this->date_modification = $this->db->jdate($obj->datem);
730 $this->date_validation = $this->db->jdate($obj->datev);
731 }
732
733 $this->db->free($result);
734 } else {
735 dol_print_error($this->db);
736 }
737 }
738
745 public function initAsSpecimen()
746 {
747 $this->initAsSpecimenCommon();
748 $this->title = '';
749 }
750
758 public function getChildWarehouse($id, &$TChildWarehouse)
759 {
760 $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'entrepot';
761 $sql.= ' WHERE fk_parent='.(int) $id;
762 $sql.= ' ORDER BY rowid';
763 $resql = $this->db->query($sql);
764 if ($resql && $this->db->num_rows($resql)>0) {
765 while ($obj = $this->db->fetch_object($resql)) {
766 $TChildWarehouse[] = $obj->rowid;
767 $this->getChildWarehouse($obj->rowid, $TChildWarehouse);
768 }
769 return 1;
770 } else {
771 return -1;
772 }
773 }
774}
775
780{
784 public $element = 'inventoryline';
785
789 public $table_element = 'inventorydet';
790
794 public $ismultientitymanaged = 0;
795
799 public $isextrafieldmanaged = 0;
800
804 public $picto = 'stock';
805
823 // BEGIN MODULEBUILDER PROPERTIES
827 public $fields = array(
828 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>'Id',),
829 'fk_inventory' => array('type'=>'integer:Inventory:product/inventory/class/inventory.class.php', 'label'=>'Inventory', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'index'=>1, 'help'=>'LinkToInventory'),
830 'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Warehouse', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'index'=>1, 'help'=>'LinkToThirdparty'),
831 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'visible'=>1, 'enabled'=>1, 'position'=>32, 'index'=>1, 'help'=>'LinkToProduct'),
832 'batch' => array('type'=>'string', 'label'=>'Batch', 'visible'=>1, 'enabled'=>1, 'position'=>32, 'index'=>1, 'help'=>'LinkToProduct'),
833 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500),
834 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501),
835 'qty_stock' => array('type'=>'double', 'label'=>'QtyFound', 'visible'=>1, 'enabled'=>1, 'position'=>32, 'index'=>1, 'help'=>'Qty we found/want (to define during draft edition)'),
836 'qty_view' => array('type'=>'double', 'label'=>'QtyBefore', 'visible'=>1, 'enabled'=>1, 'position'=>33, 'index'=>1, 'help'=>'Qty before (filled once movements are validated)'),
837 'qty_regulated' => array('type'=>'double', 'label'=>'QtyDelta', 'visible'=>1, 'enabled'=>1, 'position'=>34, 'index'=>1, 'help'=>'Qty aadded or removed (filled once movements are validated)'),
838 'pmp_real' => array('type'=>'double', 'label'=>'PMPReal', 'visible'=>1, 'enabled'=>1, 'position'=>35),
839 'pmp_expected' => array('type'=>'double', 'label'=>'PMPExpected', 'visible'=>1, 'enabled'=>1, 'position'=>36),
840 );
841
845 public $rowid;
846
847 public $fk_inventory;
848 public $fk_warehouse;
849 public $fk_product;
850 public $batch;
851 public $datec;
852 public $tms;
853 public $qty_stock;
854 public $qty_view;
855 public $qty_regulated;
856 public $pmp_real;
857 public $pmp_expected;
858
859
867 public function create(User $user, $notrigger = false)
868 {
869 return $this->createCommon($user, $notrigger);
870 }
871
879 public function fetch($id, $ref = null)
880 {
881 $result = $this->fetchCommon($id, $ref);
882 //if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines();
883 return $result;
884 }
885
893 public function update(User $user, $notrigger = false)
894 {
895 return $this->updateCommon($user, $notrigger);
896 }
897
905 public function delete(User $user, $notrigger = false)
906 {
907 return $this->deleteCommon($user, $notrigger);
908 //return $this->deleteCommon($user, $notrigger, 1);
909 }
910}
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Definition security.php:604
Parent class of all other business classes (invoices, contracts, proposals, orders,...
deleteLineCommon(User $user, $idline, $notrigger=false)
Delete a line of object in database.
createCommon(User $user, $notrigger=false)
Create object into database.
deleteCommon(User $user, $notrigger=false, $forcechilddeletion=0)
Delete object in database.
setStatut($status, $elementId=null, $elementType='', $trigkey='', $fieldstatus='fk_statut')
Set status of an object.
initAsSpecimenCommon()
Initialise object with example values Id must be 0 if object instance is a specimen.
updateCommon(User $user, $notrigger=false)
Update object into database.
fetchCommon($id, $ref=null, $morewhere='', $noextrafields=0)
Load object in memory from the database.
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
Class to manage Dolibarr database access.
Class for Inventory.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionaly the picto)
deleteLine(User $user, $idline, $notrigger=false)
Delete a line of object in database.
create(User $user, $notrigger=false)
Create object into database.
getKanbanView($option='', $arraydata=null)
Return a thumb for kanban views.
__construct(DoliDB $db)
Constructor.
getLibStatut($mode=0)
Return the label of the status.
info($id)
Charge les informations d'ordre info dans l'objet commande.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
fetch($id, $ref=null)
Load object in memory from the database.
validate(User $user, $notrigger=false, $include_sub_warehouse=0)
Validate inventory (start it)
getChildWarehouse($id, &$TChildWarehouse)
Return the child warehouse of the current one.
setDraft(User $user, $notrigger=false)
Go back to draft.
static LibStatut($status, $mode=0)
Return the status.
setRecorded(User $user, $notrigger=false)
Set to inventory to status "Closed".
update(User $user, $notrigger=false)
Load object lines in memory from the database.
createFromClone(User $user, $fromid)
Clone and object into another one.
setCanceled(User $user, $notrigger=false)
Set to Canceled.
Class InventoryLine.
update(User $user, $notrigger=false)
Update object into database.
fetch($id, $ref=null)
Load object in memory from the database.
create(User $user, $notrigger=false)
Create object in database.
Class to manage Dolibarr users.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a 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_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.