<?php 
if(!isset($_SESSION)) { 
  session_start(); 
  include('../includes/dbcon.php');
}
if(empty($_SESSION['hrm_id'])):
header('Location:../index.php');
endif;

$edate=date("Y-m-d");
//////////////// Get Sequence Number ----------------------- 

$fdate=$edate;
$tdate=$edate;

$loc1=0;
$loc2=9999;

$item1=0;
$item2=99999999;



//////////////////End of gettinh sequence Number ------------------
?>
<!DOCTYPE html>
<html lang="en">


<head>
  <!-- Required meta tags -->
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <title>SalesHub | Stock Adjustments </title>
  <!-- plugins:css -->
  <?php include('../includes/commonheader.php');?>



</head>
<body>
 <?php include('../includes/header.php');?>
 <?php include('../includes/leftsidebar.php');?>
           <!-- partial -->
 <div class="main-panel">        
        <div class="content-wrapper">

          <div class="page-header">
            <h3 class="page-title">
                Stock Adjustment
            </h3>
          
          </div>
          <div class="col-22 grid-margin">
              <div class="card">
                <div class="card-body">
              
                          
    <form class="needs-validation" novalidate method="post" action="stock_adjust_add.php" enctype="multipart/form-data" onsubmit="return validateForm()">                   
                    <div class="row">                     
                      <div class="col-md-6">
                        <div class="form-group row">
                          <label class="col-sm-3 col-form-label">Location: </label>
                          <div class="col-sm-9">
                            <select class="form-control select2" style="width: 100%;" name="loc" id="loc" required >
           <option value="0">~~~Select ~~~~</option>  
          <?php            
          $querydoc=mysqli_query($con,"select * from stock_locations  ")or die(mysqli_error());
          
          while($rowd=mysqli_fetch_array($querydoc)){
          ?>
          <option value="<?php echo $rowd['loc_id'];?>"><?php echo $rowd['loc_name'];?></option>        
          <?php }?>
          </select> 
                          </div>
                        </div>


                      </div>
                                              
                  <div class="col-md-6">
                        <div class="form-group row">
                          <label class="col-sm-3 col-form-label">Trn Date: </label>
                          <div class="col-sm-8">
                            <input type="date" class="form-control" id="tdate" name="tdate" >

                          </div>
                        </div>

                    </div> <!-------End of first form raw------->

            

</div>



  <div class="row">                     
  <div class="col-md-6">
  <div class="form-group row">
   <label class="col-sm-3 col-form-label">Note: </label>
  <div class="col-sm-9">
  <input type="text" class="form-control" id="note" name="note" >
 </div>



</div>
</div>
<div class="col-md-6">                  
           
</div>
</div>
            

  <div class="row">                     
  <div class="col-md-6">
  <div class="form-group row">





</div>
</div>
<div class="col-md-4">
                    

  </div> <!-------End of first form raw------->
<div class="col-md-2">
                 
  </div> <!-------End of first form raw------->
</div>






                     <button type="submit" class="btn btn-primary">Save</button>
                    <button class="btn btn-light">Cancel</button>
                  </form>
                </div>
              </div>
            </div>








  <div class="content-wrapper">
          <div class="col-lg-22 grid-margin stretch-card">
              <div class="card">
                <div class="card-body">
                  <h6 >Draft </h6>
                  <p class="card-description">
                    <button type="button" onclick="document.location='home.php'" class="btn btn-warning "><i class="fas fa-arrow-left"></i> Go Back
                    
                  </button>
                  </p>
                  <div class="table-responsive">
                    <table class="table table-hover">
                      <thead>
                        <tr>
                          <th>#</th>
                          <th>No</th>
                          <th>Date</th>
                          <th>Location</th>
                          <th>Note</th>
                         
                        </tr>
                      </thead>
                      <tbody>
<?php
$rcount=0;
$fdate=$edate;
$tdate=$edate;

$loc1=0;
$loc2=9999;

$item1=0;
$item2=99999999;


$query=mysqli_query($con,"SELECT stock_adjust_header.tran_id,stock_adjust_header.tran_date,
stock_adjust_header.refnote,stock_locations.loc_name
 FROM stock_adjust_header
LEFT JOIN stock_locations ON stock_adjust_header.from_loc_id=stock_locations.loc_id")or die(mysqli_error()); 
 while($row=mysqli_fetch_array($query)){   $rcount=$rcount+1;
             
                $tran_id=$row['tran_id'];
                $tran_date=$row['tran_date']; 
                $loc_name=$row['loc_name'];
                $refnote=$row['refnote'];
               
              

 ?>
   <tr>
                         <td><?php echo $rcount;  ?></td>
                         <td><a href="http://localhost:81/saleshub/pages/report_stokadj_detail.php?tran_id=<?php echo $tran_id; ?>"><?php echo $row['tran_id'];?></a>  </td>
                         <td><?php echo $row['tran_date'];?></td>
                         <td><?php echo $row['loc_name'];?></td>
                         <td><?php echo $row['refnote'];?></td>
                        

</tr>

 <?php }  ?>

                      </tbody>
                    </table>



        </div>  <!----- <div class="content-wrapper">------>
        </div>
          
          
  </div>

 </div><!-----End of main panel--~~~~~~~~~~~~~~~~~~~~~~~--------------->
 </div><!-----Dont Delete this DIV--~~~~~~~~~~~~~~~~~~~~~~~--------------->
</div>
  <!-- container-scroller -->
<?php include('../includes/footer.php');?>
<?php include('../includes/commonjs.php');?>
 
</body>


</html>

<script>
    $( document ).ready(function() {
         // alert("Please Select Order Type");

    });

function validateForm() { 

    //````````route````````````````````````````````````
    if($('#bname').val().trim().length == 0) {
           alert("Please enter the route you visited !!!");               
            return false;
    } ////``````````````````````````````````````````

    



 } ///validateForm() { 

</script>

 <!-- End custom js for this page-->
  <script>
  $(function () {
    //Initialize Select2 Elements
    $('.select2').select2()

    //Initialize Select2 Elements
    $('.select2bs4').select2({
      theme: 'bootstrap4'
    })
  })

</script>



