<?php include('includes/header.php'); ?>

<div class="row">
    <div class="col-md-12">
        <div class="card">
            <div class="card-header">
                <h4>
                    Edit Client
                    <a href="clients.php" class="btn btn-danger float-end">Back</a>
                </h4>
            </div>
            <div class="card-body">

            <?= alertMessage(); ?>

                <form action="code.php" method="POST">

                <?php
                    $paramResult = checkParamId('clientID');
                    if(!is_numeric($paramResult))
                    {
                        echo '<h5>'.$paramResult.'</h5>';
                        return false;
                    }
                    
                    $clients = getBycId('clients',checkParamId('clientID'));
                    if($clients['status'==200])
                    {
                        ?>
                        <?php
                    }
                    else
                    {
                        echo '<h5>'.$clients['message'].'</h5>';
                    }
                ?>

                <input type="hidden" name="CID" value="<?= $clients['data']['clientID'] ;?>"required >

                    <div class="row">
                        <div class="col-md-6">
                            <div class="mb-3">
                                <label>Client Name</label>
                                <input type="text" name="clientName" value="<?= $clients['data']['clientName'] ;?>"required class="form-control">
                            </div>
                        </div>

                        <div class="col-md-6">
                            <div class="mb-3">
                                <br>
                                <button type="submit" name="updateClient" class="btn btn-primary">Update</button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>



<?php include('includes/footer.php'); ?>