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

// HTML FORM ELEMENTS

$doc = new label();
$doc->for("doc");
$doc->value("DOC : ");
$doc->addAttribute("style", "margin: 1vw auto;");

$document = new input();
$document->type("text");
$document->name("doc");
$document->id("doc");
$document->class("inputs");
$document->required();
$document->addAttribute("style", "margin: 1vw auto;");

$date_time_label = new label();
$date_time_label->for("date");
$date_time_label->value("Date & Time : ");
$date_time_label->addAttribute("style", "margin: 1vw auto;");

$date_time = new input();
$date_time->type("datetime-local");
$date_time->name("date");
$date_time->id("date");
$date_time->class("inputs");
$date_time->required();
$date_time->addAttribute("style", "margin: 1vw auto;");

$person_capturing_label = new label();
$person_capturing_label->for("person_capturing");
$person_capturing_label->value("Person Capturing Results : ");
$person_capturing_label->addAttribute("style", "margin: 1vw auto;");

$person_capturing = new input();
$person_capturing->type("text");
$person_capturing->name("person_capturing");
$person_capturing->id("person_capturing");
$person_capturing->class("inputs");
$person_capturing->required();
$person_capturing->addAttribute("style", "margin: 1vw auto;");

$lab_name_label = new label();
$lab_name_label->for("laboratory_name");
$lab_name_label->value("Laboratory Name : ");
$lab_name_label->addAttribute("style", "margin: 1vw auto;");

$laboratory_name = new select();
$laboratory_name->name("laboratory_name");
$laboratory_name->id("laboratory_name");
$laboratory_name->class("inputs");
$laboratory_name->add_option("", "Select Laboratory Name");
$laboratory_name->add_option("Merieux", "Merieux");
$laboratory_name->add_option("Microchem", "Microchem");
$laboratory_name->add_option("FACTS SA", "FACTS SA");
$laboratory_name->add_option("PPECB", "PPECB");
$laboratory_name->add_option("Hearshaw & Kinnes", "Hearshaw & Kinnes");
$laboratory_name->required();
$laboratory_name->addAttribute("style", "margin: 1vw auto;width: 20%;");

$lab_accreditation_label = new label();
$lab_accreditation_label->for("laboratory_accreditation");
$lab_accreditation_label->value("Lab SANAS Accreditation number : ");
$lab_accreditation_label->addAttribute("style", "margin: 1vw auto;");

$lab_accreditation = new input();
$lab_accreditation->type("text");
$lab_accreditation->name("laboratory_accreditation");
$lab_accreditation->id("laboratory_accreditation");
$lab_accreditation->class("inputs");
$lab_accreditation->required();
$lab_accreditation->addAttribute("style", "margin: 1vw auto; width: 25%;");

$laboratory_ref_number_label = new label();
$laboratory_ref_number_label->for("laboratory_ref_number");
$laboratory_ref_number_label->value("Laboratory Reference Number : ");
$laboratory_ref_number_label->addAttribute("style", "margin: 1vw auto;");

$laboratory_ref_number = new input();
$laboratory_ref_number->type("text");
$laboratory_ref_number->name("laboratory_ref_number");
$laboratory_ref_number->id("laboratory_ref_number");
$laboratory_ref_number->class("inputs");
$laboratory_ref_number->required();
$laboratory_ref_number->addAttribute("style", "margin: 1vw auto; width: 25%;");

$analysis_date_label = new label();
$analysis_date_label->for("analysis_date");
$analysis_date_label->value("Date of Analysis : ");
$analysis_date_label->addAttribute("style", "margin: 1vw auto;");

$analysis_date = new input();
$analysis_date->type("date");
$analysis_date->name("analysis_date");
$analysis_date->id("analysis_date");
$analysis_date->class("inputs");
$analysis_date->required();
$analysis_date->addAttribute("style", "margin: 1vw auto; ");

$sample_label = new label();
$sample_label->for("sample");
$sample_label->value("Sample name : ");
$sample_label->addAttribute("style", "margin: 1vw auto;");

$sample_name = new select();
$sample_name->name("sample");
$sample_name->id("sample");
$sample_name->class("inputs");
$sample_name->add_option("", "Select Sample Name");
$sample_name->add_option("Sample 1", "Sample 1");
$sample_name->add_option("Sample 2", "Sample 2");
$sample_name->add_option("Sample 3", "Sample 3");
$sample_name->required();
$sample_name->addAttribute("style", "margin: 1vw auto; width: 20%;");

$customer_label = new label();
$customer_label->for("customer");
$customer_label->value("Customer : ");
$customer_label->addAttribute("style", "margin: 1vw auto;");

$customers = new select();
$customers->name("customer");
$customers->id("customer");
$customers->class("inputs");
$customers->add_option("", "Select Customer");
$customers->add_option("Carb Smart", "Carb Smart");
$customers->add_option("Clicks", "Clicks");
$customers->add_option("Ambassador Foods", "Ambassador Foods");
$customers->add_option("Makro/ Mass Mart", "Makro/ Mass Mart");
$customers->add_option("Spinneys", "Spinneys");
$customers->add_option("House of Macadamias- Blueprint", "House of Macadamias- Blueprint");
$customers->add_option("House of Macadamias", "House of Macadamias");
$customers->add_option("Lux 1701", "Lux 1701");
$customers->add_option("Wedgewood", "Wedgewood");
$customers->add_option("Youthful Living", "Youthful Living");
$customers->add_option("Other", "Other");
$customers->onchange("check_customer()");
$customers->required();
$customers->addAttribute("style", "margin: 1vw auto; width: 20%;");

