<?php
	include('common/header.php');
?>
<div id="messages" style="color: green;"><h5><?php echo $this->session->flashdata('message'); ?></h5></div>
<div class="row">
  <section class="panel panel-default">
     <header class="panel-heading bg-info lt font-bold"><?php echo 'Search results'; ?></header>
    <form method="post" action="<?php echo base_url()?>index.php/<?php echo CUSTOMER_MASTER;?>list_customer_master">

    <div class="panel-body bs-example form-horizontal">
     <div class="col-sm-12" >                                             
                          <div class="col-sm-6">
                            <div class="form-group" id="client_code">
                              <label for="client_code" class="col-sm-3 control-label required"><?php echo 'Customer Name'; ?>:</label>
                              <div class="col-sm-7">
                                <select class="select2 select2-multiple form-control" name="customer_id" id="customer_id" style="width: 250px;">
                                </select>
                                
                              </div>
                            </div>
                          </div>

                        <div class="col-sm-6">
                           <div class="form-group">
                              <label for="client_code" class="col-sm-3 control-label required"><?php echo 'Sale Person Name'; ?>:</label>
                                <div class="col-sm-7">
                                 
                                <input type="text" name="cutomer_sale_person" onkeypress="return RestrictSpace()" value="" id="cutomer_sale_person" placeholder="Sale Person Name" class="form-control" maxlength="75" /> 
                                  
                                 </div>
                              
                            </div>
                          </div> 
        </div>
        <div class="col-sm-12">
                      <div class="col-sm-6">    
                           <div class="form-group" id="client_code">
                            <label for="client_code" class="col-sm-3 control-label required"><?php echo 'Mobile No'; ?>:</label>
                              <div class="col-sm-7">   
                                <input type="text" name="cutomer_mobile" onkeypress="return RestrictSpace()" value="" id="cutomer_mobile" placeholder="Mobile Number" class="form-control" maxlength="10">
                                                                        
                              </div>   
                            </div>                         
                      </div>
                      <div class="col-sm-6">    
                       <div class="form-group">
                                <label for="client_code" class="col-sm-3 control-label required"><?php echo 'Email Id'; ?>:</label>
                              <div class="col-sm-7">                             
                                <input type="text" name="cutomer_email" onkeypress="return RestrictSpace()" value="" id="cutomer_email" placeholder="Email Id" class="form-control" maxlength="75" />                                        
                              </div>
                       </div>                            
                     </div>
        </div>

    </div>
    <div class="clearfix form-actions">
      <div class="col-md-offset-5 col-md-5">
        <button class="btn btn-info" type="submit" value="search" name="search">
         Search
        </button>
      </div>
    </div>
</form>
  </section>
</div>
<div class="row">
 <div class="col-xs-12">
      <section class="panel panel-default">
     <form method="post" action="<?php echo base_url();?>index.php/gc/customer_master/excel_list">
      <input type="hidden" name="excel" value="1">
        <div class="panel-body bs-example form-horizontal">
          <div class="table-responsive">
            <table  class="table table-bordered" cellspacing="0" width="100%">
              <thead>
        <tr>
          <th>Sr No</th>
		      <th>Branch Company Name</th>
          <th>Customer</th>
          <th>Customer Contact Name</th>
          <th>Sales Person Name</th>
          <th>City</th>
          <th>Address</th>
          <th>Pincode</th>
          <th>Contact Number</th>         
          <th>Email Id</th>         
          <th>Date of Enrollment</th>
          <th>Action</th>
        </tr> 
      </thead>
      <tbody>  
       <?php 
     $icnt=0;
     $count=count($customer);
       foreach ($customer as  $value) {
         $customer_id=$value->customer_id;		 
         $id=$this->encrypt->encode($customer_id);
         $customer_name=$value->customer_name;
         $company_branch_name=$value->company_branch_name;
         $city_name=$value->city_name;
         $email_id=$value->email_id;
         $date_of_enrollment=$value->date_of_enrollment;
         $is_active=$value->is_active;
         $contact_person_name=$value->contact_person_name;
         $first_name=$value->first_name;
         $address_line1=$value->address_line1;
         $address_line2=$value->address_line2;
         $postal_code=$value->postal_code;
         $mobile_no=$value->mobile_no;
         $icnt++;
        $sr=$offset+$icnt;
       ?>     
        <tr>
          <td><?php echo $sr; ?></td>
		  <td><?php echo $company_branch_name;?></td> 
          <td><?php echo $customer_name;?></td>  
          <td><?php echo $contact_person_name;?></td>
          <td><?php echo $first_name;?></td>
          <td><?php echo $city_name;?></td>
          <td><?php echo $address_line1." ".$address_line2;?></td>
          <td><?php echo $postal_code;?></td>
          <td><?php echo $mobile_no;?></td>
          <td><?php echo $email_id;?></td>
          <td><?php echo $date_of_enrollment;?></td>
         <td>
            <b><a href="<?php echo base_url();?>index.php/gc/customer_master/view_customer_master/<?php echo $id?>">View</a> | <a href="<?php echo base_url();?>index.php/gc/customer_master/manage_customer_master/<?php echo $id ?>"> Edit |
             <?php if($is_active==0) {?>
                 <a href="<?php echo base_url();?>index.php/gc/customer_master/enable_customer_master/<?php echo $id ?>">Enable</a></b><?php }else{?>
                 <a href="<?php echo base_url();?>index.php/gc/customer_master/disable_customer_master/<?php echo $id ?> " onclick="return confirm('Are you sure you want to Disable?')">Disable</a></b><?php } ?>

          </td>
        </tr> 
        <?php 
         $srno=$srno+1;
       }
         ?>
        </tbody>
            </table>
          </div>
           <?php
     if($num_results > 0) { ?>
      <div class="block"> </div>
        <div class="clearfix">
        <div class="row">
          <?php 
            if (strlen($pagination)): 
              $label_disp="Customer";
              $data['label_disp']=$label_disp;
              $data['count']=$count;
              $this->load->view('pagination_view.php',$data);
            endif; ?>
            </div>
        </div>
          <div class="block"> </div>
      <?php } ?>
   <!--   </div> -->
      </section>

		<div class="clearfix form-actions">
			<div class="col-md-offset-5 col-md-5">
				<button class="btn btn-info" type="button" onclick="javascript:window.location='<?php echo base_url();?>index.php/gc/customer_master/manage_customer_master'">
					Add Customer 
				</button>
        <button class="btn btn-info" type="submit">
         Export to Excel
        </button>
			</div>
		</div>
    </form>
	</div>
</div>
<div>
	<!-- /.page-row -->
    <!-- /.page-content --> 
</div>
<!-- /.main-content --> 
</div>
<!-- /#ace-settings-container --> 
</div>
<!-- /.main-container-inner -->
<?php
	include('common/footer.php');
?>
<script>
  $(".select2").select2();  
  $(".select2").prop("multiple", "");

   $("#customer_id").select2({
     tags: true,
    multiple: false,
    //tokenSeparators: [',', ' '],
    minimumInputLength: 3,
    minimumResultsForSearch: 10, 
    ajax: {
      url: '<?php echo base_url();?>index.php/gc/refill_sale_data/customer',
      dataType: "json",
      type: "POST",
      data: function (params) {

        var queryParameters = {
          customer_id: params.term
        }
        return queryParameters;
      },
      processResults: function (data) {
        return {
          results: data
        };
      }
    }
  });
</script>