function prepareInputForAdd($input) { $item = new ConsumableItem(); if ($item->getFromDB($input["tID"])) { return array("consumableitems_id" => $item->fields["id"], "entities_id" => $item->getEntityID(), "date_in" => date("Y-m-d")); } return array(); }
public function getLinkedItemDetails($itemtype, $items_id) { $comments = ""; switch ($itemtype) { case 'ConsumableItem': $ci = new Consumable(); if ($ci->getFromDB($items_id)) { $ct = new ConsumableItem(); $ct->getFromDB($ci->fields['consumableitems_id']); $comments .= "<strong>" . __("Entity") . ":</strong> "; $comments .= Dropdown::getDropdownName("glpi_entities", $ct->fields["entities_id"]); $comments .= '<br><strong>' . __("Consumable") . ' : </strong> #' . $items_id; $comments .= '<br><strong>' . __("Consumable type") . ' : </strong>'; $comments .= $ct->fields['name']; $comments .= '<br><strong>' . __("Manufacturer") . ' : </strong>'; $comments .= Dropdown::getDropdownName('glpi_manufacturers', $ct->fields['manufacturers_id']); $comments .= '<br><strong>' . __("State") . ' : </strong>'; $comments .= !$ci->fields['users_id'] ? __("In stock") : __("Used"); if ($ci->fields['users_id']) { $comments .= '<br><strong>' . __("User") . ' : </strong>'; $comments .= Dropdown::getDropdownName('glpi_users', $ci->fields['users_id']); } } break; case 'CartridgeItem': $ci = new Cartridge(); if ($ci->getFromDB($items_id)) { $ct = new CartridgeItem(); $ct->getFromDB($ci->fields['cartridgeitems_id']); $comments .= "<strong>" . __("Entity") . ":</strong> "; $comments .= Dropdown::getDropdownName("glpi_entities", $ct->fields["entities_id"]); $comments .= '<br><strong>' . __("Cartridge") . ' : </strong> #' . $items_id; $comments .= '<br><strong>' . _n("New", "New", 2) . ' : </strong>'; $comments .= $ct->fields['name']; $comments .= '<br><strong>' . __("Manufacturer") . ' : </strong>'; $comments .= Dropdown::getDropdownName('glpi_manufacturers', $ct->fields['manufacturers_id']); } break; // case 'Computer' : // case 'Monitor' : // case 'NetworkEquipment' : // case 'Peripheral' : // case 'Phone' : // case 'Printer' : // case 'Computer' : // case 'Monitor' : // case 'NetworkEquipment' : // case 'Peripheral' : // case 'Phone' : // case 'Printer' : default: $item = new $itemtype(); $item->getFromDB($items_id); if ($item->getField("name")) { $comments .= "<strong>" . __("Name") . ":</strong> "; $comments .= $item->getField("name"); } if ($item->getField("entities_id")) { $comments .= "<strong>" . __("Entity") . ":</strong> "; $comments .= Dropdown::getDropdownName("glpi_entities", $item->getField("entities_id")); } if ($item->getField("serial") != '') { $comments .= "<br><strong>" . __("Serial number") . ":</strong> "; $comments .= $item->getField("serial"); } if ($item->getField("otherserial") != '') { $comments .= "<br><strong>" . __("Inventory number") . ":</strong> "; $comments .= $item->getField("otherserial"); } if ($item->getField("locations_id")) { $comments .= "<br><strong>" . __("Location") . ":</strong> "; $comments .= Dropdown::getDropdownName('glpi_locations', $item->getField("locations_id")); } if ($item->getField("users_id")) { $comments .= "<br><strong>" . __("User") . ":</strong> "; $comments .= Dropdown::getDropdownName('glpi_users', $item->getField("users_id")); } break; } return $comments; }
/** * @since version 0.84 * * @see CommonDBTM::getPreAdditionalInfosForName **/ function getPreAdditionalInfosForName() { $ci = new ConsumableItem(); if ($ci->getFromDB($this->fields['consumableitems_id'])) { return $ci->getName(); } return ''; }
/** * 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); }