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

$zdb = $_SESSION["zdbyear_" . $dbname];
mysqli_select_db($conn, $zdb);
$fseries = $_SESSION["series_" . $dbname];

if (isset($_REQUEST["quotvouch"])) {
    $quotvouch = $_REQUEST['quotvouch'];

    $query = mysqli_query($conn, "SELECT `vouchno`, `series`,`vouchdt`, `party`, `remark1` , `remark2`,`subtotal`,`totqty`,
                                    `lessperc`,`lesother` ,`totalamount`,`packkg`,`packrate`,`packamt`,`paidrate`,`paidamt`,
                                    `roundoff`,`netamt` FROM `quotmain` WHERE `vouchno` ='$quotvouch' and series = '$fseries'") or die(mysqli_error($conn));

    $rows = array();
    $ctr = 0;
    $r =  mysqli_fetch_array($query) or die(mysqli_error($conn));

    $party = $r['party'];
    $remark1 = $r['remark1'];
    $remark2 = $r['remark2'];
    $subtotal = $r['subtotal'];
    $totqty = $r['totqty'];
    $lessperc = $r['lessperc'];
    $lesother = $r['lesother'];
    $totalamount = $r['totalamount'];
    $packkg = $r['packkg'];
    $packrate = $r['packrate'];
    $packamt = $r['packamt'];
    $paidrate = $r['paidrate'];
    $roundoff = $r['roundoff'];
    $netamt = $r['netamt'];

    $rows = array('success' => true, 
    'party' => $party,
    'remark1' => $remark1,
    'remark2' => $remark2,
    'subtotal' => $subtotal,
    'totqty' => $totqty,
    'lessperc' => $lessperc,
    'lesother' => $lesother,
    'totalamount' => $totalamount,
    'packkg' => $packkg,
    'packrate' => $packrate,
    'packamt' => $packamt,
    'paidamt' => $paidamt,
    'paidrate' => $paidrate,
    'roundoff' => $roundoff,
    'netamt' => $netamt);
    
    header("Content-type: application\json");
    echo json_encode($rows);
}