<?php

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


foreach ($_POST as $paramName => $paramValue) {
}

//$controls =['livFieldProject','selParcel','selDate','selBreakDur',
//            'selStartTime','selEndTime','pw_idKey','putValidProject'];


$controls =['putFormValidate'];

$dal = new DAL();

foreach ($controls as $control) {

  $sql = "SELECT id FROM controlinstance WHERE instance = '$control' LIMIT 1";
  $ci_id = $dal->query($sql)->id;

//  $sql = "SELECT id FROM controlentry WHERE controlinstance_id = $ci_id "; 
//  $result = $dal->query($sql);
//$cnt = count ($result);
//print_r ("$control id:$ci_id entries:$cnt\n");

  $sql = "DELETE FROM controlentry WHERE controlinstance_id = $ci_id "; 
  $result = $dal->query($sql);
  
  $sql = "DELETE FROM controlinstance WHERE id = $ci_id "; 
  $result = $dal->query($sql);

}

echo json_encode($result);

?>

