dolibarr 18.0.6
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'),
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 (empty($conf->global->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
263 public function validate(User $user, $notrigger = false)
264 {
265 global $conf;
266 $this->db->begin();
267
268 $result = 0;
269
270 if ($this->status == self::STATUS_DRAFT) {
271 // Delete inventory
272 $sql = 'DELETE FROM '.$this->db->prefix().'inventorydet WHERE fk_inventory = '.((int) $this->id);
273 $resql = $this->db->query($sql);
274 if (!$resql) {
275 $this->error = $this->db->lasterror();
276 $this->db->rollback();
277 return -1;
278 }
279
280 // Scan existing stock to prefill the inventory
281 $sql = "SELECT ps.rowid, ps.fk_entrepot as fk_warehouse, ps.fk_product, ps.reel,";
282 $sql .= " pb.batch, pb.qty";
283 $sql .= " FROM ".$this->db->prefix()."product_stock as ps";
284 $sql .= " LEFT JOIN ".$this->db->prefix()."product_batch as pb ON pb.fk_product_stock = ps.rowid,";
285 $sql .= " ".$this->db->prefix()."product as p, ".$this->db->prefix()."entrepot as e";
286 $sql .= " WHERE p.entity IN (".getEntity('product').")";
287 $sql .= " AND ps.fk_product = p.rowid AND ps.fk_entrepot = e.rowid";
288 if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
289 $sql .= " AND p.fk_product_type = 0";
290 }
291 if ($this->fk_product > 0) {
292 $sql .= " AND ps.fk_product = ".((int) $this->fk_product);
293 }
294 if ($this->fk_warehouse > 0) {
295 $sql .= " AND ps.fk_entrepot = ".((int) $this->fk_warehouse);
296 }
297 if (!empty($this->categories_product)) {
298 $sql .= " AND EXISTS (";
299 $sql .= " SELECT cp.fk_product";
300 $sql .= " FROM ".$this->db->prefix()."categorie_product AS cp";
301 $sql .= " WHERE cp.fk_product = ps.fk_product";
302 $sql .= " AND cp.fk_categorie IN (".$this->db->sanitize($this->categories_product).")";
303 $sql .= ")";
304 }
305
306 $inventoryline = new InventoryLine($this->db);
307
308 $resql = $this->db->query($sql);
309 if ($resql) {
310 $num = $this->db->num_rows($resql);
311
312 $i = 0;
313 while ($i < $num) {
314 $obj = $this->db->fetch_object($resql);
315
316 $inventoryline->fk_inventory = $this->id;
317 $inventoryline->fk_warehouse = $obj->fk_warehouse;
318 $inventoryline->fk_product = $obj->fk_product;
319 $inventoryline->batch = $obj->batch;
320 $inventoryline->datec = dol_now();
321
322 if (isModEnabled('productbatch')) {
323 $inventoryline->qty_stock = ($obj->batch ? $obj->qty : $obj->reel); // If there is batch detail, we take qty for batch, else global qty
324 } else {
325 $inventoryline->qty_stock = $obj->reel;
326 }
327
328 $resultline = $inventoryline->create($user);
329 if ($resultline <= 0) {
330 $this->error = $inventoryline->error;
331 $this->errors = $inventoryline->errors;
332 $result = -1;
333 break;
334 }
335
336 $i++;
337 }
338 } else {
339 $result = -1;
340 $this->error = $this->db->lasterror();
341 }
342 }
343
344 if ($result >= 0) {
345 $result = $this->setStatut($this::STATUS_VALIDATED, null, '', 'INVENTORY_VALIDATED');
346 }
347
348 if ($result > 0) {
349 $this->db->commit();
350 } else {
351 $this->db->rollback();
352 }
353 return $result;
354 }
355
363 public function setDraft(User $user, $notrigger = false)
364 {
365 $this->db->begin();
366
367 // Delete inventory
368 $sql = 'DELETE FROM '.$this->db->prefix().'inventorydet WHERE fk_inventory = '.((int) $this->id);
369 $resql = $this->db->query($sql);
370 if (!$resql) {
371 $this->error = $this->db->lasterror();
372 $this->db->rollback();
373 return -1;
374 }
375
376 $result = $this->setStatut($this::STATUS_DRAFT, null, '', 'INVENTORY_DRAFT');
377
378 if ($result > 0) {
379 $this->db->commit();
380 } else {
381 $this->db->rollback();
382 }
383 return $result;
384 }
385
393 public function setRecorded(User $user, $notrigger = false)
394 {
395 $this->db->begin();
396
397 $result = $this->setStatut($this::STATUS_RECORDED, null, '', 'INVENTORY_RECORDED');
398
399 if ($result > 0) {
400 $this->db->commit();
401 } else {
402 $this->db->rollback();
403 return -1;
404 }
405 return $result;
406 }
407
415 public function setCanceled(User $user, $notrigger = false)
416 {
417 $this->db->begin();
418
419 $result = $this->setStatut($this::STATUS_CANCELED, null, '', 'INVENTORY_CANCELED');
420
421 if ($result > 0) {
422 $this->db->commit();
423 } else {
424 $this->db->rollback();
425 return -1;
426 }
427 return $result;
428 }
429
437 public function createFromClone(User $user, $fromid)
438 {
439 global $hookmanager, $langs;
440 $error = 0;
441
442 dol_syslog(__METHOD__, LOG_DEBUG);
443
444 $object = new self($this->db);
445
446 $this->db->begin();
447
448 // Load source object
449 $object->fetchCommon($fromid);
450 // Reset some properties
451 unset($object->id);
452 unset($object->fk_user_creat);
453 unset($object->import_key);
454
455 // Clear fields
456 $object->ref = "copy_of_".$object->ref;
457 $object->title = $langs->trans("CopyOf")." ".$object->title;
458 // ...
459
460 // Create clone
461 $object->context['createfromclone'] = 'createfromclone';
462 $result = $object->createCommon($user);
463 if ($result < 0) {
464 $error++;
465 $this->error = $object->error;
466 $this->errors = $object->errors;
467 }
468
469 unset($object->context['createfromclone']);
470
471 // End
472 if (!$error) {
473 $this->db->commit();
474 return $object;
475 } else {
476 $this->db->rollback();
477 return -1;
478 }
479 }
480
488 public function fetch($id, $ref = null)
489 {
490 $result = $this->fetchCommon($id, $ref);
491 //if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines();
492 return $result;
493 }
494
500 /*public function fetchLines()
501 {
502 $this->lines=array();
503
504 // Load lines with object MyObjectLine
505
506 return count($this->lines)?1:0;
507 }*/
508
516 public function update(User $user, $notrigger = false)
517 {
518 return $this->updateCommon($user, $notrigger);
519 }
520
528 public function delete(User $user, $notrigger = false)
529 {
530 return $this->deleteCommon($user, $notrigger);
531 }
532
541 public function deleteLine(User $user, $idline, $notrigger = false)
542 {
543 if ($this->status < 0) {
544 $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus';
545 return -2;
546 }
547
548 return $this->deleteLineCommon($user, $idline, $notrigger);
549 }
550
561 public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
562 {
563 global $db, $conf, $langs;
564 global $dolibarr_main_authentication, $dolibarr_main_demo;
565 global $menumanager;
566
567 if (!empty($conf->dol_no_mouse_hover)) {
568 $notooltip = 1; // Force disable tooltips
569 }
570
571 $result = '';
572 $companylink = '';
573
574 $label = '<u>'.$langs->trans("Inventory").'</u>';
575 $label .= '<br>';
576 $label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
577
578 $url = dol_buildpath('/product/inventory/card.php', 1).'?id='.$this->id;
579
580 $linkclose = '';
581 if (empty($notooltip)) {
582 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
583 $label = $langs->trans("ShowInventory");
584 $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
585 }
586 $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
587 $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
588 } else {
589 $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
590 }
591
592 $linkstart = '<a href="'.$url.'"';
593 $linkstart .= $linkclose.'>';
594 $linkend = '</a>';
595
596 $result .= $linkstart;
597 if ($withpicto) {
598 $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);
599 }
600 if ($withpicto != 2) {
601 $result .= $this->ref;
602 }
603 $result .= $linkend;
604 //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
605
606 return $result;
607 }
608
615 public function getLibStatut($mode = 0)
616 {
617 return $this->LibStatut($this->status, $mode);
618 }
619
620 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
628 public static function LibStatut($status, $mode = 0)
629 {
630 // phpcs:enable
631 global $langs;
632
633 $labelStatus = array();
634 $labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
635 $labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated').' ('.$langs->transnoentitiesnoconv('InventoryStartedShort').')';
636 $labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Canceled');
637 $labelStatus[self::STATUS_RECORDED] = $langs->transnoentitiesnoconv('Closed');
638 $labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
639 $labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('InventoryStartedShort');
640 $labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Canceled');
641 $labelStatusShort[self::STATUS_RECORDED] = $langs->transnoentitiesnoconv('Closed');
642
643 $statusType = 'status'.$status;
644 if ($status == self::STATUS_RECORDED) {
645 $statusType = 'status6';
646 }
647
648 return dolGetStatus($labelStatus[$status], $labelStatusShort[$status], '', $statusType, $mode);
649 }
650
658 public function getKanbanView($option = '', $arraydata = null)
659 {
660 global $conf, $langs;
661
662 $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
663
664 $return = '<div class="box-flex-item box-flex-grow-zero">';
665 $return .= '<div class="info-box info-box-sm">';
666 $return .= '<span class="info-box-icon bg-infobox-action">';
667 $return .= img_picto('', $this->picto);
668 $return .= '</span>';
669 $return .= '<div class="info-box-content">';
670 $return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).'</span>';
671 $return .= '<input id="cb'.$this->id.'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->id.'"'.($selected ? ' checked="checked"' : '').'>';
672 if (property_exists($this, 'label')) {
673 $return .= ' <div class="inline-block opacitymedium valignmiddle tdoverflowmax100">'.$this->label.'</div>';
674 }
675 if (property_exists($this, 'amount')) {
676 $return .= '<br>';
677 $return .= '<span class="info-box-label amount">'.price($this->amount, 0, $langs, 1, -1, -1, $conf->currency).'</span>';
678 }
679 if (method_exists($this, 'getLibStatut')) {
680 $return .= '<br><div class="info-box-status margintoponly">'.$this->getLibStatut(3).'</div>';
681 }
682 $return .= '</div>';
683 $return .= '</div>';
684 $return .= '</div>';
685
686 return $return;
687 }
688
695 public function info($id)
696 {
697 $sql = "SELECT rowid, date_creation as datec, tms as datem, date_validation as datev,";
698 $sql .= " fk_user_creat, fk_user_modif, fk_user_valid";
699 $sql .= " FROM ".$this->db->prefix().$this->table_element." as t";
700 $sql .= " WHERE t.rowid = ".((int) $id);
701 $result = $this->db->query($sql);
702 if ($result) {
703 if ($this->db->num_rows($result)) {
704 $obj = $this->db->fetch_object($result);
705
706 $this->id = $obj->rowid;
707
708 if ($obj->fk_user_creat > 0) {
709 $cuser = new User($this->db);
710 $cuser->fetch($obj->fk_user_creat);
711 $this->user_creation = $cuser;
712 }
713
714 if ($obj->fk_user_modif > 0) {
715 $muser = new User($this->db);
716 $muser->fetch($obj->fk_user_modif);
717 $this->user_creation = $muser;
718 }
719
720 if ($obj->fk_user_valid > 0) {
721 $vuser = new User($this->db);
722 $vuser->fetch($obj->fk_user_valid);
723 $this->user_validation = $vuser;
724 }
725
726 $this->date_creation = $this->db->jdate($obj->datec);
727 $this->date_modification = $this->db->jdate($obj->datem);
728 $this->date_validation = $this->db->jdate($obj->datev);
729 }
730
731 $this->db->free($result);
732 } else {
733 dol_print_error($this->db);
734 }
735 }
736
743 public function initAsSpecimen()
744 {
745 $this->initAsSpecimenCommon();
746 $this->title = '';
747 }
748}
749
754{
758 public $element = 'inventoryline';
759
763 public $table_element = 'inventorydet';
764
768 public $ismultientitymanaged = 0;
769
773 public $isextrafieldmanaged = 0;
774
778 public $picto = 'stock';
779
797 // BEGIN MODULEBUILDER PROPERTIES
801 public $fields = array(
802 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>'Id',),
803 'fk_inventory' => array('type'=>'integer:Inventory:product/inventory/class/inventory.class.php', 'label'=>'Inventory', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'index'=>1, 'help'=>'LinkToInventory'),
804 'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Warehouse', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'index'=>1, 'help'=>'LinkToThirdparty'),
805 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'visible'=>1, 'enabled'=>1, 'position'=>32, 'index'=>1, 'help'=>'LinkToProduct'),
806 'batch' => array('type'=>'string', 'label'=>'Batch', 'visible'=>1, 'enabled'=>1, 'position'=>32, 'index'=>1, 'help'=>'LinkToProduct'),
807 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500),
808 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501),
809 '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)'),
810 'qty_view' => array('type'=>'double', 'label'=>'QtyBefore', 'visible'=>1, 'enabled'=>1, 'position'=>33, 'index'=>1, 'help'=>'Qty before (filled once movements are validated)'),
811 '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)'),
812 'pmp_real' => array('type'=>'double', 'label'=>'PMPReal', 'visible'=>1, 'enabled'=>1, 'position'=>35),
813 'pmp_expected' => array('type'=>'double', 'label'=>'PMPExpected', 'visible'=>1, 'enabled'=>1, 'position'=>36),
814 );
815
819 public $rowid;
820
821 public $fk_inventory;
822 public $fk_warehouse;
823 public $fk_product;
824 public $batch;
825 public $datec;
826 public $tms;
827 public $qty_stock;
828 public $qty_view;
829 public $qty_regulated;
830 public $pmp_real;
831 public $pmp_expected;
832
833
841 public function create(User $user, $notrigger = false)
842 {
843 return $this->createCommon($user, $notrigger);
844 }
845
853 public function fetch($id, $ref = null)
854 {
855 $result = $this->fetchCommon($id, $ref);
856 //if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines();
857 return $result;
858 }
859
867 public function update(User $user, $notrigger = false)
868 {
869 return $this->updateCommon($user, $notrigger);
870 }
871
879 public function delete(User $user, $notrigger = false)
880 {
881 return $this->deleteCommon($user, $notrigger);
882 //return $this->deleteCommon($user, $notrigger, 1);
883 }
884}
Parent class of all other business classes (invoices, contracts, proposals, orders,...
deleteLineCommon(User $user, $idline, $notrigger=false)
Delete a line of object in database.
fetchCommon($id, $ref=null, $morewhere='')
Load object in memory from the 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.
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.
validate(User $user, $notrigger=false)
Validate inventory (start it)
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.
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.
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.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.