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



  $fdate = $_GET['fdate'];



  $tdate = $_GET['tdate'];



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



  { 



date_default_timezone_set('Asia/Karachi');







      for($count=0; $count<$_POST["total_item"]; $count++)



      {



        



        $statement = $connect->prepare("



          update sale



          set inv_no = :inv_no,



          po_no = :po_no,



          chal_no = :chal_no,



          bilty_no = :bilty_no



          where s_id = :s_id



        ");



        $statement->execute(



          array(



            ':inv_no'              =>  trim($_POST["inv_no"][$count]),



            ':po_no'              =>  trim($_POST["po_no"][$count]),        



            ':chal_no'              =>  trim($_POST["chal_no"][$count]),



            ':bilty_no'              =>  trim($_POST["bilty_no"][$count]),



            ':s_id'              =>  trim($_POST["s_id"][$count]),



                       



          )



        );



      }



      



       



        



      header("location: dashboard");



    



  }



  



  ?>



<!DOCTYPE html>



<html>



<head>



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



  <link rel="stylesheet" href="css/datepicker.css">



  <link rel="stylesheet" href="css/jquery.datetimepicker.css">



  <link rel="stylesheet" href="css/jquery.datetimepicker.min.css">



  



  



  



</head>



<body>



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



  <?php include('include/sidebar.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"><a href="#">Receivable</a></li>



              <li class="breadcrumb-item"><a href="sales.php">Sale Invoices</a></li>



              <li class="breadcrumb-item active">Sale Invoice Customize</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>



      <?php



       include('include/script.php');



       



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



      {



      ?>



      



        



       <form method="post" id="sale_form" AutoComplete="off" />



        <div class="table-responsive">



          <table class="table table-bordered">



            







                  <div class="row">



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



              <h4>Sales Invoices <br />From : <?php echo $fdate .'<br />To : ' .$tdate;?></h4>



               <tr>



                <th width="3%">Sr</th>



                <th width="10%">ID</th>



                <th width="10%">Date</th>



                <th width="37%">Name</th>



                <th width="10%">Inv No.</th>



                <th width="10%">PO No.</th>



                <th width="10%">Chal No.</th>



                <th width="10%">Bilty No.</th>



                </tr>



                



                <?php



                    $statement = $connect->prepare("select m.s_id,m.dated,c.name,m.po_no,m.bilty_no,m.inv_no,m.chal_no from sale m, customers c where m.inv_type='Credit' and m.cust_id = c.cust_id and m.dated between '".$fdate."' and '".$tdate."'



                    ");



                    $statement->execute();



                      



                    $item_result = $statement->fetchAll();



                    $m = 0;



                    



                    foreach($item_result as $sub_row)



                    {



                      



                      $m = $m + 1;



                      



                    ?>



                    <tr id="row_id_<?php echo $m; ?>">



                      <td><span id="sr_no"><?php echo $m; ?></span></td>



                      <td><input type="text" name="s_id[]" id="s_id<?php echo $m; ?>" class="form-control input-sm number_only s_id" value="<?php echo $sub_row["s_id"]; ?>" readOnly/></td>



                     



                      <td><?php echo $sub_row["dated"]; ?></td>



                      <td><?php echo $sub_row["name"]; ?></td>



                      <td><input type="text" name="inv_no[]" id="inv_no<?php echo $m; ?>" class="form-control input-sm number_only inv_no" value="<?php echo $sub_row["inv_no"]; ?>" /></td>



                      



                     </td>



                     <td><input type="text" name="po_no[]" id="po_no<?php echo $m; ?>" class="form-control input-sm number_only po_no" value="<?php echo $sub_row["po_no"]; ?>" /></td>



                      



                     </td>



                      <td><input type="text" name="chal_no[]" id="chal_no<?php echo $m; ?>" class="form-control input-sm number_only chal_no" value="<?php echo $sub_row["chal_no"]; ?>" /></td>



                      



                     </td>



                      <td><input type="text" name="bilty_no[]" id="bilty_no<?php echo $m; ?>" class="form-control input-sm number_only bilty_no" value="<?php echo $sub_row["bilty_no"]; ?>" /></td>



                      



                     </td>



                    



                    </tr>



                    <?php



                   



                    }



                    ?>



                <tr>



                  <td colspan="8">



               



                  <input type="hidden" name="total_item" id="total_item" value="<?php echo $m;?>" />



                 



                



                  



                  <input type="submit" name="save" id="save"  class="form-control btn btn-primary btn_save" value="Save" autocomplete="off" />



               



    </td>



  </tr>



          </table>



        </div>



      </form>



      </div>



             



        



        



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



    </section>



    <!-- /.content -->



 



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



 



    </div>



    </div>



  



  



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



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



  



  



</body>



</html>



<?php 



}



?>