<?php
//user.php
include('db_con.php');
include('function.php');
if (isset($_SESSION['user_id'])) {
    $user_type = $_SESSION['user_type'];
    $user_id = $_SESSION['user_id'];
    $user_name = $_SESSION['user_name'];
    $branch_id = $_SESSION['branch_id'];
    $branch_name = $_SESSION['branch_name'];
       $store_id = $_SESSION['store_id'];
        $store_name = $_SESSION['store_name'];
}else{
  header('Location: login');
  die();
}


?>
<!DOCTYPE html>
<html>
<head>
  <title><?php echo basename(__FILE__, '.php'); ?></title>
  <title>Sales </title>
<?php include('include/head.php'); ?>
  
</head>
<body>
<?php include('include/header.php'); ?>
<?php include('include/sidebar.php'); ?>
<div class="main-container">
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1 class="m-0 text-dark"></h1>
          </div><!-- /.col -->
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="#">Accounts Receivable</a></li>
              <li class="breadcrumb-item active">Quotaions</li>
            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->
    <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
        <!-- Small boxes (Stat box) -->
     <span id="alert_action"></span>
    <div class="row">
        <div class="col-12">
          <div class="card">
            <div class="card-header">
            <div class="row">
                          <div class="col-lg-10 col-md-10 col-sm-8 col-xs-6">
                              <h3 class="panel-title">Quotation</h3>
                            </div>
                          <div class="col-lg-2 col-md-2 col-sm-4 col-xs-6" align="right">
                              <a href="quotation_new?add=1" class="btn btn-primary"><i class="fa fa-plus"></i> New Quotation </a>
                            
                          </div>
                            
                        </div>
            </div>
            <!-- /.card-header -->
            <div class="card-body">
              
                        <table width="100%" id="_dataTable" class="table table-bordered table-striped table-hover">
                          <thead>
                  <tr>
                    <th width="3%">ID.</th>
                    <th width="3%">No.</th>
                    <th width="13%">Date</th>
                    <th width="25%">Customer</th>
                    <th width="13%">Description</th>
                
                    <th width="10%">Created</th>
                    
                    
                    <th width="8%">Amount</th>
                   <th width="5%"></th>
                   
                    
                    
         
                    <th width="5%">Edit</th>
                <th width="5%">Delete</th>

                    
                  </tr>
                </thead>
                        </table>
                           </div>
              </div>
          </div>
      </div>
             
        
        
      </div><!-- /.container-fluid -->
    </section>
    <!-- /.content -->
 
  <!-- /.content-wrapper -->
 
    </div>
    </div>
<?php include('include/script.php'); ?>
  
</body>
</html>
       
<script>
$(document).ready(function(){
  
  var _dataTable = $('#_dataTable').DataTable({
    "processing": true,
    "serverSide": true,
    "order": [],
    "ajax":{
      url:"quotation_fetch.php",
      type:"POST"
    },
    "columnDefs":[
      {
        "target":[1,2,3,4],
        "orderable":false
      }
    ],
        
        "pageLength": 25
        
    
  });
  
  
  $(document).on('click', '.delete', function(){
    var s_id = $(this).attr("id");
    
    var btn_action = "delete";
    if(confirm("Are you sure you want delete it permanently?"))
    {
      $.ajax({
        url:"quotation_action.php",
        method:"POST",
        data:{s_id:s_id, btn_action:btn_action},
        success:function(data)
        {
          $('#alert_action').fadeIn().html('<div class="alert alert-info">'+data+'</div>');
          _dataTable.ajax.reload();
        }
      })
    }
    else
    {
      return false;
    }
  });
});
    
</script>
<?php
//include('footer.php');
?>
