<?php
$ti=time();
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=wedding_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">Wedding 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">Groom Name</th>
            <th class="align-center">Bride Name</th>
            <th class="align-center">Contact Person</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->bwh_paid_amount;
                    $part_pay_rec_no = $this->wedding_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->bwh_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 text(date('d-m-Y',strtotime($value->bwh_from_date)));?></td>
                    <td><?php echo text(date('d-m-Y',strtotime($value->created_on)));?></td>
                    <td><?php echo text($value->period_str);?></td>
                    <td><?php echo date('h:i A',strtotime($value->bwh_from_date)) . ' - ' . date('h:i A',strtotime($value->bwh_to_date));?></td>
                    <td><?php echo text($value->bwh_groom_name);?></td>
                    <td><?php echo text($value->bwh_bride_name);?></td>
                    <td><?php echo text($value->bwh_contact_name);?></td>
                    <td><?php echo text($value->bwh_contact_no);?></td>
                    <td><?php echo text($value->bwh_email);?></td>
                    <td width="15%"><?php echo text(nl2br($value->bwh_address));?></td>
                    <td width="15%"><?php echo text(nl2br($value->bwh_desc));?></td>
                    <td class="align-right"><?php echo $value->bwh_paid_amount;?></td>
                </tr>
            <?php } } ?>
        <?php } ?>
</table>