<?php
if(!isset( $_GET["pro_name"])){
	header("Location: https://itmecom.com"); 
	exit();
}

include("header.php");
	$HOST_NAME = "localhost";
		$DB_NAME = "itmecom";
		$CHAR_SET = "charset=utf8";
		$USERNAME = "admin_itmecom";
		$PASSWORD = "eB254w%4g";

$connect = null;

try {
    $connect = new PDO('mysql:host='.$HOST_NAME.';dbname='.$DB_NAME.';'.$CHAR_SET,$USERNAME,$PASSWORD);
    //session_start();
} catch (PDOException $e) {
    echo 'Connection failed: ' . $e->getMessage();
}


$query = "select * from content";
$statement = $connect->prepare($query);
$statement->execute();
$result_content = $statement->fetchAll();

$product = new Products();
$pro_name = $_GET["pro_name"];


$products = $product->getProductListName($pro_name);

?>
          <!-- Content wrapper -->
          <div class="content-wrapper" id="main-Content">
          		<div class="container-xxl flex-grow-1 container-p-y">
				<?php
					if($pro_name != ""){
						?>
						<h4 class="fw-bold py-3 mb-4"><span class="fw-light"></span><span class=" fw-light"> <?=$pro_name?> </span> </h4>
						<?php
					}
				?>

				<div class="row mb-5">
					<?php
					foreach ($products as $key => $value) {
						?>
							<div class="col-md-12 col-lg-12 div-product">
							  <div class="card">
								  <div class="card-body">
								  <div class="row">
									  <div class="col-lg-6 col-md-12">
										  <img class="card-img-top" src="<?=$value->product_img?>" onerror="this.src='https://via.placeholder.com/150/'">
									  </div>
									  <div class="col-lg-6 col-md-12">
										  	 <h6 class="card-title"><?=str_replace("Out of stock HQ",'',$value->product_name)?></h6>
								  				<p class="card-text"><?=$value->product_desc?></p>
										  	<ul class="list-group list-group-flush">
											  <li class="list-group-item">
												<font color="#157bed"><?=number_format($value->product_price_srp)?> MMK</font> 
												<font color="red" style="float: right"><?=$value->product_warranty?>
												</font>
											  </li>

											</ul>
										  <div style="font-size: 1.2rem;width: 100%;display: flex;flex-direction: row;justify-content: space-around;
				align-items: cente" onclick="add_cart('<?=$value->id?>','<?=$value->product_code?>','<?=$value->product_name?>','<?=$value->product_desc?>','<?=$value->product_price_srp?>','<?=$value->product_img?>','<?=$value->product_warranty?>')" class="btn btn-primary"><i style="font-size: 2rem;" class="bx bx-cart"></i><?=number_format($value->product_price_srp)?> MMK</button>
								</div>
									  </div>
								  </div>
								</div>
							</div>
						<?php
					}
					?>	
				</div>
			</div>
          	</div>
          <?php
          if(($count_carts) > 0){
				?>
					<div class="buy-now">
					  
					  <div id="div-cart-stick" style="" class="btn-buy-now">
					  	
					  </div>
					  
					</div>
				<?php
		  }

include("footer.php");
?>
