static function showHelpdeskOptions(Entity $entity)
{
global $CFG_GLPI;
$ID = $entity->getField('id');
if (!$entity->can($ID, READ) || !Session::haveRightsOr(self::$rightname, array(self::READHELPDESK, self::UPDATEHELPDESK))) {
return false;
}
$canedit = Session::haveRight(self::$rightname, self::UPDATEHELPDESK) && Session::haveAccessToEntity($ID);
echo "<div class='spaced'>";
if ($canedit) {
echo "<form method='post' name=form action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
}
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'><td colspan='2'>" . _n('Ticket template', 'Ticket templates', 1) . "</td>";
echo "<td colspan='2'>";
$toadd = array();
if ($ID != 0) {
$toadd = array(self::CONFIG_PARENT => __('Inheritance of the parent entity'));
}
$options = array('value' => $entity->fields["tickettemplates_id"], 'entity' => $ID, 'toadd' => $toadd);
TicketTemplate::dropdown($options);
if ($entity->fields["tickettemplates_id"] == self::CONFIG_PARENT && $ID != 0) {
echo "<font class='green'> ";
$tt = new TicketTemplate();
$tid = self::getUsedConfig('tickettemplates_id', $ID, '', 0);
if (!$tid) {
echo Dropdown::EMPTY_VALUE;
} else {
if ($tt->getFromDB($tid)) {
echo $tt->getLink();
}
}
echo "</font>";
}
echo "</td></tr>";
echo "<tr class='tab_bg_1'><td colspan='2'>" . __('Calendar') . "</td>";
echo "<td colspan='2'>";
$options = array('value' => $entity->fields["calendars_id"], 'emptylabel' => __('24/7'));
if ($ID != 0) {
$options['toadd'] = array(self::CONFIG_PARENT => __('Inheritance of the parent entity'));
}
Calendar::dropdown($options);
if ($entity->fields["calendars_id"] == self::CONFIG_PARENT && $ID != 0) {
echo "<font class='green'> ";
$calendar = new Calendar();
$cid = self::getUsedConfig('calendars_id', $ID, '', 0);
if (!$cid) {
_e('24/7');
} else {
if ($calendar->getFromDB($cid)) {
echo $calendar->getLink();
}
}
echo "</font>";
}
echo "</td></tr>";
echo "<tr class='tab_bg_1'><td colspan='2'>" . __('Tickets default type') . "</td>";
echo "<td colspan='2'>";
$toadd = array();
if ($ID != 0) {
$toadd = array(self::CONFIG_PARENT => __('Inheritance of the parent entity'));
}
Ticket::dropdownType('tickettype', array('value' => $entity->fields["tickettype"], 'toadd' => $toadd));
if ($entity->fields['tickettype'] == self::CONFIG_PARENT && $ID != 0) {
echo "<font class='green'> ";
echo Ticket::getTicketTypeName(self::getUsedConfig('tickettype', $ID, '', Ticket::INCIDENT_TYPE));
echo "</font>";
}
echo "</td></tr>";
echo "<tr class='tab_bg_1'><td colspan='2'>" . __('Automatic assignment of tickets') . "</td>";
echo "<td colspan='2'>";
$autoassign = self::getAutoAssignMode();
if ($ID == 0) {
unset($autoassign[self::CONFIG_PARENT]);
}
Dropdown::showFromArray('auto_assign_mode', $autoassign, array('value' => $entity->fields["auto_assign_mode"]));
if ($entity->fields['auto_assign_mode'] == self::CONFIG_PARENT && $ID != 0) {
$auto_assign_mode = self::getUsedConfig('auto_assign_mode', $entity->fields['entities_id']);
echo "<font class='green'> ";
echo $autoassign[$auto_assign_mode];
echo "</font>";
}
echo "</td></tr>";
echo "<tr><th colspan='4'>" . __('Automatic closing configuration') . "</th></tr>";
echo "<tr class='tab_bg_1'>" . "<td colspan='2'>" . __('Automatic closing of solved tickets after') . "</td>";
echo "<td colspan='2'>";
$autoclose = array(self::CONFIG_PARENT => __('Inheritance of the parent entity'), self::CONFIG_NEVER => __('Never'), 0 => __('Immediatly'));
if ($ID == 0) {
unset($autoclose[self::CONFIG_PARENT]);
}
Dropdown::showNumber('autoclose_delay', array('value' => $entity->fields['autoclose_delay'], 'min' => 1, 'max' => 99, 'step' => 1, 'toadd' => $autoclose, 'unit' => 'day'));
if ($entity->fields['autoclose_delay'] == self::CONFIG_PARENT && $ID != 0) {
$autoclose_mode = self::getUsedConfig('autoclose_delay', $entity->fields['entities_id'], '', self::CONFIG_NEVER);
echo "<br><font class='green'> ";
if ($autoclose_mode >= 0) {
printf(_n('%d day', '%d days', $autoclose_mode), $autoclose_mode);
} else {
echo $autoclose[$autoclose_mode];
}
echo "</font>";
}
echo "</td></tr>";
echo "<tr><th colspan='4'>" . __('Configuring the satisfaction survey') . "</th></tr>";
echo "<tr class='tab_bg_1'>" . "<td colspan='2'>" . __('Configuring the satisfaction survey') . "</td>";
echo "<td colspan='2'>";
/// no inquest case = rate 0
$typeinquest = array(self::CONFIG_PARENT => __('Inheritance of the parent entity'), 1 => __('Internal survey'), 2 => __('External survey'));
// No inherit from parent for root entity
if ($ID == 0) {
unset($typeinquest[self::CONFIG_PARENT]);
if ($entity->fields['inquest_config'] == self::CONFIG_PARENT) {
$entity->fields['inquest_config'] = 1;
}
}
$rand = Dropdown::showFromArray('inquest_config', $typeinquest, $options = array('value' => $entity->fields['inquest_config']));
echo "</td></tr>\n";
// Do not display for root entity in inherit case
if ($entity->fields['inquest_config'] == self::CONFIG_PARENT && $ID != 0) {
$inquestconfig = self::getUsedConfig('inquest_config', $entity->fields['entities_id']);
$inquestrate = self::getUsedConfig('inquest_config', $entity->fields['entities_id'], 'inquest_rate');
echo "<tr class='tab_bg_1'><td colspan='4' class='green center'>";
if ($inquestrate == 0) {
_e('Disabled');
} else {
echo $typeinquest[$inquestconfig] . '<br>';
$inqconf = self::getUsedConfig('inquest_config', $entity->fields['entities_id'], 'inquest_delay');
printf(_n('%d day', '%d days', $inqconf), $inqconf);
echo "<br>";
//TRANS: %d is the percentage. %% to display %
printf(__('%d%%'), $inquestrate);
if ($inquestconfig == 2) {
echo "<br>";
echo self::getUsedConfig('inquest_config', $entity->fields['entities_id'], 'inquest_URL');
}
}
echo "</td></tr>\n";
}
echo "<tr class='tab_bg_1'><td colspan='4'>";
$_POST = array('inquest_config' => $entity->fields['inquest_config'], 'entities_id' => $ID);
$params = array('inquest_config' => '__VALUE__', 'entities_id' => $ID);
echo "<div id='inquestconfig'>";
include GLPI_ROOT . '/ajax/ticketsatisfaction.php';
echo "</div>\n";
echo "</td></tr>";
if ($canedit) {
echo "<tr class='tab_bg_2'>";
echo "<td class='center' colspan='4'>";
echo "<input type='hidden' name='id' value='" . $entity->fields["id"] . "'>";
echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\"\n class='submit'>";
echo "</td></tr>";
echo "</table>";
Html::closeForm();
} else {
echo "</table>";
}
echo "</div>";
Ajax::updateItemOnSelectEvent("dropdown_inquest_config{$rand}", "inquestconfig", $CFG_GLPI["root_doc"] . "/ajax/ticketsatisfaction.php", $params);
}