Пример #1
0
if (!CBXFeatures::IsFeatureEnabled('SaleRecurring')) {
    require $DOCUMENT_ROOT . "/bitrix/modules/main/include/prolog_admin_after.php";
    ShowError(GetMessage("SALE_FEATURE_NOT_ALLOW"));
    require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin.php";
    die;
}
IncludeModuleLangFile(__FILE__);
$errorMessage = "";
$bVarsFromForm = false;
ClearVars();
$ID = IntVal($ID);
$simpleForm = COption::GetOptionString("sale", "lock_catalog", "Y");
$bSimpleForm = $simpleForm == "Y" ? True : False;
if ($bSimpleForm) {
    if ($ID > 0) {
        if ($arRecurring = CSaleRecurring::GetByID($ID)) {
            if ($arRecurring["MODULE"] != "catalog" || $arRecurring["CALLBACK_FUNC"] != "CatalogRecurringCallback" || $arRecurring["PRODUCT_PROVIDER_CLASS"] != "CCatalogProductProvider") {
                $bSimpleForm = False;
            }
        }
    }
}
if ($REQUEST_METHOD == "POST" && strlen($Update) > 0 && $saleModulePermissions >= "U" && check_bitrix_sessid()) {
    if ($ID <= 0 && $saleModulePermissions < "W") {
        $errorMessage .= GetMessage("SRE_NO_PERMS2ADD") . ".<br>";
    }
    $NEXT_DATE = Trim($NEXT_DATE);
    if (strlen($NEXT_DATE) <= 0) {
        $errorMessage .= GetMessage("SRE_EMPTY_NEXT") . ".<br>";
    }
    if ($saleModulePermissions >= "W") {
Пример #2
0
	/**
	 * <p>Метод осуществляет отмену продления подписки с кодом ID.</p>
	 *
	 *
	 *
	 *
	 * @param int $ID  Код записи с информацией о продлении.
	 *
	 *
	 *
	 * @param string $val  "Y", если подписка отменяется, и "N", если подписка
	 * восстанавливается.
	 *
	 *
	 *
	 * @param  $string  Причина отмены подписки.
	 *
	 *
	 *
	 * @param descriptio $n = ""] 
	 *
	 *
	 *
	 * @return bool <p>Метод возвращает код отменяемой записи или <i>false</i> в случае
	 * ошибки.</p><br><br>
	 *
	 * @static
	 * @link http://dev.1c-bitrix.ru/api_help/sale/classes/csalerecurring/csalerecurring.cancelrecurring.php
	 * @author Bitrix
	 */
	public static function CancelRecurring($ID, $val, $description = "")
	{
		global $DB, $USER;

		$ID = IntVal($ID);
		$val = (($val != "Y") ? "N" : "Y");
		$description = Trim($description);

		if ($ID <= 0)
		{
			$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGR_EMPTY_SUBSCR"), "NO_RECURRING_ID");
			return False;
		}

		$arRecurring = CSaleRecurring::GetByID($ID);
		if (!$arRecurring)
		{
			$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $ID, GetMessage("SKGR_NO_SUBSCR")), "NO_RECURRING");
			return False;
		}

		if ($arRecurring["CANCELED"] == $val)
		{
			$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $ID, GetMessage("SKGR_DUB_CANCEL")), "ALREADY_FLAG");
			return False;
		}

		$arFields = array(
				"CANCELED" => $val,
				"DATE_CANCELED" => (($val == "Y") ? Date(CDatabase::DateFormatToPHP(CLang::GetDateFormat("FULL", LANG))) : False),
				"CANCELED_REASON" => ( strlen($description)>0 ? $description : false )
			);
		$res = CSaleRecurring::Update($ID, $arFields);

		unset($GLOBALS["SALE_RECURRING"]["SALE_RECURRING_CACHE_".$ID]);

		$arRecurring = CSaleRecurring::GetByID($ID);
		$dbUser = CUser::GetByID($arRecurring["USER_ID"]);
		$arUser = $dbUser->Fetch();

		$arOrder = CSaleOrder::GetByID($arRecurring["ORDER_ID"]);

		$arFields = array(
			"RECURRING_ID" => $ID,
			"PRODUCT_NAME" => $arRecurring["PRODUCT_NAME"],
			"EMAIL" => $arUser["EMAIL"],
			"CANCELED_REASON" => $description,
			"SALE_EMAIL" => COption::GetOptionString("sale", "order_email", "order@".$SERVER_NAME)
		);
		$eventName = "SALE_RECURRING_CANCEL";

		$bSend = true;
		foreach(GetModuleEvents("sale", "OnOrderRecurringCancelSendEmail", true) as $arEvent)
		{
			if (ExecuteModuleEventEx($arEvent, Array($ID, &$eventName, &$arFields))===false)
				$bSend = false;
		}

		if($bSend)
		{
			$event = new CEvent;
			$event->Send($eventName, $arOrder["LID"], $arFields, "N");
		}

		return $res;
	}