示例#1
0
         } else {
             tep_db_query("delete from " . TABLE_PRODUCTS_GROUPS . " where customers_group_id = '" . $customers_group['customers_group_id'] . "' and products_id = '" . $products_id . "'");
         }
     } elseif (tep_db_num_rows($attributes_query) > 0 && $delete_row_from_pg == true) {
         tep_db_query("delete from " . TABLE_PRODUCTS_GROUPS . " where customers_group_id = '" . $customers_group['customers_group_id'] . "' and products_id = '" . $products_id . "'");
     } elseif ($_POST['sppcoption'][$customers_group['customers_group_id']] && $delete_row_from_pg == false) {
         tep_db_query("insert into " . TABLE_PRODUCTS_GROUPS . " (products_id, customers_group_id, customers_group_price, products_qty_blocks, products_min_order_qty) values ('" . $products_id . "', '" . $customers_group['customers_group_id'] . "', " . $pg_cg_group_price . ", " . $pg_products_qty_blocks . ", " . $pg_products_min_order_qty . ")");
     }
 }
 // end while ($customers_group = tep_db_fetch_array($customers_group_query))
 // EOF entries in products_groups
 // BOF entries in products_to_discount_categories
 foreach ($_POST['discount_categories_id'] as $dc_cg_id => $dc_id) {
     $current_discount_category = (int) $_POST['current_discount_cat_id'][$dc_cg_id];
     $new_discount_category = (int) $dc_id;
     $discount_category_result = qpbpp_insert_update_discount_cats($products_id, $current_discount_category, $new_discount_category, $dc_cg_id);
     if ($discount_category_result == false) {
         $messageStack->add_session(ERROR_UPDATE_INSERT_DISCOUNT_CATEGORY, 'error');
     }
 }
 // end foreach ($_POST['discount_categories_id'] as $dc_cg_id => $dc_id
 // EOF entries in products_to_discount_categories
 // BOF entries in products_price_break
 foreach ($_POST['products_price_break'] as $pbb_cg_id => $price_break_array) {
     foreach ($price_break_array as $key1 => $products_price) {
         $pb_action = 'insert';
         // re-set default to insert
         $where_clause = '';
         if (isset($_POST['products_delete'][$pbb_cg_id][$key1]) && $_POST['products_delete'][$pbb_cg_id][$key1] == 'y' && isset($_POST['products_price_break_id'][$pbb_cg_id][$key1])) {
             $delete_from_ppb_array[] = (int) $_POST['products_price_break_id'][$pbb_cg_id][$key1];
             continue;
            $discount_categories_name = tep_db_prepare_input($_POST['discount_categories_name']);
            $last_id_query = tep_db_query("select MAX(discount_categories_id) as last_dc_id from " . TABLE_DISCOUNT_CATEGORIES . "");
            $last_dc_id_inserted = tep_db_fetch_array($last_id_query);
            $new_dc_id = $last_dc_id_inserted['last_dc_id'] + 1;
            tep_db_query("insert into " . TABLE_DISCOUNT_CATEGORIES . " set discount_categories_id = '" . $new_dc_id . "', discount_categories_name = '" . tep_db_input($discount_categories_name) . "'");
            tep_redirect(tep_href_link(FILENAME_DISCOUNT_CATEGORIES, tep_get_all_get_params(array('action'))));
            break;
    }
}
$do = isset($_GET['do']) ? $_GET['do'] : '';
if (tep_not_null($do)) {
    switch ($do) {
        case 'update':
            foreach ($_POST['pdcID'] as $pid => $new_discount_category) {
                if (isset($_POST['pdcID_old'][$pid])) {
                    $discount_category_result = qpbpp_insert_update_discount_cats($pid, (int) $_POST['pdcID_old'][$pid], $new_discount_category, $cgID);
                    if ($discount_category_result == false) {
                        $messageStack->add(ERROR_UPDATE_INSERT_DISCOUNT_CATEGORY, 'error');
                    }
                }
            }
            // end foreach ($_POST['pdcID'] as $pid => $new_discount_category)
            break;
    }
}
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php 
echo HTML_PARAMS;
?>
>