'Deny', text=>'Deny'); $restrict_array[] = array('id'=>'Allow', text=>'Allow'); if (isset($_GET['cid'])) $_GET['cid'] = (int)$_GET['cid']; if (isset($_GET['info'])) $_GET['info'] = (int)$_GET['info']; if (isset($_POST['cPath'])) $_POST['cPath'] = (int)$_POST['cPath']; if (isset($_POST['cPath_prod'])) $_POST['cPath_prod'] = (int)$_POST['cPath_prod']; if (isset($_GET['build_cat'])) $_GET['build_cat'] = (int)$_GET['build_cat']; $the_path = $_POST['cPath']; if (isset($_GET['action']) && $_GET['action']=='switch_status') { if (isset($_POST['switchStatusProto'])) { $status = $db->Execute("select coupon_restrict from " . TABLE_COUPON_RESTRICT . " where restrict_id = '" . $_GET['info'] . "'"); $new_status = 'N'; if ($status->fields['coupon_restrict'] == 'N') $new_status = 'Y'; $db->Execute("update " . TABLE_COUPON_RESTRICT . " set coupon_restrict = '" . $new_status . "' where restrict_id = '" . $_GET['info'] . "'"); } } if ($_GET['action']=='add_category' && isset($_POST['cPath'])) { if ($_POST['cPath'] == 0) $_POST['cPath'] = -1; $test_query=$db->Execute("select * from " . TABLE_COUPON_RESTRICT . " where coupon_id = '" . $_GET['cid'] . "' and category_id = '" . $_POST['cPath'] . "'"); if ($test_query->RecordCount() < 1) { $status = 'N'; if ($_POST['restrict_status']=='Deny') $status = 'Y'; $db->Execute("insert into " . TABLE_COUPON_RESTRICT . " (coupon_id, category_id, coupon_restrict) values ('" . $_GET['cid'] . "', '" . $_POST['cPath'] . "', '" . $status . "')"); } else { // message that nothing is done $messageStack->add(ERROR_DISCOUNT_COUPON_DEFINED_CATEGORY . ' ' . $_POST['cPath'], 'caution'); } } // from products dropdown selection if ($_GET['action']=='add_product' && $_POST['products_drop']) { $test_query=$db->Execute("select * from " . TABLE_COUPON_RESTRICT . " where coupon_id = '" . $_GET['cid'] . "' and product_id = '" . (int)$_POST['products_drop'] . "'"); if ($test_query->RecordCount() < 1) { $status = 'N'; if ($_POST['restrict_status']=='Deny') $status = 'Y'; // ================================== // bof: ALL ADD/DELETE of Products in one Category if ($_POST['products_drop'] < 0) { // adding new records if ($_POST['products_drop'] == -1) { // to insert new products from a given categories_id for a coupon_code that are not already in the table // products in the table from the catategories_id are skipped $new_products_query = "select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . $_GET['build_cat'] . "' and products_id not in (select product_id from " . TABLE_COUPON_RESTRICT . " where coupon_id = '" . $_GET['cid'] . "')"; $new_products = $db->Execute($new_products_query); } if ($_POST['products_drop'] == -2) { // to delete existing products from a given categories_id for a coupon_code that are already in the table // products in the table from the catategories_id are skipped $new_products_query = "select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . $_GET['build_cat'] . "' and products_id in (select product_id from " . TABLE_COUPON_RESTRICT . " where coupon_restrict = '" . $status . "' and coupon_id = '" . $_GET['cid'] . "')"; $new_products = $db->Execute($new_products_query); } // nothing to be done if ($new_products->RecordCount() == 0) { $messageStack->add(ERROR_DISCOUNT_COUPON_DEFINED_CATEGORY . ' ' . $_POST['cPath'], 'caution'); } while(!$new_products->EOF) { // product passed and needs to be added/deleted // add all products from select category for each product not already defined in coupons_restrict if ($_POST['products_drop'] == -1) { $db->Execute("insert into " . TABLE_COUPON_RESTRICT . " (coupon_id, product_id, coupon_restrict) values ('" . $_GET['cid'] . "', '" . $new_products->fields['products_id'] . "', '" . $status . "')"); } else { // removed as defined in coupons_restrict for either DENY or ALLOW $db->Execute("delete from " . TABLE_COUPON_RESTRICT . " WHERE coupon_id = '" . $_GET['cid'] . "' and product_id = '" . $new_products->fields['products_id'] . "' and coupon_restrict = '" . $status . "'"); } $new_products->MoveNext(); } // eof: ALL ADD/DELETE of Products in one Category // ================================== } else { // normal insert of product one by one allow/deny to coupon $db->Execute("insert into " . TABLE_COUPON_RESTRICT . " (coupon_id, product_id, coupon_restrict) values ('" . $_GET['cid'] . "', '" . (int)$_POST['products_drop'] . "', '" . $status . "')"); } // not all deny allow } else { $messageStack->add(ERROR_DISCOUNT_COUPON_DEFINED_PRODUCT . ' ' . (int)$_POST['products_drop'], 'caution'); } } if ($_GET['action']=='remove') { if (isset($_GET['info']) && isset($_POST['actionRemoveProto'])) { $db->Execute("delete from " . TABLE_COUPON_RESTRICT . " where restrict_id = '" . $_GET['info'] . "'"); } } ?> > <?php echo TITLE; ?>
Execute($cr_query_raw); while (!$cr_list->EOF) { $rows++; if (strlen($rows) < 2) { $rows = '0' . $rows; } if (((!$_GET['cid']) || (@$_GET['cid'] == $cr_list->fields['restrict_id'])) && (!$cInfo)) { $cInfo = new objectInfo($cr_list->fields); } echo ' ' . "\n"; if ($cr_list->fields['category_id'] != -1) { $coupon = $db->Execute("select coupon_name from " . TABLE_COUPONS_DESCRIPTION . " where coupon_id = '" . $_GET['cid'] . "' and language_id = '" . (int)$_SESSION['languages_id'] . "'"); $category_name = zen_get_category_name($cr_list->fields['category_id'], $_SESSION['languages_id']); } else { $category_name = TEXT_ALL_CATEGORIES; } ?> fields['coupon_restrict']=='N') { echo ''; } else { echo ''; } if ($cr_list->fields['coupon_restrict']=='Y') { echo ''; } else { echo ''; } echo ''; ?> MoveNext(); } ?>
fields['coupon_name']; ?> fields['category_id']; ?> ' . zen_image(DIR_WS_IMAGES . 'icon_status_green.gif', IMAGE_ALLOW) . '' . zen_image(DIR_WS_IMAGES . 'icon_status_red.gif', IMAGE_DENY) . '' . zen_image(DIR_WS_IMAGES . 'icon_status_green.gif', IMAGE_ALLOW) . '' . zen_image(DIR_WS_IMAGES . 'icon_status_red.gif', IMAGE_DENY) . '' . zen_image(DIR_WS_IMAGES . 'icons/delete.gif', IMAGE_REMOVE) . '
display_count($cr_query_numrows, MAX_DISPLAY_RESTRICT_ENTRIES, $_GET['cpage'], TEXT_DISPLAY_NUMBER_OF_CATEGORIES); ?> display_links($cr_query_numrows, MAX_DISPLAY_RESTRICT_ENTRIES, MAX_DISPLAY_PAGE_LINKS, $_GET['cpage'],zen_get_all_get_params(array('cpage','action', 'x', 'y')),'cpage'); ?>
   
Execute($pr_query_raw); while (!$pr_list->EOF) { $rows++; if (strlen($rows) < 2) { $rows = '0' . $rows; } if (((!$_GET['cid']) || (@$_GET['cid'] == $cr_list->fields['restrict_id'])) && (!$pInfo)) { $pInfo = new objectInfo($pr_list); } echo ' ' . "\n"; $coupon = $db->Execute("select coupon_name from " . TABLE_COUPONS_DESCRIPTION . " where coupon_id = '" . $_GET['cid'] . "' and language_id = '" . (int)$_SESSION['languages_id'] . "'"); $product_name = zen_get_products_name($pr_list->fields['product_id'], $_SESSION['languages_id']); ?> fields['coupon_restrict']=='N') { echo ''; } else { echo ''; } if ($pr_list->fields['coupon_restrict']=='Y') { echo ''; } else { echo ''; } echo ''; ?> MoveNext(); } ?>
fields['coupon_name']; ?> fields['product_id']; ?> ' . $product_name . '
' . TEXT_CATEGORY . zen_get_categories_name_from_product($pr_list->fields['product_id']) . '
' . TEXT_MANUFACTURER . zen_get_products_manufacturers_name($pr_list->fields['product_id']); ?>
' . zen_image(DIR_WS_IMAGES . 'icon_status_green.gif', IMAGE_ALLOW) . '' . zen_image(DIR_WS_IMAGES . 'icon_status_red.gif', IMAGE_DENY) . '' . zen_image(DIR_WS_IMAGES . 'icon_status_green.gif', IMAGE_DENY) . '' . zen_image(DIR_WS_IMAGES . 'icon_status_red.gif', IMAGE_ALLOW) . '' . zen_image(DIR_WS_IMAGES . 'icons/delete.gif', IMAGE_REMOVE) . '
display_count($pr_query_numrows, MAX_DISPLAY_RESTRICT_ENTRIES, $_GET['ppage'], TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?> display_links($pr_query_numrows, MAX_DISPLAY_RESTRICT_ENTRIES, MAX_DISPLAY_PAGE_LINKS, $_GET['ppage'],zen_get_all_get_params(array('ppage','action', 'x', 'y')),'ppage'); ?>
Execute("select p.products_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' and p.products_id = p2c.products_id and p2c.categories_id = '" . $_POST['cPath_prod'] . "' order by pd.products_name"); $products_array = array(); if (!$products->EOF) { $products_array[] = array('id' => '-1', 'text' => TEXT_ALL_PRODUCTS_ADD); $products_array[] = array('id' => '-2', 'text' => TEXT_ALL_PRODUCTS_REMOVE); } while (!$products->EOF) { $products_array[] = array('id'=>$products->fields['products_id'], 'text'=>$products->fields['products_name']); $products->MoveNext(); } ?> 0) { ?>
     
coupon_id) ? $cInfo->coupon_id : $_GET['cid']) . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '')) . '">' . zen_image_button('button_back.gif', IMAGE_BACK) . ''; ?>