<?php
ob_start();

if (!session_start()) {
    session_start();
}

unset($_SESSION['bookid']);
?>

<!--Global Header Starts -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="description" content="" />
<meta name="author" content="" />
<title>Monsoon Vibes - Book Market Place</title>
<!-- Google monseratt 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=Montserrat:wght@200;300;400;500;600;700&display=swap" rel="stylesheet">
<!-- Favicon-->
<link rel="icon" type="image/x-icon" href="assets/favicon.ico" />
<!-- Bootstrap icons-->
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css" rel="stylesheet" />
<!-- Core theme CSS (includes Bootstrap)-->
<link href="css/layout.css" rel="stylesheet" />
<link href="css/styles.css" rel="stylesheet" />
</head>
<body>
<header>
  <div class="container">
    <div class="row">
      <div class="col-md-12">
        <nav class="navbar navbar-expand-lg navbar-light navigation"> <a class="navbar-brand" href="index.php"> <img src="assets/image/monsoon_vibes.png" alt="Monsoon Vibes" class="img-fluid"> </a>
          <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button>
          <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <ul class="navbar-nav m-auto main-nav ">
              <li class="nav-item"><a class="nav-link active" aria-current="page" href="index.php">Home</a></li>
               
              <li class="nav-item"><a class="nav-link" href="authors.php">Reviews</a></li>
              <form class="d-flex" action="cart.php" method="post">
          <button class="btn btn border-0 cart-btn" type="submit"> <i class="bi-cart me-1 d-block"></i> <span class="cart-text">Cart</span> </button>
        </form>
            </ul>
            <ul class="navbar-nav me-end">
             <?php
                                if ($_SESSION['CustId'] > 0) {
                                    ?>
							     <a class="nav-link login-btn" href="login/logout.php">Logout</a> 
							     <?php
                                } else {
                                    ?>
							     <a class="nav-link login-btn" href="login/login.php">Login</a> 
							     <?php
                                }
?>
            </ul>
          </div>
        </nav>
      </div>
    </div>
    <div class="row">
      <div class="search-bar d-flex justify-content-center m-auto">
        <div class="input-group mb-2">
          </div>
        
      </div>
    </div>
  </div>
</header>
<!-- Global Header Ends --> 


<!-- Inside Body Starts-->

<?php

    $insert_id = $_GET['insert_id'];

$visible = $_GET['vis'];


try {
    $db = new PDO('mysql:host=localhost;dbname=gdhhsxmy_monsoonvibespublica;charset=utf8', 'gdhhsxmy_monsoonvibespublica', 'monsoonvibespublica');
} catch (Exception $e) {
    echo 'Error has Occured';
}


