<?php
$ti=time();
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=hall_booking_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">Event Date</th>
            <th class="align-center">Booked Date</th>
            <th class="align-center">Period</th>
            <th class="align-center">Time</th>
            <th class="align-center">Event Type</th>
            <th class="align-center">Name</th>
            <th class="align-center">Tamil Name</th>
            <th class="align-center">Contact No</th>
            <th class="align-center">Email</th>
            <th width="15%" 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; $ii =0;?>
			<?php foreach($results as $key=>$value) {
                if($value->self_id == '') {
                    $total_amt += $value->bh_paid_amount;
                    $tooltip = ($value->status == 2) ? $value->del_reason : '';
                    $part_pay_rec_no = $this->hall_booking_report_model->get_part_pay_rec_no($value->id); 
                    $rec_no = explode(',',$part_pay_rec_no->receipt_no);  $Receipt = '';
                    foreach($rec_no as $no) {
                        if(!empty($no)) {
                            $Receipt .= ((($general->prefix == 1) ? $value->prefix : '') . trim($no));
                            $Receipt .= ',';
                        }                                                
                    }
                    $Rec = rtrim($Receipt,',');
                ?>
                <tr>
                    <td class="align-center"><?php echo ++$ii;?></td>
                    <td><?php echo (($general->prefix == 1) ? $value->prefix : '') . $value->bh_rec_no . '<span style="color: #999; font-size: 11px;" data-toggle="tooltip" title="Rec.No for Part Paid">' . ((!empty($Rec)) ? ' (' . $Rec . ')' : '') . '</span>';?></td>
                    <td><?php echo text($value->service_name);?></td>
                    <td><?php echo date('d-m-Y',strtotime($value->bh_from_date));?></td>
                    <td><?php echo date('d-m-Y',strtotime($value->created_on));?></td>
                    <td><?php echo $value->period_str;?></td>
                    <td><?php echo date('h:i A',strtotime($value->bh_from_date)) . ' - ' . date('h:i A',strtotime($value->bh_to_date));?></td>
                    <td><?php echo text($value->bh_evt_type);?></td>
                    <td><?php echo text($value->bh_name);?></td>
                    <td><?php echo (!empty($value->bh_tamil_name)) ? '<span class="lang-tamil">' . $value->bh_tamil_name . '</span>' : 'N/A';?></span></td>
                    <td><?php echo text($value->bh_contact_no);?></td>
                    <td><?php echo text($value->bh_email);?></td>
                    <td width="15%"><?php echo text(nl2br($value->bh_address));?></td>
                    <td width="15%"><?php echo text(nl2br($value->bh_desc));?></td>
                    <td class="align-right"><?php echo $value->bh_paid_amount;?></td>
                </tr>
            <?php } }?>
        <?php } ?>	
</table>