dolibarr 20.0.0
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 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2024 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 '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,),
98 '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,),
99 'note_public' => array('type' => 'html', 'label' => 'NotePublic', 'enabled' => 1, 'position' => 300, 'notnull' => 0, 'visible' => 0, 'validate' => 1,),
100 'note_private' => array('type' => 'html', 'label' => 'NotePrivate', 'enabled' => 1, 'position' => 301, 'notnull' => 0, 'visible' => 0, 'validate' => 1,),
101 'date_creation' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'position' => 500, 'notnull' => 1, 'visible' => -2,),
102 'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'position' => 501, 'notnull' => 0, 'visible' => -2,),
103 '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',),
104 'fk_user_modif' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserModif', 'enabled' => 1, 'position' => 511, 'notnull' => -1, 'visible' => -2,),
105 'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'position' => 1000, 'notnull' => -1, 'visible' => -2,),
106 '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,),
107 );
108 public $rowid;
109 public $ref;
110 public $label;
111 public $asset_type;
112 public $note_public;
113 public $note_private;
114 public $date_creation;
115 public $fk_user_creat;
116 public $fk_user_modif;
117 public $last_main_doc;
118 public $import_key;
119 public $model_pdf;
120 public $status;
121 public $asset_depreciation_options;
122 public $asset_accountancy_codes;
123
124 // /**
125 // * @var string Field with ID of parent key if this object has a parent
126 // */
127 // public $fk_element = 'fk_assetmodel';
128 // /**
129 // * @var array List of child tables. To test if we can delete object.
130 // */
131 // protected $childtables = array();
132 // /**
133 // * @var array List of child tables. To know object to delete on cascade.
134 // * If name matches '@ClassNAme:FilePathClass;ParentFkFieldName' it will
135 // * call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object
136 // */
137 // protected $childtablesoncascade = array('asset_assetmodeldet');
138
139
145 public function __construct(DoliDB $db)
146 {
147 global $conf, $langs;
148
149 $this->db = $db;
150
151 $this->ismultientitymanaged = 1;
152
153 $this->isextrafieldmanaged = 1;
154
155 if (!getDolGlobalString('MAIN_SHOW_TECHNICAL_ID') && isset($this->fields['rowid'])) {
156 $this->fields['rowid']['visible'] = 0;
157 }
158 if (!isModEnabled('multicompany') && isset($this->fields['entity'])) {
159 $this->fields['entity']['enabled'] = 0;
160 }
161
162 // Unset fields that are disabled
163 foreach ($this->fields as $key => $val) {
164 if (isset($val['enabled']) && empty($val['enabled'])) {
165 unset($this->fields[$key]);
166 }
167 }
168
169 // Translate some data of arrayofkeyval
170 if (is_object($langs)) {
171 foreach ($this->fields as $key => $val) {
172 if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
173 foreach ($val['arrayofkeyval'] as $key2 => $val2) {
174 $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
175 }
176 }
177 }
178 }
179 }
180
188 public function create(User $user, $notrigger = 0)
189 {
190 $resultcreate = $this->createCommon($user, $notrigger);
191
192 if ($resultcreate > 0 && !empty($this->asset_depreciation_options)) {
193 $this->asset_depreciation_options->setDeprecationOptionsFromPost(1);
194 $this->asset_depreciation_options->updateDeprecationOptions($user, 0, $resultcreate);
195 }
196
197 if ($resultcreate > 0 && !empty($this->asset_accountancy_codes)) {
198 $this->asset_accountancy_codes->setAccountancyCodesFromPost();
199 $this->asset_accountancy_codes->updateAccountancyCodes($user, 0, $resultcreate);
200 }
201
202 return $resultcreate;
203 }
204
212 public function createFromClone(User $user, $fromid)
213 {
214 global $langs, $extrafields;
215 $error = 0;
216
217 dol_syslog(__METHOD__, LOG_DEBUG);
218
219 $object = new self($this->db);
220
221 $this->db->begin();
222
223 // Load source object
224 $result = $object->fetchCommon($fromid);
225 if ($result > 0 && !empty($object->table_element_line)) {
226 $object->fetchLines();
227 }
228
229 // get lines so they will be clone
230 //foreach($this->lines as $line)
231 // $line->fetch_optionals();
232
233 // Reset some properties
234 unset($object->id);
235 unset($object->fk_user_creat);
236 unset($object->import_key);
237
238 // Clear fields
239 if (property_exists($object, 'ref')) {
240 $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default'];
241 }
242 if (property_exists($object, 'label')) {
243 $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default'];
244 }
245 if (property_exists($object, 'status')) {
246 $object->status = self::STATUS_DRAFT;
247 }
248 if (property_exists($object, 'date_creation')) {
249 $object->date_creation = dol_now();
250 }
251 if (property_exists($object, 'date_modification')) {
252 $object->date_modification = null;
253 }
254 // ...
255 // Clear extrafields that are unique
256 if (is_array($object->array_options) && count($object->array_options) > 0) {
257 $extrafields->fetch_name_optionals_label($this->table_element);
258 foreach ($object->array_options as $key => $option) {
259 $shortkey = preg_replace('/options_/', '', $key);
260 if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) {
261 //var_dump($key); var_dump($clonedObj->array_options[$key]); exit;
262 unset($object->array_options[$key]);
263 }
264 }
265 }
266
267 // Create clone
268 $object->context['createfromclone'] = 'createfromclone';
269 $result = $object->createCommon($user);
270 if ($result < 0) {
271 $error++;
272 $this->error = $object->error;
273 $this->errors = $object->errors;
274 }
275
276 if (!$error) {
277 // copy internal contacts
278 if ($this->copy_linked_contact($object, 'internal') < 0) {
279 $error++;
280 }
281 }
282
283 if (!$error) {
284 // copy external contacts if same company
285 if (property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) {
286 if ($this->copy_linked_contact($object, 'external') < 0) {
287 $error++;
288 }
289 }
290 }
291
292 unset($object->context['createfromclone']);
293
294 // End
295 if (!$error) {
296 $this->db->commit();
297 return $object;
298 } else {
299 $this->db->rollback();
300 return -1;
301 }
302 }
303
311 public function fetch($id, $ref = null)
312 {
313 $result = $this->fetchCommon($id, $ref);
314 if ($result > 0 && !empty($this->table_element_line)) {
315 $this->fetchLines();
316 }
317 return $result;
318 }
319
325 public function fetchLines()
326 {
327 $this->lines = array();
328
329 return 1;
330 }
331
332
345 public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND')
346 {
347 dol_syslog(__METHOD__, LOG_DEBUG);
348
349 $records = array();
350
351 $sql = "SELECT ";
352 $sql .= $this->getFieldList('t');
353 $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
354 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
355 $sql .= " WHERE t.entity IN (".getEntity($this->element).")";
356 } else {
357 $sql .= " WHERE 1 = 1";
358 }
359
360 // Manage filter
361 $errormessage = '';
362 $sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage);
363 if ($errormessage) {
364 $this->errors[] = $errormessage;
365 dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
366 return -1;
367 }
368
369 if (!empty($sortfield)) {
370 $sql .= $this->db->order($sortfield, $sortorder);
371 }
372 if (!empty($limit)) {
373 $sql .= $this->db->plimit($limit, $offset);
374 }
375
376 $resql = $this->db->query($sql);
377 if ($resql) {
378 $num = $this->db->num_rows($resql);
379 $i = 0;
380 while ($i < ($limit ? min($limit, $num) : $num)) {
381 $obj = $this->db->fetch_object($resql);
382
383 $record = new self($this->db);
384 $record->setVarsFromFetchObj($obj);
385
386 $records[$record->id] = $record;
387
388 $i++;
389 }
390 $this->db->free($resql);
391
392 return $records;
393 } else {
394 $this->errors[] = 'Error '.$this->db->lasterror();
395 dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
396
397 return -1;
398 }
399 }
400
408 public function update(User $user, $notrigger = 0)
409 {
410 $resultupdate = $this->updateCommon($user, $notrigger);
411
412 if ($resultupdate > 0 && !empty($this->asset_depreciation_options)) {
413 $this->asset_depreciation_options->setDeprecationOptionsFromPost(1);
414 $this->asset_depreciation_options->updateDeprecationOptions($user, 0, $resultupdate);
415 }
416
417 if ($resultupdate > 0 && !empty($this->asset_accountancy_codes)) {
418 $this->asset_accountancy_codes->setAccountancyCodesFromPost();
419 $this->asset_accountancy_codes->updateAccountancyCodes($user, 0, $resultupdate);
420 }
421
422 return $resultupdate;
423 }
424
432 public function delete(User $user, $notrigger = 0)
433 {
434 return $this->deleteCommon($user, $notrigger);
435 //return $this->deleteCommon($user, $notrigger, 1);
436 }
437
438
446 public function validate($user, $notrigger = 0)
447 {
448 global $conf, $langs;
449
450 $error = 0;
451
452 // Protection
453 if ($this->status == self::STATUS_VALIDATED) {
454 dol_syslog(get_class($this) . "::validate action abandoned: already validated", LOG_WARNING);
455 return 0;
456 }
457
458 $now = dol_now();
459
460 $this->db->begin();
461
462 // Validate
463 $sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element;
464 $sql .= " SET status = " . self::STATUS_VALIDATED;
465 if (!empty($this->fields['date_validation'])) {
466 $sql .= ", date_validation = '" . $this->db->idate($now) . "'";
467 }
468 if (!empty($this->fields['fk_user_valid'])) {
469 $sql .= ", fk_user_valid = " . ((int) $user->id);
470 }
471 $sql .= " WHERE rowid = " . ((int) $this->id);
472
473 dol_syslog(get_class($this) . "::validate()", LOG_DEBUG);
474 $resql = $this->db->query($sql);
475 if (!$resql) {
476 dol_print_error($this->db);
477 $this->error = $this->db->lasterror();
478 $error++;
479 }
480
481 if (!$error && !$notrigger) {
482 // Call trigger
483 $result = $this->call_trigger('ASSETMODEL_VALIDATE', $user);
484 if ($result < 0) {
485 $error++;
486 }
487 // End call triggers
488 }
489
490 // Set new ref and current status
491 if (!$error) {
492 $this->status = self::STATUS_VALIDATED;
493 }
494
495 if (!$error) {
496 $this->db->commit();
497 return 1;
498 } else {
499 $this->db->rollback();
500 return -1;
501 }
502 }
503
504
512 public function setDraft($user, $notrigger = 0)
513 {
514 // Protection
515 if ($this->status <= self::STATUS_DRAFT) {
516 return 0;
517 }
518
519 return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'ASSETMODEL_UNVALIDATE');
520 }
521
529 public function cancel($user, $notrigger = 0)
530 {
531 // Protection
532 if ($this->status != self::STATUS_VALIDATED) {
533 return 0;
534 }
535
536 return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'ASSETMODEL_CANCEL');
537 }
538
546 public function reopen($user, $notrigger = 0)
547 {
548 // Protection
549 if ($this->status != self::STATUS_CANCELED) {
550 return 0;
551 }
552
553 return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'ASSETMODEL_REOPEN');
554 }
555
566 public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
567 {
568 global $conf, $langs, $hookmanager;
569
570 if (!empty($conf->dol_no_mouse_hover)) {
571 $notooltip = 1; // Force disable tooltips
572 }
573
574 $result = '';
575
576 $label = img_picto('', $this->picto).' <u>'.$langs->trans("AssetModel").'</u>';
577 if (isset($this->status)) {
578 $label .= ' '.$this->getLibStatut(5);
579 }
580 $label .= '<br>';
581 $label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
582
583 $url = dol_buildpath('/asset/model/card.php', 1).'?id='.$this->id;
584
585 if ($option != 'nolink') {
586 // Add param to save lastsearch_values or not
587 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
588 if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
589 $add_save_lastsearch_values = 1;
590 }
591 if ($add_save_lastsearch_values) {
592 $url .= '&save_lastsearch_values=1';
593 }
594 }
595
596 $linkclose = '';
597 if (empty($notooltip)) {
598 if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
599 $label = $langs->trans("ShowAssetModel");
600 $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
601 }
602 $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
603 $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
604 } else {
605 $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
606 }
607
608 if ($option == 'nolink') {
609 $linkstart = '<span';
610 } else {
611 $linkstart = '<a href="'.$url.'"';
612 }
613 $linkstart .= $linkclose.'>';
614 if ($option == 'nolink') {
615 $linkend = '</span>';
616 } else {
617 $linkend = '</a>';
618 }
619
620 $result .= $linkstart;
621
622 if (empty($this->showphoto_on_popup)) {
623 if ($withpicto) {
624 $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);
625 }
626 } else {
627 if ($withpicto) {
628 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
629
630 list($class, $module) = explode('@', $this->picto);
631 $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref);
632 $filearray = dol_dir_list($upload_dir, "files");
633 $filename = $filearray[0]['name'];
634 if (!empty($filename)) {
635 $pospoint = strpos($filearray[0]['name'], '.');
636
637 $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint);
638 if (!getDolGlobalString(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS')) {
639 $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>';
640 } else {
641 $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>';
642 }
643
644 $result .= '</div>';
645 } else {
646 $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);
647 }
648 }
649 }
650
651 if ($withpicto != 2) {
652 $result .= $this->ref;
653 }
654
655 $result .= $linkend;
656 //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
657
658 global $action, $hookmanager;
659 $hookmanager->initHooks(array('assetmodeldao'));
660 $parameters = array('id' => $this->id, 'getnomurl' => $result);
661 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
662 if ($reshook > 0) {
663 $result = $hookmanager->resPrint;
664 } else {
665 $result .= $hookmanager->resPrint;
666 }
667
668 return $result;
669 }
670
677 public function getLabelStatus($mode = 0)
678 {
679 return $this->LibStatut($this->status, $mode);
680 }
681
688 public function getLibStatut($mode = 0)
689 {
690 return $this->LibStatut($this->status, $mode);
691 }
692
693 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
701 public function LibStatut($status, $mode = 0)
702 {
703 // phpcs:enable
704 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
705 global $langs;
706 //$langs->load("assets");
707 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
708 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled');
709 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled');
710 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
711 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled');
712 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled');
713 }
714
715 $statusType = 'status'.$status;
716 //if ($status == self::STATUS_VALIDATED) $statusType = 'status1';
717 if ($status == self::STATUS_CANCELED) {
718 $statusType = 'status6';
719 }
720
721 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
722 }
723
730 public function info($id)
731 {
732 $sql = "SELECT rowid, date_creation as datec, tms as datem,";
733 $sql .= " fk_user_creat, fk_user_modif";
734 $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
735 $sql .= " WHERE t.rowid = ".((int) $id);
736
737 $result = $this->db->query($sql);
738 if ($result) {
739 if ($this->db->num_rows($result)) {
740 $obj = $this->db->fetch_object($result);
741
742 $this->id = $obj->rowid;
743
744 $this->user_creation_id = $obj->fk_user_creat;
745 $this->user_modification_id = $obj->fk_user_modif;
746 $this->date_creation = $this->db->jdate($obj->datec);
747 $this->date_modification = $this->db->jdate($obj->datem);
748 }
749
750 $this->db->free($result);
751 } else {
752 dol_print_error($this->db);
753 }
754 }
755
762 public function initAsSpecimen()
763 {
764 // Set here init that are not commonf fields
765 // $this->property1 = ...
766 // $this->property2 = ...
767
768 return $this->initAsSpecimenCommon();
769 }
770
776 public function getLinesArray()
777 {
778 $this->lines = array();
779
780 return $this->lines;
781 }
782
790 public function doScheduledJob()
791 {
792 //global $conf, $langs;
793
794 //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log';
795
796 $error = 0;
797 $this->output = '';
798 $this->error = '';
799
800 dol_syslog(__METHOD__, LOG_DEBUG);
801
802 $now = dol_now();
803
804 $this->db->begin();
805
806 // ...
807
808 $this->db->commit();
809
810 return $error;
811 }
812}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Definition security.php:637
$object ref
Definition info.php:79
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.
doScheduledJob()
Action executed by scheduler CAN BE A CRON TASK.
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.
getLinesArray()
Create an array of lines.
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.
fetchLines()
Load object lines in memory from the database.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
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.
call_trigger($triggerName, $user)
Call trigger based on this instance.
Class to manage Dolibarr database access.
Class to manage Dolibarr users.
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:63
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
dol_now($mode='auto')
Return date for now.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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 dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.