コード例 #1
0
ファイル: entity.class.php プロジェクト: korial29/glpi
 /**
  * @since version 0.84 (before in entitydata.class)
  *
  * @param $entity Entity object
  **/
 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'>&nbsp;&nbsp;";
         $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'>&nbsp;&nbsp;";
         $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'>&nbsp;&nbsp;";
         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'>&nbsp;&nbsp;";
         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'>&nbsp;&nbsp;";
         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);
 }
コード例 #2
0
 function showTicketTemplate($items_id)
 {
     global $CFG_GLPI;
     $ticketTemplate = new TicketTemplate();
     echo "<form method='post' name='form_addquestion' action='" . $CFG_GLPI['root_doc'] . "/plugins/surveyticket/front/tickettemplate.form.php'>";
     echo "<table class='tab_cadre' width='700'>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Ticket template') . "&nbsp;:</td>";
     echo "<td>";
     $a_used = array();
     Dropdown::show("TicketTemplate", array("name" => "tickettemplates_id", "used" => $a_used));
     echo "</td>";
     echo "<td>" . __('Type') . "&nbsp;:</td>";
     echo "<td>";
     Ticket::dropdownType("type");
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Simplified interface') . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::showYesNo("is_helpdesk");
     echo "</td>";
     echo "<td>" . __('Standard interface') . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::showYesNo("is_central");
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td class='tab_bg_2 top' colspan='4'>";
     echo "<input type='hidden' name='plugin_surveyticket_surveys_id' value='" . $items_id . "'>";
     echo "<div class='center'>";
     echo "<input type='submit' name='add' value=\"" . __('Add') . "\" class='submit'>";
     echo "</div></td></tr>";
     echo "</table>";
     Html::closeForm();
     // list templates
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>";
     echo __('Ticket template');
     echo "</th>";
     echo "<th>";
     echo __('Type');
     echo "</th>";
     echo "<th>";
     echo __('Simplified interface');
     echo "</th>";
     echo "<th>";
     echo __('Standard interface');
     echo "</th>";
     echo "<th>";
     echo "</th>";
     echo "</tr>";
     $_tickettempaltes = $this->find("`plugin_surveyticket_surveys_id`='" . $items_id . "'");
     foreach ($_tickettempaltes as $data) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>";
         $ticketTemplate->getFromDB($data['tickettemplates_id']);
         echo $ticketTemplate->getLink(1);
         echo "</td>";
         echo "<td>";
         echo Ticket::getTicketTypeName($data['type']);
         echo "</td>";
         echo "<td>";
         echo Dropdown::getYesNo($data['is_helpdesk']);
         echo "</td>";
         echo "<td>";
         echo Dropdown::getYesNo($data['is_central']);
         echo "</td>";
         echo "<td align='center'>";
         echo "<form method='post' name='form_delettickettemplate' action='" . $CFG_GLPI['root_doc'] . "/plugins/surveyticket/front/tickettemplate.form.php'>";
         echo "<input type='hidden' name='id' value='" . $data['id'] . "'>";
         echo "<input type='submit' name='delete' value=\"" . _sx('button', 'Delete permanently') . "\" class='submit'>";
         Html::closeForm();
         echo "</td>";
         echo "</tr>";
     }
     echo "</table>";
 }