<?php

include "classes/html.class.php";

$html = new html("clients");
?>



<div class='form'>
    <h2 style="font-size:2vw">ADD CLIENT:</h2>
    <hr><br>

    <label style="font-size:1.5vw">CLIENT NAME: </label><br>
    <input type='text' placeholder="CLIENT NAME" id='client_name' class='form_input' />
    <br><br>

    <label style="font-size:1.5vw">EMAIL: </label><br>
    <input type='text' placeholder="EMAIL" id='email' class='form_input' />
    <br><br>

    <label style="font-size:1.5vw">CONTACT PERSON: </label><br>
    <input type='text' placeholder="CONTACT PERSON" id='contact_person' class='form_input' />
    <br><br>

    <label style="font-size:1.5vw">LOCATION: </label><br>
    <input type='text' placeholder="LOCATION" id='location' class='form_input' />
    <hr><br>

    <label style="font-size:1.5vw">COMPANY NAME: </label><br>
    <input type='text' placeholder="COMPANY NAME" id='company_name' class='form_input' />
    <br><br>

    <label style="font-size:1.5vw">CONTACT NUMBER: </label><br>
    <input type='number' placeholder="CONTACT NUMBER" id='contact_number' class='form_input' />
    <br><br>

    <label style="font-size:1.5vw">VAT NUMBER: </label><br>
    <input type='number' placeholder="VAT NUMBER" id='vat_number' class='form_input' />
    <br><br>

    <label style="font-size:1.5vw">COMPANY REGISTRATION NUMBER: </label><br>
    <input type='number' placeholder="COMPANY REGI NUMBER" id='company_registration_number' class='form_input' />
    <hr><br>

    <label style="font-size:1.5vw">STATUS: </label><br>
    <select name='status' id='status' class='form_input'>
        <option value=''></option>
        <option value='ACTIVE'>ACTIVE</option>
        <option value='INACTIVE'>INACTIVE</option>
    </select>
    <br><br>

    <input type='submit' value='ADD' class='form_btn' onclick='ajax_func()' />

</div>

<script>
    function ajax_func() {
        client_name = document.getElementById('client_name').value;
        email = document.getElementById('email').value;
        contact_person = document.getElementById('contact_person').value;
        location = document.getElementById('location').value;
        company_name = document.getElementById('company_name').value;
        contact_number = document.getElementById('contact_number').value;
        vat_number = document.getElementById('vat_number').value;
        company_registration_number = document.getElementById('company_registration_number').value;
        status = document.getElementById('status').value;

        // Create an XMLHttpRequest object
        const xhttp = new XMLHttpRequest();
        // Define a callback function
        xhttp.onload = function () {
            // Here you can use the Data
            if (this.responseText != 1) {

                alert(this.responseText);

            } else {
                alert("CLIENT ADDED")
                window.location.href = "add_home.php";
            }
        }

        xhttp.open("GET", "ajax/add_client.ajax.php?client_name=" + client_name + '&email=' + email + '&contact_person=' + contact_person + '&location' + location + '&company_name=' + company_name + '&contact_number=' + contact_number + '&vat_number=' + vat_number + '&company_registration_number=' + company_registration_number + '&status=' + status);
        xhttp.send();

    }
</script>


</body>

</html>