$stmt = $db->query("SELECT product.*,category.title catname,author.title authname,author.description authdescription,author.image authimg FROM product
	inner join author on author.id=product.authorid
	inner join category on category.id=product.catid
	where product.id=$insert_id ");


while ($row = $stmt->fetch()) {
    if ($row['paid_delivery'] == 'no') {
        $delivery = 'Free Delivery';
    } else {
        $delivery = 'Paid Delivery';
    }
    $bookid             = $row['id'];
    $qun                = 1;
    $_SESSION['bookid'] = $bookid;



    ?>

        
        
        <section class="pt-5">
	        <!-- Buy Book -->
            <div class="container px-4 px-lg-5 my-5">
                <div class="row gx-4 gx-lg-5 align-items-center">
                    <div class="col-md-4 d-flex justify-content-center"><img class="card-img-top mb-5 mb-md-0 book-cover" src="../pic/book/<?php echo $row['image'] ?>" alt="..."></div>
                    <div class="col-md-8">
                        <h1 class="fw-bolder book-title"><?php echo $row['title'] ?> </h1>
                        <div class="mb-2 fs-5">
                           By: <span class="text-uppercase text-theme auth-name"><?php echo $row['authname'] ?></span>
                            <hr>
                        </div>
                        <div class="row">
							<div class="col-md-6">
								<div class="det-col">
									Category: <span class="fw-semibold category"><?php echo $row['catname'] ?></span>
								</div>
								<div class="det-col">
									Publishing Date: <span class="fw-semibold pub-date"><?php echo  date('d-m-Y', strtotime($row['publishing_date'])); ?></span>
								</div>
								<div class="det-col">
									Edition: <span class="fw-semibold edition"><?php echo $row['edition'] ?></span>
								</div>
								<div class="det-col">
										Number of pages : <span class="fw-semibold p-numbers"><?php echo $row['no_of_pages'] ?></span>
								</div>
								<div class="det-col">
										Language: <span class="fw-semibold b-language"><?php echo $row['language'] ?></span>
								</div>
								
							</div>
							<div class="col-md-6 d-flex align-items-end">
								<div class="price-col">
									<div class="book-price">
										<div class="d-flex flex-row align-items-center">
										  <div class="offer-price"><span class="inr">₹</span><?php echo $row['price'] ?></div>
										  
										</div>
									  </div>
									
								</div>
							</div>
							<?php
                                if ($visible != 1) {
                                    ?>
							
							<div class="col-md-12 mt-4">
								<div class="d-flex">
								    
								    <?php
                                        if ($_SESSION['CustId'] > 0) {
                                            ?>
								    
                            <button class="btn btn-outline-dark rounded-pill px-4 me-3 btn-addtocart" type="button" onclick="window.location='<?php
               echo 'buynow.php?insert_id=' . $bookid . '&qun=' . $qun ;  ?>' ">
						
                                <i class="bi-cart-fill me-1"></i>
                                Add to Cart
                            </button>
                             <?php
                                        }
                                    ?>
							<button class="btn btn-primary rounded-pill px-4 btn-buynow" type="button" onclick="window.location='<?php
               echo 'buynow.php?insert_id=' . $bookid . '&qun=' . $qun ;  ?>' ">
						
                                <i class="bi bi-bag me-1"></i>
                                Buy Now
                            </button>		
                        </div>
							</div>
							
						<?php	}
                                ?>
						</div>
                        
                    </div>
                </div>
				

            </div>
		<!-- Buy Book Ends-->
        </section>
        


  
        
        
        
        <section class="book-summary">
  <div class="container">
	   <div class="row">
		      <div class="col-12 px-4 title-band">
				  	  <hr class="mb-5">
        <div class="d-flex justify-content-between mb-3 px-0">
          <div class="cmn-title">
           <h3 class="section-title">Description</h3>
         </div>
        </div>
     </div>
    </div>
    <div class="row">
        
               <p class="in_malayalam"> <?php echo $row['description'] ?> </p></div>
       
    </div>
    
    <div class="container">
	   <div class="row">
		      <div class="col-12 px-4 title-band">
				  	  <hr class="mb-5">
        <div class="d-flex justify-content-between mb-3 px-0">
          <div class="cmn-title">
           <h3 class="section-title">Author</h3>
         </div>
        </div>
     </div>
    </div>
    <div class="row">
        <div class="col-md-4 d-flex justify-content-center"><img class="card-img-top mb-5 mb-md-0 book-cover" src="../pic/author/<?php echo $row['authimg'] ?>" alt="..."></div>
          
              <div class="col-12 p-4 preview-text">
                  <?php //echo $row['authname']?>
                           
                        </div>
               <p class="in_malayalam"> <?php echo $row['authdescription'] ?> </p></div>
       
    </div>
 </div>
</section>




<?php
}
?>
	<section class="review">
	<div class="container">
		<div class="row">
		      <div class="col-12 px-4 title-band">
				  	  <hr class="mb-5">
        <div class="d-flex justify-content-between mb-3 px-0">
          <div class="cmn-title">
            <!--<h3 class="section-title">Write a review</h3>-->
          </div>
        </div>
      </div>
    </div>
		<!--<div class="row score">
			<div class="col-12 px-4">
			<h5 class="fw-semibold">Score</h5>
                                     Product reviews
                                    <div class="d-flex text-warning mb-2 lead">
                                        <div class="bi-star-fill pe-2"></div>
                                        <div class="bi-star-fill pe-2"></div>
                                        <div class="bi-star-fill pe-2"></div>
                                        <div class="bi-star-fill pe-2"></div>
                                        <div class="bi-star pe-2"></div>
                                    </div>
			
			</div> -->
			<div class="px-4 mb-5">
			<form action="#">
			 <!-- <div class="mb-3 my-3">
				<textarea class="form-control mb-4" rows="5" id="comment" name="text"></textarea>
			  </div>-->
			  <div class="d-flex justify-content-center">
                            <a href="index.php"><button class="btn btn-outline-dark rounded-pill px-4 me-3 btn-addtocart" type="button">
                                Cancel
                            </button></a>
						<!--	<button class="btn btn-primary rounded-pill px-4 btn-buynow" type="button">
                               Submit
                            </button>-->		
                        </div>
			</form>
			
			</div>
		
		</div>
		
		</div>
	</section>
<!--cta ends--> 

<!-- Global Footer Section-->
<footer class="footer-new">
    <div class="container">
      <div class="row">
        <div class="footer-new-col">
          
          <img src="assets/image/monsoon_vibes.png" class="img-fluid set-200" alt="logo">
       
          <p class="alt-color mt-2">MONSOONVIBES PUBLICA PRIVATE LIMITED, 33/6466-C, Shanthi Villa, Vappoli Thazham,
            Puliyankode Road,Marikunnu P.O, 673012 - Pin, Kozhikkode .</p>
        </div>
        <div class="footer-new-col res-new-ps-md" >
          <h4>Policies</h4>
          <ul>
            <li><a href="Privacy_Policy.php">Privacy policy</a></li>
              <li><a href="Refundpolicy.php">Refund policy</a></li>
              <li><a href="TermsAndConditions.php">Terms & conditions</a></li>
          </ul>
        </div>
        <div class="footer-new-col">
          <h4>Quick Links</h4>
          <ul>
            <li><a href="about_us.php">About us</a></li>
            
            <!--<li><a href="#">FAQ</a></li>-->
            <li><a href="#">Profile</a></li>
          </ul>
        </div>
        
        <div class="footer-new-col">
          <h4>follow us</h4>
          <div class="social-links">
            <a href="https://www.facebook.com/monsoonvibes/?paipv=0&eav=AfZpBwqPtSXZtMH65SXYth8zMXVn66ngzKdU58PQvx1ZMABzbpEHV9J5qSZ3WcOGdWE&_rdr"><i class="fab fa-facebook-f"></i></a>
            <a href="#"><i class="fab fa-twitter"></i></a>
            <a href="#"><i class="fab fa-instagram"></i></a>
            <a href="#"><i class="fab fa-linkedin-in"></i></a>
            <a href="#"><i class="fab fa-youtube"></i></a>

          </div>
        </div>
      </div>
    </div>
 </footer>
<footer class="py-1 footer">
    <div class="container">
      <p class="m-0 text-center " style="color: gray;">Copyright @ 2024. Workmate infotech Pvt Ltd All rights reserved</p>
    </div>
  </footer>
	<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css">
<!-- Bootstrap core JS--> 
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script> 
<!-- Core theme JS--> 
<script src="js/scripts.js"></script>
</body>
</html>
<!-- Global Footer Section Ends-->
