<?php


  //invoice.php  


  include('db_con.php');  


  include('function.php');


  


  if (isset($_SESSION['user_id'])) {


    $user_type = $_SESSION['user_type'];


    $user_id = $_SESSION['user_id'];


    $user_name = $_SESSION['user_name'];


    $branch_id = $_SESSION['branch_id'];


    $branch_name = $_SESSION['branch_name'];


    $store_id = $_SESSION['store_id'];


    $store_name = $_SESSION['store_name'];


}else{


  header('Location: login');


  die();


}


$dated = date('Y-m-d');


$fdated = date('Y-01-01');


  if(isset($_POST["print"]))


  {


   


   $fdate = $_POST['fdate'];


   $tdate = $_POST['tdate'];


   


   $sv_id = $_POST['sv_id'];


   $rpt_type = $_POST['rpt_type'];





   $v_id = $sv_id;





   $acc_no = "201".$sv_id;


      


      //$result = $statement->fetchAll();


    if($rpt_type==0)


    {


      header('location:rpt_svl_preview?print=1&sv_id='.$sv_id.'&fdate='.$fdate.'&tdate='.$tdate.'');


    }else{


       header('location:rpt_svl_detail_preview?print=1&acc_no='.$acc_no.'&sv_id='.$sv_id.'&fdate='.$fdate.'&tdate='.$tdate.'');


    }


  }


           


  ?>


<!DOCTYPE html>


<html>


<head>


  <?php include('include/head.php'); ?>


  


</head>


<body>


  <?php include('include/header.php'); ?>


  <?php include('include/sidebar.php'); ?>


   <?php include('include/script.php'); ?>


<div class="main-container">


  <!-- Content Wrapper. Contains page content -->


  <div class="content-wrapper">


    <!-- Content Header (Page header) -->


    <div class="content-header">


      <div class="container-fluid">


        <div class="row mb-2">


          <div class="col-sm-6">


            <h1 class="m-0 text-dark"></h1>


          </div><!-- /.col -->


          <div class="col-sm-6">


            <ol class="breadcrumb float-sm-right">


              <li class="breadcrumb-item active">AP</li>


              <li class="breadcrumb-item active">Reports </li>


              <li class="breadcrumb-item active">SubVendor Ledger </li>


            </ol>


          </div><!-- /.col -->


        </div><!-- /.row -->


      </div><!-- /.container-fluid -->


    </div>


    <!-- /.content-header -->


    <!-- Main content -->


    <section class="content">


      <div class="container-fluid">


        <!-- Small boxes (Stat box) -->


     <span id="alert_action"></span>


    <div class="row">


        <div class="col-12">


          <div class="card">


            <div class="card-header">


            <div class="row">


                          <div class="col-lg-10 col-md-10 col-sm-8 col-xs-6">


                              <h3 class="panel-title">AP Report</h3>


                            </div>


                            


                        </div>


            </div>


            <!-- /.card-header -->


            <div class="card-body">


       <form method="post" id="report_form">


      <br />


      


        <div class="table-responsive">


          <table class="table table-bordered">


            <tr>


              <td colspan="2" align="center"><h2 style="margin-top:10.5px">SubVendor Ledger</h2></td>


            </tr>


            <tr>


                <td colspan="2">


                  <div class="row">


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


                    <select name="sv_id" id="sv_id" class="form-control input-sm sv_id select2" required />


                       


                          <?php echo fill_sv_name($connect);?>


                        </select>


                        <br />


                        <br />


                     <select name="rpt_type" id="rpt_type" class="form-control rpt_type" />


                     <option value="0">Without Detail


                       


                     </option>


                       <option value="1">With Detail


                       


                     </option>


                      </select>          


                      <br />


                     <b>From :</b><input type="text" name="fdate" id="fdate" class="form-control input-sm" readonly value="<?php echo $fdated; ?>" AutoComplete="off" required />  <br />


                     <b>To :</b><input type="text" name="tdate" id="tdate" class="form-control input-sm" readonly value="<?php echo $dated; ?>" AutoComplete="off" required />  <br />   


                           


                  


                


                    </div>                    


                  </div>                   


                  </td>


                  </tr>


                       


            


              <tr>


                <td colspan="2" align="center">


                <input type="submit" name="print" id="print" class="form-control btn btn-info" value="Preview" />


                 


                 


                </td>


              </tr>


          </table>


        </div>


      </form>


       </div>


              </div>


          </div>


      </div>


             


        


        


      </div><!-- /.container-fluid -->


    </section>


    <!-- /.content -->


 


  <!-- /.content-wrapper -->


 


  


  <script src="js/jquery-ui.js"></script>


  <script src="js/jquery-ui.min.js"></script>


    </div>


    </div>


 


  


</body>


</html>


<script>


 


  $(document).ready(function(){


    $('#fdate').datepicker({


      dateFormat: 'yy-mm-dd',


      changeMonth: true,


      changeYear: true


    });


  })


  </script>


<script>


 


  $(document).ready(function(){


    $('#tdate').datepicker({


      dateFormat: 'yy-mm-dd',


      changeMonth: true,


      changeYear: true


    });


  })


  </script>


  <script>


   $(document).ready(function(){


         $('#v_id').change(function(){


            var v_id = $(this).val();


            $.ajax({


              url:"find_sub_vendors.php",


              method:"POST",


              data:{v_id:v_id},


              dataType:"text",


              success:function(data)


              {


                $('#sv_id').html(data);


                var len  = $('#sv_id option').length;


              if(len > 1)


              {


                document.getElementById("sv_id").required = true;


              }else{ document.getElementById("sv_id").required = false;}


               // $('#sv_id').addClass("select2");


              }


            });


         });


      });


    </script>


  <script>


  $('.select2').select2();


  </script>


     


      


