<?php

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

$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
$myyear = $_SESSION[$myyear];
mysqli_select_db($conn, $zdb);
$maindb = 'product';
$zroot = $_SESSION["zdbroot"];
$file = 'getitem.php';

$custcode = $_REQUEST["custcode"];
$party = $_REQUEST["party"];

$ccond = "";
if($custcode != ""){
    $ccond = "and `custcode`='$custcode'";
}
$pcond = "";
if($party != ""){
    $pcond = "and `accode`='$party'";
}
$getcc = mysqli_query($conn, "SELECT discapply, discdies,custcode FROM accmast where accode != '' $ccond $pcond ") or die(mysqli_error($conn));
if (mysqli_num_rows($getcc) > 0) {
    $custcc = mysqli_fetch_array($getcc);
    $mdiscdies = $custcc['discdies'];
    $mdiscapply = $custcc['discapply'];
    $mcustcode = $custcc['custcode'];
} else {
    $mdiscdies = 0;
}

$rows = array('success' => true,
        'custcode' => "$mcustcode",
        'discdies' => "$mdiscdies");
    header("Content-type: application\json");
    echo json_encode($rows);

?>