<?
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($baseV);
$xpath 	= new DOMXPath($dom);
	
$f_year = ' and datey="'.$sel_year.'"';
	
if(isset($_POST['search'])) {
	$query			= mb_strtolower(rawurldecode($_POST['query']), 'UTF-8');
	$vacations		= $xpath->query('/vacations/vacation[contains(translate(., "ABCDEFGHJIKLMNOPQRSTUVWXYZАБВГДЕЁЖЗИКЛМНОПРСТУФХЦЧШЩЭЮЯ", "abcdefghjiklmnopqrstuvwxyzабвгдеёжзиклмнопрстуфхцчшщэюя"),"'.$query.'")]');
	$countvacation 	= $vacations->length;
} elseif( isset( $_POST['VacationsFilter'] ) ) {
	
	/* Список - после фильтрации */
	if( isset( $_POST["radioUser"] ) ) {
		$filterUser 	= ' and @user="'.$_POST["radioUser"].'"';
		$selectUser 	= $_POST["radioUser"];
		echo '<script>$(function() {$("form#filter-list input[value*=\''.$_POST["radioUser"].'\']").prop("checked", true); $(".filter-buttons").fadeIn("500");});</script>';
	} else {
		$filterUser 	= '';
		$selectUser 	= '';
	}
	
	if( isset( $_POST["radioType"] ) ) {
		$filterType = '@type="'.$_POST["radioType"].'"';
		$selectType = $_POST["radioType"];
		echo '<script>$(function() {$("form#filter-list input[value*=\''.$_POST["radioType"].'\']").prop("checked", true); $(".filter-buttons").fadeIn("500");});</script>';
	} else {
		$filterType = '@type';
		$selectType 	= '';
	}
	
	if(isset($_POST["checkYear"])) {
		echo '<script>$(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>';
	}
	
	$vacations 		= $xpath->query('/vacations/vacation['.$filterType.$filterUser.$f_year.']');
	$countvacation 	= $vacations->length;
} elseif(isset($_GET['id'])){
	$vacations		= $xpath->query('/vacations/vacation[@id="'.$_GET["id"].'"]');
	$countvacation 	= $vacations->length;
	$selectUser 	= '';
	$filterType = '@type';
	$selectType 	= '';
} else {
	$vacations 		= $xpath->query('/vacations/vacation[@type '.$f_year.']');
	$countvacation 	= $vacations->length;
	$selectUser 	= '';
	$filterType = '@type';
	$selectType 	= '';
}
?>
