<?php
include('../config.php');
include('../units.php');
$zapicey=0;
$sql = "SELECT id, number, IFNULL((SELECT fio FROM klients WHERE discount_card.id_klients=klients.id),'Ничья') AS klient FROM discount_card WHERE 1";

echo ' <table class="nice_table" cellspacing=1 cellpadding=2>
	<TR>
        <Th bgcolor="#C4D9F7">id</Th>
        <Th bgcolor="#C4D9F7">Карта</Th>
        <Th bgcolor="#C4D9F7">Клиент</Th>
        <Th bgcolor="#C4D9F7">Скидка</Th>
	</TR>';
foreach ($db->query($sql) as $row) {
	$mcolor='FBFCE8';
	echo '<tr bgcolor=#'.$mcolor.' onclick="LoadDiscoundInfo(this)">'.
//	'<td><font color=gray>'.$row['id'].'</font></td>'.
	'<td>'.$row['id'].'</td>'.
	'<td><b>'.$row['number'].'</b></td>'.
	'<td>'.$row['klient'].'</td>'.
	'<td>'.GetSkidka($row['id']).' %</td>'.
	'</tr>';
	$zapicey++;
	}
echo '</TABLE>';
echo '<div id="container" align="left">&nbsp;Записей: '.$zapicey.' </div>';

?>
