<?php require_once '../init.php'; $cat_id = $_GET['cat_id']; $query = "SELECT * FROM products WHERE deleted='0' AND product_category=" . $cat_id; $product_list = MySQLSELECT($query); // $smarty = new SmartyEx; $smarty->assign("product_list", $product_list); $smarty->display('admin/products.tpl');
<?php $query = "SELECT * FROM configurations WHERE deleted='0'"; $values = MySQLSELECT($query); // pd($values); foreach ($values as $value) { if (isset($smarty)) { $smarty->assign($value['name'], $value['value']); } }
<?php require_once '../init.php'; $product_id = $_GET['product_id']; $query = "SELECT * FROM products WHERE deleted='0' AND id=" . MySQLQuote($product_id); $product = MySQLSELECT($query); $query = "SELECT * FROM categories WHERE deleted='0'"; $cat_list = MySQLSELECT($query); // $smarty = new SmartyEx; if ($_SERVER['REQUEST_METHOD'] == 'POST') { $product_id = $_POST['product_id']; $product_category = $_POST['product_category']; $product_price = $_POST['product_price']; $product_name = $_POST['product_name']; $product_description = $_POST['product_description']; $basefilename = basename($_FILES['product_image']['name']); if (!empty($basefilename)) { $tmp_upload = UPLOADS . $basefilename; if (move_uploaded_file($_FILES['product_image']['tmp_name'], $tmp_upload)) { ResizeImage($tmp_upload, 800, 600); rename($tmp_upload . '_resized', SYS_IMAGES_PATH . $basefilename); unlink($tmp_upload); } unlink(SYS_IMAGES_PATH . $product['product_image']); MySQLUPDATE('products', array('id' => $product_id), array('product_category' => $product_category, 'product_price' => MySQLQuote($product_price), 'product_name' => MySQLQuote($product_name), 'product_image' => MySQLQuote($basefilename), 'product_description' => MySQLQuote($product_description), 'updated_date' => date('Y-m-d H:i:s'))); } else { MySQLUPDATE('products', array('id' => $product_id), array('product_category' => $product_category, 'product_price' => MySQLQuote($product_price), 'product_name' => MySQLQuote($product_name), 'product_description' => MySQLQuote($product_description), 'updated_date' => date('Y-m-d H:i:s'))); } $_SESSION['flash']['update_product_ok'] = '1'; header('Location: /quanly/product_detail.php?product_id=' . $product_id); exit;
function Load_Fist_Category() { $query = "SELECT id FROM categories WHERE deleted='0' LIMIT 1"; $result = MySQLSELECT($query); return empty($result[0]['id']) ? '' : $result[0]['id']; }
<?php require_once 'init.php'; // $smarty = new SmartyEx; $cat_id = empty($_GET['cat_id']) ? Load_Fist_Category() : $_GET['cat_id']; if (!empty($cat_id)) { $query = 'SELECT * FROM categories WHERE id=' . $cat_id; $select_cat_obj = MySQLSELECT($query); $smarty->assign('select_cat_obj', $select_cat_obj[0]); } require_once 'categories.php'; require_once 'products.php'; $smarty->assign('categories_tree', $categories_tree); $smarty->assign('product_list', $product_list); $smarty->display('index.tpl');
require_once '../init.php'; $cat_id = $_GET['cat_id']; $query = "SELECT * FROM categories WHERE deleted='0' AND id=" . MySQLQuote($cat_id); $cat = MySQLSELECT($query); $query = "SELECT * FROM categories WHERE deleted='0'"; $cat_list = MySQLSELECT($query); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $cat_id = $_POST['cat_id']; if ($_POST['submit'] == 'Lưu thay đổi') { $cat_parent = $_POST['cat_parent']; $cat_name = $_POST['cat_name']; MySQLUPDATE('categories', array('id' => $cat_id), array('category_name' => MySQLQuote($cat_name), 'category_parent' => MySQLQuote($cat_parent), 'updated_date' => date('Y-m-d H:i:s'))); } elseif ($_POST['submit'] == 'Xóa danh mục này') { $subcat = FindSubCategories($cat_id); MySQLUPDATE('categories', array('id' => $subcat), array('deleted' => "1", 'updated_date' => date('Y-m-d H:i:s'))); $query = "SELECT id FROM categories WHERE deleted='0' LIMIT 1"; $cat = MySQLSELECT($query); } $_SESSION['flash']['update_category_ok'] = '1'; header('Location: /quanly/category_detail.php?cat_id=' . $cat[0]['id']); exit; } // $smarty = new SmartyEx; if (isset($_SESSION['flash']['update_category_ok'])) { $smarty->assign('update_category_ok', '1'); unset($_SESSION['flash']['update_category_ok']); } $smarty->assign("cat_id", $cat_id); $smarty->assign("cat", $cat[0]); $smarty->assign("cat_list", $cat_list); $smarty->display('admin/category_detail.tpl');