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

$date_created = new input();
$date_created->type("hidden");
$date_created->name("date_time_created");
$date_created->id("date_time_created");
$date_created->placeholder("DATE CREATED");
$date_created->value($current_date);

$supplier_batch_no = new input();
$supplier_batch_no->type("text");
$supplier_batch_no->name("supplier_batch_no");
$supplier_batch_no->id("supplier_batch_no");
$supplier_batch_no->placeholder("SUPPLIER BATCH ID");
$supplier_batch_no->style("width: 80%;margin:1vw auto;");
$supplier_batch_no->readonly();

$purchase_order_no = new input();
$purchase_order_no->type("text");
$purchase_order_no->name("purchase_order_no");
$purchase_order_no->id("purchase_order_no");
$purchase_order_no->placeholder("PURCHASE ORDER NO");
$purchase_order_no->style("width: 80%;margin:1vw auto;");

// vehicle checks

$vehicle_registration_no = new input();
$vehicle_registration_no->type("text");
$vehicle_registration_no->name("vehicle_registration_no");
$vehicle_registration_no->id("vehicle_registration_no");
$vehicle_registration_no->placeholder("VEHICLE REGISTRATION NO");
$vehicle_registration_no->style("width: 80%;margin:1vw auto;");

$vehicle_cleaness = new select();
$vehicle_cleaness->name("vehicle_cleaness");
$vehicle_cleaness->id("vehicle_cleaness");
$vehicle_cleaness->class("inputs");
$vehicle_cleaness->add_option("", "Vehicle State");
$vehicle_cleaness->add_option("Clean", "Clean");
$vehicle_cleaness->add_option("Dirty", "Dirty");
$vehicle_cleaness->style("width: 80%;margin:1vw auto;");

$vehicle_cleaness_comment = new input();
$vehicle_cleaness_comment->name('vehicle_cleaness_comment');
$vehicle_cleaness_comment->id('vehicle_cleaness_comment');
$vehicle_cleaness_comment->placeholder("COMMENT");
$vehicle_cleaness_comment->style("width: 95%;margin:1vw auto;");

$weather_proof = new select();
$weather_proof->name("enclosed_weather_proof");
$weather_proof->id("enclosed_weather_proof");
$weather_proof->class("inputs");
$weather_proof->add_option("", "Enclosed and Weather proof");
$weather_proof->add_option("Yes", "Yes");
$weather_proof->add_option("No", "No");
$weather_proof->style("width: 80%;margin:1vw auto;");

$weather_proof_comment = new input();
$weather_proof_comment->name('weather_proof_comment');
$weather_proof_comment->id('weather_proof_comment');
$weather_proof_comment->placeholder("COMMENT");
$weather_proof_comment->style("width: 95%;margin:1vw auto;");

$seal_state = new select();
$seal_state->name("seal_state");
$seal_state->id("seal_state");
$seal_state->class("inputs");
$seal_state->add_option("", "Seal Unbroken");
$seal_state->add_option("Yes", "Yes");
$seal_state->add_option("No", "No");
$seal_state->style("width: 80%;margin:1vw auto;");

$seal_state_comment = new input();
$seal_state_comment->name('seal_state_comment');
$seal_state_comment->id('seal_state_comment');
$seal_state_comment->placeholder("COMMENT");
$seal_state_comment->style("width: 95%;margin:1vw auto;");

$other_products_present = new select();
$other_products_present->name("other_products_present");
$other_products_present->id("other_products_present");
$other_products_present->class("inputs");
$other_products_present->add_option("", "Other non-food Products in truck");
$other_products_present->add_option("Yes", "Yes");
$other_products_present->add_option("No", "No");
$other_products_present->style("width: 80%;margin:1vw auto;");

$other_products_present_comment = new input();
$other_products_present_comment->name('other_products_present_comment');
$other_products_present_comment->id('other_products_present_comment');
$other_products_present_comment->placeholder("COMMENT");
$other_products_present_comment->style("width: 95%;margin:1vw auto;");

$pallet_condition = new select();
$pallet_condition->name("pallet_condition");
$pallet_condition->id("pallet_condition");
$pallet_condition->class("inputs");
$pallet_condition->add_option("", "Pallet in Clean and in good condition");
$pallet_condition->add_option("Good", "Good");
$pallet_condition->add_option("Bad", "Bad");
$pallet_condition->style("width: 80%;margin:1vw auto;");

$pallet_condition_comment = new input();
$pallet_condition_comment->name('pallet_condition_comment');
$pallet_condition_comment->id('pallet_condition_comment');
$pallet_condition_comment->placeholder("COMMENT");
$pallet_condition_comment->style("width: 95%;margin:1vw auto;");

