<?php
session_start();
include("connection.php");
 

 include('header.php');
 
 if(isset($_GET['mid']) && $_GET['mid'] !=''){
  $mid = $conn->real_escape_string($_GET['mid']);
  $delete_status =  "DELETE FROM package1 WHERE id = '$mid'";
  if(mysqli_query($conn,$delete_status)){
    echo "<script>
    alert('Plan Deleted Successfully!');
    window.location.href='plans.php';
    </script>
    ";
  }
}
 ?>

        <!-- Page Content Start -->
        <div class="content-page">
            <a class="btn btn-primary" href="addpackages.php">Add Investment plans</a>
            <div class="content">
                 <div class="container-fluid">
    	            <div class="row">
                
                <br>
                <?php 
                    $sql = "SELECT * FROM package1";
                    $result = mysqli_query($conn,$sql);
                    if(mysqli_num_rows($result) > 0){
                        while($row = mysqli_fetch_assoc($result)){  
                        $row['pname'];
                ?>
                            <div class="col-xl-4 col-lg-6 col-sm-6">
                                <div class="card">
                                    <div class="card-body">
                                        <div class="new-arrival-product">
                                            <form method="POST" action="">
                                                <div class="new-arrival-content text-center mt-0">
                                                    
                                                    <input type="hidden" name="pname" value="<?php echo $row['pname'];?>">
                                                    <h3 class="mb-4"><?php echo $row['pname'] ?></h3>
                                                    <h4>Increase - <?php echo $row['increase']?>%</h4>
                                                
                                                    <p><i class="pe-7s-play"></i> Plan Minimum Amount - <b>$<?php echo $row['min_amt'];?></b></p>
                                                <p><i class="pe-7s-play"></i> Plan maximum Amount - <b>$<?php echo $row['max_amt'];?></b></p>
                                                    <p><i class="pe-7s-play"></i> Duration - <?php echo $row['duration'];?> Day(s)</p>
                                                    
                                                    <a href="addpackages.php?id=<?php echo $row['id'];?>"  class="btn btn-success" style="margin-bottom: 2px;">Update</a>

                                                    <a href="plans.php?mid=<?php echo $row['id'];?>"  class="btn btn-danger" onclick="return confirm('Do you really want to delete this package');">Delete</a>
                                                </div>
                                            </form>
                                        </div>
                                    </div>
                                </div>
                            </div>

                <?php }} ?>
                        </div>
                    </div>



                </div> <!-- end container-fluid-->
            </div> <!-- end contant-->
        </div>
        <!-- End Page Content-->
     


                <!-- Footer Start -->
                <footer class="footer">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-md-12 text-center">
                                  <script>document.write(new Date().getFullYear())</script> ©  <?=$sitename?>
                            </div>
                        </div>
                    </div>
                </footer>
                <!-- end Footer -->

            </div>

            <!-- ============================================================== -->
            <!-- End Page content -->
            <!-- ============================================================== -->


        </div>
        <!-- END wrapper -->

       

        <!-- Right bar overlay-->
        <div class="rightbar-overlay"></div>

        <!-- Vendor js -->
        <script src="assets/js/vendor.min.js"></script>

        <!-- datatable js -->
        <script src="assets/libs/datatables/jquery.dataTables.min.js"></script>
        <script src="assets/libs/datatables/dataTables.bootstrap4.min.js"></script>
        <script src="assets/libs/datatables/dataTables.responsive.min.js"></script>
        <script src="assets/libs/datatables/responsive.bootstrap4.min.js"></script>
        
        <script src="assets/libs/datatables/dataTables.buttons.min.js"></script>
        <script src="assets/libs/datatables/buttons.bootstrap4.min.js"></script>
        <script src="assets/libs/datatables/buttons.html5.min.js"></script>
        <script src="assets/libs/datatables/buttons.flash.min.js"></script>
        <script src="assets/libs/datatables/buttons.print.min.js"></script>

        <script src="assets/libs/datatables/dataTables.keyTable.min.js"></script>
        <script src="assets/libs/datatables/dataTables.select.min.js"></script>

        <!-- Datatables init -->
        <script src="assets/js/pages/datatables.init.js"></script>

        <!-- App js -->
        <script src="assets/js/app.min.js"></script>
        
    </body>
</html>