<?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" />


  <link rel="stylesheet" href="css/jquery-ui.css">
        <link rel="stylesheet" href="bootstrap.min.css" />
    <script src="js/jquery-1.12.4.js"></script>
     <script src="js/jquery-ui.js"></script>
<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="#">Broiler Transfer</a>
        </li>
    </ul>
</div>
  <style>
/* Chrome, Safari, Edge, Opera */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Firefox */
input[type=number] {
  -moz-appearance: textfield;
}


.inpbox {
  /*background-color: lightgreen;*/
  width: 100px;
  padding: 5px;
  margin-left: 10px;
}

@media only screen and (max-width: 600px) {
  .inpbox {
    /*background-color: lightblue;*/
    width: 70%;
  color: black;
  padding: 5px;
  margin-top: 10px;

  }

  .mydv{
    margin-top: 20px;
    margin-bottom: 20px;
  }
    .mydv2{

    margin-bottom: 20px;
  }
}


</style> 
<div class="row">
    <div class="box col-md-12">
            <input type="text" placeholder="Bwp" name="" id="rtbwp">
<input type="text" placeholder="List" name="" id="rtlst">
<button id="btnsav" class="btn btn-xs btn-primary">save</button>
        <div class="box-inner">

          
         <?php
                    require 'connection.php';

                 $qryvno = "SELECT max(vno) as vno FROM broilertransfer";
             $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> Broiler Transfer </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 col-sm-12 ">
                  <div class="pull-right" class="col-lg-12 col-md-12 col-sm-12 ">
               <input class="mydv2" style=" border: none; border-bottom: 1px solid black;  font-size: 2rem" type="date"  data-date-format="DD MMMM YYYY" id="dated">
                </div>
                </div>
       <!-- dated -->
          


                <!-- Account -->
              
                  <div style="margin-bottom: 20px; margin-top: 20px;" class="col-lg-12 col-md-12 col-sm-12" >

                <div class="col-lg-4 col-md-12 col-sm-12" >
<label>Creditor / جمع پارٹی</label>

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

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

      <div  class="col-lg-6 col-md-12 col-sm-12 mydv"> 
                               <label>Debitor / بنام پارٹی</label>
   
                  <select id="custid" class="form-control selectpicker"data-live-search="true">
                 <?php
                    require 'connection.php';

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

                      <div style=" float: right;" class="col-lg-2 col-md-12 col-sm-12 " >
                    
                 <select id="vid" class="form-control selectpicker"data-live-search="true">
                 <?php
                    require 'connection.php';

              $qry = "SELECT * FROM broilertransfer";
             $run = mysqli_query($connect, $qry) or die(mysqli_error($connect));
    while($row = mysqli_fetch_array($run)){
?>
        <option id="dd" value="<?php echo $row['vno']; ?>"><?php echo $row['vno']; ?></option>
        <?php } ?>
            </select>
             <i  id="refresh" style="color: red; height: 70px; width: 70px;" class="glyphicon glyphicon-search  btn-lg"></i>
            </div>  

                </div>
