<?php 
    require_once 'connection.php'; // Include your database connection file
    // Retrieve data from the database
    $sql = "SELECT * FROM offer_letter";
    $result = $conn->query($sql);
?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Admin : Offer Letter</title>
    <link rel="stylesheet"
        href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">

    <link rel="stylesheet" href="../../plugins/fontawesome-free/css/all.min.css">

    <link rel="stylesheet" href="../../plugins/datatables-bs4/css/dataTables.bootstrap4.min.css">
    <link rel="stylesheet" href="../../plugins/datatables-responsive/css/responsive.bootstrap4.min.css">
    <link rel="stylesheet" href="../../plugins/datatables-buttons/css/buttons.bootstrap4.min.css">
    <link rel="stylesheet" href="https://cdn.datatables.net/1.11.4/css/jquery.dataTables.min.css">

    <link rel="stylesheet" href="../../dist/css/adminlte.min.css">
    <?php include("headerlink.php")?>
</head>

<body class="hold-transition sidebar-mini layout-fixed">
    <div class="wrapper">

        <div class="preloader flex-column justify-content-center align-items-center">
            <img class="animation__shake" src="dist/img/AdminLTELogo.png" alt="AdminLTELogo" height="60" width="60">
        </div>

        <?php include("navbar.php")?>

        <?php include("sidebar.php")?>

        <div class="content-wrapper">

            <div class="content-header">
                <div class="container-fluid">
                    <div class="row mb-2">
                        <div class="col-sm-6">
                            <h1 class="m-0 fw-bold text-uppercase">Print Documents</h1>
                        </div>

                        <div class="col-sm-6">
                            <ol class="breadcrumb float-sm-right">
                                <li class="breadcrumb-item"><a href="#">Home</a></li>
                                <li class="breadcrumb-item active">Print Documents</li>
                                <li class="breadcrumb-item active">Offer Letter</li>
                            </ol>
                        </div>

                    </div>

                </div>

            </div>

            <section class="content">
                <div class="container-fluid">
                    <div class="row">

                        <div class="col-md-12">

                            <div class="card card-primary">
                                <div class="card-header" style="background: #343a40;">
                                    <h3 class="card-title text-uppercase fw-bold">Print Offer Letter</h3>
                                </div>

                                <form action="offer-lettercode.php" method="post" enctype="multipart/form-data">
                                    <div class="card-body">
                                        <div class="row">
                                            <div class="col-lg-5 col-sm-12">
                                                <div class="form-group">
                                                    <label for="exampleInputPerson">Name</label>
                                                    <input type="text" id="name" class="form-control" name="name"
                                                        required placeholder="Name">
                                                </div>
                                            </div>
                                            <div class="col-lg-5 col-sm-12">
                                                <div class="form-group">
                                                    <label for="exampleInputPerson">Full Name</label>
                                                    <input type="text" id="full_name" name="full_name" required
                                                        placeholder="Full_name" class="form-control">
                                                </div>
                                            </div>
                                            <div class="col-lg-2 col-sm-12">
                                                <div class="form-group">
                                                    <label for="exampleInputPerson">Year</label>
                                                    <input type="text" id="year" name="year" required
                                                        class="form-control" placeholder="Year">
                                                </div>
                                            </div>

                                        </div>
                                        <div class="row">
                                            <div class="col-lg-6 col-sm-12">
                                                <div class="form-group">
                                                    <label for="exampleInputNumber">Desgination</label>
                                                    <input type="text" id="designation" name="designation"
                                                        class="form-control" required placeholder="desgination">

                                                </div>
                                            </div>
                                            <div class="col-lg-6 col-sm-12">
                                                <div class="form-group">
                                                    <label for="exampleInputEmail">Department</label>
                                                    <input type="text" id="department" name="department"
                                                        class="form-control" required placeholder="department"><br>
                                                </div>
                                            </div>

                                        </div>

                                    </div>

                                    <div class="card-footer">
                                        <button type="submit" class="btn text-white fw-bold"
                                            style="background: #343a40;">Create OL</button>
                                    </div>
                                </form>
                            </div>

                        </div>

                    </div>

                </div>
            </section>
            <section class="content">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-12">
                            <div class="card shadow">
                                <div class="card-header" style="background: #343a40; ">
                                    <h3 class="card-title text-white text-bold text-uppercase">All Resume</h3>
                                </div>

                                <div class="card-body">
                                    <div id="example2_wrapper" class="dataTables_wrapper dt-bootstrap4">
                                        <div class="row">
                                            <div class="col-sm-12 col-md-6"></div>
                                            <div class="col-sm-12 col-md-6"></div>
                                        </div>
                                        <div class="row">
                                            <div class="col-sm-12">
                                                <table class="table-responsive">
                                                    <table id="example2"
                                                        class="table table-bordered table-hover dataTable dtr-inline display"
                                                        aria-describedby="example2_info">
                                                        <thead>
                                                            <tr>
                                                                <th>Date &amp; time</th>
                                                                <th>Name</th>
                                                                <th>Full Name</th>
                                                                <th>Year</th>
                                                                <th>Desgination</th>
                                                                <th>Department</th>
                                                                <th>Download</th>
                                                            </tr>
                                                        </thead>
                                                        <tbody>

                                                            <?php while ($row = $result->fetch_assoc()) : ?>

                                                            <tr>
                                                                <td><?php echo $row["id"]; ?></td>
                                                                <td><?php echo $row["name"]; ?></td>
                                                                <td><?php echo $row["full_name"]; ?></td>
                                                                <td><?php echo $row["year"]; ?></td>
                                                                <td><?php echo $row["designation"]; ?></td>
                                                                <td><?php echo $row["department"]; ?></td>
                                                                <td>
                                                                    <a href="download.php?id=<?php echo $row['id']; ?>"
                                                                        class="btn btn-primary btn-sm">
                                                                        <i class="fas fa-download"></i> Download
                                                                    </a>
                                                                </td>
                                                            </tr>
                                                            <?php endwhile; ?>
                                                        </tbody>

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

                                    </div>
                                </div>

                            </div>

                        </div>

                    </div>

                </div>

            </section>

        </div>

        <?php include("footer.php")?>


    </div>


    <?php include("footerlink.php")?>

    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script src="https://cdn.datatables.net/1.11.4/js/jquery.dataTables.min.js"></script>
    <script>
    var $j = jQuery.noConflict();
    $j(document).ready(function() {
        $j('#example2').DataTable();
    });
    </script>
</body>

</html>