<?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 USER_PATH;?>search_user">

    <div class="panel-body bs-example form-horizontal">
     <div class="col-sm-12" >  

                      <div class="col-sm-6">
                          <div class="form-group">
                            <label for="client_code" class="col-sm-3 control-label required"><?php echo 'User Type'?>:</label>
                              <div class="col-sm-7">
                                 <select name="user_type"  id="user_type"  style="width: 250px;">
                                    <option value="">Select User Type</option>
                                      <?php  
                                        foreach ($type_array as  $value) {
                                          $user_type_id = $value['user_type_id'];
                                          $user_type = $value['user_type'];
                                      ?>  
                                      <option value="<?php echo $user_type_id ?>" <?php if ( $user_type_id==$user_type_id_check) {
                                        echo 'selected="selected"';
                                      } ?>><?php echo $user_type; ?></option>
                                      <?php } ?>                           
                                 </select>
                    
                              </div>  
                          </div>
                      </div> 

                      <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 'Person Name'; ?>:</label>
                              <div class="col-sm-7">
                                <input type="text" name="user_first_name" onkeypress="return RestrictSpace()" value="<?php echo $user_first_name; ?>" id="user_first_name" placeholder=" 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 'Branch Name'; ?>:</label>
                              <div class="col-sm-7">   
                                <input type="text" name="user_branch_name" onkeypress="return RestrictSpace()" value="<?php echo $user_branch_name; ?>" id="user_branch_name" placeholder="Branch Name" class="form-control" maxlength="150">
                                                                        
                              </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 'Mobile Number'; ?>:</label>
                              <div class="col-sm-7">                             
                                <input type="text" name="user_mobile_no" onkeypress="return RestrictSpace()" value="<?php echo $user_mobile_no; ?>" id="user_mobile_no" placeholder="Mobile Number" class="form-control" maxlength="20" />                                        
                              </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">
      
  
        <div class="panel-body bs-example form-horizontal">
          <div class="table-responsive">
            <table id="example" class="table table-bordered dataTables" cellspacing="0" width="100%">
              <thead>
        <tr>
          <th>Sr No</th>

           <?php foreach($fields as $field_name => $field_display): ?>
            <th <?php if ($sort_by == $field_name) echo "class=\"sorting_$sort_order\"" ?>>
            <?php echo anchor("gc/user/list_user/$query_id/$field_name/" .
            (($sort_order == 'asc' && $sort_by == $field_name) ? 'desc' : 'asc') ,
            $field_display); ?>     </th>
          <?php endforeach; ?>
          <!-- <th>User Type</th> 
          <th>User Name</th>
          <th>Branch Name</th>
          <th>Email id</th>             
          <th>Mobile Number</th>
          <th>Accessible branches</th> -->
          <th>Action</th>
        </tr> 
      </thead>
      <tbody>
         <?php 
       $icnt=0;
	    $count=count($users);
      if ($count>0) {
      foreach ($users as  $value) {
         // $user_id = $value['user_id'];
		  $user_id=$value->user_id;
        //  $id=$this->encrypt->encode($user_id);
		  $id=encrypt_decrypt_parameters($user_id,'encrypt');
		  $company_branch_name=$value->company_branch_name;
		  $user_type=$value->user_type;
		  $user_name=$value->first_name." ".$value->last_name;
		  $mobile_no=$value->mobile_no;		 
      $email_id=$value->email_id;
      $accessible_branches=$value->accessible_branches;
      $is_active=$value->is_active;
      $designation=$value->designation;
      
		  $icnt++;
			$sr=$offset+$icnt;
       ?> 
        
        <tr>
          <td><?php echo $sr; ?></td>
          <td><?php echo $user_type;?></td>
          <td><?php echo $user_name;?></td>
          <td><?php echo $company_branch_name;?></td>
          <td><?php echo $email_id;?></td>  
          <td><?php echo $mobile_no;?></td>
          <td><?php echo $designation;?></td>
          <td><?php 
            if($accessible_branches!='') {
               echo $ac_branches=fetch_accessible_branch($accessible_branches); 
            } 
           ?>           
          </td>     
          <td>
            
            <b><a href="<?php echo base_url();?>index.php/gc/user/view_user/<?php echo $id?>">View </a>|<a href="<?php echo base_url();?>index.php/gc/user/manage_user/<?php echo $id ?>"> Edit </a>| 
                <?php if($is_active==0) {?>
                 <a href="<?php echo base_url();?>index.php/gc/user/enable_user/<?php echo $id ?>" onclick="return confirm('Are you sure you want to Enable?')">Enable</a></b><?php }else{?>
                 <a href="<?php echo base_url();?>index.php/gc/user/disable_user/<?php echo $id ?> " onclick="return confirm('Are you sure you want to Disable?')">Disable</a></b><?php } ?>
          </td>
        </tr> 
        <?php 
         //$srno=$srno+1;
       }
      }else{?>
              <td colspan="8" class="text-center">no data found</td>
         <?php } ?>
        </tbody>
            </table>
          </div>
		   <?php
		 if($num_results > 0)	{ ?>
			<div class="block">  </div>
				<div class="clearfix">
				<div class="row">
					<?php 
						if (strlen($pagination)): 
							$label_disp="User";
							$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/user/manage_user'">
          Add User
        </button>
      </div>
    </div>
	
  </div>
</div>

<!-- /.main-content --> 
</div>
<!-- /#ace-settings-container --> 
</div>
<!-- /.main-container-inner -->
 
<?php
  include('common/footer.php');
?>
<!-- <script type="text/javascript" charset="utf-8">
  $(document).ready(function() {
    $('#example').DataTable();
  } );
</script> -->
<!-- <script type="text/javascript">
$(document).ready(function() {
    $('#example').DataTable( {
    destroy: true,
    searching: false,
    paging: false,
    sorting:false,
    bInfo : false,
    "order": [],
	"pageLength": 5,
    "columnDefs": [
      { "orderable": false, "targets":  [] }
      ]
  } );
});
</script>  -->