<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_ON"); ?><?php echo $createdDate;?></p>
        <p><?php echo __("LBL_BALANCE"); ?>: <b><?php echo $balance." ".$expense["currency"];?></b></p>
    </div>    
    
     <div class="print">
    	<?php echo __("LBL_INCOMES"); ?> <span><?php echo __("LBL_PRINTED_ON"); ?> <?php echo date("d/m/Y - H:i");?></span>
    </div>
     
    <table class="printTable">
    	<tr> 
            <th><?php echo __("LBL_FOR_WHAT_REASONS"); ?></th>
            <th><?php echo __("LBL_CATEGORY"); ?></th>
             <th><?php echo __("LBL_WHEN"); ?></th>
             <th><?php echo __("LBL_HOW_MUCH"); ?>?</th>
        </tr>
        
        <?php 
	    foreach($incomeList as $key=>$value){
	    ?>
	    	<tr> 	           
	            <td><?php echo $value["expenseName"];?></td>
	            <td><?php echo $value["expenseCategory"];?></td>
	            <td><?php echo $value["expenseDate"];?></td>	 
	             <td><?php echo $value["amount"];?><?php echo " ".$expense["currency"];?></td>            
        	</tr>
	        
	    <?php
	    }
	    ?> 
	    
	    <tr> 	           
			<td style="border:0px"> </td>
			<td  style="border:0px"> </td>
			<td  style="border:0px;text-align:right"><?php echo __("LBL_TOTAL"); ?>:</td>
			<td  style="border:0px"><b><?php echo $totalIncome." ".$expense["currency"];?></b></td>            
		</tr>
     
    </table>  
    
    <br/> 
    <div class="print">
    	<?php echo __("LBL_EXPENSE"); ?>
    </div>
	<table class="printTable table" id="exportTable">
		<thead>
    	<tr> 
            <th><?php echo __("LBL_FOR_WHAT_REASONS"); ?></th>
            <th><?php echo __("LBL_CATEGORY"); ?></th>
             <th><?php echo __("LBL_WHEN"); ?></th>
             <th><?php echo __("LBL_HOW_MUCH"); ?>?</th>
        </tr>
		</thead>
		<tbody>
        <?php 
	    foreach($expenseList as $key=>$value){
	    ?>
	    	<tr> 	           
	            <td><?php echo $value["expenseName"];?></td>
	            <td><?php echo $value["expenseCategory"];?></td>
	            <td><?php echo $value["expenseDate"];?></td>	 
	             <td><?php echo $value["amount"];?><?php echo " ".$expense["currency"];?></td>            
        	</tr>
	        
	    <?php
	    }
	    ?>
		</tbody>
		<tfoot>
	    <tr style="background: #fff;">
			<td style="border:0px"> </td>
			<td  style="border:0px"> </td>
			<td  style="border:0px;text-align:right"><?php echo __("LBL_TOTAL"); ?>:</td>
			<td  style="border:0px"><b><?php echo $totalExpense." ".$expense["currency"];?></b></td>            
		</tr>
		</tfoot>
    </table>
    
     
    <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>