<?php include "../../root.class.php";
$html = new html();
$db = new db_safeguard();
$html->add_styles_page();
// $html->check_user_type("ADMIN");

$pv = $_GET['pv'];
$ffa = $_GET['ffa'];
$variety = $_GET['variety'];
$weight = $_GET['weight'];
$size = $_GET['size'];
$sound_not_sound = $_GET['sound_not_sound'];
$mold = strtoupper($_GET['mold']);
$moisture = $_GET['moisture'];
$client = $_GET['client'];
$shell = strtoupper($_GET['shell']);
$date = $_GET['date'];
$notes = $_GET['additional_info'];
$user_id = $_GET['user_id'];
$bins = $_GET['bins'];

echo "INSERT INTO `batches`(`pv`, `ffa`, `variety_id`, `weight`, `size`, `sound_not_sound`, `mold`, `moisture`, `client_id`, `shell`, `date`) VALUES ('$pv','$ffa','$variety','$weight','$size','$sound_not_sound','$mold','$moisture','$client','$shell','$date','$notes','$user_id')";

if ($sound_not_sound = 'YES') {
    $res = $db->insert("INSERT INTO `batches`(`pv`, `ffa`, `variety_id`, `weight`, `size`, `sound_not_sound`, `mold`, `moisture`, `client_id`, `shell`, `date`, `notes`, `user_id`, `status`) VALUES ($pv,$ffa,$variety,$weight,$size,'$sound_not_sound','$mold',$moisture,'$client','$shell','$date','$notes',$user_id,'BATCH RECEIVED')");
} else {
    $res = $db->insert("INSERT INTO `batches`(`pv`, `ffa`, `variety_id`, `weight`, `size`, `sound_not_sound`, `mold`, `moisture`, `client_id`, `shell`, `date`, `notes`, `user_id`, `status`) VALUES ($pv,$ffa,$variety,$weight,$size,'$sound_not_sound','$mold',$moisture,'$client','$shell','$date','$notes',$user_id,'NOT SOUND')");
}


if ($res) {
    echo 1;
} else {
    echo 0;
}