예제 #1
0
        $arResult['STATUS'] = 'ERROR';
        $arResult['MESSAGE'] = Loc::getMessage('BT_CAT_TOOLS_GEN_CPN_ERR_AUTH');
        $boolFlag = false;
    }
}
if ($boolFlag) {
    if (!check_bitrix_sessid()) {
        $arResult['STATUS'] = 'ERROR';
        $arResult['MESSAGE'] = Loc::getMessage('BT_CAT_TOOLS_GEN_CPN_ERR_SESSION');
        $boolFlag = false;
    }
}
if ($boolFlag) {
    if (!$USER->CanDoOperation('catalog_discount')) {
        $arResult['STATUS'] = 'ERROR';
        $arResult['MESSAGE'] = Loc::getMessage('BT_CAT_TOOLS_GEN_CPN_ERR_RIGHTS');
        $boolFlag = false;
    }
}
if ($boolFlag) {
    if (Loader::includeModule('catalog')) {
        do {
            $strCoupon = substr(CatalogGenerateCoupon(), 0, 32);
            $boolCheck = !CCatalogDiscountCoupon::IsExistCoupon($strCoupon);
        } while (!$boolCheck);
        $arResult['RESULT'] = $strCoupon;
    } else {
        $arResult['STATUS'] = 'ERROR';
    }
}
echo CUtil::PhpToJSObject($arResult);