コード例 #1
0
         $fields['COUPON']['TYPE'] = $_POST[$prefix . 'TYPE'];
     }
     if (isset($_POST[$prefix . 'MAX_USE'])) {
         $fields['COUPON']['MAX_USE'] = $_POST[$prefix . 'MAX_USE'];
     }
     if (isset($_POST[$prefix . 'COUNT'])) {
         $fields['COUNT'] = (int) $_POST[$prefix . 'COUNT'];
     }
     if ($fields['COUNT'] <= 0) {
         $errors[] = Loc::getMessage('BX_SALE_DISCOUNT_COUPON_ERR_COUPON_COUNT');
     }
     $checkResult = Internals\DiscountCouponTable::checkPacket($fields['COUPON'], false);
     if (!$checkResult->isSuccess(true)) {
         $errors = $checkResult->getErrorMessages();
     } else {
         $couponsResult = Internals\DiscountCouponTable::addPacket($fields['COUPON'], $fields['COUNT']);
         if (!$couponsResult->isSuccess()) {
             $errors = $couponsResult->getErrorMessages();
         }
     }
     unset($checkResult);
 } else {
     if ($subWindow) {
         $fields['DISCOUNT_ID'] = $discountID;
     } elseif (!empty($_POST['DISCOUNT_ID'])) {
         $fields['DISCOUNT_ID'] = $_POST['DISCOUNT_ID'];
     }
     if (isset($_POST['COUPON'])) {
         $fields['COUPON'] = $_POST['COUPON'];
     }
     if (!empty($_POST[$prefix . 'ACTIVE'])) {
コード例 #2
0
ファイル: discount_edit.php プロジェクト: webgksupport/alpina
                } else {
                    $errors[] = str_replace('#ID#', $discountID, GetMessage('BT_SALE_DISCOUNT_EDIT_ERR_UPDATE'));
                }
            }
        } else {
            $discountID = (int) CSaleDiscount::Add($arFields);
            if ($discountID <= 0) {
                if ($ex = $APPLICATION->GetException()) {
                    $errors[] = $ex->GetString();
                } else {
                    $errors[] = GetMessage('BT_SALE_DISCOUNT_EDIT_ERR_ADD');
                }
            } else {
                if ($couponsAdd) {
                    $couponsFields['DISCOUNT_ID'] = $discountID;
                    $couponsResult = Internals\DiscountCouponTable::addPacket($couponsFields, $additionalFields['COUPON_COUNT']);
                    if (!$couponsResult->isSuccess()) {
                        $errors = $couponsResult->getErrorMessages();
                    }
                }
            }
        }
    }
    if (empty($errors)) {
        if (empty($_POST['apply'])) {
            LocalRedirect("/bitrix/admin/sale_discount.php?lang=" . LANGUAGE_ID . GetFilterParams("filter_", false));
        } else {
            LocalRedirect("/bitrix/admin/sale_discount_edit.php?lang=" . LANGUAGE_ID . "&ID=" . $discountID . '&' . $control->ActiveTabParam());
        }
    }
}