<?php

include "../../classes/app.class.php";

$app = new app();

?>


<div class='container flex_container'>
    <h1>SEARCH CLIENT BY:</h1>
    <div class="container flex_container" style='border: 1px solid black; width:80%;padding: 10px;border-radius: 10px;'>

        <div class='flex_container_content'>
            <input type='text' id='name' placeholder='Enter Client Name'>
            <input type='text' id='contact_person' placeholder='Enter Contact Name'>
            <input type='text' id='number' placeholder='Enter Contact Number'>
            <select id='status' style='font-size:1vw;'>
                <option>STATUS</option>
                <option value=1>ACTIVE</option>
                <option value=0>INACTIVE</option>
            </select>
        </div>
        <div class='flex_container_content'>
            <input type='text' id='email' placeholder='Enter Client Email'>
            <input type='text' id='address' placeholder='Enter Client Address'>

        </div>
        <button onclick="search_client()" class='font_size_2vw'>SEARCH</button>
    </div>
</div>

<div class='flex_container' id='content'>

</div>

<script>
    function search_client() {
        var name = document.getElementById('name').value;
        var contact_person = document.getElementById('contact_person').value;
        var number = document.getElementById('number').value;
        var email = document.getElementById('email').value;
        var address = document.getElementById('address').value;
        var status = document.getElementById('status').value;

        var xhttp = new XMLHttpRequest();
        xhttp.onload = function() {
          
                document.getElementById('content').innerHTML = this.responseText;
            
        }
        xhttp.open("GET", '../../ajax/clients/search_client.php?name=' + name + '& contact_person=' + contact_person + '&number=' + number + '&email=' + email + '&address=' + address + '&status=' + status);
        xhttp.send();

    }

    function edit_client($id){
        window.location.href='edit_client.php?record_id=' + $id;
    }
</script>