$other_customer = new input();
$other_customer->type("text");
$other_customer->name("other_customer");
$other_customer->id("other_customer");
$other_customer->class("inputs");
$other_customer->placeholder("Please specify");
$other_customer->required();
$other_customer->addAttribute("style", "margin: 1vw auto; width: 100%;");

$product_code_label = new label();
$product_code_label->for("product_code");
$product_code_label->value("Product Code : ");
$product_code_label->addAttribute("style", "margin: 1vw auto;");

$product_code = new input();
$product_code->type("text");
$product_code->name("product_code");
$product_code->id("product_code");
$product_code->class("inputs");
$product_code->required();
$product_code->addAttribute("style", "margin: 1vw auto;");

$batch_number_label = new label();
$batch_number_label->for("batch_number");
$batch_number_label->value("Batch Number : ");
$batch_number_label->addAttribute("style", "margin: 1vw auto;");

$batch_number = new input();
$batch_number->type("text");
$batch_number->name("batch_number");
$batch_number->id("batch_number");
$batch_number->class("inputs");
$batch_number->placeholder("Batch Number");
$batch_number->required();
$batch_number->addAttribute("style", "margin: 1vw auto;");

$production_date_label = new label();
$production_date_label->for("production_date");
$production_date_label->value("Production Date : ");
$production_date_label->addAttribute("style", "margin: 1vw auto;");

$production_date = new input();
$production_date->type("date");
$production_date->name("production_date");
$production_date->id("production_date");
$production_date->class("inputs");
$production_date->required();
$production_date->addAttribute("style", "margin: 1vw auto;");

$expiration_date_label = new label();
$expiration_date_label->for("Expiration_date");
$expiration_date_label->value("Expiration Date : ");
$expiration_date_label->addAttribute("style", "margin: 1vw auto;");

$expiration_date = new input();
$expiration_date->type("date");
$expiration_date->name("Expiration_date");
$expiration_date->id("Expiration_date");
$expiration_date->class("inputs");
$expiration_date->required();
$expiration_date->addAttribute("style", "margin: 1vw auto;");

$purpose_test_label = new label();
$purpose_test_label->for("purpose_test");
$purpose_test_label->value("Purpose of Test : ");
$purpose_test_label->addAttribute("style", "margin: 1vw auto;");

$purpose_test = new select();
$purpose_test->name("purpose_test");
$purpose_test->id("purpose_test");
$purpose_test->class("inputs");
$purpose_test->add_option("", "Select purpose of test");
$purpose_test->add_option("Validation", "Validation");
$purpose_test->add_option("Routine Verification", "Routine Verification");
$purpose_test->add_option("Customer Complaint", "Customer Complaint");
$purpose_test->add_option("Positive Release", "Positive Release");
$purpose_test->add_option("Claim Validation", "Claim Validation");
$purpose_test->add_option("Other", "Other");
$purpose_test->onchange("check_test()");
$purpose_test->addAttribute("style", "margin: 1vw auto;width: 20%;");

$other_purpose_test = new input();
$other_purpose_test->type("text");
$other_purpose_test->name("other_purpose_test");
$other_purpose_test->id("other_purpose_test");
$other_purpose_test->class("inputs");
$other_purpose_test->placeholder("Please specify");
$other_purpose_test->required();
$other_purpose_test->addAttribute("style", "margin: 1vw auto; width: 100%;");

$analysis_type_label = new label();
$analysis_type_label->for("analysis_type_label");
$analysis_type_label->value("Type of Analysis : ");
$analysis_type_label->addAttribute("style", "margin: 1vw auto;");

$analysis_type = new select();
$analysis_type->name("analysis_types");
$analysis_type->id("analysis_types");
$analysis_type->class("inputs");
$analysis_type->add_option("", "Select Type of Analysis");
$analysis_type->add_option("Microbiological analysis", "Microbiological analysis");
$analysis_type->add_option("Chemical analysis", "Chemical analysis");
$analysis_type->add_option("Nutritional analysis", "Nutritional analysis");
$analysis_type->onchange("check_analysis()");
$analysis_type->addAttribute("style", "margin: 1vw auto;width: 20%;");

$sample_type_label = new label();
$sample_type_label->for("sample_type");
$sample_type_label->value("Type of Sample : ");
$sample_type_label->addAttribute("style", "margin: 1vw auto;");

$sample_type = new select();
$sample_type->name("sample_type");
$sample_type->id("sample_type");
$sample_type->class("inputs");
$sample_type->add_option("", "Select Type of Sample");
$sample_type->add_option("Final Product", "Final Product");
$sample_type->add_option("Raw Material", "Raw Material");
$sample_type->add_option("Water", "Water");
$sample_type->add_option("Chemical", "Chemical");
$sample_type->add_option("Surface Swabs", "Surface Swabs");
$sample_type->add_option("Airplates", "Airplates");
$sample_type->addAttribute("style", "margin: 1vw auto;width: 20%;");

$organism = new select();
$organism->name("organisms");
$organism->id("organisms");
$organism->class("inputs");
$organism->add_option("", "Select Organism");
$organism->fill_from_db("micro_list", "record_id", "name", "1");
$organism->addAttribute("style", "margin: 1vw auto;");
$organism->onchange("check_organism(this)");

$results = new input();
$results->type("text");
$results->name("results");
$results->id("results");
$results->class("inputs");
$results->placeholder("Results");
$results->required();
$results->addAttribute("style", "margin: 1vw auto; width: 80%;");

