<?php
include"initialize_page.php";

?>
<!DOCTYPE html>
<html lang="en">

<head>
  
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

	<title>Loan</title>

	<!-- Bootstrap core CSS -->
	<link rel="stylesheet" href="assets/css/bootstrap/bootstrap.css" /> 

	<!-- datatables Styling  -->
    <link rel="stylesheet" href="assets/css/plugins/datatables/jquery.dataTables.css" />
    
    <!-- Fonts  -->
    <link href='http://fonts.googleapis.com/css?family=Raleway:400,500,600,700,300' rel='stylesheet' type='text/css'>
    
    <!-- Base Styling  -->
    <link rel="stylesheet" href="assets/css/app/app.v1.css" />

	<!-- 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  -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
<script type="text/javascript" src="jquery-1.11.1.min.js"></script>
		<script type="text/javascript">
	 $(document).ready(function() {
    $("#addcustom").on('submit',(function(e) {
e.preventDefault();

$.ajax({
url: "controller.php", // Url to which the request is send
type: "POST",             // Type of request to be send, called as method
data: new FormData(this), // Data sent to server, a set of key/value pairs (i.e. form fields and values)
contentType: false,       // The content type used when sending data to the server.
cache: false,             // To unable request pages to be cached
processData:false,        // To send DOMDocument or non processed data file it is set to false
success: function(data)   // A function to be called if request succeeds
{   //alert(data);
	//alert(data);
	if(data == "empty")
	{
		alert("Please Fill All Fields...");
	}
	if(data == "notnumeric")
	{
	     alert("Please Fill Numbers in Interest...");	
	}
	if(data=="done")
	{
		alert("Added Successfully..");
		window.location.href='<?php   echo website_settingdata('x_weburl');   ?>admin/add_loan_type.php';
	}
}
});
}));
});
	
</script>
	
	  <script type="text/javascript">
	
		function deleteloantype(id)
		 {
		    var r=confirm("Are you sure to Delete??");
			if(r==true)
			{
			$.post("controller.php", {id:id, q:"delete_loan_type"} , function(data)
			{
			window.location.href='<?php   echo website_settingdata('x_weburl');?>admin/add_loan_type.php';  
			});
  
		    }
						
		}

	</script>
		
</head>
<body>	

	
    
	<?php    include"xleftmenu.php"; ?>
    
    <section class="content">
    	
         <?php  include"xheader.php";  ?>
        <!-- Header Ends -->
        
        <div class="warper container-fluid">
        	
            <div class="page-header"><h2>Loan</h2></div>
            
            
            <div class="row">
            
            	<div class="col-md-12">
                
                	<div class="panel panel-default">
                      
                       
                        <div class="panel-body">
							<div class="col-sm-8">
								<form class="form-horizontal" method="post" action="" id="addcustom">
									<div class="form-group">
										<input type="hidden" name="q" value="add_loan_type">
									</div>
									<div class="form-group">
										<label class="control-label col-sm-3">Type</label>
										<div class="col-sm-9">
											<input type="text" class="form-control"   name="loan_type" required >
										</div>	
									</div>
									<div class="form-group">	
										<label class="control-label col-sm-3">Interest (%)</label>
										<div class="col-sm-9">
											<input type="text" class="form-control"   name="loan_interest" required>
										</div>	
									</div>
									<div class="form-group">
										<div class="col-sm-12 col-sm-offset-6">
											<input type="submit" class="btn btn-primary"  value="Add" name="addloantype">
										</div>	
									</div>
								</form>
							</div>	
                     
                    </div>
                    
                
                </div>
				<div class="panel panel-default">
                  
           
                   
                    <div class="row">
                    <div class="col-md-12">
                    <div class="panel-body">
                   
<table class="table table-striped table-bordered" id="basic-datatable" width="100%">
        <thead>
            <tr>
                <th>Sr.</th>
                <th>Type</th>
                <th>Interest</th>
				 <th>Delete</th>
                <th>Edit</th>
                
            </tr>
        </thead>
        <tbody>
                            
             <?php
				$sr=1;		  
			    $data_q=mysqli_query($con,"SELECT * FROM x_loantype ORDER by x_id DESC");
				while($data_array=mysqli_fetch_array($data_q))
			    {
				
			?>
                <tr class="odd gradeX">
				
                <td><?php echo $sr; ?></td>
                <td><?php echo $data_array['x_loan'];?> </td>              
                <td><?php echo $data_array['x_loaninterest'];?>%</td> 
                <td><button class="btn btn-danger" onClick="deleteloantype(<?php echo $data_array['x_id'];  ?>)">Delete</button></td>
				
               <td><a href="<?php   echo website_settingdata('x_weburl');   ?>admin/edit_loan_type.php?id=<?php echo $data_array['x_id'];  ?>&ss=<?php  echo md5(rand(00000,99999));?>"><button class="btn btn-primary">Edit</button></a></td>
			   
			  
                                 
                </tr>
			<?php
            
            $sr++;
            }
            ?>  
</tbody>
</table>

</div></div>
</div></div>
                
              
            </div>
          
        </div>
    </div>
            
        <!-- Warper Ends Here (working area) -->
        
        <footer class="container-fluid footer">
        	Copyright &copy; <?php    echo date('Y');  ?>
        </footer>
        
    
    </section>
    <!-- Content Block Ends Here (right box)-->
    
    
    
    <!-- JQuery v1.9.1 -->
	<script src="assets/js/jquery/jquery-1.9.1.min.js" type="text/javascript"></script>
    
    <!-- Bootstrap -->
    <script src="assets/js/bootstrap/bootstrap.min.js"></script>
    
    <!-- NanoScroll -->
    <script src="assets/js/plugins/nicescroll/jquery.nicescroll.min.js"></script>
    
    
	<!-- Data Table -->
    <script src="assets/js/plugins/datatables/jquery.dataTables.js"></script>
    <script src="assets/js/plugins/datatables/DT_bootstrap.js"></script>
    <script src="assets/js/plugins/datatables/jquery.dataTables-conf.js"></script>
    
    
    <!-- Custom JQuery -->
	<script src="assets/js/app/custom.js" type="text/javascript"></script>
    <!-- Wysihtml5 -->
    <script src="assets/js/plugins/bootstrap-wysihtml5/wysihtml5-0.3.0.min.js"></script>
    <script src="assets/js/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.js"></script>
    
  <script src="assets/js/plugins/ckeditor/ckeditor.js"></script>
    <script src="assets/js/plugins/ckeditor/adapters/jquery.js"></script>
    
	<script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
    
    ga('create', 'UA-56821827-1', 'auto');
    ga('send', 'pageview');
    
    </script>
</body>
</html>
