dolibarr 24.0.0-beta
assetmodel.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2021 Open-Dsi <support@open-dsi.fr>
4 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
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';
29//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
30//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
31
36{
40 public $module = 'asset';
41
45 public $element = 'assetmodel';
46
50 public $table_element = 'asset_model';
51
55 public $picto = 'asset';
56
57
58 const STATUS_DRAFT = 0;
59 const STATUS_VALIDATED = 1;
60 const STATUS_CANCELED = 9;
61
62
94 public $fields = array(
95 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'position' => 1, 'notnull' => 1, 'visible' => 0, 'noteditable' => 1, 'index' => 1, 'css' => 'left', 'comment' => "Id"),
96 'ref' => array('type' => 'varchar(128)', 'label' => 'Ref', 'enabled' => 1, 'position' => 20, 'notnull' => 1, 'visible' => 1, 'index' => 1, 'searchall' => 1, 'showoncombobox' => 1, 'validate' => 1),
97 'ref_ext' => array('type' => 'varchar(255)', 'label' => 'RefExt', 'enabled' => 1, 'position' => 25, 'notnull' => 0, 'visible' => 0),
98 'label' => array('type' => 'varchar(255)', 'label' => 'Label', 'enabled' => 1, 'position' => 30, 'notnull' => 1, 'visible' => 1, 'searchall' => 1, 'css' => 'minwidth300', 'cssview' => 'wordbreak', 'showoncombobox' => 2, 'validate' => 1,),
99 'asset_type' => array('type' => 'smallint', 'label' => 'AssetType', 'enabled' => 1, 'position' => 40, 'notnull' => 1, 'visible' => 1, 'arrayofkeyval' => array(0 => 'AssetTypeIntangible', 1 => 'AssetTypeTangible', 2 => 'AssetTypeInProgress', 3 => 'AssetTypeFinancial'), 'validate' => 1,),
100 'note_public' => array('type' => 'html', 'label' => 'NotePublic', 'enabled' => 1, 'position' => 300, 'notnull' => 0, 'visible' => 0, 'validate' => 1,),
101 'note_private' => array('type' => 'html', 'label' => 'NotePrivate', 'enabled' => 1, 'position' => 301, 'notnull' => 0, 'visible' => 0, 'validate' => 1,),
102 'date_creation' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'position' => 500, 'notnull' => 1, 'visible' => -2,),
103 'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'position' => 501, 'notnull' => 0, 'visible' => -2,),
104 'fk_user_creat' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserAuthor', 'enabled' => 1, 'position' => 510, 'notnull' => 1, 'visible' => -2, 'foreignkey' => 'user.rowid',),
105 'fk_user_modif' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserModif', 'enabled' => 1, 'position' => 511, 'notnull' => -1, 'visible' => -2,),
106 'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'position' => 1000, 'notnull' => -1, 'visible' => -2,),
107 'status' => array('type' => 'smallint', 'label' => 'Status', 'enabled' => 1, 'position' => 1000, 'notnull' => 1, 'default' => '1', 'visible' => 1, 'index' => 1, 'arrayofkeyval' => array(0 => 'Draft', 1 => 'Enabled', 9 => 'Disabled'), 'validate' => 1,),
108 );
112 public $rowid;
116 public $ref;
120 public $label;
124 public $asset_type;
128 public $note_public;
132 public $note_private;
136 public $fk_user_creat;
140 public $fk_user_modif;
144 public $last_main_doc;
148 public $import_key;
152 public $model_pdf;
156 public $status;
160 public $asset_depreciation_options;
164 public $asset_accountancy_codes;
165
166 // /**
167 // * @var string Field with ID of parent key if this object has a parent
168 // */
169 // public $fk_element = 'fk_assetmodel';
170 // /**
171 // * @var array List of child tables. To test if we can delete object.
172 // */
173 // protected $childtables = array();
174 // /**
175 // * @var array List of child tables. To know object to delete on cascade.
176 // * If name matches '@ClassNAme:FilePathClass;ParentFkFieldName' it will
177 // * call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object
178 // */
179 // protected $childtablesoncascade = array('asset_assetmodeldet');
180
181
187 public function __construct(DoliDB $db)
188 {
189 global $langs;
190
191 $this->db = $db;
192
193 $this->ismultientitymanaged = 1;
194
195 $this->isextrafieldmanaged = 1;
196
197 if (!getDolGlobalString('MAIN_SHOW_TECHNICAL_ID') && isset($this->fields['rowid'])) {
198 $this->fields['rowid']['visible'] = 0;
199 }
200 if (!isModEnabled('multicompany') && isset($this->fields['entity'])) {
201 $this->fields['entity']['enabled'] = 0;
202 }
203
204 // Unset fields that are disabled
205 foreach ($this->fields as $key => $val) {
206 if (isset($val['enabled']) && empty($val['enabled'])) {
207 unset($this->fields[$key]);
208 }
209 }
210
211 // Translate some data of arrayofkeyval
212 if (is_object($langs)) {
213 foreach ($this->fields as $key => $val) {
214 if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
215 foreach ($val['arrayofkeyval'] as $key2 => $val2) {
216 $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
217 }
218 }
219 }
220 }
221 }
222
230 public function create(User $user, $notrigger = 0)
231 {
232 $resultcreate = $this->createCommon($user, $notrigger);
233
234 if ($resultcreate > 0 && !empty($this->asset_depreciation_options)) {
235 $this->asset_depreciation_options->setDeprecationOptionsFromPost(1);
236 $this->asset_depreciation_options->updateDeprecationOptions($user, 0, $resultcreate);
237 }
238
239 if ($resultcreate > 0 && !empty($this->asset_accountancy_codes)) {
240 $this->asset_accountancy_codes->setAccountancyCodesFromPost();
241 $this->asset_accountancy_codes->updateAccountancyCodes($user, 0, $resultcreate);
242 }
243
244 return $resultcreate;
245 }
246
254 public function createFromClone(User $user, $fromid)
255 {
256 global $langs, $extrafields;
257 $error = 0;
258
259 dol_syslog(__METHOD__, LOG_DEBUG);
260
261 $object = new self($this->db);
262
263 $this->db->begin();
264
265 // Load source object
266 $result = $object->fetchCommon($fromid);
267
268 // Reset some properties
269 unset($object->id);
270 unset($object->fk_user_creat);
271 unset($object->import_key);
272
273 // Clear fields
274 if (property_exists($object, 'ref')) {
275 // @phan-suppress-next-line PhanTypeInvalidDimOffset
276 $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default'];
277 }
278 if (property_exists($object, 'label')) {
279 // @phan-suppress-next-line PhanTypeInvalidDimOffset
280 $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default'];
281 }
282 if (property_exists($object, 'status')) {
283 $object->status = self::STATUS_DRAFT;
284 }
285 if (property_exists($object, 'date_creation')) {
286 $object->date_creation = dol_now();
287 }
288 if (property_exists($object, 'date_modification')) {
289 $object->date_modification = null;
290 }
291 // ...
292 // Clear extrafields that are unique
293 if (is_array($object->array_options) && count($object->array_options) > 0) {
294 $extrafields->fetch_name_optionals_label($this->table_element);
295 foreach ($object->array_options as $key => $option) {
296 $shortkey = preg_replace('/options_/', '', $key);
297 if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) {
298 //var_dump($key); var_dump($clonedObj->array_options[$key]); exit;
299 unset($object->array_options[$key]);
300 }
301 }
302 }
303
304 // Create clone
305 $object->context['createfromclone'] = 'createfromclone';
306 $result = $object->createCommon($user);
307 if ($result < 0) {
308 $error++;
310 }
311
312 if (!$error) {
313 // copy internal contacts
314 if ($this->copy_linked_contact($object, 'internal') < 0) {
315 $error++;
316 }
317 }
318
319 unset($object->context['createfromclone']);
320
321 // End
322 if (!$error) {
323 $this->db->commit();
324 return $object;
325 } else {
326 $this->db->rollback();
327 return -1;
328 }
329 }
330
338 public function fetch($id, $ref = null)
339 {
340 $result = $this->fetchCommon($id, $ref);
341
342 return $result;
343 }
344
357 public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND')
358 {
359 dol_syslog(__METHOD__, LOG_DEBUG);
360
361 $records = array();
362
363 $sql = "SELECT ";
364 $sql .= $this->getFieldList('t');
365 $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
366 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
367 $sql .= " WHERE t.entity IN (".getEntity($this->element).")";
368 } else {
369 $sql .= " WHERE 1 = 1";
370 }
371
372 // Manage filter
373 $errormessage = '';
374 $sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage);
375 if ($errormessage) {
376 $this->errors[] = $errormessage;
377 dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
378 return -1;
379 }
380
381 if (!empty($sortfield)) {
382 $sql .= $this->db->order($sortfield, $sortorder);
383 }
384 if (!empty($limit)) {
385 $sql .= $this->db->plimit($limit, $offset);
386 }
387
388 $resql = $this->db->query($sql);
389 if ($resql) {
390 $num = $this->db->num_rows($resql);
391 $i = 0;
392 while ($i < ($limit ? min($limit, $num) : $num)) {
393 $obj = $this->db->fetch_object($resql);
394
395 $record = new self($this->db);
396 $record->setVarsFromFetchObj($obj);
397
398 $records[$record->id] = $record;
399
400 $i++;
401 }
402 $this->db->free($resql);
403
404 return $records;
405 } else {
406 $this->errors[] = 'Error '.$this->db->lasterror();
407 dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
408
409 return -1;
410 }
411 }
412
420 public function update(User $user, $notrigger = 0)
421 {
422 $resultupdate = $this->updateCommon($user, $notrigger);
423
424 if ($resultupdate > 0 && !empty($this->asset_depreciation_options)) {
425 $this->asset_depreciation_options->setDeprecationOptionsFromPost(1);
426 $this->asset_depreciation_options->updateDeprecationOptions($user, 0, $resultupdate);
427 }
428
429 if ($resultupdate > 0 && !empty($this->asset_accountancy_codes)) {
430 $this->asset_accountancy_codes->setAccountancyCodesFromPost();
431 $this->asset_accountancy_codes->updateAccountancyCodes($user, 0, $resultupdate);
432 }
433
434 return $resultupdate;
435 }
436
444 public function delete(User $user, $notrigger = 0)
445 {
446 return $this->deleteCommon($user, $notrigger);
447 //return $this->deleteCommon($user, $notrigger, 1);
448 }
449
450
458 public function validate($user, $notrigger = 0)
459 {
460 $error = 0;
461
462 // Protection
463 if ($this->status == self::STATUS_VALIDATED) {
464 dol_syslog(get_class($this) . "::validate action abandoned: already validated", LOG_WARNING);
465 return 0;
466 }
467
468 $now = dol_now();
469
470 $this->db->begin();
471
472 // Validate
473 $sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element;
474 $sql .= " SET status = " . self::STATUS_VALIDATED;
475 if (!empty($this->fields['date_validation'])) {
476 $sql .= ", date_validation = '" . $this->db->idate($now) . "'";
477 }
478 if (!empty($this->fields['fk_user_valid'] ?? null)) {
479 $sql .= ", fk_user_valid = " . ((int) $user->id);
480 }
481 $sql .= " WHERE rowid = " . ((int) $this->id);
482
483 dol_syslog(get_class($this) . "::validate()", LOG_DEBUG);
484
485 $resql = $this->db->query($sql);
486 if (!$resql) {
487 dol_print_error($this->db);
488 $this->error = $this->db->lasterror();
489 $error++;
490 }
491
492 if (!$error && !$notrigger) {
493 // Call trigger
494 $result = $this->call_trigger('ASSETMODEL_VALIDATE', $user);
495 if ($result < 0) {
496 $error++;
497 }
498 // End call triggers
499 }
500
501 // Set new ref and current status
502 if (!$error) {
503 $this->status = self::STATUS_VALIDATED;
504 }
505
506 if (!$error) {
507 $this->db->commit();
508 return 1;
509 } else {
510 $this->db->rollback();
511 return -1;
512 }
513 }
514
515
523 public function setDraft($user, $notrigger = 0)
524 {
525 // Protection
526 if ($this->status <= self::STATUS_DRAFT) {
527 return 0;
528 }
529
530 return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'ASSETMODEL_UNVALIDATE');
531 }
532
540 public function cancel($user, $notrigger = 0)
541 {
542 // Protection
543 if ($this->status != self::STATUS_VALIDATED) {
544 return 0;
545 }
546
547 return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'ASSETMODEL_CANCEL');
548 }
549
557 public function reopen($user, $notrigger = 0)
558 {
559 // Protection
560 if ($this->status != self::STATUS_CANCELED) {
561 return 0;
562 }
563
564 return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'ASSETMODEL_REOPEN');
565 }
566
577 public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
578 {
579 global $conf, $langs, $hookmanager;
580
581 if (!empty($conf->dol_no_mouse_hover)) {
582 $notooltip = 1; // Force disable tooltips
583 }
584
585 $result = '';
586
587 $label = img_picto('', $this->picto).' <u>'.$langs->trans("AssetModel").'</u>';
588 if (isset($this->status)) {
589 $label .= ' '.$this->getLibStatut(5);
590 }
591 $label .= '<br>';
592 $label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
593
594 $url = dol_buildpath('/asset/model/card.php', 1).'?id='.$this->id;
595
596 if ($option != 'nolink') {
597 // Add param to save lastsearch_values or not
598 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
599 if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
600 $add_save_lastsearch_values = 1;
601 }
602 if ($add_save_lastsearch_values) {
603 $url .= '&save_lastsearch_values=1';
604 }
605 }
606
607 $linkclose = '';
608 if (empty($notooltip)) {
609 if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
610 $label = $langs->trans("ShowAssetModel");
611 $linkclose .= ' alt="'.dolPrintHTMLForAttribute($label).'"';
612 }
613 $linkclose .= ' title="'.dolPrintHTMLForAttribute($label).'"';
614 $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
615 } else {
616 $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
617 }
618
619 if ($option == 'nolink') {
620 $linkstart = '<span';
621 } else {
622 $linkstart = '<a href="'.$url.'"';
623 }
624 $linkstart .= $linkclose.'>';
625 if ($option == 'nolink') {
626 $linkend = '</span>';
627 } else {
628 $linkend = '</a>';
629 }
630
631 $result .= $linkstart;
632
633 if (empty($this->showphoto_on_popup)) {
634 if ($withpicto) {
635 $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);
636 }
637 } else {
638 if ($withpicto) {
639 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
640
641 list($class, $module) = explode('@', $this->picto);
642 $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref);
643 $filearray = dol_dir_list($upload_dir, "files");
644 $filename = $filearray[0]['name'];
645 if (!empty($filename)) {
646 $pospoint = strpos($filearray[0]['name'], '.');
647
648 $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint);
649 if (!getDolGlobalString(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS')) {
650 $result .= '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref"><img class="photo'.$module.'" alt="No photo" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$module.'&entity='.$conf->entity.'&file='.urlencode($pathtophoto).'"></div></div>';
651 } else {
652 $result .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photouserphoto userphoto" alt="No photo" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$module.'&entity='.$conf->entity.'&file='.urlencode($pathtophoto).'"></div>';
653 }
654
655 $result .= '</div>';
656 } else {
657 $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);
658 }
659 }
660 }
661
662 if ($withpicto != 2) {
663 $result .= $this->ref;
664 }
665
666 $result .= $linkend;
667 //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
668
669 global $action, $hookmanager;
670 $hookmanager->initHooks(array('assetmodeldao'));
671 $parameters = array('id' => $this->id, 'getnomurl' => $result);
672 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
673 if ($reshook > 0) {
674 $result = $hookmanager->resPrint;
675 } else {
676 $result .= $hookmanager->resPrint;
677 }
678
679 return $result;
680 }
681
688 public function getLabelStatus($mode = 0)
689 {
690 return $this->LibStatut($this->status, $mode);
691 }
692
699 public function getLibStatut($mode = 0)
700 {
701 return $this->LibStatut($this->status, $mode);
702 }
703
704 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
712 public function LibStatut($status, $mode = 0)
713 {
714 // phpcs:enable
715 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
716 global $langs;
717 //$langs->load("assets");
718 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
719 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled');
720 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled');
721 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
722 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled');
723 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled');
724 }
725
726 $statusType = 'status'.$status;
727 //if ($status == self::STATUS_VALIDATED) $statusType = 'status1';
728 if ($status == self::STATUS_CANCELED) {
729 $statusType = 'status6';
730 }
731
732 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
733 }
734
741 public function info($id)
742 {
743 $sql = "SELECT rowid, date_creation as datec, tms as datem,";
744 $sql .= " fk_user_creat, fk_user_modif";
745 $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
746 $sql .= " WHERE t.rowid = ".((int) $id);
747
748 $result = $this->db->query($sql);
749 if ($result) {
750 if ($this->db->num_rows($result)) {
751 $obj = $this->db->fetch_object($result);
752
753 $this->id = $obj->rowid;
754
755 $this->user_creation_id = $obj->fk_user_creat;
756 $this->user_modification_id = $obj->fk_user_modif;
757 $this->date_creation = $this->db->jdate($obj->datec);
758 $this->date_modification = $this->db->jdate($obj->datem);
759 }
760
761 $this->db->free($result);
762 } else {
763 dol_print_error($this->db);
764 }
765 }
766
773 public function initAsSpecimen()
774 {
775 // Set here init that are not commonf fields
776 // $this->property1 = ...
777 // $this->property2 = ...
778
779 return $this->initAsSpecimenCommon();
780 }
781}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$object ref
Definition info.php:90
Class for AssetModel.
reopen($user, $notrigger=0)
Set back to validated status.
getLabelStatus($mode=0)
Return the label of the status.
LibStatut($status, $mode=0)
Return the status.
setDraft($user, $notrigger=0)
Set draft status.
fetch($id, $ref=null)
Load object in memory from the database.
__construct(DoliDB $db)
Constructor.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
getLibStatut($mode=0)
Return the label of the status.
createFromClone(User $user, $fromid)
Clone an object into another one.
create(User $user, $notrigger=0)
Create object into database.
info($id)
Load the info information in the object.
validate($user, $notrigger=0)
Validate object.
cancel($user, $notrigger=0)
Set cancel status.
update(User $user, $notrigger=0)
Update object into database.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionally the picto)
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, $filter='', $filtermode='AND')
Load list of objects in memory from the database.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
setErrorsFromObject($object)
setErrorsFromObject
createCommon(User $user, $notrigger=0)
Create object in the database.
getFieldList($alias='', $excludefields=array())
Function to concat keys of fields.
updateCommon(User $user, $notrigger=0)
Update object into database.
setStatusCommon($user, $status, $notrigger=0, $triggercode='')
Set to a status.
initAsSpecimenCommon()
Initialise object with example values Id must be 0 if object instance is a specimen.
copy_linked_contact($objFrom, $source='internal')
Copy contact from one element to current.
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.
Class to manage Dolibarr database access.
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:168
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:64
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)
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
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.