<?php 
session_start();
ob_start();
error_reporting(0);
include("../leadsnew/branch_connection.php");
$sujpath="./";
if((!isset($_SESSION['user_name'])) && ($_SESSION['user_name'] == '')){
	header("Location: ../index.php");
} 
?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Projects</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.5 -->
    <link rel="stylesheet" href="<?php echo $sujpath; ?>bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="<?php echo $sujpath; ?>font-awesome/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="<?php echo $sujpath; ?>font-awesome/ionicons.min.css">
    <!-- DataTables -->
    <link rel="stylesheet" href="<?php echo $sujpath; ?>plugins/datatables/dataTables.bootstrap.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="<?php echo $sujpath; ?>dist/css/AdminLTE.min.css">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" href="<?php echo $sujpath; ?>dist/css/skins/_all-skins.min.css">
    <link rel="stylesheet" type="text/css" href="tcal.css" />    
    <script type="text/javascript" src="tcal.js"></script>
<script>
/* ADD TAX */
function tax_register(){
    $.ajax({
        type:"POST",
        url:"ajaxmarket8.php",
        data:{
            btn_add_tax:1,
            taxname:$('#taxname').val(),
            tax:$('#tax').val()
        },
        success:function(res){
            if(res=="duplicate"){
                alert("Tax already exists");
            }else{
                alert("Tax Added Successfully");
                location.reload();
            }
        }
    });
}

/* EDIT TAX */
function edit_tax(){
    $.ajax({
        type:"POST",
        url:"ajaxmarket8.php",
        data:{
            btn_edit_tax:1,
            tid:$('#tid').val(),
            taxname:$('#taxname').val(),
            tax:$('#tax').val()
        },
        success:function(res){
            if(res=="duplicate"){
                alert("Tax already exists");
            }else{
                alert("Updated Successfully");
                location.reload();
            }
        }
    });
}

/* DELETE TAX */
function delete_tax(tid){
    if(confirm("Are you sure to delete?")){
        $.ajax({
            type:"POST",
            url:"ajaxmarket8.php",
            data:{btn_delete_tax:1, tid:tid},
            success:function(){
                alert("Deleted Successfully");
                location.reload();
            }
        });
    }
}

/* LOAD DATA FOR EDIT */
function edit_tax1(tid,taxname,tax){
    $('#tid').val(tid);
    $('#taxname').val(taxname);
    $('#tax').val(tax);
    $('#frasubmit').val('Update').attr('onclick','edit_tax()');
}
</script>
    
  </head>
  <body class="hold-transition skin-blue sidebar-mini">
     <div class="wrapper">
  <?php include("head.php");
        include("left.php"); ?> 
	 
      <!-- Content Wrapper. Contains page content -->
      <div class="content-wrapper" >
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1 style=" font-size: 22px;"> Tax master
          	<small>- Control panel</small>
          	</h1>
          <ol class="breadcrumb">
            <li><a href="dash_board.php"><i class="fa fa-dashboard"></i> Home</a></li>
            <li class="active"> Tax master</li> 
          </ol>
        </section>
  <!-- Main content -->
        <section class="content" >
          <div class="row" >
            <div class="col-xs-12" >


  
  <div class="row" style=" margin-top: 20px;">	
<div class="col-md-12" style="" >
	
<form method="POST" onsubmit="return false;">
<input type="hidden" id="tid">

<div class="col-md-6" style="padding-left:2px;padding-right:0px;">
<div class="form-group">
<input type="text" id="taxname" class="form-control" placeholder="Tax Name">
</div>
</div>

<div class="col-md-3" style="padding-left:2px;padding-right:0px;">
<div class="form-group">
<input type="text" id="tax" class="form-control" placeholder="Tax %">
</div>
</div>

<div class="col-md-2" style="padding-left:2px;padding-right:0px;">
<div class="form-group">
<input type="button" class="btn btn-primary"
       id="frasubmit"
       value="Submit"
       onclick="tax_register();"
       style="float:right;margin-right:20px;">
</div>
</div>
</form>
 </div></div>



  
  
<div id="marketingdiv123" >


<div class="box" >
   <div class="box-body" style="padding-left: 2px; padding-right: 2px;"">
        <div class="box-body table-responsive no-padding" >
		         	
<table id="example1" class="table table-bordered table-striped" >
<thead >
<tr >
                   	
<th>Tax Name</th>
<th>Tax %</th>
<th>Action</th>
</tr>
</thead>
<tbody>

<?php
    
	
	$sq = mysqli_query($conn, "SELECT * FROM `tax_master`");
	$k=1;
	while($rs = mysqli_fetch_array($sq)){
      $tname = $rs['tax_name'];
	  $tax = $rs['tax_per'];	
	 
	?>
   <tr>
   	
   	<td><?php echo $rs['tax_name']; ?></td>
   	<td><?php echo $rs['tax_per']; ?></td>
<td>
<a onclick="edit_tax1('<?php echo $rs['tid']; ?>','<?php echo $rs['tax_name']; ?>','<?php echo $rs['tax_per']; ?>')" style="cursor:pointer">
<i class="fa fa-pencil"></i></a>

&nbsp;

<a onclick="delete_tax('<?php echo $rs['tid']; ?>')" style="cursor:pointer">
<i class="fa fa-trash"></i></a>
</td>
   </tr>
   <?php $k=$k+1; }  ?>
   
</tbody>
</table>
         		  </div>
                </div><!-- /.box-body -->
              </div><!-- /.box -->
	
	
</div>
	
		
			
			
			








                           
            </div><!-- /.col -->
          </div><!-- /.row -->
        </section><!-- /.content -->
  </div><!-- /.content-wrapper -->
  </div>
	<!-- <?php include("footer.php"); ?> -->
 <!-- jQuery 2.1.4 -->
    <script src="<?php echo $sujpath; ?>plugins/jQuery/jQuery-2.1.4.min.js"></script>
    <!-- Bootstrap 3.3.5 -->
    <script src="<?php echo $sujpath; ?>bootstrap/js/bootstrap.min.js"></script>
    <!-- DataTables -->
	<script src="<?php echo $sujpath; ?>plugins/datatables/jquery.dataTables.min.js"></script>
    <script src="<?php echo $sujpath; ?>plugins/datatables/dataTables.bootstrap.min.js"></script>
    <!-- SlimScroll -->
    <script src="<?php echo $sujpath; ?>plugins/slimScroll/jquery.slimscroll.min.js"></script>
    <!-- FastClick -->
    <script src="<?php echo $sujpath; ?>plugins/fastclick/fastclick.min.js"></script>
    <!-- AdminLTE App -->
    <script src="<?php echo $sujpath; ?>dist/js/app.min.js"></script>
    <!-- AdminLTE for demo purposes -->
    <script src="<?php echo $sujpath; ?>dist/js/demo.js"></script>
    <!-- page script -->
   
    <script>
      $(document).ready(function() {
        $("#example1").DataTable();
      });
      
	function datat(){
	  alert("Data Deleted Successfully.");
      $(document).ready(function() {
        $("#example1").DataTable();
       
      });
    }
    function datat2(){
	  alert("Data Added Successfully");
      $(document).ready(function() {
        $("#example1").DataTable();
       
      });
    }
    function datat3(){
	  alert("Updated Successfully");
      $(document).ready(function() {
        $("#example1").DataTable();
       
      });
    }
   </script>  
   
   
   
  </body>
</html>
