<?php
include "db.class.php";

$db = new DBMain();

//a search query that searches for the jobcard number

if (isset($_POST['search'])) {
    $search = $_POST['search'];

    $jobcard_res = $db->exec_query('jobcards', ['*'], '', '', '', '', 'jobcard_number = ' . $search);
}

?>
<style>
    .apple-form {
        display: flex;
        flex-direction: column;
        align-items: center;
        font-family: 'Arial', sans-serif;
        width: 80%;
        border: #007AFF 1px solid;
        border-radius: 25px;
        margin-left: auto;
        padding: 5vw;
        margin-right: auto;
    }

    .form-group {
        display: flex;
        flex-direction: column;
        margin-bottom: 10px;
        width: 500px;
        margin-left: auto;
        margin-right: auto;
        align-content: center;
        flex-wrap: wrap;
        background-color: #929292;
        border-radius: 10px;
    }

    .form-group label {
        margin-bottom: 5px;
    }

    .form-group input {
        padding: 5px;
        border: 1px solid #ccc;
        border-radius: 5px;
        width: 100%;
    }

    .form-group select {
        padding: 5px;
        border: 1px solid #ccc;
        border-radius: 5px;
        width: 100%;
        max-width: 300px;
    }

    .form-group textarea {
        padding: 5px;
        border: 1px solid #ccc;
        border-radius: 5px;
        width: 100%;
        max-width: 300px;
    }

    .form-group input[type=submit] {
        padding: 10px 20px;
        border: none;
        border-radius: 5px;
        background-color: #007AFF;
        color: #fff;
        cursor: pointer;
        margin-top: 10px;
    }

    .apple-form button {
        padding: 10px 20px;
        border: none;
        border-radius: 5px;
        background-color: #007AFF;
        color: #fff;
        cursor: pointer;
        margin-top: 10px;
    }

    .form {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
    }

    .form-group input[type=submit]:hover {
        background-color: black;
        cursor: pointer;
        transition: ease-in-out 0.5s;
    }

    @media (max-width: 480px) {
        .apple-form {
            flex-direction: column;
        }

        .form-group {
            margin-bottom: 5px;
        }
    }
</style>
<br><br>
<style>
    .back_btn {
        position: absolute;
        left: 1%;
        top: 1%;
        width: 25%;
        height: fit-content;
        background-color: #007AFF;
        color: #fff;
        border-radius: 10px;
        padding: 1%;
        text-align: center;
    }
</style>
<a href='index.php'>
    <div class='back_btn'>
        BACK
    </div>
</a>
<div class="form-group">
    <h1>SEARCH JOBCARD</h1>
    <form method="POST" action="search_results.php">

        <input type="number" name="jobccard" placeholder="Jobcard Number">
        <br>
        <br>

        <input type="text" name="artist" placeholder="Artist">
        <br>
        <br>
        <input type="text" name="sculpture" placeholder="Sculpture">
        <br>
        <br>
        <input type="text" name="account_number" placeholder="Account Number">
        <br>
        <br>
        <input type="date" name="date" placeholder="Date">

        <input type="submit" value="Search"></input>

    </form>
</div>