<?php
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';

?>
<style type="text/css">
@media only screen and (max-width: 600px) {
.desc{
    width: 100%;
    margin-bottom: 10px;
           }

           .inpbx{
width: 49%;
           }

       }
       @media only screen and (max-width: 2024px) {
.desc{
    width: 100%;
           }

           .inpbx{
width: 49%;
           }

       }
.desc{
  font-size: 16px;

           }

           .inpbx{
font-size: 16px;
           }
   </style>

        <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="ffdslr.php">Voucher Transfer</a>
        </li>
    </ul>
</div>

<div class="row">
    <div class="box col-md-12">
        <div class="box-inner">
<style type="text/css">
    


</style>
        
         <?php
                    require 'connection.php';

                 $qryvno = "SELECT max(tvno) as tvno FROM trvoucher";
             $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> Transfer Voucher</h2>
                <h2 id="prid" style="margin-left: 10px"><?php echo $rowvno['tvno']+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: 10px">
               <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>
                <br>
                <br>
                <div class="col-lg-12 col-md-12 col-sm-12" style="margin-bottom: 10px">
                    
                      <div class="col-lg-12 col-md-12">
                        <label>Transfer From</label>
                    <select id="selaccid" 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 value="<?php echo $row['accid']; ?>"><?php echo $row['accname']; ?></option>
                                     <?php } ?>
                                     </select>
                                     </div>
                        
           

                         <div  style="margin-top: 20px; margin-bottom: 20px;" class="col-lg-12 col-md-12 col-sm-12">
                            <div  class="col-lg-7 col-md-7 col-sm-12">
                                       <input class="desc"   autocomplete="off" type="text"  name="" id="desc" placeholder="Description">
                                 
                          </div>
                            <div  class="col-lg-5 col-md-5 col-sm-12">
                                     <input class="inpbx"  autocomplete="off" type="number"  placeholder="Debit" name="" id="debit" >
                                       <input class="inpbx" autocomplete="off" type="number"  placeholder="Credit" name="tAmount" id="credit">
                                       </div>

                                       </div>

                                 <div class="col-lg-12 col-md-12">
                                <LABEL>Transfer To</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 value="<?php echo $row['accid']; ?>"><?php echo $row['accname']; ?></option>
                                     <?php } ?>
                                     </select>
                                    </div>
                 <br>
                        <div class="col-lg-12 col-md-12">
                 <br>

                                    <button id="postdata"  class="btn btn-primary">Save Record</button>                   
        </div>
  
                                    </div>     
             
               
    

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



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

   

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


<!-- POST DATA INTO DATABASE -->
<script type="text/javascript">
    
$('#postdata').click(function(e){
  var accid = $('#selaccid').val();
var dated = $('#dated').val();
var tvno = 0;
var description = $('#desc').val();
var debit = $('#debit').val();
var credit = $('#credit').val();
var accidto = $('#selaccid2').val();
 if(debit=="" && credit==""){

  alert("Enter Amount");
}
else{
 event.preventDefault();
 
            $.ajax({
        url: 'addtrv.php',
        method: 'POST',
       data: {accid: accid, tvno: tvno, description: description, dated: dated, debit: debit, credit: credit, accidto: accidto},
        success: function(data){
            // $('#prate').val(data);
             $('#Invono').val("");
             $('#debit').val("");
             $('#credit').val("");
              $('#Invono').focus(); 
                  var v1 = parseInt(1);
              var v2 = parseInt(tvno);
              $('#prid').val(v1+v2);
               alert(data);
          
              // alert(v1+v2);
        }
      })

}
 

});
</script>



</body>
</html>
