Example #1
0
$parameters = new Parameters("POST");
$action = $parameters->getValue('action');
if ($action == 'checkstock') {
    //check
    $sku = $parameters->getValue('sku');
    $rows = $pm->checkProductsStock();
    echo json_encode($rows);
} else {
    if ($action == 'update') {
        //   sku: loginValue, newItemName: editedItemName, newPrice: editedPrice, newStock:  editedStock},
        $sku = $parameters->getValue('sku');
        $pname = $parameters->getValue('newItemName');
        $pdesc = $parameters->getValue('newDesc');
        $price = $parameters->getValue('newPrice');
        $stock = $parameters->getValue('newStock');
        $rows = $pm->updateProduct($sku, $pname, $pdesc, $price, $stock);
        echo json_encode($rows);
    } else {
        if ($action == 'add') {
            $pname = $parameters->getValue('productName');
            $pdesc = $parameters->getValue('productDesc');
            $price = $parameters->getValue('productPrice');
            $stock = $parameters->getValue('productStock');
            $rows = $pm->addProduct($pname, $pdesc, $price, $stock);
            echo json_encode($rows);
        } else {
            if ($action == 'delete') {
                $sku = $parameters->getValue('sku');
                $pm->deleteProduct($sku);
                echo json_encode(array('deleted item' => $sku));
            } else {
Example #2
0
                        $photoMgr->AddPhoto($product_id, $imgColor, $pic_path);
                        array_push($colorArr, $imgColor);
                        $productMgr->addProductColorOptionalCode($product_id, $imgColor, $_POST['edit_color_symbol_code4']);
                    } else {
                        unset($colorArr[$key]);
                        array_push($colorArr, $imgColor);
                        $photoMgr->updatePhoto($product_id, $imgOriginalColor, $imgColor, $pic_path);
                        unlink($existingPhotoList[$imgOriginalColor]);
                        $productMgr->updateProductColorOptionalCode($product_id, $imgColor, $_POST['edit_color_symbol_code4']);
                    }
                    break;
            }
        }
    }
    $colors = implode(",", $colorArr);
    $productMgr->updateProduct($product_id, $product_name, $symbol_code, $price, $colors, $description, $stock);
    header("Location: admin.php#viewProduct");
} elseif ($operation === "add_product_to_cart") {
    session_start();
    $customer_id = $_SESSION["userid"];
    //$customer_id = filter_input(INPUT_POST,'customer_id');
    $product_id = filter_input(INPUT_POST, 'product_id');
    $qty = filter_input(INPUT_POST, 'product_qty');
    $productMgr->addProductToShoppingCart($customer_id, $product_id, $qty);
    //$_SESSION["message_add_cart"] = "Your Selected Prodcut has been added";
    //header("Location: testAddToCart.php");
} elseif ($operation === "deletePhoto") {
    $product_id = addslashes(filter_input(INPUT_POST, 'product_id'));
    $photo_type = addslashes(filter_input(INPUT_POST, 'photo_type'));
    $photoMgr->deletePhoto($product_id, $photo_type);
    $color_str = $productMgr->getColor($product_id);