<?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["jobgiven"])) {
    $jobgiven = $_REQUEST['jobgiven'];

    $query = mysqli_query($conn, "SELECT `vouchno`, `series`,`vouchdt`,`saleorder`,`saleorddate`, `party`, `prodcode`, `colorname`, `process`, `karigar`,
                                 `expectdate` , `qty` , `rate` , `billamt` , `remark1` , `remark2` FROM `jobgiven` WHERE `vouchno` ='$jobgiven' and series = '$fseries'") or die(mysqli_error($conn));

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

    $saleorder = $r['saleorder'];
    $party = $r['party'];
    $saleorddate = $r['saleorddate'];
    $prodcode = $r['prodcode'];
    $colorname = $r['colorname'];
    $process = $r['process'];
    $karigar = $r['karigar'];
    $expectdate = $r['expectdate'];
    $qty = $r['qty'];
    $rate = $r['rate'];
    $remark1 = $r['remark1'];
    $remark2 = $r['remark2'];

    $rows = array('success' => true, 
    'saleorder' => $saleorder,
    'party' => $party,
    'saleorddate' => $saleorddate,
    'prodcode' => $prodcode,
    'colorname' => $colorname,
    'process' => $process,
    'karigar' => $karigar,
    'expectdate' => $expectdate,
    'qty'  => $qty,
    'rate' => $rate,
    'remark1' => $remark1,
    'remark2' => $remark2);
    
    header("Content-type: application\json");
    echo json_encode($rows);
}