<?php
$link = mssql_connect('192.168.1.30\SAP', 'sa', 'sap123');

$_SESSION['itemcode'] = $_GET['itemcode'];
 
if (!$link)
    die('Unable to connect!');
 
if (!mssql_select_db('btocumen', $link))
    die('Unable to select database!');
 
$result = mssql_query("select  oitw.itemcode , oitw.whscode,owhs.whsname,onhand,a.Price,b.Price as venta from oitw left outer join owhs on oitw.whscode=owhs.whscode  


LEFT OUTER JOIN itm1 a ON oitw.itemcode=a.itemcode AND a.PriceList=1
LEFT OUTER JOIN itm1 b ON oitw.itemcode=b.itemcode AND b.PriceList=4
 where oitw.itemcode='".$_SESSION['itemcode']."' and oitw.whscode in ('01','02','03','04','05')");

$return_arr = array();
while ($row = mssql_fetch_array($result)) {
    
   
    $row_array['itemcode'] = $row['itemcode'];
    $row_array['whscode'] = $row['whscode'];
    $row_array['whsname'] = $row['whsname'];
    $row_array['onhand'] = $row['onhand'];
    $row_array['Price'] = $row['Price'];
 $row_array['venta'] = $row['venta'];

    array_push($return_arr,$row_array);

//$msg = array("itemcode" => $row['itemcode'], "whscode" => $row['whscode'],"whsname" => $row['whsname'],"onhand" => $row['onhand']);
}

$json = $msg;

 header('content-type: application/json');
echo json_encode($return_arr);
mssql_free_result($result);
 
?>
