<?php require("../config/config.php"); 
 
    $vendor_id = $_REQUEST['vendor_id'];

    $sql = "SELECT a.vendor_id,
        a.code,
        a.vendor_group,
        a.vendor_type,
        a.name,
        c.phone,
        c.address,
        c.address_2,
        c.address_3,
        c.city,
        c.city_code,
        c.pin,
        a.pan_number,
        a.stn_number,
        c.gst_number,
        c.gst_type,
        c.is_sez,
        c.email,
        c.state,
        c.state_code,
        c.website,
        a.ceo,
        a.ceo_email_id,
        a.ceo_phone,
        c.fax,
        a.contact_person,
        a.contact_designation,
        a.contact_person_email_id,
        a.contact_person_phone,
        a.created_ts,
        a.vendor_from,
        a.created_by,
        a.updated_by,
        a.updated_ts,
        b.ShortName as country
        FROM master_vendors as a " 
        ." inner join master_vendors_address as c on a.vendor_id = c.vendor_id "
        ." inner join master_country as b on c.country = b.CountryRegionId "
        ." where a.is_deleted = '0' and a.vendor_id = '".$db_cust->escape($vendor_id)."'";
    $rec = $db_cust->query_first($sql);

    $response_data = array();

    $response_data['code'] = $rec['code'];

    if($rec['vendor_group'] == "NONMEM"){
        $group = "Non MEM";
    }else if($rec['vendor_group'] == "MEMBER"){
        $group = "MEMBER";
    }else{
        $group = "Non MEMF";
    }
    $response_data['vendor_group'] = $group;
    $response_data['vendor_type'] = $rec['vendor_type'];
    $response_data['name'] = $rec['name'];
    $response_data['phone'] = $rec['phone'];
    $response_data['address'] = $rec['address'];

    $response_data['address_2'] = $rec['address_2'];
    $response_data['address_3'] = $rec['address_3'];
    $response_data['city'] = $rec['city'];
    $response_data['city_code'] = $rec['city_code'];
    $response_data['pin'] = $rec['pin'];
    $response_data['pan_number'] = $rec['pan_number'];
    $response_data['stn_number'] = $rec['stn_number'];
    $response_data['gst_type'] = $rec['gst_type'];
    $response_data['is_sez'] = $rec['is_sez'];
    $response_data['gst_number'] = $rec['gst_number'];
    $response_data['email'] = $rec['email'];
    $response_data['country'] = $rec['country'];
    $response_data['state'] = $rec['state'];
    $response_data['state_code'] = $rec['state_code'];
    $response_data['website'] = $rec['website'];
    $response_data['ceo'] = $rec['ceo'];
    $response_data['ceo_email_id'] = $rec['ceo_email_id'];
    $response_data['ceo_phone'] = $rec['ceo_phone'];
    $response_data['fax'] = $rec['fax'];
    $response_data['contact_person'] = $rec['contact_person'];
    $response_data['contact_designation'] = $rec['contact_designation'];
    $response_data['contact_person_email_id'] = $rec['contact_person_email_id'];
    $response_data['contact_person_phone'] = $rec['contact_person_phone'];
    $response_data['vendor_from'] = $rec['vendor_from'];


    echo json_encode($response_data);
    $db_cust->close();

 ?>