. * --------------------------------------------------------------------- */ include ("../inc/includes.php"); Session::checkRight("reports", READ); Html::header(Report::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "tools", "report"); Report::title(); $items = $CFG_GLPI["report_types"]; // Titre echo "
".__('Device list')."
"; // Request All if ((isset($_POST["item_type"][0]) && ($_POST["item_type"][0] == 0)) || !isset($_POST["item_type"])) { $_POST["item_type"] = $items; } if (isset($_POST["item_type"]) && is_array($_POST["item_type"])) { $all_criteria = []; foreach ($_POST["item_type"] as $key => $val) { if (in_array($val, $items)) { $itemtable = getTableForItemType($val); $deleted_field = "$itemtable.is_deleted"; $location_field = null; $add_leftjoin = ""; $template_condition = '1'; $criteria = [ 'SELECT' => [ "$itemtable.name AS itemname", 'glpi_contracttypes.name AS type', 'glpi_infocoms.buy_date', 'glpi_infocoms.warranty_duration', 'glpi_contracts.begin_date', 'glpi_contracts.duration', 'glpi_entities.completename AS entname', 'glpi_entities.id AS entID' ], 'FROM' => $itemtable, 'LEFT JOIN' => [], 'WHERE' => [], 'ORDERBY' => ['entname ASC', 'itemdeleted DESC', 'itemname ASC'] ]; if ($val != 'Project') { $location_field = "glpi_locations.completename"; $criteria['LEFT JOIN']['glpi_locations'] = [ 'ON' => [ $itemtable => 'locations_id', 'glpi_locations.id' ] ]; $criteria['WHERE']["$itemtable.is_template"] = 0; } if ($val == 'SoftwareLicense') { $deleted_field = "glpi_softwares.is_deleted"; $location_field = null; $criteria['LEFT JOIN']['glpi_softwares'] = [ 'ON' => [ 'glpi_softwares' => 'id', 'glpi_softwarelicenses' => 'softwares_id' ] ]; $criteria['WHERE']['glpi_softwares.is_template'] = 0; } $criteria['SELECT'][] = "$deleted_field AS itemdeleted"; $criteria['SELECT'][] = ($location_field !== null ? "$location_field AS location" : new QueryExpression("'' AS " . $DB->quoteName('location'))); $criteria['LEFT JOIN'] = $criteria['LEFT JOIN'] + [ 'glpi_contracts_items' => [ 'ON' => [ $itemtable => 'id', 'glpi_contracts_items' => 'items_id', [ 'AND' => [ 'glpi_contracts_items.itemtype' => $val ] ] ] ], 'glpi_contracts' => [ 'ON' => [ 'glpi_contracts_items' => 'contracts_id', 'glpi_contracts' => 'id', [ 'AND' => [ 'NOT' => ['glpi_contracts_items.contracts_id' => null] ] ] ] ], 'glpi_infocoms' => [ 'ON' => [ $itemtable => 'id', 'glpi_infocoms' => 'items_id', [ 'AND' => [ 'glpi_infocoms.itemtype' => $val ] ] ] ], 'glpi_contracttypes' => [ 'ON' => [ 'glpi_contracts' => 'contracttypes_id', 'glpi_contracttypes' => 'id' ] ], 'glpi_entities' => [ 'ON' => [ $itemtable => 'entities_id', 'glpi_entities' => 'id' ] ] ]; $criteria['WHERE'] = $criteria['WHERE'] + getEntitiesRestrictCriteria($itemtable); if (isset($_POST["year"][0]) && ($_POST["year"][0] != 0)) { $ors = []; foreach ($_POST["year"] as $val2) { $ors[] = new QueryExpression("YEAR(".$DB->quoteName('glpi_infocoms.buy_date').") = ".$DB->quote($val2)); $ors[] = new QueryExpression("YEAR(".$DB->quoteName('glpi_contracts.begin_date').") = ".$DB->quote($val2)); } if (count($ors)) { $criteria['WHERE'][] = [ 'OR' => $ors ]; } } } $all_criteria[$val] = $criteria; } } $display_entity = Session::isMultiEntitiesMode(); if (count($all_criteria)) { foreach ($all_criteria as $key => $val) { $iterator = $DB->request($val); if (count($iterator)) { $item = new $key(); echo "
".$item->getTypeName(1)."
"; echo ""; echo ""; echo ""; if ($display_entity) { echo ""; } echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; while ($data = $iterator->next()) { echo ""; if ($data['itemname']) { echo ""; } else { echo ""; } echo ""; if ($display_entity) { echo ""; } if ($data['location']) { echo ""; } else { echo ""; } if ($data['buy_date']) { echo ""; if ($data["warranty_duration"]) { echo ""; } else { echo ""; } } else { echo ""; echo ""; } if ($data['type']) { echo ""; } else { echo ""; } if ($data['begin_date']) { echo ""; if ($data["duration"]) { echo ""; } else { echo ""; } } else { echo ""; echo ""; } echo "\n"; } echo "
".__('Name')."".__('Deleted')."".Entity::getTypeName(1)."".Location::getTypeName(1)."".__('Date of purchase')."".__('Warranty expiration date')."".ContractType::getTypeName(1)."".__('Start date')."".__('End date')."
".$data['itemname']."".NOT_AVAILABLE."".Dropdown::getYesNo($data['itemdeleted'])."".$data['entname']."".$data['location']."".NOT_AVAILABLE."".Html::convDate($data['buy_date'])."".Infocom::getWarrantyExpir($data["buy_date"], $data["warranty_duration"]). "".NOT_AVAILABLE."".NOT_AVAILABLE."".NOT_AVAILABLE."".$data['type']."".NOT_AVAILABLE."".Html::convDate($data['begin_date'])."".Infocom::getWarrantyExpir($data["begin_date"], $data["duration"])."".NOT_AVAILABLE."".NOT_AVAILABLE."".NOT_AVAILABLE."



"; } } } Html::footer();