<?php

$filters=$S['balanceInvoices']['client'];
$filtersOK=1;

// RESERVATION DATE ///////////////////////////////////////////////////////////////////////////////
$filters['resStartDateMysql']=standard2mysqlDateConversion($filters['resStartDate']);
$filters['resEndDateMysql']=standard2mysqlDateConversion($filters['resEndDate']);
if (!$filters['resStartDateMysql'] or !$filters['resEndDateMysql']) {
	$filtersOK=0;
	$showMessage['warning']=$_LANG['invoices']['balanceInvoices']['clientServicesList']['filters']['noStartEndDate'];
}
if ($filters['resStartDateMysql'] and $filters['resEndDateMysql']) {
	if ($filters['resStartDateMysql']>$filters['resEndDateMysql']) {
		$filtersOK=0;
		$showMessage['warning']=$_LANG['invoices']['balanceInvoices']['clientServicesList']['filters']['resStartDateAfterEnd'];
	}
}

// CLIENT TYPE ////////////////////////////////////////////////////////////////////////////////////
if (!$filters['idReservationType']) {
	$filters['idReservationType']=$CFG['balanceInvoices']['filters']['client']['idReservationType'];
}

// BALANCE STATUS /////////////////////////////////////////////////////////////////////////////////
if (!isset($filters['balanceStatus'])) {
	$filters['balanceStatus']=$CFG['balanceInvoices']['filters']['client']['balanceStatus'];
}

// SERVICE START DATE /////////////////////////////////////////////////////////////////////////////
$filters['serviceStartDateMysql']=standard2mysqlDateConversion($filters['serviceStartDate']);
$filters['serviceEndDateMysql']=standard2mysqlDateConversion($filters['serviceEndDate']);
if ($filters['serviceStartDateMysql'] and $filters['serviceEndDateMysql']) {
	if ($filters['serviceStartDateMysql']>$filters['serviceEndDateMysql']) {
		$filtersOK=0;
		$showMessage['warning']=$_LANG['invoices']['balanceInvoices']['clientServicesList']['filters']['servStartDateAfterEnd'];
	}
}

// TICKET START DATE //////////////////////////////////////////////////////////////////////////////
$filters['ticketStartDateMysql']=standard2mysqlDateConversion($filters['ticketStartDate']);
$filters['ticketEndDateMysql']=standard2mysqlDateConversion($filters['ticketEndDate']);
if ($filters['ticketStartDateMysql'] and $filters['ticketEndDateMysql']) {
	if ($filters['ticketStartDateMysql']>$filters['ticketEndDateMysql']) {
		$filtersOK=0;
		$showMessage['warning']=$_LANG['invoices']['balanceInvoices']['clientServicesList']['filters']['ticketStartDateAfterEnd'];
	}
}


// BREAK SPECIAL IDS (separated by '|') ///////////////////////////////////////////////////////////

// RESPONSIBLE RESERVATION USER & OFFICE ---
$resp=explode('|', $filters['resIdOfficeUser']);
$filters['resIdOffice']=$resp[0];
$filters['resIdUser']=$resp[1];

// RESPONSIBLE SERVICE USER & OFFICE ---
$resp=explode('|', $filters['servIdOfficeUser']);
$filters['servIdOffice']=$resp[0];
$filters['servIdUser']=$resp[1];

// EXTERNAL RESERVATION DATE ---
$filters['extResDateMysql']=standard2mysqlDateConversion($filters['extResDate']);

// SUPPLIER AND SUPPLIER PRODUCT
list($filters['servIdSupplier'], $filters['servIdSupplierProduct'])=explode('|', $filters['servIdSupplierAndProduct']);

// DESTINATION ---
$dest=explode('|', $filters['idDestination']);
$filters['destinationCountryCode']=$dest[0];
$filters['destinationCityId']=$dest[1];


// if some problems found...
if (!$filtersOK) {
	$OK=0;
}


?>