<!-- *********************************** -->

       
     


                <br>
                <br>
                <br>
      <div class="col-lg-12 col-md-12">
      

        <input class="inpbox"  placeholder="Ref.No." autocomplete="off" type="number" name="refno" id="refno"  />


        <span id="error_qty" class="text-danger"></span>
      
        
        <input class="inpbox" placeholder="Qty" autocomplete="off"  type="number" name="qty" id="qty" />
        <span id="error_qty" class="text-danger"></span>
 



        <input class="inpbox" placeholder="P.Rate" autocomplete="off"  type="number" name="prate" id="prate"  />
        <input  type="checkbox"  id="fixprate2">
        
        <span id="error_rate" class="text-danger"></span>
     


        <input class="inpbox" placeholder="S.Rate" autocomplete="off"  type="number" name="rate" id="rate"  />
        <input  type="checkbox"  id="fixrate">

        <span id="error_rate" class="text-danger"></span>
    
      
        <input  class="inpbox" placeholder="S.Amount" disabled  type="text" name="amt" id="amt" />
        <span id="error_amt" class="text-danger"></span>
   

      </div>

      <div class="form-group" align="center">
        <input type="hidden" name="row_id" id="hidden_row_id" />
        <!-- <button type="button" name="save" id="save" class="btn btn-info">Save</button> -->
        <!-- <button type="button" name="post" id="post" class="btn btn-info">POST</button> -->
      </div>

    <div id="action_alert" title="Action">

    </div>



      <form method="post" id="user_form">
        <div class="col-lg-12">
          <label class="glyphicon glyphicon-shopping-cart" style="color: maroon; font-size: 30px; margin-top: 3px; margin-left: 15px;"></label>
          <label class="" style="color: maroon; font-size: 20px;">Add to Cart</label>
          <!-- <table class="table table-striped table-bordered" id="user_data"> -->
                  <table class="table" id="user_data">

            <tr>
                   <th hidden>ID</th>
                   <th hidden>ID2</th>
                   <th hidden>Date</th>
                    <th>V.No.</th>
                    <th>Ref.No.</th>
                    <th>Qty</th>
                    <th>P_Rate</th>
                    <th>S_Rate</th>
                    <th>Details</th>
                    <th>Remove</th>
                  </tr>
             
           
          </table>

        </div>
        <div align="center">
        <input type="checkbox"  id="dontmsg2"><label style="color: red; margin-top: -20px;">Change Supplier</label>
<br>
<br>
        <input type="checkbox"  id="dontmsg"><label style="color: red; margin-top: -20px;">Change Customer</label>
<br>
<br>
          <input style="margin-bottom: 20px;" type="submit" name="insert" id="insert" class="btn btn-info" value="Insert into Database" />

 <img style=" display: none; height: 30px; width: 30px; margin-bottom: 20px;" id="load" src="ajaxresult.gif">

        <br>  


 

        </div>
      </form>
      <!-- <button disabled id="msgsnd" class="btn btn-danger">Send Sms ?</button> -->
   
    </div>





<!-- ************************************** -->
            </div>
<!-- ***************************************************************** -->

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

            <div class="box-header well">
                <h2></i>Detail Section</h2>
                <div class="box-icon">
                   
                    <a href="index.php" 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" id="itemdetail" style="margin-bottom: 20px;">
                
        <!--          <table class="table" id="table">
                    <tr>
                    <th>Sr. No.</th>
                    <th>Product Name</th>
                    <th>Rate</th>
                    <th>Qty</th>
                    <th>Amount</th>
                  </tr>
                                     <tbody id="itemdetail">
                                     </tbody>
                                   </table> -->
                             <!--       <div class="col-lg-9 col-md-12">
                           <input disabled style="float: right; width: 100px;" type="text" id="tamt" name="">
                           </div> -->

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

      <div class="col-lg-6 col-md-12">
   <!--   <button id="prev" class="btn btn-sm btn-danger">Previous Record</button>
     <button id="nxt" class="btn btn-sm btn-danger">Next Record</button>

     <button id="deltebtn" class="btn btn-sm btn-danger">Delete Record</button> -->
<?php 
  if($_SESSION['userId']==2532){

?>
  <button id="updtbtn" class="btn btn-sm btn-info">Update Record</button>
  <button id="dlttbtn" class="btn btn-sm btn-primary pull-right">Delete Voucher</button>
<?php 
}

?>
                           </div>
  <div class="col-lg-1 col-md-12">
    </div>
            </div>
        </div>
    </div>
</div>

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


        </div>


    </div>






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


    <!-- content ends -->
    </div><!--/#content.col-md-0-->
</div><!--/fluid-row-->

   

    <hr>



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



