<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Contractor App </title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <!-- Bootstrap 3.3.7 -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">

  <!-- Theme style -->
  <link rel="stylesheet" href="<?php echo base_url();?>assets/css/AdminLTE.min.css">
  <link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css">
  <link rel="stylesheet" href="<?php echo base_url();?>assets/css/custom.css" type="text/css" media="screen"/>


  <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->

  <!-- Google Font -->
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

<?php  include"includes/header.php";  ?>
  <!-- Left side column. contains the logo and sidebar -->
  <aside class="main-sidebar">
    <!-- sidebar: style can be found in sidebar.less -->
    <?php  include"includes/sidebar.php";  ?>
    <!-- /.sidebar -->
  </aside>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper ">
	<section class="content-header">
      <h1>Settings</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="table-responsive">
				<table  class="table table-striped datatble">
					<thead>
					  <tr>
						<th>Contractor Application Fee</th>
						<th></th>
					  </tr>
					</thead>
					<tbody>
					<?php 
					
					$query = $this->db->query("SELECT * FROM  setting_tbl");
					foreach($query->result_array('setting_tbl') as $row){
					?>
					  <tr>
						<td><?php echo $row['contractor_application_fee'];?></td>
						<td>
							<button class="btn btn-info edit_fee" data-toggle="modal" data-target="#add-job-categories" setting_id="<?php echo $row['setting_id'];?>">Edit</button>
							
						</td>
					  </tr>
                      <?php } ?>
					</tbody>
				  </table>
			</div>

      </div>
		
		</section>
		
		
		
  </div>
  
  
  
  
  <!-- Modal -->
<div id="add-job-categories" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <form  method="post" id="add_fee">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Settings</h4>
      </div>
      <div class="modal-body">
        <div class="form-group">
		  <label for="usr">Contractor Application Fee:</label>
		  <input type="text" class="form-control" id="application_fee" name="application_fee" required>
                  <input type="hidden" name="setting_id" id="setting_id" value="1">
		</div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
       <input type="submit" class="btn btn-success update" name="sub" value="Save">
      </div>
      </form>
    </div>

  </div>
</div>
  
  
  <!-- Modal -->

<?php  include"includes/footer.php";  ?>
 <script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery.validate.min.js"></script>
 <script>
 
 $('.edit_fee').click(function(){
     var setting_id = $(this).attr('setting_id');
   
         $.ajax({
                type: "POST",
                url: '<?php echo base_url() ?>index.php/admin/edit_fee',
                data: {setting_id:setting_id},
				dataType:"json",
                success:function(data)
                {
			      $("#setting_id").val(data.setting_id);
				  $("#application_fee").val(data.contractor_application_fee);  
				
				 },
                error:function()
                {
                    alert('fail');
                }
            });
   
   
   });
 
    
$(".update").click(function () {
$('form[id="add_fee"]').validate({
  rules: {
    application_fee: {
      required: true,
    },
	
	},

  submitHandler: function(form) {
	var setting_id   = $('#setting_id').val();
	var data = $("#add_fee").serialize();
	$.ajax({                                      
				  url: '<?php echo base_url() ?>index.php/admin/update_fee',      //the script to call to get data  
				  type:'post',
				 // dataType: 'json',
				  data: data,//you can insert url argumnets here to pass to api.php
					  success: function(data)          //on recieve of reply
					  {
						if(data == 1){
					 alert("Contractor Fee Updated Successfully");
						location.reload();
						}
						
					  } 
				  });
  }
});
});


 </script>
</body>
</html>
