Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ticket_List_Color_by_Category #16948

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/ITILCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ public function getAdditionalFields()
'type' => 'bool',
'list' => true,
],
[
'name' => 'color',
'label' => __('Color'),
'type' => 'color',
],

];

$show_for_problem = Session::haveRightsOr('problem', [CREATE, UPDATE, DELETE, Problem::READALL, Problem::READMY]);
Expand Down
100 changes: 88 additions & 12 deletions src/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ class Search
**/
public static function show($itemtype)
{
global $ticketcolor;
$ticketcolor = $itemtype;



$params = self::manageParams($itemtype, $_GET);
echo "<div class='search_page row'>";
Expand Down Expand Up @@ -8718,13 +8722,14 @@ public static function showHeaderItem(
**/
public static function showItem($type, $value, &$num, $row, $extraparam = '')
{


global $ticketcolor;
$out = "";
// Handle null values
if ($value === null) {
$value = '';
}

switch ($type) {
case self::PDF_OUTPUT_LANDSCAPE: //pdf
case self::PDF_OUTPUT_PORTRAIT:
Expand All @@ -8737,9 +8742,9 @@ public static function showItem($type, $value, &$num, $row, $extraparam = '')
$PDF_TABLE .= "<td $extraparam valign='top'>";
$PDF_TABLE .= $value;
$PDF_TABLE .= "</td>";

break;

case self::SYLK_OUTPUT: //sylk
/**
* @var array $SYLK_ARRAY
Expand All @@ -8755,14 +8760,14 @@ public static function showItem($type, $value, &$num, $row, $extraparam = '')
Toolbox::strlen($SYLK_ARRAY[$row][$num])
);
break;

case self::CSV_OUTPUT: //csv
$value = DataExport::normalizeValueForTextExport($value);
$value = preg_replace('/' . self::LBBR . '/', '<br>', $value);
$value = preg_replace('/' . self::LBHR . '/', '<hr>', $value);
$out = "\"" . self::csv_clean($value) . "\"" . $_SESSION["glpicsv_delimiter"];
break;

case self::NAMES_OUTPUT:
// We only want to display one column (the name of the item).
// The name field is always the first column expect for tickets
Expand All @@ -8787,32 +8792,44 @@ public static function showItem($type, $value, &$num, $row, $extraparam = '')
}
}
break;

default:
/** @var array $CFG_GLPI */
global $CFG_GLPI;
$out = "<td $extraparam valign='top'>";


//Abfrage nach der Tickettabelle
if($_GET["itemtype"]== "Ticket" || $ticketcolor == "Ticket" )
{






if (!preg_match('/' . self::LBHR . '/', $value)) {
$values = preg_split('/' . self::LBBR . '/i', $value);
$line_delimiter = '<br>';

} else {
$values = preg_split('/' . self::LBHR . '/i', $value);
$line_delimiter = '<hr>';
}



if (
count($values) > 1
&& Toolbox::strlen($value) > $CFG_GLPI['cut']
) {
$value = '';
foreach ($values as $v) {
$value .= $v . $line_delimiter;


}
$value = preg_replace('/' . self::LBBR . '/', '<br>', $value);
$value = preg_replace('/' . self::LBHR . '/', '<hr>', $value);
$value = '<div class="fup-popup">' . $value . '</div>';
$valTip = ' ' . Html::showToolTip(
$valTip = "&nbsp;" . Html::showToolTip(
$value,
[
'awesome-class' => 'fa-comments',
Expand All @@ -8821,17 +8838,76 @@ public static function showItem($type, $value, &$num, $row, $extraparam = '')
'onclick' => true
]
);

$out .= $values[0] . $valTip;
} else {
$value = preg_replace('/' . self::LBBR . '/', '<br>', $value);
$value = preg_replace('/' . self::LBHR . '/', '<hr>', $value);
$out .= $value;
}
$out .= "</td>\n";





}
else
{
$out = "<td $extraparam valign='top'>";


if (!preg_match('/' . self::LBHR . '/', $value)) {
$values = preg_split('/' . self::LBBR . '/i', $value);
$line_delimiter = '<br>';

} else {
$values = preg_split('/' . self::LBHR . '/i', $value);
$line_delimiter = '<hr>';
}


if (
count($values) > 1
&& Toolbox::strlen($value) > $CFG_GLPI['cut']
) {
$value = '';
foreach ($values as $v) {
$value .= $v . $line_delimiter;


}
$value = preg_replace('/' . self::LBBR . '/', '<br>', $value);
$value = preg_replace('/' . self::LBHR . '/', '<hr>', $value);
$value = '<div class="fup-popup">' . $value . '</div>';
$valTip = "&nbsp;" . Html::showToolTip(
$value,
[
'awesome-class' => 'fa-comments',
'display' => false,
'autoclose' => false,
'onclick' => true
]
);

$out .= $values[0] . $valTip;
} else {
$value = preg_replace('/' . self::LBBR . '/', '<br>', $value);
$value = preg_replace('/' . self::LBHR . '/', '<hr>', $value);
$out .= $value;
}

}
$out .= "</td>\n";


}
$num++;

return $out;

}




/**
Expand Down
10 changes: 10 additions & 0 deletions src/Ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -3157,6 +3157,16 @@ public function rawSearchOptions()
'computation' => self::generateSLAOLAComputation('internal_time_to_own')
];


$tab[] = [
'id' => '15',
'table' => 'glpi_itilcategories',
'field' => 'color',
'name' => __('Color'),
'datatype' => 'color'
];


$max_date = '99999999';
$tab[] = [
'id' => '188',
Expand Down
Loading
Loading