
<script>
function printPage(){
window.print();
}
</script>
<div id="exportPrintTable">
<div class="wrapper">
	<p><a href="<?php echo $this->webroot; ?>"><img src="<?php echo CDN_URL; ?><?php echo __('LBL_LOGO_PDF');?>" width="270" height="72"  alt=""/></a> </p>
    <div class="description">
        <p><strong> ExpenseCount "<?php echo $expense["title"];?>"</strong></p>
        <?php if(isset($expense["description"])){ ?>
        <p><?php echo $expense["description"];?></p>
        <?php } ?>
        <p><?php echo __("LBL_CREATED_BY"); ?>  <?php echo $createdBy;?>, <?php echo __('LBL_ON'); ?> <?php echo $createdDate;?></p>
    </div>    
    <div class="print">
    	<?php echo __("LBL_PRINTED_BY"); ?> <?php echo $printedBy;?> <span><?php echo date("d/m/Y - H:i");?></span>
    </div>
    <p><?php echo $printedBy;?> <?php echo __("LBL_SHOULD_VERIFY"); ?></p>
    
    <table class="printTable table" id="exportTable">
		<thead>
    	<tr>
        	<th><?php echo __("LBL_DATE"); ?></th>
            <th><?php echo __("LBL_DAY"); ?></th>
            <th><?php echo __("LBL_BREAKFAST"); ?></th>
            <th><?php echo __("LBL_LUNCH"); ?></th>
             <th><?php echo __("LBL_DINNER"); ?></th>
            <th><?php echo __("LBL_TOTAL"); ?></th>
        </tr>
		</thead>
		<tbody>
        <?php 
         $subtotal = 0;
	    foreach($expenseList as $key=>$value){
	    
	      $total = $value["breakfast"]+$value["lunch"]+$value["dinner"];
	    $subtotal =  $subtotal + $total;
	    ?>
	    	<tr>
	        	<td align="center"><?php echo $value["date"];?></td>
	            <td align="center"><?php echo $value["day"];?></td>
	            <td align="center"><?php echo $value["breakfast"];?></td>
	            <td align="center"><?php echo $value["lunch"];?></td>
	             <td align="center"><?php echo $value["dinner"];?></td>
	            <td align="center"><?php echo $total;?></td>	            
        	</tr>
	        
	    <?php
	    }
	    ?>
		</tbody>
		<tfoot>
        <tr style="background: transparent;">
			<td style="border:0" align="center"> </td>
			<td style="border:0"  align="center"> </td>
			<td style="border:0" align="center"> </td>
			<td style="border:0" align="center"> </td>
			 <td style="border:0;font-weight: bold;" align="right"> <?php echo __("LBL_SUBTOTAL"); ?> : </td>
			<td align="center" style="border:0;font-weight:bold;"> <?php echo $subtotal;?> </td>
		</tr>
		</tfoot>
    </table>
    
    <div class="description">
    	<p><strong><u><?php echo __("LBL_MEAL_SUMMARY"); ?>:</u></strong></p>
    	<table style="font-size:12px;">
    		<tr><td><?php echo __("LBL_TOTAL_MEAL"); ?>: </td><td><b><?php echo $balanceArray[0];?>,</b></td><td><?php echo __("LBL_TOTAL_COST"); ?>: </td><td><b><?php echo $balanceArray[2]." ".$expense["currency"];?></b></td></tr>
    		<?php if($balanceArray[0] > 0){ ?>
    			<tr><td colspan="4"><?php echo __(LBL_HENCE_PER_COST); ?>:(<?php echo $balanceArray[2];?> / <?php echo $balanceArray[0];?>) = <b> <?php echo round($balanceArray[2]/$balanceArray[0],2)." ".$expense["currency"];?></b></td></tr>
    		<?php } else { ?>
    			<tr><td colspan="4"><?php echo __(LBL_HENCE_PER_COST); ?>:<b><?php echo "0.00".$expense["currency"];?></b></td></tr>
    		<?php } ?>
    	</table>
     	 
    </div>
    <div class="footerText"><?php echo __('LBL_ADD_MODIFY_DELETE_MEAL_NECESSARY'); ?><br/>
    <?php echo __("LBL_CLICK"); ?> <a href="#" style="cursor:pointer" onclick="printPage()"> <?php echo __("LBL_HERE"); ?></a> <?php echo __("LBL_TO_PRINT_THE_PAGE"); ?>.</div>
	<div class="footer-pdf-print-link hidden-print">
		<a href="#" onclick="printPage()" class="btn btn-info"><?php echo __("LBL_PRINT"); ?></a>
		<form action="<?php echo $this->Html->url(array('controller'=>'Expense','action'=>'generatePdf'));?>" class="form-inline" method="post" id="generatePdf">
			<input type="hidden" name="whole_content" id="wholeContent">
			<div class="form-group">
				<button type="submit" class="btn btn-info" id="generatePdfBtn"><?php echo __("LBL_DOWNLOAD"); ?></button>
			</div>
		</form>
	</div>
</div>
</div>
<script>
    $(document).ready(function(){
        $('#exportTable').DataTable({
            "paging":   false,
            "searching": false,
            "info":     false
        });
        $("#generatePdfBtn").on('click', function () {
            var Content = $('#exportPrintTable').html();
            var ContentWrap = "<!doctype html><html><body>"+Content+"</body></html>";
            var currentHtml = $("#wholeContent").val(ContentWrap);
            // alert($("#wholeContent").val());
            $("form#generatePdf").submit();
        })
    });
</script>