<?
if( isset( $_POST['search'] ) AND $_POST['query'] != '' ) {
	$dom = new DOMDocument;
	$dom->load($baseR);
	$xpath = new DOMXPath($dom);
	$query	= mb_strtolower(rawurldecode($_POST['query']), 'UTF-8');
	$requests	= $xpath->query('/requests/request[contains(translate(., "ABCDEFGHJIKLMNOPQRSTUVWXYZАБВГДЕЁЖЗИКЛМНОПРСТУФХЦЧШЩЭЮЯ", "abcdefghjiklmnopqrstuvwxyzабвгдеёжзиклмнопрстуфхцчшщэюя"),"'.$query.'")]');
	$countRequest = $requests->length;
} else {
	/* Список - стандартный вид */
	$dom = new DOMDocument;
	$dom->load($baseR);
	$xpath = new DOMXPath($dom);
	$requests = $xpath->query('/requests/request');
	$countRequest = $requests->length;
}

if( isset($_GET['view']) and $_GET['view'] != '' ) {
	$dom = new DOMDocument;
	$dom->load($baseR);
	$xpath = new DOMXPath($dom);
	$requests = $xpath->query('/requests/request[@id="'.$_GET['view'].'"]');
	foreach ($requests as $request) {
		$id 		= $request->getAttribute('id');
		$name 		= $request->getElementsByTagName("uname")->item(0)->nodeValue;
		$sname 		= $request->getElementsByTagName("usname")->item(0)->nodeValue;
		$company 	= $request->getElementsByTagName("company")->item(0)->nodeValue;
		$phone 		= $request->getElementsByTagName("phone")->item(0)->nodeValue;
		$email 		= $request->getElementsByTagName("email")->item(0)->nodeValue;
		$service 	= $request->getElementsByTagName("service")->item(0)->nodeValue;
		$source 	= $request->getElementsByTagName("source")->item(0)->nodeValue;
		$web 		= $request->getElementsByTagName("web")->item(0)->nodeValue;
		$addr 		= $request->getElementsByTagName("addr")->item(0)->nodeValue;
		$date 		= $request->getElementsByTagName("date")->item(0)->nodeValue;
	}
}
?>