<?
if( isset( $_POST['search'] ) ) {
	$dom = new DOMDocument;
	$dom->load($baseT);
	$xpath = new DOMXPath($dom);
	$query	= mb_strtolower(rawurldecode($_POST['query']), 'UTF-8');
	$tasks	= $xpath->query('/tasks/task[@status="done" and contains(translate(., "ABCDEFGHJIKLMNOPQRSTUVWXYZАБВГДЕЁЖЗИКЛМНОПРСТУФХЦЧШЩЭЮЯ", "abcdefghjiklmnopqrstuvwxyzабвгдеёжзиклмнопрстуфхцчшщэюя"),"'.$query.'")]');
	$countTaskStatusDone 	= count($xmltask->xpath('/tasks/task[@status="done" and contains(translate(., "ABCDEFGHJIKLMNOPQRSTUVWXYZАБВГДЕЁЖЗИКЛМНОПРСТУФХЦЧШЩЭЮЯ", "abcdefghjiklmnopqrstuvwxyzабвгдеёжзиклмнопрстуфхцчшщэюя"),"'.$query.'")]'));
} elseif( isset( $_POST['TaskFilter'] ) ) {
	/* Список - после фильтрации */
	if( isset( $_POST["selectDeal"] ) ) {
		$filterDeal 	= ' and @deal="'.$_POST["selectDeal"].'"';
		echo '<script>$(document).ready(function() {$("form#filter-list input[name=checkDeal]").prop("checked", true);$("form#filter-list select[name=selectDeal]").prop("disabled",false); $("form#filter-list option[value=\''.$_POST["selectDeal"].'\']").prop("selected", true);});</script>';
	} else {
		$filterDeal 	= '';
	}
	if( isset( $_POST["radioUser"] ) ) {
		$filterUser 	= ' and @deligated="'.$_POST["radioUser"].'"';
		echo '<script>$(function() {$("form#filter-list input[value*=\''.$_POST["radioUser"].'\']").prop("checked", true);$(".filter-buttons").fadeIn("500");});</script>';
	} else {
		$filterUser 	= '';
	}
	if( isset( $_POST["radioPriority"] ) ) {
		$filterPriority = ' and @priority="'.$_POST["radioPriority"].'"';
		echo '<script>$(function() {$("form#filter-list input[value*=\''.$_POST["radioPriority"].'\']").prop("checked", true);$(".filter-buttons").fadeIn("500");});</script>';
	} else {
		$filterPriority = '';
	}
	$dom = new DOMDocument;
	$dom->load($baseT);
	$xpath = new DOMXPath($dom);
	$tasks = $xpath->query('/tasks/task[@status="done"'.$filterDeal.$filterUser.$filterPriority.']');
	$countTaskStatusDone 	= count($xmltask->xpath('/tasks/task[@status="done"'.$filterDeal.$filterUser.$filterPriority.']'));
} else {
	/* Список - стандартный вид */
	$dom = new DOMDocument;
	$dom->load($baseT);
	$xpath = new DOMXPath($dom);
	$tasks = $xpath->query('/tasks/task[@status="done"]');
	$countTaskStatusDone 	= count($xmltask->xpath('/tasks/task[@status="done"]'));
}
?>