getStatusColor() статический публичный Метод

Get Ticket validation status Color
static public getStatusColor ( $value )
$value status ID
Пример #1
0
 /**
  * Show consumable validation
  */
 function showConsumableValidation()
 {
     global $CFG_GLPI;
     if (!$this->canView()) {
         return false;
     }
     // Wizard title
     echo "<div class='consumables_wizard_title'><p>";
     echo "<img class='consumables_wizard_img' src='" . $CFG_GLPI['root_doc'] . "/plugins/consumables/pics/consumablevalidation.png' alt='consumablevalidation'/>&nbsp;";
     _e("Consumable validation", "consumables");
     echo "</p></div>";
     $rand = mt_rand();
     $fields = $this->find("`status` NOT IN ('" . CommonITILValidation::REFUSED . "','" . CommonITILValidation::ACCEPTED . "')", "`date_mod`");
     echo "<div class='center'>";
     if (!empty($fields)) {
         if ($this->canValidate()) {
             Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
             $massiveactionparams = array('item' => __CLASS__, 'container' => 'mass' . __CLASS__ . $rand);
             Html::showMassiveActions($massiveactionparams);
         }
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr>";
         echo "<th colspan='7'>" . self::getTypeName() . "</th>";
         echo "</tr>";
         echo "<tr>";
         echo "<th width='10'>";
         if ($this->canValidate()) {
             echo Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
         }
         echo "</th>";
         echo "<th>" . __('Requester') . "</th>";
         echo "<th>" . _n('Consumable type', 'Consumable types', 1) . "</th>";
         echo "<th>" . _n('Consumable', 'Consumables', 1) . "</th>";
         echo "<th>" . __('Number', 'consumables') . "</th>";
         echo "<th>" . __("Give to") . "</th>";
         echo "<th>" . _sx("item", "State") . "</th>";
         echo "</tr>";
         foreach ($fields as $field) {
             echo "<tr class='tab_bg_1'>";
             echo "<td width='10'>";
             if ($this->canValidate()) {
                 Html::showMassiveActionCheckBox(__CLASS__, $field['id']);
             }
             echo "</td>";
             echo "<td>";
             echo getUserName($field['requesters_id']);
             echo "</td>";
             echo "<td>";
             echo Dropdown::getDropdownName("glpi_consumableitemtypes", $field['consumableitemtypes_id']);
             echo "</td>";
             echo "<td>";
             echo Dropdown::getDropdownName("glpi_consumableitems", $field['consumables_id']);
             echo "</td>";
             echo "<td>";
             echo $field['number'];
             echo "</td>";
             echo "<td>";
             if (!empty($field['give_itemtype'])) {
                 $give_item = getItemForItemtype($field['give_itemtype']);
                 $give_item->getFromDB($field['give_items_id']);
                 echo $give_item->getLink();
             }
             echo "</td>";
             echo "<td>";
             $bgcolor = CommonITILValidation::getStatusColor($field['status']);
             $status = CommonITILValidation::getStatus($field['status']);
             echo "<div style='background-color:" . $bgcolor . ";'>" . $status . "</div>";
             echo "</td>";
             echo "</tr>";
         }
         if ($this->canValidate()) {
             $massiveactionparams['ontop'] = false;
             Html::showMassiveActions($massiveactionparams);
             Html::closeForm();
         }
         echo "</table>";
     } else {
         echo __("No item to display");
     }
     echo "</div>";
     // Footer
     if ($this->canCreate() && $this->canValidate()) {
         echo "<br/><table width='100%'>";
         echo "<tr>";
         echo "<td class='consumables_wizard_button'>";
         echo "<div id='dialog-confirm'></div>";
         echo "<input type=\"button\" class=\"consumable_previous_button submit\" name=\"previous\" value=\"" . _sx('button', 'Cancel') . "\" onclick=\"consumables_cancel('" . $CFG_GLPI['root_doc'] . "/plugins/consumables/front/wizard.php');\">";
         echo "<input type='hidden' name='requesters_id' value='" . Session::getLoginUserID() . "'>";
         echo "</td>";
         echo "</tr>";
         echo "</table>";
     }
     // Init consumable cart javascript
     echo "<script type='text/javascript'>";
     echo "consumables_initJs('" . $CFG_GLPI['root_doc'] . "');";
     echo "</script>";
 }
Пример #2
0
 /**
  * Show list of items
  * 
  * @param type $fields
  */
 function listItemsForUser($requesters_id, $options = array())
 {
     $params['begin_date'] = "NULL";
     $params['end_date'] = "NULL";
     foreach ($options as $key => $val) {
         $params[$key] = $val;
     }
     $data = $this->find('`requesters_id` = ' . $requesters_id . " " . "AND `end_date` >= '" . $params['begin_date'] . "' " . "AND (`end_date` <= '" . $params['end_date'] . "' OR `end_date` IS NULL)", "`end_date` DESC");
     $message = null;
     if (!empty($data)) {
         $message .= "<table class='tab_cadre_fixe'>";
         $message .= "<tr>";
         $message .= "<th colspan='7'>" . __('Consumable request report', 'consumables') . "</th>";
         $message .= "</tr>";
         $message .= "<tr>";
         $message .= "<th>" . _n('Consumable', 'Consumables', 1) . "</th>";
         $message .= "<th>" . _n('Consumable type', 'Consumable types', 1) . "</th>";
         $message .= "<th>" . __('Requester') . "</th>";
         $message .= "<th>" . __('Approver') . "</th>";
         $message .= "<th>" . __('Number of used consumables') . "</th>";
         $message .= "<th>" . __('Request date') . "</th>";
         $message .= "<th>" . __('Status') . "</th>";
         $message .= "</tr>";
         $consumable = new ConsumableItem();
         foreach ($data as $field) {
             $message .= "<tr class='tab_bg_1'>";
             $consumable->getFromDB($field['consumables_id']);
             $message .= "<td>" . $consumable->getLink() . "</td>";
             $message .= "<td>" . Dropdown::getDropdownName(ConsumableItemType::getTable(), $field['consumableitemtypes_id']) . "</td>";
             $message .= "<td>" . getUserName($field['requesters_id']) . "</td>";
             $message .= "<td>" . getUserName($field['validators_id']) . "</td>";
             $message .= "<td>" . $field['number'] . "</td>";
             $message .= "<td>" . Html::convDateTime($field['date_mod']) . "</td>";
             $message .= "<td>";
             $bgcolor = CommonITILValidation::getStatusColor($field['status']);
             $status = CommonITILValidation::getStatus($field['status']);
             $message .= "<div style='background-color:" . $bgcolor . ";'>" . $status . "</div>";
             $message .= "</td>";
             $message .= "</tr>";
         }
         $message .= "</table>";
         $message .= "</div>";
     } else {
         $message .= "<div class='center'>";
         $message .= "<table class='tab_cadre_fixe'>";
         $message .= "<tr>";
         $message .= "<th colspan='6'>" . __('Consumable request report', 'consumables') . "</th>";
         $message .= "</tr>";
         $message .= "<tr><td class='center'>" . __('No item found') . "</td></tr>";
         $message .= "</table>";
     }
     return array('success' => true, 'message' => $message);
 }