<?php

include "../../root.class.php";
include "../../html.class.php";
include "../../classes/db.class.php";
$html = new html();
$functions = new functions();

$client_name = new input();
$client_name->id("client_name");
$client_name->name("client_name");
$client_name->type("text");
$client_name->placeholder("Client Name");
$client_name->class();
$client_name->onkeyup("search_client()");

$tanks_res = $db->query("clients", "SELECT * FROM clients WHERE company_id = {$_SESSION['company_id']} ORDER BY record_id DESC");

$company_id = new input();
$company_id->class("inputs");
$company_id->type("hidden");
$company_id->placeholder("company id");
$company_id->name("company_id");
$company_id->required();
$company_id->id("company_id");
$company_id->value($_SESSION['company_id']);

$client_email = new input();
$client_email->id("client_email");
$client_email->name("client_email");
$client_email->type("email");
$client_email->placeholder("Client Email");
$client_email->class();
$client_email->onkeyup("search_client()");

?>

<div class="tank_item_container">
    <h1>CLIENTS</h1>
    <input type="submit" class="app_buttons_small" value="ADD" onclick="window.location.href='add_client.php'">
</div>
<div class="tank_item_container">
    <div class="table-responsive">
        <table>
            <tr>
                <th>
                    NAME
                </th>
                <th>
                    EMAIL
                </th>
                <th>
                    CONTACT
                </th>
            </tr>

            <?php

            while ($tanks = $tanks_res->fetch_assoc()) {
                ?>

                <tr  onclick="window.location.href='edit_client.php?record_id=<?php echo $tanks['record_id']; ?>'">
                    <td>
                        <input type='text' value='<?php echo $tanks['client_name']; ?>' readonly class="table_input">
                    </td>
                    <td>
                        <input type='text' value='<?php echo $tanks['client_email']; ?>' readonly class="table_input">
                    </td>
                    <td>
                        <input type='text' value='<?php echo $tanks['client_contact']; ?>' readonly class="table_input">
                    </td>

                </tr>
                <?php
            }
            ?>

        </table>
    </div>
</div>