$other_unit_measure = new input();
$other_unit_measure->type("text");
$other_unit_measure->name("other_unit_measure");
$other_unit_measure->id("other_unit_measure");
$other_unit_measure->class("inputs");
$other_unit_measure->placeholder("Unit Of Measure");
$other_unit_measure->required();
$other_unit_measure->addAttribute("style", "margin: 1vw auto;");

$unit_measure_db = new input();
$unit_measure_db->type();
$unit_measure_db->name("unit_of_measure_db");
$unit_measure_db->id("unit_of_measure_db");
$unit_measure_db->class("inputs");
$unit_measure_db->hidden();
$unit_measure_db->value_return();
$unit_measure_db->placeholder("Unit Of Measure");
$unit_measure_db->required();
$unit_measure_db->addAttribute("style", "margin: 1vw auto;");

$unit_measure = new input();
$unit_measure->name("unit_of_measure");
$unit_measure->id("unit_of_measure");
$unit_measure->class("inputs");
$unit_measure->placeholder("Unit Of Measure");
$unit_measure->required();
$unit_measure->addAttribute("style", "margin: 1vw auto; width: 80%;");

$other_unit = new input();
$other_unit->type("text");
$other_unit->name("other_unit_of_measure");
$other_unit->id("other_unit_of_measure");
$other_unit->class("inputs");
$other_unit->required();
$other_unit->addAttribute("style", "margin: 1vw auto;");

$specs_limits = new input();
$specs_limits->type("text");
$specs_limits->name("specs_limits");
$specs_limits->id("specs_limits");
$specs_limits->class("inputs");
$specs_limits->placeholder("Specs/Limits");
$specs_limits->required();
$specs_limits->addAttribute("style", "margin: 1vw auto; width: 80%;");

$within_limits = new select();
$within_limits->name("within_limits");
$within_limits->id("within_limits");
$within_limits->class("inputs");
$within_limits->add_option("", "Within Limits");
$within_limits->add_option("Yes", "Yes");
$within_limits->add_option("No", "No");
$within_limits->addAttribute("style", "margin: 1vw auto; width: 80%;");

$chemical_analysis = new select();
$chemical_analysis->name("chemical_analys");
$chemical_analysis->id("chemical_analys");
$chemical_analysis->class("inputs");
$chemical_analysis->add_option("", "Chemical Analysis");
$chemical_analysis->add_option("Pesticide verification analysis", "Pesticide verification analysis");
$chemical_analysis->add_option("Heavy metal verification analysis", "Heavy metal verification analysis");
$chemical_analysis->add_option("Allergenn verification analysis", "Allergenn verification analysis");
$chemical_analysis->add_option("GMO verification analysis", "GMO verification analysis");
$chemical_analysis->add_option("Chlorine verification", "Chlorine verification");
$chemical_analysis->add_option("Other", "Other");
$chemical_analysis->onchange("check_chemical()");
$chemical_analysis->addAttribute("style", "margin: 1vw auto;");

$add_another = new select();
$add_another->name("another_micro");
$add_another->id("another_micro");
$add_another->class("inputs");
$add_another->onchange("another()");
$add_another->add_option("", "");
$add_another->add_option("Yes", "Yes");
$add_another->add_option("No", "No");
$add_another->addAttribute("style", "margin: 1vw auto;");

$pesticides = new select();
$pesticides->name("pesticides");
$pesticides->id("pesticides");
$pesticides->class("inputs");
$pesticides->add_option("", "Pesticides");
$pesticides->fill_from_db("pesticide_list", "record_id", "name", "1");
$pesticides->addAttribute("style", "margin: 1vw auto;");

$default_mrl = new input();
$default_mrl->type("text");
$default_mrl->name("default_mrl");
$default_mrl->id("default_mrl");
$default_mrl->class("inputs");
$default_mrl->placeholder("Default MRL");
$default_mrl->required();
$default_mrl->addAttribute("style", "margin: 1vw auto;");

$loq = new input();
$loq->type("text");
$loq->name("loq");
$loq->id("loq");
$loq->class("inputs");
$loq->placeholder("LOQ");
$loq->required();
$loq->addAttribute("style", "margin: 1vw auto;");

$mou = new input();
$mou->type("text");
$mou->name("mou");
$mou->id("mou");
$mou->class("inputs");
$mou->placeholder("MOU %");
$mou->required();
$mou->addAttribute("style", "margin: 1vw auto; width: 80%;");

$metal_list = new select();
$metal_list->name("metal_list");
$metal_list->id("metal_list");
$metal_list->class("inputs");
$metal_list->onchange("check_metal()");
$metal_list->add_option("", "Metal List");
$metal_list->add_option("Arsenic", "Arsenic");
$metal_list->add_option("Mercury", "Mercury");
$metal_list->add_option("Lead", "Lead");
$metal_list->add_option("Copper", "Copper");
$metal_list->add_option("Cadmium", "Cadmium");
$metal_list->add_option("Other", "Other");
$metal_list->addAttribute("style", "margin: 1vw auto; width: 80%;");

$other_metal = new input();
$other_metal->type("text");
$other_metal->name("other_metal");
$other_metal->id("other_metal");
$other_metal->class("inputs");
$other_metal->placeholder("Please specify");
$other_metal->required();
$other_metal->addAttribute("style", "margin: 1vw auto; width: 80%;");

