<?php session_start();
   include("./../config/config.php");  
   include("./backend/validated_admin.php");
   $sql_blog_id = "SELECT * FROM blog_category_add";
   $myquery_blog_id=$conn->query($sql_blog_id);
   $mydara_blog_id =$myquery_blog_id->fetchAll();
   $row_found_blog_id = $myquery_blog_id->rowCount();
   $no_of_records_per_page = 12;
   if (isset($_GET['page']) && is_numeric($_GET['page'])) {
       $page = intval($_GET['page']);
   } else {
       $page = 1;
   }
   
   $start_from = ($page - 1) * $no_of_records_per_page;
   $total_pages_sql = "SELECT COUNT(*) FROM blog_category_add";
   $result = $conn->query($total_pages_sql);
  
   $total_rows = $result->fetchAll();
   $row_found = $result->rowCount();
   //  var_dump($row_found_blog_id);
   //  die;
   $total_pages = ceil($row_found_blog_id / $no_of_records_per_page);
   
   $stmt = $conn->prepare("SELECT * FROM blog_category_add ORDER BY s_no ASC LIMIT $start_from, $no_of_records_per_page");
   $stmt->execute();
   $users = $stmt->fetchAll();
   // var_dump($users);
   // die;
   ?>
<!DOCTYPE html>
<html lang="en">
   <head>
      <meta charset="UTF-8">
      <title>Blog Details - iCouponWorld | Coupons | Discounts| Promo Codes<</title>
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <link id="favicon" rel="icon" type="image/x-icon" href="../images/web-images/home/favicon.png">
      <meta name="robots" content="index, follow" />
      <meta name="author" content="Design Collection">
      <meta name="description" content="With Edit Delete Master you can edit and delete pages">
      <meta name="keywords" content="Edit, Delete,Edit Delete Master">
      <link rel="canonical" href="blog-details.php"/>
      <!-- Viewport configuration, scaling options -->
      <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
      <!-- Bootstrap CSS -->
      <link href="../css/icouponworld.css" rel="stylesheet">
      <!-- CSS Stylesheet -->
      <link href="../css/dashboard.css" rel="stylesheet">
      <!-- Font Awesome icon -->
      <link href="../fontawesome/css/fontawesome.css" rel="stylesheet" />
      <!-- Roboto font  -->
      <link rel="preconnect" href="https://fonts.googleapis.com">
      <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
      <link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;1,100;1,300;1,400;1,500;1,700&display=swap" rel="stylesheet">
      <!-- sweetalert.min.js Begin  -->
      <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
     <!-- sweetalert.min.js End  -->
      <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
      <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
      <![endif]-->
   </head>
   <body>
      <!--unique id begin -->
      <div id="s_mm">
         <!--scroll-top Begin-->
         <div id="scroll-top">
            <!--sidebarwrapper Begin-->
            <div id="sidebarwrapper">
               <!--Sidebarmenu Begin-->
               <?php include("./includefiles/sidebar.php"); ?>
               <!--Sidebarmenu End-->
               <!--content-wrapper Begin-->
               <div id="content-wrapper" class="d-flex flex-column dashboard-navbar">
                  <div id="maincontent">
                     <!-- Navbar Topbar Begin-->
                     <?php include("./includefiles/header.php"); ?>
                     <!-- Navbar Topbar End-->
                     <!-- Container Begin-->
                     <div class="container-fluid px-4">
                        <div class="d-sm-flex align-items-center justify-content-between mb-4">
                           <h3>
                              Blog Details Webpages
                           </h3>
                        </div>
                        <?php include("./includefiles/coupon_count.php"); ?>
                        <div class="row">
                           <div class="col-md-12">
                              <div class="mb-5">
                                 <!--Alert Message Begin-->
                                 <div class="alert alert-primary fs-14 mt-2" role="alert">
                                    <strong>Important message:</strong>  You can edit and delete your blog page very easily. 
                                 </div>
                                 <!--Alert Message End-->
                                 <?php 
                                     if($_SESSION['delete-blog'] !=""){?>
                                        <div class="alert alert-success" role="alert">
                                       Your Blog Delete successfully!
                                     </div>
                                     <?php
                                     }
                                     unset($_SESSION['delete-blog']);
                                  ?>
                              </div>
                           </div>
                        </div>
                        <div class="row">
                           <!-- Blog -->
                           <?php
                              if($row_found_blog_id>0){
                                 foreach($mydara_blog_id as $row_form){
                                   $metatitles = $row_form['metatitle'];
                                   $metadesc = $row_form['metadesc'];
                                    $metakey = $row_form['metakey'];     
                                    $images = $row_form['blog_image']; 
                                    $editor = $row_form['editor1']; 
                                    $blog_title = $row_form['blogtitle']; 
                                    $dates = strtotime($row_form['datecreated']); 
                                    $categorys = $row_form['category'];
                                    $ids = $row_form['idcodes'];
                           ?>
                           <div class="col-xl-3 col-lg-3 col-md-3 col-sm-12 mb-4">
                              <div class="card border-0 shadow br-4 mini-stats-wid">
                                 <img src="./backend/<?=$images?>" class="img-fluid card-img-top" alt="blog" title="blog">
                                 <div class="card-body">
                                    <h6 class="card-title text-truncate fw-bold mb-2">
                                     <?=$blog_title?>
                                    </h6>
                                    <p class="text-truncate"><?=$metadesc?></p>
                                    <div class="post-admin mb-3">
                                       <span> <img alt="user" tittle="user" src="./backend/<?=$profile_pic?>" class="img-fluid rounded-circle" width="22">  <?=$full_name?> </span> 
                                       <span><?php echo date("M d, y", $dates);?> </span>
                                    </div>
                                    <div class="card-footer border-0">
                                       <div class="row d-flex align-items-center">
                                          <div class="col-5">
                                             <p class="text-primary"><?=$categorys?></p>
                                          </div>
                                          <div class="col-7">
                                             <ul class="list-unstyled d-flex m-0 align-items-center justify-content-end">
                                                <li class="me-3  align-items-center d-flex">
                                                   <a href="./edit-post.php?id=<?=$ids?>"  class="btn btn-primary px-2 py-1 btn-sm"><i class="fas fa-edit" data-bs-toggle="tooltip" title="Edit"></i></a>
                                                </li>
                                                <li class="me-3 align-items-center d-flex">
                                                   <a href="./backend/delete_blog.php?id=<?=$ids?>"   class="btn btn-danger px-2 py-1 btn-sm"><i class="fas fa-trash-alt" data-bs-toggle="tooltip" title="Delete"></i></a>
                                                </li>
                                             </ul>
                                          </div>
                                       </div>
                                    </div>
                                 </div>
                              </div>
                           </div>
                           <!-- Blog -->
                        
                           <!-- Update Modal Begin -->
                           <div class="modal fade" id="updatemodel" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="updatemodelLabel" aria-hidden="true">
                              <div class="modal-dialog">
                                 <div class="modal-content">
                                    <div class="modal-header">
                                       <h5 class="modal-title" id="updatemodelLabel">Edit Post</h5>
                                       <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                                    </div>
                                    <div class="modal-body">
                                       <p>Are you sure! you want to edit this post?</p>
                                    </div>
                                    <div class="modal-footer bg-white">
                                       <a href="./edit-post.php?id=<?=$ids?>" class="btn btn-primary">Yes</a>
                                       <a class="btn btn-secondary" data-bs-dismiss="modal">No</a>
                                    </div>
                                 </div>
                              </div>
                           </div>
                           <!-- Update Modal End -->
                           <!-- Delete Modal Begin -->
                           <div class="modal fade" id="deletemodel" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="deletemodelLabel" aria-hidden="true">
                              <div class="modal-dialog">
                                 <div class="modal-content">
                                    <div class="modal-header">
                                       <h5 class="modal-title" id="deletemodelLabel">Delete post</h5>
                                       <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                                    </div>
                                    <div class="modal-body">
                                       <p>Are you sure! you want to delete this post?</p>
                                    </div>
                                    <div class="modal-footer bg-white">
                                       <a href="./backend/delete_blog.php?id=<?=$ids?>" class="btn btn-primary">Yes</a>
                                       <a class="btn btn-secondary" data-bs-dismiss="modal">No</a>
                                    </div>
                                 </div>
                              </div>
                           </div>
                           <!-- Delete Modal End -->
                           <?php }  }?>
                           <div class="col-md-12">
                              <!--Navbar Begin-->
            <nav>
               <ul class="pagination justify-content-center">
                  <li class="page-item <?php if($page <= 1){ echo 'disabled'; } ?>">
                     <a class="page-link" href="?page=<?php echo $page - 1; ?>">Previous</a>
                  </li>
                  <?php for($i=1; $i<=$total_pages; $i++): ?>
                  <li class="page-item <?php if($page == $i){ echo 'active'; } ?>">
                     <a class="page-link" href="?page=<?php echo $i; ?>"><?php echo $i; ?></a>
                  </li>
                  <?php endfor; ?>
                  <li class="page-item <?php if($page >= $total_pages){ echo 'disabled'; } ?>">
                     <a class="page-link" href="?page=<?php echo $page + 1; ?>">Next</a>
                  </li>
               </ul>
            </nav>
            <!--Navbar End--
                           </div>
                        </div>
                     </div>
                     <!-- Container End-->
                  </div>
                  <!--Copyright Begin-->
                  <div class="p-4 border bg-white">
                     <div class="container">
                        <div class="row align-items-center">
                           <div class="col-lg-12 col-sm-12">
                              <p class="small text-center p-0 m-0">© 2022. All Rights Reserved. Proudly Designed By icoupon world Team. </p>
                           </div>
                        </div>
                     </div>
                  </div>
                  <!--Copyright End-->
               </div>
               <!--content-wrapper End-->
            </div>
            <!--sidebarwrapper End-->
            <!--Scroll to top Begin-->
            <a class="scroll-to-top rounded" href="#scroll-top">
            <i class="fas fa-angle-up"></i>
            </a>
            <!--Scroll to top End-->
            <!-- Jquery Script Begin-->
            <script src="../js/jquery-3.4.1.min.js"></script>
             <!-- Jquery Script End-->
            <!-- Bootstrap Script Begin-->
            <script src="../js/bootstrap.bundle.min.js"></script>
            <!-- Bootstrap Script end-->
            <!-- dashboard-icouponworld.js  Begin-->
            <script src="../js/dashboard-icouponworld.js"></script>
            <!-- dashboard-icouponworld.js  End-->
            <!-- Tooltips Script Begin-->
            <script>
               var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
               var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
                 return new bootstrap.Tooltip(tooltipTriggerEl)
               })
            </script>
             <!-- Tooltips Script End-->
         </div>
         <!--scroll-top End-->
      </div>
      <!--unique id End -->
   </body>
</html>