<?php
$find_date= $_POST["StartDate"];
$find_enddate= $_POST["EndDate"];
$week_no= $_POST["Weeknumber"];
$section= $_POST["Section"];
if ($find_date =="" || $find_enddate =="" ){
   $find_date =date("Y.m.d");
   $find_enddate =date("Y.m.d");
}
$today = date("d/m/Y H:i:s");
$host ="it2008";
$user = "sa";
$pass = "mercury";
$objConnect = mssql_connect($host,$user,$pass);
$objDB = mssql_select_db("smvDB_web");
$strSQL="";
if ($section =='1'){
    $strSQL = "select Item_No,status_desc,SUM(unit_qty)as unit_qty,SUM(unit_value)as unit_value from wh_value "
            . "where convert(char(10),pick_date,102)  between CONVERT(VARCHAR(10), '$find_date',102) and CONVERT(VARCHAR(10),'$find_enddate' ,102) group by Item_no,status_desc order by item_no";
}
if($strSQL != ""){
$objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
 $resultArray = array();
while($objResult = mssql_fetch_array($objQuery))
{
   array_push($resultArray,$objResult);
}
mssql_close($objConnect);
$return_json ="";
$totalVal=0;
foreach ($resultArray as $result)
{
$return_json .="    <tr>
      <td class=\"result_section\"><strong>". $result["status_desc"]. "</strong></td>
      <td><strong>" .$result["unit_qty"]."</strong></td>
      <td><strong>" .$result["unit_value"]."</strong></td>  
      </tr>"; 
//<td><strong>" .number_format($result["wip_am"])."</strong></td>
//    <td><strong>" .number_format($result["wip_pm"])."</strong></td>
}
}
echo $return_json;
?>
