<?php 
if(!isset($_SESSION)) { 
  session_start(); 
  include('../includes/dbcon.php');
}
if(empty($_SESSION['hrm_id'])):
header('Location:../index.php');
endif;
$cval=0;
$grn_no=0;
$edate=date("Y-m-d"); 
$userid=$_SESSION['hrm_id'];

$loc_id=$_SESSION['loc_id'];
$emp_id=$_SESSION['hrm_emp_id'];
//////////////// Get Sequence Number ----------------------- 
 $querydoc=mysqli_query($con,"select * from sequence where seq_id=5 ")or die(mysqli_error());

    while($row=mysqli_fetch_array($querydoc)){ 
    $invd_no=$row['cno'];  
    }

//////////////////End of gettinh sequence Number ------------------

 $querydoc=mysqli_query($con,"select * from tran_master LEFT JOIN root_master ON tran_master.r_id=root_master.r_id where t_end=0 and userid=$userid ")or die(mysqli_error());

   $count=mysqli_num_rows($querydoc);
   if ($count>0){ 

       while($row=mysqli_fetch_array($querydoc)){ 
            $r_id=$row['r_id'];  
            $r_name=$row['r_name'];  
        }

   }

else {

      echo "<script type='text/javascript'>alert('Root should be assign for this data!!!');</script>";
        echo "<script>document.location='day_start.php'</script>";
}


 




?>
<!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 | Sales Management </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">
      New Invoice - <?php echo  $r_name; ?>
     </h3>
     </div> 
     <div class="col-22 grid-margin">
     <div class="card">
     <div class="card-body">
       <form class="needs-validation" novalidate method="post" action="sales_start_emp.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">Customer: </label>
                          <div class="col-sm-9">
                             <select class="form-control select2" style="width: 100%;" name="cus_id" id="cus_id" required >
           <option value="0">~~~Select ~~~~</option>  
          <?php            
          $querydoc=mysqli_query($con,"select * from customer_master where r_id=$r_id ")or die(mysqli_error());
          
          while($rowd=mysqli_fetch_array($querydoc)){
          ?>
          <option value="<?php echo $rowd['cus_id'];?>"><?php echo $rowd['cus_name'];?></option>        
          <?php }?>
          </select> 
                          </div>
                        </div>


                      </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">Next</button>
                    <button class="btn btn-light">Cancel</button>
                  </form>
     </div><!-----End of <div class="card-body">--~~~~~~---->
     </div><!-----End of <div class="card">--~~~~~~---->
     </div><!-----End of  <div class="col-22 grid-margin">--~~~~~~---->

 
     <div class="col-22 grid-margin" >
     <div class="card" style="background-color:#D0E5F8;">      
            
             
    </div>
     </div><!-----End of <div class="card-body">--~~~~~~---->
     </div><!-----End of <div class="card">--~~~~~~---->
     </div><!-----End of  <div class="col-22 grid-margin">--~~~~~~---->




     </div><!-----End of   <div class="content-wrapper">--~~~~~~---->
       



 </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() { 
  
    //````````Location````````````````````````````````````
   if ($('#loc_id').val() == 0){
    //if($('#loc_id').val().trim().length == 0) {
           alert("Please select the Location !!!");               
            return false;
    } ////``````````````````````````````````````````

    

    //````````Customer````````````````````````````````````
   if ($('#cus_id').val() == 0){
    //if($('#loc_id').val().trim().length == 0) {
           alert("Please select the Customer !!!");               
            return false;
    } ////


        //````````Employee````````````````````````````````````
   if ($('#emp_id').val() == 0){
    //if($('#loc_id').val().trim().length == 0) {
           alert("Please select the Employee !!!");               
            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>



