Example #1
0
        $jTableResult['Records'] = $rows;
        break;
    case "addProduct":
        $res = addProduct(filter_input(INPUT_POST, "nombre", FILTER_SANITIZE_STRING), filter_input(INPUT_POST, "precio", FILTER_SANITIZE_STRING));
        //Return result to jTable
        if ($res) {
            $jTableResult['Result'] = "OK";
            $jTableResult['Record'] = productsList();
        } else {
            $jTableResult['Result'] = "ERROR";
        }
        break;
    case "modifyProduct":
        $res = modifyProduct(filter_input(INPUT_POST, "IDP", FILTER_SANITIZE_STRING), filter_input(INPUT_POST, "nombre", FILTER_SANITIZE_STRING), filter_input(INPUT_POST, "precio", FILTER_SANITIZE_STRING));
        //Return result to jTable
        if ($res) {
            $jTableResult['Result'] = "OK";
        } else {
            $jTableResult['Result'] = "ERROR";
        }
        break;
    case "removeProduct":
        $res = removeProduct(filter_input(INPUT_POST, "IDP", FILTER_SANITIZE_STRING));
        if ($res) {
            $jTableResult['Result'] = "OK";
        } else {
            $jTableResult['Result'] = "ERROR";
        }
        break;
}
print json_encode($jTableResult);
function delete_all()
{
    global $wpdb;
    $ids = $wpdb->get_col('SELECT id FROM ' . $wpdb->prefix . 'spidercatalog_products');
    foreach ($ids as $id) {
        if (isset($_POST['check_' . $id])) {
            removeProduct($id);
        }
    }
    return true;
}
<?php 
chdir("../../database");
require_once "store_backoffice.php";
if (isset($_GET["storeId"]) and isset($_GET["productId"]) and strlen($_GET["productId"]) > 0) {
    removeProduct($_GET["productId"]);
    echo json_encode(array("result" => "ok"));
} else {
    echo json_encode(array("result" => "missingParams"));
}
function removeCategory($id)
{
    //? the id should be listed as an html attribute for that particular selection, get the attribute of the current selection passed from
    //the js script along with the
    //make sure the js displays a confirmation before proceeding
    //with this process
    //be sure to refresh by using getCategory on current category
    //send that back for processing in the javascript
    $db = connect(0, 0, 0);
    $category_id = $id;
    $result = $db->query('delete from CATEGORY where category_id = ' . $id);
    $result = $db->query('select product_id from PRODUCT where category_id = ' . $id);
    $num_results = $result->num_rows;
    $p = "";
    for ($i = 0; $i < $num_results; $i++) {
        $row = $result->fetch_assoc();
        $p[$i] = $row['product_id'];
    }
    for ($j = 0; $j < count($p); $j++) {
        removeProduct($p[$j]);
    }
    $arr = array('selector' => '#removeCategory');
    echo json_encode($arr);
}
function Products_Spider_Catalog()
{
    global $wpdb;
    require_once "products.php";
    require_once "Products.html.php";
    if (!function_exists('print_html_nav')) {
        require_once "nav_function/nav_html_func.php";
    }
    if (isset($_GET['id'])) {
        $id = $_GET['id'];
    } else {
        $id = 0;
    }
    if (isset($_GET['task'])) {
        $task = $_GET['task'];
    } else {
        $task = "";
    }
    switch ($task) {
        case 'edit_prad':
            editProduct($id);
            break;
        case 'add_prad':
            addProduct();
            break;
        case 'apply':
            if ($id) {
                check_admin_referer('nonce_sp_cat', 'nonce_sp_cat');
                update_prad_cat($id);
            } else {
                check_admin_referer('nonce_sp_cat', 'nonce_sp_cat');
                save_prad_cat();
                $id = $wpdb->get_var("SELECT MAX(id) FROM " . $wpdb->prefix . "spidercatalog_products");
            }
            editProduct($id);
            break;
        case 'save':
            if ($id) {
                check_admin_referer('nonce_sp_cat', 'nonce_sp_cat');
                update_prad_cat($id);
            } else {
                check_admin_referer('nonce_sp_cat', 'nonce_sp_cat');
                save_prad_cat();
            }
            showProducts();
            break;
        case 'saveorder':
            break;
        case 'publish':
            check_admin_referer('nonce_sp_cat', 'nonce_sp_cat');
            publish_all(TRUE);
            showProducts();
            break;
        case 'unpublish':
            check_admin_referer('nonce_sp_cat', 'nonce_sp_cat');
            publish_all(FALSE);
            showProducts();
            break;
        case 'delete':
            check_admin_referer('nonce_sp_cat', 'nonce_sp_cat');
            delete_all();
            showProducts();
            break;
        case 'unpublish_prad':
            $nonce_sp_cat = $_REQUEST['_wpnonce'];
            if (!wp_verify_nonce($nonce_sp_cat, 'nonce_sp_cat')) {
                die("Are you sure you want to do this?");
            }
            change_prod($id);
            showProducts();
            break;
        case 'unpublish_prad':
            $nonce_sp_cat = $_REQUEST['_wpnonce'];
            if (!wp_verify_nonce($nonce_sp_cat, 'nonce_sp_cat')) {
                die("Are you sure you want to do this?");
            }
            change_prod($id);
            showProducts();
            break;
        case 'remove_prod':
            $nonce_sp_cat = $_REQUEST['_wpnonce'];
            if (!wp_verify_nonce($nonce_sp_cat, 'nonce_sp_cat')) {
                die("Are you sure you want to do this?");
            }
            removeProduct($id);
            showProducts();
            break;
        case 'edit_reviews':
            spider_cat_prod_rev($id);
            break;
        case 'delete_reviews':
            check_admin_referer('nonce_sp_cat', 'nonce_sp_cat');
            delete_rev($id);
            spider_cat_prod_rev($id);
            break;
        case 'delete_review':
            $nonce_sp_cat = $_REQUEST['_wpnonce'];
            if (!wp_verify_nonce($nonce_sp_cat, 'nonce_sp_cat')) {
                die("Are you sure you want to do this?");
            }
            delete_single_review($id);
            spider_cat_prod_rev($id);
            break;
        case 'edit_rating':
            spider_cat_prod_rating($id);
            break;
        case 'delete_ratings':
            check_admin_referer('nonce_sp_cat', 'nonce_sp_cat');
            delete_ratings($id);
            spider_cat_prod_rating($id);
            break;
        case 'delete_rating':
            $nonce_sp_cat = $_REQUEST['_wpnonce'];
            if (!wp_verify_nonce($nonce_sp_cat, 'nonce_sp_cat')) {
                die("Are you sure you want to do this?");
            }
            delete_single_rating($id);
            spider_cat_prod_rating($id);
            break;
        case 's_p_apply_rating':
            check_admin_referer('nonce_sp_cat', 'nonce_sp_cat');
            update_s_c_rating($id);
            spider_cat_prod_rating($id);
            break;
        case 's_p_save_rating':
            check_admin_referer('nonce_sp_cat', 'nonce_sp_cat');
            update_s_c_rating($id);
            editProduct($id);
            break;
        default:
            showProducts();
            break;
    }
}
Example #6
0
$qty = new InputText();
$qty->setClass("inputtextTitlewhite");
$price = new InputNumeric(12, 4);
$price->setClass("inputtextTitlewhite");
$price->setLabelPosition("Left");
$price->setLabelCaption("X \$");
$table_desc = new Table();
$table_desc->setColumnsStyle("5%;5%;90%");
$table_desc->addControl($name, 1, 1, 1, 4, "Left", "Top");
$table_desc->addControl($qty, 2, 1, 1, 1, "Left", "Top");
$table_desc->addControl($price, 2, 2, 1, 2, "Left", "Top");
$table_list = new Table();
$table_list->setColumnsStyle("95dip;100%");
$table_list->addControl($image, 1, 1);
$table_list->addControl($table_desc, 1, 2);
$table_list->onLongTap(removeProduct());
//$table_list->onTap(view_image());
$list->addControl($table_list, 1, 1);
$table_result = new Table();
$table_result->setClass("table.checkout");
$table_result->setRowsStyle("90dip;70dip");
$lbl_total = new Label();
$lbl_total->setCaption("Total: ");
$lbl_sub_total = new Label();
$lbl_sub_total->setCaption("Sub total: ");
$lbl_shipping = new Label();
$lbl_shipping->setCaption("Shipping: ");
$lbl_tax = new Label();
$lbl_tax->setCaption("Tax: ");
$total = new InputText(10);
$total->setReadOnly(true);