dolibarr 19.0.4
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 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
25// Put here all includes required by your class file
26require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
27//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
28//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
29
34{
38 public $module = 'asset';
39
43 public $element = 'assetmodel';
44
48 public $table_element = 'asset_model';
49
54 public $ismultientitymanaged = 1;
55
59 public $isextrafieldmanaged = 1;
60
64 public $picto = 'asset';
65
66
67 const STATUS_DRAFT = 0;
68 const STATUS_VALIDATED = 1;
69 const STATUS_CANCELED = 9;
70
71
103 public $fields=array(
104 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
105 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'validate'=>'1'),
106 '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',),
107 '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',),
108 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>300, 'notnull'=>0, 'visible'=>0, 'validate'=>'1',),
109 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>301, 'notnull'=>0, 'visible'=>0, 'validate'=>'1',),
110 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,),
111 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,),
112 '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',),
113 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,),
114 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,),
115 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>1, 'default'=>'0', 'visible'=>2, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Enabled', '9'=>'Disabled'), 'validate'=>'1',),
116 );
117 public $rowid;
118 public $ref;
119 public $label;
120 public $asset_type;
121 public $note_public;
122 public $note_private;
123 public $date_creation;
124 public $tms;
125 public $fk_user_creat;
126 public $fk_user_modif;
127 public $last_main_doc;
128 public $import_key;
129 public $model_pdf;
130 public $status;
131 public $asset_depreciation_options;
132
133 // /**
134 // * @var string Field with ID of parent key if this object has a parent
135 // */
136 // public $fk_element = 'fk_assetmodel';
137 // /**
138 // * @var array List of child tables. To test if we can delete object.
139 // */
140 // protected $childtables = array();
141 // /**
142 // * @var array List of child tables. To know object to delete on cascade.
143 // * If name matches '@ClassNAme:FilePathClass;ParentFkFieldName' it will
144 // * call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object
145 // */
146 // protected $childtablesoncascade = array('asset_assetmodeldet');
147
148
154 public function __construct(DoliDB $db)
155 {
156 global $conf, $langs;
157
158 $this->db = $db;
159
160 if (!getDolGlobalString('MAIN_SHOW_TECHNICAL_ID') && isset($this->fields['rowid'])) {
161 $this->fields['rowid']['visible'] = 0;
162 }
163 if (!isModEnabled('multicompany') && isset($this->fields['entity'])) {
164 $this->fields['entity']['enabled'] = 0;
165 }
166
167 // Unset fields that are disabled
168 foreach ($this->fields as $key => $val) {
169 if (isset($val['enabled']) && empty($val['enabled'])) {
170 unset($this->fields[$key]);
171 }
172 }
173
174 // Translate some data of arrayofkeyval
175 if (is_object($langs)) {
176 foreach ($this->fields as $key => $val) {
177 if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
178 foreach ($val['arrayofkeyval'] as $key2 => $val2) {
179 $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
180 }
181 }
182 }
183 }
184 }
185
193 public function create(User $user, $notrigger = false)
194 {
195 $resultcreate = $this->createCommon($user, $notrigger);
196
197 return $resultcreate;
198 }
199
207 public function createFromClone(User $user, $fromid)
208 {
209 global $langs, $extrafields;
210 $error = 0;
211
212 dol_syslog(__METHOD__, LOG_DEBUG);
213
214 $object = new self($this->db);
215
216 $this->db->begin();
217
218 // Load source object
219 $result = $object->fetchCommon($fromid);
220 if ($result > 0 && !empty($object->table_element_line)) {
221 $object->fetchLines();
222 }
223
224 // get lines so they will be clone
225 //foreach($this->lines as $line)
226 // $line->fetch_optionals();
227
228 // Reset some properties
229 unset($object->id);
230 unset($object->fk_user_creat);
231 unset($object->import_key);
232
233 // Clear fields
234 if (property_exists($object, 'ref')) {
235 $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default'];
236 }
237 if (property_exists($object, 'label')) {
238 $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default'];
239 }
240 if (property_exists($object, 'status')) {
241 $object->status = self::STATUS_DRAFT;
242 }
243 if (property_exists($object, 'date_creation')) {
244 $object->date_creation = dol_now();
245 }
246 if (property_exists($object, 'date_modification')) {
247 $object->date_modification = null;
248 }
249 // ...
250 // Clear extrafields that are unique
251 if (is_array($object->array_options) && count($object->array_options) > 0) {
252 $extrafields->fetch_name_optionals_label($this->table_element);
253 foreach ($object->array_options as $key => $option) {
254 $shortkey = preg_replace('/options_/', '', $key);
255 if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) {
256 //var_dump($key); var_dump($clonedObj->array_options[$key]); exit;
257 unset($object->array_options[$key]);
258 }
259 }
260 }
261
262 // Create clone
263 $object->context['createfromclone'] = 'createfromclone';
264 $result = $object->createCommon($user);
265 if ($result < 0) {
266 $error++;
267 $this->error = $object->error;
268 $this->errors = $object->errors;
269 }
270
271 if (!$error) {
272 // copy internal contacts
273 if ($this->copy_linked_contact($object, 'internal') < 0) {
274 $error++;
275 }
276 }
277
278 if (!$error) {
279 // copy external contacts if same company
280 if (property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) {
281 if ($this->copy_linked_contact($object, 'external') < 0) {
282 $error++;
283 }
284 }
285 }
286
287 unset($object->context['createfromclone']);
288
289 // End
290 if (!$error) {
291 $this->db->commit();
292 return $object;
293 } else {
294 $this->db->rollback();
295 return -1;
296 }
297 }
298
306 public function fetch($id, $ref = null)
307 {
308 $result = $this->fetchCommon($id, $ref);
309 if ($result > 0 && !empty($this->table_element_line)) {
310 $this->fetchLines();
311 }
312 return $result;
313 }
314
320 public function fetchLines()
321 {
322 $this->lines = array();
323
324 return 1;
325 }
326
327
339 public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
340 {
341 global $conf;
342
343 dol_syslog(__METHOD__, LOG_DEBUG);
344
345 $records = array();
346
347 $sql = "SELECT ";
348 $sql .= $this->getFieldList('t');
349 $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
350 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
351 $sql .= " WHERE t.entity IN (".getEntity($this->element).")";
352 } else {
353 $sql .= " WHERE 1 = 1";
354 }
355 // Manage filter
356 $sqlwhere = array();
357 if (count($filter) > 0) {
358 foreach ($filter as $key => $value) {
359 if ($key == 't.rowid') {
360 $sqlwhere[] = $key." = ".((int) $value);
361 } elseif (array_key_exists($key, $this->fields) && in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) {
362 $sqlwhere[] = $key." = '".$this->db->idate($value)."'";
363 } elseif ($key == 'customsql') {
364 $sqlwhere[] = $value;
365 } elseif (strpos($value, '%') === false) {
366 $sqlwhere[] = $key." IN (".$this->db->sanitize($this->db->escape($value)).")";
367 } else {
368 $sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'";
369 }
370 }
371 }
372 if (count($sqlwhere) > 0) {
373 $sql .= " AND (".implode(" ".$filtermode." ", $sqlwhere).")";
374 }
375
376 if (!empty($sortfield)) {
377 $sql .= $this->db->order($sortfield, $sortorder);
378 }
379 if (!empty($limit)) {
380 $sql .= $this->db->plimit($limit, $offset);
381 }
382
383 $resql = $this->db->query($sql);
384 if ($resql) {
385 $num = $this->db->num_rows($resql);
386 $i = 0;
387 while ($i < ($limit ? min($limit, $num) : $num)) {
388 $obj = $this->db->fetch_object($resql);
389
390 $record = new self($this->db);
391 $record->setVarsFromFetchObj($obj);
392
393 $records[$record->id] = $record;
394
395 $i++;
396 }
397 $this->db->free($resql);
398
399 return $records;
400 } else {
401 $this->errors[] = 'Error '.$this->db->lasterror();
402 dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
403
404 return -1;
405 }
406 }
407
415 public function update(User $user, $notrigger = false)
416 {
417 return $this->updateCommon($user, $notrigger);
418 }
419
427 public function delete(User $user, $notrigger = false)
428 {
429 return $this->deleteCommon($user, $notrigger);
430 //return $this->deleteCommon($user, $notrigger, 1);
431 }
432
433
441 public function validate($user, $notrigger = 0)
442 {
443 global $conf, $langs;
444
445 $error = 0;
446
447 // Protection
448 if ($this->status == self::STATUS_VALIDATED) {
449 dol_syslog(get_class($this) . "::validate action abandonned: already validated", LOG_WARNING);
450 return 0;
451 }
452
453 $now = dol_now();
454
455 $this->db->begin();
456
457 // Validate
458 $sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element;
459 $sql .= " SET status = " . self::STATUS_VALIDATED;
460 if (!empty($this->fields['date_validation'])) {
461 $sql .= ", date_validation = '" . $this->db->idate($now) . "'";
462 }
463 if (!empty($this->fields['fk_user_valid'])) {
464 $sql .= ", fk_user_valid = " . ((int) $user->id);
465 }
466 $sql .= " WHERE rowid = " . ((int) $this->id);
467
468 dol_syslog(get_class($this) . "::validate()", LOG_DEBUG);
469 $resql = $this->db->query($sql);
470 if (!$resql) {
471 dol_print_error($this->db);
472 $this->error = $this->db->lasterror();
473 $error++;
474 }
475
476 if (!$error && !$notrigger) {
477 // Call trigger
478 $result = $this->call_trigger('ASSETMODEL_VALIDATE', $user);
479 if ($result < 0) {
480 $error++;
481 }
482 // End call triggers
483 }
484
485 // Set new ref and current status
486 if (!$error) {
487 $this->status = self::STATUS_VALIDATED;
488 }
489
490 if (!$error) {
491 $this->db->commit();
492 return 1;
493 } else {
494 $this->db->rollback();
495 return -1;
496 }
497 }
498
499
507 public function setDraft($user, $notrigger = 0)
508 {
509 // Protection
510 if ($this->status <= self::STATUS_DRAFT) {
511 return 0;
512 }
513
514 return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'ASSETMODEL_UNVALIDATE');
515 }
516
524 public function cancel($user, $notrigger = 0)
525 {
526 // Protection
527 if ($this->status != self::STATUS_VALIDATED) {
528 return 0;
529 }
530
531 return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'ASSETMODEL_CANCEL');
532 }
533
541 public function reopen($user, $notrigger = 0)
542 {
543 // Protection
544 if ($this->status != self::STATUS_CANCELED) {
545 return 0;
546 }
547
548 return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'ASSETMODEL_REOPEN');
549 }
550
561 public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
562 {
563 global $conf, $langs, $hookmanager;
564
565 if (!empty($conf->dol_no_mouse_hover)) {
566 $notooltip = 1; // Force disable tooltips
567 }
568
569 $result = '';
570
571 $label = img_picto('', $this->picto).' <u>'.$langs->trans("AssetModel").'</u>';
572 if (isset($this->status)) {
573 $label .= ' '.$this->getLibStatut(5);
574 }
575 $label .= '<br>';
576 $label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
577
578 $url = dol_buildpath('/asset/model/card.php', 1).'?id='.$this->id;
579
580 if ($option != 'nolink') {
581 // Add param to save lastsearch_values or not
582 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
583 if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
584 $add_save_lastsearch_values = 1;
585 }
586 if ($add_save_lastsearch_values) {
587 $url .= '&save_lastsearch_values=1';
588 }
589 }
590
591 $linkclose = '';
592 if (empty($notooltip)) {
593 if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
594 $label = $langs->trans("ShowAssetModel");
595 $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
596 }
597 $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
598 $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
599 } else {
600 $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
601 }
602
603 if ($option == 'nolink') {
604 $linkstart = '<span';
605 } else {
606 $linkstart = '<a href="'.$url.'"';
607 }
608 $linkstart .= $linkclose.'>';
609 if ($option == 'nolink') {
610 $linkend = '</span>';
611 } else {
612 $linkend = '</a>';
613 }
614
615 $result .= $linkstart;
616
617 if (empty($this->showphoto_on_popup)) {
618 if ($withpicto) {
619 $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);
620 }
621 } else {
622 if ($withpicto) {
623 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
624
625 list($class, $module) = explode('@', $this->picto);
626 $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref);
627 $filearray = dol_dir_list($upload_dir, "files");
628 $filename = $filearray[0]['name'];
629 if (!empty($filename)) {
630 $pospoint = strpos($filearray[0]['name'], '.');
631
632 $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint);
633 if (!getDolGlobalString(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS')) {
634 $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>';
635 } else {
636 $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>';
637 }
638
639 $result .= '</div>';
640 } else {
641 $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);
642 }
643 }
644 }
645
646 if ($withpicto != 2) {
647 $result .= $this->ref;
648 }
649
650 $result .= $linkend;
651 //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
652
653 global $action, $hookmanager;
654 $hookmanager->initHooks(array('assetmodeldao'));
655 $parameters = array('id'=>$this->id, 'getnomurl'=>$result);
656 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
657 if ($reshook > 0) {
658 $result = $hookmanager->resPrint;
659 } else {
660 $result .= $hookmanager->resPrint;
661 }
662
663 return $result;
664 }
665
672 public function getLabelStatus($mode = 0)
673 {
674 return $this->LibStatut($this->status, $mode);
675 }
676
683 public function getLibStatut($mode = 0)
684 {
685 return $this->LibStatut($this->status, $mode);
686 }
687
688 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
696 public function LibStatut($status, $mode = 0)
697 {
698 // phpcs:enable
699 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
700 global $langs;
701 //$langs->load("assets");
702 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
703 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled');
704 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled');
705 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
706 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled');
707 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled');
708 }
709
710 $statusType = 'status'.$status;
711 //if ($status == self::STATUS_VALIDATED) $statusType = 'status1';
712 if ($status == self::STATUS_CANCELED) {
713 $statusType = 'status6';
714 }
715
716 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
717 }
718
725 public function info($id)
726 {
727 $sql = "SELECT rowid, date_creation as datec, tms as datem,";
728 $sql .= " fk_user_creat, fk_user_modif";
729 $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
730 $sql .= " WHERE t.rowid = ".((int) $id);
731
732 $result = $this->db->query($sql);
733 if ($result) {
734 if ($this->db->num_rows($result)) {
735 $obj = $this->db->fetch_object($result);
736
737 $this->id = $obj->rowid;
738
739 $this->user_creation_id = $obj->fk_user_creat;
740 $this->user_modification_id = $obj->fk_user_modif;
741 $this->date_creation = $this->db->jdate($obj->datec);
742 $this->date_modification = $this->db->jdate($obj->datem);
743 }
744
745 $this->db->free($result);
746 } else {
747 dol_print_error($this->db);
748 }
749 }
750
757 public function initAsSpecimen()
758 {
759 // Set here init that are not commonf fields
760 // $this->property1 = ...
761 // $this->property2 = ...
762
763 $this->initAsSpecimenCommon();
764 }
765
771 public function getLinesArray()
772 {
773 $this->lines = array();
774
775 return $this->lines;
776 }
777
785 public function doScheduledJob()
786 {
787 global $conf, $langs;
788
789 //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log';
790
791 $error = 0;
792 $this->output = '';
793 $this->error = '';
794
795 dol_syslog(__METHOD__, LOG_DEBUG);
796
797 $now = dol_now();
798
799 $this->db->begin();
800
801 // ...
802
803 $this->db->commit();
804
805 return $error;
806 }
807}
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Definition security.php:604
$object ref
Definition info.php:79
Class for AssetModel.
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter=array(), $filtermode='AND')
Load list of objects in memory from the database.
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.
info($id)
Load the info information in the object.
update(User $user, $notrigger=false)
Update object into database.
validate($user, $notrigger=0)
Validate object.
create(User $user, $notrigger=false)
Create object into database.
cancel($user, $notrigger=0)
Set cancel status.
getLinesArray()
Create an array of lines.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionaly the picto)
fetchLines()
Load object lines in memory from the database.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
createCommon(User $user, $notrigger=false)
Create object into database.
deleteCommon(User $user, $notrigger=false, $forcechilddeletion=0)
Delete object in database.
getFieldList($alias='', $excludefields=array())
Function to concat keys of fields.
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.
updateCommon(User $user, $notrigger=false)
Update object into database.
fetchCommon($id, $ref=null, $morewhere='', $noextrafields=0)
Load object in memory from the 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($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:62
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
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.