$infestation_pests = new select();
$infestation_pests->name("infestation_pests_present");
$infestation_pests->id("infestation_pests_present");
$infestation_pests->class("inputs");
$infestation_pests->add_option("", "Signs of Infestation and Pests");
$infestation_pests->add_option("Yes", "Yes");
$infestation_pests->add_option("No", "No");
$infestation_pests->style("width: 80%;margin:1vw auto;");

$infestation_pests_comment = new input();
$infestation_pests_comment->name('infestation_pests_comment');
$infestation_pests_comment->id('infestation_pests_comment');
$infestation_pests_comment->placeholder("COMMENT");
$infestation_pests_comment->style("width: 95%;margin:1vw auto;");

$foreign_objects = new select();
$foreign_objects->name("foreign_objects_present");
$foreign_objects->id("foreign_objects_present");
$foreign_objects->class("inputs");
$foreign_objects->add_option("", "Free from Foreign Objects");
$foreign_objects->add_option("Yes", "Yes");
$foreign_objects->add_option("No", "No");
$foreign_objects->style("width: 80%;margin:1vw auto;");

$foreign_objects_comment = new input();
$foreign_objects_comment->name('foreign_objects_comment');
$foreign_objects_comment->id('foreign_objects_comment');
$foreign_objects_comment->placeholder("COMMENT");
$foreign_objects_comment->style("width: 95%;margin:1vw auto;");

$odours_present = new select();
$odours_present->name("odours_present");
$odours_present->id("odours_present");
$odours_present->class("inputs");
$odours_present->add_option("", "Free from Odours");
$odours_present->add_option("Yes", "Yes");
$odours_present->add_option("No", "No");
$odours_present->style("width: 80%;margin:1vw auto;");

$purchase_order_received = new select();
$purchase_order_received->name("purchase_order_received");
$purchase_order_received->id("purchase_order_received");
$purchase_order_received->class("inputs");
$purchase_order_received->add_option("", "Purchase Order Received");
$purchase_order_received->add_option("Yes", "Yes");
$purchase_order_received->add_option("No", "No");
$purchase_order_received->style("width: 80%;margin:1vw auto;");

$purchase_order_received_comment = new input();
$purchase_order_received_comment->name('purchase_order_received_comment');
$purchase_order_received_comment->id('purchase_order_received_comment');
$purchase_order_received_comment->placeholder("COMMENT");
$purchase_order_received_comment->style("width: 95%;margin:1vw auto;");

$supplier_invoice_received = new select();
$supplier_invoice_received->name("supplier_invoice_received");
$supplier_invoice_received->id("supplier_invoice_received");
$supplier_invoice_received->class("inputs");
$supplier_invoice_received->add_option("", "Supplier Invoice Received");
$supplier_invoice_received->add_option("Yes", "Yes");
$supplier_invoice_received->add_option("No", "No");
$supplier_invoice_received->style("width: 80%;margin:1vw auto;");

$supplier_invoice_received_comment = new input();
$supplier_invoice_received_comment->name('supplier_invoice_received_comment');
$supplier_invoice_received_comment->id('supplier_invoice_received_comment');
$supplier_invoice_received_comment->placeholder("COMMENT");
$supplier_invoice_received_comment->style("width: 95%;margin:1vw auto;");

$coa_received = new select();
$coa_received->name("coa_received");
$coa_received->id("coa_received");
$coa_received->class("inputs");
$coa_received->add_option("", "COA Received");
$coa_received->add_option("Yes", "Yes");
$coa_received->add_option("No", "No");
$coa_received->style("width: 80%;margin:1vw auto;");

$coa_received_comment = new input();
$coa_received_comment->name('coa_received_comment');
$coa_received_comment->id('coa_received_comment');
$coa_received_comment->placeholder("COMMENT");
$coa_received_comment->style("width: 95%;margin:1vw auto;");

$truck_clearance_certificate = new select();
$truck_clearance_certificate->name("truck_clearance_certificate");
$truck_clearance_certificate->id("truck_clearance_certificate");
$truck_clearance_certificate->class("inputs");
$truck_clearance_certificate->add_option("", "Truck Clearance Certificate Received");
$truck_clearance_certificate->add_option("Yes", "Yes");
$truck_clearance_certificate->add_option("No", "No");
$truck_clearance_certificate->style("width: 80%;margin:1vw auto;");

