} $ID = IntVal($arParams["ID"]); $arParams["PATH_TO_LIST"] = Trim($arParams["PATH_TO_LIST"]); if (strlen($arParams["PATH_TO_LIST"]) <= 0) { $arParams["PATH_TO_LIST"] = htmlspecialcharsbx($APPLICATION->GetCurPage()); } $arParams["SET_TITLE"] = $arParams["SET_TITLE"] == "N" ? "N" : "Y"; if ($arParams["SET_TITLE"] == 'Y') { $APPLICATION->SetTitle(str_replace("#ID#", $ID, GetMessage("SPSC_TITLE"))); } if ($ID > 0 && $_REQUEST["CANCEL_SUBSCRIBE"] == "Y" && check_bitrix_sessid()) { $dbRecurring = CSaleRecurring::GetList(array("ID" => "DESC"), array("ID" => $ID, "USER_ID" => IntVal($USER->GetID())), false, false, array("ID")); if ($arRecurring = $dbRecurring->Fetch()) { CSaleRecurring::CancelRecurring($arRecurring["ID"], "Y", $_REQUEST["REASON_CANCELED"]); LocalRedirect($arParams["PATH_TO_LIST"]); } } if ($ID <= 0) { LocalRedirect($arParams["PATH_TO_LIST"]); } $dbRecurring = CSaleRecurring::GetList(array("ID" => "DESC"), array("ID" => $ID, "USER_ID" => IntVal($GLOBALS["USER"]->GetID())), false, false, array("ID", "CANCELED", "PRODUCT_NAME")); if ($arRecurring = $dbRecurring->GetNext()) { if ($arRecurring["CANCELED"] != "Y") { $arResult = array("ID" => $ID, "URL_TO_LIST" => $arParams["PATH_TO_LIST"], "CONFIRM" => str_replace("#NAME#", $arRecurring["PRODUCT_NAME"], str_replace("#ID#", $ID, GetMessage("STPSC_CONFIRM"))), "RECURRING" => $arRecurring); } else { $arResult["ERROR_MESSAGE"] = GetMessage("STPSC_CANT_CANCEL"); } } else { $arResult["ERROR_MESSAGE"] = str_replace("#ID#", $ID, GetMessage("SPOC_NO_ORDER")); } $this->IncludeComponentTemplate();
function _Delete($ID) { global $DB; $ID = IntVal($ID); $bSuccess = True; foreach (GetModuleEvents("sale", "OnBeforeOrderDelete", true) as $arEvent) { if (ExecuteModuleEventEx($arEvent, array($ID)) === false) { return false; } } $DB->StartTransaction(); if ($bSuccess) { $dbBasket = CSaleBasket::GetList(array(), array("ORDER_ID" => $ID)); while ($arBasket = $dbBasket->Fetch()) { $bSuccess = CSaleBasket::Delete($arBasket["ID"]); if (!$bSuccess) { break; } } } if ($bSuccess) { $dbRecurring = CSaleRecurring::GetList(array(), array("ORDER_ID" => $ID)); while ($arRecurring = $dbRecurring->Fetch()) { $bSuccess = CSaleRecurring::Delete($arRecurring["ID"]); if (!$bSuccess) { break; } } } if ($bSuccess) { $bSuccess = CSaleOrderPropsValue::DeleteByOrder($ID); } if ($bSuccess) { $bSuccess = CSaleOrderTax::DeleteEx($ID); } if ($bSuccess) { $bSuccess = CSaleUserTransact::DeleteByOrder($ID); } if ($bSuccess) { unset($GLOBALS["SALE_ORDER"]["SALE_ORDER_CACHE_" . $ID]); } if ($bSuccess) { $bSuccess = $DB->Query("DELETE FROM b_sale_order WHERE ID = " . $ID . "", true); } if ($bSuccess) { $DB->Commit(); } else { $DB->Rollback(); } foreach (GetModuleEvents("sale", "OnOrderDelete", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array($ID, $bSuccess)); } return $bSuccess; }
$arFields = array("CANCELED" => $_REQUEST['action'] == "cancel" ? "Y" : "N"); if ($_REQUEST['action'] != "cancel") { $arFields["REMAINING_ATTEMPTS"] = Defined("SALE_PROC_REC_ATTEMPTS") ? SALE_PROC_REC_ATTEMPTS : 3; } if (!CSaleRecurring::Update($ID, $arFields)) { if ($ex = $APPLICATION->GetException()) { $lAdmin->AddGroupError($ex->GetString(), $ID); } else { $lAdmin->AddGroupError(str_replace("#ID#", $id, GetMessage("SRA_ERROR_UPDATE")), $ID); } } break; } } } $dbResultList = CSaleRecurring::GetList(array($by => $order), $arFilter, false, false, array("*")); $dbResultList = new CAdminResult($dbResultList, $sTableID); $dbResultList->NavStart(); $lAdmin->NavText($dbResultList->GetNavPrint(GetMessage("SRA_NAV"))); $lAdmin->AddHeaders(array(array("id" => "ID", "content" => "ID", "sort" => "id", "default" => true), array("id" => "USER_ID", "content" => GetMessage("SRA_USER1"), "sort" => "user_id", "default" => true), array("id" => "CANCELED", "content" => GetMessage('SRA_CANC'), "sort" => "canceled", "default" => true), array("id" => "PRIOR_DATE", "content" => GetMessage("SRA_LAST_RENEW"), "sort" => "prior_date", "default" => true), array("id" => "NEXT_DATE", "content" => GetMessage("SRA_NEXT_RENEW"), "sort" => "next_date", "default" => true), array("id" => "SUCCESS_PAYMENT", "content" => GetMessage("SRA_SUCCESS_PAY"), "sort" => "success_payment", "default" => true))); $arVisibleColumns = $lAdmin->GetVisibleHeaderColumns(); while ($arRecurring = $dbResultList->NavNext(true, "f_")) { $row =& $lAdmin->AddRow($f_ID, $arRecurring); $row->AddField("ID", $f_ID); $fieldValue = "[<a href=\"/bitrix/admin/user_edit.php?ID=" . $f_USER_ID . "&lang=" . LANG . "\">" . $f_USER_ID . "</a>] "; $fieldValue .= htmlspecialcharsEx($arRecurring["USER_NAME"] . (strlen($arRecurring["USER_NAME"]) <= 0 || strlen($arRecurring["USER_LAST_NAME"]) <= 0 ? "" : " ") . $arRecurring["USER_LAST_NAME"]) . "<br>"; $fieldValue .= htmlspecialcharsEx($arRecurring["USER_LOGIN"]) . " "; $fieldValue .= "<a href=\"mailto:" . htmlspecialcharsEx($arRecurring["USER_EMAIL"]) . "\">" . htmlspecialcharsEx($arRecurring["USER_EMAIL"]) . "</a>"; $row->AddField("USER_ID", $fieldValue); $row->AddField("CANCELED", $arRecurring["CANCELED"] == "Y" ? GetMessage("SRA_YES") : GetMessage("SRA_NO")); $row->AddField("PRIOR_DATE", $arRecurring["PRIOR_DATE"] . " ");
function OrderDelivery($orderID, $bPaid, $recurringID = 0) { global $DB, $APPLICATION; $orderID = IntVal($orderID); if ($orderID <= 0) { return False; } $bPaid = $bPaid ? True : False; $recurringID = IntVal($recurringID); $arOrder = CSaleOrder::GetByID($orderID); if ($arOrder) { $dbBasketList = CSaleBasket::GetList(array("NAME" => "ASC"), array("ORDER_ID" => $orderID)); while ($arBasket = $dbBasketList->Fetch()) { if (strlen($arBasket["PAY_CALLBACK_FUNC"]) > 0 || strlen($arBasket["PRODUCT_PROVIDER_CLASS"]) > 0) { if ($bPaid) { /** @var $productProvider IBXSaleProductProvider */ if ($productProvider = CSaleBasket::GetProductProvider($arBasket)) { $arFields = $productProvider::DeliverProduct(array("PRODUCT_ID" => $arBasket["PRODUCT_ID"], "USER_ID" => $arOrder["USER_ID"], "PAID" => $bPaid, "ORDER_ID" => $orderID, 'BASKET_ID' => $arBasket['ID'])); } else { $arFields = CSaleBasket::ExecuteCallbackFunction($arBasket["PAY_CALLBACK_FUNC"], $arBasket["MODULE"], $arBasket["PRODUCT_ID"], $arOrder["USER_ID"], $bPaid, $orderID, $arBasket["QUANTITY"]); } if ($arFields && is_array($arFields) && count($arFields) > 0) { $arFields["ORDER_ID"] = $orderID; $arFields["REMAINING_ATTEMPTS"] = Defined("SALE_PROC_REC_ATTEMPTS") ? SALE_PROC_REC_ATTEMPTS : 3; $arFields["SUCCESS_PAYMENT"] = "Y"; if ($recurringID > 0) { CSaleRecurring::Update($recurringID, $arFields); } else { CSaleRecurring::Add($arFields); } } elseif ($recurringID > 0) { CSaleRecurring::Delete($recurringID); } } else { /** @var $productProvider IBXSaleProductProvider */ if ($productProvider = CSaleBasket::GetProductProvider($arBasket)) { $productProvider::DeliverProduct(array("PRODUCT_ID" => $arBasket["PRODUCT_ID"], "USER_ID" => $arOrder["USER_ID"], "PAID" => $bPaid, "ORDER_ID" => $orderID, 'BASKET_ID' => $arBasket['ID'])); } else { CSaleBasket::ExecuteCallbackFunction($arBasket["PAY_CALLBACK_FUNC"], $arBasket["MODULE"], $arBasket["PRODUCT_ID"], $arOrder["USER_ID"], $bPaid, $orderID, $arBasket["QUANTITY"]); } $dbRecur = CSaleRecurring::GetList(array(), array("USER_ID" => $arOrder["USER_ID"], "PRODUCT_ID" => $arBasket["PRODUCT_ID"], "MODULE" => $arBasket["MODULE"])); while ($arRecur = $dbRecur->Fetch()) { CSaleRecurring::Delete($arRecur["ID"]); } } } } } }
function _Delete($ID) { global $DB, $USER_FIELD_MANAGER; $ID = IntVal($ID); $bSuccess = True; foreach(GetModuleEvents("sale", "OnBeforeOrderDelete", true) as $arEvent) if (ExecuteModuleEventEx($arEvent, Array($ID))===false) return false; $DB->StartTransaction(); if ($bSuccess) { $dbBasket = CSaleBasket::GetList(array(), array("ORDER_ID" => $ID)); while ($arBasket = $dbBasket->Fetch()) { if (CSaleBasketHelper::isSetItem($arBasket)) // set items are deleted when parent is deleted continue; $bSuccess = CSaleBasket::Delete($arBasket["ID"]); if (!$bSuccess) break; } } if ($bSuccess) { $dbRecurring = CSaleRecurring::GetList(array(), array("ORDER_ID" => $ID)); while ($arRecurring = $dbRecurring->Fetch()) { $bSuccess = CSaleRecurring::Delete($arRecurring["ID"]); if (!$bSuccess) break; } } if ($bSuccess) $bSuccess = CSaleOrderPropsValue::DeleteByOrder($ID); if ($bSuccess) $bSuccess = CSaleOrderTax::DeleteEx($ID); if($bSuccess) $bSuccess = CSaleUserTransact::DeleteByOrder($ID); if ($bSuccess) unset($GLOBALS["SALE_ORDER"]["SALE_ORDER_CACHE_".$ID]); if ($bSuccess) $bSuccess = $DB->Query("DELETE FROM b_sale_order WHERE ID = ".$ID."", true); if ($bSuccess) $USER_FIELD_MANAGER->Delete("ORDER", $ID); if ($bSuccess) $DB->Commit(); else $DB->Rollback(); foreach(GetModuleEvents("sale", "OnOrderDelete", true) as $arEvent) ExecuteModuleEventEx($arEvent, Array($ID, $bSuccess)); return $bSuccess; }
if (strlen($apply) <= 0) { LocalRedirect("/bitrix/admin/sale_recurring_admin.php?lang=" . LANGUAGE_ID . GetFilterParams("filter_", false)); } } } else { $bVarsFromForm = true; } } require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/sale/prolog.php"; if ($ID > 0) { $APPLICATION->SetTitle(GetMessage("SRE_TITLE_UPDATE")); } else { $APPLICATION->SetTitle(GetMessage("SRE_TITLE_ADD")); } require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php"; $dbRecurring = CSaleRecurring::GetList(array(), array("ID" => $ID), false, false, array("ID", "USER_ID", "MODULE", "PRODUCT_ID", "PRODUCT_NAME", "PRODUCT_URL", "PRODUCT_PRICE_ID", "RECUR_SCHEME_TYPE", "RECUR_SCHEME_LENGTH", "WITHOUT_ORDER", "PRICE", "CURRENCY", "ORDER_ID", "CANCELED", "CALLBACK_FUNC", "PRODUCT_PROVIDER_CLASS", "DESCRIPTION", "TIMESTAMP_X", "PRIOR_DATE", "NEXT_DATE", "REMAINING_ATTEMPTS", "SUCCESS_PAYMENT", "USER_LOGIN", "USER_NAME", "USER_LAST_NAME", "CANCELED_REASON")); if (!$dbRecurring->ExtractFields("str_")) { if ($saleModulePermissions < "W") { $errorMessage .= GetMessage("SRE_NO_PERMS2ADD") . ".<br>"; } $ID = 0; $str_CANCELED = "N"; $str_REMAINING_ATTEMPTS = Defined("SALE_PROC_REC_ATTEMPTS") ? SALE_PROC_REC_ATTEMPTS : 3; $str_SUCCESS_PAYMENT = "Y"; } if ($bVarsFromForm) { $DB->InitTableVarsForEdit("b_sale_recurring", "", "str_"); } $aMenu = array(array("TEXT" => GetMessage("SREN_2FLIST"), "ICON" => "btn_list", "LINK" => "/bitrix/admin/sale_recurring_admin.php?lang=" . LANGUAGE_ID . GetFilterParams("filter_"))); if ($ID > 0 && $saleModulePermissions >= "U") { $aMenu[] = array("SEPARATOR" => "Y");
public static function AgentCheckRecurring() { $bTmpUser = False; if (!isset($GLOBALS["USER"]) || !is_object($GLOBALS["USER"])) { $bTmpUser = True; $GLOBALS["USER"] = new CUser; } CSaleRecurring::CheckRecurring(); global $pPERIOD; if (defined("SALE_PROC_REC_FREQUENCY") && IntVal(SALE_PROC_REC_FREQUENCY) > 0) $pPERIOD = IntVal(SALE_PROC_REC_FREQUENCY); else $pPERIOD = 7200; if ($bTmpUser) { unset($GLOBALS["USER"]); } return "CSaleRecurring::AgentCheckRecurring();"; }
function Add($arFields) { global $DB; if (!CSaleRecurring::CheckFields("ADD", $arFields, 0)) { return false; } $arInsert = $DB->PrepareInsert("b_sale_recurring", $arFields); $strSql = "INSERT INTO b_sale_recurring(" . $arInsert[0] . ") " . "VALUES(" . $arInsert[1] . ")"; $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); $ID = IntVal($DB->LastID()); return $ID; }
ShowError(GetMessage("SALE_MODULE_NOT_INSTALL")); return; } if (!$USER->IsAuthorized()) { $APPLICATION->AuthForm(GetMessage("SALE_ACCESS_DENIED")); } $arParams["PATH_TO_CANCEL"] = Trim($arParams["PATH_TO_CANCEL"]); if (strlen($arParams["PATH_TO_CANCEL"]) <= 0) { $arParams["PATH_TO_CANCEL"] = htmlspecialcharsbx($APPLICATION->GetCurPage() . "?ID=#ID#"); } $arParams["PER_PAGE"] = intval($arParams["PER_PAGE"]) <= 0 ? 20 : intval($arParams["PER_PAGE"]); $arParams["SET_TITLE"] = $arParams["SET_TITLE"] == "N" ? "N" : "Y"; if ($arParams["SET_TITLE"] == 'Y') { $APPLICATION->SetTitle(GetMessage("SPSL_DEFAULT_TITLE")); } $by = strlen($_REQUEST["by"]) > 0 ? $_REQUEST["by"] : "ID"; $order = strlen($_REQUEST["order"]) > 0 ? $_REQUEST["order"] : "DESC"; $dbRecurring = CSaleRecurring::GetList(array($by => $order), array("USER_ID" => IntVal($USER->GetID())), false, false, array("ID", "USER_ID", "MODULE", "PRODUCT_ID", "PRODUCT_NAME", "PRODUCT_URL", "PRODUCT_PRICE_ID", "RECUR_SCHEME_TYPE", "RECUR_SCHEME_LENGTH", "WITHOUT_ORDER", "PRICE", "CURRENCY", "ORDER_ID", "CANCELED", "CALLBACK_FUNC", "DESCRIPTION", "TIMESTAMP_X", "PRIOR_DATE", "NEXT_DATE", "REMAINING_ATTEMPTS", "SUCCESS_PAYMENT")); $dbRecurring->NavStart($arParams["PER_PAGE"]); $arResult["NAV_STRING"] = $dbRecurring->GetPageNavString(GetMessage("SPSL_PAGES")); $arResult["RECURRING"] = array(); while ($arRecurring = $dbRecurring->GetNext()) { $arResultTmp = array(); $arResultTmp = $arRecurring; if (array_key_exists($arRecurring["RECUR_SCHEME_TYPE"], $GLOBALS["SALE_TIME_PERIOD_TYPES"])) { $arResultTmp["SALE_TIME_PERIOD_TYPES"] = $GLOBALS["SALE_TIME_PERIOD_TYPES"][$arRecurring["RECUR_SCHEME_TYPE"]]; } $arResultTmp["URL_TO_CANCEL"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_CANCEL"], array("ID" => $arRecurring["ID"])); $arResult["RECURRING"][] = $arResultTmp; } $this->IncludeComponentTemplate();