<?php
include "../classes/db.class.php";
$db = new db();

$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 = date("Y-m-d H:i", strtotime("+ 2hours"));
$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;
}