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 );
111 public $rowid;
115 public $ref;
119 public $label;
123 public $asset_type;
127 public $note_public;
131 public $note_private;
135 public $fk_user_creat;
139 public $fk_user_modif;
143 public $last_main_doc;
147 public $import_key;
151 public $model_pdf;
155 public $status;
159 public $asset_depreciation_options;
163 public $asset_accountancy_codes;
164
165 // /**
166 // * @var string Field with ID of parent key if this object has a parent
167 // */
168 // public $fk_element = 'fk_assetmodel';
169 // /**
170 // * @var array List of child tables. To test if we can delete object.
171 // */
172 // protected $childtables = array();
173 // /**
174 // * @var array List of child tables. To know object to delete on cascade.
175 // * If name matches '@ClassNAme:FilePathClass;ParentFkFieldName' it will
176 // * call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object
177 // */
178 // protected $childtablesoncascade = array('asset_assetmodeldet');
179
180
186 public function __construct(DoliDB $db)
187 {
188 global $conf, $langs;
189
190 $this->db = $db;
191
192 $this->ismultientitymanaged = 1;
193
194 $this->isextrafieldmanaged = 1;
195
196 if (!getDolGlobalString('MAIN_SHOW_TECHNICAL_ID') && isset($this->fields['rowid'])) {
197 $this->fields['rowid']['visible'] = 0;
198 }
199 if (!isModEnabled('multicompany') && isset($this->fields['entity'])) {
200 $this->fields['entity']['enabled'] = 0;
201 }
202
203 // Unset fields that are disabled
204 foreach ($this->fields as $key => $val) {
205 if (isset($val['enabled']) && empty($val['enabled'])) {
206 unset($this->fields[$key]);
207 }
208 }
209
210 // Translate some data of arrayofkeyval
211 if (is_object($langs)) {
212 foreach ($this->fields as $key => $val) {
213 if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
214 foreach ($val['arrayofkeyval'] as $key2 => $val2) {
215 $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
216 }
217 }
218 }
219 }
220 }
221
229 public function create(User $user, $notrigger = 0)
230 {
231 $resultcreate = $this->createCommon($user, $notrigger);
232
233 if ($resultcreate > 0 && !empty($this->asset_depreciation_options)) {
234 $this->asset_depreciation_options->setDeprecationOptionsFromPost(1);
235 $this->asset_depreciation_options->updateDeprecationOptions($user, 0, $resultcreate);
236 }
237
238 if ($resultcreate > 0 && !empty($this->asset_accountancy_codes)) {
239 $this->asset_accountancy_codes->setAccountancyCodesFromPost();
240 $this->asset_accountancy_codes->updateAccountancyCodes($user, 0, $resultcreate);
241 }
242
243 return $resultcreate;
244 }
245
253 public function createFromClone(User $user, $fromid)
254 {
255 global $langs, $extrafields;
256 $error = 0;
257
258 dol_syslog(__METHOD__, LOG_DEBUG);
259
260 $object = new self($this->db);
261
262 $this->db->begin();
263
264 // Load source object
265 $result = $object->fetchCommon($fromid);
266 if ($result > 0 && !empty($object->table_element_line)) {
267 $object->fetchLines();
268 }
269
270 // get lines so they will be clone
271 //foreach($this->lines as $line)
272 // $line->fetch_optionals();
273
274 // Reset some properties
275 unset($object->id);
276 unset($object->fk_user_creat);
277 unset($object->import_key);
278
279 // Clear fields
280 if (property_exists($object, 'ref')) {
281 $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default'];
282 }
283 if (property_exists($object, 'label')) {
284 $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default'];
285 }
286 if (property_exists($object, 'status')) {
287 $object->status = self::STATUS_DRAFT;
288 }
289 if (property_exists($object, 'date_creation')) {
290 $object->date_creation = dol_now();
291 }
292 if (property_exists($object, 'date_modification')) {
293 $object->date_modification = null;
294 }
295 // ...
296 // Clear extrafields that are unique
297 if (is_array($object->array_options) && count($object->array_options) > 0) {
298 $extrafields->fetch_name_optionals_label($this->table_element);
299 foreach ($object->array_options as $key => $option) {
300 $shortkey = preg_replace('/options_/', '', $key);
301 if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) {
302 //var_dump($key); var_dump($clonedObj->array_options[$key]); exit;
303 unset($object->array_options[$key]);
304 }
305 }
306 }
307
308 // Create clone
309 $object->context['createfromclone'] = 'createfromclone';
310 $result = $object->createCommon($user);
311 if ($result < 0) {
312 $error++;
313 $this->error = $object->error;
314 $this->errors = $object->errors;
315 }
316
317 if (!$error) {
318 // copy internal contacts
319 if ($this->copy_linked_contact($object, 'internal') < 0) {
320 $error++;
321 }
322 }
323
324 if (!$error) {
325 // copy external contacts if same company
326 if (property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) {
327 if ($this->copy_linked_contact($object, 'external') < 0) {
328 $error++;
329 }
330 }
331 }
332
333 unset($object->context['createfromclone']);
334
335 // End
336 if (!$error) {
337 $this->db->commit();
338 return $object;
339 } else {
340 $this->db->rollback();
341 return -1;
342 }
343 }
344
352 public function fetch($id, $ref = null)
353 {
354 $result = $this->fetchCommon($id, $ref);
355 if ($result > 0 && !empty($this->table_element_line)) {
356 $this->fetchLines();
357 }
358 return $result;
359 }
360
366 public function fetchLines()
367 {
368 $this->lines = array();
369
370 return 1;
371 }
372
373
386 public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND')
387 {
388 dol_syslog(__METHOD__, LOG_DEBUG);
389
390 $records = array();
391
392 $sql = "SELECT ";
393 $sql .= $this->getFieldList('t');
394 $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
395 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
396 $sql .= " WHERE t.entity IN (".getEntity($this->element).")";
397 } else {
398 $sql .= " WHERE 1 = 1";
399 }
400
401 // Manage filter
402 $errormessage = '';
403 $sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage);
404 if ($errormessage) {
405 $this->errors[] = $errormessage;
406 dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
407 return -1;
408 }
409
410 if (!empty($sortfield)) {
411 $sql .= $this->db->order($sortfield, $sortorder);
412 }
413 if (!empty($limit)) {
414 $sql .= $this->db->plimit($limit, $offset);
415 }
416
417 $resql = $this->db->query($sql);
418 if ($resql) {
419 $num = $this->db->num_rows($resql);
420 $i = 0;
421 while ($i < ($limit ? min($limit, $num) : $num)) {
422 $obj = $this->db->fetch_object($resql);
423
424 $record = new self($this->db);
425 $record->setVarsFromFetchObj($obj);
426
427 $records[$record->id] = $record;
428
429 $i++;
430 }
431 $this->db->free($resql);
432
433 return $records;
434 } else {
435 $this->errors[] = 'Error '.$this->db->lasterror();
436 dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
437
438 return -1;
439 }
440 }
441
449 public function update(User $user, $notrigger = 0)
450 {
451 $resultupdate = $this->updateCommon($user, $notrigger);
452
453 if ($resultupdate > 0 && !empty($this->asset_depreciation_options)) {
454 $this->asset_depreciation_options->setDeprecationOptionsFromPost(1);
455 $this->asset_depreciation_options->updateDeprecationOptions($user, 0, $resultupdate);
456 }
457
458 if ($resultupdate > 0 && !empty($this->asset_accountancy_codes)) {
459 $this->asset_accountancy_codes->setAccountancyCodesFromPost();
460 $this->asset_accountancy_codes->updateAccountancyCodes($user, 0, $resultupdate);
461 }
462
463 return $resultupdate;
464 }
465
473 public function delete(User $user, $notrigger = 0)
474 {
475 return $this->deleteCommon($user, $notrigger);
476 //return $this->deleteCommon($user, $notrigger, 1);
477 }
478
479
487 public function validate($user, $notrigger = 0)
488 {
489 global $conf, $langs;
490
491 $error = 0;
492
493 // Protection
494 if ($this->status == self::STATUS_VALIDATED) {
495 dol_syslog(get_class($this) . "::validate action abandoned: already validated", LOG_WARNING);
496 return 0;
497 }
498
499 $now = dol_now();
500
501 $this->db->begin();
502
503 // Validate
504 $sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element;
505 $sql .= " SET status = " . self::STATUS_VALIDATED;
506 if (!empty($this->fields['date_validation'])) {
507 $sql .= ", date_validation = '" . $this->db->idate($now) . "'";
508 }
509 if (!empty($this->fields['fk_user_valid'] ?? null)) {
510 $sql .= ", fk_user_valid = " . ((int) $user->id);
511 }
512 $sql .= " WHERE rowid = " . ((int) $this->id);
513
514 dol_syslog(get_class($this) . "::validate()", LOG_DEBUG);
515 $resql = $this->db->query($sql);
516 if (!$resql) {
517 dol_print_error($this->db);
518 $this->error = $this->db->lasterror();
519 $error++;
520 }
521
522 if (!$error && !$notrigger) {
523 // Call trigger
524 $result = $this->call_trigger('ASSETMODEL_VALIDATE', $user);
525 if ($result < 0) {
526 $error++;
527 }
528 // End call triggers
529 }
530
531 // Set new ref and current status
532 if (!$error) {
533 $this->status = self::STATUS_VALIDATED;
534 }
535
536 if (!$error) {
537 $this->db->commit();
538 return 1;
539 } else {
540 $this->db->rollback();
541 return -1;
542 }
543 }
544
545
553 public function setDraft($user, $notrigger = 0)
554 {
555 // Protection
556 if ($this->status <= self::STATUS_DRAFT) {
557 return 0;
558 }
559
560 return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'ASSETMODEL_UNVALIDATE');
561 }
562
570 public function cancel($user, $notrigger = 0)
571 {
572 // Protection
573 if ($this->status != self::STATUS_VALIDATED) {
574 return 0;
575 }
576
577 return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'ASSETMODEL_CANCEL');
578 }
579
587 public function reopen($user, $notrigger = 0)
588 {
589 // Protection
590 if ($this->status != self::STATUS_CANCELED) {
591 return 0;
592 }
593
594 return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'ASSETMODEL_REOPEN');
595 }
596
607 public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
608 {
609 global $conf, $langs, $hookmanager;
610
611 if (!empty($conf->dol_no_mouse_hover)) {
612 $notooltip = 1; // Force disable tooltips
613 }
614
615 $result = '';
616
617 $label = img_picto('', $this->picto).' <u>'.$langs->trans("AssetModel").'</u>';
618 if (isset($this->status)) {
619 $label .= ' '.$this->getLibStatut(5);
620 }
621 $label .= '<br>';
622 $label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
623
624 $url = dol_buildpath('/asset/model/card.php', 1).'?id='.$this->id;
625
626 if ($option != 'nolink') {
627 // Add param to save lastsearch_values or not
628 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
629 if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
630 $add_save_lastsearch_values = 1;
631 }
632 if ($add_save_lastsearch_values) {
633 $url .= '&save_lastsearch_values=1';
634 }
635 }
636
637 $linkclose = '';
638 if (empty($notooltip)) {
639 if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
640 $label = $langs->trans("ShowAssetModel");
641 $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
642 }
643 $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
644 $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
645 } else {
646 $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
647 }
648
649 if ($option == 'nolink') {
650 $linkstart = '<span';
651 } else {
652 $linkstart = '<a href="'.$url.'"';
653 }
654 $linkstart .= $linkclose.'>';
655 if ($option == 'nolink') {
656 $linkend = '</span>';
657 } else {
658 $linkend = '</a>';
659 }
660
661 $result .= $linkstart;
662
663 if (empty($this->showphoto_on_popup)) {
664 if ($withpicto) {
665 $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);
666 }
667 } else {
668 if ($withpicto) {
669 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
670
671 list($class, $module) = explode('@', $this->picto);
672 $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref);
673 $filearray = dol_dir_list($upload_dir, "files");
674 $filename = $filearray[0]['name'];
675 if (!empty($filename)) {
676 $pospoint = strpos($filearray[0]['name'], '.');
677
678 $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint);
679 if (!getDolGlobalString(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS')) {
680 $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>';
681 } else {
682 $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>';
683 }
684
685 $result .= '</div>';
686 } else {
687 $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);
688 }
689 }
690 }
691
692 if ($withpicto != 2) {
693 $result .= $this->ref;
694 }
695
696 $result .= $linkend;
697 //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
698
699 global $action, $hookmanager;
700 $hookmanager->initHooks(array('assetmodeldao'));
701 $parameters = array('id' => $this->id, 'getnomurl' => $result);
702 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
703 if ($reshook > 0) {
704 $result = $hookmanager->resPrint;
705 } else {
706 $result .= $hookmanager->resPrint;
707 }
708
709 return $result;
710 }
711
718 public function getLabelStatus($mode = 0)
719 {
720 return $this->LibStatut($this->status, $mode);
721 }
722
729 public function getLibStatut($mode = 0)
730 {
731 return $this->LibStatut($this->status, $mode);
732 }
733
734 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
742 public function LibStatut($status, $mode = 0)
743 {
744 // phpcs:enable
745 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
746 global $langs;
747 //$langs->load("assets");
748 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
749 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled');
750 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled');
751 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
752 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled');
753 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled');
754 }
755
756 $statusType = 'status'.$status;
757 //if ($status == self::STATUS_VALIDATED) $statusType = 'status1';
758 if ($status == self::STATUS_CANCELED) {
759 $statusType = 'status6';
760 }
761
762 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
763 }
764
771 public function info($id)
772 {
773 $sql = "SELECT rowid, date_creation as datec, tms as datem,";
774 $sql .= " fk_user_creat, fk_user_modif";
775 $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
776 $sql .= " WHERE t.rowid = ".((int) $id);
777
778 $result = $this->db->query($sql);
779 if ($result) {
780 if ($this->db->num_rows($result)) {
781 $obj = $this->db->fetch_object($result);
782
783 $this->id = $obj->rowid;
784
785 $this->user_creation_id = $obj->fk_user_creat;
786 $this->user_modification_id = $obj->fk_user_modif;
787 $this->date_creation = $this->db->jdate($obj->datec);
788 $this->date_modification = $this->db->jdate($obj->datem);
789 }
790
791 $this->db->free($result);
792 } else {
793 dol_print_error($this->db);
794 }
795 }
796
803 public function initAsSpecimen()
804 {
805 // Set here init that are not commonf fields
806 // $this->property1 = ...
807 // $this->property2 = ...
808
809 return $this->initAsSpecimenCommon();
810 }
811
817 public function getLinesArray()
818 {
819 $this->lines = array();
820
821 return $this->lines;
822 }
823
831 public function doScheduledJob()
832 {
833 //global $conf, $langs;
834
835 //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log';
836
837 $error = 0;
838 $this->output = '';
839 $this->error = '';
840
841 dol_syslog(__METHOD__, LOG_DEBUG);
842
843 $now = dol_now();
844
845 $this->db->begin();
846
847 // ...
848
849 $this->db->commit();
850
851 return $error;
852 }
853}
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:634
$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 a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.