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

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

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

// cleanup invoice clients filters
$reportFilters['corporate'] = $reportFilters['corporate']['id'];

$reportFilters['clientType'] = (array)$reportFilters['clientType'];

// PREPARE EXTRA FILTERS
$reportExtraFilters = [];
if ($reportFilters['corporate']) {
	$reportExtraFilters['corporate'] = \Entity\Corporate::select($reportFilters['corporate'])->fullDuplicatedCorporatesGroup;
}

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());
}

