<?php

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

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

if (isset($_REQUEST['custcode'])) {
    $custcode = $_REQUEST['custcode'];
    $custcond = '';

    if (!empty($_REQUEST['custcode'])) {
        $custcond = "AND custcode = '$custcode' ";
    }

    $getm = mysqli_query($conn, "SELECT accode,custcode,medmcode FROM `accmast` WHERE `grpcode` = '010'  $custcond")or die(mysqli_error($conn));
    $m = mysqli_fetch_array($getm);

    $code = $m['custcode'];
    $name = $m['accode'];
    $medium = $m['medmcode'];

    $rows = array('name' => "$name",
                  'medium' => "$medium"
    );
    header("Content-type: application\json");
    echo json_encode($rows);
}