<?php
$availableTableColumns = array_keys($tableColumns);
// PREPROCESS FILTERS /////////////////////////////////////////////////////////////////////////////
// cleanup dates
$reportFilters['addDate']['startDate'] = standard2mysqlDateConversion($reportFilters['addDate']['startDate']);
$reportFilters['addDate']['endDate'] = standard2mysqlDateConversion($reportFilters['addDate']['endDate']);

// cleanup add user
list($reportFilters['addOfficeUser']['idOffice'], $reportFilters['addOfficeUser']['idUser']) = explode("|", $reportFilters['addOfficeUser']['id']);

// cleanup corporate filter
$reportFilters['idCorporate'] = $reportFilters['corporate']['id'];
$reportExtraFilters = [];
if ($reportFilters['idCorporate']) {
	$reportExtraFilters['corporate'] = \Entity\Corporate::select($reportFilters['idCorporate'])->fullDuplicatedCorporatesGroup;
}

try {
	// EXCUTE MAIN SQLs ---------------------------------------------------------------------------
	include(__DIR__."/reportData_executeSQL.php");

	// FILL IN OTHER FIELDS -----------------------------------------------------------------------
	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());
}
