���� JFIF �� � ( %"1"%)+...383,7(-.-
![]() Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.20 System : Linux st2.domain.com 3.10.0-1127.10.1.el7.x86_64 #1 SMP Wed Jun 3 14:28:03 UTC 2020 x86_64 User : apache ( 48) PHP Version : 7.4.20 Disable Function : NONE Directory : /proc/self/root/var/www/html/tien-dien/code/product/ |
<?php global $DB,$INFO,$print; $type='list'; if(isset($CORE->input['type']) && $CORE->input['type']!=''){ $type=$CORE->input['type']; } // If type is detail, include the detail page and exit if($type == 'detail') { include 'detail.php'; } $q_block = $DB->query("SELECT a.* FROM tb_block a LEFT JOIN tb_block_page b ON a.block_id=b.block_id WHERE b.menus_id=1 ORDER BY a.block_pos ASC, a.block_id ASC"); $txt_list = ''; while ($r_block = $DB->fetch_row($q_block)){ $arr_block['id'] = $r_block['block_id']; $arr_block['name'] = $r_block['block_title']; if($r_block['block_type']==1){ $arr_block['content'] = htmlspecialchars_decode(html_entity_decode($r_block['block_detail'])); }else{ $arr_block['content'] = ''; } $list_block[] = $arr_block; } // Get categories $query_categories = $DB->query("SELECT * FROM tb_product_categories WHERE category_status=0 ORDER BY category_pos ASC"); $categories = array(); while ($row_category = $DB->fetch_row($query_categories)) { $categories[] = $row_category; } // Function to build category tree function buildCategoryTree($categories, $parent_id = 0, $current_category = 0) { $html = ''; foreach ($categories as $category) { if ($category['category_parentid'] == $parent_id) { $active = ($category['category_id'] == $current_category) ? 'active' : ''; $html .= '<li class="list-group-item '.$active.'"> <a href="?act=product&category='.$category['category_id'].'">'.$category['category_name'].'</a>'; // Check for children $has_children = false; foreach ($categories as $child) { if ($child['category_parentid'] == $category['category_id']) { $has_children = true; break; } } if ($has_children) { $html .= '<ul class="list-group mt-2">'; $html .= buildCategoryTree($categories, $category['category_id'], $current_category); $html .= '</ul>'; } $html .= '</li>'; } } return $html; } // Get products $pageNum = isset($_GET['pageNum']) ? intval($_GET['pageNum']) : 1; $pageSize = 12; $from = (($pageNum * $pageSize) - $pageSize); $where = " AND status=0 "; $param_search = ''; $current_category = 0; if(isset($CORE->input['category']) && $CORE->input['category'] > 0) { $current_category = intval($CORE->input['category']); $where .= " AND id IN (SELECT product_id FROM tb_product_category WHERE category_id='".$current_category."') "; $param_search .= 'category='.$current_category.'&'; // Get category info for title $query_cat_info = $DB->query("SELECT * FROM tb_product_categories WHERE category_id='$current_category'"); $category_info = $DB->fetch_row($query_cat_info); } $t = $DB->fetch_row($DB->query("SELECT count(*) as total FROM tb_product WHERE 1 ".$where)); $total = $t['total']; $totalPage = ceil($total / $pageSize); $query = $DB->query("SELECT * FROM tb_product WHERE 1 ".$where." ORDER BY `pos` ASC, `noibat` DESC, status ASC LIMIT $from, $pageSize"); $products = array(); while ($row = $DB->fetch_row($query)){ $products[] = $row; } $CORE->title_page = 'Sản phẩm | '; include 'layout/'.$INFO['path_skin'].'/header.php'; include 'layout/'.$INFO['path_skin'].'/menu.php'; ?> <?php include 'layout/'.$INFO['path_skin'].'/banner.php'; ?> <div class="container mt-4 mb-4"> <div class="row"> <div class="col-md-12"> <h1 class="page-title"> <?php if(isset($category_info)): ?> <?php echo $category_info['category_name']; ?> <?php else: ?> Sản phẩm <?php endif; ?> </h1> </div> </div> <div class="row"> <!-- Category Sidebar --> <div class="col-md-3"> <div class="card mb-4"> <div class="card-header"> <h5 class="mb-0">Danh mục sản phẩm</h5> </div> <div class="card-body p-0"> <ul class="list-group list-group-flush"> <li class="list-group-item <?php echo ($current_category == 0) ? 'active' : ''; ?>"> <a href="?act=product">Tất cả sản phẩm</a> </li> <?php echo buildCategoryTree($categories, 0, $current_category); ?> </ul> </div> </div> </div> <!-- Product List --> <div class="col-md-9"> <div class="row"> <?php if(!empty($products)): ?> <?php foreach($products as $product): ?> <div class="col-md-4 mb-4"> <div class="card h-100"> <?php if($product['path_img']): ?> <img src="<?php echo $product['path_img']; ?>" class="card-img-top" alt="<?php echo $product['title']; ?>"> <?php endif; ?> <div class="card-body"> <h5 class="card-title"><?php echo $product['title']; ?></h5> <p class="card-text"><?php echo $product['intro']; ?></p> <?php if(hasActiveDiscount($product)): ?> <p class="card-text text-danger font-weight-bold"><?php echo number_format(getDiscountedPrice($product)); ?> VNĐ</p> <p class="card-text"><small class="text-muted"><del><?php echo number_format($product['price']); ?> VNĐ</del></small></p> <p class="badge badge-success">Giảm giá <?php echo number_format($product['discount_amount']); ?> VNĐ</p> <?php else: ?> <p class="card-text text-danger font-weight-bold"><?php echo number_format($product['price']); ?> VNĐ</p> <?php endif; ?> <a href="?act=product&type=detail&id=<?php echo $product['id']; ?>" class="btn btn-primary">Chi tiết</a> <?php if($product['price'] > 0): ?> <div class="mt-2"> <a href="?act=cart&action=add&id=<?php echo $product['id']; ?>" class="btn btn-outline-secondary btn-sm">Thêm vào giỏ hàng</a> <a href="?act=checkout&action=buy_now&id=<?php echo $product['id']; ?>" class="btn btn-success btn-sm">Mua ngay</a> </div> <?php else: ?> <div class="mt-2"> <a href="?act=contact&product_id=<?php echo $product['id']; ?>" class="btn btn-info btn-sm">Liên hệ</a> </div> <?php endif; ?> </div> </div> </div> <?php endforeach; ?> <?php else: ?> <div class="col-md-12"> <p>Không có sản phẩm nào.</p> </div> <?php endif; ?> </div> <?php if($totalPage > 1): ?> <div class="row"> <div class="col-md-12"> <nav aria-label="Page navigation"> <ul class="pagination justify-content-center"> <?php echo $print->Pagination($totalPage,$pageNum,'pages','?act=product&'.$param_search); ?> </ul> </nav> </div> </div> <?php endif; ?> </div> </div> </div> <?php include 'layout/'.$INFO['path_skin'].'/footer.php'; ?>