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(
221 public $fk_user_creat;
226 public $fk_user_modif;
241 global $conf, $langs, $user;
245 $this->ismultientitymanaged = 0;
246 $this->isextrafieldmanaged = 1;
249 $this->fields[
'rowid'][
'visible'] = 0;
251 if (!isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
252 $this->fields[
'entity'][
'enabled'] = 0;
256 foreach ($this->fields as $key => $val) {
257 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
258 unset($this->fields[$key]);
263 foreach ($this->fields as $key => $val) {
264 if (is_array($this->fields[
'status'][
'arrayofkeyval'])) {
265 foreach ($this->fields[
'status'][
'arrayofkeyval'] as $key2 => $val2) {
266 $this->fields[
'status'][
'arrayofkeyval'][$key2] = $langs->trans($val2);
293 global $langs, $hookmanager, $extrafields;
310 $object->ref =
"copy_of_".$object->ref;
314 if (is_array(
$object->array_options) && count(
$object->array_options) > 0) {
315 $extrafields->fetch_name_optionals_label($this->table_element);
316 foreach (
$object->array_options as $key => $option) {
317 $shortkey = preg_replace(
'/options_/',
'', $key);
318 if (!empty($extrafields->attributes[$this->table_element][
'unique'][$shortkey])) {
322 unset(
$object->array_options[$key]);
328 $object->context[
'createfromclone'] =
'createfromclone';
329 $result =
$object->createCommon($user);
333 $this->errors =
$object->errors;
336 unset(
$object->context[
'createfromclone']);
343 $this->db->rollback();
355 public function fetch($id, $ref =
null)
374 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, $filter =
'', $filtermode =
'AND')
385 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
386 $sql .=
' WHERE t.entity = '.((int) $conf->entity);
392 $this->errors[] = $errormessage;
393 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
397 if (!empty($sortfield)) {
398 $sql .= $this->db->order($sortfield, $sortorder);
400 if (!empty($limit)) {
401 $sql .= $this->db->plimit($limit, $offset);
404 $resql = $this->db->query($sql);
406 $num = $this->db->num_rows($resql);
408 while ($obj = $this->db->fetch_object($resql)) {
409 $record =
new self($this->db);
411 $record->id = $obj->rowid;
415 $records[$record->id] = $record;
417 $this->db->free($resql);
421 $this->errors[] =
'Error '.$this->db->lasterror();
422 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
447 public function delete(
User $user, $notrigger = 0)
463 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
465 global $db, $conf, $langs, $hookmanager, $action;
466 global $dolibarr_main_authentication, $dolibarr_main_demo;
469 if (!empty($conf->dol_no_mouse_hover)) {
476 $label =
'<u>'.$langs->trans(
"Hook").
'</u>';
478 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
480 $url = DOL_URL_ROOT.
'/zapier/hook_card.php?id='.$this->id;
482 if ($option !=
'nolink') {
484 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
485 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
486 $add_save_lastsearch_values = 1;
488 if ($add_save_lastsearch_values) {
489 $url .=
'&save_lastsearch_values=1';
494 if (empty($notooltip)) {
496 $label = $langs->trans(
"ShowMyObject");
497 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
499 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
500 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
502 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
505 $linkstart =
'<a href="'.$url.
'"';
506 $linkstart .= $linkclose.
'>';
509 $result .= $linkstart;
511 $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);
513 if ($withpicto != 2) {
514 $result .= $this->ref;
519 $hookmanager->initHooks(array(
'hookdao'));
522 'getnomurl' => &$result,
525 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
527 $result = $hookmanager->resPrint;
529 $result .= $hookmanager->resPrint;
565 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
568 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Disabled');
569 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Enabled');
570 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Disabled');
571 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Enabled');
574 $statusType =
'status5';
575 if ($status == self::STATUS_VALIDATED) {
576 $statusType =
'status4';
579 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
590 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
591 $sql .=
' fk_user_creat, fk_user_modif';
592 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
593 $sql .=
' WHERE t.rowid = '.((int) $id);
594 $result = $this->db->query($sql);
596 if ($this->db->num_rows($result)) {
597 $obj = $this->db->fetch_object($result);
599 $this->
id = $obj->rowid;
601 $this->user_creation_id = $obj->fk_user_creat;
602 $this->user_modification_id = $obj->fk_user_modif;
603 $this->date_creation = $this->db->jdate($obj->datec);
604 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
607 $this->db->free($result);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Parent class of all other business classes (invoices, contracts, proposals, orders,...
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...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
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.