コード例 #1
0
ファイル: ticket.class.php プロジェクト: gaforeror/glpi
 function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
 {
     if (static::canView()) {
         $nb = 0;
         $title = self::getTypeName(2);
         if ($_SESSION['glpishow_count_on_tabs']) {
             switch ($item->getType()) {
                 case 'Change':
                     $nb = countElementsInTable('glpi_changes_tickets', "`changes_id` = '" . $item->getID() . "'");
                     break;
                 case 'Problem':
                     $nb = countElementsInTable('glpi_problems_tickets', "`problems_id` = '" . $item->getID() . "'");
                     break;
                 case 'User':
                     $nb = countElementsInTable('glpi_tickets_users', "`users_id` = '" . $item->getID() . "'\n                                                AND `type` = " . CommonITILActor::REQUESTER);
                     $title = __('Created tickets');
                     break;
                 case 'Supplier':
                     $nb = countElementsInTable('glpi_suppliers_tickets', "`suppliers_id` = '" . $item->getID() . "'");
                     break;
                 case 'SLA':
                     $nb = countElementsInTable('glpi_tickets', "`slas_id` = '" . $item->getID() . "'");
                     break;
                 case 'Group':
                     $nb = countElementsInTable('glpi_groups_tickets', "`groups_id` = '" . $item->getID() . "'\n                                               AND `type` = " . CommonITILActor::REQUESTER);
                     $title = __('Created tickets');
                     break;
                 default:
                     // Direct one
                     $nb = countElementsInTable('glpi_tickets', " `itemtype` = '" . $item->getType() . "'\n                                                AND `items_id` = '" . $item->getID() . "'");
                     // Linked items
                     if ($subquery = $item->getSelectLinkedItem()) {
                         $nb += countElementsInTable('glpi_tickets', "(`itemtype`,`items_id`) IN (" . $subquery . ")");
                     }
                     break;
             }
         }
         // glpishow_count_on_tabs
         // Not for Ticket class
         if ($item->getType() != __CLASS__) {
             return self::createTabEntry($title, $nb);
         }
     }
     // show_all_ticket right check
     // Not check show_all_ticket for Ticket itself
     switch ($item->getType()) {
         case __CLASS__:
             $ong = array();
             $ong[2] = _n('Solution', 'Solutions', 1);
             // enquete si statut clos
             if ($item->fields['status'] == self::CLOSED) {
                 $satisfaction = new TicketSatisfaction();
                 if ($satisfaction->getFromDB($item->getID())) {
                     $ong[3] = __('Satisfaction');
                 }
             }
             if (Session::haveRight('observe_ticket', '1')) {
                 $ong[4] = __('Statistics');
             }
             return $ong;
             //   default :
             //      return _n('Ticket','Tickets',2);
     }
     return '';
 }
コード例 #2
0
ファイル: item_problem.class.php プロジェクト: gaforeror/glpi
 function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
 {
     if (!$withtemplate) {
         switch ($item->getType()) {
             case 'Problem':
                 return _n('Item', 'Items', 2);
             default:
                 if (Session::haveRight("show_all_problem", "1")) {
                     $nb = 0;
                     if ($_SESSION['glpishow_count_on_tabs']) {
                         // Direct one
                         $nb = countElementsInTable('glpi_items_problems', " `itemtype` = '" . $item->getType() . "'\n                                                   AND `items_id` = '" . $item->getID() . "'");
                         // Linked items
                         if ($subquery = $item->getSelectLinkedItem()) {
                             $nb += countElementsInTable('glpi_items_problems', " (`itemtype`,`items_id`) IN (" . $subquery . ")");
                         }
                     }
                     return self::createTabEntry(Problem::getTypeName(2), $nb);
                 }
         }
     }
     return '';
 }