<?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];

// browse($zdb);
if (isset($_REQUEST["saleorder"])) {
    $saleorder = $_REQUEST['saleorder'];
    $query = mysqli_query($conn, "SELECT a.`vouchno`, a.`series`,a.`vouchdt`,a.`party`,b.barcode,b.item,b.color 
                                    FROM `sordmain`a , `sordtran`b WHERE a.`vouchno`= '$saleorder' and a.`series`='$fseries'") or die(mysqli_error($conn));

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

    $saleorddate = $r['vouchdt'];
    $party = $r['party'];
    $item = $r['item'];
    $color = $r['color'];

    $rows = array('success' => true, 
    'saleorddate' => $saleorddate,
    'item' => $item,
    'color' => $color,
    'party' => $party);
    
    header("Content-type: application\json");
    echo json_encode($rows);
}