<?php
$ti=time();
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=ubayam_report".$ti.".xls");
header("Pragma: no-cache");
header("Expires: 0");
?>
<table class="table table-bordered table-striped filterTable" id="filterTable">
        <tr>
            <th width="5%" class="align-center">S.No</th>
            <th class="align-center">Receipt No</th>
            <th class="align-center">Type</th>
            <th class="align-center">Function Date</th>
            <th class="align-center">Booked Date</th>
            <th class="align-center">Deity</th>
            <th class="align-center">Period</th>
            <th class="align-center">Time</th>
            <th class="align-center">Name 1</th>
            <th class="align-center">Tamil Name 1</th>
            <th class="align-center">Star 1</th>
            <th class="align-center">Name 2</th>
            <th class="align-center">Tamil Name 2</th>
            <th class="align-center">Star 2</th>
            <th class="align-center">Contact No</th>
            <th class="align-center">Email</th>
            <th width="15%" class="align-center">Desc</th>
            <th width="15%" class="align-center">Address</th>
            <th class="align-center">Amount</th>
        </tr>

		 <?php if(count($results) > 0) {  $total_amt = 0;?>
			<?php foreach($results as $key=>$value) {
                    $total_amt += $value->amount;
                    $tooltip = ($value->status == 2) ? $value->del_reason : '';
                ?>
                <tr data-toggle="tooltip" title="<?php echo $tooltip;?>">
                    <td class="align-center"><?php echo ++$key;?></td>
                    <td><?php echo (($general->prefix == 1) ? $value->prefix : '') . $value->receipt_no;?></td>
                    <td><?php echo text($value->service_name);?></td>
                    <td><?php echo text(date('d-m-Y',strtotime($value->date)));?></td>
                    <td><?php echo date('d-m-Y',strtotime($value->created_on));?></td>
                    <td><?php echo $value->deity;?></td>
                    <td><?php echo text($value->period_str);?></td>
                    <td><?php echo text(date('H:i',strtotime($value->from_time)) . ' - ' . date('H:i',strtotime($value->to_time)));?></td>
                    <td><?php echo text($value->devotee_name1);?></td>
                    <td><?php echo (!empty($value->tamil_name1)) ? '<span class="lang-tamil">' . $value->tamil_name1 . '</span>' : 'N/A';?></td>
                    <td><?php echo text($value->star);?></td>
                    <td><?php echo text($value->devotee_name2);?></td>
                    <td><?php echo (!empty($value->tamil_name2)) ? '<span class="lang-tamil">' . $value->tamil_name2 . '</span>' : 'N/A';?></td>
                    <td><?php echo text($value->star2);?></td>
                    <td><?php echo text($value->contact_no);?></td>
                    <td><?php echo text($value->email);?></td>
                    <td width="15%"><?php echo text(nl2br($value->desc));?></td>
                    <td width="15%"><?php echo text(nl2br($value->address));?></td>
                    <td class="align-right"><?php echo $value->amount;?></td>
                </tr>
            <?php } ?>
        <?php } ?>

		<?php if(!empty($total_amt)) { ?>
            <tr>
                <td colspan="18" align="right"><b>Total</b></td>
                <td align="right"><b><?php echo number_format($total_amt,2,'.','');?></b></td>
            </tr>
        <?php } ?>
</table>