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 $fk_user_creat;
144 public $fk_user_modif;
149 public $last_main_doc;
166 global $conf, $langs;
170 $this->ismultientitymanaged = 0;
171 $this->isextrafieldmanaged = 0;
174 $this->fields[
'rowid'][
'visible'] = 0;
176 if (!
isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
177 $this->fields[
'entity'][
'enabled'] = 0;
181 foreach ($this->fields as $key => $val) {
182 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
183 unset($this->fields[$key]);
188 if (is_object($langs)) {
189 foreach ($this->fields as $key => $val) {
190 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
191 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
192 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
212 return $resultcreate;
224 global $langs, $extrafields;
234 $result =
$object->fetchCommon($fromid);
235 if ($result > 0 && !empty(
$object->table_element_line)) {
249 if (property_exists(
$object,
'ref')) {
250 $object->ref = empty($this->fields[
'ref'][
'default']) ?
"Copy_Of_".$object->ref : $this->fields[
'ref'][
'default'];
252 if (property_exists(
$object,
'label')) {
254 $object->label = empty($this->fields[
'label'][
'default']) ? $langs->trans(
"CopyOf").
" ".
$object->label : $this->fields[
'label'][
'default'];
256 if (property_exists(
$object,
'date_creation')) {
259 if (property_exists(
$object,
'date_modification')) {
260 $object->date_modification =
null;
264 if (is_array(
$object->array_options) && count(
$object->array_options) > 0) {
265 $extrafields->fetch_name_optionals_label($this->table_element);
266 foreach (
$object->array_options as $key => $option) {
267 $shortkey = preg_replace(
'/options_/',
'', $key);
268 if (!empty($extrafields->attributes[$this->table_element][
'unique'][$shortkey])) {
271 unset(
$object->array_options[$key]);
277 $object->context[
'createfromclone'] =
'createfromclone';
278 $result =
$object->createCommon($user);
293 if (property_exists($this,
'fk_soc') && $this->fk_soc ==
$object->socid) {
300 unset(
$object->context[
'createfromclone']);
307 $this->db->rollback();
319 public function fetch($id, $ref =
null)
322 if ($result > 0 && !empty($this->table_element_line)) {
335 $this->lines = array();
354 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, $filter =
'', $filtermode =
'AND')
362 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
363 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
364 $sql .=
' WHERE t.entity IN ('.getEntity($this->element).
')';
366 $sql .=
' WHERE 1 = 1';
373 $this->errors[] = $errormessage;
374 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
378 if (!empty($sortfield)) {
379 $sql .= $this->db->order($sortfield, $sortorder);
381 if (!empty($limit)) {
382 $sql .= $this->db->plimit($limit, $offset);
385 $resql = $this->db->query($sql);
387 $num = $this->db->num_rows($resql);
389 while ($i < ($limit ? min($limit, $num) : $num)) {
390 $obj = $this->db->fetch_object($resql);
392 $record =
new self($this->db);
393 $record->setVarsFromFetchObj($obj);
395 $records[$record->id] = $record;
399 $this->db->free($resql);
403 $this->errors[] =
'Error '.$this->db->lasterror();
404 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
429 public function delete(
User $user, $notrigger = 0)
446 $this->error =
'ErrorDeleteLineNotAllowedByObjectStatus';
464 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
466 global $conf, $langs, $hookmanager;
468 if (!empty($conf->dol_no_mouse_hover)) {
485 if ($option !=
'nolink') {
487 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
488 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
489 $add_save_lastsearch_values = 1;
491 if ($add_save_lastsearch_values) {
492 $url .=
'&save_lastsearch_values=1';
497 if (empty($notooltip)) {
499 $label = $langs->trans(
"ShowMyObject");
500 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label).
'"';
502 $linkclose .=
' title="'.dolPrintHTMLForAttribute($label).
'"';
503 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
505 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
508 if ($option ==
'nolink') {
509 $linkstart =
'<span';
511 $linkstart =
'<a href="'.$url.
'"';
513 $linkstart .= $linkclose.
'>';
514 if ($option ==
'nolink') {
515 $linkend =
'</span>';
521 $result .= $this->label;
524 global $action, $hookmanager;
525 $hookmanager->initHooks(array(
'cticketcategorydao'));
526 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
527 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
529 $result = $hookmanager->resPrint;
531 $result .= $hookmanager->resPrint;
559 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
562 $this->labelStatus[self::STATUS_ENABLED] = $langs->transnoentitiesnoconv(
'Enabled');
563 $this->labelStatus[self::STATUS_DISABLED] = $langs->transnoentitiesnoconv(
'Disabled');
564 $this->labelStatusShort[self::STATUS_ENABLED] = $langs->transnoentitiesnoconv(
'Enabled');
565 $this->labelStatusShort[self::STATUS_DISABLED] = $langs->transnoentitiesnoconv(
'Disabled');
568 $statusType =
'status'.$status;
570 if ($status == self::STATUS_DISABLED) {
571 $statusType =
'status6';
574 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
585 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
586 $sql .=
' fk_user_creat, fk_user_modif';
587 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
588 $sql .=
' WHERE t.rowid = '.((int) $id);
589 $result = $this->db->query($sql);
591 if ($this->db->num_rows($result)) {
592 $obj = $this->db->fetch_object($result);
594 $this->
id = $obj->rowid;
596 $this->user_creation_id = $obj->fk_user_creat;
597 $this->user_modification_id = $obj->fk_user_modif;
598 $this->date_creation = $this->db->jdate($obj->datec);
599 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
602 $this->db->free($result);
if(! $sortfield) if(! $sortorder) $object
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.
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.
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.
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...
dol_now($mode='gmt')
Return date for now.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
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.