<?php
include_once('details.php');

	$compname =  $dat['company'];
	$compaddress = $dat['email'];
	$userphone = $dat['phone'];
	$compwatermark = $dat['company']." Top-up Report";
	
	$gid = $_GET['id'];
	$gname = $_GET['nm'];
	
//<img src="images/logo.png" height="100px;">

$html = '
<html>
<head>
<style>
body {font-family: sans-serif;
	font-size: 10pt;
}
p {	margin: 0pt; }
table.items {
	border: 0.1mm solid #000000;
}
td { vertical-align: top; }
.items td {
	border-left: 0.1mm solid #000000;
	border-right: 0.1mm solid #000000;
}
table thead td { background-color: #EEEEEE;
	text-align: center;
	border: 0.1mm solid #000000;
	font-variant: small-caps;
}
.items td.blanktotal {
	background-color: #EEEEEE;
	border: 0.1mm solid #000000;
	background-color: #FFFFFF;
	border: 0mm none #000000;
	border-top: 0.1mm solid #000000;
	border-right: 0.1mm solid #000000;
}
.items td.totals {
	text-align: right;
	border: 0.1mm solid #000000;
}
.items td.cost {
	text-align: "." center;
}
</style>
</head>
<body>

<!--mpdf
<htmlpageheader name="myheader">
<table  width="100%" style="font-size: 11pt;"  >
<tr>
<td width="15%">
<img src="'.$photo.'" height="100px;" style="margin-right:50px;" >
</td>
<td width="70%" class="headerData" ><h2>'.$compname.'</h2><br> Email: '.$compaddress.' <br>Tel: '.$userphone.'<br>
<td>
</tr>
<tr> <td></td><td></td> </tr>
<tr><td></td>   <td><strong>Airtime Topup Report: Airtime Sent To Group : '.$gname.'</strong></td></tr>
</table>
</htmlpageheader>

<htmlpagefooter name="myfooter">
<div style="border-top: 1px solid #000000; font-size: 9pt; text-align: center; padding-top: 3mm; ">
Page {PAGENO} of {nb}
</div>
</htmlpagefooter>

<sethtmlpageheader name="myheader" value="on" show-this-page="1" />
<sethtmlpagefooter name="myfooter" value="on" />
mpdf-->



<table class="items" width="100%" style="font-size: 9pt; border-collapse: collapse; " cellpadding="8">
<thead>
<tr>
<td width="8%"> No.</td>
<td width="20%">Name</td>
<td width="15%">Contact</td>
<td width="10%">Airtime Sent</td>
<td width="20%">Date Sent</td>
<td width="12%">Status</td>
</tr>
</thead>
<tbody>
<!-- ITEMS HERE -->
';

 $num = 0; 
 
 	$sql = mysql_query("select airtime_sending_records.r_id, airtime_sending_records.airtime_sent, airtime_sending_records.recipient, airtime_sending_records.date_sent, airtime_sending_records.status, airtime_contacts.fname, airtime_contacts.contact, airtime_groups.name from airtime_sending_records inner join airtime_contacts on concat('+254',substr(airtime_sending_records.recipient,-9)) = concat('+254',substr(airtime_contacts.contact,-9)) inner join airtime_groups on airtime_contacts.group_id = airtime_groups.group_id where airtime_sending_records.customer_id = '$session_id' and airtime_contacts.group_id = '$gid' order by date_sent desc ");
                                                   	
		if(mysql_num_rows($sql) > 0 ){
						
			while($dt=mysql_fetch_array($sql)) { 
			  $num++;
			  
				$html .= '
					<tr>
						<td align="center">'.$num.'</td>
						<td>'.$dt['fname'].'</td>
						<td >'.$dt['recipient'].' </td>
						<td>'.$dt['airtime_sent'].'</td>
						<td >'.$dt['date_sent'].' </td>
						<td >'.$dt['status'].' </td>
					</tr>
					';
			}
		}
		$html .= '

<!-- END ITEMS HERE -->


</tbody>
</table>



</body>
</html>
';
//==============================================================
//==============================================================
//==============================================================
//==============================================================
//==============================================================
//==============================================================

define('_MPDF_PATH','/');
include("mpdf.php");

$mpdf=new mPDF('c','A4-L','','',25,20,48,25,10,10); 

$mpdf->allow_charset_conversion=true;
$mpdf->charset_in='ISO-8859-2';
$mpdf->SetProtection(array('print'));
$mpdf->SetTitle("".$compwatermark."");
$mpdf->SetAuthor("".$compwatermark."");
$mpdf->SetWatermarkText("".$compwatermark."");
$mpdf->showWatermarkText = true;
$mpdf->watermark_font = 'DejaVuSansCondensed';
$mpdf->watermarkTextAlpha = 0.1;
$mpdf->SetDisplayMode('fullpage');
$mpdf->WriteHTML($html);


$mpdf->Output();

exit;

?>