<?php
error_reporting(0);
ini_set('display_errors', 0);

session_start();
include "../../root.class.php";
$db = new db_safeguard();

if (empty($_POST['jobcard_no'])) {
    echo '0';
    exit;
}

$jobcard_no = $_POST['jobcard_no'];
$reason     = $_POST['reason'] ?? '';
$note       = $_POST['note'] ?? '';
$image      = $_POST['image'] ?? '';
$date_time  = date("Y-m-d H:i", strtotime("+2 Hours"));

$results = $db->query("notes", "INSERT INTO notes (jobcard_id, reason, note, image, date_time) VALUES ('{$jobcard_no}', '{$reason}', '{$note}', '{$image}', '{$date_time}')");

if($results){
    echo 'success';
} else {
    echo 'Error Uploading data';
}

?>