<?php if (file_exists($baseC) AND file_exists($fileC)) { ?>

	<div class="btn-group btn-group-justified" style="margin-bottom: 20px;">
		<a href="/<?php echo $folder; ?>/clients/?new" class="btn btn-md btn-info add-task" style="color:#fff;">Добавить</a>
		<a href="/<?php echo $folder; ?>/requests" class="btn btn-md btn-default">Запросы</a>
	</div>  

<div class="filters">
	<form method="POST" id="filter-list">
	
		<div class="panel panel-default">
			<div class="panel-heading">
				<h3 class="panel-title"><i class="fa fa-fw fa-address-book"></i> Фильтр по типу клиента</h3>
			</div>
			<div class="panel-body">
				<ul class="filter-list">
					<li><input type="radio" name="radioType" id="radioTypeUL" value="UL"/><label for="radioTypeUL"><i class="fa fa-fw fa-address-book"></i> Юридическое лицо</label><b><span class="filter-list-num"><?php echo multi_count_client('UL', '', $radioPriority); ?></span></b></li>
					<li><input type="radio" name="radioType" id="radioTypeFL" value="FL"/><label for="radioTypeFL"><i class="fa fa-fw fa-address-book-o"></i> Физическое лицо</label><b><span class="filter-list-num"><?php echo multi_count_client('FL', '', $radioPriority); ?></span></b></li>
				</ul>
			</div>
		</div>
		
		<div class="panel panel-default">
			<div class="panel-heading">
				<h3 class="panel-title"><i class="fa fa-fw fa-exclamation-triangle"></i> Фильтр по важности</h3>
			</div>
			<div class="panel-body">
				<ul class="filter-list">
					<li>
						<input type="radio" name="radioPriority" id="radioPriorityhigh" value="high"/>
						<label for="radioPriorityhigh"><i class="fa fa-fw fa-bookmark clr_high"></i> Высокая важность</label>
						<b><span class="filter-list-num"><?php echo multi_count_client($radioType, '', 'high'); ?></span></b>
					</li>
					<li>
						<input type="radio" name="radioPriority" id="radioPrioritymedium" value="medium"/>
						<label for="radioPrioritymedium"><i class="fa fa-fw fa-bookmark clr_medium"></i> Средняя важность</label>
						<b><span class="filter-list-num"><?php echo multi_count_client($radioType, '', 'medium'); ?></span></b>
					</li>
					<li>
						<input type="radio" name="radioPriority" id="radioPrioritylow" value="low"/>
						<label for="radioPrioritylow"><i class="fa fa-fw fa-bookmark clr_low"></i> Низкая важность</label>
						<b><span class="filter-list-num"><?php echo multi_count_client($radioType, '', 'low'); ?></span></b>
					</li>
					<li>
						<input type="radio" name="radioPriority" id="radioPrioritynone" value="none"/>
						<label for="radioPrioritynone"><i class="fa fa-fw fa-bookmark clr_none"></i> Важность отсутствует</label>
						<b><span class="filter-list-num"><?php echo multi_count_client($radioType, '', 'none'); ?></span></b>
					</li>
				</ul>
			</div>
		</div>
		
		<div class="panel panel-default">
			<div class="panel-heading">
				<h3 class="panel-title"><i class="fa fa-fw fa-bullhorn"></i> Источник информации</h3>
			</div>
			<div class="panel-body centered">
				<?php
				$doc = new DOMDocument;
				$doc->load($baseC);
				$xpathc = new DOMXPath($doc);
				$allclients = $xpathc->query('/clients/client');
				$sourses_arr = array();
				$i = 0;
				foreach ($allclients as $client) {
					$listSourceName = $client->getElementsByTagName("clientfined")->item(0)->nodeValue;
					$countSource = count($xmlclient->xpath('/clients/client[clientfined="'.$listSourceName.'"]'));
					$sourses_arr[$listSourceName] =  $countSource;
					$i++;
				}
				$sources = $sourses_arr;
				?>
				<canvas id="ChartClientsSource" style="z-index:1;display:block;width:100%;height:auto;min-height:100px;"></canvas>
				<script>
					var ctxclientssource = document.getElementById("ChartClientsSource").getContext('2d');
					var ChartClientsSource = new Chart(ctxclientssource, {
						type: 'horizontalBar',
						data: {
							datasets: [{
								data: [<?php foreach ($sources as $key => $value) {echo '"' . $value . '", ';} ?>],
								backgroundColor:[<?php foreach ($sources as $key => $value) {echo '"' . hexToRgb(get_color2($key).'40', true) . '", ';} ?>],
								borderColor: 	[<?php foreach ($sources as $key => $value) {echo '"' . hexToRgb(get_color2($key).'ff', true) . '", ';} ?>],
								borderWidth: 2
							}],
							labels: [<?php foreach ($sources as $key => $value) {if($key == ''){echo '"Нет данных", ';}else{echo '"' . $key . '", ';}} ?>]
						},
						options: {
							responsive: false,
							legend: {
								display: false
							},
							title: {
								display: false
							},
							animation: {
								animateScale: true,
								animateRotate: true
							}
						}
					});
				</script>
			</div>
		</div>
		
		<div class="btn-group btn-group-justified filter-buttons">
			<input type="submit" class="btn-filter btn btn-md btn-success" value="Фильтровать" name="ClientFilter" />
			<input type="submit" class="btn-freset btn btn-md btn-default" value="Сбросить" />
		</div>
		
	</form>
</div>

<?php } ?>