<script>  
$(document).ready(function(){ 
  
  var count = 0;
})


  $( 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>


  <!-- Fetch Rate -->
 <script type="text/javascript">
  $('.table').on('change','#selaccid',function(){
    var currow = $(this).closest('tr');
    var acid = $('#selaccid2').val();
    var itid = currow.find('#selaccid').val();
      event.preventDefault();
 
            $.ajax({
        url: 'ratmed.php',
        method: 'POST',
       data: {acid: acid, itid: itid},
        success: function(data){
  currow.find('#rate').val(data);
  currow.find('#rate').focus();

        }
      })

 })
</script>

 <script type="text/javascript">
  $('#msgsnd').click(function(){
    var dated = $('#dated').val();
      event.preventDefault();
 
            $.ajax({
        url: 'smspk.php',
        method: 'POST',
       data: {dated: dated},
        success: function(data){
          alert(data);
        }
      })

 })
</script>


  <!-- Fetch item detail-->
 <script type="text/javascript">
  $('#refresh').click(function(){

   
 // if($("#checkid").prop("checked") == true){
    var vno= $("#vid").val();
            $.ajax({
        url: 'brldetail.php',
        method: 'POST',
       data: {vno: vno},
        success: function(data){
          $("#itemdetail").html(data);
        }
      })
           // }


 })
</script>
<!-- NEXT INDEX -->
  <!-- Fetch item detail-->
 <script type="text/javascript">
  $('#nxt').click(function(){
  var isLastElementSelected = $('#vid > option:selected').index() == $('#vid > option').length -1;
  if(!isLastElementSelected){

        $("#vid").val($("#vid > option:selected").next().val());
$('#vid').change();
    var vno= $("#vid").val();
            $.ajax({
        url: 'brldetail.php',
        method: 'POST',
       data: {vno: vno},
        success: function(data){
          $("#itemdetail").html(data);
        }
      })
  }
  else{
    alert("This is last record !")
  }
 })
</script>

<!-- Previous INDEX -->
  <!-- Fetch item detail-->
 <script type="text/javascript">
  $('#prev').click(function(){
   var isFirstElementSelected = $('#vid > option:selected').index() == 0;
   if(!isFirstElementSelected){
      // $('#vid option:selected').prev().attr('selected', 'selected');
        $("#vid").val($("#vid > option:selected").prev().val());
$('#vid').change();
           var vno= $("#vid").val();
            $.ajax({
        url: 'brldetail.php',
        method: 'POST',
       data: {vno: vno},
        success: function(data){
          $("#itemdetail").html(data);
        }
      }) 
   }
  else{
    alert("This is first record !")
  }

 })
</script>


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

   var rate = $('#rate').val();
   var qty = $('#qty').val();
   var amt = parseInt(rate*qty)

  $('#amt').val(amt);

 })
</script>



 <script type="text/javascript">
  $('#custid').change(function(){
  $("#refno").focus();

 })
</script>

 <script type="text/javascript">
  $('#qty').keyup(function(e){
  if(e.keyCode == 13)
    {

       if($('#qty').val()!==""){
     $('#prate').focus();
      }
    }
 });

  $('#prate').keyup(function(e){
  if(e.keyCode == 13)
    {

       if($('#prate').val()!==""){
     $('#rate').focus();
      }
    }
 });



    $('#refno').keydown(function(e){
  if(e.keyCode == 13)
    {

    var refno= $("#refno").val();


       if($('#refno').val()==""){
        var vno = $("#vno").text();
        $("#refno").val(vno);

     $('#qty').focus();
      }
      else{


     $('#qty').focus();

      }
    }
 });
</script>


