<?php

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

$dal = new DAL();

if ($oz_id == 0) {
    
  $oz_id = hexdec(uniqid());

  $sql = "INSERT INTO organization " .
         "(id, name) " .
         "VALUES " .
         "($oz_id, '$name') ";
  $result = $dal->query($sql);

}

else {

  $sql = "UPDATE organization SET " .
         "name='$name' " . 
         "WHERe id = $oz_id ";
  $result = $dal->query($sql);

}

echo json_encode($oz_id);

?>

