
<?php include_once('header.php'); ?>
<?php include_once('sidebar.php'); ?>
	<!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper ">
	<section class="content-header">
      <h1>Clients</h1>
    </section>
  
 
		<section class="content">
			
		<div class="backf pt30">
		
			<!-- <div class="row mb20">
				<div class="col-sm-10 col-sm-offset-1 col-md-8 ">
					<div class="form-group">
					  <label for="usr">Email Name:</label>
					  <input type="text" class="form-control" id="usr">
					</div>
					 <div class="form-group">
					  <label for="usr">Grade:</label>
					 <select class="form-control"><option>A</option></select>
					</div>
					
					<div class="mb20">
						<button class="btn btn-success" >SAVE</button>
					</div>
					<div class="mb20">
						<button class="btn btn-info upoadldbtn" >Upload Button</button>
						<input type="file" id="my_file" style="display: none;" multiple /> 
					</div>
					
				</div>
			</div> -->
		
			
			<div class="mb20">
				<button class="btn btn-warning mb20" data-toggle="modal" data-target="#add-client">Add Client</button>
			</div>
			
			<div class="table-responsive">
				<table  class="table table-striped datatble">
					<thead>
					  <tr>
						<th>First Name</th>
						<th>Last Name</th>
						<th>Email</th>
						
						<th>Phone</th>
						<!-- <th>Address</th> -->
						<th></th>
					  </tr>
					</thead>
					<tbody>
					<?php foreach($data as $d){ 
						if(empty($d->phone_no)){$d->phone_no=0;}
					?>
					  <tr>
						<td><?php echo $d->first_name; ?></td>
						<td><?php echo $d->last_name; ?></td>
						<td><?php echo $d->email; ?></td>
						<td><?php echo $d->phone_no; ?></td>
						
						<!-- <td>Lorem Address</td> -->
						<td>
							<button class="btn btn-info" data-toggle="modal" data-target="#edit-client" onclick="set_data('<?php echo $d->id; ?>','<?php echo $d->first_name; ?>','<?php echo $d->last_name; ?>','<?php echo $d->email; ?>','<?php echo $d->phone_no; ?>')">Edit</button>
							<button class="btn btn-danger" data-toggle="modal" data-target="#delete-client" onclick="del_data('<?php echo $d->id; ?>')">Delete</button>
						</td>
					<?php } ?>
					  </tr>
					  
					  
					</tbody>
				  </table>
			</div>

      </div>
		
		</section>
		
		
		
  </div>
		
		
  </div>
  
  
 <!-- Modal -->
<div id="add-client" class="modal fade" role="dialog">
  <div class="modal-dialog">
<form method="post" action="<?php echo base_url(); ?>main_controller/add_clients">
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Add Client</h4>
      </div>
      <div class="modal-body">
        <div class="form-group">
		  <label for="usr">First Name:</label>
		  <input type="text" class="form-control" id="usr"  name="add_fname">
		</div>
		 <div class="form-group">
		  <label for="usr">Last Name:</label>
		  <input type="text" class="form-control" id="usr" name="add_lname">
		</div>
		 <div class="form-group">
		  <label for="usr">Email Name:</label>
		  <input type="text" class="form-control" id="usr" name="add_email">
		</div>
		 <div class="form-group">
		  <label for="usr">Password:</label>
		  <input type="text" class="form-control" id="usr" name="add_pass">
		</div>
		 <div class="form-group">
		  <label for="usr">Phone:</label>
		  <input type="text" class="form-control" id="usr" name="add_phone">
		</div>
		 <!-- <div class="form-group">
		  <label for="usr">Address:</label>
		  <input type="text" class="form-control" id="usr">
		</div> -->
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="submit" class="btn btn-success" >Save</button>
      </div>
    </div>
</form>
  </div>
  
</div>
  
  
  <!-- Modal -->
<div id="edit-client" class="modal fade" role="dialog">
  <div class="modal-dialog">
<form method="post" action="<?php echo base_url(); ?>main_controller/edit_clients">
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Edit Client</h4>
      </div>
      <div class="modal-body">
        <div class="form-group">
		  <label for="usr">First Name:</label>
		  <input type="text" class="form-control" id="edit_fname" name="edit_fname">
		  <input type="hidden" class="form-control" id="edit_id" name="edit_id">
		</div>
		 <div class="form-group">
		  <label for="usr">Last Name:</label>
		  <input type="text" class="form-control" id="edit_lname" name="edit_lname">
		</div>
		 <div class="form-group">
		  <label for="usr">Email Name:</label>
		  <input type="text" class="form-control" id="edit_email" name="edit_email">
		</div>
		 <div class="form-group">
		  <label for="usr">New Password:</label>
		  <input type="text" class="form-control" id="edit_pass" name="edit_pass">
		</div>
		 <div class="form-group">
		  <label for="usr">Phone:</label>
		  <input type="text" class="form-control" id="edit_ph" name="edit_ph">
		</div>
		 <!-- <div class="form-group">
		  <label for="usr">Address:</label>
		  <input type="text" class="form-control" id="usr">
		</div> -->
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="submit" class="btn btn-success" >Update</button>
      </div>
    </div>
</form>
  </div>
  
</div> 
  
  
<!-- Modal -->
<div id="delete-client" class="modal fade" role="dialog">
  <div class="modal-dialog">
<form method="post" action="<?php echo base_url(); ?>main_controller/delete_clients">
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Delete Client</h4>
      </div>
      <div class="modal-body">
        <div class="form-group">
		  <label for="usr">Do you want to Delete Client?</label>
		 
		  <input type="hidden" class="form-control" id="del_id" name="del_id">
		</div>
		
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="submit" class="btn btn-success" >Delete</button>
      </div>
    </div>
</form>
  </div>
  </div> 
</div>   
<?php include_once('footer.php'); ?>
<script>
function set_data(id,fname,lname,email,ph){
	$("#edit_fname").val(fname); //alert(fname);
	$("#edit_id").val(id); //alert(page_name);
	$("#edit_lname").val(lname); //alert(page_name);
	$("#edit_email").val(email); //alert(page_name);
	$("#edit_ph").val(ph); //alert(page_name);
	
	
}
function del_data(id){
	$("#del_id").val(id);
}
</script>
