28require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
40 public $module =
'ticket';
45 public $element =
'cticketcategory';
50 public $table_element =
'c_ticket_category';
55 public $picto =
'ticket';
58 const STATUS_DISABLED = 0;
59 const STATUS_ENABLED = 1;
92 public $fields = array(
93 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 10),
94 'entity' => array(
'type' =>
'integer',
'label' =>
'Entity',
'default' =>
'1',
'enabled' => 1,
'visible' => -2,
'position' => 15,
'index' => 1),
95 'code' => array(
'type' =>
'varchar(32)',
'label' =>
'Code',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 20),
96 'pos' => array(
'type' =>
'integer',
'label' =>
'Pos',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 25),
97 'label' => array(
'type' =>
'varchar(128)',
'label' =>
'Label',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 30,
'showoncombobox' => 1),
98 'active' => array(
'type' =>
'integer',
'label' =>
'Active',
'enabled' => 1,
'visible' => -1,
'position' => 35),
99 'use_default' => array(
'type' =>
'integer',
'label' =>
'Usedefault',
'enabled' => 1,
'visible' => -1,
'position' => 40),
100 'description' => array(
'type' =>
'varchar(255)',
'label' =>
'Description',
'enabled' => 1,
'visible' => -1,
'position' => 45),
101 'fk_parent' => array(
'type' =>
'integer',
'label' =>
'Fkparent',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 50),
102 'force_severity' => array(
'type' =>
'varchar(32)',
'label' =>
'Forceseverity',
'enabled' => 1,
'visible' => -1,
'position' => 55),
103 'public' => array(
'type' =>
'integer',
'label' =>
'Public',
'enabled' => 1,
'visible' => -1,
'position' => 60),
139 public $date_creation;
144 public $fk_user_creat;
149 public $fk_user_modif;
154 public $last_main_doc;
171 global $conf, $langs;
175 $this->ismultientitymanaged = 0;
176 $this->isextrafieldmanaged = 0;
179 $this->fields[
'rowid'][
'visible'] = 0;
181 if (!isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
182 $this->fields[
'entity'][
'enabled'] = 0;
186 foreach ($this->fields as $key => $val) {
187 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
188 unset($this->fields[$key]);
193 if (is_object($langs)) {
194 foreach ($this->fields as $key => $val) {
195 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
196 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
197 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
217 return $resultcreate;
229 global $langs, $extrafields;
239 $result =
$object->fetchCommon($fromid);
240 if ($result > 0 && !empty(
$object->table_element_line)) {
254 if (property_exists(
$object,
'ref')) {
255 $object->ref = empty($this->fields[
'ref'][
'default']) ?
"Copy_Of_".$object->ref : $this->fields[
'ref'][
'default'];
257 if (property_exists(
$object,
'label')) {
258 $object->label = empty($this->fields[
'label'][
'default']) ? $langs->trans(
"CopyOf").
" ".
$object->label : $this->fields[
'label'][
'default'];
260 if (property_exists(
$object,
'date_creation')) {
263 if (property_exists(
$object,
'date_modification')) {
264 $object->date_modification =
null;
268 if (is_array(
$object->array_options) && count(
$object->array_options) > 0) {
269 $extrafields->fetch_name_optionals_label($this->table_element);
270 foreach (
$object->array_options as $key => $option) {
271 $shortkey = preg_replace(
'/options_/',
'', $key);
272 if (!empty($extrafields->attributes[$this->table_element][
'unique'][$shortkey])) {
275 unset(
$object->array_options[$key]);
281 $object->context[
'createfromclone'] =
'createfromclone';
282 $result =
$object->createCommon($user);
286 $this->errors =
$object->errors;
298 if (property_exists($this,
'fk_soc') && $this->fk_soc ==
$object->socid) {
305 unset(
$object->context[
'createfromclone']);
312 $this->db->rollback();
324 public function fetch($id, $ref =
null)
327 if ($result > 0 && !empty($this->table_element_line)) {
340 $this->lines = array();
359 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, $filter =
'', $filtermode =
'AND')
367 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
368 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
369 $sql .=
' WHERE t.entity IN ('.getEntity($this->element).
')';
371 $sql .=
' WHERE 1 = 1';
378 $this->errors[] = $errormessage;
379 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
383 if (!empty($sortfield)) {
384 $sql .= $this->db->order($sortfield, $sortorder);
386 if (!empty($limit)) {
387 $sql .= $this->db->plimit($limit, $offset);
390 $resql = $this->db->query($sql);
392 $num = $this->db->num_rows($resql);
394 while ($i < ($limit ? min($limit, $num) : $num)) {
395 $obj = $this->db->fetch_object($resql);
397 $record =
new self($this->db);
398 $record->setVarsFromFetchObj($obj);
400 $records[$record->id] = $record;
404 $this->db->free($resql);
408 $this->errors[] =
'Error '.$this->db->lasterror();
409 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
434 public function delete(
User $user, $notrigger = 0)
451 $this->error =
'ErrorDeleteLineNotAllowedByObjectStatus';
469 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
471 global $conf, $langs, $hookmanager;
473 if (!empty($conf->dol_no_mouse_hover)) {
491 if ($option !=
'nolink') {
493 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
494 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
495 $add_save_lastsearch_values = 1;
497 if ($add_save_lastsearch_values) {
498 $url .=
'&save_lastsearch_values=1';
503 if (empty($notooltip)) {
505 $label = $langs->trans(
"ShowMyObject");
506 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
508 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
509 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
511 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
514 if ($option ==
'nolink') {
515 $linkstart =
'<span';
517 $linkstart =
'<a href="'.$url.
'"';
519 $linkstart .= $linkclose.
'>';
520 if ($option ==
'nolink') {
521 $linkend =
'</span>';
527 $result .= $this->label;
530 global $action, $hookmanager;
531 $hookmanager->initHooks(array(
'cticketcategorydao'));
532 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
533 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
535 $result = $hookmanager->resPrint;
537 $result .= $hookmanager->resPrint;
565 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
568 $this->labelStatus[self::STATUS_ENABLED] = $langs->transnoentitiesnoconv(
'Enabled');
569 $this->labelStatus[self::STATUS_DISABLED] = $langs->transnoentitiesnoconv(
'Disabled');
570 $this->labelStatusShort[self::STATUS_ENABLED] = $langs->transnoentitiesnoconv(
'Enabled');
571 $this->labelStatusShort[self::STATUS_DISABLED] = $langs->transnoentitiesnoconv(
'Disabled');
574 $statusType =
'status'.$status;
576 if ($status == self::STATUS_DISABLED) {
577 $statusType =
'status6';
580 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
591 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
592 $sql .=
' fk_user_creat, fk_user_modif';
593 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
594 $sql .=
' WHERE t.rowid = '.((int) $id);
595 $result = $this->db->query($sql);
597 if ($this->db->num_rows($result)) {
598 $obj = $this->db->fetch_object($result);
600 $this->
id = $obj->rowid;
602 $this->user_creation_id = $obj->fk_user_creat;
603 $this->user_modification_id = $obj->fk_user_modif;
604 $this->date_creation = $this->db->jdate($obj->datec);
605 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
608 $this->db->free($result);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Or an array listing all the potential status of the object: array: int of the status => translated la...
deleteLine(User $user, $idline, $notrigger=0)
Delete a line of object in database.
info($id)
Load the info information in the object.
createFromClone(User $user, $fromid)
Clone an object into another one.
update(User $user, $notrigger=0)
Update object into database.
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, $filter='', $filtermode='AND')
Load list of objects in memory from the database.
getLibStatut($mode=0)
Return the label of the status.
LibStatut($status, $mode=0)
Return the status.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
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.
create(User $user, $notrigger=0)
Create object into database.
__construct(DoliDB $db)
Constructor.
fetchLines()
Load object lines in memory from the database.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
deleteLineCommon(User $user, $idline, $notrigger=0)
Delete a line of object in database.
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.
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.
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.
Class to manage Dolibarr database access.
Class to manage Dolibarr users.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
dol_now($mode='auto')
Return date for now.
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 dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.