 <link href="<?php echo base_url();?>admin_assets/plugins/datatables/dataTables.bootstrap4.min.css" rel="stylesheet">
  <div class="body-content">
            <div class="row">
                <div class="col-md-4">
                	<?php if($this->session->flashdata("msg")!==""){echo $this->session->flashdata("msg"); }?>
                    <div class="card mb-4">
                        <div class="card-header">
                            <div class="d-flex justify-content-between align-items-center">
                            <h6 class="fs-17 font-weight-600 mb-0"><i class="fa fa-user"></i> Add/Edit New Customer</h6>
                            </div>
                        </div>
                        <div class="card-body">
                        	<?php if($this->uri->segment(3)){
								$edit=$this->db->get_where("clients",array("client_id"=>$this->uri->segment(3)))->row();?>
                            <form action="<?php echo base_url();?>admin/update_client" method="post" enctype="multipart/form-data">
                            	  <input type="hidden" name="client_id" value="<?php echo $edit->client_id;?>" />
                            	  <div class="form-group"> 
                                    <label for="email">Company Name</label>
                                    <input type="text" required value="<?php echo $edit->client_comp_name;?>" class="form-control" name="client_comp_name">
                                  </div>
                                  <div class="form-group"> 
                                    <label for="email">Client Name</label>
                                    <input type="text" required value="<?php echo $edit->client_name;?>" class="form-control" name="client_name">
                                  </div>
                                  <div class="form-group ">
                                    <label for="email">Email</label>
                                    <input type="email"  class="form-control" value="<?php echo $edit->client_email;?>" name="client_email" required>
                                  </div>
                                  <div class="row">
                                      <div class="form-group col-md-6"> 
                                        <label for="email">Mobile No</label>
                                        <input type="text" required class="form-control" value="<?php echo $edit->client_contact;?>" name="client_contact">
                                      </div>
                                      <div class="form-group col-md-6"> 
                                        <label for="email">Alternate No</label>
                                        <input type="text" class="form-control" value="<?php echo $edit->client_contact2;?>" name="client_contact2">
                                      </div>
                                  </div> 
                                  <div class="row">
                                  <div class="form-group col-md-6">
                                    <label for="email">Select Location</label>
                                    <select class="form-control" name="client_location" required>
                                    <option value="">Select Location</option>
                                    <?php $locs=$this->db->get("locations")->result();
									foreach($locs as $l){?>
                                    <option value="<?php echo $l->loc_id;?>" <?php if($l->loc_id==$edit->client_location){echo "selected";}?>><?php echo $l->loc_name;?></option>
                                    <?php }?>
                                    </select>
                                  </div> 
                                  <div class="form-group col-md-6">
                                    <label for="email">Business Type</label>
                                    <select class="form-control" name="client_type" required>
                                        <option value="">Select Location</option>
                    <option value="Restaurant" <?php if($edit->client_type=='Restaurant'){echo "selected";}?>>Restaurant</option>
                    <option value="Gas Station" <?php if($edit->client_type=='Gas Station'){echo "selected";}?>>Gas Station</option>
                    <option value="Grocery" <?php if($edit->client_type=='Grocery'){echo "selected";}?>>Grocery</option>
                                    </select>
                                  </div>  
                                  </div>                          
                                  <button type="submit" class="btn btn-success">Update Customer</button>
                                </form>
                            <?php }else{?>
                            <form action="<?php echo base_url();?>admin/add_client" method="post" enctype="multipart/form-data">
                            	  <input type="hidden" name="client_add_date" value="<?php echo date("Y-m-d");?>" />
                            	  <div class="form-group"> 
                                    <label for="email">Company Name</label>
                                    <input type="text" required class="form-control" name="client_comp_name">
                                  </div>
                                  <div class="form-group"> 
                                    <label for="email">Client Name</label>
                                    <input type="text" required class="form-control" name="client_name">
                                  </div>
                                  <div class="form-group ">
                                    <label for="email">Email</label>
                                    <input type="email"  class="form-control" name="client_email" required>
                                  </div>
                                  <div class="row">
                                      <div class="form-group col-md-6"> 
                                        <label for="email">Mobile No</label>
                                        <input type="text" required class="form-control" name="client_contact">
                                      </div>
                                      <div class="form-group col-md-6"> 
                                        <label for="email">Alternate No</label>
                                        <input type="text" class="form-control" name="client_contact2">
                                      </div>
                                  </div> 
                                  <div class="row">
                                      <div class="form-group col-md-6"> 
                                        <label for="email">Username</label>
                                        <input type="text" required class="form-control" name="client_username">
                                      </div>
                                      <div class="form-group col-md-6"> 
                                        <label for="email">Password</label>
                                        <input type="text" required class="form-control" name="client_password">
                                      </div>
                                  </div> 
                                  <div class="row">
                                  <div class="form-group col-md-6">
                                    <label for="email">Select Location</label>
                                    <select class="form-control" name="client_location" required>
                                    <option value="">Select Location</option>
                                    <?php $locs=$this->db->get("locations")->result();
									foreach($locs as $l){?>
                                    <option value="<?php echo $l->loc_id;?>"><?php echo $l->loc_name;?></option>
                                    <?php }?>
                                    </select>
                                  </div> 
                                  <div class="form-group col-md-6">
                                    <label for="email">Business Type</label>
                                    <select class="form-control" name="client_type" required>
                                        <option value="">Select Location</option>
                                        <option value="Restaurant">Restaurant</option>
                                        <option value="Gas Station">Gas Station</option>
                                        <option value="Grocery">Grocery</option>
                                    </select>
                                  </div>  
                                  </div>                          
                                  <button type="submit" class="btn btn-success">Add Client</button>
                                </form>
                            <?php }?>
                        </div>
                     </div>
                </div> 
                <div class="col-md-8">
                    <div class="card mb-4">
                        <div class="card-header">
                            <div class="d-flex justify-content-between align-items-center">
                            <h6 class="fs-17 font-weight-600 mb-0"><i class="fa fa-users"></i> Listed All Customer</h6>
                            </div>
                        </div>
                        <div class="card-body">
                        	<table class="table display table-bordered table-striped table-hover basic">
                                        <thead>
                                            <tr>
                                            	<th>S.No.</th>
                                                <th>Company/Name</th>
                                                <th>Location/Business Type</th>
                                                <th>Email/Mobile</th>
                                                <th>RegDate</th>
                                                <th>Action</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                        	<?php $i=1;foreach($clients as $u){?>
                                            <tr>
                                        <td><?php echo $i;?></td>
                                        <td><b><?php echo $u->client_comp_name;?></b>
										<br/><?php echo $u->client_name;?></td>
                                        <td><?php echo $u->loc_name;?><br/>
											<label class="badge badge-primary"><?php echo $u->client_type;?></label><br/>
											<label class="badge badge-dark"><?php echo $u->client_username;?></label></td>
                                        <td><i class="fa fa-envelope"></i> <?php echo $u->client_email.'<br/>
										<i class="fa fa-phone"></i> '.$u->client_contact.' '.$u->client_contact2;?></td>
                                        <td><?php echo $u->client_add_date;?></td>
                                        <td>
<a href="<?php echo base_url().'admin/clients/'.$u->client_id;?>" class="btn btn-sm btn-warning"><i class="fa fa-edit"></i></a>
<a href="#" id="<?php echo $u->client_id;?>" class="btn btn-sm btn-danger client_delete"><i class="fa fa-trash"></i></a></td>
                                            </tr>
                                            <?php $i++;}?>
                                        </tbody>
                                    </table>
                        </div>
                     </div>
                </div> 
            </div>
                         
                    </div><!--/.body content-->
                </div><!--/.main content-->
                
                
                

                <footer class="footer-content">
                    <div class="footer-text d-flex align-items-center justify-content-between">
                        <div class="copy">© 2019 CRM</div>
                    </div>
                </footer><!--/.footer content-->
                <div class="overlay"></div>
            </div><!--/.wrapper-->
        </div>
        <!--Global script(used by all pages)-->
        <script src="<?php echo base_url();?>admin_assets/dist/js/popper.min.js"></script>
        <script>
		$(document).ready(function(){
			$(".client_delete").click(function(e){e.preventDefault();
		if (!confirm("Sure you want to delete?")){
				  return false;
				}
			var id=$(this).attr("id");$(this).closest("tr").remove();
			$.ajax({
							 type: "POST",
							 url: '<?php echo base_url();?>admin/ajax_client_delete',
							 data: {id:id},
							 success: function(response){
								 //alert(response);
							 }
							 });
		});
			});
		</script>
        <script src="<?php echo base_url();?>admin_assets/plugins/bootstrap/js/bootstrap.min.js"></script>
        <script src="<?php echo base_url();?>admin_assets/plugins/metisMenu/metisMenu.min.js"></script>
        <script src="<?php echo base_url();?>admin_assets/plugins/perfect-scrollbar/dist/perfect-scrollbar.min.js"></script>
        <!-- Third Party Scripts(used by this page)-->
        <script src="<?php echo base_url();?>admin_assets/plugins/datatables/dataTables.min.js"></script>
        <script src="<?php echo base_url();?>admin_assets/plugins/datatables/dataTables.bootstrap4.min.js"></script>
        <!--Page Active Scripts(used by this page)-->
        <script src="<?php echo base_url();?>admin_assets/plugins/datatables/data-basic.active.js"></script>
        <!--Page Scripts(used by all page)-->
        <script src="<?php echo base_url();?>admin_assets/dist/js/sidebar.js"></script>
    </body>

<!-- Mirrored from bhulua.thememinister.com/tables_data_basic.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 28 Sep 2019 13:44:34 GMT -->
</html>