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