<?php 
  if($_SESSION['userId']==2532){

?>


 <!-- Detail invoice-->
 <script type="text/javascript">
  $('#updtbtn').click(function(){

    var vno= $("#vnoval").text();
    var refno= $("#refnoval").val();
    var dated= $("#datedval").val();
  

  if($("#dontmsg").prop("checked") == true){
    var custid= $("#custid").val();

  }
  else{
    var custid= $("#custidval").text();
    }

 if($("#dontmsg2").prop("checked") == true){
    var supid= $("#selaccid2").val();

  }
  else{
    var supid= $("#supidval").text();
    }

    
    var qty= $("#qtyval").val();
    var itemid=1;
    var crate= $("#crateval").val();
    var srate= $("#srateval").val();


  var updat= confirm("Do you realy want to Update Record# " + vno);
    if(updat){
         $.ajax({
        url: 'brlupdt.php',
        method: 'POST',
       data: {vno: vno, refno: refno, dated: dated, supid: supid, custid: custid, qty: qty, crate: crate, srate: srate,  itemid: itemid },
        success: function(data){
        alert(data);

        }
      })    
      }
 })
</script>



 <!-- Detail invoice-->
 <script type="text/javascript">
  $('#dlttbtn').click(function(){

    var vnodlt= $("#vnoval").text();


    var qty= $("#qtyval").val();
    var itemid=1;
    var crate= $("#crateval").val();
    var srate= $("#srateval").val();


  var updat= confirm("Do you realy want to Delete " + vnodlt);
    if(updat){
         $.ajax({
        url: 'brlupdt.php',
        method: 'POST',
       data: {vnodlt: vnodlt},
        success: function(data){
        alert(data);

        }
      })    
      }
 })
</script>




<?php } ?>


 <!-- Delete invoice-->
 <script type="text/javascript">
  $('#deltebtn').click(function(){

  var x = document.getElementById("vid");
  var option = document.createElement("option");
  option.text = "Kiwi";
  x.add(option);
 })
</script>

  <script type="text/javascript">
 $('#table').on('click','#dltbtn',function(){
   var currow = $(this).closest('tr');

// if($('#checkid'). prop("checked") == true){
    var vno= $("#vid").val(); 
// }


  var srno = currow.find('td:eq(0)').text();
            $.ajax({
        url: 'slitemdlt.php',
        method: 'POST',
       data: {vno: vno, srno: srno},
        success: function(data){
          $("#itemdetail").html(data);
        }
      })
})

  </script>



    <script type="text/javascript">
 $('#vid').change(function(){
// if($("#checkid").prop("checked") == true){
    var vno= $("#vid").val();
            $.ajax({
        url: 'brldetail.php',
        method: 'POST',
       data: {vno: vno},
        success: function(data){
          $("#itemdetail").html(data);
        }
      })
          // }
})

  </script>


   <script type="text/javascript">
  $('#btnsav').click(function(){
    var dated = $('#dated').val();
    var rtbwp = $('#rtbwp').val();
    var rtlst = $('#rtlst').val();
      event.preventDefault();
 
            $.ajax({
        url: 'adbrllst.php',
        method: 'POST',
       data: {dated: dated, rtbwp: rtbwp, rtlst: rtlst,},
        success: function(data){
          alert(data);
        }
      })

 })
</script>


