<?php

      include "../include/mysql.php";

        include "../include/common.php";

		 extract($_REQUEST);

        $exp=explode("***",$val);

        $itemid=$exp[0];

        $fdate=date("Y-m-d",strtotime($exp[1]));

        $tdate=date("Y-m-d",strtotime($exp[2]));

		$fdateDisplay=date("d/m/Y",strtotime($exp[1]));

		$tdateDisplay=date("d/m/Y",strtotime($exp[2]));

      
			$icondn=" where created_date between '$fdate' and '$tdate'";

			$table="<table style='width:100%;'><tr><td align='center'><b><span>அருள்மிகு மீனாட்சி சுந்தரேசுவரர் திருக்கோவில் <br>மதுரை</span> </b></td></tr><tr><td align='center'><b><span>MANUAL BOOKING CONSOLIDATED DATEWISE REPORT</span></b></td></tr><tr><td align='center'><b><span>$fdateDisplay To  $tdateDisplay</span></b></td></tr></table><br />";	

           	 $table=$table."<table id='$field_display_table' width='850px;'  border='0' class='price1' cellpadding='8' cellspacing='6' style='border-collapse:collapse;font-size:13px;'>
											<col style='width: 20%' class='col1'>
											<col style='width: 20%'>
											<col style='width: 20%'>
											<col style='width: 20%'>
											<col style='width: 20%'>	
											<col style='width: 20%'>	
										  <thead>			
												<tr>

													<th align='left' class='pdftbl' style='text-align:left;'>TicketName</th>

													<th align='left' class='pdftbl' style='text-align:left;'>Rate</th>

													<th align='right' class='pdftbl' style='text-align:right;'>Start No.</th>

													<th align='right' class='pdftbl' style='text-align:right;'>End No.</th>
													
													<th align='right' class='pdftbl' style='text-align:right;'>Sold</th>
												
													<th align='right' class='pdftbl' style='text-align:right;'>Total</th>
																								
													</thead>";

				$getinfo=$db->select(MTD,"distinct(mtid),rate",$icondn);

				$overAllTotal=0;

				while($getinfo_fetch=$db->fetch($getinfo))
				{
			
						$mtid=$getinfo_fetch[0];

						$rate=$getinfo_fetch[1];

						$tcondn=" where mtid='$mtid'";

						$ticketinfo=$db->select(MTM,"*",$tcondn);

						$ticketinfoFetch=$db->fetch($ticketinfo);

						$mtname=$ticketinfoFetch["mtname"];

						$totcondn=" where mtid='$mtid' and created_date between '$fdate' and '$tdate'";

						$totalinfo=$db->select(MTD,"sum(qty),sum(amount),min(start_no),max(end_no)",$totcondn);
						
						$totalinfofetch=$db->fetch($totalinfo);

						$qty=$totalinfofetch[0];

						$amount=$totalinfofetch[1];

						$start_no=$totalinfofetch[2];

						$end_no=$totalinfofetch[3];

						$overAllTotal=$overAllTotal+$amount;

						$table=$table."<tr><td>$mtname</td><td>$rate</td><td align='right'>$start_no</td><td align='right'>$end_no</td><td align='right'>$qty</td><td align='right'>$amount</td></tr>";

				}

				$overAllTotal=number_format($overAllTotal,2);
			
				$table=$table."<tr><td colspan='5' align='right'>Total</td><td align='right'>$overAllTotal</td></tr></table><br><br><table border='0' width='100%' style='font-weight:bold'><tr><td align='center'>உதவியாளர்</td><td align='center'>பேஷ்கார்</td><td align='center'>கண்காணிப்பாளர்</td></tr></table><br><table border='0' width='100%' style='font-weight:bold'><tr><td align='right'>கணக்காளர்</td><td align='right'>முதுநிலை கணக்கு அலுவலர்</td><td align='right'>இணை ஆணையர் / நிர்வாக அதிகாரி</td></tr></table>";  	
				

//==============================================================
//==============================================================
//==============================================================


include("mpdf.php");

$mpdf=new mPDF(); 

$mpdf->useAdobeCJK = true;		// Default setting in config.php
						// You can set this to false if you have defined other CJK fonts

$mpdf->SetAutoFont(AUTOFONT_ALL);	//	AUTOFONT_CJK | AUTOFONT_THAIVIET | AUTOFONT_RTL | AUTOFONT_INDIC	// AUTOFONT_ALL
						// () = default ALL, 0 turns OFF (default initially)

//$mpdf->mirrorMargins = 1;


/*$mpdf->pagenumPrefix = 'Page number ';
$mpdf->pagenumSuffix = ' - ';
$mpdf->nbpgPrefix = ' out of ';
$mpdf->nbpgSuffix = ' pages';

$mpdf->SetFooter('{PAGENO}{nbpg}');*/

$mpdf->WriteHTML($table);

$mpdf->Output(); 

exit;
//==============================================================
//==============================================================
//==============================================================


?>