Exemplo n.º 1
0
    $new_color_str = str_replace($old_color, $new_color, $color_str);
    $productMgr->updateColor($product_id, $new_color_str);
    $productMgr->updateColorInOptionalCodeTable($product_id, $new_color, $old_color);
    $photoMgr->updateColorInPhotoTable($product_id, $new_color, $old_color);
    $return = [];
    $return['status'] = 'success';
    echo json_encode($return);
} elseif ($operation === "updateColorSymbolCode") {
    $product_id = addslashes(filter_input(INPUT_POST, 'product_id'));
    $color = addslashes(filter_input(INPUT_POST, 'color'));
    $symbol_code = addslashes(filter_input(INPUT_POST, 'symbol_code'));
    $productMgr->updateProductColorOptionalCode($product_id, $color, $symbol_code);
    $return = [];
    $return['status'] = 'success';
    echo json_encode($return);
} elseif ($operation === "deleteProduct") {
    $productIdList_str = filter_input(INPUT_POST, 'productIdList');
    $productIdList = explode(",", $productIdList_str);
    foreach ($productIdList as $id) {
        $count = $orderMgr->checkProductPendingOrderStatus($id);
        if ($count === 0) {
            $productMgr->deleteProduct($id);
            //delete from product table
            $photoMgr->deleteAllPhotosByProduct($id);
            //delete from photo table
            $productMgr->deleteAllColorOptionalCodeByProduct($id);
            //delete from optional_code table
        }
    }
    header("Location: admin.php#viewProduct");
}