$allergen = new select();
$allergen->name("allergens");
$allergen->id("allergens");
$allergen->class("inputs");
$allergen->onchange("check_allergen()");
$allergen->add_option("", "Allergen");
$allergen->add_option("Peanuts", "Peanuts");
$allergen->add_option("Treenuts", "Treenuts");
$allergen->add_option("Cow's milk", "Cow's milk");
$allergen->add_option("Soya", "Soya");
$allergen->add_option("Wheat", "Wheat");
$allergen->add_option("Gluten", "Gluten");
$allergen->add_option("Shell fish", "Shell fish");
$allergen->add_option("Fish", "Fish");
$allergen->add_option("Sesame", "Sesame");
$allergen->add_option("Cellary", "Cellary");
$allergen->add_option("Mustard", "Mustard");
$allergen->add_option("Sulphur dioxide", "Sulphur dioxide");
$allergen->add_option("Other", "Other");
$allergen->addAttribute("style", "margin: 1vw auto; width: 80%;");

$other_allergen = new input();
$other_allergen->type("text");
$other_allergen->name("other_allergen");
$other_allergen->id("other_allergen");
$other_allergen->class("inputs");
$other_allergen->placeholder("Please specify");
$other_allergen->required();
$other_allergen->addAttribute("style", "margin: 1vw auto; width: 80%;");

$gmo = new input();
$gmo->type("text");
$gmo->name("gmo");
$gmo->id("gmo");
$gmo->class("inputs");
$gmo->required();
$gmo->addAttribute("style", "margin: 1vw auto;");

$other_sample = new input();
$other_sample->type("text");
$other_sample->name("other_sample");
$other_sample->id("other_sample");
$other_sample->class("inputs");
$other_sample->required();
$other_sample->addAttribute("style", "margin: 1vw auto;");

$other_result = new input();
$other_result->type("text");
$other_result->name("other_result");
$other_result->id("other_result");
$other_result->class("inputs");
$other_result->required();
$other_result->addAttribute("style", "margin: 1vw auto;");

$other_specs = new input();
$other_specs->type("text");
$other_specs->name("other_specifications");
$other_specs->id("other_specifications");
$other_specs->class("inputs");
$other_specs->required();
$other_specs->addAttribute("style", "margin: 1vw auto;");

$other_within_limits = new select();
$other_within_limits->name("other_within_limits");
$other_within_limits->id("other_within_limits");
$other_within_limits->class("inputs");
$other_within_limits->add_option("", "Select within Critical Limits");
$other_within_limits->add_option("Yes", "Yes");
$other_within_limits->add_option("No", "No");
$other_within_limits->addAttribute("style", "margin: 1vw auto;");

$submit_btn = new button();
$submit_btn->value("SUBMIT");
$submit_btn->onclick("capture_results()");

?>

