<?php

require_once($_SERVER['DOCUMENT_ROOT'] . '/sys/db.php');
 
foreach ($_POST as $paramName => $paramValue) {
  if ($paramName == "id")
    $ip_id = $paramValue;
  elseif ($paramName == "period_id") 
    $period_id = $paramValue;  
  else if ($paramName == "change")
    $change = $paramValue;
}

$dal = new DAL(); 
 
if ($ip_id == 0) {
  $sql = "INSERT INTO instrperform " .
         "(period_id, change) " .
         "VALUES ($period_id, '$change') ";
  $ip_id = $dal->query($sql);
}

else {
  $sql = "UPDATE instrperform " .
         "SET period_id=$period_id, change='$change' " .
         "WHERE id = $ip_id ";
  $result = $dal->query($sql);
}

echo json_encode($ip_id);

?>

