dolibarr  17.0.3
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
28 require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
29 require_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 
37 class Inventory extends CommonObject
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'=>'maxwidth200'),
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'=>'tdoverflowmax200'),
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'=>'tdoverflowmax200'),
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'=>'tdoverflowmax200'),
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'=>'tdoverflowmax200'),
112  'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511, 'csslist'=>'tdoverflowmax200'),
113  'fk_user_valid' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'visible'=>-2, 'enabled'=>1, 'position'=>512, 'csslist'=>'tdoverflowmax200'),
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 
657  public function info($id)
658  {
659  $sql = "SELECT rowid, date_creation as datec, tms as datem, date_validation as datev,";
660  $sql .= " fk_user_creat, fk_user_modif, fk_user_valid";
661  $sql .= " FROM ".$this->db->prefix().$this->table_element." as t";
662  $sql .= " WHERE t.rowid = ".((int) $id);
663  $result = $this->db->query($sql);
664  if ($result) {
665  if ($this->db->num_rows($result)) {
666  $obj = $this->db->fetch_object($result);
667 
668  $this->id = $obj->rowid;
669 
670  if ($obj->fk_user_creat > 0) {
671  $cuser = new User($this->db);
672  $cuser->fetch($obj->fk_user_creat);
673  $this->user_creation = $cuser;
674  }
675 
676  if ($obj->fk_user_modif > 0) {
677  $muser = new User($this->db);
678  $muser->fetch($obj->fk_user_modif);
679  $this->user_creation = $muser;
680  }
681 
682  if ($obj->fk_user_valid > 0) {
683  $vuser = new User($this->db);
684  $vuser->fetch($obj->fk_user_valid);
685  $this->user_validation = $vuser;
686  }
687 
688  $this->date_creation = $this->db->jdate($obj->datec);
689  $this->date_modification = $this->db->jdate($obj->datem);
690  $this->date_validation = $this->db->jdate($obj->datev);
691  }
692 
693  $this->db->free($result);
694  } else {
695  dol_print_error($this->db);
696  }
697  }
698 
705  public function initAsSpecimen()
706  {
707  $this->initAsSpecimenCommon();
708  $this->title = '';
709  }
710 }
711 
716 {
720  public $element = 'inventoryline';
721 
725  public $table_element = 'inventorydet';
726 
730  public $ismultientitymanaged = 0;
731 
735  public $isextrafieldmanaged = 0;
736 
740  public $picto = 'stock';
741 
759  // BEGIN MODULEBUILDER PROPERTIES
763  public $fields = array(
764  'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>'Id',),
765  'fk_inventory' => array('type'=>'integer:Inventory:product/inventory/class/inventory.class.php', 'label'=>'Inventory', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'index'=>1, 'help'=>'LinkToInventory'),
766  'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Warehouse', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'index'=>1, 'help'=>'LinkToThirdparty'),
767  'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'visible'=>1, 'enabled'=>1, 'position'=>32, 'index'=>1, 'help'=>'LinkToProduct'),
768  'batch' => array('type'=>'string', 'label'=>'Batch', 'visible'=>1, 'enabled'=>1, 'position'=>32, 'index'=>1, 'help'=>'LinkToProduct'),
769  'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500),
770  'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501),
771  '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)'),
772  'qty_view' => array('type'=>'double', 'label'=>'QtyBefore', 'visible'=>1, 'enabled'=>1, 'position'=>33, 'index'=>1, 'help'=>'Qty before (filled once movements are validated)'),
773  '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)'),
774  'pmp_real' => array('type'=>'double', 'label'=>'PMPReal', 'visible'=>1, 'enabled'=>1, 'position'=>35),
775  'pmp_expected' => array('type'=>'double', 'label'=>'PMPExpected', 'visible'=>1, 'enabled'=>1, 'position'=>36),
776  );
777 
781  public $rowid;
782 
783  public $fk_inventory;
784  public $fk_warehouse;
785  public $fk_product;
786  public $batch;
787  public $datec;
788  public $tms;
789  public $qty_stock;
790  public $qty_view;
791  public $qty_regulated;
792  public $pmp_real;
793  public $pmp_expected;
794 
795 
803  public function create(User $user, $notrigger = false)
804  {
805  return $this->createCommon($user, $notrigger);
806  }
807 
815  public function fetch($id, $ref = null)
816  {
817  $result = $this->fetchCommon($id, $ref);
818  //if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines();
819  return $result;
820  }
821 
829  public function update(User $user, $notrigger = false)
830  {
831  return $this->updateCommon($user, $notrigger);
832  }
833 
841  public function delete(User $user, $notrigger = false)
842  {
843  return $this->deleteCommon($user, $notrigger);
844  //return $this->deleteCommon($user, $notrigger, 1);
845  }
846 }
InventoryLine\update
update(User $user, $notrigger=false)
Update object into database.
Definition: inventory.class.php:829
CommonObject\deleteCommon
deleteCommon(User $user, $notrigger=false, $forcechilddeletion=0)
Delete object in database.
Definition: commonobject.class.php:9573
db
$conf db
API class for accounts.
Definition: inc.php:41
CommonObject\fetchCommon
fetchCommon($id, $ref=null, $morewhere='')
Load object in memory from the database.
Definition: commonobject.class.php:9363
Inventory\getNomUrl
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionaly the picto)
Definition: inventory.class.php:561
InventoryLine\fetch
fetch($id, $ref=null)
Load object in memory from the database.
Definition: inventory.class.php:815
DoliDB
Class to manage Dolibarr database access.
Definition: DoliDB.class.php:30
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4993
Inventory\validate
validate(User $user, $notrigger=false)
Validate inventory (start it)
Definition: inventory.class.php:263
dol_buildpath
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
Definition: functions.lib.php:1061
Inventory\fetch
fetch($id, $ref=null)
Load object in memory from the database.
Definition: inventory.class.php:488
CommonObject\setStatut
setStatut($status, $elementId=null, $elementType='', $trigkey='', $fieldstatus='fk_statut')
Set status of an object.
Definition: commonobject.class.php:4380
Inventory\setDraft
setDraft(User $user, $notrigger=false)
Go back to draft.
Definition: inventory.class.php:363
CommonObject\initAsSpecimenCommon
initAsSpecimenCommon()
Initialise object with example values Id must be 0 if object instance is a specimen.
Definition: commonobject.class.php:9901
Inventory
Class for Inventory.
Definition: inventory.class.php:37
CommonObjectLine
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
Definition: commonobjectline.class.php:32
CommonObject
Parent class of all other business classes (invoices, contracts, proposals, orders,...
Definition: commonobject.class.php:44
Inventory\update
update(User $user, $notrigger=false)
Load object lines in memory from the database.
Definition: inventory.class.php:516
Inventory\LibStatut
static LibStatut($status, $mode=0)
Return the status.
Definition: inventory.class.php:628
Inventory\getLibStatut
getLibStatut($mode=0)
Retourne le libelle du status d'un user (actif, inactif)
Definition: inventory.class.php:615
Inventory\create
create(User $user, $notrigger=false)
Create object into database.
Definition: inventory.class.php:249
CommonObject\createCommon
createCommon(User $user, $notrigger=false)
Create object into database.
Definition: commonobject.class.php:9191
Inventory\info
info($id)
Charge les informations d'ordre info dans l'objet commande.
Definition: inventory.class.php:657
Inventory\setCanceled
setCanceled(User $user, $notrigger=false)
Set to Canceled.
Definition: inventory.class.php:415
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:745
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1628
InventoryLine\create
create(User $user, $notrigger=false)
Create object in database.
Definition: inventory.class.php:803
Inventory\setRecorded
setRecorded(User $user, $notrigger=false)
Set to inventory to status "Closed".
Definition: inventory.class.php:393
CommonObject\updateCommon
updateCommon(User $user, $notrigger=false)
Update object into database.
Definition: commonobject.class.php:9469
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:137
User
Class to manage Dolibarr users.
Definition: user.class.php:46
InventoryLine
Class InventoryLine.
Definition: inventory.class.php:715
dolGetStatus
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
Definition: functions.lib.php:10745
Inventory\initAsSpecimen
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
Definition: inventory.class.php:705
img_object
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
Definition: functions.lib.php:4360
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2951
Inventory\__construct
__construct(DoliDB $db)
Constructor.
Definition: inventory.class.php:227
CommonObject\deleteLineCommon
deleteLineCommon(User $user, $idline, $notrigger=false)
Delete a line of object in database.
Definition: commonobject.class.php:9789
Inventory\deleteLine
deleteLine(User $user, $idline, $notrigger=false)
Delete a line of object in database.
Definition: inventory.class.php:541
Inventory\createFromClone
createFromClone(User $user, $fromid)
Clone and object into another one.
Definition: inventory.class.php:437