<div class="form_down">
    <!-- Heading -->
    <div style="border : 2px solid black; padding: 1vw;">
        <?php
        $doc->add();
        $document->add();
        ?>
        <h2>ANALYSIS RESULT CAPTURE RECORD & TRENDING</h2>
    </div>

    <br><br>

    <!-- Date & Person Capturing -->
    <div style="border : 2px solid black; padding: 1vw; width: 95%;border-radius: 2vw;">
        <div style="display: flex;align-items: center; width:100%;">
            <?php
            $date_time_label->add();
            $date_time->add();
            $person_capturing_label->add();
            $person_capturing->add();
            ?>
        </div>
    </div>

    <br><br>

    <!-- Laboratory Details -->
    <div style="display: flex;flex-direction: column;align-items: center; border: 2px solid black; padding: 1vw; width: 95%;border-radius: 2vw;">

        <div style="display: flex;align-items: center;width: 100%;">
            <?php
            $lab_name_label->add();
            $laboratory_name->add();
            $lab_accreditation_label->add();
            $lab_accreditation->add();
            ?>
        </div>
        <div style="display: flex;align-items: center;width: 100%;">
            <?php
            $laboratory_ref_number_label->add();
            $laboratory_ref_number->add();
            $analysis_date_label->add();
            $analysis_date->add();
            ?>
        </div>
    </div>

    <br><br>

    <!-- Sample and Product Details -->
    <div style="display:flex; flex-direction: column;align-items: center; border : 2px solid black; width: 95%;border-radius: 2vw;">
        <div style="display: flex;align-items: center;width: 100%; border-bottom: 2px solid black;">
            <?php
            $sample_label->add();
            $sample_name->add();
            ?>
        </div>
        <div style="display: flex;align-items: center;width: 90%;">
            <?php
            $customer_label->add();
            $customers->add();
            ?>

            <div id="other_customers" style="display: none;">
                <?php
                $other_customer->add();
                ?>
            </div>

            <script>
                function check_customer() {
                    var value = document.getElementById("customer").value;

                    if (value == "Other") {
                        document.getElementById("other_customers").style.display = "flex";
                    } else {
                        document.getElementById("other_customers").style.display = "none";
                    }
                }
            </script>
        </div>
        <div style="display: flex;align-items: center;width: 100%; border-bottom: 2px solid black; border-top: 2px solid black;">
            <?php
            $product_code_label->add();
            $product_code->add();
            $batch_number_label->add();
            $batch_number->add();
            ?>
        </div>
        <div style="display: flex;align-items: center;width: 100%; border-bottom: 2px solid black;">
            <?php
            $production_date_label->add();
            $production_date->add();
            $expiration_date_label->add();
            $expiration_date->add();
            ?>
        </div>
        <div style="display: flex;align-items: center;width: 90%;">
            <?php
            $purpose_test_label->add();
            $purpose_test->add();
            ?>

            <div id="other_test" style="display: none;">
                <?php
                $other_purpose_test->add();
                ?>
            </div>

            <script>
                function check_test() {
                    var value = document.getElementById("purpose_test").value;

                    if (value == "Other") {
                        document.getElementById("other_test").style.display = "flex";
                    } else {
                        document.getElementById("other_test").style.display = "none";
                    }
                }
            </script>
        </div>
    </div>

    <br><br>

    <!-- Analysis & Sample Type -->
    <div style="border : 2px solid black; padding: 1vw; width: 95%;border-radius: 2vw;">
        <div style="display: flex;align-items: center;width: 100%;">
            <?php
            $analysis_type_label->add();
            $analysis_type->add();
            $sample_type_label->add();
            $sample_type->add();
            ?>
        </div>
    </div>

    <!-- Check Analysis function -->
    <script>
        function check_analysis() {
            var value = document.getElementById("analysis_types").value;

            if (value == "Microbiological analysis") {
                document.getElementById("chemical").style.display = "none";
                document.getElementById("micro").style.display = "block";
                document.getElementById("nutrition").style.display = "none";

            } else if (value == "Chemical analysis") {
                document.getElementById("chemical").style.display = "block";
                document.getElementById("micro").style.display = "none";
                document.getElementById("nutrition").style.display = "none";

            } else if (value == "Nutritional analysis") {
                document.getElementById("chemical").style.display = "none";
                document.getElementById("micro").style.display = "none";
                document.getElementById("nutrition").style.display = "block";

            }
        }
    </script>

    <br><br>

    <!-- Microbiological analysis -->
    <div id="micro" style="display: none; width: 95%;">
        <div style="border : 2px solid black;padding-top: 1vw; width: 100%;">
            <div
                style="display: flex; flex-direction: row; justify-content: space-around;width: 100%; border-bottom: 2px solid black;">
                <div style="width: 20%;">
                    ORGANISM
                </div>
                <div style="width: 20%;">
                    RESULTS
                </div>
                <div style="width: 20%;">
                    UNIT OF MEASURE
                </div>
                <div style="width: 20%;">
                    SPECIFICATION/CRITICAL LIMITS
                </div>
                <div style="width: 20%;">
                    WITHIN CRITICAL LIMITS
                </div>
            </div>
            <div style="display: flex; flex-direction: row; width: 100%;justify-content: space-around; ">
                <div style="width: 20%;">
                    <?php
                    $organism->add();
                    ?>
                </div>
                <div style="width: 20%;">
                    <?php
                    $results->add();
                    ?>
                </div>
                <div style="width: 20%;">
                    <?php
                    $unit_measure_db->add();

                    $unit_measure->add();
                    ?>
                </div>
                <div style="width: 20%;">
                    <?php
                    $specs_limits->add();
                    ?>
                </div>
                <div style="width: 20%;">
                    <?php
                    $within_limits->add();
                    ?>
                </div>
            </div>
        </div>

        <!-- ADD ANOTHER -->
        <div>
            <h3>Would you like to add another </h3>
            <?php
            $add_another->add();
            ?>
        </div>

        <br>

        <div id="add_micro" style="border : 2px solid black;padding-top: 1vw; width: 100%; display: none; ">
            <div
                style="display: flex; flex-direction: row; justify-content: space-around;width: 100%; border-bottom: 2px solid black;">
                <div style="width: 20%;">
                    ORGANISM
                </div>
                <div style="width: 20%;">
                    RESULTS
                </div>
                <div style="width: 20%;">
                    UNIT OF MEASURE
                </div>
                <div style="width: 20%;">
                    SPECIFICATION/CRITICAL LIMITS
                </div>
                <div style="width: 20%;">
                    WITHIN CRITICAL LIMITS
                </div>
            </div>
            <div style="display: flex; flex-direction: row; width: 100%;justify-content: space-around; ">
                <div style="width: 20%;">
                    <?php
                    $organism->add();
                    ?>
                </div>
                <div style="width: 20%;">
                    <?php
                    $results->add();
                    ?>
                </div>
                <div id="measure" style="width: 20%;">
                    <?php
                    $unit_measure->add();
                    ?>
                </div>
                <div id="other_organism" style="width: 20%; display: none;">
                    <?php
                    $unit_measure->add();
                    ?>
                </div>
                <div style="width: 20%;">
                    <?php
                    $specs_limits->add();
                    ?>
                </div>
                <div style="width: 20%;">
                    <?php
                    $within_limits->add();
                    ?>
                </div>
            </div>
        </div>

        <script>
            function check_organism(input) {
                document.getElementById('unit_of_measure_db').value = input.value;
            }

            function another() {
                var sec_micro = document.getElementById("another_micro").value;

                if (sec_micro == "Yes") {
                    document.getElementById("add_micro").style.display = "block";
                }
            }

            document.getElementById("unit_of_measure_db").value;



        </script>

    </div>

    <!-- Chemical analysis -->
    <div id="chemical" style="border : 2px solid black; padding: 1vw; width: 95%;border-radius: 2vw; display: none;">
        <div>
            <?php
            $chemical_analysis->add();
            ?>
        </div>
    </div>

    <!-- Check Chemical function -->
    <script>
        function check_chemical() {
            var value = document.getElementById("chemical_analys").value;
            if (value == "Other") {
                document.getElementById("pesticides").style.display = "none";
                document.getElementById("heavy_metals").style.display = "none";
                document.getElementById("allergens").style.display = "none";
                document.getElementById("gmo").style.display = "none";
                document.getElementById("chlorine").style.display = "none";
                document.getElementById("other").style.display = "block";
            } else if (value == "Pesticide verification analysis") {
                document.getElementById("pesticides").style.display = "block";
                document.getElementById("heavy_metals").style.display = "none";
                document.getElementById("allergens").style.display = "none";
                document.getElementById("gmo").style.display = "none";
                document.getElementById("chlorine").style.display = "none";
                document.getElementById("other").style.display = "none";
            } else if (value == "Heavy metal verification analysis") {
                document.getElementById("pesticides").style.display = "none";
                document.getElementById("heavy_metals").style.display = "block";
                document.getElementById("allergens").style.display = "none";
                document.getElementById("gmo").style.display = "none";
                document.getElementById("chlorine").style.display = "none";
                document.getElementById("other").style.display = "none";
            } else if (value == "Allergenn verification analysis") {
                document.getElementById("pesticides").style.display = "none";
                document.getElementById("heavy_metals").style.display = "none";
                document.getElementById("allergens").style.display = "block";
                document.getElementById("gmo").style.display = "none";
                document.getElementById("chlorine").style.display = "none";
                document.getElementById("other").style.display = "none";
            } else if (value == "GMO verification analysis") {
                document.getElementById("pesticides").style.display = "none";
                document.getElementById("heavy_metals").style.display = "none";
                document.getElementById("allergens").style.display = "none";
                document.getElementById("gmo").style.display = "block";
                document.getElementById("chlorine").style.display = "none";
                document.getElementById("other").style.display = "none";
            } else if (value = "Chlorine verification") {
                document.getElementById("pesticides").style.display = "none";
                document.getElementById("heavy_metals").style.display = "none";
                document.getElementById("allergens").style.display = "none";
                document.getElementById("gmo").style.display = "none";
                document.getElementById("chlorine").style.display = "block";
                document.getElementById("other").style.display = "none";
            } else {
                document.getElementById("pesticides").style.display = "none";
                document.getElementById("heavy_metals").style.display = "none";
                document.getElementById("allergens").style.display = "none";
                document.getElementById("gmo").style.display = "none";
                document.getElementById("chlorine").style.display = "none";
                document.getElementById("other").style.display = "none";
            }
        }
    </script>

    <!-- Nutritional analysis -->
    <div id="nutrition" style="border : 2px solid black; width: 95%; display: none;">
        <div
            style="display: flex; flex-direction: row; justify-content: space-around;width: 100%; background-color: black;">
            <p style="color: white;">NUTRITIONAL INFORMATION</p>
        </div>
        <div
            style="display: flex; flex-direction: row; justify-content: space-around;width: 100%; border-bottom: 2px solid black;">
            <div style="width: 30%;"></div>
            <div style="border-left: 2px solid black; width: 30%; font-weight: bold;">per 100 g</div>
            <div style="border-left: 2px solid black; width: 30%; font-weight: bold;">per 20 g</div>
        </div>
        <div
            style="display: flex; flex-direction: row; justify-content: space-around;width: 100%; border-bottom: 2px solid black;">
            <div style="width: 30%;">Kilojoules (kJ)</div>
            <div style="border-left: 2px solid black; width: 30%;"></div>
            <div style="border-left: 2px solid black; width: 30%;"></div>
        </div>
        <div
            style="display: flex; flex-direction: row; justify-content: space-around;width: 100%; border-bottom: 2px solid black;">
            <div style="width: 30%;">Protein (g)</div>
            <div style="border-left: 2px solid black; width: 30%;"></div>
            <div style="border-left: 2px solid black; width: 30%;"></div>
        </div>
        <div
            style="display: flex; flex-direction: row; justify-content: space-around;width: 100%; border-bottom: 2px solid black;">
            <div style="width: 30%;">Fat (g)</div>
            <div style="border-left: 2px solid black; width: 30%;"></div>
            <div style="border-left: 2px solid black; width: 30%;"></div>
        </div>
        <div
            style="display: flex; flex-direction: row; justify-content: space-around;width: 100%; border-bottom: 2px solid black;">
            <div style="width: 30%;">Unsaturated fats (g)</div>
            <div style="border-left: 2px solid black; width: 30%;"></div>
            <div style="border-left: 2px solid black; width: 30%;"></div>
        </div>
        <div
            style="display: flex; flex-direction: row; justify-content: space-around;width: 100%; border-bottom: 2px solid black;">
            <div style="width: 30%;">Saturated fats (g)</div>
            <div style="border-left: 2px solid black; width: 30%;"></div>
            <div style="border-left: 2px solid black; width: 30%;"></div>
        </div>
        <div
            style="display: flex; flex-direction: row; justify-content: space-around;width: 100%; border-bottom: 2px solid black;">
            <div style="width: 30%;">Monounsaturated fats (g)</div>
            <div style="border-left: 2px solid black; width: 30%;"></div>
            <div style="border-left: 2px solid black; width: 30%;"></div>
        </div>
        <div
            style="display: flex; flex-direction: row; justify-content: space-around;width: 100%; border-bottom: 2px solid black;">
            <div style="width: 30%;">Polyunsaturated fats (g)</div>
            <div style="border-left: 2px solid black; width: 30%;"></div>
            <div style="border-left: 2px solid black; width: 30%;"></div>
        </div>
        <div
            style="display: flex; flex-direction: row; justify-content: space-around;width: 100%; border-bottom: 2px solid black;">
            <div style="width: 30%;">Carbohydrates (g)</div>
            <div style="border-left: 2px solid black; width: 30%;"></div>
            <div style="border-left: 2px solid black; width: 30%;"></div>
        </div>
        <div
            style="display: flex; flex-direction: row; justify-content: space-around;width: 100%; border-bottom: 2px solid black;">
            <div style="width: 30%;">of which sugars(g)</div>
            <div style="border-left: 2px solid black; width: 30%;"></div>
            <div style="border-left: 2px solid black; width: 30%;"></div>
        </div>
        <div
            style="display: flex; flex-direction: row; justify-content: space-around;width: 100%; border-bottom: 2px solid black;">
            <div style="width: 30%;">Fibre (g)</div>
            <div style="border-left: 2px solid black; width: 30%;"></div>
            <div style="border-left: 2px solid black; width: 30%;"></div>
        </div>
        <div
            style="display: flex; flex-direction: row; justify-content: space-around;width: 100%; border-bottom: 2px solid black;">
            <div style="width: 30%;">Soluble (g)</div>
            <div style="border-left: 2px solid black; width: 30%;"></div>
            <div style="border-left: 2px solid black; width: 30%;"></div>
        </div>
        <div
            style="display: flex; flex-direction: row; justify-content: space-around;width: 100%; border-bottom: 2px solid black;">
            <div style="width: 30%;">Non-soluble (g)</div>
            <div style="border-left: 2px solid black; width: 30%;"></div>
            <div style="border-left: 2px solid black; width: 30%;"></div>
        </div>
        <div
            style="display: flex; flex-direction: row; justify-content: space-around;width: 100%; border-bottom: 2px solid black;">
            <div style="width: 30%;">Sodium (mg)</div>
            <div style="border-left: 2px solid black; width: 30%;"></div>
            <div style="border-left: 2px solid black; width: 30%;"></div>
        </div>
        <div
            style="display: flex; flex-direction: row; justify-content: space-around;width: 100%; border-bottom: 2px solid black;">
            <div style="width: 30%;">Cholesterol (mg)</div>
            <div style="border-left: 2px solid black; width: 30%;"></div>
            <div style="border-left: 2px solid black; width: 30%;"></div>
        </div>
        <div style="display: flex; flex-direction: row; justify-content: space-around;width: 100%;">
            <div style="width: 30%;font-weight: bold;">Other</div>
            <div style="border-left: 2px solid black; width: 30%;"></div>
            <div style="border-left: 2px solid black; width: 30%;"></div>
        </div>
    </div>

    <br><br>

    <!-- pesticides -->
    <div id="pesticides" style="border : 2px solid black; padding-top: 1vw; width: 95%; display: none;">
        <div
            style="display: flex; flex-direction: row; justify-content: space-around;width: 100%;border-bottom: 2px solid black;">
            <div style="width: 20%;">
                COMPOUND DETECTED
            </div>
            <div style="width: 20%;">
                RESULTS
            </div>
            <div style="width: 20%;">
                DEFAULT MRL
            </div>
            <div style="width: 20%;">
                LOQ
            </div>
            <div style="width: 20%;">
                SPECIFICATION/CRITICAL LIMITS
            </div>
            <div style="width: 20%;">
                WITHIN CRITICAL LIMITS
            </div>
        </div>
        <div style="display: flex; flex-direction: row; width: 100%;justify-content: space-around;">
            <div style="width: 20%;">
                <?php
                $pesticides->add();
                ?>
            </div>
            <div style="width: 20%;">
                <?php
                $results->add();
                ?>
            </div>
            <div style="width: 20%;">
                <?php
                $default_mrl->add();
                ?>
            </div>
            <div style="width: 20%;">
                <?php
                $loq->add();
                ?>
            </div>
            <div style="width: 20%;">
                <?php
                $specs_limits->add();
                ?>
            </div>
            <div style="width: 20%;">
                <?php
                $within_limits->add();
                ?>
            </div>
        </div>
    </div>

    <!-- heavy metals -->
    <div id="heavy_metals" style="border : 2px solid black; padding-top: 1vw; width: 95%; display: none;">
        <div
            style="display: flex; flex-direction: row; justify-content: space-around;width: 100%;border-bottom: 2px solid black;">
            <div style="width: 20%;">
                TEST TYPE [METAL]
            </div>
            <div style="width: 20%;">
                RESULTS
            </div>
            <div style="width: 20%;">
                UNIT OF MEASURE
            </div>
            <div style="width: 20%;">
                MOU (%)
            </div>
            <div style="width: 20%;">
                SPECIFICATION/CRITICAL LIMITS
            </div>
            <div style="width: 20%;">
                WITHIN CRITICAL LIMITS
            </div>
        </div>
        <div style="display: flex; flex-direction: row; width: 100%;justify-content: space-around;">
            <div style="width: 20%;">
                <?php
                $metal_list->add();
                ?>
            </div>
            <div style="width: 20%; display: none;" id="other_metal">
                <?php
                $other_metal->add();
                ?>
            </div>
            <div style="width: 20%;">
                <?php
                $results->add();
                ?>
            </div>
            <div style="width: 20%;">
                <?php
                $unit_measure->add();
                ?>
            </div>
            <div style="width: 20%;">
                <?php
                $mou->add();
                ?>
            </div>
            <div style="width: 20%;">
                <?php
                $specs_limits->add();
                ?>
            </div>
            <div style="width: 20%;">
                <?php
                $within_limits->add();
                ?>
            </div>
        </div>

        <script>
            function check_metal() {
                var metal = document.getElementById('metal_list').value;

                if (metal == "Other") {
                    document.getElementById("other_metal").style.display = "flex";
                } else {
                    document.getElementById("other_metal").style.display = "none";
                }
            }
        </script>
    </div>

    <!-- allergens -->
    <div id="allergens" style="border : 2px solid black; padding-top: 1vw; width: 95%;display: none;">
        <div
            style="display: flex; flex-direction: row; justify-content: space-around;width: 100%;border-bottom: 2px solid black;">
            <div style="width: 20%;">
                ALLERGEN
            </div>
            <div style="width: 20%;">
                RESULTS
            </div>
            <div style="width: 20%;">
                UNIT OF MEASURE
            </div>
            <div style="width: 20%;">
                MOU (%)
            </div>
            <div style="width: 20%;">
                SPECIFICATION/CRITICAL LIMITS
            </div>
            <div style="width: 20%;">
                WITHIN CRITICAL LIMITS
            </div>
        </div>
        <div style="display: flex; flex-direction: row; width: 100%;justify-content: space-around;">
            <div style="width: 20%;">
                <?php
                $allergen->add();
                ?>
            </div>
            <div id="other_allergens" style="width: 20%; display: none;">
                <?php
                $other_allergen->add();
                ?>
            </div>
            <div style="width: 20%;">
                <?php
                $results->add();
                ?>
            </div>
            <div style="width: 20%;">
                <?php
                $unit_measure->add();
                ?>
            </div>
            <div style="width: 20%;">
                <?php
                $mou->add();
                ?>
            </div>
            <div style="width: 20%;">
                <?php
                $specs_limits->add();
                ?>
            </div>
            <div style="width: 20%;">
                <?php
                $within_limits->add();
                ?>
            </div>
        </div>

        <script>
            function check_allergen() {
                var allergens = document.getElementById('allergens').value;

                if (allergens == "Other") {
                    document.getElementById("other_allergens").style.display = "flex";
                } else {
                    document.getElementById("other_allergens").style.display = "none";
                }
            }
        </script>
    </div>

    <!-- GMO -->
    <div id="gmo" style="border : 2px solid black; padding-top: 1vw; width: 95%;display: none;">
        <div
            style="display: flex; flex-direction: row; justify-content: space-around;width: 100%;border-bottom: 2px solid black;">
            <div style="width: 20%;">
                ORGANISM
            </div>
            <div style="width: 20%;">
                RESULTS
            </div>
            <div style="width: 20%;">
                UNIT OF MEASURE
            </div>
            <div style="width: 20%;">
                MOU (%)
            </div>
            <div style="width: 20%;">
                SPECIFICATION/CRITICAL LIMITS
            </div>
            <div style="width: 20%;">
                WITHIN CRITICAL LIMITS
            </div>
        </div>
        <div style="display: flex; flex-direction: row; width: 100%;justify-content: space-around;">
            <div style="width: 20%;">
                <?php
                $gmo->add();
                ?>
            </div>
            <div style="width: 20%;">
                <?php
                $results->add();
                ?>
            </div>
            <div style="width: 20%;">
                <?php
                $unit_measure->add();
                ?>
            </div>
            <div style="width: 20%;">
                <?php
                $mou->add();
                ?>
            </div>
            <div style="width: 20%;">
                <?php
                $specs_limits->add();
                ?>
            </div>
            <div style="width: 20%;">
                <?php
                $within_limits->add();
                ?>
            </div>
        </div>
    </div>

    <!-- chlorine -->
    <div id="chlorine" style="border : 2px solid black; padding-top: 1vw; width: 95%;display: none;">
        <div
            style="display: flex; flex-direction: row; justify-content: space-around;width: 100%;border-bottom: 2px solid black;">
            <div style="width: 20%;">
                ORGANISM
            </div>
            <div style="width: 20%;">
                RESULTS
            </div>
            <div style="width: 20%;">
                UNIT OF MEASURE
            </div>
            <div style="width: 20%;">
                SPECIFICATION/CRITICAL LIMITS
            </div>
            <div style="width: 20%;">
                WITHIN CRITICAL LIMITS
            </div>
        </div>
        <div style="display: flex; flex-direction: row; width: 100%;justify-content: space-around;align-items: center;">
            <div class="inputs" style="width: 13%;">
                Chlorine In Water
            </div>
            <div style="width: 20%;">
                <?php
                $results->add();
                ?>
            </div>
            <div style="width: 20%;">
                <?php
                $unit_measure->add();
                ?>
            </div>
            <div style="width: 20%;">
                <?php
                $specs_limits->add();
                ?>
            </div>
            <div style="width: 20%;">
                <?php
                $within_limits->add();
                ?>
            </div>
        </div>
    </div>

    <!-- other -->
    <div id="other" style="border : 2px solid black; padding-top: 1vw; width: 95%;display: none;">
        <div
            style="display: flex; flex-direction: row; justify-content: space-around;width: 100%;border-bottom: 2px solid black;">
            <div style="width: 20%;">
                ORGANISM
            </div>
            <div style="width: 20%;">
                RESULTS
            </div>
            <div style="width: 20%;">
                UNIT OF MEASURE
            </div>
            <div style="width: 20%;">
                SPECIFICATION/CRITICAL LIMITS
            </div>
            <div style="width: 20%;">
                WITHIN CRITICAL LIMITS
            </div>
        </div>
        <div style="display: flex; flex-direction: row; width: 100%;justify-content: space-around;">
            <div style="width: 20%;">
                <?php
                $other_sample->add();
                ?>
            </div>
            <div style="width: 20%;">
                <?php
                $other_result->add();
                ?>
            </div>
            <div style="width: 20%;">
                <?php
                $other_unit->add();
                ?>
            </div>
            <div style="width: 20%;">
                <?php
                $other_specs->add();
                ?>
            </div>
            <div style="width: 20%;">
                <?php
                $other_within_limits->add();
                ?>
            </div>
        </div>
    </div>

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

<?php

$ajax = new js_ajax();
$ajax->function_name("capture_results");
$ajax->submit_btn_id("submit");
$ajax->insert("drying_bins");
$ajax->on_success("DRYING BIN ADDED SUCCESSFULLY");

?>