26require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
36 public $element =
'hook';
41 public $table_element =
'zapier_hook';
46 public $picto =
'hook@zapier';
49 const STATUS_DRAFT = 0;
50 const STATUS_VALIDATED = 1;
51 const STATUS_DISABLED = -1;
77 public $fields = array(
80 'label' =>
'TechnicalID',
101 'label' =>
'UserOwner',
106 'foreignkey' =>
'llx_user.rowid',
109 'type' =>
'varchar(255)',
115 'css' =>
'minwidth200',
119 'type' =>
'varchar(128)',
125 'css' =>
'minwidth200',
126 'help' =>
'Hook module'
129 'type' =>
'varchar(128)',
135 'css' =>
'minwidth200',
136 'help' =>
'Hook action trigger'
139 'type' =>
'varchar(255)',
145 'css' =>
'minwidth200',
147 'showoncombobox' => 1,
149 'date_creation' => array(
150 'type' =>
'datetime',
151 'label' =>
'DateCreation',
157 'import_key' => array(
158 'type' =>
'varchar(14)',
159 'label' =>
'ImportId',
175 'arrayofkeyval' => array(
216 public $fk_user_creat;
221 public $fk_user_modif;
240 $this->ismultientitymanaged = 0;
241 $this->isextrafieldmanaged = 1;
244 $this->fields[
'rowid'][
'visible'] = 0;
246 if (!
isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
247 $this->fields[
'entity'][
'enabled'] = 0;
251 foreach ($this->fields as $key => $val) {
252 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
253 unset($this->fields[$key]);
258 if (is_object($langs)) {
259 foreach ($this->fields as $key => $val) {
260 if (is_array($this->fields[
'status'][
'arrayofkeyval'])) {
261 foreach ($this->fields[
'status'][
'arrayofkeyval'] as $key2 => $val2) {
262 $this->fields[
'status'][
'arrayofkeyval'][$key2] = $langs->trans($val2);
290 global $langs, $extrafields;
307 $object->ref =
"copy_of_".$object->ref;
311 if (is_array(
$object->array_options) && count(
$object->array_options) > 0) {
312 $extrafields->fetch_name_optionals_label($this->table_element);
313 foreach (
$object->array_options as $key => $option) {
314 $shortkey = preg_replace(
'/options_/',
'', $key);
315 if (!empty($extrafields->attributes[$this->table_element][
'unique'][$shortkey])) {
319 unset(
$object->array_options[$key]);
325 $object->context[
'createfromclone'] =
'createfromclone';
326 $result =
$object->createCommon($user);
332 unset(
$object->context[
'createfromclone']);
339 $this->db->rollback();
351 public function fetch($id, $ref =
null)
370 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, $filter =
'', $filtermode =
'AND')
381 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
382 $sql .=
' WHERE t.entity = '.((int)
$conf->entity);
388 $this->errors[] = $errormessage;
389 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
393 if (!empty($sortfield)) {
394 $sql .= $this->db->order($sortfield, $sortorder);
396 if (!empty($limit)) {
397 $sql .= $this->db->plimit($limit, $offset);
400 $resql = $this->db->query($sql);
402 $num = $this->db->num_rows($resql);
404 while ($obj = $this->db->fetch_object($resql)) {
405 $record =
new self($this->db);
407 $record->id = $obj->rowid;
411 $records[$record->id] = $record;
413 $this->db->free($resql);
417 $this->errors[] =
'Error '.$this->db->lasterror();
418 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
443 public function delete(
User $user, $notrigger = 0)
459 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
461 global $db,
$conf, $langs, $hookmanager, $action;
462 global $dolibarr_main_authentication, $dolibarr_main_demo;
465 if (!empty(
$conf->dol_no_mouse_hover)) {
472 $label =
'<u>'.$langs->trans(
"Hook").
'</u>';
474 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
476 $url = DOL_URL_ROOT.
'/zapier/hook_card.php?id='.$this->id;
478 if ($option !=
'nolink') {
480 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
481 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
482 $add_save_lastsearch_values = 1;
484 if ($add_save_lastsearch_values) {
485 $url .=
'&save_lastsearch_values=1';
490 if (empty($notooltip)) {
492 $label = $langs->trans(
"ShowMyObject");
493 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label).
'"';
495 $linkclose .=
' title="'.dolPrintHTMLForAttribute($label).
'"';
496 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
498 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
501 $linkstart =
'<a href="'.$url.
'"';
502 $linkstart .= $linkclose.
'>';
505 $result .= $linkstart;
507 $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);
509 if ($withpicto != 2) {
510 $result .= $this->ref;
515 $hookmanager->initHooks(array(
'hookdao'));
518 'getnomurl' => &$result,
521 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
523 $result = $hookmanager->resPrint;
525 $result .= $hookmanager->resPrint;
561 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
564 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Disabled');
565 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Enabled');
566 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Disabled');
567 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Enabled');
570 $statusType =
'status5';
571 if ($status == self::STATUS_VALIDATED) {
572 $statusType =
'status4';
575 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
586 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
587 $sql .=
' fk_user_creat, fk_user_modif';
588 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
589 $sql .=
' WHERE t.rowid = '.((int) $id);
590 $result = $this->db->query($sql);
592 if ($this->db->num_rows($result)) {
593 $obj = $this->db->fetch_object($result);
595 $this->
id = $obj->rowid;
597 $this->user_creation_id = $obj->fk_user_creat;
598 $this->user_modification_id = $obj->fk_user_modif;
599 $this->date_creation = $this->db->jdate($obj->datec);
600 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
603 $this->db->free($result);
605 dol_print_error($this->db);
if(! $sortfield) if(! $sortorder) $object
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
setErrorsFromObject($object)
setErrorsFromObject
createCommon(User $user, $notrigger=0)
Create object in the database.
updateCommon(User $user, $notrigger=0)
Update object into database.
initAsSpecimenCommon()
Initialise object with example values Id must be 0 if object instance is a specimen.
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.
Class to manage Dolibarr database access.
info($id)
Load the info information in the object.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
__construct(DoliDB $db)
Constructor.
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, $filter='', $filtermode='AND')
Load list of objects 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)
fetch($id, $ref=null)
Load object in memory from the database.
getLibStatut($mode=0)
Return label of the status.
create(User $user, $notrigger=0)
Create object into database.
update(User $user, $notrigger=0)
Update object into database.
createFromClone(User $user, $fromid)
Clone an object into another one.
LibStatut($status, $mode=0)
Return the status.
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...
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0, $forbiddenfields=array())
forgeSQLFromUniversalSearchCriteria
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.