dolibarr 23.0.3
triggerhistory.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2023-2025 Frédéric France <frederic.france@free.fr>
4 * Copyright (C) 2025 Alice Adminson <myemail@mycompany.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26// Put here all includes required by your class file
27require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
28//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
29//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
30
35{
39 public $module = 'webhook';
40
44 public $element = 'webhook_triggerhistory';
45
49 public $table_element = 'webhook_history';
50
54 //public $element_for_permission = 'webhook';
55
59 public $picto = 'fa-calendar-alt';
60
61
62 const STATUS_SUCCESS = 1;
63 const STATUS_ERROR = -1;
64
108 // BEGIN MODULEBUILDER PROPERTIES
113 public $fields = array(
114 "rowid" => array("type" => "integer", "label" => "TechnicalID", "enabled" => 1, 'position' => 1, 'notnull' => 1, "visible" => 1, "noteditable" => 1, "index" => 1, "css" => "left", "comment" => "Id"),
115 "fk_target" => array("type" => "integer:target:webhook/class/target.class.php:0:(status:=:1)", "label" => "Target", "enabled" => 1, 'position' => 5, 'notnull' => 1, "visible" => 1),
116 "trigger_code" => array("type" => "varchar(128)", "label" => "TriggerCode", "enabled" => 1, 'position' => 8, 'notnull' => 1, "visible" => 1),
117 "url" => array("type" => "varchar(255)", "label" => "Url", "enabled" => 1, 'position' => 15, 'notnull' => 1, "visible" => 1, 'csslist' => "small tdoverflowmax150"),
118 "trigger_data" => array("type" => "text", "label" => "TriggerData", "enabled" => 1, 'position' => 20, 'notnull' => 1, "visible" => 1, "csslist" => "small tdoverflowmax300"),
119 "note_private" => array("type" => "text", "label" => "NotePrivate", "enabled" => 1, 'position' => 62, 'notnull' => 0, "visible" => 0, "cssview" => "wordbreak", "validate" => 1),
120 "date_creation" => array("type" => "datetime", "label" => "DateCreation", "enabled" => 1, 'position' => 500, 'notnull' => 1, "visible" => -2),
121 "tms" => array("type" => "timestamp", "label" => "DateModification", "enabled" => 1, 'position' => 501, 'notnull' => 0, "visible" => -2),
122 "fk_user_creat" => array("type" => "integer:User:user/class/user.class.php", "label" => "UserAuthor", "picto" => "user", "enabled" => 1, 'position' => 510, 'notnull' => 1, "visible" => -2, "csslist" => "tdoverflowmax150"),
123 "import_key" => array("type" => "varchar(14)", "label" => "ImportId", "enabled" => 1, 'position' => 1000, 'notnull' => -1, "visible" => -2,),
124 "status" => array("type" => "integer", "label" => "Status", "enabled" => 1, "position" => 2000, "notnull" => 1, 'default' => '1', "visible" => 1, "index" => 1, "arrayofkeyval" => array("1" => "Success", "-1" => "Error"), "validate" => 1),
125 "error_message" => array("type" => "text", "label" => "ErrorMessage", "enabled" => 1, 'position' => 50, 'notnull' => 0, "visible" => 1, "csslist" => "small tdoverflowmax150"),
126 );
130 public $rowid;
134 public $note_public;
138 public $note_private;
142 public $date_creation;
146 public $tms;
150 public $fk_user_creat;
154 public $import_key;
158 public $status;
162 public $trigger_data;
166 public $fk_target;
170 public $url;
174 public $trigger_code;
178 public $error_messsage;
179 // END MODULEBUILDER PROPERTIES
180
181
182 // If this object has a subtable with lines
183
184 // /**
185 // * @var string Name of subtable line
186 // */
187 // public $table_element_line = 'webhook_historyline';
188
189 // /**
190 // * @var string Field name with ID of parent key if this object has a parent, Or Field name of in child tables to link to this record.
191 // */
192 // public $fk_element = 'fk_history';
193
194 // /**
195 // * @var string Name of subtable class that manage subtable lines
196 // */
197 // public $class_element_line = 'Historyline';
198
199 // /**
200 // * @var array List of child tables. To test if we can delete object.
201 // */
202 // protected $childtables = array('mychildtable' => array('name'=>'', 'fk_element'=>'fk_history'));
203
204 // /**
205 // * @var array List of child tables. To know object to delete on cascade.
206 // * If name matches '@ClassName:FilePathClass:ParentFkFieldName' (the recommended mode) it will
207 // * call method ClassName->deleteByParentField(parentId, 'ParentFkFieldName') to fetch and delete child object.
208 // * Using an array like childtables should not be implemented because a child may have other child, so we must only use the method that call deleteByParentField().
209 // */
210 // protected $childtablesoncascade = array('webhook_historydet');
211
212 // /**
213 // * @var HistoryLine[] Array of subtable lines
214 // */
215 // public $lines = array();
216
217
218
224 public function __construct(DoliDB $db)
225 {
226 global $langs;
227
228 $this->db = $db;
229 $this->ismultientitymanaged = 0;
230 $this->isextrafieldmanaged = 1;
231
232 if (!getDolGlobalInt('MAIN_SHOW_TECHNICAL_ID') && isset($this->fields['rowid']) && !empty($this->fields['ref'])) {
233 $this->fields['rowid']['visible'] = 0;
234 }
235 if (!isModEnabled('multicompany') && isset($this->fields['entity'])) {
236 $this->fields['entity']['enabled'] = 0;
237 }
238
239 // Example to show how to set values of fields definition dynamically
240 /*if ($user->hasRight('webhook', 'triggerhistory', 'read')) {
241 $this->fields['myfield']['visible'] = 1;
242 $this->fields['myfield']['noteditable'] = 0;
243 }*/
244
245 // Unset fields that are disabled
246 foreach ($this->fields as $key => $val) {
247 if (isset($val['enabled']) && empty($val['enabled'])) {
248 unset($this->fields[$key]);
249 }
250 }
251
252 // Translate some data of arrayofkeyval
253 if (is_object($langs)) {
254 foreach ($this->fields as $key => $val) {
255 if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
256 foreach ($val['arrayofkeyval'] as $key2 => $val2) {
257 $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
258 }
259 }
260 }
261 }
262 }
263
271 public function create(User $user, $notrigger = 0)
272 {
273 $result = $this->createCommon($user, $notrigger);
274
275 // uncomment lines below if you want to validate object after creation
276 // if ($result > 0) {
277 // $this->fetch($this->id); // needed to retrieve some fields (ie date_creation for masked ref)
278 // $resultupdate = $this->validate($user, $notrigger);
279 // if ($resultupdate < 0) { return $resultupdate; }
280 // }
281
282 return $result;
283 }
284
294 public function fetch($id, $ref = null, $noextrafields = 0, $nolines = 0)
295 {
296 $result = $this->fetchCommon($id, $ref, '', $noextrafields);
297 if ($result > 0 && !empty($this->table_element_line) && empty($nolines)) {
298 $this->fetchLines($noextrafields);
299 }
300 return $result;
301 }
302
309 public function fetchLines($noextrafields = 0)
310 {
311 $this->lines = array();
312
313 $result = $this->fetchLinesCommon('', $noextrafields);
314 return $result;
315 }
316
317
332 public function fetchAll($sortorder = '', $sortfield = '', $limit = 1000, $offset = 0, string $filter = '', $filtermode = 'AND')
333 {
334 dol_syslog(__METHOD__, LOG_DEBUG);
335
336 $records = array();
337
338 $sql = "SELECT ";
339 $sql .= $this->getFieldList('t');
340 $sql .= " FROM ".$this->db->prefix().$this->table_element." as t";
341 if ($this->isextrafieldmanaged == 1) {
342 $sql .= " LEFT JOIN ".$this->db->prefix().$this->table_element."_extrafields as te ON te.fk_object = t.rowid";
343 }
344 if ($this->ismultientitymanaged == 1) {
345 $sql .= " WHERE t.entity IN (".getEntity($this->element).")";
346 } else {
347 $sql .= " WHERE 1 = 1";
348 }
349
350 // Manage filter
351 $errormessage = '';
352 $sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage);
353 if ($errormessage) {
354 $this->errors[] = $errormessage;
355 dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
356 return -1;
357 }
358
359 if (!empty($sortfield)) {
360 $sql .= $this->db->order($sortfield, $sortorder);
361 }
362 if (!empty($limit)) {
363 $sql .= $this->db->plimit($limit, $offset);
364 }
365
366 $resql = $this->db->query($sql);
367 if ($resql) {
368 $num = $this->db->num_rows($resql);
369 $i = 0;
370 while ($i < ($limit ? min($limit, $num) : $num)) {
371 $obj = $this->db->fetch_object($resql);
372
373 $record = new self($this->db);
374 $record->setVarsFromFetchObj($obj);
375
376 if (!empty($record->isextrafieldmanaged)) {
377 $record->fetch_optionals();
378 }
379
380 $records[$record->id] = $record;
381
382 $i++;
383 }
384 $this->db->free($resql);
385
386 return $records;
387 } else {
388 $this->errors[] = 'Error '.$this->db->lasterror();
389 dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
390
391 return -1;
392 }
393 }
394
402 public function update(User $user, $notrigger = 0)
403 {
404 return $this->updateCommon($user, $notrigger);
405 }
406
414 public function delete(User $user, $notrigger = 0)
415 {
416 return $this->deleteCommon($user, $notrigger);
417 //return $this->deleteCommon($user, $notrigger, 1);
418 }
419
428 public function deleteLine(User $user, $idline, $notrigger = 0)
429 {
430 if ($this->status < 0) {
431 $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus';
432 return -2;
433 }
434
435 return $this->deleteLineCommon($user, $idline, $notrigger);
436 }
437
445 public function setDraft($user, $notrigger = 0)
446 {
447 // Protection
448 if ($this->status <= self::STATUS_SUCCESS) {
449 return 0;
450 }
451
452 /* if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('webhook','write'))
453 || (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('webhook','webhook_advance','validate'))))
454 {
455 $this->error='Permission denied';
456 return -1;
457 }*/
458
459 return $this->setStatusCommon($user, self::STATUS_ERROR, $notrigger, 'WEBHOOK_MYOBJECT_UNVALIDATE');
460 }
461
469 public function cancel($user, $notrigger = 0)
470 {
471 // Protection
472 if ($this->status != self::STATUS_SUCCESS) {
473 return 0;
474 }
475
476 /* if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('webhook','write'))
477 || (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('webhook','webhook_advance','validate'))))
478 {
479 $this->error='Permission denied';
480 return -1;
481 }*/
482
483 return $this->setStatusCommon($user, self::STATUS_ERROR, $notrigger, 'WEBHOOK_MYOBJECT_CANCEL');
484 }
485
493 public function reopen($user, $notrigger = 0)
494 {
495 // Protection
496 if ($this->status == self::STATUS_SUCCESS) {
497 return 0;
498 }
499
500 /*if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('webhook','write'))
501 || (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('webhook','webhook_advance','validate'))))
502 {
503 $this->error='Permission denied';
504 return -1;
505 }*/
506
507 return $this->setStatusCommon($user, self::STATUS_SUCCESS, $notrigger, 'WEBHOOK_MYOBJECT_REOPEN');
508 }
509
517 public function getTooltipContentArray($params)
518 {
519 global $langs;
520
521 $datas = [];
522
523 if (getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER')) {
524 return ['optimize' => $langs->trans("ShowTriggerHistory")];
525 }
526 $datas['picto'] = img_picto('', $this->picto).' <u>'.$langs->trans("").'</u>';
527 $datas['picto'] .= ' '.$this->getLibStatut(5);
528 return $datas;
529 }
530
541 public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
542 {
543 global $conf, $langs, $hookmanager;
544
545 if (!empty($conf->dol_no_mouse_hover)) {
546 $notooltip = 1; // Force disable tooltips
547 }
548
549 $result = '';
550 $params = [
551 'id' => (string) $this->id,
552 'objecttype' => $this->element.($this->module ? '@'.$this->module : ''),
553 'option' => $option,
554 ];
555 $classfortooltip = 'classfortooltip';
556 $dataparams = '';
557 $label = img_picto('', $this->picto).' <u>'.$langs->trans("TriggerHistory").'</u>';
558 $label .= ' '.$this->getLibStatut(5);
559 $label .= '<br>';
560 $label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
561 $url = dol_buildpath('/webhook/triggerhistory_card.php', 1).'?id='.$this->id;
562
563 if ($option !== 'nolink') {
564 // Add param to save lastsearch_values or not
565 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
566 if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
567 $add_save_lastsearch_values = 1;
568 }
569 if ($add_save_lastsearch_values) {
570 $url .= '&save_lastsearch_values=1';
571 }
572 }
573
574 $linkclose = '';
575 if (empty($notooltip)) {
576 if (getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER')) {
577 $label = $langs->trans("ShowTriggerHistory");
578 $linkclose .= ' alt="'.dolPrintHTMLForAttribute($label).'"';
579 }
580 $linkclose .= ($label ? ' title="'.dolPrintHTMLForAttribute($label).'"' : ' title="tocomplete"');
581 $linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"';
582 } else {
583 $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
584 }
585
586 if ($option == 'nolink') {
587 $linkstart = '<span';
588 } else {
589 $linkstart = '<a href="'.$url.'"';
590 }
591 $linkstart .= $linkclose.'>';
592 if ($option == 'nolink') {
593 $linkend = '</span>';
594 } else {
595 $linkend = '</a>';
596 }
597
598 $result .= $linkstart;
599
600 if (empty($this->showphoto_on_popup)) {
601 if ($withpicto) {
602 $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1);
603 }
604 } else {
605 if ($withpicto) {
606 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
607
608 list($class, $module) = explode('@', $this->picto);
609 $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref);
610 $filearray = dol_dir_list($upload_dir, "files");
611 $filename = $filearray[0]['name'];
612 if (!empty($filename)) {
613 $pospoint = strpos($filearray[0]['name'], '.');
614
615 $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint);
616 if (!getDolGlobalString(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS')) {
617 $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>';
618 } else {
619 $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>';
620 }
621
622 $result .= '</div>';
623 } else {
624 $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"'), 0, 0, $notooltip ? 0 : 1);
625 }
626 }
627 }
628
629 if ($withpicto != 2) {
630 $result .= $this->ref;
631 }
632
633 $result .= $linkend;
634 //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
635
636 global $action, $hookmanager;
637 $hookmanager->initHooks(array($this->element.'dao'));
638 $parameters = array('id' => $this->id, 'getnomurl' => &$result);
639 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
640 if ($reshook > 0) {
641 $result = $hookmanager->resPrint;
642 } else {
643 $result .= $hookmanager->resPrint;
644 }
645
646 return $result;
647 }
648
656 public function getKanbanView($option = '', $arraydata = null)
657 {
658 global $conf, $langs;
659
660 $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
661
662 $return = '<div class="box-flex-item box-flex-grow-zero">';
663 $return .= '<div class="info-box info-box-sm">';
664 $return .= '<span class="info-box-icon bg-infobox-action">';
665 $return .= img_picto('', $this->picto);
666 $return .= '</span>';
667 $return .= '<div class="info-box-content">';
668 $return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.$this->getNomUrl().'</span>';
669 if ($selected >= 0) {
670 $return .= '<input id="cb'.$this->id.'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->id.'"'.($selected ? ' checked="checked"' : '').'>';
671 }
672 if (is_object($this->thirdparty)) {
673 $return .= '<br><div class="info-box-ref tdoverflowmax150">'.$this->thirdparty->getNomUrl(1).'</div>';
674 }
675 /*if (property_exists($this, 'amount')) {
676 $return .= '<br>';
677 $return .= '<span class="info-box-label amount">'.price($this->amount, 0, $langs, 1, -1, -1, getDolCurrency()).'</span>';
678 }*/
679 $return .= '<br><div class="info-box-status">'.$this->getLibStatut(3).'</div>';
680 $return .= '</div>';
681 $return .= '</div>';
682 $return .= '</div>';
683
684 return $return;
685 }
686
693 public function getLabelStatus($mode = 0)
694 {
695 return $this->LibStatut($this->status, $mode);
696 }
697
704 public function getLibStatut($mode = 0)
705 {
706 return $this->LibStatut($this->status, $mode);
707 }
708
709 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
717 public function LibStatut($status, $mode = 0)
718 {
719 // phpcs:enable
720 if (is_null($status)) {
721 return '';
722 }
723
724 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
725 global $langs;
726 //$langs->load("webhook@webhook");
727 $this->labelStatus[self::STATUS_SUCCESS] = $langs->transnoentitiesnoconv('Success');
728 $this->labelStatus[self::STATUS_ERROR] = $langs->transnoentitiesnoconv('Error');
729 $this->labelStatusShort[self::STATUS_SUCCESS] = $langs->transnoentitiesnoconv('Success');
730 $this->labelStatusShort[self::STATUS_ERROR] = $langs->transnoentitiesnoconv('Error');
731 }
732
733 $statusType = 'status'.$status;
734 if ($status == self::STATUS_SUCCESS) {
735 $statusType = 'status4';
736 }
737 if ($status == self::STATUS_ERROR) {
738 $statusType = 'status8';
739 }
740
741 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
742 }
743
750 public function info($id)
751 {
752 $sql = "SELECT rowid,";
753 $sql .= " date_creation as datec, tms as datem";
754 if (!empty($this->fields['date_validation'])) {
755 $sql .= ", date_validation as datev";
756 }
757 if (!empty($this->fields['fk_user_creat'])) {
758 $sql .= ", fk_user_creat";
759 }
760 if (!empty($this->fields['fk_user_modif'])) {
761 $sql .= ", fk_user_modif";
762 }
763 if (!empty($this->fields['fk_user_valid'])) {
764 $sql .= ", fk_user_valid";
765 }
766 $sql .= " FROM ".$this->db->prefix().$this->table_element." as t";
767 $sql .= " WHERE t.rowid = ".((int) $id);
768
769 $result = $this->db->query($sql);
770 if ($result) {
771 if ($this->db->num_rows($result)) {
772 $obj = $this->db->fetch_object($result);
773
774 $this->id = $obj->rowid;
775
776 if (!empty($this->fields['fk_user_creat'])) {
777 $this->user_creation_id = $obj->fk_user_creat;
778 }
779 if (!empty($this->fields['fk_user_modif'])) {
780 $this->user_modification_id = $obj->fk_user_modif;
781 }
782 if (!empty($this->fields['fk_user_valid'])) {
783 $this->user_validation_id = $obj->fk_user_valid;
784 }
785 $this->date_creation = $this->db->jdate($obj->datec);
786 $this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem);
787 if (!empty($obj->datev)) {
788 $this->date_validation = empty($obj->datev) ? '' : $this->db->jdate($obj->datev);
789 }
790 }
791
792 $this->db->free($result);
793 } else {
794 dol_print_error($this->db);
795 }
796 }
797
804 public function initAsSpecimen()
805 {
806 // Set here init that are not commonf fields
807 // $this->property1 = ...
808 // $this->property2 = ...
809
810 return $this->initAsSpecimenCommon();
811 }
812
818 public function getLinesArray()
819 {
820 $this->lines = array();
821
822 $objectline = new HistoryLine($this->db);
823 $result = $objectline->fetchAll('ASC', 'position', 0, 0, '(fk_history:=:'.((int) $this->id).')');
824
825 if (is_numeric($result)) {
826 $this->setErrorsFromObject($objectline);
827 return $result;
828 } else {
829 $this->lines = $result;
830 return $this->lines;
831 }
832 }
833
843 public function validateField($fields, $fieldKey, $fieldValue)
844 {
845 // Add your own validation rules here.
846 // ...
847
848 return parent::validateField($fields, $fieldKey, $fieldValue);
849 }
850
858 public function doScheduledJob()
859 {
860 //global $conf, $langs;
861
862 //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlogfile.log';
863
864 $error = 0;
865 $this->output = '';
866 $this->error = '';
867
868 dol_syslog(__METHOD__." start", LOG_INFO);
869
870 $now = dol_now();
871
872 $this->db->begin();
873
874 // ...
875
876 $this->db->commit();
877
878 dol_syslog(__METHOD__." end", LOG_INFO);
879
880 return $error;
881 }
882}
883
884
885require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
886
891{
892 // To complete with content of an object HistoryLine
893 // We should have a field rowid, fk_history and position
894
899 public $parent_element = ''; // Example: '' or 'triggerhistory'
900
905 public $fk_parent_attribute = ''; // Example: '' or 'fk_history'
906
912 public function __construct(DoliDB $db)
913 {
914 $this->db = $db;
915
916 $this->isextrafieldmanaged = 0;
917 }
918}
$object ref
Definition info.php:90
Parent class of all other business classes (invoices, contracts, proposals, orders,...
deleteLineCommon(User $user, $idline, $notrigger=0)
Delete a line of object in database.
setErrorsFromObject($object)
setErrorsFromObject
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.
fetchLinesCommon($morewhere='', $noextrafields=0)
Load object in memory from the database.
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.
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
Class to manage Dolibarr database access.
Class HistoryLine.
$parent_element
To overload.
$fk_parent_attribute
To overload.
__construct(DoliDB $db)
Constructor.
doScheduledJob()
Action executed by scheduler CAN BE A CRON TASK.
initAsSpecimen()
Initialize object with example values Id must be 0 if object instance is a specimen.
cancel($user, $notrigger=0)
Set cancel status.
$fields
'type' field format: 'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortf...
getLinesArray()
Create an array of lines.
getTooltipContentArray($params)
getTooltipContentArray
LibStatut($status, $mode=0)
Return the label of a given status.
getLabelStatus($mode=0)
Return the label of the status.
getKanbanView($option='', $arraydata=null)
Return a thumb for kanban views.
__construct(DoliDB $db)
Constructor.
fetch($id, $ref=null, $noextrafields=0, $nolines=0)
Load object in memory from the database.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionally the picto)
update(User $user, $notrigger=0)
Update object into database.
reopen($user, $notrigger=0)
Set back to validated status.
fetchAll($sortorder='', $sortfield='', $limit=1000, $offset=0, string $filter='', $filtermode='AND')
Load list of objects in memory from the database.
deleteLine(User $user, $idline, $notrigger=0)
Delete a line of object in database.
getLibStatut($mode=0)
Return the label of the status.
setDraft($user, $notrigger=0)
Set draft status.
create(User $user, $notrigger=0)
Create object into database.
validateField($fields, $fieldKey, $fieldValue)
Return validation test result for a field.
fetchLines($noextrafields=0)
Load object lines in memory from the database.
info($id)
Load the info information in the object.
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:171
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:64
dol_now($mode='gmt')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.