<script>  
$(document).ready(function(){ 
  
  var count = 0;

  $('#user_dialog').dialog({
    autoOpen:false,
    width:400
  });

  $('#add').click(function(){
    $('#user_dialog').dialog('option', 'title', 'Add Data');
    $('#first_name').val('');
    $('#last_name').val('');
    $('#ids').val('');
    $('#error_first_name').text('');
    $('#error_last_name').text('');
    $('#ids').text('');
    $('#first_name').css('border-color', '');
    $('#last_name').css('border-color', '');
    $('#last_name1').css('border-color', '');
    $('#save').text('Save');
    $('#user_dialog').dialog('open');
  });


  $('#rate').keydown(function(e){
if(e.keyCode==13 && $("#qty").val()!=="" && $("#qty").val()>0)
{
   var custid = $('#custid').val();
    var accid =  $('#selaccid2').val();
    var vno =  $('#vno').text();
    var vno2= parseInt(vno)+1;
    var dated =  $('#dated').val();
    var itemid = 1;
    var refno =  $('#refno').val();
    var prate =  $('#prate').val();
    var rate =  $('#rate').val();
    var qty =  $('#qty').val();
    count = count + 1;
    var srno =  count;

        output = '<tr id="row_'+count+'">';
        output += '<td hidden>'+accid+' <input type="hidden" name="hidden_accid[]" id="accid'+count+'" class="accid" value="'+accid+'" /></td>';

        output += '<td hidden>'+custid+' <input type="hidden" name="hidden_custid[]" id="custid'+count+'" class="custid" value="'+custid+'" /></td>';
        output += '<td hidden>'+dated+' <input type="hidden" name="hidden_dated[]" id="dated'+count+'" value="'+dated+'" /></td>';

   output += '<td>'+vno+' <input type="hidden" name="hidden_vno[]" id="vno'+count+'" class="vno" value="'+vno+'" /></td>';

        output += '<td>'+refno+' <input type="hidden" name="hidden_refno[]" id="refno'+count+'" value="'+refno+'" /></td>';

   output += '<td hidden>'+itemid+' <input type="hidden" name="hidden_itemid[]" id="itemid'+count+'" value="'+itemid+'" /></td>';

  
   output += '<td>'+qty+' <input type="hidden" name="hidden_qty[]" id="qty'+count+'" value="'+qty+'" /></td>';
    output += '<td>'+prate+' <input type="hidden" name="hidden_prate[]" id="prate'+count+'" value="'+prate+'" /></td>';
    output += '<td>'+rate+' <input type="hidden" name="hidden_rate[]" id="rate'+count+'" value="'+rate+'" /></td>';

        output += '<td><button type="button" name="view_details" class="btn btn-warning btn-xs view_details" id="'+count+'">View</button></td>';

        output += '<td><button type="button" name="remove_details" class="btn btn-danger btn-xs remove_details" id="'+count+'">Remove</button></td>';
        output += '</tr>';
        $('#user_data').append(output);
        // $('#user_dialog').dialog('close');
        $("#refno").val("");
        $("#qty").val("");
        var i=1;

$('#vid').append(new Option('Foo', 'foo', true, true));

        $("#vno").text(vno2);

if($('#fixrate'). prop("checked")!== true){
        $("#rate").val("");
  }

  if($('#fixrate2'). prop("checked")!== true){
        $("#prate").val("");
  }

        $("#amt").val("");
        $("#refno").focus();
}
});



  $('#save').click(function(){
    var error_first_name = '';
    var error_last_name = '';
    var first_name = '';
    var last_name = '';
    if($('#first_name').val() == '')
    {
      error_first_name = 'First Name is required';
      $('#error_first_name').text(error_first_name);
      $('#first_name').css('border-color', '#cc0000');
      first_name = '';
    }
    else
    {
      error_first_name = '';
      $('#error_first_name').text(error_first_name);
      $('#first_name').css('border-color', '');
      first_name = $('#first_name').val();
    } 
    if($('#last_name').val() == '')
    {
      error_last_name = 'Last Name is required';
      $('#error_last_name').text(error_last_name);
      $('#last_name').css('border-color', '#cc0000');
      last_name = '';
    }
    else
    {
      error_last_name = '';
      $('#error_last_name').text(error_last_name);
      $('#last_name').css('border-color', '');
      last_name = $('#last_name').val();
    }

      if($('#last_name1').val() == '')
    {
      error_last_name1 = 'Last Name1 is required';
      $('#error_last_name1').text(error_last_name1);
      $('#last_name1').css('border-color', '#cc0000');
      last_name1 = '';
    }
    else
    {
      error_last_name1 = '';
      $('#error_last_name1').text(error_last_name1);
      $('#last_name1').css('border-color', '');
      last_name1 = $('#last_name1').val();
    }

    if(error_first_name != '' || error_last_name != '' || error_last_name1 != '')
    {
      return false;
    }
    else
    {
      if($('#save').text() == 'Save')
      {
        count = count + 1;
        output = '<tr id="row_'+count+'">';
        output += '<td>'+first_name+' <input type="hidden" name="hidden_first_name[]" id="first_name'+count+'" class="first_name" value="'+first_name+'" /></td>';
        
        output += '<td>'+last_name+' <input type="hidden" name="hidden_last_name[]" id="last_name'+count+'" value="'+last_name+'" /></td>';

      output += '<td>'+last_name1+' <input type="hidden" name="hidden_last_name1[]" id="last_name1'+count+'" value="'+last_name1+'" /></td>';

        output += '<td><button type="button" name="view_details" class="btn btn-warning btn-xs view_details" id="'+count+'">View</button></td>';

        output += '<td><button type="button" name="remove_details" class="btn btn-danger btn-xs remove_details" id="'+count+'">Remove</button></td>';
        output += '</tr>';
        $('#user_data').append(output);

      }
      else
      {
        var row_id = $('#hidden_row_id').val();
        output = '<td>'+first_name+' <input type="hidden" name="hidden_first_name[]" id="first_name'+row_id+'" class="first_name" value="'+first_name+'" /></td>';
      
          output += '<td>'+last_name1+' <input type="hidden" name="hidden_last_name[]" id="last_name'+row_id+'" value="'+last_name+'" /></td>';

        output += '<td>'+last_name1+' <input type="hidden" name="hidden_last_name1[]" id="last_name1'+row_id+'" value="'+last_name1+'" /></td>';
          
            output += '<td>'+last_name+' <input type="hidden" name="hidden_last_name[]" id="last_name'+row_id+'" value="'+last_name+'" /></td>';

        output += '<td><button type="button" name="view_details" class="btn btn-warning btn-xs view_details" id="'+row_id+'">View</button></td>';
        output += '<td><button type="button" name="remove_details" class="btn btn-danger btn-xs remove_details" id="'+row_id+'">Remove</button></td>';
        $('#row_'+row_id+'').html(output);
      }
      $("#first_name").focus();
       $('#user_dialog').dialog('close');
    }
  });


  $(document).on('click', '.view_details', function(){
    var row_id = $(this).attr("id");
    var srno = $('#srno'+row_id+'').val();
    var accid = $('#accid'+row_id+'').val();
    var itemid = $('#itemid'+row_id+'').val();
    var rate = $('#rate'+row_id+'').val();
    var qty = $('#qty'+row_id+'').val();
    $('#srno').val(srno);
    $('#accid').val(accid);
    $('#itemid').val(itemid);
    $('#rate').val(rate);
    $('#qty').val(qty);
    $('#save').text('Edit');
    $('#hidden_row_id').val(row_id);
    $('#user_dialog').dialog('option', 'title', 'Edit Data');
    $('#user_dialog').dialog('open');
  });

  $(document).on('click', '.remove_details', function(){
    var row_id = $(this).attr("id");
    if(confirm("Are you sure you want to remove this row data?"))
    {
      $('#row_'+row_id+'').remove();
    }
    else
    {
      return false;
    }
  });

  $('#action_alert').dialog({
    autoOpen:false
  });

  $('#user_form').on('submit', function(event){
    event.preventDefault();
     var save= confirm("Do you realy want to save this invoice?");
    if(save){
      $("#load").show();
    var count_data = 0;
    $('.vno').each(function(){
      count_data = count_data + 1;
    });
    if(count_data > 0)
    {
      if($('#dontmsg'). prop("checked")== true){
      var form_data = $(this).serialize();
      $.ajax({
        url:"addbrl2.php",
        method:"POST",
        data:form_data,
        success:function(data)
        {
           $('#user_data').find("tr:gt(0)").remove();
        
          alert(data);
      $("#load").hide();
      $("#refno").focus();

           // location.reload(true);
        }
      })

        }
        else{

              var form_data = $(this).serialize();
      $.ajax({
        url:"addbrl2.php",
        method:"POST",
        data:form_data,
        success:function(data)
        {
           $('#user_data').find("tr:gt(0)").remove();
        
          alert(data);
      $("#load").hide();

           // location.reload(true);
        }
      })

        }

    }
    else
    {
      $('#action_alert').html('<p>Please Add atleast one data</p>');
      $('#action_alert').dialog('open');
    }
  }
  });
  
});  
</script>


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