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