Ejemplo n.º 1
0
 *
 */
//TRANS: The name of the report = Financial information
$report = new PluginReportsAutoReport(__('infocom_report_title', 'reports'));
$ignored = array('Cartridge', 'CartridgeItem', 'Consumable', 'ConsumableItem', 'Software');
$date = new PluginReportsDateIntervalCriteria($report, '`glpi_infocoms`.`buy_date`', __('Date of purchase'));
$type = new PluginReportsItemTypeCriteria($report, 'itemtype', '', 'infocom_types', $ignored);
$budg = new PluginReportsDropdownCriteria($report, '`glpi_infocoms`.`budgets_id`', 'Budget', __('Budget'));
//Display criterias form is needed
$report->displayCriteriasForm();
//If criterias have been validated
if ($report->criteriasValidated()) {
    $report->setSubNameAuto();
    $cols = array(new PluginReportsColumnType('itemtype', __('Item type')), new PluginReportsColumn('manufacturer', __('Manufacturer')), new PluginReportsColumn('type', __('Type')), new PluginReportsColumn('model', __('Model')), new PluginReportsColumnTypeLink('itemid', __('Name'), 'itemtype'), new PluginReportsColumn('serial', __('Serial number')), new PluginReportsColumn('otherserial', __('Inventory number')), new PluginReportsColumn('location', __('Location')), new PluginReportsColumn('building', __('Building number')), new PluginReportsColumn('room', __('Room number')), new PluginReportsColumnLink('groups_id', __('Group'), 'Group'), new PluginReportsColumn('state', __('Status')), new PluginReportsColumn('immo_number', __('Immobilization number')), new PluginReportsColumnDate('buy_date', __('Date of purchase')), new PluginReportsColumnDate('use_date', __('Startup date')), new PluginReportsColumnDate('warranty_date', __('Start date of warranty')), new PluginReportsColumnInteger('warranty_duration', __('Warranty duration')), new PluginReportsColumnInteger('warranty_info', __('Warranty information')), new PluginReportsColumnLink('suppliers_id', __('Supplier'), "Supplier"), new PluginReportsColumnDate('order_date', __('Order date')), new PluginReportsColumn('order_number', __('Order number')), new PluginReportsColumnDate('delivery_date', __('Delivery date')), new PluginReportsColumn('delivery_number', __('Delivery form')), new PluginReportsColumnFloat('value', __('Value')), new PluginReportsColumnFloat('warranty_value', __('Warranty extension value')), new PluginReportsColumnInteger('sink_time', __('Amortization duration')), new PluginReportsColumnInteger('sink_type', __('Amortization type')), new PluginReportsColumnFloat('sink_coeff', __('Amortization coefficient')), new PluginReportsColumn('bill', __('Invoice number')), new PluginReportsColumn('budget', __('Budget')), new PluginReportsColumnDate('inventory_date', __('Date of last physical inventory')));
    $report->setColumns($cols);
    $sel = $type->getParameterValue();
    if ($sel) {
        $types = array($sel);
    } else {
        $types = array_diff($CFG_GLPI['infocom_types'], $ignored);
    }
    $sql = '';
    foreach ($types as $itemtype) {
        $item = new $itemtype();
        $table = $item->getTable();
        $select = "SELECT '{$itemtype}' as itemtype,\n                        `{$table}`.id AS itemid";
        $from = "FROM `{$table}` ";
        if ($itemtype == 'SoftwareLicense') {
            $select .= ", `glpi_manufacturers`.`name` AS manufacturer";
            $from .= "LEFT JOIN `glpi_softwares`\n                        ON (`glpi_softwarelicenses`.`softwares_id` = `glpi_softwares`.`id`)\n                     LEFT JOIN `glpi_manufacturers`\n                        ON (`glpi_manufacturers`.`id` = `glpi_softwares`.`manufacturers_id`) ";
        } else {
// Initialization of the variables
include "../../../../inc/includes.php";
//TRANS: The name of the report = Time before equipment start-up
$report = new PluginReportsAutoReport(__('iteminstall_report_title', 'reports'));
//Report's search criterias
$date = new PluginReportsDateIntervalCriteria($report, 'buy_date');
$type = new PluginReportsItemTypeCriteria($report, 'itemtype', '', 'infocom_types');
$budg = new PluginReportsDropdownCriteria($report, 'budgets_id', 'glpi_budgets', __('Budget'));
//Display criterias form is needed
$report->displayCriteriasForm();
$display_type = Search::HTML_OUTPUT;
//If criterias have been validated
if ($report->criteriasValidated()) {
    $report->setSubNameAuto();
    $title = $report->getFullTitle();
    $itemtype = $type->getParameterValue();
    if ($itemtype && $itemtype != "all") {
        $types = array($itemtype);
    } else {
        $types = array();
        $sql = "SELECT DISTINCT `itemtype`\n                FROM `glpi_infocoms` " . getEntitiesRestrictRequest('WHERE', 'glpi_infocoms') . $date->getSqlCriteriasRestriction('AND') . $budg->getSqlCriteriasRestriction('AND');
        foreach ($DB->request($sql) as $data) {
            $types[] = $data['itemtype'];
        }
    }
    $result = array();
    foreach ($types as $type) {
        if (!class_exists($type)) {
            continue;
        }
        $item = new $type();