<?php

require_once($_SERVER['DOCUMENT_ROOT'] . '/sys/db.php');

foreach ($_POST as $paramName => $paramValue) {
  if ($paramName == "scopeid") 
    $pwo_id = $paramValue;  
  else if ($paramName == "id") 
    $lo_id = $paramValue;  
  else if ($paramName == "lotinterpret_id") 
    $lotinterpret_id = $paramValue;  
  else if ($paramName == "rationale") 
    $rationale = $paramValue;  
  else if ($paramName == "lottype_id") 
    $lottype_id = $paramValue;  
  else if ($paramName == "selectlot_name") 
    $lot_name_id = $paramValue;  
}

if ("null" == $lot_name_id)
  $lot_name_id = $lo_id;

$dal = new DAL();
  
$sql = "SELECT name FROM lot WHERE id = $lot_name_id LIMIT 1 ";
$lot_name = $dal->query($sql)->name; 

$sql = "UPDATE lot " .
       "SET name='$lot_name', lottype_id=$lottype_id, rationale='$rationale',  lotinterpret_id=$lotinterpret_id  " .
       "WHERE id = $lo_id " ;
$result = $dal->query($sql);
    
echo json_encode($result);

?>

