<?php
 echo @$_GET['msg'];
  session_start();
  if(isset($_SESSION['userId'])){ 
include 'template/header.php';

?>
 <link rel="stylesheet" href="css/jquery-ui.css">
  <!-- <link rel="stylesheet" href="/resources/demos/style.css"> -->
  <script src="js/jquery-1.12.4.js"></script>
  <script src="js/jquery-ui.js"></script>
    <link rel="stylesheet" href="css/bootsrap_my.css" />


<div class="ch-container">
    <div class="row">
        
<!-- SIDEBAR HERE-->
<?php

include 'template/sidebar.php';

?>
    

        <div id="content" class="col-lg-10 col-sm-10">
            <!-- content starts -->
            <div>
    <ul class="breadcrumb">
        <li>
            <a href="#">Home</a>
        </li>
        <li>
            <a href="#">FEED TRANSFER</a>
        </li>
    </ul>
</div>

<div class="row">
    <div class="box col-md-12">
        <div class="box-inner">

          
         <?php
                    require 'connection.php';

                 $qryvno = "SELECT max(vno) as vno FROM feedinout";
             $runvno = mysqli_query($connect, $qryvno) or die(mysqli_error($connect));
            $rowvno = mysqli_fetch_array($runvno);
?>
            <div class="box-header well">
                <h2><i class="glyphicon glyphicon-info-sign"></i> FEED IN/OUT</h2>
                <h2 id="vno" style="margin-left: 10px"><?php echo $rowvno['vno']+1; ?></h2>

    <!--   <p>Date: <input type="text" id="datepicker" data-role="calendarpicker" data-input-format="%d-%m-%y"></p> -->


                <div class="box-icon">
                    <a href="#" class="btn btn-setting btn-round btn-default"><i
                            class="glyphicon glyphicon-cog"></i></a>
                    <a href="#" class="btn btn-minimize btn-round btn-default"><i
                            class="glyphicon glyphicon-chevron-up"></i></a>
                    <a href="#" class="btn btn-close btn-round btn-default"><i
                            class="glyphicon glyphicon-remove"></i></a>
                </div>
            </div>
            <div class="box-content row">

                <div class="col-lg-12 col-md-12" style="margin-bottom: 30px">
               <input style=" border: none; border-bottom: 1px solid black; float: right; font-size: 2rem" type="date"  data-date-format="DD MMMM YYYY" id="dated">
                </div>
                <div class="col-lg-12 col-md-12" style="margin-bottom: 30px">
                    
                      <div class="col-lg-6 col-md-12">
                    <label>Creditor / جمع پارٹی</label>
                    <select id="selaccid" class="form-control selectpicker"data-live-search="true">
                 <?php
                    require 'connection.php';

              $qry = "SELECT * FROM accreg where accid>4";
             $run = mysqli_query($connect, $qry) or die(mysqli_error($connect));
    while($row = mysqli_fetch_array($run)){
?>
                                         <option value="<?php echo $row['accid']; ?>"><?php echo $row['accname']; ?></option>
                                     <?php } ?>
                                     </select>
                                     </div>
                        
                              <div class="col-lg-6 col-md-12">
                               <label>Debitor / بنام پارٹی</label>
                           

                              <select  id="selaccid2" class="form-control selectpicker"data-live-search="true">
                 <?php
                    require 'connection.php';

                 $qry = "SELECT * FROM accreg where accid>4";
             $run = mysqli_query($connect, $qry) or die(mysqli_error($connect));
    while($row = mysqli_fetch_array($run)){
?>
                                         <option value="<?php echo $row['accid']; ?>"><?php echo $row['accname']; ?></option>
                                     <?php } ?>
                                     </select>
                                    </div>
             
                </div>

         <div class="col-lg-12 col-md-12">
                         <div class="col-lg-2 col-md-12">
                              <label>Item Detail</label>
                                <select id="itemid" class="form-control selectpicker"data-live-search="true">
                                 <?php
                                  require 'connection.php';

                                      $qry = "SELECT * FROM itemreg ";
                                       $run = mysqli_query($connect, $qry) or die(mysqli_error($connect));
                                     while($row = mysqli_fetch_array($run)){
?>
                                         <option value="<?php echo $row['itemid']; ?>"><?php echo $row['itemname']; ?></option>
                                     <?php } ?>
                                     </select>
                        </div>

                                <div class="form-group col-md-2 col-xs-12">
                                       <label>Qty</label>
                                       <input autocomplete="off" type="text" class="form-control input-default" name="" id="qty">
                                       </div>
                                        <div class="form-group col-md-2 col-xs-12">
                                       <label>Frieght</label>
                                       <input type="text" class="form-control input-default" name="" id="frieght">
                              <label style="color: red;"><input type="checkbox" value="" id="checkpending">Bilty Pending</label>
               
                      <label style="color: red;"> <input style="size: 25px;" type="checkbox" id="custbiltybox" name="" value="bilty credit"> Bilty Credit</label>
                
                  <label style="color: red;"><input type="checkbox" value="" id="nillbilty">Null Bilty</label>
                              
                                  </div>
                                      <div class="form-group col-md-2 col-xs-12">
                                       <label>S.Rate</label>
                                       <input autocomplete="off" type="text" class="form-control input-default" name="" id="Srate" >
                                         <input disabled style="margin-left: 5px; width: 100px; border-radius: 5px;" type="text" name="" id="Samt">
                                       </div>

                                      
                                       <div class="form-group col-md-2 col-xs-12">
                                       <label>C.Rate </label>
                                        <input autocomplete="off" type="text" class="form-control input-default" name="tAmount" id="Crate">

                                            <input disabled style="margin-left: 5px; width: 100px; border-radius: 5px;" type="text" name="" id="Camt">
                                       </div>
        </div>

             
               
    

            </div>
        </div>
    </div>
</div>

<div class="row">
    <div class="box col-md-12">
        <div class="box-inner">
        <div class="box-header well">
                <h2><i class="glyphicon glyphicon-info-sign"></i> RATE DETAIL</h2>

                <div class="box-icon">
                    <a href="#" class="btn btn-setting btn-round btn-default"><i
                            class="glyphicon glyphicon-cog"></i></a>
                    <a href="#" class="btn btn-minimize btn-round btn-default"><i
                            class="glyphicon glyphicon-chevron-up"></i></a>
                    <a href="#" class="btn btn-close btn-round btn-default"><i
                            class="glyphicon glyphicon-remove"></i></a>
                </div>
            </div>
            <div class="box-content row">
                 <div id="itemdetail" class="col-lg-12 col-md-12">
                                
               </div>


                 <div class="col-lg-12 col-md-12" style="margin-bottom: 20px;">
                 <div class="col-lg-12 col-md-4">

                <label>Select Qty</label>
                
             <!--      <label style="margin-left: 20px; color: red;">Farmer Rate<input type="checkbox" value="" id="farmrid"></label>
                  <label style="margin-left: 20px; color: red;">New Rate Company<input type="checkbox" value="" id="addrateco"></label>
                  <label style="margin-left: 20px; color: red;">New Rate Shed<input type="checkbox" value="" id="addrateshd"></label>
                  <label style="margin-left: 20px; color: red;">Disc Rate Co.<input type="checkbox" value="" id="discco"></label>
                  <label style="margin-left: 20px; color: red;">Disc Rate Shed<input type="checkbox" value="" id="discshd"></label> -->
                </div>
             
                </div>

                 <div class="col-lg-6 col-md-12">
            <button id="qty50"  class="btn btn-inverse btn-danger btn-sm">50</button>
            <button id="qty100" class="btn btn-inverse btn-danger btn-sm">100</button>
            <button id="qty150" class="btn btn-inverse btn-danger btn-sm">150</button>
            <button id="qty200" class="btn btn-inverse btn-danger btn-sm">200</button>
            <button id="qty300" class="btn btn-inverse btn-danger btn-sm">300</button>
            <button id="qty400" class="btn btn-inverse btn-danger btn-sm">400</button>
            <button id="qty600" class="btn btn-inverse btn-danger btn-sm">600</button>
            <button id="qty800" class="btn btn-inverse btn-danger btn-sm">800</button>
            <button id="qty1000" class="btn btn-inverse btn-danger btn-sm">1000</button>
            </div>
     <div  class="col-lg-4 col-md-12">
            <input autocomplete="off" type="text" name="" id="refbox" class="input-default form-control">

             </div>
                <div style="margin-bottom: 30px;" class="col-lg-1 col-md-12">
            <button id="postdata"  class="btn btn-inverse btn-danger">Submit Data</button>

             </div>


              

         
</div>
</div>
  </div>
      </div>


<!-- ********************************** -->


<div class="row">
    <div class="box col-md-12">
        <div class="box-inner">
            <div class="box-header well">
                <h2><i class="glyphicon glyphicon-info-sign"></i>Voucher Details</h2>

                <div class="box-icon">
                    <a href="#" class="btn btn-setting btn-round btn-default"><i
                            class="glyphicon glyphicon-cog"></i></a>
                    <a href="#" class="btn btn-minimize btn-round btn-default"><i
                            class="glyphicon glyphicon-chevron-up"></i></a>
                    <a href="#" class="btn btn-close btn-round btn-default"><i
                            class="glyphicon glyphicon-remove"></i></a>
                </div>
            </div>
            <div class="box-content row">
                <div class="col-lg-12 col-md-12">
                  <table class="table table-striped table-bordered bootstrap-datatable datatable responsive">
    <thead>
    <tr>
        <th>V.No</th>
        <th>Account Title</th>
        <th>Qty</th>
        <th>Pr_Rate</th>
        <th>Sl_Rate</th> 
    </tr>
    </thead>
    <tbody id="itemdetail2">

                     


         </tbody>
    </table>
                       



                </div>
            </div>
        </div>
    </div>
</div>


   

    <hr>

    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true">

        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">×</button>
                    <h3>Settings</h3>
                </div>
                <div class="modal-body">
                    <p>Here settings can be configured...</p>
                </div>
                <div class="modal-footer">
                    <a href="#" class="btn btn-default" data-dismiss="modal">Close</a>
                    <a href="#" class="btn btn-primary" data-dismiss="modal">Save changes</a>
                </div>
            </div>
        </div>
    </div>

<?php
include 'template/footer.php';
?>


  <script type="text/javascript">
 $('#chkdtl').click(function(){

    var ddate = $("#dated").val();
             $.ajax({
        url: 'fdtodaydtl.php',
        method: 'POST',
       data: {ddate: ddate},
        success: function(data){
            // $('#prate').val(data);
                $('#itemdetail').html(data);
        document.getElementById('tabless').scrollIntoView();

        }
      })
       
  })
 
</script> 


<script type="text/javascript">
$("#msfeed").click(function(){
    $('#selaccid').val('940').change();
})

$("#shamim").click(function(){
    $('#selaccid').val('80').change();
})

$("#mumtaz").click(function(){
    $('#selaccid').val('98').change();
})

$("#star").click(function(){
    $('#selaccid').val('97').change();
})

$("#suncrop").click(function(){
    $('#selaccid').val('99').change();
})

$("#sabir").click(function(){
    $('#selaccid').val('504').change();
})

$("#royal").click(function(){
    $('#selaccid').val('539').change();
})

$("#chanab").click(function(){
    $('#selaccid').val('371').change();
})

$("#punjab").click(function(){
    $('#selaccid').val('779').change();
})

$("#aziz").click(function(){
    $('#selaccid').val('809').change();
})


$("#jadeed").click(function(){
    $('#selaccid').val('828').change();
})

$("#kausar").click(function(){
    $('#selaccid').val('250').change();
})

$("#selaccid").change(function(){

    var acid=$("#selaccid").val()

        event.preventDefault();
 
            $.ajax({
        url: 'fdrtdtl.php',
        method: 'POST',
       data: {acid: acid},
        success: function(data){
        $('#itemdetail').html(data);
        }
      })
})

</script>

<script type="text/javascript">
  $("#qty50").click(function(){
  $("#qty").val(50)
    var qty= $("#qty").val()
  var suprate= $("#Srate").val()
  var custrate= $("#Crate").val()
  $("#Samt").val(suprate*qty)
  $("#Camt").val(custrate*qty)
})

  $("#qty100").click(function(){
  $("#qty").val(100)
    var qty= $("#qty").val()
  var suprate= $("#Srate").val()
  var custrate= $("#Crate").val()
  $("#Samt").val(suprate*qty)
  $("#Camt").val(custrate*qty)
})
    $("#qty150").click(function(){
  $("#qty").val(150)
    var qty= $("#qty").val()
  var suprate= $("#Srate").val()
  var custrate= $("#Crate").val()
  $("#Samt").val(suprate*qty)
  $("#Camt").val(custrate*qty)
})
      $("#qty200").click(function(){
  $("#qty").val(200)
    var qty= $("#qty").val()
  var suprate= $("#Srate").val()
  var custrate= $("#Crate").val()
  $("#Samt").val(suprate*qty)
  $("#Camt").val(custrate*qty)
})
        $("#qty300").click(function(){
  $("#qty").val(300)
    var qty= $("#qty").val()
  var suprate= $("#Srate").val()
  var custrate= $("#Crate").val()
  $("#Samt").val(suprate*qty)
  $("#Camt").val(custrate*qty)
})
          $("#qty400").click(function(){
  $("#qty").val(400)
    var qty= $("#qty").val()
  var suprate= $("#Srate").val()
  var custrate= $("#Crate").val()
  $("#Samt").val(suprate*qty)
  $("#Camt").val(custrate*qty)
})
            $("#qty600").click(function(){
  $("#qty").val(600)
    var qty= $("#qty").val()
  var suprate= $("#Srate").val()
  var custrate= $("#Crate").val()
  $("#Samt").val(suprate*qty)
  $("#Camt").val(custrate*qty)
})
              $("#qty800").click(function(){
  $("#qty").val(800)
    var qty= $("#qty").val()
  var suprate= $("#Srate").val()
  var custrate= $("#Crate").val()
  $("#Samt").val(suprate*qty)
  $("#Camt").val(custrate*qty)
})
  $("#qty1000").click(function(){
  $("#qty").val(1000)
    var qty= $("#qty").val()
  var suprate= $("#Srate").val()
  var custrate= $("#Crate").val()
  $("#Samt").val(suprate*qty)
  $("#Camt").val(custrate*qty)
})
</script>

<script type="text/javascript">
  
 $("#qty").keyup(function(){

  var qty= $("#qty").val()
  var suprate= $("#Srate").val()
  var custrate= $("#Crate").val()
  $("#Samt").val(suprate*qty)
  $("#Camt").val(custrate*qty)
 })
</script>

<script type="text/javascript">
  
 $("#Srate").keyup(function(){

  var qty= $("#qty").val()
  var suprate= $("#Srate").val()
  $("#Samt").val(suprate*qty)
 })
</script>


<script type="text/javascript">
  
 $("#Crate").keyup(function(){

  var qty= $("#qty").val()
  var custrate= $("#Crate").val()
  $("#Camt").val(custrate*qty)
 })
</script>

<script>
  $( function() {
    $( "#datepicker" ).datepicker();
  } );
  </script>

<script type="text/javascript">
 var today = new Date();

document.getElementById("dated").value = today.getFullYear() + '-' + ('0' + (today.getMonth() + 1)).slice(-2) + '-' + ('0' + today.getDate()).slice(-2);
  </script>
<script>

$(document).ready(function(){
      var dated = $('#dated').val();
               $.ajax({
        url: 'ffddetail.php',
        method: 'POST',
       data: {dated: dated},
        success: function(data){
            $('#itemdetail2').html(data);
        }
      });


});
</script>
<script type="text/javascript">
  
 $("#dated").change(function(){
   var dated = $('#dated').val();
               $.ajax({
        url: 'ffddetail.php',
        method: 'POST',
       data: {dated: dated},
        success: function(data){
            $('#itemdetail2').html(data);
        }
      });

 })
</script>

<!-- POST DATA INTO DATABASE -->
<script type="text/javascript">
    
$('#postdata').click(function(e){
  if($('#qty').val()==""){

    alert("Enter Qty");
    $('#qty').focus(); 
    alert($('#dated').val())
  }
  else{
    if($('#Crate').val()==""){
      alert("Enter Customer Rate");
    $('#Crate').focus(); 

    }
    else{
      var amt = $('#Camt').val();
      if(amt ==0) {
        alert("empty");
      }
      else{

        // var vno,refno,dated,supid,qty,kat,srate,crate,samt,camt,custid,itemid;
       var vno = $('#vno').text();
       var refno = $('#vno').text();
       var refno2 = $('#refbox').val();
       var dated = $('#dated').val();
       var supid = $('#selaccid').val();
       var qty = $('#qty').val();
       var frieght = $('#frieght').val();
       var srate = $('#Srate').val();
       var crate = $('#Crate').val();
       var samt = $('#Samt').val();
       var camt = $('#Camt').val();
       var custid = $('#selaccid2').val();
       var itemid = $('#itemid').val();
       if($('#custbiltybox'). prop("checked") == true){

  custbilty=1;
}
else{
  custbilty="";
}

if($('#checkpending'). prop("checked") == true){
//   var vl= 2;
// $('#frieght').val(vl);
//    frieght = $('#frieght').val();
  custbilty2=0;

}

else
{
  custbilty2=1;
}

if($("#frieght").val()=="" && $('#nillbilty'). prop("checked") == false && $('#checkpending'). prop("checked") == false){
  alert("Enter Frieght")

}
else{
       $('#postdata').hide();
            event.preventDefault();
 
            $.ajax({
        url: 'addfed.php',
        method: 'POST',
       data: {custbilty2: custbilty2, custbilty: custbilty, refno2: refno2, vno: vno, refno: refno, dated: dated, supid: supid, qty: qty, frieght: frieght, srate: srate, crate:crate, samt:samt, camt:camt, custid:custid, itemid:itemid},
        success: function(data){
            // $('#prate').val(data);
              $('#qty').focus();
             
             var vno2 = parseInt(1);
              var vno3 = parseInt(vno);
             $('#vno').text(vno3+vno2);

                // $('#itemdetail').html(data);
                 alert(data);
                 // $('#refreshbtn').click();
                // $('#refbox').val("");
                 $('#qty').val("");
                 $('#frieght').val("");
                 $('#Srate').val("");
                 $('#Crate').val("");
                 $('#Camt').val("");
                 $('#Samt').val("");
       $('#postdata').show();

        }
      })
   
            }
      }
    }
  }

});
</script>

<script type="text/javascript">
  
 $("#selaccid2").change(function(){

  var acid= $("#selaccid2").val()
      event.preventDefault();

       $.ajax({
        url: 'shedname.php',
        method: 'POST',
       data: {acid: acid},
        success: function(data){
        $('#refbox').val(data);
        }
      })
 })
</script>

</body>
</html>
<?php 
}
?>