private function EditCouponStep1() { // Show the form to edit a news $couponId = (int) $_GET['couponId']; $arrData = array(); $sel_cats = array(); if (GetConfig('CurrencyLocation') == 'right') { $GLOBALS['CurrencyTokenLeft'] = ''; $GLOBALS['CurrencyTokenRight'] = GetConfig('CurrencyToken'); } else { $GLOBALS['CurrencyTokenLeft'] = GetConfig('CurrencyToken'); $GLOBALS['CurrencyTokenRight'] = ''; } $GLOBALS['CurrencyToken'] = GetConfig('CurrencyToken'); if (CouponExists($couponId)) { $this->_GetCouponData($couponId, $arrData); $GLOBALS['Title'] = GetLang('EditCoupon'); $GLOBALS['Intro'] = GetLang('EditCouponIntro'); $GLOBALS['FormAction'] = "editCoupon2"; $GLOBALS['CouponCode'] = isc_html_escape($arrData['couponcode']); $GLOBALS['CouponName'] = isc_html_escape($arrData['couponname']); $GLOBALS['MaxUses'] = (int) $arrData['couponmaxuses']; if ($GLOBALS['MaxUses'] > 0) { $GLOBALS['MaxUsesChecked'] = 'checked="checked"'; } else { $GLOBALS['MaxUsesHide'] = 'none'; } if ($arrData['couponappliesto'] == "categories") { // Show the categories list $GLOBALS['ToggleUsedFor'] = "ToggleUsedFor(0);"; $sel_cats = explode(",", $arrData['couponappliestovalues']); if ($arrData['couponappliestovalues'] == "0") { $GLOBALS['AllCategoriesSelected'] = "selected=\"selected\""; } } else { // Show the products textbox $GLOBALS['ToggleUsedFor'] = "ToggleUsedFor(1);"; // Select a list of the products that this coupon is active for if ($arrData['couponappliestovalues'] != "") { $GLOBALS['SelectedProducts'] = ''; $GLOBALS['ProductIds'] = ''; $query = sprintf("SELECT productid, prodname FROM [|PREFIX|]products WHERE productid IN (%s) ORDER BY prodname ASC", $arrData['couponappliestovalues']); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $GLOBALS['SelectedProducts'] .= sprintf("<option value='%d'>%s</option>", $row['productid'], $row['prodname']); $GLOBALS['ProductIds'] .= $row['productid'] . ","; } $GLOBALS['ProductIds'] = isc_substr($GLOBALS['ProductIds'], 0, -1); } } $GLOBALS['ISC_CLASS_ADMIN_CATEGORY'] = GetClass('ISC_ADMIN_CATEGORY'); $GLOBALS['CategoryList'] = $GLOBALS["ISC_CLASS_ADMIN_CATEGORY"]->GetCategoryOptions($sel_cats, "<option %s value='%d'>%s</option>", "selected=\"selected\"", "- ", false); if ($arrData['coupontype'] == 1) { $GLOBALS['SelDiscount1'] = "selected=\"selected\""; } else { $GLOBALS['SelDiscount2'] = "selected=\"selected\""; } $GLOBALS['DiscountAmount'] = $arrData['couponamount']; if ($arrData['couponminpurchase'] == 0) { $GLOBALS['MinPurchase'] = 0; } else { $GLOBALS['MinPurchase'] = CPrice($arrData['couponminpurchase']); } if ($arrData['couponexpires'] > 0) { $GLOBALS['ExpiryDate'] = isc_date("m/d/Y", $arrData['couponexpires']); } if ($arrData['couponenabled'] == 1) { $GLOBALS['Enabled'] = 'checked="checked"'; } $GLOBALS['CouponId'] = (int) $arrData['couponid']; $GLOBALS["ISC_CLASS_TEMPLATE"]->SetTemplate("coupon.form"); $GLOBALS["ISC_CLASS_TEMPLATE"]->ParseTemplate(); } else { // The coupon doesn't exist if ($GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Manage_Coupons)) { $this->ManageCoupons(GetLang('CouponDoesntExist'), MSG_ERROR); } else { $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->DoHomePage(GetLang('Unauthorized'), MSG_ERROR); } } }
protected function EditEnabled() { // Update the status of a coupon with a simple query $couponId = (int)$_GET['couponId']; if (CouponExists($couponId)) { $query = "UPDATE [|PREFIX|]coupons SET couponenabled = '" . (int)$_GET['enabled'] . "' WHERE couponid = '" . $couponId . "'"; if ($GLOBALS['ISC_CLASS_DB']->Query($query)) { if ($GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Manage_Coupons)) { $this->ManageCoupons(GetLang('CouponEnabledSuccessfully'), MSG_SUCCESS); } else { $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->DoHomePage(GetLang('CouponEnabledSuccessfully'), MSG_SUCCESS); } } else { if ($GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Manage_Coupons)) { $this->ManageCoupons(sprintf(GetLang('ErrCouponEnabledNotChanged'), $coupon->error), MSG_ERROR); } else { $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->DoHomePage(sprintf(GetLang('ErrCouponEnabledNotChanged'), $coupon->error), MSG_ERROR); } } } }