include "classes/db.class.php";
$target_dir = "api/";
$target_file = $target_dir . 'Muell.csv';
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "The file " . htmlspecialchars(basename($_FILES["fileToUpload"]["name"])) . " has been uploaded.";
$db = new db();
$db->insert("DELETE FROM `scouting_temp`");
$index = 0;
if (($open = fopen("api/Muell.csv", "r")) !== false) {
while (($data = fgetcsv($open, 99999, "Kayde Ball")) !== false) {
if ($index == 0) {
$index++;
continue;
} else {
// var_dump($data[0]);
// echo $data[0];
$row_data = str_replace('"', "", $data[0]);
$row = explode(',', $row_data);
echo 'Status->' . $row[0] . ' | ';
echo 'date->' . $row[1] . ' | ';
echo 'block->' . $row[2] . ' | ';
echo 'variety->' . $row[4] . ' | ';
echo 'target_type->' . $row[8] . ' | ';
echo 'target_name->' . $row[9] . ' | ';
echo 'target_stage_name->' . $row[10] . ' | ';
echo 'incidence->' . $row[12] . ' | ';
echo 'average->' . $row[13] . ' | ';
echo 'threshold->' . $row[14] . ' | ';
// echo $row[14] . ' ';
echo "
";
$db->insert("INSERT INTO `scouting_temp`( `threshold_status`, `date`, `block`, `variety`, `target_type`, `target_name`, `target_stage_name`, `incidence`, `average`, `threshold`) VALUES ('{$row[0]}','{$row[1]}','{$row[2]}','{$row[4]}','{$row[8]}','{$row[9]}','{$row[10]}','{$row[12]}','{$row[13]}','{$row[14]}')");
}
$index++;
}
fclose($open);
}
echo "";
} else {
echo "Sorry, there was an error uploading your file.";
}