public static function getListWithInner(array $parameters = array()) { if (isset($parameters['filter'])) { $parameters['filter'] = array('LOGIC' => 'OR', $parameters['filter'], array('ID' => PaySystemInner::getId())); } return parent::getList($parameters); }
public function checkByShipment(\Bitrix\Sale\Shipment $shipment, array $restrictionParams, $deliveryId = 0) { if (intval($deliveryId) <= 0) { return true; } $paymentsCount = 0; $paySystemId = 0; /** @var \Bitrix\Sale\Payment $payment */ foreach ($shipment->getCollection()->getOrder()->getPaymentCollection() as $payment) { if ($payment->getId() != PaySystemInner::getId()) { $paymentsCount++; $paySystemId = $payment->getPaymentSystemId(); } } if ($paymentsCount <= 0 || $paymentsCount > 1 || $paySystemId <= 0) { return true; } return $this->check($paySystemId, $restrictionParams, $deliveryId); }
/** * @param null $order * @return array */ public static function getPaySystemList($order = null) { $result = array(); $result[] = array('ID' => '0', 'NAME' => Loc::getMessage('SALE_ORDER_PAYMENT_NO_PAYSYSTEM')); if ($order) { self::$order = $order; } else { if (!self::$order) { return $result; } } $res = \CSaleUserAccount::getList(array(), array('USER_ID' => self::$order->getUserId(), 'CURRENCY' => self::$order->getCurrency(), 'LOCKED' => 'N'), false, false, array('CURRENT_BUDGET')); $userAccount = $res->Fetch(); $dbRes = PaySystemServiceTable::getListWithInner(array('select' => array('ID', 'NAME'), 'filter' => array('=ACTION.PERSON_TYPE_ID' => self::$order->getPersonTypeId(), '=ACTION.HAVE_PAYMENT' => 'Y', '=ACTIVE' => 'Y'), 'order' => array('SORT' => 'ASC'))); while ($paySystem = $dbRes->fetch()) { if ($userAccount['CURRENT_BUDGET'] <= 0 && $paySystem["ID"] == PaySystemInner::getId()) { continue; } $result[] = array('ID' => $paySystem['ID'], 'NAME' => $paySystem["NAME"] . " [" . $paySystem["ID"] . "]"); } return $result; }
/** * Paid from internal account * * @param Sale\Order $order Entity of the order. * @param bool $pay Flag making donations to internal account. * @param null $paidFormUserBudget * @return Sale\Result * @throws Main\ObjectNotFoundException * @throws \Bitrix\Main\ArgumentOutOfRangeException * @throws \Bitrix\Main\InvalidOperationException */ public static function payFromBudget(Sale\Order $order, $pay, $paidFormUserBudget = null) { $result = new Sale\Result(); /** @var Sale\Payment|null $paymentOuter */ $paymentInner = null; /** @var Sale\Payment|null $paymentOuter */ $paymentOuter = null; /** @var Sale\PaymentCollection $paymentCollection */ if (!($paymentCollection = $order->getPaymentCollection())) { throw new Main\ObjectNotFoundException('Entity "PaymentCollection" not found'); } if (count($paymentCollection) > 2) { return $result; } $needSum = $order->getPrice() - $order->getSumPaid(); if ($needSum > 0) { /** @var Sale\Payment $payment */ foreach ($paymentCollection as $payment) { if (!$payment->isInner()) { $paymentOuter = $payment; break; } } if (!$pay || $pay && $paidFormUserBudget === false) { /** @var Sale\Payment $paymentInner */ if (!($paymentInner = $paymentCollection->getInnerPayment())) { throw new Main\ObjectNotFoundException('Entity inner "Payment" not found'); } $userBudget = Sale\Internals\UserBudgetPool::getUserBudget($order->getUserId(), $order->getCurrency()); $setSum = $userBudget; if ($userBudget >= $needSum) { $setSum = $needSum; } if ($paymentInner->getId() == 0) { $paymentInnerFields = array('SUM' => $setSum, 'CURRENCY' => $order->getCurrency(), 'DATE_BILL' => new Main\Type\DateTime()); $r = $paymentInner->setFields($paymentInnerFields); if (!$r->isSuccess()) { $result->addErrors($r->getErrors()); } } else { if ($paymentInner->getSum() < $needSum) { $paymentInner->setField('SUM', $needSum - $paymentInner->getSum()); } } if ($pay && $paidFormUserBudget === false) { $paymentOuter->setField('SUM', $needSum - $setSum); } $payment = $paymentInner; } else { $payment = $paymentOuter; } if ($pay) { if ($payment === null) { $paySystemId = static::getDefaultPaySystemId($order->getPersonTypeId()); /** @var Sale\PaySystemService $paysystem */ if ($paysystem = Sale\PaySystemService::load($paySystemId)) { $payment = Sale\Payment::create($paymentCollection, $paysystem); $payment->setField('SUM', $needSum); $payment->setField('DATE_BILL', new Main\Type\DateTime()); $paymentCollection->addItem($payment); } } $operationPayment = $payment; if ($paidFormUserBudget === false) { $operationPayment = $paymentOuter; } $r = Sale\Internals\PaySystemInner::createOperation($order, $operationPayment, Sale\Internals\PaySystemInner::OPERATION_CREDIT); if (!$r->isSuccess()) { $result->addErrors($r->getErrors()); } } if ($payment->isReturn() && $payment->isInner()) { /** @var Sale\Result $r */ $r = $payment->setReturn('N'); } else { /** @var Sale\Result $r */ $r = $payment->setPaid('Y'); if ($r->isSuccess()) { if ($pay) { $operationPayment = $payment; if ($paidFormUserBudget === false) { $operationPayment = $paymentOuter; /** @var Sale\Result $resultPayment */ $resultPayment = $paymentOuter->setPaid('Y'); if (!$resultPayment->isSuccess()) { $result->addErrors($resultPayment->getErrors()); } } /** @var Sale\Result $r */ $r = Sale\Internals\PaySystemInner::createOperation($order, $operationPayment, Sale\Internals\PaySystemInner::OPERATION_DEBIT); } } else { $result->addErrors($r->getErrors()); } } if (!$r->isSuccess()) { $result->addErrors($r->getErrors()); } } $result->setData(array('PAID_FROM_BUDGET' => $paidFormUserBudget)); return $result; }
if ($ex = $APPLICATION->GetException()) { $lAdmin->AddGroupError($ex->GetString(), $ID); } else { $lAdmin->AddGroupError(GetMessage("SPSAN_ERROR_UPDATE"), $ID); } } break; } } } $arPersonTypeList = array(); $dbPersonType = CSalePersonType::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array()); while ($arPersonType = $dbPersonType->Fetch()) { $arPersonTypeList[$arPersonType["ID"]] = $arPersonType["NAME"]; } $arFilter["!ID"] = \Bitrix\Sale\Internals\PaySystemInner::getId(); $dbResultList = CSalePaySystem::GetList(array($by => $order), $arFilter, false, false, array("ID", "LID", "CURRENCY", "NAME", "ACTIVE", "SORT", "DESCRIPTION")); $siteList = array(); $rsSites = CSite::GetList($b = "sort", $o = "asc", array()); while ($arRes = $rsSites->Fetch()) { $siteList[$arRes['ID']] = $arRes['NAME']; } $dbResultList = new CAdminResult($dbResultList, $sTableID); $dbResultList->NavStart(); $lAdmin->NavText($dbResultList->GetNavPrint(GetMessage("SALE_PRLIST"))); $lAdmin->AddHeaders(array(array("id" => "ID", "content" => "ID", "sort" => "id", "default" => true), array("id" => "NAME", "content" => GetMessage("SALE_NAME"), "sort" => "NAME", "default" => true), array("id" => "ACTIVE", "content" => GetMessage("SALE_ACTIVE"), "sort" => "ACTIVE", "default" => true), array("id" => "SORT", "content" => GetMessage("SALE_SORT"), "sort" => "SORT", "default" => true), array("id" => "LID", "content" => GetMessage('SALE_LID'), "sort" => "LID", "default" => false), array("id" => "CURRENCY", "content" => GetMessage("SALE_H_CURRENCY"), "sort" => "CURRENCY", "default" => false), array("id" => "DESCRIPTION", "content" => GetMessage("SALE_H_DESCRIPTION"), "default" => false), array("id" => "PERSON_TYPES", "content" => GetMessage("SALE_H_PERSON_TYPES"), "default" => false), array("id" => "ACTION_FILES", "content" => GetMessage("SALE_H_ACTION_FILES"), "default" => false))); $arVisibleColumns = $lAdmin->GetVisibleHeaderColumns(); while ($arCCard = $dbResultList->NavNext(true, "f_")) { $row =& $lAdmin->AddRow($f_ID, $arCCard, "sale_pay_system_edit.php?ID=" . $f_ID . "&lang=" . LANG, GetMessage("SALE_EDIT_DESCR")); $row->AddField("ID", "<a href=\"sale_pay_system_edit.php?ID=" . $f_ID . "&lang=" . LANG . "\">" . $f_ID . "</a>"); $row->AddField("NAME", $f_NAME);
/** * @return bool */ public function isExistsInnerPayment() { if ($paySystemId = Internals\PaySystemInner::getId()) { /** @var Payment $payment */ foreach ($this->collection as $payment) { if ($payment->getPaymentSystemId() == $paySystemId) { return true; } } } return false; }
/** * @return int|null */ protected static function getInnerPaySystemId() { if (static::$innerPaySystemId === null) { static::$innerPaySystemId = Internals\PaySystemInner::getId(); } return static::$innerPaySystemId; }
function ExportOrders2Xml($arFilter = array(), $nTopCount = 0, $currency = "", $crmMode = false, $time_limit = 0, $version = false, $arOptions = array()) { global $DB; $count = false; if (IntVal($nTopCount) > 0) { $count = array("nTopCount" => $nTopCount); } $bNewVersion = strlen($version) > 0; $bExportFromCrm = isset($arOptions["EXPORT_FROM_CRM"]) && $arOptions["EXPORT_FROM_CRM"] === "Y"; if (IntVal($time_limit) > 0) { //This is an optimization. We assume than no step can take more than one year. if ($time_limit > 0) { $end_time = time() + $time_limit; } else { $end_time = time() + 365 * 24 * 3600; } // One year //$version $lastOrderPrefix = "LAST_ORDER_ID"; if ($crmMode) { $lastOrderPrefix = md5(serialize($arFilter)); if (!empty($_SESSION["BX_CML2_EXPORT"][$lastOrderPrefix]) && IntVal($nTopCount) > 0) { $count["nTopCount"] = $count["nTopCount"] + count($_SESSION["BX_CML2_EXPORT"][$lastOrderPrefix]); } } else { if (IntVal($_SESSION["BX_CML2_EXPORT"][$lastOrderPrefix]) > 0) { $arFilter["<ID"] = $_SESSION["BX_CML2_EXPORT"][$lastOrderPrefix]; } } } $arResultStat = array("ORDERS" => 0, "CONTACTS" => 0, "COMPANIES" => 0); $accountNumberPrefix = COption::GetOptionString("sale", "1C_SALE_ACCOUNT_NUMBER_SHOP_PREFIX", ""); $dbPaySystem = CSalePaySystem::GetList(array("ID" => "ASC"), array("ACTIVE" => "Y"), false, false, array("ID", "NAME", "ACTIVE")); while ($arPaySystem = $dbPaySystem->Fetch()) { $paySystems[$arPaySystem["ID"]] = $arPaySystem["NAME"]; } $dbDelivery = CSaleDelivery::GetList(array("ID" => "ASC"), array("ACTIVE" => "Y"), false, false, array("ID", "NAME", "ACTIVE")); while ($arDelivery = $dbDelivery->Fetch()) { $delivery[$arDelivery["ID"]] = $arDelivery["NAME"]; } $rsDeliveryHandlers = CSaleDeliveryHandler::GetAdminList(array("SID" => "ASC")); while ($arHandler = $rsDeliveryHandlers->Fetch()) { if (is_array($arHandler["PROFILES"])) { foreach ($arHandler["PROFILES"] as $k => $v) { $delivery[$arHandler["SID"] . ":" . $k] = $v["TITLE"] . " (" . $arHandler["NAME"] . ")"; } } } $arStore = array(); $arMeasures = array(); if (CModule::IncludeModule("catalog")) { $dbList = CCatalogStore::GetList(array("SORT" => "DESC", "ID" => "ASC"), array("ACTIVE" => "Y", "ISSUING_CENTER" => "Y"), false, false, array("ID", "SORT", "TITLE", "ADDRESS", "DESCRIPTION", "PHONE", "EMAIL", "XML_ID")); while ($arStoreTmp = $dbList->Fetch()) { if (strlen($arStoreTmp["XML_ID"]) <= 0) { $arStoreTmp["XML_ID"] = $arStoreTmp["ID"]; } $arStore[$arStoreTmp["ID"]] = $arStoreTmp; } $dbList = CCatalogMeasure::getList(array(), array(), false, false, array("CODE", "MEASURE_TITLE")); while ($arList = $dbList->Fetch()) { $arMeasures[$arList["CODE"]] = $arList["MEASURE_TITLE"]; } } if (empty($arMeasures)) { $arMeasures[796] = GetMessage("SALE_EXPORT_SHTUKA"); } $dbExport = CSaleExport::GetList(); while ($arExport = $dbExport->Fetch()) { $arAgent[$arExport["PERSON_TYPE_ID"]] = unserialize($arExport["VARS"]); } $dateFormat = CSite::GetDateFormat("FULL"); if ($crmMode) { echo "<" . "?xml version=\"1.0\" encoding=\"UTF-8\"?" . ">\n"; $arCharSets = array(); $dbSitesList = CSite::GetList($b = "", $o = ""); while ($arSite = $dbSitesList->Fetch()) { $arCharSets[$arSite["ID"]] = $arSite["CHARSET"]; } } else { echo "<" . "?xml version=\"1.0\" encoding=\"windows-1251\"?" . ">\n"; } ?> <<?php echo GetMessage("SALE_EXPORT_COM_INFORMATION"); ?> <?php echo GetMessage("SALE_EXPORT_SHEM_VERSION"); ?> ="<?php echo $bNewVersion ? "2.08" : "2.05"; ?> " <?php echo GetMessage("SALE_EXPORT_SHEM_DATE_CREATE"); ?> ="<?php echo date("Y-m-d"); ?> T<?php echo date("G:i:s"); ?> " <?php echo GetMessage("SALE_EXPORT_DATE_FORMAT"); ?> ="<?php echo GetMessage("SALE_EXPORT_DATE_FORMAT_DF"); ?> =yyyy-MM-dd; <?php echo GetMessage("SALE_EXPORT_DATE_FORMAT_DLF"); ?> =DT" <?php echo GetMessage("SALE_EXPORT_DATE_FORMAT_DATETIME"); ?> ="<?php echo GetMessage("SALE_EXPORT_DATE_FORMAT_DF"); ?> =<?php echo GetMessage("SALE_EXPORT_DATE_FORMAT_TIME"); ?> ; <?php echo GetMessage("SALE_EXPORT_DATE_FORMAT_DLF"); ?> =T" <?php echo GetMessage("SALE_EXPORT_DEL_DT"); ?> ="T" <?php echo GetMessage("SALE_EXPORT_FORM_SUMM"); ?> ="<?php echo GetMessage("SALE_EXPORT_FORM_CC"); ?> =18; <?php echo GetMessage("SALE_EXPORT_FORM_CDC"); ?> =2; <?php echo GetMessage("SALE_EXPORT_FORM_CRD"); ?> =." <?php echo GetMessage("SALE_EXPORT_FORM_QUANT"); ?> ="<?php echo GetMessage("SALE_EXPORT_FORM_CC"); ?> =18; <?php echo GetMessage("SALE_EXPORT_FORM_CDC"); ?> =2; <?php echo GetMessage("SALE_EXPORT_FORM_CRD"); ?> =."> <?php $arOrder = array("ID" => "DESC"); if ($crmMode) { $arOrder = array("DATE_UPDATE" => "ASC"); } $arSelect = array("ID", "LID", "PERSON_TYPE_ID", "PAYED", "DATE_PAYED", "EMP_PAYED_ID", "CANCELED", "DATE_CANCELED", "EMP_CANCELED_ID", "REASON_CANCELED", "STATUS_ID", "DATE_STATUS", "PAY_VOUCHER_NUM", "PAY_VOUCHER_DATE", "EMP_STATUS_ID", "PRICE_DELIVERY", "ALLOW_DELIVERY", "DATE_ALLOW_DELIVERY", "EMP_ALLOW_DELIVERY_ID", "PRICE", "CURRENCY", "DISCOUNT_VALUE", "SUM_PAID", "USER_ID", "PAY_SYSTEM_ID", "DELIVERY_ID", "DATE_INSERT", "DATE_INSERT_FORMAT", "DATE_UPDATE", "USER_DESCRIPTION", "ADDITIONAL_INFO", "PS_STATUS", "PS_STATUS_CODE", "PS_STATUS_DESCRIPTION", "PS_STATUS_MESSAGE", "PS_SUM", "PS_CURRENCY", "PS_RESPONSE_DATE", "COMMENTS", "TAX_VALUE", "STAT_GID", "RECURRING_ID", "ACCOUNT_NUMBER", "SUM_PAID", "DELIVERY_DOC_DATE", "DELIVERY_DOC_NUM", "TRACKING_NUMBER", "STORE_ID", "ID_1C", "VERSION"); $bCrmModuleIncluded = false; if ($bExportFromCrm) { $arSelect[] = "UF_COMPANY_ID"; $arSelect[] = "UF_CONTACT_ID"; if (IsModuleInstalled("crm") && CModule::IncludeModule("crm")) { $bCrmModuleIncluded = true; } } $dbOrderList = CSaleOrder::GetList($arOrder, $arFilter, false, $count, $arSelect); while ($arOrder = $dbOrderList->Fetch()) { if ($crmMode) { if ($bNewVersion && is_array($_SESSION["BX_CML2_EXPORT"][$lastOrderPrefix]) && in_array($arOrder["ID"], $_SESSION["BX_CML2_EXPORT"][$lastOrderPrefix]) && empty($arFilter["ID"])) { continue; } ob_start(); } $arResultStat["ORDERS"]++; $agentParams = $arAgent[$arOrder["PERSON_TYPE_ID"]]; $arProp = array(); $arProp["ORDER"] = $arOrder; if (IntVal($arOrder["USER_ID"]) > 0) { $dbUser = CUser::GetByID($arOrder["USER_ID"]); if ($arUser = $dbUser->Fetch()) { $arProp["USER"] = $arUser; } } if ($bExportFromCrm) { $arProp["CRM"] = array(); $companyID = isset($arOrder["UF_COMPANY_ID"]) ? intval($arOrder["UF_COMPANY_ID"]) : 0; $contactID = isset($arOrder["UF_CONTACT_ID"]) ? intval($arOrder["UF_CONTACT_ID"]) : 0; if ($companyID > 0) { $arProp["CRM"]["CLIENT_ID"] = "CRMCO" . $companyID; } else { $arProp["CRM"]["CLIENT_ID"] = "CRMC" . $contactID; } $clientInfo = array("LOGIN" => "", "NAME" => "", "LAST_NAME" => "", "SECOND_NAME" => ""); if ($bCrmModuleIncluded) { if ($companyID > 0) { $arCompanyFilter = array('=ID' => $companyID); $dbCompany = CCrmCompany::GetListEx(array(), $arCompanyFilter, false, array("nTopCount" => 1), array("TITLE")); $arCompany = $dbCompany->Fetch(); unset($dbCompany, $arCompanyFilter); if (is_array($arCompany)) { if (isset($arCompany["TITLE"])) { $clientInfo["NAME"] = $arCompany["TITLE"]; } } unset($arCompany); } else { if ($contactID > 0) { $arContactFilter = array('=ID' => $contactID); $dbContact = CCrmContact::GetListEx(array(), $arContactFilter, false, array("nTopCount" => 1), array("NAME", "LAST_NAME", "SECOND_NAME")); $arContact = $dbContact->Fetch(); unset($dbContact, $arContactFilter); if (is_array($arContact)) { if (isset($arContact["NAME"])) { $clientInfo["NAME"] = $arContact["NAME"]; } if (isset($arContact["LAST_NAME"])) { $clientInfo["LAST_NAME"] = $arContact["LAST_NAME"]; } if (isset($arContact["SECOND_NAME"])) { $clientInfo["SECOND_NAME"] = $arContact["SECOND_NAME"]; } } unset($arContact); } } } $arProp["CRM"]["CLIENT"] = $clientInfo; unset($clientInfo); } if (IntVal($arOrder["PAY_SYSTEM_ID"]) > 0) { $arProp["ORDER"]["PAY_SYSTEM_NAME"] = $paySystems[$arOrder["PAY_SYSTEM_ID"]]; } if (strlen($arOrder["DELIVERY_ID"]) > 0) { $arProp["ORDER"]["DELIVERY_NAME"] = $delivery[$arOrder["DELIVERY_ID"]]; } $dbOrderPropVals = CSaleOrderPropsValue::GetList(array(), array("ORDER_ID" => $arOrder["ID"]), false, false, array("ID", "CODE", "VALUE", "ORDER_PROPS_ID", "PROP_TYPE")); $locationStreetPropertyValue = ''; while ($arOrderPropVals = $dbOrderPropVals->Fetch()) { if ($arOrderPropVals["PROP_TYPE"] == "CHECKBOX") { if ($arOrderPropVals["VALUE"] == "Y") { $arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"]] = "true"; } else { $arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"]] = "false"; } } elseif ($arOrderPropVals["PROP_TYPE"] == "TEXT" || $arOrderPropVals["PROP_TYPE"] == "TEXTAREA") { $arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"]] = $arOrderPropVals["VALUE"]; } elseif ($arOrderPropVals["PROP_TYPE"] == "SELECT" || $arOrderPropVals["PROP_TYPE"] == "RADIO") { $arVal = CSaleOrderPropsVariant::GetByValue($arOrderPropVals["ORDER_PROPS_ID"], $arOrderPropVals["VALUE"]); $arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"]] = $arVal["NAME"]; } elseif ($arOrderPropVals["PROP_TYPE"] == "MULTISELECT") { $curVal = explode(",", $arOrderPropVals["VALUE"]); foreach ($curVal as $vm) { $arVal = CSaleOrderPropsVariant::GetByValue($arOrderPropVals["ORDER_PROPS_ID"], $vm); $arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"]] .= ", " . $arVal["NAME"]; } $arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"]] = substr($arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"]], 2); } elseif ($arOrderPropVals["PROP_TYPE"] == "LOCATION") { $arVal = CSaleLocation::GetByID($arOrderPropVals["VALUE"], LANGUAGE_ID); if (CSaleLocation::isLocationProEnabled()) { if (intval($arVal['ID'])) { try { $res = \Bitrix\Sale\Location\LocationTable::getPathToNode($arVal['ID'], array('select' => array('LNAME' => 'NAME.NAME', 'TYPE_ID'), 'filter' => array('=NAME.LANGUAGE_ID' => LANGUAGE_ID))); $types = \Bitrix\Sale\Location\Admin\TypeHelper::getTypeCodeIdMapCached(); $path = array(); while ($item = $res->fetch()) { // copy street to STREET property if ($types['ID2CODE'][$item['TYPE_ID']] == 'STREET') { $locationStreetPropertyValue = $item['LNAME']; } $path[] = $item['LNAME']; } $locationString = implode(' - ', $path); } catch (\Bitrix\Main\SystemException $e) { $locationString = ''; } } else { $locationString = ''; } } else { $locationString = $arVal["COUNTRY_NAME"] . (strlen($arVal["COUNTRY_NAME"]) <= 0 || strlen($arVal["REGION_NAME"]) <= 0 ? "" : " - ") . $arVal["REGION_NAME"] . (strlen($arVal["COUNTRY_NAME"]) <= 0 || strlen($arVal["CITY_NAME"]) <= 0 ? "" : " - ") . $arVal["CITY_NAME"]; } $arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"]] = $locationString; $arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"] . "_CITY"] = $arVal["CITY_NAME"]; $arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"] . "_COUNTRY"] = $arVal["COUNTRY_NAME"]; $arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"] . "_REGION"] = $arVal["REGION_NAME"]; } else { $arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"]] = $arOrderPropVals["VALUE"]; } } $resShipment = \Bitrix\Sale\Internals\ShipmentTable::getList(array('select' => array('DELIVERY_ID', 'ALLOW_DELIVERY', 'DEDUCTED', 'DATE_ALLOW_DELIVERY', 'DATE_DEDUCTED'), 'filter' => array('ORDER_ID' => $arOrder['ID'], '=SYSTEM' => 'N'), 'limit' => array(1))); $arShipment = $resShipment->fetch(); $resPayment = \Bitrix\Sale\Internals\PaymentTable::getList(array('select' => array('PAY_VOUCHER_NUM', 'PAY_SYSTEM_ID', 'PAY_VOUCHER_DATE'), 'filter' => array('ORDER_ID' => $arOrder['ID'], '!PAY_SYSTEM_ID' => \Bitrix\Sale\Internals\PaySystemInner::getId()), 'limit' => array(1))); $arPayment = $resPayment->fetch(); foreach ($agentParams as $k => $v) { if (strpos($k, "REKV_") !== false) { if (!is_array($v)) { $agent["REKV"][$k] = $v; } else { if (strlen($v["TYPE"]) <= 0) { $agent["REKV"][$k] = $v["VALUE"]; } else { $agent["REKV"][$k] = $arProp[$v["TYPE"]][$v["VALUE"]]; } } } else { if (!is_array($v)) { $agent[$k] = $v; } else { if (strlen($v["TYPE"]) <= 0) { $agent[$k] = $v["VALUE"]; } else { $agent[$k] = $arProp[$v["TYPE"]][$v["VALUE"]]; } if ($k == 'STREET' && strlen($locationStreetPropertyValue)) { $agent[$k] = $locationStreetPropertyValue . (strlen($agent[$k]) ? ', ' : '') . $agent[$k]; } } } } ?> <<?php echo GetMessage("SALE_EXPORT_DOCUMENT"); ?> > <<?php echo GetMessage("SALE_EXPORT_ID"); ?> ><?php echo $arOrder["ID"]; ?> </<?php echo GetMessage("SALE_EXPORT_ID"); ?> > <<?php echo GetMessage("SALE_EXPORT_NUMBER"); ?> ><?php echo $accountNumberPrefix . $arOrder["ACCOUNT_NUMBER"]; ?> </<?php echo GetMessage("SALE_EXPORT_NUMBER"); ?> > <<?php echo GetMessage("SALE_EXPORT_DATE"); ?> ><?php echo $DB->FormatDate($arOrder["DATE_INSERT_FORMAT"], $dateFormat, "YYYY-MM-DD"); ?> </<?php echo GetMessage("SALE_EXPORT_DATE"); ?> > <<?php echo GetMessage("SALE_EXPORT_HOZ_OPERATION"); ?> ><?php echo GetMessage("SALE_EXPORT_ITEM_ORDER"); ?> </<?php echo GetMessage("SALE_EXPORT_HOZ_OPERATION"); ?> > <<?php echo GetMessage("SALE_EXPORT_ROLE"); ?> ><?php echo GetMessage("SALE_EXPORT_SELLER"); ?> </<?php echo GetMessage("SALE_EXPORT_ROLE"); ?> > <<?php echo GetMessage("SALE_EXPORT_CURRENCY"); ?> ><?php echo htmlspecialcharsbx(strlen($currency) > 0 ? substr($currency, 0, 3) : substr($arOrder["CURRENCY"], 0, 3)); ?> </<?php echo GetMessage("SALE_EXPORT_CURRENCY"); ?> > <<?php echo GetMessage("SALE_EXPORT_CURRENCY_RATE"); ?> >1</<?php echo GetMessage("SALE_EXPORT_CURRENCY_RATE"); ?> > <<?php echo GetMessage("SALE_EXPORT_AMOUNT"); ?> ><?php echo $arOrder["PRICE"]; ?> </<?php echo GetMessage("SALE_EXPORT_AMOUNT"); ?> > <?php if ($bNewVersion) { ?> <<?php echo GetMessage("SALE_EXPORT_VERSION"); ?> ><?php echo IntVal($arOrder["VERSION"]) > 0 ? $arOrder["VERSION"] : 0; ?> </<?php echo GetMessage("SALE_EXPORT_VERSION"); ?> > <?php if (strlen($arOrder["ID_1C"]) > 0) { ?> <<?php echo GetMessage("SALE_EXPORT_ID_1C"); ?> ><?php echo htmlspecialcharsbx($arOrder["ID_1C"]); ?> </<?php echo GetMessage("SALE_EXPORT_ID_1C"); ?> ><?php } } if ($crmMode) { ?> <DateUpdate><?php echo $DB->FormatDate($arOrder["DATE_UPDATE"], $dateFormat, "YYYY-MM-DD HH:MI:SS"); ?> </DateUpdate><?php } $deliveryAdr = CSaleExport::ExportContragents($arOrder, $arProp, $agent, $arResultStat, $bNewVersion, $bExportFromCrm ? array("EXPORT_FROM_CRM" => "Y") : array()); ?> <<?php echo GetMessage("SALE_EXPORT_TIME"); ?> ><?php echo $DB->FormatDate($arOrder["DATE_INSERT_FORMAT"], $dateFormat, "HH:MI:SS"); ?> </<?php echo GetMessage("SALE_EXPORT_TIME"); ?> > <<?php echo GetMessage("SALE_EXPORT_COMMENTS"); ?> ><?php echo htmlspecialcharsbx($arOrder["COMMENTS"]); ?> </<?php echo GetMessage("SALE_EXPORT_COMMENTS"); ?> > <?php $dbOrderTax = CSaleOrderTax::GetList(array(), array("ORDER_ID" => $arOrder["ID"]), false, false, array("ID", "TAX_NAME", "VALUE", "VALUE_MONEY", "CODE", "IS_IN_PRICE")); $i = -1; $orderTax = 0; while ($arOrderTax = $dbOrderTax->Fetch()) { $arOrderTax["VALUE_MONEY"] = roundEx($arOrderTax["VALUE_MONEY"], 2); $orderTax += $arOrderTax["VALUE_MONEY"]; $i++; if ($i == 0) { echo "<" . GetMessage("SALE_EXPORT_TAXES") . ">"; } ?> <<?php echo GetMessage("SALE_EXPORT_TAX"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo htmlspecialcharsbx($arOrderTax["TAX_NAME"]); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo GetMessage("SALE_EXPORT_IN_PRICE"); ?> ><?php echo $arOrderTax["IS_IN_PRICE"] == "Y" ? "true" : "false"; ?> </<?php echo GetMessage("SALE_EXPORT_IN_PRICE"); ?> > <<?php echo GetMessage("SALE_EXPORT_AMOUNT"); ?> ><?php echo $arOrderTax["VALUE_MONEY"]; ?> </<?php echo GetMessage("SALE_EXPORT_AMOUNT"); ?> > </<?php echo GetMessage("SALE_EXPORT_TAX"); ?> > <?php } if ($i != -1) { echo "</" . GetMessage("SALE_EXPORT_TAXES") . ">"; } ?> <?php if (DoubleVal($arOrder["DISCOUNT_VALUE"]) > 0) { ?> <<?php echo GetMessage("SALE_EXPORT_DISCOUNTS"); ?> > <<?php echo GetMessage("SALE_EXPORT_DISCOUNT"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo GetMessage("SALE_EXPORT_ORDER_DISCOUNT"); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo GetMessage("SALE_EXPORT_AMOUNT"); ?> ><?php echo $arOrder["DISCOUNT_VALUE"]; ?> </<?php echo GetMessage("SALE_EXPORT_AMOUNT"); ?> > <<?php echo GetMessage("SALE_EXPORT_IN_PRICE"); ?> >false</<?php echo GetMessage("SALE_EXPORT_IN_PRICE"); ?> > </<?php echo GetMessage("SALE_EXPORT_DISCOUNT"); ?> > </<?php echo GetMessage("SALE_EXPORT_DISCOUNTS"); ?> > <?php } $storeBasket = ""; if (IntVal($arOrder["STORE_ID"]) > 0 && !empty($arStore[$arOrder["STORE_ID"]])) { ?> <<?php echo GetMessage("SALE_EXPORT_STORIES"); ?> > <<?php echo GetMessage("SALE_EXPORT_STORY"); ?> > <<?php echo GetMessage("SALE_EXPORT_ID"); ?> ><?php echo $arStore[$arOrder["STORE_ID"]]["XML_ID"]; ?> </<?php echo GetMessage("SALE_EXPORT_ID"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo htmlspecialcharsbx($arStore[$arOrder["STORE_ID"]]["TITLE"]); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo GetMessage("SALE_EXPORT_ADDRESS"); ?> > <<?php echo GetMessage("SALE_EXPORT_PRESENTATION"); ?> ><?php echo htmlspecialcharsbx($arStore[$arOrder["STORE_ID"]]["ADDRESS"]); ?> </<?php echo GetMessage("SALE_EXPORT_PRESENTATION"); ?> > <<?php echo GetMessage("SALE_EXPORT_ADDRESS_FIELD"); ?> > <<?php echo GetMessage("SALE_EXPORT_TYPE"); ?> ><?php echo GetMessage("SALE_EXPORT_STREET"); ?> </<?php echo GetMessage("SALE_EXPORT_TYPE"); ?> > <<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> ><?php echo htmlspecialcharsbx($arStore[$arOrder["STORE_ID"]]["ADDRESS"]); ?> </<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> > </<?php echo GetMessage("SALE_EXPORT_ADDRESS_FIELD"); ?> > </<?php echo GetMessage("SALE_EXPORT_ADDRESS"); ?> > <<?php echo GetMessage("SALE_EXPORT_CONTACTS"); ?> > <<?php echo GetMessage("SALE_EXPORT_CONTACT"); ?> > <<?php echo GetMessage("SALE_EXPORT_TYPE"); ?> ><?php echo $bNewVersion ? GetMessage("SALE_EXPORT_WORK_PHONE_NEW") : GetMessage("SALE_EXPORT_WORK_PHONE"); ?> </<?php echo GetMessage("SALE_EXPORT_TYPE"); ?> > <<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> ><?php echo htmlspecialcharsbx($arStore[$arOrder["STORE_ID"]]["PHONE"]); ?> </<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> > </<?php echo GetMessage("SALE_EXPORT_CONTACT"); ?> > </<?php echo GetMessage("SALE_EXPORT_CONTACTS"); ?> > </<?php echo GetMessage("SALE_EXPORT_STORY"); ?> > </<?php echo GetMessage("SALE_EXPORT_STORIES"); ?> > <?php /* $storeBasket = " <".GetMessage("SALE_EXPORT_STORIES")."> <".GetMessage("SALE_EXPORT_STORY")."> <".GetMessage("SALE_EXPORT_ID").">".$arStore[$arOrder["STORE_ID"]]["XML_ID"]."</".GetMessage("SALE_EXPORT_ID")."> <".GetMessage("SALE_EXPORT_ITEM_NAME").">".htmlspecialcharsbx($arStore[$arOrder["STORE_ID"]]["TITLE"])."</".GetMessage("SALE_EXPORT_ITEM_NAME")."> </".GetMessage("SALE_EXPORT_STORY")."> </".GetMessage("SALE_EXPORT_STORIES")."> "; */ } ?> <<?php echo GetMessage("SALE_EXPORT_ITEMS"); ?> > <?php $dbBasket = \Bitrix\Sale\Internals\BasketTable::getList(array('select' => array("ID", "NOTES", "PRODUCT_XML_ID", "CATALOG_XML_ID", "NAME", "PRICE", "QUANTITY", "DISCOUNT_PRICE", "VAT_RATE", "MEASURE_CODE"), 'filter' => array("ORDER_ID" => $arOrder["ID"]), 'order' => array("NAME" => "ASC"))); $basketSum = 0; $priceType = ""; $bVat = false; $vatRate = 0; $vatSum = 0; while ($arBasket = $dbBasket->fetch()) { if (strlen($priceType) <= 0) { $priceType = $arBasket["NOTES"]; } ?> <<?php echo GetMessage("SALE_EXPORT_ITEM"); ?> > <<?php echo GetMessage("SALE_EXPORT_ID"); ?> ><?php echo htmlspecialcharsbx($arBasket["PRODUCT_XML_ID"]); ?> </<?php echo GetMessage("SALE_EXPORT_ID"); ?> > <<?php echo GetMessage("SALE_EXPORT_CATALOG_ID"); ?> ><?php echo htmlspecialcharsbx($arBasket["CATALOG_XML_ID"]); ?> </<?php echo GetMessage("SALE_EXPORT_CATALOG_ID"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo htmlspecialcharsbx($arBasket["NAME"]); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <?php if ($bNewVersion) { if (IntVal($arBasket["MEASURE_CODE"]) <= 0) { $arBasket["MEASURE_CODE"] = 796; } ?> <<?php echo GetMessage("SALE_EXPORT_UNIT"); ?> > <<?php echo GetMessage("SALE_EXPORT_CODE"); ?> ><?php echo $arBasket["MEASURE_CODE"]; ?> </<?php echo GetMessage("SALE_EXPORT_CODE"); ?> > <<?php echo GetMessage("SALE_EXPORT_FULL_NAME_UNIT"); ?> ><?php echo htmlspecialcharsbx($arMeasures[$arBasket["MEASURE_CODE"]]); ?> </<?php echo GetMessage("SALE_EXPORT_FULL_NAME_UNIT"); ?> > </<?php echo GetMessage("SALE_EXPORT_UNIT"); ?> > <<?php echo GetMessage("SALE_EXPORT_KOEF"); ?> >1</<?php echo GetMessage("SALE_EXPORT_KOEF"); ?> > <?php } else { ?> <<?php echo GetMessage("SALE_EXPORT_BASE_UNIT"); ?> <?php echo GetMessage("SALE_EXPORT_CODE"); ?> ="796" <?php echo GetMessage("SALE_EXPORT_FULL_NAME_UNIT"); ?> ="<?php echo GetMessage("SALE_EXPORT_SHTUKA"); ?> " <?php echo GetMessage("SALE_EXPORT_INTERNATIONAL_ABR"); ?> ="<?php echo GetMessage("SALE_EXPORT_RCE"); ?> "><?php echo GetMessage("SALE_EXPORT_SHT"); ?> </<?php echo GetMessage("SALE_EXPORT_BASE_UNIT"); ?> > <?php } if (DoubleVal($arBasket["DISCOUNT_PRICE"]) > 0) { ?> <<?php echo GetMessage("SALE_EXPORT_DISCOUNTS"); ?> > <<?php echo GetMessage("SALE_EXPORT_DISCOUNT"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo GetMessage("SALE_EXPORT_ITEM_DISCOUNT"); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo GetMessage("SALE_EXPORT_AMOUNT"); ?> ><?php echo $arBasket["DISCOUNT_PRICE"]; ?> </<?php echo GetMessage("SALE_EXPORT_AMOUNT"); ?> > <<?php echo GetMessage("SALE_EXPORT_IN_PRICE"); ?> >true</<?php echo GetMessage("SALE_EXPORT_IN_PRICE"); ?> > </<?php echo GetMessage("SALE_EXPORT_DISCOUNT"); ?> > </<?php echo GetMessage("SALE_EXPORT_DISCOUNTS"); ?> > <?php } ?> <<?php echo GetMessage("SALE_EXPORT_PRICE_PER_ITEM"); ?> ><?php echo $arBasket["PRICE"]; ?> </<?php echo GetMessage("SALE_EXPORT_PRICE_PER_ITEM"); ?> > <<?php echo GetMessage("SALE_EXPORT_QUANTITY"); ?> ><?php echo $arBasket["QUANTITY"]; ?> </<?php echo GetMessage("SALE_EXPORT_QUANTITY"); ?> > <<?php echo GetMessage("SALE_EXPORT_AMOUNT"); ?> ><?php echo $arBasket["PRICE"] * $arBasket["QUANTITY"]; ?> </<?php echo GetMessage("SALE_EXPORT_AMOUNT"); ?> > <<?php echo GetMessage("SALE_EXPORT_PROPERTIES_VALUES"); ?> > <<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo GetMessage("SALE_EXPORT_TYPE_NOMENKLATURA"); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> ><?php echo GetMessage("SALE_EXPORT_ITEM"); ?> </<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> > </<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo GetMessage("SALE_EXPORT_TYPE_OF_NOMENKLATURA"); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> ><?php echo GetMessage("SALE_EXPORT_ITEM"); ?> </<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> > </<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <?php $dbProp = CSaleBasket::GetPropsList(array("SORT" => "ASC", "ID" => "ASC"), array("BASKET_ID" => $arBasket["ID"], "!CODE" => array("CATALOG.XML_ID", "PRODUCT.XML_ID")), false, false, array("NAME", "VALUE", "CODE")); while ($arProp = $dbProp->Fetch()) { ?> <<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo htmlspecialcharsbx($arProp["NAME"]); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> ><?php echo htmlspecialcharsbx($arProp["VALUE"]); ?> </<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> > </<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <?php } ?> </<?php echo GetMessage("SALE_EXPORT_PROPERTIES_VALUES"); ?> > <?php if (DoubleVal($arBasket["VAT_RATE"]) > 0) { $bVat = true; $vatRate = DoubleVal($arBasket["VAT_RATE"]); $basketVatSum = $arBasket["PRICE"] / ($arBasket["VAT_RATE"] + 1) * $arBasket["VAT_RATE"]; $vatSum += roundEx($basketVatSum * $arBasket["QUANTITY"], 2); ?> <<?php echo GetMessage("SALE_EXPORT_TAX_RATES"); ?> > <<?php echo GetMessage("SALE_EXPORT_TAX_RATE"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo GetMessage("SALE_EXPORT_VAT"); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo GetMessage("SALE_EXPORT_RATE"); ?> ><?php echo $arBasket["VAT_RATE"] * 100; ?> </<?php echo GetMessage("SALE_EXPORT_RATE"); ?> > </<?php echo GetMessage("SALE_EXPORT_TAX_RATE"); ?> > </<?php echo GetMessage("SALE_EXPORT_TAX_RATES"); ?> > <<?php echo GetMessage("SALE_EXPORT_TAXES"); ?> > <<?php echo GetMessage("SALE_EXPORT_TAX"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo GetMessage("SALE_EXPORT_VAT"); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo GetMessage("SALE_EXPORT_IN_PRICE"); ?> >true</<?php echo GetMessage("SALE_EXPORT_IN_PRICE"); ?> > <<?php echo GetMessage("SALE_EXPORT_AMOUNT"); ?> ><?php echo roundEx($basketVatSum, 2); ?> </<?php echo GetMessage("SALE_EXPORT_AMOUNT"); ?> > </<?php echo GetMessage("SALE_EXPORT_TAX"); ?> > </<?php echo GetMessage("SALE_EXPORT_TAXES"); ?> > <?php } ?> <?php echo $storeBasket; ?> </<?php echo GetMessage("SALE_EXPORT_ITEM"); ?> > <?php $basketSum += $arBasket["PRICE"] * $arBasket["QUANTITY"]; } if (IntVal($arOrder["PRICE_DELIVERY"]) > 0) { ?> <<?php echo GetMessage("SALE_EXPORT_ITEM"); ?> > <<?php echo GetMessage("SALE_EXPORT_ID"); ?> >ORDER_DELIVERY</<?php echo GetMessage("SALE_EXPORT_ID"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo GetMessage("SALE_EXPORT_ORDER_DELIVERY"); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <?php if ($bNewVersion) { ?> <<?php echo GetMessage("SALE_EXPORT_UNIT"); ?> > <<?php echo GetMessage("SALE_EXPORT_CODE"); ?> >796</<?php echo GetMessage("SALE_EXPORT_CODE"); ?> > <<?php echo GetMessage("SALE_EXPORT_FULL_NAME_UNIT"); ?> ><?php echo htmlspecialcharsbx($arMeasures[796]); ?> </<?php echo GetMessage("SALE_EXPORT_FULL_NAME_UNIT"); ?> > </<?php echo GetMessage("SALE_EXPORT_UNIT"); ?> > <<?php echo GetMessage("SALE_EXPORT_KOEF"); ?> >1</<?php echo GetMessage("SALE_EXPORT_KOEF"); ?> > <?php } else { ?> <<?php echo GetMessage("SALE_EXPORT_BASE_UNIT"); ?> <?php echo GetMessage("SALE_EXPORT_CODE"); ?> ="796" <?php echo GetMessage("SALE_EXPORT_FULL_NAME_UNIT"); ?> ="<?php echo GetMessage("SALE_EXPORT_SHTUKA"); ?> " <?php echo GetMessage("SALE_EXPORT_INTERNATIONAL_ABR"); ?> ="<?php echo GetMessage("SALE_EXPORT_RCE"); ?> "><?php echo GetMessage("SALE_EXPORT_SHT"); ?> </<?php echo GetMessage("SALE_EXPORT_BASE_UNIT"); ?> > <?php } ?> <<?php echo GetMessage("SALE_EXPORT_PRICE_PER_ITEM"); ?> ><?php echo $arOrder["PRICE_DELIVERY"]; ?> </<?php echo GetMessage("SALE_EXPORT_PRICE_PER_ITEM"); ?> > <<?php echo GetMessage("SALE_EXPORT_QUANTITY"); ?> >1</<?php echo GetMessage("SALE_EXPORT_QUANTITY"); ?> > <<?php echo GetMessage("SALE_EXPORT_AMOUNT"); ?> ><?php echo $arOrder["PRICE_DELIVERY"]; ?> </<?php echo GetMessage("SALE_EXPORT_AMOUNT"); ?> > <<?php echo GetMessage("SALE_EXPORT_PROPERTIES_VALUES"); ?> > <<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo GetMessage("SALE_EXPORT_TYPE_NOMENKLATURA"); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> ><?php echo GetMessage("SALE_EXPORT_SERVICE"); ?> </<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> > </<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo GetMessage("SALE_EXPORT_TYPE_OF_NOMENKLATURA"); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> ><?php echo GetMessage("SALE_EXPORT_SERVICE"); ?> </<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> > </<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > </<?php echo GetMessage("SALE_EXPORT_PROPERTIES_VALUES"); ?> > <?php if ($bVat) { $deliveryTax = roundEx($arOrder["PRICE_DELIVERY"] / ($vatRate + 1) * $vatRate, 2); if ($orderTax > $vatSum && $orderTax == roundEx($vatSum + $deliveryTax, 2)) { ?> <<?php echo GetMessage("SALE_EXPORT_TAX_RATES"); ?> > <<?php echo GetMessage("SALE_EXPORT_TAX_RATE"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo GetMessage("SALE_EXPORT_VAT"); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo GetMessage("SALE_EXPORT_RATE"); ?> ><?php echo $vatRate * 100; ?> </<?php echo GetMessage("SALE_EXPORT_RATE"); ?> > </<?php echo GetMessage("SALE_EXPORT_TAX_RATE"); ?> > </<?php echo GetMessage("SALE_EXPORT_TAX_RATES"); ?> > <<?php echo GetMessage("SALE_EXPORT_TAXES"); ?> > <<?php echo GetMessage("SALE_EXPORT_TAX"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo GetMessage("SALE_EXPORT_VAT"); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo GetMessage("SALE_EXPORT_IN_PRICE"); ?> >true</<?php echo GetMessage("SALE_EXPORT_IN_PRICE"); ?> > <<?php echo GetMessage("SALE_EXPORT_AMOUNT"); ?> ><?php echo $deliveryTax; ?> </<?php echo GetMessage("SALE_EXPORT_AMOUNT"); ?> > </<?php echo GetMessage("SALE_EXPORT_TAX"); ?> > </<?php echo GetMessage("SALE_EXPORT_TAXES"); ?> > <?php } } ?> </<?php echo GetMessage("SALE_EXPORT_ITEM"); ?> > <?php } ?> </<?php echo GetMessage("SALE_EXPORT_ITEMS"); ?> > <<?php echo GetMessage("SALE_EXPORT_PROPERTIES_VALUES"); ?> > <?php if (strlen($arOrder["DATE_PAYED"]) > 0) { ?> <<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo GetMessage("SALE_EXPORT_DATE_PAID"); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> ><?php echo $arOrder["DATE_PAYED"]; ?> </<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> > </<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <?php } if (strlen($arPayment["PAY_VOUCHER_NUM"]) > 0) { ?> <<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo GetMessage("SALE_EXPORT_PAY_NUMBER"); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> ><?php echo htmlspecialcharsbx($arPayment["PAY_VOUCHER_NUM"]); ?> </<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> > </<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <?php } if (IntVal($arPayment["PAY_SYSTEM_ID"]) > 0) { ?> <<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo GetMessage("SALE_EXPORT_PAY_SYSTEM"); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> ><?php echo htmlspecialcharsbx($paySystems[$arPayment["PAY_SYSTEM_ID"]]); ?> </<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> > </<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo GetMessage("SALE_EXPORT_PAY_SYSTEM_ID"); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> ><?php echo htmlspecialcharsbx($arPayment["PAY_SYSTEM_ID"]); ?> </<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> > </<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <?php } if (strlen($arShipment["DATE_ALLOW_DELIVERY"]) > 0) { ?> <<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo GetMessage("SALE_EXPORT_DATE_ALLOW_DELIVERY"); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> ><?php echo $arShipment["DATE_ALLOW_DELIVERY"]; ?> </<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> > </<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <?php } if (strlen($arShipment["DELIVERY_ID"]) > 0) { ?> <<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo GetMessage("SALE_EXPORT_DELIVERY_SERVICE"); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> ><?php echo htmlspecialcharsbx($delivery[$arShipment["DELIVERY_ID"]]); ?> </<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> > </<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <?php } ?> <<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo GetMessage("SALE_EXPORT_ORDER_PAID"); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> ><?php echo $arOrder["PAYED"] == "Y" ? "true" : "false"; ?> </<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> > </<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo GetMessage("SALE_EXPORT_ALLOW_DELIVERY"); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> ><?php echo $arShipment["ALLOW_DELIVERY"] == "Y" ? "true" : "false"; ?> </<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> > </<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo GetMessage("SALE_EXPORT_CANCELED"); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> ><?php echo $arOrder["CANCELED"] == "Y" ? "true" : "false"; ?> </<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> > </<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo GetMessage("SALE_EXPORT_FINAL_STATUS"); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> ><?php echo $arOrder["STATUS_ID"] == "F" ? "true" : "false"; ?> </<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> > </<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo GetMessage("SALE_EXPORT_ORDER_STATUS"); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> ><?php $arStatus = CSaleStatus::GetLangByID($arOrder["STATUS_ID"]); echo htmlspecialcharsbx("[" . $arOrder["STATUS_ID"] . "] " . $arStatus["NAME"]); ?> </<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> > </<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo GetMessage("SALE_EXPORT_ORDER_STATUS_ID"); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> ><?php echo htmlspecialcharsbx($arOrder["STATUS_ID"]); ?> </<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> > </<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <?php if (strlen($arOrder["DATE_CANCELED"]) > 0) { ?> <<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo GetMessage("SALE_EXPORT_DATE_CANCEL"); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> ><?php echo $arOrder["DATE_CANCELED"]; ?> </<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> > </<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo GetMessage("SALE_EXPORT_CANCEL_REASON"); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> ><?php echo htmlspecialcharsbx($arOrder["REASON_CANCELED"]); ?> </<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> > </<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <?php } if (strlen($arOrder["DATE_STATUS"]) > 0) { ?> <<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo GetMessage("SALE_EXPORT_DATE_STATUS"); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> ><?php echo $arOrder["DATE_STATUS"]; ?> </<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> > </<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <?php } if (strlen($arOrder["USER_DESCRIPTION"]) > 0) { ?> <<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo GetMessage("SALE_EXPORT_USER_DESCRIPTION"); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> ><?php echo htmlspecialcharsbx($arOrder["USER_DESCRIPTION"]); ?> </<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> > </<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <?php } $dbSite = CSite::GetByID($arOrder["LID"]); $arSite = $dbSite->Fetch(); ?> <<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo GetMessage("SALE_EXPORT_SITE_NAME"); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> >[<?php echo $arOrder["LID"]; ?> ] <?php echo htmlspecialcharsbx($arSite["NAME"]); ?> </<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> > </<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <?php if (!empty($agent["REKV"])) { foreach ($agent["REKV"] as $k => $v) { if (strlen($agentParams[$k]["NAME"]) > 0 && strlen($v) > 0) { ?> <<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo htmlspecialcharsbx($agentParams[$k]["NAME"]); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> ><?php echo htmlspecialcharsbx($v); ?> </<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> > </<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <?php } } } if (strlen($deliveryAdr) > 0) { ?> <<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo GetMessage("SALE_EXPORT_DELIVERY_ADDRESS"); ?> </<?php echo GetMessage("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> ><?php echo htmlspecialcharsbx($deliveryAdr); ?> </<?php echo GetMessage("SALE_EXPORT_VALUE"); ?> > </<?php echo GetMessage("SALE_EXPORT_PROPERTY_VALUE"); ?> > <?php } ?> </<?php echo GetMessage("SALE_EXPORT_PROPERTIES_VALUES"); ?> > </<?php echo GetMessage("SALE_EXPORT_DOCUMENT"); ?> > <?php if ($crmMode) { $c = ob_get_clean(); $c = CharsetConverter::ConvertCharset($c, $arCharSets[$arOrder["LID"]], "utf-8"); echo $c; $_SESSION["BX_CML2_EXPORT"][$lastOrderPrefix][] = $arOrder["ID"]; } else { $_SESSION["BX_CML2_EXPORT"][$lastOrderPrefix] = $arOrder["ID"]; } if (IntVal($time_limit) > 0 && time() > $end_time) { break; } } ?> </<?php echo GetMessage("SALE_EXPORT_COM_INFORMATION"); ?> > <?php return $arResultStat; }
$arResult["ACCOUNT_NUMBER"] = $arOrder["ACCOUNT_NUMBER"]; } } if (!$arOrder) { $dbOrder = CSaleOrder::GetList(array("DATE_UPDATE" => "DESC"), array("LID" => SITE_ID, "ID" => $ID)); if ($arOrder = $dbOrder->GetNext()) { $arResult["ORDER_ID"] = $ID; $arResult["ACCOUNT_NUMBER"] = $arOrder["ACCOUNT_NUMBER"]; } } if ($arOrder) { foreach (GetModuleEvents("sale", "OnSaleComponentOrderOneStepFinal", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array($arResult["ORDER_ID"], &$arOrder, &$arParams)); } } $payment = \Bitrix\Sale\Internals\PaymentTable::getRow(array('select' => array('ID', 'PAY_SYSTEM_ID', 'SUM', 'DATE_BILL'), 'filter' => array('ORDER_ID' => $arResult["ORDER_ID"], '!PAY_SYSTEM_ID' => \Bitrix\Sale\Internals\PaySystemInner::getId()))); if ($arOrder && $arOrder["USER_ID"] == IntVal($USER->GetID())) { if ($payment && IntVal($payment["PAY_SYSTEM_ID"]) > 0 && $arOrder["PAYED"] != "Y") { $arOrder['PAYMENT_ID'] = $payment['ID']; $dbPaySysAction = CSalePaySystemAction::GetList(array(), array("PAY_SYSTEM_ID" => $payment["PAY_SYSTEM_ID"], "PERSON_TYPE_ID" => $arOrder["PERSON_TYPE_ID"]), false, false, array("NAME", "ACTION_FILE", "NEW_WINDOW", "PARAMS", "ENCODING", "LOGOTIP")); if ($arPaySysAction = $dbPaySysAction->Fetch()) { $arPaySysAction["NAME"] = htmlspecialcharsEx($arPaySysAction["NAME"]); if (strlen($arPaySysAction["ACTION_FILE"]) > 0) { if ($arPaySysAction["NEW_WINDOW"] != "Y") { CSalePaySystemAction::InitParamArrays($arOrder, $arOrder["ID"], $arPaySysAction["PARAMS"], array(), $payment); $pathToAction = $_SERVER["DOCUMENT_ROOT"] . $arPaySysAction["ACTION_FILE"]; $pathToAction = str_replace("\\", "/", $pathToAction); while (substr($pathToAction, strlen($pathToAction) - 1, 1) == "/") { $pathToAction = substr($pathToAction, 0, strlen($pathToAction) - 1); } if (file_exists($pathToAction)) {
} $end = microtime(true); file_put_contents($_SERVER["DOCUMENT_ROOT"] . '/bitrix/modules/sale_convert.txt', 'Migrate statuses and properties = ' . ($end - $start) . "\n", FILE_APPEND); $result = array(); if (empty($error)) { $message = Loc::getMessage('SALE_CONVERTER_AJAX_STEP_PAY_SYSTEM_INNER'); $result['NEXT_STEP'] = ++$ajax_step; } else { $message = Loc::getMessage('SALE_CONVERTER_AJAX_STEP_STATUS_CONVERT'); $result['ERROR'] = true; $message .= "<br>" . $error; } $result['DATA'] = $message; break; case 14: $res = \Bitrix\Sale\Internals\PaySystemInner::add(); if ($res !== false) { $message = Loc::getMessage('SALE_CONVERTER_AJAX_STEP_INSTALLER'); $result['NEXT_STEP'] = ++$ajax_step; } else { $message = Loc::getMessage('SALE_CONVERTER_AJAX_STEP_PAY_SYSTEM_INNER'); $result['ERROR'] = true; $message .= "<br>" . Loc::getMessage('SALE_CONVERTER_AJAX_STEP_PAY_SYSTEM_INNER_ERROR'); } $result['DATA'] = $message; break; case 15: if (!CopyDirFiles($_SERVER["DOCUMENT_ROOT"] . '/bitrix/modules/sale/install/admin', $_SERVER["DOCUMENT_ROOT"] . '/bitrix/admin', true, true)) { $error .= "<br>" . str_replace(array('#FROM#', '#TO#'), array($_SERVER["DOCUMENT_ROOT"] . '/bitrix/modules/sale/install/admin', $_SERVER["DOCUMENT_ROOT"] . '/bitrix/admin'), Loc::getMessage('SALE_CONVERTER_COPY_FILES_ERROR')); } if (!CopyDirFiles($_SERVER["DOCUMENT_ROOT"] . '/bitrix/modules/sale/install/components', $_SERVER["DOCUMENT_ROOT"] . '/bitrix/components', true, true)) {
function InitParamArrays($arOrder, $orderID = 0, $psParams = "", $relatedData = array(), $payment = array()) { if (!is_array($relatedData)) { $relatedData = array(); } $GLOBALS["SALE_INPUT_PARAMS"] = array(); $GLOBALS["SALE_CORRESPONDENCE"] = array(); if (!is_array($arOrder) || count($arOrder) <= 0 || !array_key_exists("ID", $arOrder)) { $arOrder = array(); $orderID = IntVal($orderID); if ($orderID > 0) { $arOrderTmp = CSaleOrder::GetByID($orderID); } if (!empty($arOrderTmp)) { foreach ($arOrderTmp as $k => $v) { $arOrder["~" . $k] = $v; $arOrder[$k] = htmlspecialcharsbx($v); } } } else { if ($orderID == 0 && $arOrder['ID'] > 0) { $orderID = $arOrder['ID']; } } if (empty($payment)) { $payment = \Bitrix\Sale\Internals\PaymentTable::getRow(array('select' => array('ID', 'PAY_SYSTEM_ID', 'SUM', 'PAID', 'DATE_BILL'), 'filter' => array('ORDER_ID' => $orderID, '!PAY_SYSTEM_ID' => \Bitrix\Sale\Internals\PaySystemInner::getId()))); } if (count($arOrder) > 0) { $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"] = $arOrder; } if (!empty($payment)) { $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["SHOULD_PAY"] = $payment['SUM']; $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["PRICE"] = $payment['SUM']; $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["PAYMENT_ID"] = $payment['ID']; $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["PAYED"] = $payment['PAID']; } else { $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["SHOULD_PAY"] = DoubleVal($GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["PRICE"]) - DoubleVal($GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["SUM_PAID"]); } $arDateInsert = explode(" ", $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["DATE_INSERT"]); if (is_array($arDateInsert) && count($arDateInsert) > 0) { $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["DATE_INSERT_DATE"] = $arDateInsert[0]; } else { $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["DATE_INSERT_DATE"] = $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["DATE_INSERT"]; } if (!empty($payment)) { $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["DATE_BILL_DATE"] = ConvertTimeStamp(MakeTimeStamp($payment["DATE_BILL"]), 'SHORT'); } $userID = IntVal($GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["USER_ID"]); if ($userID > 0) { $dbUser = CUser::GetByID($userID); if ($arUser = $dbUser->GetNext()) { $GLOBALS["SALE_INPUT_PARAMS"]["USER"] = $arUser; } } $arCurOrderProps = array(); if (isset($relatedData["PROPERTIES"]) && is_array($relatedData["PROPERTIES"])) { $properties = $relatedData["PROPERTIES"]; foreach ($properties as $key => $value) { $arCurOrderProps["~" . $key] = $value; $arCurOrderProps[$key] = htmlspecialcharsEx($value); } } else { $dbOrderPropVals = CSaleOrderPropsValue::GetList(array(), array("ORDER_ID" => $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["ID"]), false, false, array("ID", "CODE", "VALUE", "ORDER_PROPS_ID", "PROP_TYPE")); while ($arOrderPropVals = $dbOrderPropVals->Fetch()) { $arCurOrderPropsTmp = CSaleOrderProps::GetRealValue($arOrderPropVals["ORDER_PROPS_ID"], $arOrderPropVals["CODE"], $arOrderPropVals["PROP_TYPE"], $arOrderPropVals["VALUE"], LANGUAGE_ID); foreach ($arCurOrderPropsTmp as $key => $value) { $arCurOrderProps["~" . $key] = $value; $arCurOrderProps[$key] = htmlspecialcharsEx($value); } } } if (!empty($payment)) { $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["PAY_SYSTEM_ID"] = $payment['PAY_SYSTEM_ID']; $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["~PAY_SYSTEM_ID"] = $payment['PAY_SYSTEM_ID']; $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["ORDER_PAYMENT_ID"] = $payment['ID']; $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["~ORDER_PAYMENT_ID"] = $payment['ID']; } $shipment = \Bitrix\Sale\Internals\ShipmentTable::getRow(array('select' => array('DELIVERY_ID'), 'filter' => array('ORDER_ID' => $orderID, 'SYSTEM' => 'N'))); if ($shipment) { $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["DELIVERY_ID"] = $shipment['DELIVERY_ID']; $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["~DELIVERY_ID"] = $shipment['DELIVERY_ID']; } if (count($arCurOrderProps) > 0) { $GLOBALS["SALE_INPUT_PARAMS"]["PROPERTY"] = $arCurOrderProps; } if (strlen($psParams) <= 0) { $dbPaySysAction = CSalePaySystemAction::GetList(array(), array("PAY_SYSTEM_ID" => !empty($payment) ? intval($payment['PAY_SYSTEM_ID']) : intval($GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["PAY_SYSTEM_ID"]), "PERSON_TYPE_ID" => IntVal($GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["PERSON_TYPE_ID"])), false, false, array("PARAMS")); if ($arPaySysAction = $dbPaySysAction->Fetch()) { $psParams = $arPaySysAction["PARAMS"]; } } $GLOBALS["SALE_CORRESPONDENCE"] = CSalePaySystemAction::UnSerializeParams($psParams); foreach ($GLOBALS["SALE_CORRESPONDENCE"] as $key => $val) { $GLOBALS["SALE_CORRESPONDENCE"][$key]["~VALUE"] = $val["VALUE"]; $GLOBALS["SALE_CORRESPONDENCE"][$key]["VALUE"] = htmlspecialcharsEx($val["VALUE"]); } // fields with no interface $GLOBALS["SALE_CORRESPONDENCE"]['PAYER_STREET']["TYPE"] = 'PROPERTY'; $GLOBALS["SALE_CORRESPONDENCE"]['PAYER_STREET']["VALUE"] = 'LOCATION_STREET'; $GLOBALS["SALE_CORRESPONDENCE"]['PAYER_STREET']["~VALUE"] = 'LOCATION_STREET'; $GLOBALS["SALE_CORRESPONDENCE"]['PAYER_VILLAGE']["TYPE"] = 'PROPERTY'; $GLOBALS["SALE_CORRESPONDENCE"]['PAYER_VILLAGE']["VALUE"] = 'LOCATION_VILLAGE'; $GLOBALS["SALE_CORRESPONDENCE"]['PAYER_VILLAGE']["~VALUE"] = 'LOCATION_VILLAGE'; $GLOBALS["SALE_CORRESPONDENCE"]['ORDER_PAYMENT_ID']["TYPE"] = 'ORDER'; $GLOBALS["SALE_CORRESPONDENCE"]['ORDER_PAYMENT_ID']["VALUE"] = 'PAYMENT_ID'; $GLOBALS["SALE_CORRESPONDENCE"]['ORDER_PAYMENT_ID']["~VALUE"] = 'PAYMENT_ID'; $GLOBALS["SALE_CORRESPONDENCE"]['PAYED']["TYPE"] = 'ORDER'; $GLOBALS["SALE_CORRESPONDENCE"]['PAYED']["VALUE"] = 'PAYED'; $GLOBALS["SALE_CORRESPONDENCE"]['PAYED']["~VALUE"] = 'PAYED'; if (isset($relatedData["BASKET_ITEMS"]) && is_array($relatedData["BASKET_ITEMS"])) { $GLOBALS["SALE_INPUT_PARAMS"]["BASKET_ITEMS"] = $relatedData["BASKET_ITEMS"]; } if (isset($relatedData["TAX_LIST"]) && is_array($relatedData["TAX_LIST"])) { $GLOBALS["SALE_INPUT_PARAMS"]["TAX_LIST"] = $relatedData["TAX_LIST"]; } }
$ORDER_ID = urldecode(urldecode($_REQUEST["ORDER_ID"])); $paymentId = isset($_REQUEST["PAYMENT_ID"]) ? $_REQUEST["PAYMENT_ID"] : 0; $arOrder = false; if ($bUseAccountNumber) { $dbOrder = CSaleOrder::GetList(array("DATE_UPDATE" => "DESC"), array("LID" => SITE_ID, "USER_ID" => IntVal($GLOBALS["USER"]->GetID()), "ACCOUNT_NUMBER" => $ORDER_ID)); $arOrder = $dbOrder->GetNext(); } if (!$arOrder) { $dbOrder = CSaleOrder::GetList(array("DATE_UPDATE" => "DESC"), array("LID" => SITE_ID, "USER_ID" => IntVal($GLOBALS["USER"]->GetID()), "ID" => $ORDER_ID)); $arOrder = $dbOrder->GetNext(); } if ($arOrder) { if ($paymentId > 0) { $filter = array('ID' => $paymentId); } else { $filter = array('ORDER_ID' => $arOrder['ID'], '!PAY_SYSTEM_ID' => \Bitrix\Sale\Internals\PaySystemInner::getId()); } $resPayment = \Bitrix\Sale\Internals\PaymentTable::getList(array('select' => array('PAY_SYSTEM_ID', 'SUM', 'DATE_BILL', 'ID'), 'filter' => $filter, 'limit' => array(1))); $payment = $resPayment->fetch(); $dbPaySysAction = CSalePaySystemAction::GetList(array(), array("PAY_SYSTEM_ID" => $payment['PAY_SYSTEM_ID'], "PERSON_TYPE_ID" => $arOrder["PERSON_TYPE_ID"]), false, false, array("ACTION_FILE", "PARAMS", "ENCODING")); if ($arPaySysAction = $dbPaySysAction->Fetch()) { if (strlen($arPaySysAction["ACTION_FILE"]) > 0) { CSalePaySystemAction::InitParamArrays($arOrder, $ID, $arPaySysAction["PARAMS"], array(), $payment); $pathToAction = $_SERVER["DOCUMENT_ROOT"] . $arPaySysAction["ACTION_FILE"]; $pathToAction = rtrim(str_replace("\\", "/", $pathToAction), "/"); try { if (file_exists($pathToAction)) { if (is_dir($pathToAction)) { if (file_exists($pathToAction . "/payment.php")) { include $pathToAction . "/payment.php"; }
\CEventLog::Add(array("SEVERITY" => "ERROR", "AUDIT_TYPE_ID" => "SALE_CONVERTER_ERROR", "MODULE_ID" => "sale", "ITEM_ID" => "-", "DESCRIPTION" => 'COPY FILES ERROR')); } $result['DATA'] = $message; break; case 16: $start = microtime(true); $res = null; if ($DB->type == "MYSQL") { $res = $DB->Query('SELECT id FROM b_sale_order_payment LIMIT 1', false); } elseif ($DB->type == "MSSQL") { $res = $DB->Query('SELECT TOP(1) id FROM b_sale_order_payment', false); } elseif ($DB->type == "ORACLE") { $res = $DB->Query('SELECT id FROM b_sale_order_payment WHERE ROWNUM=1', false); } if ($res && !$res->Fetch()) { $innerId = \Bitrix\Sale\Internals\PaySystemInner::getId(); /** @var \Bitrix\Sale\PaySystemService $innerPaySystem */ $innerPaySystem = \Bitrix\Sale\PaySystemService::load($innerId); $concatAccNum = $DB->type == "MSSQL" ? "o.ACCOUNT_NUMBER+'/1'" : "CONCAT(o.ACCOUNT_NUMBER, '/1')"; if (!$DB->Query("\n\t\t\t\t\t\tINSERT INTO b_sale_order_payment\n\t\t\t\t\t\t\t(ORDER_ID, PAID, DATE_PAID, PS_STATUS, PS_STATUS_CODE, PS_STATUS_DESCRIPTION, PS_STATUS_MESSAGE, PS_SUM, PS_CURRENCY, PS_RESPONSE_DATE, SUM, CURRENCY, PAY_SYSTEM_ID, DATE_BILL, PAY_VOUCHER_NUM, PAY_VOUCHER_DATE, DATE_PAY_BEFORE, PAY_SYSTEM_NAME, RESPONSIBLE_ID, ACCOUNT_NUMBER)\n\t\t\t\t\tSELECT\n\t\t\t\t\t\to.ID, o.PAYED, o.DATE_PAYED, o.PS_STATUS, o.PS_STATUS_CODE, o.PS_STATUS_DESCRIPTION, o.PS_STATUS_MESSAGE, o.PS_SUM, o.PS_CURRENCY, o.PS_RESPONSE_DATE, o.SUM_PAID,\to.CURRENCY, " . $innerId . ", o.DATE_INSERT, o.PAY_VOUCHER_NUM, o.PAY_VOUCHER_DATE, o.DATE_PAY_BEFORE, '" . $innerPaySystem->getName() . "', o.CREATED_BY, " . $concatAccNum . "\n\t\t\t\t\tFROM b_sale_order o\n\t\t\t\t\tWHERE o.PAY_SYSTEM_ID IS NOT NULL AND o.SUM_PAID > 0", true)) { $error .= "<br>" . $DB->GetErrorMessage(); \CEventLog::Add(array("SEVERITY" => "ERROR", "AUDIT_TYPE_ID" => "SALE_CONVERTER_ERROR", "MODULE_ID" => "sale", "ITEM_ID" => "-", "DESCRIPTION" => $error)); } $concatAccNum = $DB->type == "MSSQL" ? "o.ACCOUNT_NUMBER+'/2'" : "CONCAT(o.ACCOUNT_NUMBER, '/2')"; if (!$DB->Query("\n\t\t\t\t\t\tINSERT INTO b_sale_order_payment\n\t\t\t\t\t\t\t(ORDER_ID, PAID, DATE_PAID, PS_STATUS, PS_STATUS_CODE, PS_STATUS_DESCRIPTION, PS_STATUS_MESSAGE, PS_SUM, PS_CURRENCY, PS_RESPONSE_DATE, SUM, CURRENCY, PAY_SYSTEM_ID, DATE_BILL, PAY_VOUCHER_NUM, PAY_VOUCHER_DATE, DATE_PAY_BEFORE, PAY_SYSTEM_NAME, RESPONSIBLE_ID, ACCOUNT_NUMBER)\n\t\t\t\t\tSELECT\n\t\t\t\t\t\to.ID, o.PAYED, o.DATE_PAYED, o.PS_STATUS, o.PS_STATUS_CODE, o.PS_STATUS_DESCRIPTION, o.PS_STATUS_MESSAGE, o.PS_SUM, o.PS_CURRENCY, o.PS_RESPONSE_DATE, o.PRICE-o.SUM_PAID,\to.CURRENCY, o.PAY_SYSTEM_ID, o.DATE_INSERT, o.PAY_VOUCHER_NUM, o.PAY_VOUCHER_DATE, o.DATE_PAY_BEFORE, b_sale_pay_system.NAME, o.CREATED_BY, " . $concatAccNum . "\n\t\t\t\t\tFROM b_sale_order o\n\t\t\t\t\tINNER JOIN b_sale_pay_system ON b_sale_pay_system.ID=o.PAY_SYSTEM_ID\n\t\t\t\t\tWHERE o.PAY_SYSTEM_ID IS NOT NULL", true)) { $error .= "<br>" . $DB->GetErrorMessage(); \CEventLog::Add(array("SEVERITY" => "ERROR", "AUDIT_TYPE_ID" => "SALE_CONVERTER_ERROR", "MODULE_ID" => "sale", "ITEM_ID" => "-", "DESCRIPTION" => $error)); } } $end = microtime(true); file_put_contents($_SERVER["DOCUMENT_ROOT"] . '/bitrix/modules/sale_convert.txt', 'insert into b_sale_order_payment = ' . ($end - $start) . "\n", FILE_APPEND);