<?php
    $filename = 'sale_report_'. date('Y_m_d_h_i_s') .".xls";
    header("Content-type: application/octet-stream");
    header("Content-Disposition: attachment; filename=\"$filename\"");
    header("Content-Type: application/xls");

    $company_branch_name=$this->input->post('company_branch_name');
    $from=$this->input->post('from');
    $to=$this->input->post('to');
    $get_sale_person_firstname=$this->input->post('get_sale_person_firstname');
    $get_sale_person_lastname=$this->input->post('get_sale_person_lastname');
    $get_dispenser=$this->input->post('get_dispenser');
    $customer_id=$this->input->post('customer_id');

?>
                                  <div class="">
                                    <div><b>Searched Results</b></div>
                                    <!-- PAGE CONTENT BEGINS -->
                                    <?php if($company_branch_name!=""){?>
                                    <div class="form-group">  
                                        <label class="col-sm-5 control-label" for="form-field-2" ><?php echo 'Company Branch Name:';?> <?php echo $company_branch_name?></label>
                                    </div>
                                    <?php }
                                     if($customer_id!=""){?>
                                    <div class="form-group">  
                                        <label class="col-sm-5 control-label" for="form-field-2" ><?php echo 'Customer Name:';?> <?php echo $customer_id?></label>
                                    </div>
                                    <?php }?>									
									 <?php if($get_product_category!=""){?>
									<div class="form-group">  
                                        <label class="col-sm-5 control-label" for="form-field-2" ><?php echo 'Product Category:';?> <?php echo $get_product_category?></label>
                                    </div>
                                    <?php } ?>									
									<?php
                                     if($from!=""){
                                    ?>
                                    <div class="form-group">  
                                        <label class="col-sm-5 control-label" for="form-field-2" ><?php echo 'From:';?><?php echo $from?></label>
                                    </div>
                                    <?php }
                                     if($to!=""){
                                    ?>
                                    <div class="form-group">  
                                        <label class="col-sm-5 control-label" for="form-field-2" ><?php echo 'To:';?><?php echo $to?></label>
                                    </div>  
                                     <?php }
                                     if($get_sale_person_firstname!="" and $get_sale_person_lastname!=""){
                                    ?>
                                    <div class="form-group">  
                                        <label class="col-sm-5 control-label" for="form-field-2" ><?php echo 'Sale Person Name:';?> <?php echo $get_sale_person_firstname." ".$get_sale_person_lastname;?></label>
                                    </div>
                                    <?php }
                                     if($get_dispenser!=""){
                                    ?>
                                    <div class="form-group">  
                                        <label class="col-sm-5 control-label" for="form-field-2" ><?php echo 'Dispenser:';?><?php echo $get_dispenser;?> </label>
                                    </div>
                                <?php } ?>
                                     
                                </div> 
                                <br>
                                <br>
		<table cellspacing="0" width="100%" class="table table-bordered table-condensed">
            <thead>
                <tr>
                    <th class="text-center">Sr no</th>
                    <th class="text-center">Customer Name</th>
                    <th class="text-center">Address</th>
                    <th class="text-center">City</th>
                    <th class="text-center">Branch</th>
                    <th class="text-center">Sales Person Name</th>
                    <th class="text-center">Product Name</th>
                    <th class="text-center">Product Type</th>
                    <th class="text-center">Installation Date</th>
                    <th class="text-center">Sales Type</th>
                    <th class="text-center">Quantity</th>
                    <th class="text-center">Location</th>
                    <!--<th class="text-center">Comments</th>-->
                </tr>   
            </thead>
            <tbody>
                <?php 
                $srno=1;
                foreach ($sale_report as $value) {
                    $customer_name=$value['customer_name'];
                    $address=$value['address_line1']." ".$value['address_line2'];
                    $city_name=$value['city_name'];
                    $company_branch_name=$value['company_branch_name'];
                    $name=$value['first_name']." ".$value['last_name'];
                    $product_name=$value['product_name'];
                    $product_type=$value['product_type'];
                    $sales_type=$value['sales_type'];
                    $stock_quantity=$value['stock_quantity'];
                    $refill_location=$value['refill_location'];
                    $installation_date=$value['installation_date'];
                    $comments=$value['comments'];
                    ?>        
                <tr>
                    <td style="text-align: center;"><?php echo $srno; ?></td>
                    <td style="text-align: center;"><?php echo $customer_name;?></td>
                    <td style="text-align: center;"><?php echo $address;?></td>
                    <td style="text-align: center;"><?php echo $city_name;?></td>
                    <td style="text-align: center;"><?php echo $company_branch_name;?></td>
                    <td style="text-align: center;"><?php echo $name;?></td>
                    <td style="text-align: center;"><?php echo $product_name;?></td>    
                    <td style="text-align: center;"><?php echo $product_type;?></td>
                    <td style="text-align: center;"><?php echo $installation_date;?></td>
                    <td style="text-align: center;"><?php echo $sales_type;?></td>
                    <td style="text-align: center;"><?php echo $stock_quantity;?></td>
                    <td style="text-align: center;"><?php echo $refill_location;?></td>
                   <!-- <td style="text-align: center;"><?php echo $comments;?></td>-->
                </tr> 
               <?php 
                $srno=$srno+1;
                }
                ?>
        </tbody>
        </table>
