<?php
$availableTableColumns = array_keys($tableColumns);

// PREPROCESS FILTERS /////////////////////////////////////////////////////////////////////////////
// cleanup dates
$reportFilters['expireDate']['start'] = standard2mysqlDateConversion($reportFilters['expireDate']['startDate']);
$reportFilters['expireDate']['end'] = standard2mysqlDateConversion($reportFilters['expireDate']['endDate']);

$reportFilters['addDate']['start'] = standard2mysqlDateConversion($reportFilters['addDate']['startDate']);
$reportFilters['addDate']['end'] = standard2mysqlDateConversion($reportFilters['addDate']['endDate']);

$reportFilters['contractDate']['start'] = standard2mysqlDateConversion($reportFilters['contractDate']['startDate']);
$reportFilters['contractDate']['end'] = standard2mysqlDateConversion($reportFilters['contractDate']['endDate']);
// cleanup responsible user
list($reportFilters['responsibleUser']['idOffice'], $reportFilters['responsibleUser']['idUser']) = explode("|", $reportFilters['responsibleUser']['id']);

// PREPARE EXTRA FILTERS
$reportExtraFilters = [];

$reportFilters['idSupplier'] = $reportFilters['supplier']['id'];
if ($reportFilters['idSupplier']) {
	$reportExtraFilters['supplier'] = \Entity\Supplier::select($reportFilters['idSupplier'])->fullDuplicatedSuppliersGroup;
}

try {
	include(__DIR__."/reportData_executeSQL.php");
	include(__DIR__."/reportData_otherFields.php");
} catch (\DBException $e) {
	killReport("Could not run SQL in report. SQL error: ".$e->getMessage());
} catch (\Exception $e) {
	killReport("Could not process report. Error: ".$e->getMessage());
}