<?
if(isset($_POST["checkYear"])){ $sel_year = date("Y",strtotime($_POST['selectYear'])); } else { $sel_year = date("Y");}
if(isset($_POST["checkYear"]) and $_POST['selectYear'] != date("Y")){ $count_month = '12'; } else { $count_month = date("n");}
		
$dom 	= new DOMDocument;
$dom	->load($baseP);
$xpath 	= new DOMXPath($dom);

$f_type = '@type';
$f_year = ' and datey="'.$sel_year.'"';

$selectType 	= '';
$selectStatus 	= '';

if(isset($_POST['search'])) {
	$query			= mb_strtolower(rawurldecode($_POST['query']), 'UTF-8');
	$payments		= $xpath->query('/payments/payment[contains(translate(., "ABCDEFGHJIKLMNOPQRSTUVWXYZАБВГДЕЁЖЗИКЛМНОПРСТУФХЦЧШЩЭЮЯ", "abcdefghjiklmnopqrstuvwxyzабвгдеёжзиклмнопрстуфхцчшщэюя"),"'.$query.'")]');
	$countPayment 	= $payments->length;
} elseif( isset( $_POST['DealFilter'] ) ) {
	
	if(isset($_POST["checkYear"])) {
		echo '
		<script>
			$(document).ready(function() {
				$("form#filter-list input[name=checkYear]").prop("checked", true);
				$("form#filter-list select[name=selectYear]").prop("disabled",false);
				$("form#filter-list option[value=\''.$_POST['selectYear'].'\']").prop("selected", true);
			});
		</script>
		';
	}
	
	if(isset($_POST["radioType"])) {
		
		if($_POST["radioType"] == 'allType'){
			$f_type 	= ' and @type';
		} else {
			$f_type 	= ' and @type="'.$_POST["radioType"].'"';
		}
		$selectType	= $_POST["radioType"];
		echo '<script>$(function() {$("form#filter-list input[value*=\''.$selectType.'\']").prop("checked", true); $(".filter-buttons").fadeIn("500");});</script>';
	} else {
		$f_type = '';
	}
	
	if(isset($_POST["radioStatus"])) {
		if($_POST["radioStatus"] == 'allStatus'){
			$f_status 	= ' and @status';
		} else {
			$f_status 	= ' and @status="'.$_POST["radioStatus"].'"';
		}
		$selectStatus	= $_POST["radioStatus"];
		echo '<script>$(function() {$("form#filter-list input[value*=\''.$selectStatus.'\']").prop("checked", true); $(".filter-buttons").fadeIn("500");});</script>';
	} else {
		$f_status = '';
	}
	
	if(isset($_POST["checkCom"])) {
		if($_POST["selectCom"] == 'all'){
			$f_com 	= '';
		} else {
			$f_com 	= ' and com="'.$_POST["selectCom"].'"';
		}
		echo '
		<script>
			$(document).ready(function() {
				$("form#filter-list input[name=checkCom]").prop("checked", true);
				$("form#filter-list select[name=selectCom]").prop("disabled",false);
				$("form#filter-list option[value=\''.$_POST["selectCom"].'\']").prop("selected", true);
			});
		</script>
		';
	} else {
		$f_com = '';
	}

	$payments 		= $xpath->query('/payments/payment[@id'.$f_type.$f_status.$f_com.$f_year.']');
	$countPayment 	= $payments->length;
} else {
	$payments 		= $xpath->query('/payments/payment[@id'.$f_year.']');
	$countPayment 	= $payments->length;
}
?>