<?php

require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include ('includes/function.php');

$zdb = $_SESSION["zdbyear_" . $dbname];
mysqli_select_db($conn, $zdb);
$admin = $_SESSION["admin_" . $dbname];
$success = false;
$maindb = 'cashrecp';
$society = $_SESSION["society_" . $dbname];
$file = "cashrecp.php";

$mfrmvouch = $_REQUEST["frmvouch"];
$mtovouch  = $_REQUEST["tovouch"];
$drawbank = $_REQUEST["drawbank"];


if($mfrmvouch && $mtovouch != ''){
    
    $recpcond = " AND vouchno BETWEEN '$mfrmvouch' AND  '$mtovouch'  ";
}


$mainqry = mysqli_query($conn, "SELECT *, DATE_FORMAT(`vouchdt`, '%d-%m-%Y') AS vouchdt, DATE_FORMAT(`chqdate`, '%d-%m-%Y') AS chqdate FROM `$maindb`
                         WHERE vouchno != '' $recpcond ") or die(mysqli_error($conn));

 
echo"<table class='table table-striped table-condensed table-bordered myTable' width='100%'>";
echo"<thead>";
echo"<tr style='background-color:#6082BF;'>";
echo"<th style='color: black;' width='8%'>";
echo"<input type='checkbox' class='form-control allchk' style='width:50%'>";
echo"</th>";
echo"<th style='color: black;' width='10%'>Voucher</th>";
echo"<th style='color: black;' width='17%'>Date</th>";
echo"<th style='color: black;' width='10%'>Code</th>";
echo"<th style='color: black;' width='50%'>School</th>";
echo"<th style='color: black;' width='15%' class='text-right'>Amount</th>";
echo"</tr>";
echo"</thead>";
echo"<tbody>";
$ctr = 0;
//$num = mysqli_num_rows();
while ($r = mysqli_fetch_array($mainqry)) {

    $getschool = mysqli_query($conn, "SELECT accode, name FROM `accmast` WHERE `grpcode` = '010' and `accode` = '$r[party]'")or die(mysqli_error($conn));
    $fschool= mysqli_fetch_array($getschool);
    $school = $fschool['name'];
    $custcode = $r['custcode'];
    $vouchdt = $r['vouchdt'];
    $vouchno = $r['vouchno'];
    $recpno = $r['recpno'];
    $amount = $r['amount'];

    echo "<tr>";
    echo "<td align='left'><input type='checkbox' class='form-control form mcheck' name='chk_$ctr' value='1' style='width:50%'></td>";
    echo "<td align='left'><input type='text' value='$recpno'  name='recpno_$ctr' class='multiple form form-control'>
                          <input type='hidden' value='$vouchno'  name='vouchno_$ctr' class='multiple form form-control'></td>";
    echo "<td align='left' name='vouchdt'>$vouchdt</td>";
    echo "<td align='left' name='custcode'>$custcode</td>";
    echo "<td align='left' name='party'>$school</td>";
    echo "<td align='right' name='amount'>$amount</td>";
    echo "</tr>";
    $ctr++;
}
echo"<input type='hidden' value='$ctr' name='count' class='form-control ' style='width:50%'>";
echo "</tbody>";
echo "</table>";
//header("Content-type: application\json");
//echo json_encode($rows);
