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);
282 $this->errors =
$object->errors;
294 if (property_exists($this,
'fk_soc') && $this->fk_soc ==
$object->socid) {
301 unset(
$object->context[
'createfromclone']);
308 $this->db->rollback();
320 public function fetch($id, $ref =
null)
323 if ($result > 0 && !empty($this->table_element_line)) {
336 $this->lines = array();
355 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, $filter =
'', $filtermode =
'AND')
363 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
364 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
365 $sql .=
' WHERE t.entity IN ('.getEntity($this->element).
')';
367 $sql .=
' WHERE 1 = 1';
374 $this->errors[] = $errormessage;
375 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
379 if (!empty($sortfield)) {
380 $sql .= $this->db->order($sortfield, $sortorder);
382 if (!empty($limit)) {
383 $sql .= $this->db->plimit($limit, $offset);
386 $resql = $this->db->query($sql);
388 $num = $this->db->num_rows($resql);
390 while ($i < ($limit ? min($limit, $num) : $num)) {
391 $obj = $this->db->fetch_object($resql);
393 $record =
new self($this->db);
394 $record->setVarsFromFetchObj($obj);
396 $records[$record->id] = $record;
400 $this->db->free($resql);
404 $this->errors[] =
'Error '.$this->db->lasterror();
405 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
430 public function delete(
User $user, $notrigger = 0)
447 $this->error =
'ErrorDeleteLineNotAllowedByObjectStatus';
465 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
467 global $conf, $langs, $hookmanager;
469 if (!empty($conf->dol_no_mouse_hover)) {
487 if ($option !=
'nolink') {
489 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
490 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
491 $add_save_lastsearch_values = 1;
493 if ($add_save_lastsearch_values) {
494 $url .=
'&save_lastsearch_values=1';
499 if (empty($notooltip)) {
501 $label = $langs->trans(
"ShowMyObject");
502 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
504 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
505 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
507 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
510 if ($option ==
'nolink') {
511 $linkstart =
'<span';
513 $linkstart =
'<a href="'.$url.
'"';
515 $linkstart .= $linkclose.
'>';
516 if ($option ==
'nolink') {
517 $linkend =
'</span>';
523 $result .= $this->label;
526 global $action, $hookmanager;
527 $hookmanager->initHooks(array(
'cticketcategorydao'));
528 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
529 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
531 $result = $hookmanager->resPrint;
533 $result .= $hookmanager->resPrint;
561 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
564 $this->labelStatus[self::STATUS_ENABLED] = $langs->transnoentitiesnoconv(
'Enabled');
565 $this->labelStatus[self::STATUS_DISABLED] = $langs->transnoentitiesnoconv(
'Disabled');
566 $this->labelStatusShort[self::STATUS_ENABLED] = $langs->transnoentitiesnoconv(
'Enabled');
567 $this->labelStatusShort[self::STATUS_DISABLED] = $langs->transnoentitiesnoconv(
'Disabled');
570 $statusType =
'status'.$status;
572 if ($status == self::STATUS_DISABLED) {
573 $statusType =
'status6';
576 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
587 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
588 $sql .=
' fk_user_creat, fk_user_modif';
589 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
590 $sql .=
' WHERE t.rowid = '.((int) $id);
591 $result = $this->db->query($sql);
593 if ($this->db->num_rows($result)) {
594 $obj = $this->db->fetch_object($result);
596 $this->
id = $obj->rowid;
598 $this->user_creation_id = $obj->fk_user_creat;
599 $this->user_modification_id = $obj->fk_user_modif;
600 $this->date_creation = $this->db->jdate($obj->datec);
601 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
604 $this->db->free($result);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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.
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...
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 a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.