if (!hasPermission($logged, 'access', 'product_form')) { header('Location:permission.html'); } if (isset($_GET['product_id'])) { $product_id = $_GET['product_id']; } if (isset($logged) && $_SERVER['REQUEST_METHOD'] != 'POST') { $data = array('product_id' => $product_id); $image_info = getProductImage($data); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { $product_id = $_POST['product_id']; $image = $_POST['file_image']; if (empty($error)) { $edit_data = array('product_id' => $product_id, 'image' => $image); $edit_query = updateProductImage($edit_data); if ($edit_query) { $_SESSION['success'] = $lang['success_edit']; } else { $_SESSION['error_warning'] = $lang['error_query']; } header('Location:product.html'); } } ?> <div id="content"> <div class="breadcrumb"> <a href="home.html"><?php echo $lang['text_home']; ?>
<?php chdir("../../database"); require_once "store_backoffice.php"; if (isset($_GET["storeId"]) and isset($_GET["name"]) and strlen($_GET["name"]) > 0 and isset($_GET["productId"]) and strlen($_GET["productId"]) > 0 and isset($_GET["description"]) and strlen($_GET["description"]) > 0 and isset($_GET["cost"]) and strlen($_GET["cost"]) > 0 and isset($_GET["category"]) and strlen($_GET["category"]) > 0 and isset($_GET["stock"]) and strlen($_GET["stock"]) > 0) { $categoryId = checkCategory($_GET["category"], $_GET["storeId"]); $categoryId = $categoryId[0]["id"]; if (isset($categoryId)) { updateProduct($_GET["productId"], $_GET["name"], $_GET["description"], $_GET["cost"], $_GET["stock"], $categoryId); if (isset($_GET['image']) and strlen($_GET['image']) > 0) { $imageId = addProductImage($_GET['image']); updateProductImage($_GET["productId"], $imageId); } echo json_encode(array("result" => "ok")); } else { echo json_encode(array("result" => "category doest exists")); } } else { echo json_encode(array("result" => "missingParams")); }