function editProduct($id) { $product = getProductById($id); if (isset($_POST['ok'])) { if ($_POST['name'] == "") { $error = "Chưa nhập tên sản phẩm"; } else { if ($_POST['price'] == "") { $error = "Chưa nhập giá sản phẩm"; } else { if ($_FILES['img']['name'] != "") { $img_name = "images/" . md5($_FILES['img']['name'] . time()) . ".png"; move_uploaded_file($_FILES["img"]["tmp_name"], $img_name); $product['img'] = $img_name; } $product['name'] = $_POST['name']; $product['price'] = $_POST['price']; $product['info'] = $_POST['info']; updateProduct($product); $error = "Chỉnh sửa thành công"; } } } include "view/product/edit.php"; }
if (isset($_POST["sub_id"])) { $sub_id_insert = $_POST["sub_id"]; } else { $sub_id_insert = NULL; } $data = array('aTitle' => $_POST["title"], 'aPrice' => $_POST["point"], 'delivery' => $_POST["Delivery"], 'aContent' => $_POST["content"], 'showID' => $_POST["showID"], 'menuID' => $_POST["menu_id"], 'subID' => $sub_id_insert); if (!empty($_FILES["fileImage"]['name'])) { $file_path = insertFile($_POST["menu_id"], $sub_id_insert); $data['Image_name'] = $file_path; } if (isset($_POST["prID"])) { $data['prID'] = $_POST["prID"]; if ($sub_id_insert == 'other') { $data['subID'] = NULL; } updateProduct($data); } else { /* var_dump($_POST); echo "<br><br><br><br>"; var_dump($data); */ insertProduct($data); } } } if (isset($_GET["sub_id"])) { $sub_id = $_GET["sub_id"]; } else { $sub_id = null; $subs = getMenuSubs($menu_id);
$product_seo = str_replace(" ", "-", strtolower($product_name)); $smallimage = $_FILES['product_image']; if ($smallimage['name'] == "") { $product_image = $_REQUEST['prev_image']; } else { $product_image = $smallimage['name']; } if (!$smallimage['error']) { if (!@move_uploaded_file($smallimage['tmp_name'], "../products/product_images/" . $smallimage['name'])) { header("location:edit-product.php?err=Unknown Error Occured please try again&id={$product_id}"); exit; } else { $work = new ImgResizer("../products/product_images/" . $smallimage['name']); } } updateProduct($product_id, $product_name, $product_description, $meta_tag_keyword, $product_image, $meta_tag_description, $product_meta_tag_title, rtrim($product_seo, "-")); header("location:products.php"); } else { header("location:edit-product.php?err=Unknown Error Occured please try again&id={$product_id}"); } class ImgResizer { var $originalFile = ''; function ImgResizer($originalFile = '') { $this->originalFile = $originalFile; } function resize($newWidth, $targetFile) { if (empty($newWidth) || empty($targetFile)) { return false;
<?php //stop the direct browsing to this file - let index.php handle which files get displayed checkLogin(); # Deal with op and add some basic sanity checking $op = !empty($_POST['op']) ? addslashes($_POST['op']) : NULL; #insert product $saved = false; if ($op === 'insert_product') { if ($id = insertProduct()) { $saved = true; //saveCustomFieldValues($_POST['categorie'], lastInsertId()); } } if ($op === 'edit_product') { if (isset($_POST['save_product']) && updateProduct()) { $saved = true; //updateCustomFieldValues($_POST['categorie'],$_GET['id']); } } $refresh_total = isset($refresh_total) ? $refresh_total : ' '; $smarty->assign('saved', $saved); //$smarty -> assign('display_block',$display_block); //$smarty -> assign('refresh_total',$refresh_total); $smarty->assign('pageActive', 'product_manage'); $smarty->assign('active_tab', '#product');
$last['product_end_date'] = $date; unset($date); } if (isset($detail) && $detail == 'done') { foreach ($_POST as $key => $data) { if ($key !== 'product_brand') { if ($data == '') { $check = false; break; } else { $check = true; } } } if ($check) { $productResponse = updateProduct($_POST, $db); if (isset($productResponse)) { $_SESSION['last_edit_product'] = $_POST['product_id']; header('Location: /dashboard/edit'); } else { $msg['class'] = 'error'; $msg['msg'] = 'Bearbeitung konnte nicht gespeichert werden!'; } } else { $msg['class'] = 'error'; $msg['msg'] = 'Produkt konnte nicht bearbeitet werden!'; } } $packages = getActivePackages($_SESSION['user_id'], $db); if ($packages) { foreach ($packages as $key => $package) {
addProduct(intval($r)); break; case 'removeProduct': removeProduct(intval($r)); break; case 'addDosage': addDosage(intval($r)); break; case 'removeDosage': removeDosage(intval($r)); break; case 'updateCategory': updateCategory(intval($r), $s); break; case 'updateProduct': updateProduct(intval($r), $s, $t); break; case 'updateDosage': updateDosage(intval($r), $s, $t); break; case 'updateCompound': updateCompound(intval($r), $s, $t); break; case 'uploadPhoto': uploadPhoto(intval($r), $s); break; default: return false; break; } ?>
$product = filter_input(INPUT_POST, 'product'); $price = filter_input(INPUT_POST, 'price'); $errors = array(); if (!isValidProduct($product)) { $errors[] = 'Product is not Valid'; } if (!isValidPrice($price)) { $errors[] = 'Price is not Valid'; } if (count($errors) == 0) { $image = uploadProductImage(); if (empty($image)) { $image = filter_input(INPUT_POST, 'old_image'); $errors[] = 'Existing image retained'; } if (updateProduct($existingProductID, $category_id, $product, $price, $image)) { $results = 'Product Updated'; $isUpdated = true; } else { $results = 'Product was not Updated'; } } } ?> <?php include '../../includes/results.html.php'; ?> <?php if (!isset($isUpdated)) {
function updateProductPhoto($prodNo, $prodPhoto) { //delete the old photo from the server (do not do this part yet) updateProduct($prodNo, null, null, $prodPhoto, null, null, null); }
<?php include "db_facade.php"; $postdata = file_get_contents("php://input"); $request = json_decode($postdata, true); if ($_SERVER['REQUEST_METHOD'] === 'POST') { if (array_key_exists('id', $request) && array_key_exists('name', $request) && array_key_exists('description', $request) && array_key_exists('price', $request) && array_key_exists('url', $request)) { $updateResult = updateProduct($request['id'], $request['name'], $request['description'], $request['price'], $request['url']); if ($updateResult == false) { failWithError('Data update failed', '500 Internal Server Error'); } } else { failWithError('Invalid input data', '400 Bad Request'); } }
$fname = $_REQUEST['fname']; $fcateg = $_REQUEST['fcateg']; $fprice = $_REQUEST['fprice']; $pic = $_REQUEST['pic']; if (!$product->updateProduct($fid, $fname, $fcateg, $fprice, $pic)) { echo '{"result":0,"message":"Could not add the product"}'; return; } echo '{"result":1,"message":"Succesfully added product"}'; } switch ($cmd) { case 1: addProduct(); break; case 2: updateProduct(); break; case 3: getAllProducts(); break; case 4: getByCategory(); break; case 5: getProductById(); break; case 6: deleteProduct(); break; case 7: searchProduct();
<?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")); }
$name = strip_tags($_POST['name']); $image = strip_tags($_POST['image']); $description = strip_tags($_POST['description']); $price = strip_tags($_POST['price']); if (isset($_POST['$taxable'])) { $taxable = 1; } else { $taxable = 0; } if (!empty($id) && !empty($quantity) && !empty($genre) && !empty($platform) && !empty($name) && !empty($image) && !empty($description) && !empty($price)) { require_once 'maintain_products.php'; $result = viewProduct($id); $rows = mysql_num_rows($result); if ($rows > 0) { // This product exists, therefore you need to update. updateProduct($id, $quantity, $genre, $platform, $name, $image, $description, $price, $taxable); } else { // This is a new product. addProduct($quantity, $genre, $platform, $name, $image, $description, $price, $taxable); } } else { echo 'Please go back and make sure to fill out all the fields.'; } echo '<br /><br /><a href="addUpdateProducts.php">Go back</a>'; } else { echo "You do not have the permissions to do that."; } } else { echo 'Please <a href="index.html">login</a>.'; } ?>
$price = filter_input(INPUT_POST, 'price'); if ($_FILES['image']['error'] == UPLOAD_ERR_NO_FILE) { $image = filter_input(INPUT_POST, 'origImg'); } else { include '../../includes/products/uploadCheck.php'; $image = $FN; } $errors = array(); if (!isValidProduct($product)) { $errors[] = 'Product is not Valid'; } if (!isValidPrice($price)) { $errors[] = 'Price is not Valid'; } if (count($errors) == 0) { $message = updateProduct($product, $category_id, $price, $image, $id); } } $results = specificProduct($id); ?> <h1>Edit Product</h1> <?php if (isset($errors) && count($errors) > 0) { ?> <ul> <?php foreach ($errors as $error) { ?> <li><?php
function processFile($filename, $clientScript) { //read the file $contents = file($filename); DaoMap::loadMap('Product'); $skuSizeLimit = DaoMap::$map['product']['sku']['size']; foreach ($contents as $line) { $pro = json_decode(trim($line), true); if (strlen($pro['sku']) > $skuSizeLimit) { continue; } updateProduct($pro, $clientScript, $filename, $line); } }