<?php

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

// INVOICE DATE ///////////////////////////////////////////////////////////////////////////////////
$filters['invoiceStartDateMysql']=standard2mysqlDateConversion($filters['invoiceStartDate']);
$filters['invoiceEndDateMysql']=standard2mysqlDateConversion($filters['invoiceEndDate']);
if (!$filters['invoiceStartDateMysql'] or !$filters['invoiceEndDateMysql']) {
	$filtersOK=0;
	$showMessage['warning']=$_LANG['invoices']['balanceInvoices']['supplierInvoiceList']['warnings']['mandatoryInterval'];
}
if ($filters['invoiceStartDateMysql'] and $filters['invoiceEndDateMysql']) {
	if ($filters['invoiceStartDateMysql']>$filters['invoiceEndDateMysql']) {
		$filtersOK=0;
		$showMessage['warning']=$_LANG['invoices']['balanceInvoices']['supplierInvoiceList']['warnings']['invoiceStartDateAfterEndDate'];
	}
}

// INVOICE DUE DATE ///////////////////////////////////////////////////////////////////////////////
$filters['dueStartDateMysql']=standard2mysqlDateConversion($filters['dueStartDate']);
$filters['dueEndDateMysql']=standard2mysqlDateConversion($filters['dueEndDate']);
if ($filters['dueStartDateMysql'] and $filters['dueEndDateMysql']) {
	if ($filters['dueStartDateMysql']>$filters['dueEndDateMysql']) {
		$filtersOK=0;
		$showMessage['warning']=$_LANG['invoices']['balanceInvoices']['supplierInvoiceList']['warnings']['dueStartDateAfterEndDate'];
	}
}

// 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']['supplierInvoiceList']['warnings']['serviceStartDateAfterEndDate'];
	}
}

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

// RESPONSIBLE USER & OFFICE ---
$resp=explode('|', $filters['invoiceIdOfficeUser']);
$filters['invoiceIdOffice']=$resp[0];
$filters['invoiceIdUser']=$resp[1];

// SUPPLIER & SUPPLIER SERVICE ---
$supp=explode('|', $filters['idSupplierAndService']);
$filters['idSupplier']=$supp[0];
$filters['idSupplierService']=$supp[1];

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

// STATUS OP/FIN
$sts=explode('|', $filters['status']);
$filters['statusOp']=$sts[0];
$filters['statusFin']=$sts[1];

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

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

?>