<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Admin : Add Expenses</title>
    <link rel="stylesheet" href="https://cdn.datatables.net/1.11.4/css/jquery.dataTables.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">Inventory</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">Inventory</li>
                                <li class="breadcrumb-item active">Expenses</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  shadow" style="background: #343a40;">
                                    <h3 class="card-title fw-bold text-uppercase">Add Expense</h3>
                                </div>

                                <form action="expenses_code.php" method="POST">
                                    <div class="card-body">
                                        <div class="row ">
                                            <div class="col-lg-6 col-sm-12">
                                                <div class="form-group">
                                                    <label for="exampleInputtitle">Title</label>
                                                    <input type="text" class="form-control" placeholder="Title"
                                                        name="title" required>
                                                </div>
                                            </div>
                                            <div class="col-lg-6 col-sm-12">
                                                <div class="form-group">
                                                    <label for="exampleInputtitle">Discription</label>
                                              
                                                    <textarea name="discription" placeholder="Enter your discription here..." class="form-control" id="" rows="1"></textarea>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-lg-5 col-sm-12">
                                                <div class="form-group">
                                                    <label for="exampleInputtitle">Quantity</label>

                                                    <input type="text" class="form-control" id="exampleInputName"
                                                        placeholder="Quantity" name="qty"
                                                        oninput="this.value = this.value.replace(/[^0-9]/g, '');">
                                                </div>
                                            </div>
                                            <div class="col-lg-6 col-sm-12">
                                                <div class="form-group">
                                                    <label for="exampleInputtitle">Amount</label>
                                                    <input type="text" class="form-control" id="exampleInputName"
                                                        placeholder="Amount" name="amount"
                                                        oninput="this.value = this.value.replace(/[^0-9]/g, '');">
                                                </div>
                                            </div>

                                            <div class="col-sm-12 col-lg-1" style="margin-top: 23px;">
                                                <button class="btn  mt-2 text-white fw-bold"
                                                    style="background: #343a40;">Submit</button>
                                            </div>
                                        </div>

                                    </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 Expenses</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>
                                                            <tr>
                                                                <th>Sr No.</th>
                                                                <th>Discription</th>
                                                                <th>Date &amp; Time</th>
                                                                <th>Amount</th>
                                                                <th>Quantity</th>
                                                                <th>Title</th>
                                                            </tr>
                                                            </tr>
                                                        </thead>
                                                        <tbody>
                                                            <tr>
                                                                <?php
                                                                include('connection.php');
                                                                $sql = "SELECT * FROM expenses";
                                                                $query = mysqli_query($conn, $sql);
                                                                while ($row = mysqli_fetch_assoc($query)) {
                                                                ?>
                                                                <td><?php echo $row['id']?></td>
                                                                <td><?php echo $row['discription']?></td>
                                                                <td><?php echo $row['datetime']?></td>
                                                                <td><?php echo $row['amount']?></td>
                                                                <td><?php echo $row['quantity']?></td>
                                                                <td><?php echo $row['title']?></td>
                                                            </tr>
                                                            <?php }?>
                                                        </tbody>

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

                                    </div>
                                </div>
                                <!-- /.card-body -->
                            </div>

                        </div>
                        <!-- /.col -->
                    </div>

                </div>

            </section>



            <!-- /.content -->
        </div>
        <!-- /.content-wrapper -->
        <?php include("footer.php")?>

        <!-- Control Sidebar -->
        <aside class="control-sidebar control-sidebar-dark">
            <!-- Control sidebar content goes here -->
        </aside>
        <!-- /.control-sidebar -->
    </div>
    <!-- ./wrapper -->
    <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 src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.2/sweetalert.min.js"></script>
    <script>
    $(document).ready(function() {
        <?php if (isset($_GET['error'])) { ?>
        Swal.fire({
            title: 'Error',
            text: '<?php echo $_GET['error']; ?>',
            icon: 'error',
            confirmButtonText: 'OK',
            confirmButtonClass: 'btn btn-success btn-lg',
        });
        <?php } ?>
        <?php if (isset($_GET['success'])) { ?>
        Swal.fire({
            title: 'Success',
            text: '<?php echo $_GET['success']; ?>',
            icon: 'success',
            confirmButtonText: 'OK',
            confirmButtonClass: 'btn btn-success btn-lg',
        });
        <?php } ?>
    });
    </script>
    <script>
    // Use noConflict to avoid conflicts with other scripts
    var $j = jQuery.noConflict();
    $j(document).ready(function() {
        $j('#example2').DataTable();
    });
    </script>
    <?php include("footerlink.php")?>
</body>

</html>