dolibarr 23.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 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
7 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29// Put here all includes required by your class file
30require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
31require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
32//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
33//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
34
40{
44 public $element = 'inventory';
45
49 public $table_element = 'inventory';
50
54 public $picto = 'inventory';
55
56 const STATUS_DRAFT = 0; // Draft
57 const STATUS_VALIDATED = 1; // Inventory is in process
58 const STATUS_RECORDED = 2; // Inventory is finisged. Stock movement has been recorded.
59 const STATUS_CANCELED = 9; // Canceled
60
87 // BEGIN MODULEBUILDER PROPERTIES
91 public $fields = array(
92 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'visible' => -1, 'enabled' => 1, 'position' => 1, 'notnull' => 1, 'index' => 1, 'comment' => 'Id',),
93 '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'),
94 'entity' => array('type' => 'integer', 'label' => 'Entity', 'visible' => 0, 'enabled' => 1, 'position' => 20, 'notnull' => 1, 'index' => 1,),
95 'title' => array('type' => 'varchar(255)', 'label' => 'Label', 'visible' => 1, 'enabled' => 1, 'position' => 25, 'css' => 'minwidth300', 'csslist' => 'tdoverflowmax150', 'alwayseditable' => 1),
96 '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'),
97 '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'),
98 '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'),
99 'date_inventory' => array('type' => 'date', 'label' => 'DateValue', 'visible' => 1, 'enabled' => 'getDolGlobalInt("STOCK_INVENTORY_ADD_A_VALUE_DATE")', 'position' => 35, 'csslist' => 'nowraponall'), // This date is not used so disabled by default.
100 'date_creation' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 500, 'csslist' => 'nowraponall'),
101 'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 501, 'csslist' => 'nowraponall'),
102 'date_validation' => array('type' => 'datetime', 'label' => 'DateValidation', 'visible' => -2, 'enabled' => 1, 'position' => 502, 'csslist' => 'nowraponall'),
103 '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'),
104 'fk_user_modif' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserModif', 'enabled' => 1, 'visible' => -2, 'notnull' => -1, 'position' => 511, 'csslist' => 'tdoverflowmax150'),
105 'fk_user_valid' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserValidation', 'visible' => -2, 'enabled' => 1, 'position' => 512, 'csslist' => 'tdoverflowmax150'),
106 'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'visible' => -2, 'notnull' => -1, 'index' => 0, 'position' => 1000),
107 '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'))
108 );
109
113 public $rowid;
114
118 public $ref;
119
123 public $fk_warehouse;
124
128 public $fk_product;
129
133 public $categories_product;
137 public $date_inventory;
141 public $title;
142
146 public $status;
147
151 public $fk_user_creat;
152
156 public $fk_user_modif;
157
161 public $fk_user_valid;
162
166 public $import_key;
167 // END MODULEBUILDER PROPERTIES
168
169
170
171 // If this object has a subtable with lines
172
176 public $table_element_line = 'inventorydet';
177
181 public $fk_element = 'fk_inventory';
182
186 public $class_element_line = 'Inventoryline';
187
191 protected $childtables = array();
195 protected $childtablesoncascade = array('inventorydet');
196
200 public $lines = array();
201
202
203
209 public function __construct(DoliDB $db)
210 {
211 $this->db = $db;
212
213 $this->ismultientitymanaged = 1;
214 $this->isextrafieldmanaged = 0;
215
216 if (!getDolGlobalString('MAIN_SHOW_TECHNICAL_ID')) {
217 $this->fields['rowid']['visible'] = 0;
218 }
219 if (!isModEnabled('multicompany')) {
220 $this->fields['entity']['enabled'] = 0;
221 }
222 }
223
224
232 public function create(User $user, $notrigger = 0)
233 {
234 $result = $this->createCommon($user, $notrigger);
235
236 return $result;
237 }
238
247 public function validate(User $user, $notrigger = 0, $include_sub_warehouse = 0)
248 {
249 $this->db->begin();
250
251 $result = 0;
252
253 if ($this->status == self::STATUS_DRAFT) {
254 // Delete inventory
255 $sql = 'DELETE FROM '.$this->db->prefix().'inventorydet WHERE fk_inventory = '.((int) $this->id);
256 $resql = $this->db->query($sql);
257 if (!$resql) {
258 $this->error = $this->db->lasterror();
259 $this->db->rollback();
260 return -1;
261 }
262
263 // Scan existing stock to prefill the inventory
264 $sql = "SELECT ps.rowid, ps.fk_entrepot as fk_warehouse, ps.fk_product, ps.reel,";
265 if (isModEnabled('productbatch')) {
266 $sql .= " COALESCE(pb.batch, '') as batch, pb.qty as qty,";
267 } else {
268 $sql .= " '' as batch, 0 as qty,";
269 }
270 $sql .= " p.ref, p.tobatch";
271 $sql .= " FROM ".$this->db->prefix()."product_stock as ps";
272 if (isModEnabled('productbatch')) {
273 $sql .= " LEFT JOIN ".$this->db->prefix()."product_batch as pb ON pb.fk_product_stock = ps.rowid";
274 }
275 $sql .= ", ".$this->db->prefix()."product as p, ".$this->db->prefix()."entrepot as e";
276 $sql .= " WHERE p.entity IN (".getEntity('product').")";
277 $sql .= " AND e.entity IN (".getEntity('stock').")";
278 $sql .= " AND ps.fk_product = p.rowid AND ps.fk_entrepot = e.rowid";
279 if (!getDolGlobalString('STOCK_SUPPORTS_SERVICES')) {
280 $sql .= " AND p.fk_product_type = 0";
281 }
282 if ($this->fk_product > 0) {
283 $sql .= " AND ps.fk_product = ".((int) $this->fk_product);
284 }
285 if ($this->fk_warehouse > 0) {
286 $sql .= " AND (ps.fk_entrepot = ".((int) $this->fk_warehouse);
287 if (!empty($include_sub_warehouse) && getDolGlobalInt('INVENTORY_INCLUDE_SUB_WAREHOUSE')) {
288 $TChildWarehouses = array();
289 $this->getChildWarehouse($this->fk_warehouse, $TChildWarehouses);
290 if (!empty($TChildWarehouses)) {
291 $sql .= " OR ps.fk_entrepot IN (" . $this->db->sanitize(implode(',', $TChildWarehouses)) . ")";
292 }
293 }
294 $sql .= ')';
295 }
296 if (!empty($this->categories_product)) {
297 $sql .= " AND EXISTS (";
298 $sql .= " SELECT cp.fk_product";
299 $sql .= " FROM ".$this->db->prefix()."categorie_product AS cp";
300 $sql .= " WHERE cp.fk_product = ps.fk_product";
301 $sql .= " AND cp.fk_categorie IN (".$this->db->sanitize($this->categories_product).")";
302 $sql .= ")";
303 }
304 if (getDolGlobalInt('PRODUIT_SOUSPRODUITS')) {
305 $sql .= " AND NOT EXISTS (";
306 $sql .= " SELECT pa.rowid";
307 $sql .= " FROM ".$this->db->prefix()."product_association as pa";
308 $sql .= " WHERE pa.fk_product_pere = ps.fk_product";
309 $sql .= ")";
310 }
311 $sql .= " ORDER BY p.rowid";
312
313 $inventoryline = new InventoryLine($this->db);
314
315 $resql = $this->db->query($sql);
316 if ($resql) {
317 $num = $this->db->num_rows($resql);
318
319 $i = 0;
320 while ($i < $num) {
321 $obj = $this->db->fetch_object($resql);
322
323 $inventoryline->fk_inventory = $this->id;
324 $inventoryline->fk_warehouse = $obj->fk_warehouse;
325 $inventoryline->fk_product = $obj->fk_product;
326 $inventoryline->batch = $obj->batch;
327 $inventoryline->datec = dol_now();
328
329 if (isModEnabled('productbatch')) {
330 if ($obj->batch && empty($obj->tobatch)) {
331 // Bad consistency of data. The product is not a product with lot/serial but we found a stock for some lot/serial.
332 $result = -2;
333 $this->error = 'The product ID='.$obj->ref." has stock with lot/serial but is configured to not manage lot/serial. You must first fix this, this way: Set the product to have 'Management of Lot/Serial' to Yes, then set it back to 'Management of Lot/Serial to No";
334 break;
335 }
336
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 //var_dump($obj->batch.' '.$obj->qty.' '.$obj->reel.' '.$this->error);exit;
342
343 $resultline = $inventoryline->create($user);
344 if ($resultline <= 0) {
345 $this->error = $inventoryline->error;
346 $this->errors = $inventoryline->errors;
347 $result = -1;
348 break;
349 }
350
351 $i++;
352 }
353 } else {
354 $result = -1;
355 $this->error = $this->db->lasterror();
356 }
357 }
358
359 if ($result >= 0) {
360 $result = $this->setStatut($this::STATUS_VALIDATED, null, '', 'INVENTORY_VALIDATED');
361 }
362
363 if ($result > 0) {
364 $this->db->commit();
365 } else {
366 $this->db->rollback();
367 }
368 return $result;
369 }
370
378 public function setDraft(User $user, $notrigger = 0)
379 {
380 $this->db->begin();
381
382 // Delete inventory
383 $sql = 'DELETE FROM '.$this->db->prefix().'inventorydet WHERE fk_inventory = '.((int) $this->id);
384 $resql = $this->db->query($sql);
385 if (!$resql) {
386 $this->error = $this->db->lasterror();
387 $this->db->rollback();
388 return -1;
389 }
390
391 $result = $this->setStatut($this::STATUS_DRAFT, null, '', 'INVENTORY_DRAFT');
392
393 if ($result > 0) {
394 $this->db->commit();
395 } else {
396 $this->db->rollback();
397 }
398 return $result;
399 }
400
408 public function setRecorded(User $user, $notrigger = 0)
409 {
410 $this->db->begin();
411
412 $result = $this->setStatut($this::STATUS_RECORDED, null, '', 'INVENTORY_RECORDED');
413
414 if ($result > 0) {
415 $this->db->commit();
416 } else {
417 $this->db->rollback();
418 return -1;
419 }
420 return $result;
421 }
422
430 public function setCanceled(User $user, $notrigger = 0)
431 {
432 $this->db->begin();
433
434 $result = $this->setStatut($this::STATUS_CANCELED, null, '', 'INVENTORY_CANCELED');
435
436 if ($result > 0) {
437 $this->db->commit();
438 } else {
439 $this->db->rollback();
440 return -1;
441 }
442 return $result;
443 }
444
452 public function createFromClone(User $user, $fromid)
453 {
454 global $langs;
455
456 $error = 0;
457
458 dol_syslog(__METHOD__, LOG_DEBUG);
459
460 $object = new self($this->db);
461
462 $this->db->begin();
463
464 // Load source object
465 $object->fetchCommon($fromid);
466 // Reset some properties
467 unset($object->id);
468 unset($object->fk_user_creat);
469 unset($object->import_key);
470
471 // Clear fields
472 $object->ref = "copy_of_".$object->ref;
473 $object->title = $langs->trans("CopyOf")." ".$object->title;
474 // ...
475
476 // Create clone
477 $object->context['createfromclone'] = 'createfromclone';
478 $result = $object->createCommon($user);
479 if ($result < 0) {
480 $error++;
482 }
483
484 unset($object->context['createfromclone']);
485
486 // End
487 if (!$error) {
488 $this->db->commit();
489 return $object;
490 } else {
491 $this->db->rollback();
492 return -1;
493 }
494 }
495
503 public function fetch($id, $ref = null)
504 {
505 $result = $this->fetchCommon($id, $ref);
506 //if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines();
507 return $result;
508 }
509
515 /*public function fetchLines()
516 {
517 $this->lines=array();
518
519 // Load lines with object MyObjectLine
520
521 return count($this->lines)?1:0;
522 }*/
523
531 public function update(User $user, $notrigger = 0)
532 {
533 return $this->updateCommon($user, $notrigger);
534 }
535
543 public function delete(User $user, $notrigger = 0)
544 {
545 return $this->deleteCommon($user, $notrigger);
546 }
547
556 public function deleteLine(User $user, $idline, $notrigger = 0)
557 {
558 if ($this->status < 0) {
559 $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus';
560 return -2;
561 }
562
563 return $this->deleteLineCommon($user, $idline, $notrigger);
564 }
565
576 public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
577 {
578 global $conf, $langs;
579
580 if (!empty($conf->dol_no_mouse_hover)) {
581 $notooltip = 1; // Force disable tooltips
582 }
583
584 $result = '';
585
586 $label = '<u>'.$langs->trans("Inventory").'</u>';
587 $label .= '<br>';
588 $label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
589
590 $url = dol_buildpath('/product/inventory/card.php', 1).'?id='.$this->id;
591
592 $linkclose = '';
593 if (empty($notooltip)) {
594 if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
595 $label = $langs->trans("ShowInventory");
596 $linkclose .= ' alt="'.dolPrintHTMLForAttribute($label).'"';
597 }
598 $linkclose .= ' title="'.dolPrintHTMLForAttribute($label).'"';
599 $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
600 } else {
601 $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
602 }
603
604 $linkstart = '<a href="'.$url.'"';
605 $linkstart .= $linkclose.'>';
606 $linkend = '</a>';
607
608 $result .= $linkstart;
609 if ($withpicto) {
610 $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);
611 }
612 if ($withpicto != 2) {
613 $result .= $this->ref;
614 }
615 $result .= $linkend;
616 //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
617
618 return $result;
619 }
620
627 public function getLibStatut($mode = 0)
628 {
629 return $this->LibStatut($this->status, $mode);
630 }
631
632 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
640 public function LibStatut($status, $mode = 0)
641 {
642 // phpcs:enable
643 global $langs, $hookmanager;
644
645 $labelStatus = array();
646 $labelStatusShort = array();
647 $labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
648 $labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated').' ('.$langs->transnoentitiesnoconv('InventoryStartedShort').')';
649 $labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Canceled');
650 $labelStatus[self::STATUS_RECORDED] = $langs->transnoentitiesnoconv('Closed');
651 $labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
652 $labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('InventoryStartedShort');
653 $labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Canceled');
654 $labelStatusShort[self::STATUS_RECORDED] = $langs->transnoentitiesnoconv('Closed');
655
656 $statusType = 'status'.$status;
657 if ($status == self::STATUS_RECORDED) {
658 $statusType = 'status6';
659 }
660
661 $parameters = array('status' => $status, 'mode' => $mode);
662 $reshook = $hookmanager->executeHooks('LibStatut', $parameters, $this); // Note that $action and $object may have been modified by hook
663 if ($reshook > 0) {
664 return $hookmanager->resPrint;
665 }
666 return dolGetStatus($labelStatus[$status], $labelStatusShort[$status], '', $statusType, $mode);
667 }
668
676 public function getKanbanView($option = '', $arraydata = null)
677 {
678 global $conf, $langs;
679
680 $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
681
682 $return = '<div class="box-flex-item box-flex-grow-zero">';
683 $return .= '<div class="info-box info-box-sm">';
684 $return .= '<span class="info-box-icon bg-infobox-action">';
685 $return .= img_picto('', $this->picto);
686 $return .= '</span>';
687 $return .= '<div class="info-box-content">';
688 $return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).'</span>';
689 if ($selected >= 0) {
690 $return .= '<input id="cb'.$this->id.'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->id.'"'.($selected ? ' checked="checked"' : '').'>';
691 }
692 if (property_exists($this, 'label')) {
693 $return .= ' <div class="inline-block opacitymedium valignmiddle tdoverflowmax100">'.$this->label.'</div>';
694 }
695 if (property_exists($this, 'amount')) {
696 $return .= '<br>';
697 $return .= '<span class="info-box-label amount">'.price($this->amount, 0, $langs, 1, -1, -1, $conf->currency).'</span>';
698 }
699 if (method_exists($this, 'getLibStatut')) {
700 $return .= '<br><div class="info-box-status">'.$this->getLibStatut(3).'</div>';
701 }
702 $return .= '</div>';
703 $return .= '</div>';
704 $return .= '</div>';
705
706 return $return;
707 }
708
715 public function info($id)
716 {
717 $sql = "SELECT rowid, date_creation as datec, tms as datem, date_validation as datev,";
718 $sql .= " fk_user_creat, fk_user_modif, fk_user_valid";
719 $sql .= " FROM ".$this->db->prefix().$this->table_element." as t";
720 $sql .= " WHERE t.rowid = ".((int) $id);
721 $result = $this->db->query($sql);
722 if ($result) {
723 if ($this->db->num_rows($result)) {
724 $obj = $this->db->fetch_object($result);
725
726 $this->id = $obj->rowid;
727
728 $this->user_creation_id = $obj->fk_user_creat;
729 $this->user_modification_id = $obj->fk_user_modif;
730 $this->user_validation_id = $obj->fk_user_valid;
731
732 $this->date_creation = $this->db->jdate($obj->datec);
733 $this->date_modification = $this->db->jdate($obj->datem);
734 $this->date_validation = $this->db->jdate($obj->datev);
735 }
736
737 $this->db->free($result);
738 } else {
739 dol_print_error($this->db);
740 }
741 }
742
749 public function initAsSpecimen()
750 {
751 $ret = $this->initAsSpecimenCommon();
752 $this->title = '';
753
754 return $ret;
755 }
756
764 public function getChildWarehouse($id, &$TChildWarehouse)
765 {
766 $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'entrepot';
767 $sql .= ' WHERE fk_parent='.(int) $id;
768 $sql .= ' ORDER BY rowid';
769 $resql = $this->db->query($sql);
770 if ($resql && $this->db->num_rows($resql) > 0) {
771 while ($obj = $this->db->fetch_object($resql)) {
772 $TChildWarehouse[] = $obj->rowid;
773 $this->getChildWarehouse($obj->rowid, $TChildWarehouse);
774 }
775 return 1;
776 } else {
777 return -1;
778 }
779 }
780}
781
786{
790 public $element = 'inventoryline';
791
795 public $table_element = 'inventorydet';
796
800 public $parent_element = 'inventory';
801
805 public $fk_parent_attribute = 'fk_inventory';
806
810 public $picto = 'stock';
811
829 // BEGIN MODULEBUILDER PROPERTIES
833 public $fields = array(
834 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'visible' => -1, 'enabled' => 1, 'position' => 1, 'notnull' => 1, 'index' => 1, 'comment' => 'Id',),
835 'fk_inventory' => array('type' => 'integer:Inventory:product/inventory/class/inventory.class.php', 'label' => 'Inventory', 'visible' => 1, 'enabled' => 1, 'position' => 30, 'index' => 1, 'help' => 'LinkToInventory'),
836 'fk_warehouse' => array('type' => 'integer:Entrepot:product/stock/class/entrepot.class.php', 'label' => 'Warehouse', 'visible' => 1, 'enabled' => 1, 'position' => 30, 'index' => 1, 'help' => 'LinkToThirdparty'),
837 'fk_product' => array('type' => 'integer:Product:product/class/product.class.php', 'label' => 'Product', 'visible' => 1, 'enabled' => 1, 'position' => 32, 'index' => 1, 'help' => 'LinkToProduct'),
838 'batch' => array('type' => 'string', 'label' => 'Batch', 'visible' => 1, 'enabled' => 1, 'position' => 32, 'index' => 1, 'help' => 'LinkToProduct'),
839 'datec' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 500),
840 'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 501),
841 '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)'),
842 'qty_view' => array('type' => 'double', 'label' => 'QtyBefore', 'visible' => 1, 'enabled' => 1, 'position' => 33, 'index' => 1, 'help' => 'Qty before (filled once movements are validated)'),
843 'qty_regulated' => array('type' => 'double', 'label' => 'QtyDelta', 'visible' => 1, 'enabled' => 1, 'position' => 34, 'index' => 1, 'help' => 'Qty added or removed (filled once movements are validated)'),
844 'pmp_real' => array('type' => 'double', 'label' => 'PMPReal', 'visible' => 1, 'enabled' => 1, 'position' => 35),
845 'pmp_expected' => array('type' => 'double', 'label' => 'PMPExpected', 'visible' => 1, 'enabled' => 1, 'position' => 36),
846 );
847
851 public $rowid;
852
856 public $fk_inventory;
860 public $fk_warehouse;
864 public $fk_product;
868 public $batch;
872 public $datec;
873
877 public $qty_stock;
878
882 public $qty_view;
883
887 public $qty_regulated;
888
892 public $pmp_real;
896 public $pmp_expected;
897
903 public function __construct($db)
904 {
905 $this->db = $db;
906 $this->ismultientitymanaged = 0;
907
908 $this->isextrafieldmanaged = 0;
909 }
917 public function create(User $user, $notrigger = 0)
918 {
919 return $this->createCommon($user, $notrigger);
920 }
921
929 public function fetch($id, $ref = null)
930 {
931 $result = $this->fetchCommon($id, $ref);
932 //if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines();
933 return $result;
934 }
935
943 public function update(User $user, $notrigger = 0)
944 {
945 return $this->updateCommon($user, $notrigger);
946 }
947
955 public function delete(User $user, $notrigger = 0)
956 {
957 return $this->deleteCommon($user, $notrigger);
958 //return $this->deleteCommon($user, $notrigger, 1);
959 }
960}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
Parent class of all other business classes (invoices, contracts, proposals, orders,...
deleteLineCommon(User $user, $idline, $notrigger=0)
Delete a line of object in database.
setStatut($status, $elementId=null, $elementType='', $trigkey='', $fieldstatus='')
Set status of an object.
setErrorsFromObject($object)
setErrorsFromObject
createCommon(User $user, $notrigger=0)
Create object in the database.
updateCommon(User $user, $notrigger=0)
Update object into database.
initAsSpecimenCommon()
Initialise object with example values Id must be 0 if object instance is a specimen.
fetchCommon($id, $ref=null, $morewhere='', $noextrafields=0)
Load object in memory from the database.
deleteCommon(User $user, $notrigger=0, $forcechilddeletion=0)
Delete object in 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 optionally the picto)
create(User $user, $notrigger=0)
Create object into database.
setRecorded(User $user, $notrigger=0)
Set to inventory to status "Closed".
LibStatut($status, $mode=0)
Return the status.
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 information d'ordre info dans l'objet commande.
setDraft(User $user, $notrigger=0)
Go back to draft.
update(User $user, $notrigger=0)
Load object lines in memory from the database.
setCanceled(User $user, $notrigger=0)
Set to Canceled.
validate(User $user, $notrigger=0, $include_sub_warehouse=0)
Validate inventory (start it)
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
deleteLine(User $user, $idline, $notrigger=0)
Delete a line of object in database.
fetch($id, $ref=null)
Load object in memory from the database.
getChildWarehouse($id, &$TChildWarehouse)
Return the child warehouse of the current one.
createFromClone(User $user, $fromid)
Clone and object into another one.
Class InventoryLine.
update(User $user, $notrigger=0)
Update object into database.
__construct($db)
Constructor.
create(User $user, $notrigger=0)
Create object in database.
fetch($id, $ref=null)
Load object in memory from the database.
Class to manage Dolibarr users.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Definition index.php:171
dol_now($mode='gmt')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
if(getDolGlobalString( 'TAKEPOS_SHOW_CUSTOMER')) print $langs trans('Date')." left Label right Qty right Price right TotalHT right TotalTTC right right right right right right right right right centpercent right TotalHT right n right VAT right n right TotalVAT right n No sujeto a RE IRPF right TotalLT1 right n right TotalLT2 right n right TotalTTC right n takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency right TotalTTC takeposcustomercurrency right takeposcustomercurrency n right PaymentTypeShortLIQ right SELECT p pos_change as p datep as p p num_paiement as f pf amount as amount
Definition receipt.php:471