public static function CreateMailTemplate($ID) { $ID = trim($ID); if ('' == $ID) { return false; } if (!($arStatus = CSaleStatus::GetByID($ID, LANGUAGE_ID))) { return false; } $eventType = new CEventType(); $eventMessage = new CEventMessage(); $eventType->Delete("SALE_STATUS_CHANGED_" . $ID); $b = 'sort'; $o = 'asc'; $dbSiteList = CSite::GetList($b, $o); while ($arSiteList = $dbSiteList->Fetch()) { IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/sale/general/status.php", $arSiteList["LANGUAGE_ID"]); $arStatusLang = CSaleStatus::GetLangByID($ID, $arSiteList["LANGUAGE_ID"]); $dbEventType = $eventType->GetList(array("EVENT_NAME" => "SALE_STATUS_CHANGED_" . $ID, "LID" => $arSiteList["LANGUAGE_ID"])); if (!($arEventType = $dbEventType->Fetch())) { $str = ""; $str .= "#ORDER_ID# - " . GetMessage("SKGS_ORDER_ID") . "\n"; $str .= "#ORDER_DATE# - " . GetMessage("SKGS_ORDER_DATE") . "\n"; $str .= "#ORDER_STATUS# - " . GetMessage("SKGS_ORDER_STATUS") . "\n"; $str .= "#EMAIL# - " . GetMessage("SKGS_ORDER_EMAIL") . "\n"; $str .= "#ORDER_DESCRIPTION# - " . GetMessage("SKGS_STATUS_DESCR") . "\n"; $str .= "#TEXT# - " . GetMessage("SKGS_STATUS_TEXT") . "\n"; $str .= "#SALE_EMAIL# - " . GetMessage("SKGS_SALE_EMAIL") . "\n"; $eventTypeID = $eventType->Add(array("LID" => $arSiteList["LANGUAGE_ID"], "EVENT_NAME" => "SALE_STATUS_CHANGED_" . $ID, "NAME" => GetMessage("SKGS_CHANGING_STATUS_TO") . " \"" . $arStatusLang["NAME"] . "\"", "DESCRIPTION" => $str)); } $dbEventMessage = $eventMessage->GetList($b = "", $o = "", array("EVENT_NAME" => "SALE_STATUS_CHANGED_" . $ID, "SITE_ID" => $arSiteList["LID"])); if (!($arEventMessage = $dbEventMessage->Fetch())) { $subject = GetMessage("SKGS_STATUS_MAIL_SUBJ"); $message = GetMessage("SKGS_STATUS_MAIL_BODY1"); $message .= "------------------------------------------\n\n"; $message .= GetMessage("SKGS_STATUS_MAIL_BODY2"); $message .= GetMessage("SKGS_STATUS_MAIL_BODY3"); $message .= "#ORDER_STATUS#\n"; $message .= "#ORDER_DESCRIPTION#\n"; $message .= "#TEXT#\n\n"; $message .= "#SITE_NAME#\n"; $arFields = array("ACTIVE" => "Y", "EVENT_NAME" => "SALE_STATUS_CHANGED_" . $ID, "LID" => $arSiteList["LID"], "EMAIL_FROM" => "#SALE_EMAIL#", "EMAIL_TO" => "#EMAIL#", "SUBJECT" => $subject, "MESSAGE" => $message, "BODY_TYPE" => "text"); $eventMessageID = $eventMessage->Add($arFields); } } return true; }
$strError .= $ex->GetString() . ".<br>"; } } else { CSaleStatus::CreateMailTemplate($ID); } } } if (strlen($strError) > 0) { $bInitVars = True; } if (strlen($save) > 0 && strlen($strError) <= 0) { LocalRedirect("sale_status.php?lang=" . LANG . GetFilterParams("filter_", false)); } } if (strlen($ID) > 0) { if (!($arStatus = CSaleStatus::GetByID($ID, LANG))) { $ID = ""; $str_ID = ""; } else { foreach ($arStatus as $key => $value) { ${"str_" . $key} = htmlspecialcharsbx($value); } } } if ($bInitVars) { $DB->InitTableVarsForEdit("b_sale_status", "", "str_"); $str_NEW_ID = $DB->ForSql($NEW_ID, 1); } if (strlen($ID) > 0) { $sDocTitle = GetMessage("SALE_EDIT_RECORD", array("#ID#" => $ID)); } else {
function StatusOrder($ID, $val) { global $DB, $USER; $ID = IntVal($ID); $val = trim($val); foreach (GetModuleEvents("sale", "OnSaleBeforeStatusOrder", true) as $arEvent) { if (ExecuteModuleEventEx($arEvent, array($ID, $val)) === false) { return false; } } $arFields = array("STATUS_ID" => $val, "=DATE_STATUS" => $DB->GetNowFunction(), "EMP_STATUS_ID" => IntVal($USER->GetID()) > 0 ? IntVal($USER->GetID()) : false); $res = CSaleOrder::Update($ID, $arFields); unset($GLOBALS["SALE_ORDER"]["SALE_ORDER_CACHE_" . $ID]); foreach (GetModuleEvents("sale", "OnSaleStatusOrder", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array($ID, $val)); } CTimeZone::Disable(); $arOrder = CSaleOrder::GetByID($ID); CTimeZone::Enable(); $userEmail = ""; $dbOrderProp = CSaleOrderPropsValue::GetList(array(), array("ORDER_ID" => $ID, "PROP_IS_EMAIL" => "Y")); if ($arOrderProp = $dbOrderProp->Fetch()) { $userEmail = $arOrderProp["VALUE"]; } if (strlen($userEmail) <= 0) { $dbUser = CUser::GetByID($arOrder["USER_ID"]); if ($arUser = $dbUser->Fetch()) { $userEmail = $arUser["EMAIL"]; } } $dbSite = CSite::GetByID($arOrder["LID"]); $arSite = $dbSite->Fetch(); $arStatus = CSaleStatus::GetByID($arOrder["STATUS_ID"], $arSite["LANGUAGE_ID"]); $arFields = array("ORDER_ID" => $ID, "ORDER_DATE" => $arOrder["DATE_INSERT_FORMAT"], "ORDER_STATUS" => $arStatus["NAME"], "EMAIL" => $userEmail, "ORDER_DESCRIPTION" => $arStatus["DESCRIPTION"], "TEXT" => "", "SALE_EMAIL" => COption::GetOptionString("sale", "order_email", "order@" . $_SERVER["SERVER_NAME"])); foreach (GetModuleEvents("sale", "OnSaleStatusEMail", true) as $arEvent) { $arFields["TEXT"] = ExecuteModuleEventEx($arEvent, array($ID, $arStatus["ID"])); } $eventName = "SALE_STATUS_CHANGED_" . $arOrder["STATUS_ID"]; $bSend = true; foreach (GetModuleEvents("sale", "OnOrderStatusSendEmail", true) as $arEvent) { if (ExecuteModuleEventEx($arEvent, array($ID, &$eventName, &$arFields, $arOrder["STATUS_ID"])) === false) { $bSend = false; } } if ($bSend) { $eventMessage = new CEventMessage(); $dbEventMessage = $eventMessage->GetList($b = "", $o = "", array("EVENT_NAME" => $eventName, "SITE_ID" => $arOrder["LID"])); if (!($arEventMessage = $dbEventMessage->Fetch())) { $eventName = "SALE_STATUS_CHANGED"; } $event = new CEvent(); $event->Send($eventName, $arOrder["LID"], $arFields, "N"); } return $res; }
echo "[" . $str_LID . "] "; $db_lang = CLang::GetByID($str_LID); if ($arLang = $db_lang->GetNext()) { echo $arLang["NAME"]; } ?> </td> </tr> <tr> <td><?php echo GetMessage("P_ORDER_STATUS"); ?> :</td> <td> <?php $ar_status = CSaleStatus::GetByID($str_STATUS_ID); ?> [<?php echo $ar_status["ID"]; ?> ] <?php echo htmlspecialcharsbx($ar_status["NAME"]); ?> </td> </tr> <tr> <td> <?php echo GetMessage("P_ORDER_CANCELED"); ?> / <?php
array("ID", "NAME") ); $arStatusList = $dbStatusList->GetNext(); } if ($row->bEditMode !== true || $row->bEditMode && !$arStatusList) { $fieldValue = ""; $fieldValueTmp = ""; if (in_array("STATUS_ID", $arVisibleColumns)) { if (!isset($LOCAL_STATUS_CACHE[$arOrder["STATUS_ID"]]) || empty($LOCAL_STATUS_CACHE[$arOrder["STATUS_ID"]])) { if ($arStatus = CSaleStatus::GetByID($arOrder["STATUS_ID"])) $LOCAL_STATUS_CACHE[$arOrder["STATUS_ID"]] = htmlspecialcharsEx($arStatus["NAME"]); } $fieldValueTmp .= "["; if ($saleModulePermissions >= "W") $fieldValueTmp .= '<a href="/bitrix/admin/sale_status_edit.php?ID='.$arOrder["STATUS_ID"].'&lang='.LANGUAGE_ID.'">'; $fieldValueTmp .= $arOrder["STATUS_ID"]; if ($saleModulePermissions >= "W") $fieldValueTmp .= "</a>"; $fieldValueTmp .= "] ".$LOCAL_STATUS_CACHE[$arOrder["STATUS_ID"]]; $fieldValue .= '<span id="status_order_'.$arOrder["ID"].'">'.$LOCAL_STATUS_CACHE[$arOrder["STATUS_ID"]].'</span>'; $fieldValueTmp .= "<br />".$arOrder["DATE_STATUS"];
/** * @param Main\Event $event * * @return Main\EventResult * @throws Main\ObjectNotFoundException */ public static function onSaleOrderStatusChangeSendEmail(Main\Event $event) { $parameters = $event->getParameters(); /** @var Sale\Order $basketItem */ $order = $parameters['ENTITY']; $value = $parameters['VALUE']; $oldValue = $parameters['OLD_VALUE']; if (!$order instanceof Sale\Order) { return new Main\EventResult(Main\EventResult::ERROR, new Sale\ResultError(Main\Localization\Loc::getMessage('SALE_EVENT_COMPATIBILITY_ORDER_STATUS_CHANGE_WRONG_ORDER'), 'SALE_EVENT_COMPATIBILITY_ORDER_STATUS_CHANGE_WRONG_ORDER'), 'sale'); } $orderFields = array(); /** @var Sale\Result $resultOrderFields */ $resultOrderFields = OrderCompatibility::getOrderFields($order); if ($resultOrderFields->isSuccess()) { if ($orderFieldsResultData = $resultOrderFields->getData()) { if (!empty($orderFieldsResultData['ORDER_FIELDS']) && is_array($orderFieldsResultData['ORDER_FIELDS'])) { $orderFields = $orderFieldsResultData['ORDER_FIELDS']; } } } \CSaleMobileOrderPush::send(static::EVENT_COMPATIBILITY_MOBILE_PUSH_ORDER_STATUS_CHANGE, array("ORDER" => $orderFields)); $propertyCollection = $order->getPropertyCollection(); $userEmail = ""; /** @var Sale\PropertyValue $userEmailProperty */ if ($userEmailProperty = $propertyCollection->getUserEmail()) { $userEmail = $userEmailProperty->getValue(); } if (strval(trim($userEmail)) == '') { $userRes = \CUser::GetByID($order->getUserId()); if ($userData = $userRes->fetch()) { $userEmail = $userData["EMAIL"]; } } static $cacheSiteData = array(); if (!isset($cacheSiteData[$order->getSiteId()])) { $siteRes = \CSite::GetByID($order->getSiteId()); $siteData = $siteRes->Fetch(); } else { $siteData = $cacheSiteData[$order->getSiteId()]; } if (($statusData = \CSaleStatus::GetByID($order->getField("STATUS_ID"), $siteData['LANGUAGE_ID'])) && $statusData['NOTIFY'] == "Y") { $fields = array("ORDER_ID" => $order->getField("ACCOUNT_NUMBER"), "ORDER_DATE" => $order->getField("DATE_INSERT")->toString(), "ORDER_STATUS" => $statusData["NAME"], "EMAIL" => $userEmail, "ORDER_DESCRIPTION" => $statusData["DESCRIPTION"], "TEXT" => "", "SALE_EMAIL" => Main\Config\Option::get("sale", "order_email", "order@" . $_SERVER["SERVER_NAME"])); foreach (GetModuleEvents("sale", static::EVENT_COMPATIBILITY_ORDER_STATUS_EMAIL, true) as $oldEvent) { $fields["TEXT"] = ExecuteModuleEventEx($oldEvent, array($order->getId(), $statusData["ID"])); } $eventName = "SALE_STATUS_CHANGED_" . $order->getField("STATUS_ID"); $isSend = true; foreach (GetModuleEvents("sale", static::EVENT_COMPATIBILITY_ORDER_STATUS_SEND_EMAIL, true) as $oldEvent) { if (ExecuteModuleEventEx($oldEvent, array($order->getId(), &$eventName, &$fields, $order->getField("STATUS_ID"))) === false) { $isSend = false; } } if ($isSend) { $b = ''; $o = ''; $eventMessage = new \CEventMessage(); $eventMessageRes = $eventMessage->GetList($b, $o, array("EVENT_NAME" => $eventName, "SITE_ID" => $order->getSiteId(), 'ACTIVE' => 'Y')); if (!($eventMessageData = $eventMessageRes->Fetch())) { $eventName = "SALE_STATUS_CHANGED"; } unset($o, $b); $event = new \CEvent(); $event->Send($eventName, $order->getSiteId(), $fields, "N"); } } return new Main\EventResult(Main\EventResult::SUCCESS, null, 'sale'); }
protected function mapYandexStatusToOrder($order, $yandexStatus, $cancelReason = "") { global $APPLICATION; if (!is_array($order) || !isset($order["ID"]) || strlen($yandexStatus) <= 0) { return false; } $settings = $this->getSettingsBySiteId($order["LID"]); if (!isset($settings["STATUS_IN"][$yandexStatus]) || strlen($settings["STATUS_IN"][$yandexStatus]) <= 0) { return false; } $result = false; $bitrixStatus = $settings["STATUS_IN"][$yandexStatus]; switch ($bitrixStatus) { /* flags */ case "CANCELED": $errorMessageTmp = ""; $result = CSaleOrder::CancelOrder($order["ID"], "Y", $cancelReason); if (!$result) { if ($ex = $APPLICATION->GetException()) { if ($ex->GetID() != "ALREADY_FLAG") { $errorMessageTmp .= $ex->GetString(); } } else { $errorMessageTmp .= GetMessage("ERROR_CANCEL_ORDER") . ". "; } } if ($errorMessageTmp != "") { $this->log(self::LOG_LEVEL_ERROR, "YMARKET_INCOMING_ORDER_STATUS", $order["XML_ID"], $errorMessageTmp); } else { $this->log(self::LOG_LEVEL_INFO, "YMARKET_INCOMING_ORDER_STATUS", $order["XML_ID"], GetMessage("SALE_YMH_INCOMING_ORDER_STATUS_CANCELED") . ": " . $order["ID"]); } break; case "ALLOW_DELIVERY": $result = CSaleOrder::DeliverOrder($order["ID"], "Y"); break; case "PAYED": $result = CSaleOrder::PayOrder($order["ID"], "Y"); break; case "DEDUCTED": $result = CSaleOrder::DeductOrder($order["ID"], "Y"); break; /* statuses */ /* statuses */ default: if (CSaleStatus::GetByID($bitrixStatus)) { $result = CSaleOrder::StatusOrder($order["ID"], $bitrixStatus); } break; } $this->log($result ? self::LOG_LEVEL_INFO : self::LOG_LEVEL_ERROR, "YMARKET_ORDER_STATUS_CHANGE", $order["ID"], ($result ? GetMessage("SALE_YMH_LOG_TYPE_ORDER_STATUS_CHANGE_OK") : GetMessage("SALE_YMH_LOG_TYPE_ORDER_STATUS_CHANGE_ERROR")) . " (" . $bitrixStatus . ")"); return $result; }
public static function FormatOrderStatusChanged($arData) { $info = GetMessage("SOC_ORDER_STATUS_CHANGED_INFO"); foreach ($arData as $param => $value) { if ($param == "STATUS_ID") { $res = CSaleStatus::GetByID($value); $value = "\"" . $res["NAME"] . "\""; } $info = str_replace("#" . $param . "#", $value, $info); } return array("NAME" => GetMessage("SOC_ORDER_STATUS_CHANGED"), "INFO" => $info); }
?> </font> </td> </tr> //--> <tr> <td align="right" width="40%" class="tablebody"> <font class="tablefieldtext"><?php echo GetMessage("STPOD_ORDER_STATUS"); ?> </font> </td> <td align="left" width="60%" class="tablebody"> <font class="tablebodytext"> <?php $arCurrentStatus = CSaleStatus::GetByID($arOrder["STATUS_ID"]); echo $arCurrentStatus["NAME"] . GetMessage("STPOD_ORDER_FROM") . $arOrder["DATE_STATUS"] . ")"; ?> </font> </td> </tr> <tr> <td align="right" width="40%" class="tablebody"> <font class="tablefieldtext"><?php echo GetMessage("P_ORDER_PRICE"); ?> :</font> </td> <td align="left" width="60%" class="tablebody"> <font class="tablebodytext"><?php echo "<b>" . SaleFormatCurrency($arOrder["PRICE"], $arOrder["CURRENCY"]) . "</b>";
<?php ini_set("session.gc_maxlifetime", 3600); ini_set("max_execution_time", 3600); require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php"; $result = 4; $status_str = ""; $ORDER_ID = (int) $_GET["id"]; if (!($arOrder = CSaleOrder::GetByID($ORDER_ID))) { $result = "Заказ с кодом " . $ORDER_ID . " не найден"; } else { $result = $arOrder["STATUS_ID"]; if ($arStatus = CSaleStatus::GetByID($result)) { $status_str = $arStatus["NAME"]; } } echo json_encode(array("result" => "asasas", "msg" => $result, "msga" => $status_str)); exit;
$arFilter = array("LID" => LANG); $arGroupByTmp = false; if ($saleModulePermissions < "W") { $arFilter["GROUP_ID"] = $GLOBALS["USER"]->GetUserGroupArray(); $arFilter["PERM_STATUS_FROM"] = "Y"; $arFilter["ID"] = $str_STATUS_ID; $arGroupByTmp = array("ID", "NAME", "MAX" => "PERM_STATUS_FROM"); } $dbStatusList = CSaleStatus::GetList(array(), $arFilter, $arGroupByTmp, false, array("ID", "NAME", "PERM_STATUS_FROM")); $arStatusList = $dbStatusList->GetNext(); ?> <div id="viewStatusDIV" style="display: block;"> <?php $arCurrentStatus = CSaleStatus::GetByID($str_STATUS_ID); echo "["; if ($saleModulePermissions >= "W") { echo "<a href=\"/bitrix/admin/sale_status_edit.php?ID=" . $str_STATUS_ID . "&lang=" . LANG . "\">"; } echo $str_STATUS_ID; if ($saleModulePermissions >= "W") { echo "</a>"; } echo "] " . htmlspecialcharsEx($arCurrentStatus["NAME"]) . " "; echo $str_DATE_STATUS; if (IntVal($str_EMP_STATUS_ID) > 0) { if (!isset($LOCAL_PAYED_USER_CACHE[$str_EMP_STATUS_ID]) || !is_array($LOCAL_PAYED_USER_CACHE[$str_EMP_STATUS_ID])) { $dbUser = CUser::GetByID($str_EMP_STATUS_ID); if ($arUser = $dbUser->Fetch()) { $LOCAL_PAYED_USER_CACHE[$str_EMP_STATUS_ID] = htmlspecialcharsEx($arUser["NAME"] . (strlen($arUser["NAME"]) <= 0 || strlen($arUser["LAST_NAME"]) <= 0 ? "" : " ") . $arUser["LAST_NAME"]);
public static function getByID($statusID) { self::ensureLanguageDefined(); return CSaleStatus::GetByID($statusID, self::$languageID); }