public function filter() { \Bitrix\Main\Loader::includeModule('sale'); $daysBasketForgotten = $this->getFieldValue('DAYS_BASKET_FORGOTTEN'); if (!is_numeric($daysBasketForgotten)) { $daysBasketForgotten = 90; } $dateFrom = new \Bitrix\Main\Type\DateTime(); $dateTo = new \Bitrix\Main\Type\DateTime(); $dateFrom->setTime(0, 0, 0)->add('-' . $daysBasketForgotten . ' days'); $dateTo->setTime(0, 0, 0)->add('1 days')->add('-' . $daysBasketForgotten . ' days'); if ($this->isRunForOldData()) { $filter = array('<MIN_DATE_INSERT' => $dateTo->format(\Bitrix\Main\UserFieldTable::MULTIPLE_DATETIME_FORMAT)); } else { $filter = array('>MIN_DATE_INSERT' => $dateFrom->format(\Bitrix\Main\UserFieldTable::MULTIPLE_DATETIME_FORMAT), '<MIN_DATE_INSERT' => $dateTo->format(\Bitrix\Main\UserFieldTable::MULTIPLE_DATETIME_FORMAT)); } $filter = $filter + array('!FUSER.USER_ID' => null, '=ORDER_ID' => null, '=LID' => $this->getSiteId()); $userListDb = \Bitrix\Sale\Internals\BasketTable::getList(array('select' => array('USER_ID' => 'FUSER.USER_ID', 'EMAIL' => 'FUSER.USER.EMAIL', 'FUSER_USER_NAME' => 'FUSER.USER.NAME'), 'filter' => $filter, 'runtime' => array(new \Bitrix\Main\Entity\ExpressionField('MIN_DATE_INSERT', 'MIN(%s)', 'DATE_INSERT')), 'order' => array('USER_ID' => 'ASC'))); if ($userListDb->getSelectedRowsCount() > 0) { $userListDb->addFetchDataModifier(array($this, 'getFetchDataModifier')); $this->recipient = $userListDb; return true; } else { return false; } }
/** * @param $id * @return Main\Entity\DeleteResult * @throws Main\ArgumentException */ public static function deleteBundle($id) { $id = intval($id); if ($id <= 0) { throw new Main\ArgumentNullException("id"); } $itemsFromDbList = BasketTable::getList(array("filter" => array('SET_PARENT_ID' => $id), "select" => array("ID"))); while ($itemsFromDbItem = $itemsFromDbList->fetch()) { BasketTable::deleteWithItems($itemsFromDbItem['ID']); } return BasketTable::deleteWithItems($id); }
/** * @param $id * @return Sale\BasketItem|Sale\Result|null * @throws \Bitrix\Main\ArgumentException * @throws \Bitrix\Main\ArgumentNullException */ protected static function loadEntityFromBasket($id) { $result = new Sale\Result(); $order = null; $basket = null; $item = null; $res = BasketTable::getList(array('filter' => array('ID' => $id), 'select' => array('ID', 'ORDER_ID', 'SET_PARENT_ID', 'TYPE', 'FUSER_ID', 'LID'))); if (!($itemDat = $res->fetch())) { $result->addError(new Sale\ResultError(Main\Localization\Loc::getMessage('SALE_BASKET_COMPATIBLE_BASKET_ITEM_NOT_FOUND'), 'BASKET_ITEM_NOT_FOUND')); return $result; } if (intval($itemDat['ORDER_ID']) > 0) { /** @var Sale\Order $order */ if ($order = Sale\Order::load(intval($itemDat['ORDER_ID']))) { if ($basket = $order->getBasket()) { /** @var Sale\BasketItem $item */ $item = $basket->getItemById($id); } } } else { // if (!array_key_exists('FUSER_ID', $itemDat) || intval($itemDat['FUSER_ID']) <= 0) // { // $itemDat['FUSER_ID'] = Sale\Fuser::getId(); // } /** @var Sale\Basket $basket */ $basket = Sale\Basket::loadItemsForFUser($itemDat["FUSER_ID"], $itemDat['LID']); if ($basket) { /** @var Sale\BasketItem $item */ $item = $basket->getItemById($id); } } $data = array('BASKET_ITEM' => $item); if ($order !== null) { $data['ORDER'] = $order; } $result->addData($data); return $result; }
/** * @return Entity\AddResult|Entity\UpdateResult * @throws ArgumentException * @throws ArgumentNullException * @throws \Exception */ public function save() { $id = $this->getId(); $changedFields = $this->fields->getChangedValues(); $isNew = $id <= 0; if (!empty($changedFields)) { /** @var array $oldEntityValues */ $oldEntityValues = $this->fields->getOriginalValues(); /** @var Event $event */ $event = new Event('sale', EventActions::EVENT_ON_BASKET_ITEM_BEFORE_SAVED, array('ENTITY' => $this, 'IS_NEW' => $isNew, 'VALUES' => $oldEntityValues)); $event->send(); if ($event->getResults()) { $result = new Result(); /** @var EventResult $eventResult */ foreach ($event->getResults() as $eventResult) { if ($eventResult->getType() == EventResult::ERROR) { $errorMsg = new ResultError(Loc::getMessage('SALE_EVENT_ON_BEFORE_BASKET_ITEM_SAVED'), 'SALE_EVENT_ON_BEFORE_BASKET_ITEM_SAVED'); if (isset($eventResultData['ERROR']) && $eventResultData['ERROR'] instanceof ResultError) { $errorMsg = $eventResultData['ERROR']; } $result->addError($errorMsg); } } if (!$result->isSuccess()) { return $result; } } } $fields = $this->fields->getValues(); if ($this->isBundleParent()) { $bundleBasketCollection = $this->getBundleCollection(); } if ($id > 0) { $fields = $changedFields; if (!isset($fields["ORDER_ID"]) || intval($fields["ORDER_ID"]) == 0) { $orderId = null; if ($this->getParentOrderId() > 0) { $orderId = $this->getParentOrderId(); } if ($this->isBundleChild() && $orderId === null) { /** @var BasketItem $parentBasket */ if (!($parentBasket = $this->getParentBasketItem())) { throw new ObjectNotFoundException('Entity parent "BasketItem" not found'); } $orderId = $parentBasket->getParentOrderId(); } if (intval($orderId) > 0 && $this->getField('ORDER_ID') != $orderId) { $fields['ORDER_ID'] = $orderId; } } if (!empty($fields) && is_array($fields)) { if (isset($fields["QUANTITY"]) && floatval($fields["QUANTITY"]) == 0) { return new Entity\UpdateResult(); } $fields['DATE_UPDATE'] = new DateTime(); $this->setFieldNoDemand('DATE_UPDATE', $fields['DATE_UPDATE']); $r = Internals\BasketTable::update($id, $fields); if (!$r->isSuccess()) { return $r; } } $result = new Entity\UpdateResult(); } else { $fields['ORDER_ID'] = $this->getParentOrderId(); $fields['DATE_INSERT'] = new DateTime(); $fields['DATE_UPDATE'] = new DateTime(); $this->setFieldNoDemand('DATE_INSERT', $fields['DATE_INSERT']); $this->setFieldNoDemand('DATE_UPDATE', $fields['DATE_UPDATE']); if (!$this->isBundleChild() && (!isset($fields["FUSER_ID"]) || intval($fields["FUSER_ID"]) <= 0)) { /** @var Basket $basket */ if (!($basket = $this->getCollection())) { throw new ObjectNotFoundException('Entity "Basket" not found'); } $fields["FUSER_ID"] = intval($basket->getFUserId()); } /** @var Basket $basket */ if (!($basket = $this->getCollection())) { throw new ObjectNotFoundException('Entity "Basket" not found'); } /** @var Order $order */ if ($order = $basket->getOrder()) { if (!isset($fields["LID"]) || strval($fields["LID"]) == '') { $fields['LID'] = $order->getField('LID'); } } else { if ($siteId = $basket->getSiteId()) { $fields['LID'] = $siteId; } } if ($this->isBundleChild()) { if (!($parentBasketItem = $this->getParentBasketItem())) { throw new ObjectNotFoundException('Entity parent "BasketItem" not found'); } $fields['LID'] = $parentBasketItem->getField('LID'); if (!isset($fields["FUSER_ID"]) || intval($fields["FUSER_ID"]) <= 0) { $fields['FUSER_ID'] = intval($parentBasketItem->getField('FUSER_ID')); } } if (!isset($fields["LID"]) || strval(trim($fields["LID"])) == '') { throw new ArgumentNullException('lid'); } if ($this->isBundleChild() && (!isset($fields["SET_PARENT_ID"]) || intval($fields["QUANTITY"]) <= 0)) { $fields["SET_PARENT_ID"] = $this->getParentBasketItemId(); $this->setFieldNoDemand('SET_PARENT_ID', $fields['SET_PARENT_ID']); } if (!isset($fields["QUANTITY"]) || floatval($fields["QUANTITY"]) == 0) { return new Entity\AddResult(); } if (!isset($fields["CURRENCY"]) || strval(trim($fields["CURRENCY"])) == '') { throw new ArgumentNullException('currency'); } $r = Internals\BasketTable::add($fields); if (!$r->isSuccess()) { return $r; } $id = $r->getId(); $this->setFieldNoDemand('ID', $id); $this->setFieldNoDemand('LID', $fields['LID']); $this->setFieldNoDemand('FUSER_ID', $fields['FUSER_ID']); if ($basket->getOrder() && $basket->getOrderId() > 0) { OrderHistory::addAction('BASKET', $order->getId(), 'BASKET_ADDED', $id, $this); } $result = new Entity\AddResult(); } if ($isNew || !empty($changedFields)) { /** @var array $oldEntityValues */ $oldEntityValues = $this->fields->getOriginalValues(); /** @var Event $event */ $event = new Event('sale', EventActions::EVENT_ON_BASKET_ITEM_SAVED, array('ENTITY' => $this, 'IS_NEW' => $isNew, 'VALUES' => $oldEntityValues)); $event->send(); if ($event->getResults()) { $result = new Result(); /** @var EventResult $eventResult */ foreach ($event->getResults() as $eventResult) { if ($eventResult->getType() == EventResult::ERROR) { $errorMsg = new ResultError(Loc::getMessage('SALE_EVENT_ON_BEFORE_BASKET_ITEM_SAVED'), 'SALE_EVENT_ON_BEFORE_BASKET_ITEM_SAVED'); if (isset($eventResultData['ERROR']) && $eventResultData['ERROR'] instanceof ResultError) { $errorMsg = $eventResultData['ERROR']; } $result->addError($errorMsg); } } if (!$result->isSuccess()) { return $result; } } } if ($eventName = static::getEntityEventName()) { /** @var array $oldEntityValues */ $oldEntityValues = $this->fields->getOriginalValues(); if (!empty($oldEntityValues)) { /** @var Event $event */ $event = new Event('sale', 'On' . $eventName . 'EntitySaved', array('ENTITY' => $this, 'VALUES' => $oldEntityValues)); $event->send(); } } $this->fields->clearChanged(); // bundle if ($this->isBundleParent()) { if (!empty($bundleBasketCollection)) { if (!($order = $bundleBasketCollection->getOrder())) { /** @var Basket $basketCollection */ $basketCollection = $this->getCollection(); if ($order = $basketCollection->getOrder()) { $bundleBasketCollection->setOrder($order); } } $itemsFromDb = array(); if (!$isNew) { $itemsFromDbList = Internals\BasketTable::getList(array("filter" => array("SET_PARENT_ID" => $id), "select" => array("ID"))); while ($itemsFromDbItem = $itemsFromDbList->fetch()) { if ($itemsFromDbItem["ID"] == $id) { continue; } $itemsFromDb[$itemsFromDbItem["ID"]] = true; } } /** @var BasketItem $bundleBasketItem */ foreach ($bundleBasketCollection as $bundleBasketItem) { $r = $bundleBasketItem->save(); if (!$r->isSuccess()) { $result->addErrors($r->getErrors()); } if (isset($itemsFromDb[$bundleBasketItem->getId()])) { unset($itemsFromDb[$bundleBasketItem->getId()]); } } foreach ($itemsFromDb as $k => $v) { Internals\BasketTable::delete($k); } } } /** @var BasketPropertiesCollection $basketPropertyCollection */ $basketPropertyCollection = $this->getPropertyCollection(); $r = $basketPropertyCollection->save(); if (!$r->isSuccess()) { $result->addErrors($r->getErrors()); } return $result; }
/** * @param array $filter * @return \Bitrix\Main\DB\Result */ public static function getList(array $filter = array()) { return Internals\BasketTable::getList($filter); }
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; }
if (!isset($SHOW_ALL) || $SHOW_ALL == "N") { $arBasketIDs_tmp = explode(",", $BASKET_IDS); $arQuantities_tmp = explode(",", $QUANTITIES); if (count($arBasketIDs_tmp) != count($arQuantities_tmp)) { die("INVALID PARAMS"); } for ($i = 0, $countBasket = count($arBasketIDs_tmp); $i < $countBasket; $i++) { if (IntVal($arBasketIDs_tmp[$i]) > 0 && doubleVal($arQuantities_tmp[$i]) > 0) { $arBasketIDs[] = IntVal($arBasketIDs_tmp[$i]); $arQuantities[] = doubleVal($arQuantities_tmp[$i]); } } unset($countBasket); } else { $params = array('select' => array("ID", "QUANTITY", "SET_PARENT_ID"), 'filter' => array("ORDER_ID" => $ORDER_ID), 'order' => array("ID" => "ASC")); $db_basket = \Bitrix\Sale\Internals\BasketTable::getList($params); while ($arBasket = $db_basket->Fetch()) { if (intval($arBasket['SET_PARENT_ID']) > 0) { continue; } $arBasketIDs[] = $arBasket["ID"]; $arQuantities[] = $arBasket["QUANTITY"]; } } $dbUser = CUser::GetByID($arOrder["USER_ID"]); $arUser = $dbUser->Fetch(); $report = ""; $serCount = IntVal(COption::GetOptionInt("sale", "reports_count")); if ($serCount > 0) { for ($i = 1; $i <= $serCount; $i++) { $report .= COption::GetOptionString("sale", "reports" . $i);
foreach ($userIdFields as $userIdField) { $uId = intval($arOrder[$userIdField]); if ($uId > 0 && !in_array($uId, $users)) { $users[] = $uId; } } $formattedUserNames = GetFormatedUserName(array_values($users), false); $ordersIds[] = $arOrder['ID']; /** * define personalization settings */ $isRecommended = false; // personalization if (\Bitrix\Main\Analytics\Catalog::isOn() || $bNeedBasket) { $arBasketItems = array(); $dbItemsList = \Bitrix\Sale\Internals\BasketTable::getList(array('order' => array('ID' => 'ASC'), 'filter' => array('=ORDER_ID' => $arOrder['ID']))); while ($arItem = $dbItemsList->fetch()) { $arBasketItems[] = $arItem; if ($arItem['RECOMMENDATION']) { $isRecommended = true; } } } /** * build row */ $rowsList[$arOrder['ID']] = $row =& $lAdmin->AddRow($f_ID, $arOrder, "sale_order_view.php?ID=" . $f_ID . "&lang=" . LANGUAGE_ID . GetFilterParams("filter_")); $lamp = "/bitrix/images/sale/" . $arOrder['LOCK_STATUS'] . ".gif"; if ($arOrder['LOCK_STATUS'] == "green") { $lamp_alt = Loc::getMessage("SMOL_GREEN_ALT"); } elseif ($arOrder['LOCK_STATUS'] == "yellow") {
function getXmlBasketItems($type, $arOrder, $arFilter, $arSelect = array(), $arShipment = array()) { $bufer = ''; $result = array(); ob_start(); ?> <<?php echo CSaleExport::getTagName("SALE_EXPORT_ITEMS"); ?> ><?php $select = array("ID", "NOTES", "PRODUCT_XML_ID", "CATALOG_XML_ID", "NAME", "PRICE", "QUANTITY", "DISCOUNT_PRICE", "VAT_RATE", "MEASURE_CODE", "SET_PARENT_ID", "TYPE"); if (count($arSelect) > 0) { $select = array_merge($arSelect, $select); } $dbBasket = \Bitrix\Sale\Internals\BasketTable::getList(array('select' => $select, 'filter' => $arFilter, 'order' => array("NAME" => "ASC"))); $basketSum = 0; $priceType = ""; $bVat = false; $vatRate = 0; $vatSum = 0; while ($arBasket = $dbBasket->fetch()) { if (strval($arBasket['TYPE']) != '' && $arBasket['TYPE'] == \Bitrix\Sale\BasketItemBase::TYPE_SET) { continue; } $result[] = $arBasket; if (strlen($priceType) <= 0) { $priceType = $arBasket["NOTES"]; } ?> <<?php echo CSaleExport::getTagName("SALE_EXPORT_ITEM"); ?> > <<?php echo CSaleExport::getTagName("SALE_EXPORT_ID"); ?> ><?php echo htmlspecialcharsbx($arBasket["PRODUCT_XML_ID"]); ?> </<?php echo CSaleExport::getTagName("SALE_EXPORT_ID"); ?> > <<?php echo CSaleExport::getTagName("SALE_EXPORT_CATALOG_ID"); ?> ><?php echo htmlspecialcharsbx($arBasket["CATALOG_XML_ID"]); ?> </<?php echo CSaleExport::getTagName("SALE_EXPORT_CATALOG_ID"); ?> > <<?php echo CSaleExport::getTagName("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo htmlspecialcharsbx($arBasket["NAME"]); ?> </<?php echo CSaleExport::getTagName("SALE_EXPORT_ITEM_NAME"); ?> > <?php if (self::getVersionSchema() > self::DEFAULT_VERSION) { if (IntVal($arBasket["MEASURE_CODE"]) <= 0) { $arBasket["MEASURE_CODE"] = 796; } ?> <<?php echo CSaleExport::getTagName("SALE_EXPORT_UNIT"); ?> > <<?php echo CSaleExport::getTagName("SALE_EXPORT_CODE"); ?> ><?php echo $arBasket["MEASURE_CODE"]; ?> </<?php echo CSaleExport::getTagName("SALE_EXPORT_CODE"); ?> > <<?php echo CSaleExport::getTagName("SALE_EXPORT_FULL_NAME_UNIT"); ?> ><?php echo htmlspecialcharsbx(self::$measures[$arBasket["MEASURE_CODE"]]); ?> </<?php echo CSaleExport::getTagName("SALE_EXPORT_FULL_NAME_UNIT"); ?> > </<?php echo CSaleExport::getTagName("SALE_EXPORT_UNIT"); ?> > <<?php echo CSaleExport::getTagName("SALE_EXPORT_KOEF"); ?> >1</<?php echo CSaleExport::getTagName("SALE_EXPORT_KOEF"); ?> > <?php } else { ?> <<?php echo CSaleExport::getTagName("SALE_EXPORT_BASE_UNIT"); ?> <?php echo CSaleExport::getTagName("SALE_EXPORT_CODE"); ?> ="796" <?php echo CSaleExport::getTagName("SALE_EXPORT_FULL_NAME_UNIT"); ?> ="<?php echo CSaleExport::getTagName("SALE_EXPORT_SHTUKA"); ?> " <?php echo CSaleExport::getTagName("SALE_EXPORT_INTERNATIONAL_ABR"); ?> ="<?php echo CSaleExport::getTagName("SALE_EXPORT_RCE"); ?> "><?php echo CSaleExport::getTagName("SALE_EXPORT_SHT"); ?> </<?php echo CSaleExport::getTagName("SALE_EXPORT_BASE_UNIT"); ?> > <?php } if (DoubleVal($arBasket["DISCOUNT_PRICE"]) > 0) { ?> <<?php echo CSaleExport::getTagName("SALE_EXPORT_DISCOUNTS"); ?> > <<?php echo CSaleExport::getTagName("SALE_EXPORT_DISCOUNT"); ?> > <<?php echo CSaleExport::getTagName("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo CSaleExport::getTagName("SALE_EXPORT_ITEM_DISCOUNT"); ?> </<?php echo CSaleExport::getTagName("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo CSaleExport::getTagName("SALE_EXPORT_AMOUNT"); ?> ><?php echo $arBasket["DISCOUNT_PRICE"]; ?> </<?php echo CSaleExport::getTagName("SALE_EXPORT_AMOUNT"); ?> > <<?php echo CSaleExport::getTagName("SALE_EXPORT_IN_PRICE"); ?> >true</<?php echo CSaleExport::getTagName("SALE_EXPORT_IN_PRICE"); ?> > </<?php echo CSaleExport::getTagName("SALE_EXPORT_DISCOUNT"); ?> > </<?php echo CSaleExport::getTagName("SALE_EXPORT_DISCOUNTS"); ?> > <?php } ?> <?php if (self::getVersionSchema() >= self::PARTIAL_VERSION && $type == 'Shipment') { ?> <<?php echo CSaleExport::getTagName("SALE_EXPORT_PRICE_PER_ITEM"); ?> ><?php echo $arBasket["PRICE"]; ?> </<?php echo CSaleExport::getTagName("SALE_EXPORT_PRICE_PER_ITEM"); ?> > <<?php echo CSaleExport::getTagName("SALE_EXPORT_QUANTITY"); ?> ><?php echo $arBasket["SALE_INTERNALS_BASKET_SHIPMENT_ITEM_QUANTITY"]; ?> </<?php echo CSaleExport::getTagName("SALE_EXPORT_QUANTITY"); ?> > <<?php echo CSaleExport::getTagName("SALE_EXPORT_AMOUNT"); ?> ><?php echo $arBasket["PRICE"] * $arBasket["SALE_INTERNALS_BASKET_SHIPMENT_ITEM_QUANTITY"]; ?> </<?php echo CSaleExport::getTagName("SALE_EXPORT_AMOUNT"); ?> > <?php } else { ?> <<?php echo CSaleExport::getTagName("SALE_EXPORT_PRICE_PER_ITEM"); ?> ><?php echo $arBasket["PRICE"]; ?> </<?php echo CSaleExport::getTagName("SALE_EXPORT_PRICE_PER_ITEM"); ?> > <<?php echo CSaleExport::getTagName("SALE_EXPORT_QUANTITY"); ?> ><?php echo $arBasket["QUANTITY"]; ?> </<?php echo CSaleExport::getTagName("SALE_EXPORT_QUANTITY"); ?> > <<?php echo CSaleExport::getTagName("SALE_EXPORT_AMOUNT"); ?> ><?php echo $arBasket["PRICE"] * $arBasket["QUANTITY"]; ?> </<?php echo CSaleExport::getTagName("SALE_EXPORT_AMOUNT"); ?> > <?php } ?> <<?php echo CSaleExport::getTagName("SALE_EXPORT_PROPERTIES_VALUES"); ?> > <<?php echo CSaleExport::getTagName("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo CSaleExport::getTagName("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo CSaleExport::getTagName("SALE_EXPORT_TYPE_NOMENKLATURA"); ?> </<?php echo CSaleExport::getTagName("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo CSaleExport::getTagName("SALE_EXPORT_VALUE"); ?> ><?php echo CSaleExport::getTagName("SALE_EXPORT_ITEM"); ?> </<?php echo CSaleExport::getTagName("SALE_EXPORT_VALUE"); ?> > </<?php echo CSaleExport::getTagName("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo CSaleExport::getTagName("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo CSaleExport::getTagName("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo CSaleExport::getTagName("SALE_EXPORT_TYPE_OF_NOMENKLATURA"); ?> </<?php echo CSaleExport::getTagName("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo CSaleExport::getTagName("SALE_EXPORT_VALUE"); ?> ><?php echo CSaleExport::getTagName("SALE_EXPORT_ITEM"); ?> </<?php echo CSaleExport::getTagName("SALE_EXPORT_VALUE"); ?> > </<?php echo CSaleExport::getTagName("SALE_EXPORT_PROPERTY_VALUE"); ?> > <?php $dbProp = CSaleBasket::GetPropsList(array("SORT" => "ASC", "ID" => "ASC"), array("BASKET_ID" => $arBasket["ID"]), false, false, array("NAME", "VALUE", "CODE")); while ($arPropBasket = $dbProp->Fetch()) { ?> <<?php echo CSaleExport::getTagName("SALE_EXPORT_PROPERTY_VALUE"); ?> > <<?php echo CSaleExport::getTagName("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo CSaleExport::getTagName("SALE_EXPORT_PROPERTY_VALUE_BASKET"); ?> #<?php echo htmlspecialcharsbx($arPropBasket["NAME"]); ?> </<?php echo CSaleExport::getTagName("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo CSaleExport::getTagName("SALE_EXPORT_VALUE"); ?> ><?php echo htmlspecialcharsbx($arPropBasket["VALUE"]); ?> </<?php echo CSaleExport::getTagName("SALE_EXPORT_VALUE"); ?> > </<?php echo CSaleExport::getTagName("SALE_EXPORT_PROPERTY_VALUE"); ?> > <?php } ?> </<?php echo CSaleExport::getTagName("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 CSaleExport::getTagName("SALE_EXPORT_TAX_RATES"); ?> > <<?php echo CSaleExport::getTagName("SALE_EXPORT_TAX_RATE"); ?> > <<?php echo CSaleExport::getTagName("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo CSaleExport::getTagName("SALE_EXPORT_VAT"); ?> </<?php echo CSaleExport::getTagName("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo CSaleExport::getTagName("SALE_EXPORT_RATE"); ?> ><?php echo $arBasket["VAT_RATE"] * 100; ?> </<?php echo CSaleExport::getTagName("SALE_EXPORT_RATE"); ?> > </<?php echo CSaleExport::getTagName("SALE_EXPORT_TAX_RATE"); ?> > </<?php echo CSaleExport::getTagName("SALE_EXPORT_TAX_RATES"); ?> > <<?php echo CSaleExport::getTagName("SALE_EXPORT_TAXES"); ?> > <<?php echo CSaleExport::getTagName("SALE_EXPORT_TAX"); ?> > <<?php echo CSaleExport::getTagName("SALE_EXPORT_ITEM_NAME"); ?> ><?php echo CSaleExport::getTagName("SALE_EXPORT_VAT"); ?> </<?php echo CSaleExport::getTagName("SALE_EXPORT_ITEM_NAME"); ?> > <<?php echo CSaleExport::getTagName("SALE_EXPORT_IN_PRICE"); ?> >true</<?php echo CSaleExport::getTagName("SALE_EXPORT_IN_PRICE"); ?> > <<?php echo CSaleExport::getTagName("SALE_EXPORT_AMOUNT"); ?> ><?php echo roundEx($basketVatSum, 2); ?> </<?php echo CSaleExport::getTagName("SALE_EXPORT_AMOUNT"); ?> > </<?php echo CSaleExport::getTagName("SALE_EXPORT_TAX"); ?> > </<?php echo CSaleExport::getTagName("SALE_EXPORT_TAXES"); ?> > <?php } ?> <?php //=self::getXmlSaleStoreBasket($arOrder,$arStore) ?> </<?php echo CSaleExport::getTagName("SALE_EXPORT_ITEM"); ?> > <?php $basketSum += $arBasket["PRICE"] * $arBasket["QUANTITY"]; } if (self::getVersionSchema() >= self::PARTIAL_VERSION) { if (count($arShipment) > 0) { foreach ($arShipment as $shipment) { self::getOrderDeliveryItem($shipment, $bVat, $vatRate, $vatSum); } } } else { self::getOrderDeliveryItem($arOrder, $bVat, $vatRate, $vatSum); } ?> </<?php echo CSaleExport::getTagName("SALE_EXPORT_ITEMS"); ?> ><?php $bufer = ob_get_clean(); return array('outputXML' => $bufer, 'result' => $result); }
$arBasketFilter["%NAME"] = $basket_name_product; } CAdminMessage::ShowNote($basketMessage); CAdminMessage::ShowMessage($basketError); //update price $arCacheFuser = array(); $arUpdateFilter = $arBasketFilter; $arUpdateFilter["!CALLBACK_FUNC"] = ''; $dbBasketList = \Bitrix\Sale\Internals\BasketTable::getList(array('order' => $arBasketSort, 'filter' => $arUpdateFilter, 'select' => array('FUSER_ID', 'LID'))); while ($arBasket = $dbBasketList->fetch()) { if (!in_array($arBasket["FUSER_ID"], $arCacheFuser)) { $arCacheFuser[] = $arBasket["FUSER_ID"]; CSaleBasket::UpdateBasketPrices($arBasket["FUSER_ID"], $arBasket["LID"]); } } $dbBasketList = \Bitrix\Sale\Internals\BasketTable::getList(array('order' => array_merge(array("SET_PARENT_ID" => "DESC", "TYPE" => "DESC"), $arBasketSort), 'filter' => $arBasketFilter)); $dbBasketList = new CAdminResult($dbBasketList, $sTableID_tab4); $dbBasketList->NavStart(); $lAdmin_tab4->NavText($dbBasketList->GetNavPrint(GetMessage('BUYER_BASKET_BASKET'))); $BasketHeader = array(array("id" => "DATE_INSERT", "content" => GetMessage("BUYER_BH_DATE_INSERT"), "sort" => "DATE_INSERT", "default" => true), array("id" => "NAME", "content" => GetMessage("BUYER_BH_NAME"), "sort" => "NAME", "default" => true), array("id" => "DELAY", "content" => GetMessage("BUYER_BH_DELAY"), "sort" => "DELAY", "default" => true), array("id" => "PRICE", "content" => GetMessage("BUYER_BH_PRICE"), "sort" => "PRICE", "default" => true), array("id" => "QUANTITY", "content" => GetMessage("BUYER_BH_QUANTITY"), "sort" => "QUANTITY", "default" => true)); if (count($arSites) > 1) { $BasketHeader[] = array("id" => "LID", "content" => GetMessage("BUYER_BH_LID"), "sort" => "LID", "default" => true); } $lAdmin_tab4->AddHeaders($BasketHeader); $arSetData = array(); $arBasketData = array(); while ($arBasket = $dbBasketList->GetNext()) { if (CSaleBasketHelper::isSetItem($arBasket)) { $arSetData[$arBasket["SET_PARENT_ID"]][] = $arBasket; continue; }
$orderList[$arOrder['ID']] = $arOrder; $recommendedList[$arOrder['ID']] = false; } if (!empty($orderList) && is_array($orderList)) { /* * $dbProp = \Bitrix\Sale\Internals\BasketPropertyTable::getList(array( 'order' => array("SORT" => "ASC", "ID" => "ASC"), 'filter' => array("BASKET_ID" => $arItem["ID"], "!CODE" => array("CATALOG.XML_ID", "PRODUCT.XML_ID")) )); while($arProp = $dbProp -> fetch()) if(strlen($arProp["VALUE"]) > 0) $fieldValue .= "<div><small>".htmlspecialcharsbx($arProp["NAME"]).": ".htmlspecialcharsbx($arProp["VALUE"])."</small></div>"; */ if (\Bitrix\Main\Analytics\Catalog::isOn() || $bNeedBasket) { $dbItemsList = \Bitrix\Sale\Internals\BasketTable::getList(array('order' => array('ID' => 'ASC'), 'filter' => array('=ORDER_ID' => array_keys($orderList)))); while ($item = $dbItemsList->fetch()) { $basketList[$item['ORDER_ID']][$item['ID']] = $item; if (array_key_exists($item['ORDER_ID'], $recommendedList)) { if ($item['RECOMMENDATION']) { $recommendedList[$item['ORDER_ID']] = true; } } if ($bShowBasketProps) { if (!empty($basketList[$item['ORDER_ID']]) && is_array($basketList[$item['ORDER_ID']])) { $resProp = \Bitrix\Sale\Internals\BasketPropertyTable::getList(array('order' => array("SORT" => "ASC", "ID" => "ASC"), 'filter' => array("BASKET_ID" => array_keys($basketList[$item['ORDER_ID']]), "!CODE" => array("CATALOG.XML_ID", "PRODUCT.XML_ID")))); while ($prop = $resProp->fetch()) { if (strval($prop["VALUE"]) != "") { $basketPropertyList[$prop['BASKET_ID']][$prop['ID']] = $prop; } }
/** * Migrate discount data from b_sale_basket into new entity. * * @param array $order Order data. * @return Result */ public static function migrateOrderDiscounts($order) { if (self::$init === false) { self::init(); } static $useBasePrice = null; if ($useBasePrice === null) { $useBasePrice = (string) Main\Config\Option::get('sale', 'get_discount_percent_from_base_price'); } $process = true; $result = new Result(); if (empty($order['ID']) || (int) $order['ID'] <= 0) { $process = false; $result->addError(new Main\Entity\EntityError(Loc::getMessage('SALE_ORDER_DISCOUNT_ERR_EMPTY_ORDER_ID'), self::ERROR_ID)); } $catalogOrder = false; $basketData = array(); if ($process) { $order['ID'] = (int) $order['ID']; $basePrices = array(); $basketIterator = Internals\BasketTable::getList(array('select' => array('ID', 'DISCOUNT_COUPON', 'DISCOUNT_NAME', 'DISCOUNT_VALUE', 'MODULE', 'PRICE', 'DISCOUNT_PRICE', 'CURRENCY', 'SET_PARENT_ID', 'TYPE'), 'filter' => array('=ORDER_ID' => $order['ID']))); while ($basket = $basketIterator->fetch()) { $basket['ID'] = (int) $basket['ID']; $basket['MODULE'] = (string) $basket['MODULE']; $basket['DISCOUNT_COUPON'] = trim((string) $basket['DISCOUNT_COUPON']); $basket['DISCOUNT_NAME'] = trim((string) $basket['DISCOUNT_NAME']); $basket['SET_PARENT_ID'] = (int) $basket['SET_PARENT_ID']; $basket['TYPE'] = (int) $basket['TYPE']; if ($basket['MODULE'] == 'catalog') { $basePrices[$basket['ID']] = array('BASE_PRICE' => $basket['PRICE'] + $basket['DISCOUNT_PRICE'], 'BASE_PRICE_CURRENCY' => $basket['CURRENCY']); } if ($basket['MODULE'] != 'catalog' || $basket['DISCOUNT_NAME'] == '' && $basket['DISCOUNT_COUPON'] == '') { continue; } if ($basket['SET_PARENT_ID'] > 0 && $basket['TYPE'] <= 0) { continue; } $catalogOrder = true; $hash = md5($basket['DISCOUNT_NAME'] . '|' . $basket['DISCOUNT_COUPON']); if (!isset($basketData[$hash])) { $basketData[$hash] = array('DISCOUNT_NAME' => $basket['DISCOUNT_NAME'], 'DISCOUNT_COUPON' => $basket['DISCOUNT_COUPON'], 'ITEMS' => array()); } $basketData[$hash]['ITEMS'][$basket['ID']] = $basket; } unset($basket, $basketIterator); } if ($process && $catalogOrder) { self::setManagerConfig(array('CURRENCY' => $order['CURRENCY'], 'SITE_ID' => $order['LID'], 'USE_BASE_PRICE' => $useBasePrice)); foreach ($basketData as &$row) { if (!self::migrateDiscount($order['ID'], $row)) { $process = false; $result->addError(new Main\Entity\EntityError(Loc::getMessage('SALE_ORDER_DISCOUNT_ERR_SAVE_MIGRATE_DISCOUNT'), self::ERROR_ID)); break; } } unset($row); } unset($basketData); Internals\OrderDiscountDataTable::clearByOrder($order['ID']); if ($process) { if (!empty($basePrices)) { foreach ($basePrices as $basketId => $price) { $fields = array('ORDER_ID' => $order['ID'], 'ENTITY_TYPE' => Internals\OrderDiscountDataTable::ENTITY_TYPE_BASKET, 'ENTITY_ID' => $basketId, 'ENTITY_VALUE' => $basketId, 'ENTITY_DATA' => $price); $operationResult = Internals\OrderDiscountDataTable::add($fields); if (!$operationResult->isSuccess()) { $process = false; $result->addErrors($operationResult->getErrors()); } unset($operationResult); } unset($basketId, $price); } } if ($process) { $fields = array('ORDER_ID' => $order['ID'], 'ENTITY_TYPE' => Internals\OrderDiscountDataTable::ENTITY_TYPE_ORDER, 'ENTITY_ID' => $order['ID'], 'ENTITY_VALUE' => $order['ID'], 'ENTITY_DATA' => array('OLD_ORDER' => 'Y')); $operationResult = Internals\OrderDiscountDataTable::add($fields); if (!$operationResult->isSuccess()) { $process = false; $result->addErrors($operationResult->getErrors()); } unset($operationResult); } unset($process); return $result; }