<?php

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

foreach ($_POST as $paramName => $paramValue) {
  if ($paramName == "id") 
    $cu_id = $paramValue;  
  else if ($paramName == "descr") 
    $descr = $paramValue;  
//  else if ($paramName == "interpret_id") 
//    $interpret_id = $paramValue;  
  else if ($paramName == "location") 
    $location = $paramValue;  
  else if ($paramName == "planshape_id") 
    $planshape_id = $paramValue;  
  else if ($paramName == "rationale") 
    $rationale = $paramValue;  
  else if ($paramName == "topography_id") 
    $topography_id = $paramValue;  
  else if ($paramName == "longaxis") 
    $longaxis = $paramValue;  
  else if ($paramName == "mapareaid") 
    $mapareaid = $paramValue;  
  else if ($paramName == "shortaxis") 
    $shortaxis = $paramValue;  
  else if ($paramName == "orientation_id") 
    $orientation_id = $paramValue;  
  else if ($paramName == "stg2recommendation") 
    $stg2recommendation = $paramValue;  
  else if ($paramName == "recommendrationale_id") 
    $recommendrationale_id = $paramValue;  
  else if ($paramName == "bordenizable") 
    $bordenizable = $paramValue;  
  else if ($paramName == "bordenrationale_id") 
    $bordenrationale_id = $paramValue;  
  else if ($paramName == "note") 
    $note = $paramValue;  
}

$dal = new DAL();
  
$sql = "UPDATE culturalunit ". 
       "SET descr='$descr', mapareaid='$mapareaid', " .
       "location='$location', longaxis='$longaxis', " .
       "shortaxis='$shortaxis', orientation_id=$orientation_id, " .
       "planshape_id=$planshape_id, " .
       "rationale='$rationale', note='$note' " .
       "WHERE id = $cu_id ";
$result = $dal->query($sql);

$sql = "UPDATE site " .
       "SET topography_id=$topography_id, bordenizable='$bordenizable', " .
       "bordenrationale_id=$bordenrationale_id, " .
       "stg2recommendation='$stg2recommendation', " .
       "WHERE culturalunit_id = $cu_id ";
$result = $dal->query($sql);

echo json_encode($cu_id);

?>

