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

	$compname =  $dat['company'];
	$compaddress = $dat['email'];
	$userphone = $dat['phone'];
	$compwatermark = $dat['company']." Top-up Report";
	
	$phne = $_GET['no'];
	$name = $_GET['nm'];
	$frm = $_GET['fr'];
	$to = $_GET['to'];
	
	
	
//<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: 12pt;"  >
<tr>
<td width="20%" >
<img src="'.$photo.'" height="100px" >
</td >
<td width="12%"> </td>
<td width="70%" class="headerData" ><h2>'.$compname.'</h2><br> Email: '.$compaddress.' <br>Tel: '.$userphone.'<br>
<td> 
</tr>
<tr> <td></td><td></td> <td></td></tr>
<tr><td></td> <td></td>  <td><strong>Airtime Sent To : '.$name.' - '.$phne.': Between '.$frm.' and '.$to.'</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="25%">RequestID</td>
<td width="20%">Date</td>
<td width="10%">Airtime Sent</td>
<td width="12%">Status</td>
</tr>
</thead>
<tbody>
<!-- ITEMS HERE -->
';

    $no_ckeck = substr($phne, 0, 1);
	if ($no_ckeck == "0"){
		$pno = substr($phne, 1);
		$pno2 = "+254".$pno;
	}elseif($no_ckeck == "2"){
		//$pno = substr($phone, 3);
		$pno2 = "+".$phne;
	}elseif($no_ckeck == "7"){
		$pno2 = "+254".$phne;
	}

 $num = 0; 
 
 		$getrecordsx = mysql_query("select * from airtime_sending_records where customer_id = '$session_id' and (date_sent BETWEEN CAST('$frm' AS DATE) and CAST('$to' AS DATE) ) and (recipient = '$phne' or recipient = '$pno2') order by date_sent DESC ");
                                                   	
		if(mysql_num_rows($getrecordsx) > 0 ){	
			
			while($dt=mysql_fetch_array($getrecordsx)) { 
			  $num++;
			  
				$html .= '
					<tr>
						<td align="center">'.$num.'</td>
						<td>'.$dt['requestid'].'</td>
						<td>'.$dt['date_sent'].'</td>
						<td>'.$dt['airtime_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-P','','',20,15,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;

?>