<?php include "../../root.class.php";
$html = new html();
$html->add_styles_page();
$db = new db_safeguard();


$teams_res = $db->query("teams", "SELECT * FROM teams WHERE status = 'ACTIVE' ORDER BY record_id DESC");

?>

<style>
    table {
        border-collapse: collapse;
        width: 90%;
        background-color: whitesmoke;
    }

    table,
    th,
    td {
        border: 2px solid black;
        padding: 1vw;
    }

    th {
        padding: 0.5vw;
    }

    /* table {
        width: 80%;
        border: 2px solid black;
    }

    th {
        text-align: left;
        font-size: 2vw;
        border: 2px solid black;
    }

    td {
        text-align: left;
        font-size: 1.5vw;
        border: 2px solid black;

    } */

    tr:nth-child(even) {
        background-color: #ffa50063;
    }

    tr:hover {
        background-color: #ddd;
    }
</style>

<div class="form_down">
    <h1>CURRENT TEAMS</h1>
    <table>
        <tr>
            <th>
                TEAM NAME
            </th>
            <th>

                ASSETS ASSIGNED TO TEAM
            </th>
            <th>
                TEAM MEMBERS
            </th>
            <th>
                STATUS
            </th>
        </tr>
        <?php
        while ($teams = $teams_res->fetch_assoc()) {
            $assets = $assets[] = explode(",", $teams["assigned_assets"]);
            ?>

            <tr onclick="window.location.href = '../teams/edit_teams.php?record_id=<?php echo $teams['record_id']; ?>'"
                style="cursor:pointer;">
                <td>
                    <?php
                    echo $teams["name"];
                    ?>
                </td>
                <td>
                    <?php
                    // echo implode("", $assets);
                    echo $teams["assigned_assets"];
                    ?>
                </td>
                <td>
                    <?php
                    echo $teams["team_members"];
                    ?>
                </td>
                <td>
                    <?php
                    echo $teams["status"] . "<br>";
                    ?>
                </td>
            </tr>
            <?php
        }
        ?>
    </table>
    <br>
</div>