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
267 // Reset some properties
268 unset($object->id);
269 unset($object->fk_user_creat);
270 unset($object->import_key);
271
272 // Clear fields
273 if (property_exists($object, 'ref')) {
274 // @phan-suppress-next-line PhanTypeInvalidDimOffset
275 $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default'];
276 }
277 if (property_exists($object, 'label')) {
278 // @phan-suppress-next-line PhanTypeInvalidDimOffset
279 $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default'];
280 }
281 if (property_exists($object, 'status')) {
282 $object->status = self::STATUS_DRAFT;
283 }
284 if (property_exists($object, 'date_creation')) {
285 $object->date_creation = dol_now();
286 }
287 if (property_exists($object, 'date_modification')) {
288 $object->date_modification = null;
289 }
290 // ...
291 // Clear extrafields that are unique
292 if (is_array($object->array_options) && count($object->array_options) > 0) {
293 $extrafields->fetch_name_optionals_label($this->table_element);
294 foreach ($object->array_options as $key => $option) {
295 $shortkey = preg_replace('/options_/', '', $key);
296 if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) {
297 //var_dump($key); var_dump($clonedObj->array_options[$key]); exit;
298 unset($object->array_options[$key]);
299 }
300 }
301 }
302
303 // Create clone
304 $object->context['createfromclone'] = 'createfromclone';
305 $result = $object->createCommon($user);
306 if ($result < 0) {
307 $error++;
308 $this->error = $object->error;
309 $this->errors = $object->errors;
310 }
311
312 if (!$error) {
313 // copy internal contacts
314 if ($this->copy_linked_contact($object, 'internal') < 0) {
315 $error++;
316 }
317 }
318
319 if (!$error) {
320 // copy external contacts if same company
321 if (property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) {
322 if ($this->copy_linked_contact($object, 'external') < 0) {
323 $error++;
324 }
325 }
326 }
327
328 unset($object->context['createfromclone']);
329
330 // End
331 if (!$error) {
332 $this->db->commit();
333 return $object;
334 } else {
335 $this->db->rollback();
336 return -1;
337 }
338 }
339
347 public function fetch($id, $ref = null)
348 {
349 $result = $this->fetchCommon($id, $ref);
350
351 return $result;
352 }
353
366 public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND')
367 {
368 dol_syslog(__METHOD__, LOG_DEBUG);
369
370 $records = array();
371
372 $sql = "SELECT ";
373 $sql .= $this->getFieldList('t');
374 $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
375 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
376 $sql .= " WHERE t.entity IN (".getEntity($this->element).")";
377 } else {
378 $sql .= " WHERE 1 = 1";
379 }
380
381 // Manage filter
382 $errormessage = '';
383 $sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage);
384 if ($errormessage) {
385 $this->errors[] = $errormessage;
386 dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
387 return -1;
388 }
389
390 if (!empty($sortfield)) {
391 $sql .= $this->db->order($sortfield, $sortorder);
392 }
393 if (!empty($limit)) {
394 $sql .= $this->db->plimit($limit, $offset);
395 }
396
397 $resql = $this->db->query($sql);
398 if ($resql) {
399 $num = $this->db->num_rows($resql);
400 $i = 0;
401 while ($i < ($limit ? min($limit, $num) : $num)) {
402 $obj = $this->db->fetch_object($resql);
403
404 $record = new self($this->db);
405 $record->setVarsFromFetchObj($obj);
406
407 $records[$record->id] = $record;
408
409 $i++;
410 }
411 $this->db->free($resql);
412
413 return $records;
414 } else {
415 $this->errors[] = 'Error '.$this->db->lasterror();
416 dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
417
418 return -1;
419 }
420 }
421
429 public function update(User $user, $notrigger = 0)
430 {
431 $resultupdate = $this->updateCommon($user, $notrigger);
432
433 if ($resultupdate > 0 && !empty($this->asset_depreciation_options)) {
434 $this->asset_depreciation_options->setDeprecationOptionsFromPost(1);
435 $this->asset_depreciation_options->updateDeprecationOptions($user, 0, $resultupdate);
436 }
437
438 if ($resultupdate > 0 && !empty($this->asset_accountancy_codes)) {
439 $this->asset_accountancy_codes->setAccountancyCodesFromPost();
440 $this->asset_accountancy_codes->updateAccountancyCodes($user, 0, $resultupdate);
441 }
442
443 return $resultupdate;
444 }
445
453 public function delete(User $user, $notrigger = 0)
454 {
455 return $this->deleteCommon($user, $notrigger);
456 //return $this->deleteCommon($user, $notrigger, 1);
457 }
458
459
467 public function validate($user, $notrigger = 0)
468 {
469 global $conf, $langs;
470
471 $error = 0;
472
473 // Protection
474 if ($this->status == self::STATUS_VALIDATED) {
475 dol_syslog(get_class($this) . "::validate action abandoned: already validated", LOG_WARNING);
476 return 0;
477 }
478
479 $now = dol_now();
480
481 $this->db->begin();
482
483 // Validate
484 $sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element;
485 $sql .= " SET status = " . self::STATUS_VALIDATED;
486 if (!empty($this->fields['date_validation'])) {
487 $sql .= ", date_validation = '" . $this->db->idate($now) . "'";
488 }
489 if (!empty($this->fields['fk_user_valid'] ?? null)) {
490 $sql .= ", fk_user_valid = " . ((int) $user->id);
491 }
492 $sql .= " WHERE rowid = " . ((int) $this->id);
493
494 dol_syslog(get_class($this) . "::validate()", LOG_DEBUG);
495 $resql = $this->db->query($sql);
496 if (!$resql) {
497 dol_print_error($this->db);
498 $this->error = $this->db->lasterror();
499 $error++;
500 }
501
502 if (!$error && !$notrigger) {
503 // Call trigger
504 $result = $this->call_trigger('ASSETMODEL_VALIDATE', $user);
505 if ($result < 0) {
506 $error++;
507 }
508 // End call triggers
509 }
510
511 // Set new ref and current status
512 if (!$error) {
513 $this->status = self::STATUS_VALIDATED;
514 }
515
516 if (!$error) {
517 $this->db->commit();
518 return 1;
519 } else {
520 $this->db->rollback();
521 return -1;
522 }
523 }
524
525
533 public function setDraft($user, $notrigger = 0)
534 {
535 // Protection
536 if ($this->status <= self::STATUS_DRAFT) {
537 return 0;
538 }
539
540 return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'ASSETMODEL_UNVALIDATE');
541 }
542
550 public function cancel($user, $notrigger = 0)
551 {
552 // Protection
553 if ($this->status != self::STATUS_VALIDATED) {
554 return 0;
555 }
556
557 return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'ASSETMODEL_CANCEL');
558 }
559
567 public function reopen($user, $notrigger = 0)
568 {
569 // Protection
570 if ($this->status != self::STATUS_CANCELED) {
571 return 0;
572 }
573
574 return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'ASSETMODEL_REOPEN');
575 }
576
587 public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
588 {
589 global $conf, $langs, $hookmanager;
590
591 if (!empty($conf->dol_no_mouse_hover)) {
592 $notooltip = 1; // Force disable tooltips
593 }
594
595 $result = '';
596
597 $label = img_picto('', $this->picto).' <u>'.$langs->trans("AssetModel").'</u>';
598 if (isset($this->status)) {
599 $label .= ' '.$this->getLibStatut(5);
600 }
601 $label .= '<br>';
602 $label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
603
604 $url = dol_buildpath('/asset/model/card.php', 1).'?id='.$this->id;
605
606 if ($option != 'nolink') {
607 // Add param to save lastsearch_values or not
608 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
609 if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
610 $add_save_lastsearch_values = 1;
611 }
612 if ($add_save_lastsearch_values) {
613 $url .= '&save_lastsearch_values=1';
614 }
615 }
616
617 $linkclose = '';
618 if (empty($notooltip)) {
619 if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
620 $label = $langs->trans("ShowAssetModel");
621 $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
622 }
623 $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
624 $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
625 } else {
626 $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
627 }
628
629 if ($option == 'nolink') {
630 $linkstart = '<span';
631 } else {
632 $linkstart = '<a href="'.$url.'"';
633 }
634 $linkstart .= $linkclose.'>';
635 if ($option == 'nolink') {
636 $linkend = '</span>';
637 } else {
638 $linkend = '</a>';
639 }
640
641 $result .= $linkstart;
642
643 if (empty($this->showphoto_on_popup)) {
644 if ($withpicto) {
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 } else {
648 if ($withpicto) {
649 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
650
651 list($class, $module) = explode('@', $this->picto);
652 $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref);
653 $filearray = dol_dir_list($upload_dir, "files");
654 $filename = $filearray[0]['name'];
655 if (!empty($filename)) {
656 $pospoint = strpos($filearray[0]['name'], '.');
657
658 $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint);
659 if (!getDolGlobalString(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS')) {
660 $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>';
661 } else {
662 $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>';
663 }
664
665 $result .= '</div>';
666 } else {
667 $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);
668 }
669 }
670 }
671
672 if ($withpicto != 2) {
673 $result .= $this->ref;
674 }
675
676 $result .= $linkend;
677 //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
678
679 global $action, $hookmanager;
680 $hookmanager->initHooks(array('assetmodeldao'));
681 $parameters = array('id' => $this->id, 'getnomurl' => $result);
682 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
683 if ($reshook > 0) {
684 $result = $hookmanager->resPrint;
685 } else {
686 $result .= $hookmanager->resPrint;
687 }
688
689 return $result;
690 }
691
698 public function getLabelStatus($mode = 0)
699 {
700 return $this->LibStatut($this->status, $mode);
701 }
702
709 public function getLibStatut($mode = 0)
710 {
711 return $this->LibStatut($this->status, $mode);
712 }
713
714 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
722 public function LibStatut($status, $mode = 0)
723 {
724 // phpcs:enable
725 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
726 global $langs;
727 //$langs->load("assets");
728 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
729 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled');
730 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled');
731 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
732 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled');
733 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled');
734 }
735
736 $statusType = 'status'.$status;
737 //if ($status == self::STATUS_VALIDATED) $statusType = 'status1';
738 if ($status == self::STATUS_CANCELED) {
739 $statusType = 'status6';
740 }
741
742 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
743 }
744
751 public function info($id)
752 {
753 $sql = "SELECT rowid, date_creation as datec, tms as datem,";
754 $sql .= " fk_user_creat, fk_user_modif";
755 $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
756 $sql .= " WHERE t.rowid = ".((int) $id);
757
758 $result = $this->db->query($sql);
759 if ($result) {
760 if ($this->db->num_rows($result)) {
761 $obj = $this->db->fetch_object($result);
762
763 $this->id = $obj->rowid;
764
765 $this->user_creation_id = $obj->fk_user_creat;
766 $this->user_modification_id = $obj->fk_user_modif;
767 $this->date_creation = $this->db->jdate($obj->datec);
768 $this->date_modification = $this->db->jdate($obj->datem);
769 }
770
771 $this->db->free($result);
772 } else {
773 dol_print_error($this->db);
774 }
775 }
776
783 public function initAsSpecimen()
784 {
785 // Set here init that are not commonf fields
786 // $this->property1 = ...
787 // $this->property2 = ...
788
789 return $this->initAsSpecimenCommon();
790 }
791}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
$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.
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.
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.
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.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Definition index.php:162
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.