<?php
$ti=time();
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=outdoor_service_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">Date</th>
            <th class="align-center">Period</th>
            <th class="align-center">Time</th>
            <th class="align-center">Name</th>
            <th class="align-center">Tamil Name</th>
            <th class="align-center">Contact No 1</th>
            <th class="align-center">Contact No 2</th>
            <th class="align-center">Email</th>
            <th width="15%" class="align-center">Address</th>
            <th class="align-center">Postal Code</th>
            <th class="align-center">Priest Name</th>
            <th class="align-center">Melam</th>
            <th class="align-center">Nathaswaram</th>
            <th class="align-center">Temple Assistant Name</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->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 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_name);?></td>
                    <td><?php echo (!empty($value->tamil_name)) ? '<span class="lang-tamil">' . $value->tamil_name . '</span>' : 'N/A';?></td>
                    <td><?php echo text($value->contact_no1);?></td>
                    <td><?php echo text($value->contact_no2);?></td>
                    <td><?php echo text($value->email);?></td>
                    <td width="15%"><?php echo text(nl2br($value->address));?></td>
                    <td><?php echo text($value->postal_code);?></td>
                    <td><?php echo text($value->priest);?></td>
                    <td><?php echo text($value->melam);?></td>
                    <td><?php echo text($value->nathaswaram);?></td>
                    <td><?php echo text($value->tem_assistant);?></td>
                    <td width="15%"><?php echo text(nl2br($value->desc));?></td>
                    <td class="align-right"><?php echo $value->amount;?></td>
                </tr>
            <?php } ?>
        <?php } ?>

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