<?php

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

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

if (isset($_REQUEST['vouchno'])) {
    $mvouchno = $_REQUEST['vouchno'];
//   print "SELECT a.*, b.discount FROM `item` a, `itemgrp` b WHERE a.barcode = '$barcoden' and a.group = b.code " ;
    $iresult = mysqli_query($conn,"SELECT `quotncall`,`quotcall`, `flwup3dt`, `cancresn`, `postdate`, `remddate`, `newvouch`,`confdate`, `mup` FROM `leadenq` WHERE vouchno ='$mvouchno'") or die(mysqli_error($conn));
    //$iresult = mysqli_query($conn,"SELECT * FROM `item` WHERE name = '$itemn' ") or die(mysqli_error($conn));
    if (mysqli_num_rows($iresult) > 0) {
        $array = mysqli_fetch_array($iresult);


        $quotncall = $array["quotncall"];
        $quotcall = $array["quotcall"];
        $flwup2dt = $array["flwup2dt"];
        $flwup3dt = $array["flwup3dt"];
        $reason = $array["cancresn"];
        $postdate = $array["postdate"];
        $remddate = $array["remddate"];
        $newvouch = $array["newvouch"];
        $mup = $array["mup"];
        $confd = $array["confdate"];
        if ($confd != '0000-00-00'){
            $confdate = $array["confdate"];
        }else {
            $confdate = date("Y-m-d");
        }
    }

    header("Content-type: application\json");
    $data = array("quotncall" => $quotncall, "quotcall" => $quotcall, "flwup2dt" => $flwup2dt, "flwup3dt" => $flwup3dt, "reason" => $reason, "postdate" => $postdate, "remddate" => $remddate, "newvouch" => $newvouch, "confdate" => $confdate, "mup" => $mup);
    echo json_encode($data);
}
?>