<?php

include "classes/html.class.php";

$db = new db();

$html = new html("DRYING BIN");

$batch_res = $db->exec_query('batch', ['*'], '', '', '', '', "silo_id = 0 AND drying_bin_id <> 0", 'order by record_id Desc', false);

if ($batch_res->num_rows >= 1) {
    while ($batch_info = $batch_res->fetch_assoc()) {

        $variety_res = $db->exec_query("variety", ['*'], '', '', '', '', "record_id = {$batch_info['variety_id']}", '', false);
        $variety_info = $variety_res->fetch_assoc();

        $bin_res = $db->exec_query("drying_bins", ['*'], '', '', '', '', "record_id = {$batch_info['drying_bin_id']}",'',false);
        $bin_info = $bin_res->fetch_assoc();

        $table_data = $table_data . "<tr>
            <td><input type='text' class='table_input' value='BA {$batch_info['batch_id']}' readonly /></td>
            <td><input type='text' class='table_input' value='{$variety_info['name']}' readonly /></td>
            <td><input type='text' class='table_input' value='{$batch_info['date']}' readonly /></td>
            <td><input type='text' class='table_input' value='{$bin_info['name']}' readonly /></td>
            <td><a href='bins.php?batch_id={$batch_info['batch_id']}' target='_blank'><input type='submit' value='MOVE TO SILO' class='form_btn' readonly /></a></td></tr>
        ";
    }
} else {
    $table_data = "<tr>
        <td> NO RESULTS</td>
    </tr>";
}

?>

<style>
        body {
            background-image: url('');
            /* background-color: white; */
            background-repeat: repeat-y;
        }
    </style>
    <br>
    
    <table style='width:100%; text-align:center;'>
        <tr>
            <td style='font-size:1.5vw;'>
                BATCH ID:
            </td>
            <td style='font-size:1.5vw;'>
                VARIETY:
            </td>
            <td style='font-size:1.5vw;'>
                DATE RECEIVED:
            </td>
            <td style='font-size:1.5vw;'>
                DRYING BINS:
            </td>
            <td>

            </td>
        </tr>

        <?php echo $table_data; ?>
    </table>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>