Example #1
0
$USEDBREPLICATE = 1;
$DBCONNECTION_REQUIRED = 0;
include "../../../../inc/includes.php";
/*
 * TODO : add more criteria
 *
 * - num_immo not empry
 * - otherserial not empty
 * - etc
 *
 */
//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 = '';
 @license   AGPL License 3.0 or (at your option) any later version
            http://www.gnu.org/licenses/agpl-3.0-standalone.html
 @link      https://forge.indepnet.net/projects/reports
 @link      http://www.glpi-project.org/
 @since     2009
 --------------------------------------------------------------------------
*/
$USEDBREPLICATE = 1;
$DBCONNECTION_REQUIRED = 1;
// 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) {