<?php
$ti=time();
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=fetival_function_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 class="align-center">Address</th>
            <th width="15%" class="align-center">Desc</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->bhm_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->bhm_rec_no;?></td>
                    <td><?php echo text($value->service_name);?></td>
                    <td><?php echo date('d-m-Y',strtotime($value->bhm_fn_from_date));?></td>
                    <td><?php echo date('d-m-Y',strtotime($value->created_on));?></td>
                    <td><?php echo text($value->deity);?></td>
                    <td><?php echo text($value->period_str);?></td>
                    <td><?php echo text(date('H:i',strtotime($value->bhm_fn_from_date)) . ' - ' . date('H:i',strtotime($value->bhm_fn_to_date)));?></td>
                    <td><?php echo text($value->bhm_name_1);?></td>
                    <td><?php echo (!empty($value->bhm_tamil_name_1)) ? '<span class="lang-tamil">' . $value->bhm_tamil_name_1 . '</span>' : 'N/A';?></td>
                    <td><?php echo text($value->star);?></td>
                    <td><?php echo text($value->bhm_name_2);?></td>
                    <td><?php echo (!empty($value->bhm_tamil_name_2)) ? '<span class="lang-tamil">' . $value->bhm_tamil_name_2 . '</span>' : 'N/A';?></td>
                    <td><?php echo text($value->star2);?></td>
                    <td><?php echo text($value->bhm_contact_no);?></td>
                    <td><?php echo text($value->bhm_email);?></td>
                    <td width="10%"><?php echo text(nl2br($value->bhm_address));?></td>
                    <td width="15%"><?php echo text(nl2br($value->bhm_desc));?></td>
                    <td class="align-right"><?php echo $value->bhm_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>