$truck_clearance_certificate_comment = new input();
$truck_clearance_certificate_comment->name('truck_clearance_certificate_comment');
$truck_clearance_certificate_comment->id('truck_clearance_certificate_comment');
$truck_clearance_certificate_comment->placeholder("COMMENT");
$truck_clearance_certificate_comment->style("width: 95%;margin:1vw auto;");


$submit_btn = new button();
$submit_btn->class("submit_btn");
$submit_btn->value("Submit");
$submit_btn->onclick("vehicle_check()");

?>

<div class="form_down">
    <h1>Vehicle Checks</h1><br>
    <style>
        table,
        th,
        td {
            border: 2px solid black;
            border-collapse: collapse;
            padding: 5px;
        }
    </style>
    <table id="vehicle_check_table" style="width: 90%;">
        <tr>
            <th colspan="4" style="background-color: #004aad80;">
                <h3>CONTAINER/ TRUCK /VEHICLE CHECKS</h3>
            </th>
        </tr>
        <tr>
            <td>Delivery Vehicle Registration number:</td>
            <td colspan="3">
                <?php
                $vehicle_registration_no->add();
                ?>
            </td>
        </tr>
        <tr>
            <td>Truck / Vehicle:</td>
            <td>
                <?php
                $vehicle_cleaness->add();
                ?>
            </td>
            <td colspan="2">
                <?php
                $vehicle_cleaness_comment->add();
                ?>
            </td>
        </tr>
        <tr>
            <td>Fully Enclosed and weather-proof:</td>
            <td>
                <?php
                $weather_proof->add();
                ?>
            </td>
            <td colspan="2">
                <?php
                $weather_proof_comment->add();
                ?>
            </td>
        </tr>
        <tr>
            <td>Container Seal Unbroken:</td>
            <td>
                <?php
                $seal_state->add();
                ?>
            </td>
            <td colspan="2">
                <?php
                $seal_state_comment->add();
                ?>
            </td>
        </tr>
        <tr>
            <td>Other non-food products</td>
            <td>
                <?php
                $other_products_present->add();
                ?>
            </td>
            <td colspan="2">
                <?php
                $other_products_present_comment->add();
                ?>
            </td>
        </tr>
        <tr>
            <td>Pallet in clean and in good condition</td>
            <td>
                <?php
                $pallet_condition->add();
                ?>
            </td>
            <td colspan="2">
                <?php
                $pallet_condition_comment->add();
                ?>
            </td>
        </tr>
        <tr>
            <td>Signs of Infestation and pests</td>
            <td>
                <?php
                $infestation_pests->add();
                ?>
            </td>
            <td colspan="2">
                <?php
                $infestation_pests_comment->add();
                ?>
            </td>
        </tr>
        <tr>
            <td>Free form foreign objects</td>
            <td>
                <?php
                $foreign_objects->add();
                ?>
            </td>
            <td colspan="2">
                <?php
                $foreign_objects_comment->add();
                ?>
            </td>
        </tr>
        <tr>
            <td>Free from odours</td>
            <td>
                <?php
                $odours_present->add();
                ?>
            </td>
            <td colspan="2">
                <?php
                $other_products_present_comment->add();
                ?>
            </td>
        </tr>
        <tr>
            <td>Docummentation received</td>
            <td>
                <div>
                    <div style="border-bottom: 2px solid black;">
                        <?php
                        $purchase_order_received->add();
                        ?>
                    </div>
                    <div style="border-bottom: 2px solid black;">
                        <?php
                        $supplier_invoice_received->add();
                        ?>
                    </div>
                    <div style="border-bottom: 2px solid black;">
                        <?php
                        $coa_received->add();
                        ?>
                    </div>
                    <div>
                        <?php
                        $truck_clearance_certificate->add();
                        ?>
                    </div>
                </div>
            </td>
            <td>
                <div>
                    <div style="border-bottom: 2px solid black;">
                        <?php
                        $purchase_order_received_comment->add();
                        ?>
                    </div>
                    <div style="border-bottom: 2px solid black;">
                        <?php
                        $supplier_invoice_received_comment->add();
                        ?>
                    </div>
                    <div style="border-bottom: 2px solid black;">
                        <?php
                        $coa_received_comment->add();
                        ?>
                    </div>
                    <div>
                        <?php
                        $truck_clearance_certificate_comment->add();
                        ?>
                    </div>
                </div>
            </td>
        </tr>
    </table>

    <?php
    $submit_btn->add();
    ?>
</div>

<?

$vehicle_check_ajax = new js_ajax();
$vehicle_check_ajax->function_name("vehicle_check");
$vehicle_check_ajax->insert("vehicle_checks");
$vehicle_check_ajax->on_success("VEHICLE CHECKED");
$vehicle_check_ajax->redirect("");