<?php
  session_start();
  if(empty($_SESSION['branch']) || $_SESSION['branch'] == ''){
    header("Location: index.php");
    die();
  }
    require_once 'system/conn.php';
?>
<!doctype html>
<html lang="en" class="semi-dark">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- loader-->
	<link href="assets/css/pace.min.css" rel="stylesheet" />
	<script src="assets/js/pace.min.js"></script>
    <!--plugins-->
    <link href="assets/plugins/perfect-scrollbar/css/perfect-scrollbar.css" rel="stylesheet" />
    <link href="assets/plugins/simplebar/css/simplebar.css" rel="stylesheet" />
    <link href="assets/plugins/metismenu/css/metisMenu.min.css" rel="stylesheet" />
    <link href="assets/plugins/datatable/css/dataTables.bootstrap5.min.css" rel="stylesheet" />
    <!-- CSS Files -->
    <link href="assets/css/bootstrap.min.css" rel="stylesheet">
    <link href="assets/css/bootstrap-extended.css" rel="stylesheet">
    <link href="assets/css/style.css" rel="stylesheet">
    <link href="assets/css/icons.css" rel="stylesheet">
	<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css">
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap" rel="stylesheet">
    <!--Theme Styles-->
    <link href="assets/css/dark-theme.css" rel="stylesheet" />
    <link href="assets/css/semi-dark.css" rel="stylesheet" />
    <link href="assets/css/header-colors.css" rel="stylesheet" />
    <title>View Old Payment Entry</title>
  </head>
  <body>
    
    <!--start wrapper-->
    <div class="wrapper">
    <?php include'system/header.php'?>
	  
        <!-- start page content wrapper-->
        <div class="page-content-wrapper">
         <!-- start page content-->
         <div class="page-content">

          <!--start breadcrumb-->
          <div class="page-breadcrumb d-none d-sm-flex align-items-center mb-3">
            <div class="breadcrumb-title pe-3">View Old Payment (<?php echo $_POST['fromdate'].' to '.$_POST['todate']; ?>)</div>
            <div class="ms-auto"></div>
          </div>

		  <hr/>
		  <div class="card">
			<div class="card-body">
				<div class="table-responsive">
				  <table id="example2" class="table table-striped table-bordered">
					<thead>
					  <tr>
						<th>SR No</th>
            			<th>Payment For</th>
            			<th>Payment Type</th>
            			<th>Payment Id</th>
            			<th>Narration</th>
            			<th>Branch</th>
            			<th>Payment Date</th>
            			<th>Updated Date</th>
					  </tr>
					</thead>
					<tbody>
					  <?php
                        $cnt=1;
                        $fromdate = $_POST['fromdate'];
                        $todate = $_POST['todate'];
                        $stmt = $conn->prepare(" SELECT * FROM `prv_payment_tbl` where branch='".$_SESSION['branch']."' AND `payment_date` BETWEEN '".$fromdate."' and '".$todate."' order by id desc ");
                        //print_r($stmt);exit;
                        $stmt->execute();
                        $sql = $stmt->fetchAll();
                        foreach($sql as $row) 
                        {  
                      ?>
                        <tr>
                            <td><?php echo $cnt;?></td>
                            <td><?php echo $row['payment_for'];?></td>
                            <td><?php echo $row['payment_type'];?></td>
                            <td><?php echo $row['payment_id'];?></td>
                            <td><?php echo $row['narration'];?></td>
                            <td>
                              <?php
                                $sth1 = $conn->prepare(" SELECT name FROM `branch` where id='".$row['branch']."'  ");
                                $sth1->execute();
                                $row2 = $sth1->fetch(PDO::FETCH_ASSOC);
                                echo $row2['name']; 
                              ?>
                            </td>
                            <td><?php echo $row['payment_date'];?></td>
                            <td><?php echo $row['updated_date'];?></td>
                        </tr>
                      <?php $cnt=$cnt+1;} ?>
					</tbody>
					<tfoot>
						<tr>
							<th>SR No</th>
            				<th>Payment For</th>
            				<th>Payment Type</th>
            				<th>Payment Id</th>
            				<th>Narration</th>
            				<th>Branch</th>
            				<th>Payment Date</th>
            				<th>Updated Date</th>
						</tr>
					</tfoot>
				  </table>
				</div>
			  </div>
			</div>

          </div>
          <!-- end page content-->
         </div>
<?php include'system/footer.php'?>