Example #1
0
 public static function DoLoadDelivery($location, $locationZip, $weight, $price, $currency, $siteId = null)
 {
     $location = intval($location);
     if ($location <= 0) {
         return null;
     }
     if ($siteId == null) {
         $siteId = SITE_ID;
     }
     $arResult = array();
     $arFilter = array("COMPABILITY" => array("WEIGHT" => $weight, "PRICE" => $price, "LOCATION_FROM" => COption::GetOptionString('sale', 'location', false, $siteId), "LOCATION_TO" => $location, "LOCATION_ZIP" => $locationZip), "SITE_ID" => $siteId);
     $dbDeliveryServices = CSaleDeliveryHandler::GetList(array("SORT" => "ASC"), $arFilter);
     while ($arDeliveryService = $dbDeliveryServices->GetNext()) {
         if (!is_array($arDeliveryService) || !is_array($arDeliveryService["PROFILES"])) {
             continue;
         }
         foreach ($arDeliveryService["PROFILES"] as $profileId => $arDeliveryProfile) {
             if ($arDeliveryProfile["ACTIVE"] != "Y") {
                 continue;
             }
             if (!array_key_exists($arDeliveryService["SID"], $arResult)) {
                 $arResult[$arDeliveryService["SID"]] = array("SID" => $arDeliveryService["SID"], "TITLE" => $arDeliveryService["NAME"], "DESCRIPTION" => $arDeliveryService["DESCRIPTION"], "PROFILES" => array());
             }
             $arResult[$arDeliveryService["SID"]]["PROFILES"][$profileId] = array("ID" => $arDeliveryService["SID"] . ":" . $profileId, "SID" => $profileId, "TITLE" => $arDeliveryProfile["TITLE"], "DESCRIPTION" => $arDeliveryProfile["DESCRIPTION"], "FIELD_NAME" => "DELIVERY_ID");
             $arDeliveryPriceTmp = CSaleDeliveryHandler::CalculateFull($arDeliveryService["SID"], $profileId, array("PRICE" => $price, "WEIGHT" => $weight, "LOCATION_FROM" => COption::GetOptionString('sale', 'location', false, $siteId), "LOCATION_TO" => $location, "LOCATION_ZIP" => $locationZip), $currency);
             if ($arDeliveryPriceTmp["RESULT"] != "ERROR") {
                 $arResult[$arDeliveryService["SID"]]["PROFILES"][$profileId]["DELIVERY_PRICE"] = roundEx($arDeliveryPriceTmp["VALUE"], SALE_VALUE_PRECISION);
                 $arResult[$arDeliveryService["SID"]]["PROFILES"][$profileId]["CURRENCY"] = $currency;
             }
         }
     }
     $dbDelivery = CSaleDelivery::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("LID" => $siteId, "+<=WEIGHT_FROM" => $weight, "+>=WEIGHT_TO" => $weight, "+<=ORDER_PRICE_FROM" => $price, "+>=ORDER_PRICE_TO" => $price, "ACTIVE" => "Y", "LOCATION" => $location));
     while ($arDelivery = $dbDelivery->GetNext()) {
         $arDeliveryDescription = CSaleDelivery::GetByID($arDelivery["ID"]);
         $arDelivery["DESCRIPTION"] = $arDeliveryDescription["DESCRIPTION"];
         $arDelivery["FIELD_NAME"] = "DELIVERY_ID";
         if (intval($arDelivery["PERIOD_FROM"]) > 0 || intval($arDelivery["PERIOD_TO"]) > 0) {
             $arDelivery["PERIOD_TEXT"] = GetMessage("SALE_DELIV_PERIOD");
             if (intval($arDelivery["PERIOD_FROM"]) > 0) {
                 $arDelivery["PERIOD_TEXT"] .= " " . GetMessage("SOA_FROM") . " " . intval($arDelivery["PERIOD_FROM"]);
             }
             if (intval($arDelivery["PERIOD_TO"]) > 0) {
                 $arDelivery["PERIOD_TEXT"] .= " " . GetMessage("SOA_TO") . " " . intval($arDelivery["PERIOD_TO"]);
             }
             if ($arDelivery["PERIOD_TYPE"] == "H") {
                 $arDelivery["PERIOD_TEXT"] .= " " . GetMessage("SOA_HOUR") . " ";
             } elseif ($arDelivery["PERIOD_TYPE"] == "M") {
                 $arDelivery["PERIOD_TEXT"] .= " " . GetMessage("SOA_MONTH") . " ";
             } else {
                 $arDelivery["PERIOD_TEXT"] .= " " . GetMessage("SOA_DAY") . " ";
             }
         }
         $arResult[] = $arDelivery;
     }
     return $arResult;
 }
Example #2
0
    public static function getDelivery($id = false)
    {
        static $result = null;
        static $resultById = null;

        if($result === null)
        {
            $rs = \CSaleDelivery::GetList(array(), array(), false, false, array('ID', 'NAME'));
            while($ar = $rs->GetNext(true, false))
            {
                $obj = new Delivery($ar);
                $resultById[ $ar['ID'] ] = &$obj;
                $result[] = &$obj;
                unset($obj);
            }
        }

        return $id ? (isset($resultById[$id]) ? $resultById[$id] : false) : $result;
    }
Example #3
0
/**
 * [getDelivery description]
 * @return array or false
 */
function getDelivery()
{
    if (CModule::IncludeModule('sale')) {
        $db_dtype = CSaleDelivery::GetList(array("SORT" => "ASC", "ID" => "ASC"), array("LID" => SITE_ID, "ACTIVE" => "Y"), false, false, array());
        while ($ar_dtype = $db_dtype->Fetch()) {
            $arDelivery[] = $ar_dtype;
        }
        return $arDelivery;
    }
    return false;
}
Example #4
0
 /**
  * Function returns reference data as shared cache between this component and sale.personal.order.list.
  *
  * @throws Exception
  * @return void
  */
 protected function obtainDataReferences()
 {
     if ($this->startCache(array('spo-shared'))) {
         try {
             $cachedData = array();
             /////////////////////
             /////////////////////
             // Person type
             $dbPType = CSalePersonType::GetList(array("SORT" => "ASC"));
             while ($arPType = $dbPType->Fetch()) {
                 $cachedData['PERSON_TYPE'][$arPType["ID"]] = $arPType;
             }
             // Save statuses for Filter form
             $dbStatus = CSaleStatus::GetList(array("SORT" => "ASC"), array("LID" => LANGUAGE_ID));
             while ($arStatus = $dbStatus->Fetch()) {
                 $cachedData['STATUS'][$arStatus["ID"]] = $arStatus;
             }
             $dbPaySystem = CSalePaySystem::GetList(array("SORT" => "ASC"));
             while ($arPaySystem = $dbPaySystem->Fetch()) {
                 $cachedData['PAYSYS'][$arPaySystem["ID"]] = $arPaySystem;
             }
             $dbDelivery = CSaleDelivery::GetList(array("SORT" => "ASC"));
             while ($arDelivery = $dbDelivery->Fetch()) {
                 $cachedData['DELIVERY'][$arDelivery["ID"]] = $arDelivery;
             }
             $dbDelivery = CSaleDeliveryHandler::GetList(array(), array(array("SITE_ID" => SITE_ID)));
             while ($arDeliveryHandler = $dbDelivery->Fetch()) {
                 $cachedData['DELIVERY_HANDLERS'][$arDeliveryHandler["SID"]] = $arDeliveryHandler;
             }
             /////////////////////
             /////////////////////
         } catch (Exception $e) {
             $this->abortCache();
             throw $e;
         }
         $this->endCache($cachedData);
     } else {
         $cachedData = $this->getCacheData();
     }
     $this->dbResult = array_merge($this->dbResult, $this->adaptCachedReferences($cachedData));
 }
Example #5
0
//get status order
$arOrderStatus = array();
$dbStatusList = CSaleStatus::GetList(
	array("SORT" => "ASC"),
	array("LID" => LANGUAGE_ID),
	false,
	false,
	array("ID", "NAME")
);
while ($arStatusList = $dbStatusList->Fetch())
	$arOrderStatus[htmlspecialcharsbx($arStatusList["ID"])] = htmlspecialcharsbx($arStatusList["NAME"]);

//get delivery
$arDelivery = array();
$dbDeliveryList = CSaleDelivery::GetList(
		array("SORT" => "ASC"),
		array()
		);
while ($arDeliveryList = $dbDeliveryList->Fetch())
	$arDelivery[$arDeliveryList["ID"]] = htmlspecialcharsbx($arDeliveryList["NAME"]);

//get paysystem
$arPaySystem = array();
$dbPaySystemList = CSalePaySystem::GetList(
		array("SORT"=>"ASC"),
		array()
		);
while ($arPaySystemList = $dbPaySystemList->Fetch())
	$arPaySystem[$arPaySystemList["ID"]] = htmlspecialcharsbx($arPaySystemList["NAME"]);


$sTableID_tab5 = "table_order_change";
Example #6
0
             }
             $arResult["DELIVERY"][$delivery_id]["LOGOTIP"] = $arDeliveryService["LOGOTIP"];
             $arResult["DELIVERY"][$delivery_id]["PROFILES"][$profile_id] = $arProfile;
             $bFirst = false;
         }
     }
 }
 if (!$bFound && !empty($arUserResult["DELIVERY_ID"]) && strpos($arUserResult["DELIVERY_ID"], ":") !== false) {
     $arUserResult["DELIVERY_ID"] = "";
 }
 /*Old Delivery*/
 $arStoreId = array();
 $arDeliveryAll = array();
 $bFound = False;
 $bFirst = True;
 $dbDelivery = CSaleDelivery::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("LID" => SITE_ID, "+<=WEIGHT_FROM" => $arResult["ORDER_WEIGHT"], "+>=WEIGHT_TO" => $arResult["ORDER_WEIGHT"], "+<=ORDER_PRICE_FROM" => $arResult["ORDER_PRICE"], "+>=ORDER_PRICE_TO" => $arResult["ORDER_PRICE"], "ACTIVE" => "Y", "LOCATION" => $arUserResult["DELIVERY_LOCATION"]));
 while ($arDelivery = $dbDelivery->Fetch()) {
     $arStore = array();
     if (strlen($arDelivery["STORE"]) > 0) {
         $arStore = unserialize($arDelivery["STORE"]);
         foreach ($arStore as $val) {
             $arStoreId[$val] = $val;
         }
     }
     $arDelivery["STORE"] = $arStore;
     if (isset($_POST["BUYER_STORE"]) && in_array($_POST["BUYER_STORE"], $arStore)) {
         $arUserResult['DELIVERY_STORE'] = $arDelivery["ID"];
     }
     $arDeliveryDescription = CSaleDelivery::GetByID($arDelivery["ID"]);
     $arDelivery["DESCRIPTION"] = htmlspecialcharsbx($arDeliveryDescription["DESCRIPTION"]);
     $arDeliveryAll[] = $arDelivery;
Example #7
0
	public static function ExportOrders2Xml($arFilter = Array(), $nTopCount = 0, $currency = "", $crmMode = false)
	{
		global $DB;
		$count = false;
		if(IntVal($nTopCount)>0)
			$count = Array("nTopCount" => $nTopCount);

		$arResultStat = array(
			"ORDERS" => 0,
			"CONTACTS" => 0,
			"COMPANIES" => 0,
		);

		$accountNumberPrefix = COption::GetOptionString("sale", "1C_SALE_ACCOUNT_NUMBER_SHOP_PREFIX", "");

		$arOrder = array("ID" => "DESC");
		if ($crmMode)
			$arOrder = array("DATE_UPDATE" => "ASC");

		$dbOrderList = CSaleOrder::GetList(
				$arOrder,
				$arFilter,
				false,
				$count,
				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"
				)
			);

		$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"].")";
				}
			}
		}

		$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");
?>
="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");
?>
=.">
		<?

		while($arOrder = $dbOrderList->Fetch())
		{
			if ($crmMode)
				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;
			}

			$dbOrderPropVals = CSaleOrderPropsValue::GetList(
					array(),
					array("ORDER_ID" => $arOrder["ID"]),
					false,
					false,
					array("ID", "CODE", "VALUE", "ORDER_PROPS_ID", "PROP_TYPE")
				);
			while ($arOrderPropVals = $dbOrderPropVals->Fetch())
			{
				//$arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"]] = $arOrderPropVals["VALUE"];
				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"]);
					for ($i = 0; $i < count($curVal); $i++)
					{
						$arVal = CSaleOrderPropsVariant::GetByValue($arOrderPropVals["ORDER_PROPS_ID"], $curVal[$i]);
						if ($i > 0)
							$arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"]] .=  ", ";
						$arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"]] .=  $arVal["NAME"];
					}
				}
				elseif ($arOrderPropVals["PROP_TYPE"] == "LOCATION")
				{
					$arVal = CSaleLocation::GetByID($arOrderPropVals["VALUE"], LANGUAGE_ID);
					$arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"]] =  ($arVal["COUNTRY_NAME"].((strlen($arVal["COUNTRY_NAME"])<=0 || strlen($arVal["CITY_NAME"])<=0) ? "" : " - ").$arVal["CITY_NAME"]);
					$arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"]."_CITY"] = $arVal["CITY_NAME"];
					$arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"]."_COUNTRY"] = $arVal["COUNTRY_NAME"];
				}
				else
				{
					$arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"]] = $arOrderPropVals["VALUE"];
				}
			}

			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"]];
						}
					}
				}
			}
			?>
			<<?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");
?>
>
				<?
				if ($crmMode)
				{
					?><DateUpdate><?php 
echo $DB->FormatDate($arOrder["DATE_UPDATE"], $dateFormat, "YYYY-MM-DD HH:MI:SS");
?>
</DateUpdate><?
				}
				?>
				<<?php 
echo GetMessage("SALE_EXPORT_CONTRAGENTS");
?>
>
					<<?php 
echo GetMessage("SALE_EXPORT_CONTRAGENT");
?>
>
						<<?php 
echo GetMessage("SALE_EXPORT_ID");
?>
><?php 
echo htmlspecialcharsbx($arOrder["USER_ID"] . "#" . $arProp["USER"]["LOGIN"] . "#" . $arProp["USER"]["LAST_NAME"] . " " . $arProp["USER"]["NAME"] . " " . $arProp["USER"]["SECOND_NAME"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_ID");
?>
>
						<<?php 
echo GetMessage("SALE_EXPORT_ITEM_NAME");
?>
><?php 
echo htmlspecialcharsbx($agent["AGENT_NAME"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_ITEM_NAME");
?>
>
						<?
						$address = "<".GetMessage("SALE_EXPORT_PRESENTATION").">".htmlspecialcharsbx($agent["ADDRESS_FULL"])."</".GetMessage("SALE_EXPORT_PRESENTATION").">";
						if(strlen($agent["INDEX"])>0)
						{
							$address .= "<".GetMessage("SALE_EXPORT_ADDRESS_FIELD").">
										<".GetMessage("SALE_EXPORT_TYPE").">".GetMessage("SALE_EXPORT_POST_CODE")."</".GetMessage("SALE_EXPORT_TYPE").">
										<".GetMessage("SALE_EXPORT_VALUE").">".htmlspecialcharsbx($agent["INDEX"])."</".GetMessage("SALE_EXPORT_VALUE").">
									</".GetMessage("SALE_EXPORT_ADDRESS_FIELD").">";
						}
						if(strlen($agent["COUNTRY"])>0)
						{
							$address .= "<".GetMessage("SALE_EXPORT_ADDRESS_FIELD").">
										<".GetMessage("SALE_EXPORT_TYPE").">".GetMessage("SALE_EXPORT_COUNTRY")."</".GetMessage("SALE_EXPORT_TYPE").">
										<".GetMessage("SALE_EXPORT_VALUE").">".htmlspecialcharsbx($agent["COUNTRY"])."</".GetMessage("SALE_EXPORT_VALUE").">
									</".GetMessage("SALE_EXPORT_ADDRESS_FIELD").">";
						}
						if(strlen($agent["REGION"])>0)
						{
							$address .= "<".GetMessage("SALE_EXPORT_ADDRESS_FIELD").">
										<".GetMessage("SALE_EXPORT_TYPE").">".GetMessage("SALE_EXPORT_REGION")."</".GetMessage("SALE_EXPORT_TYPE").">
										<".GetMessage("SALE_EXPORT_VALUE").">".htmlspecialcharsbx($agent["REGION"])."</".GetMessage("SALE_EXPORT_VALUE").">
									</".GetMessage("SALE_EXPORT_ADDRESS_FIELD").">";
						}
						if(strlen($agent["STATE"])>0)
						{
							$address .= "<".GetMessage("SALE_EXPORT_ADDRESS_FIELD").">
										<".GetMessage("SALE_EXPORT_TYPE").">".GetMessage("SALE_EXPORT_STATE")."</".GetMessage("SALE_EXPORT_TYPE").">
										<".GetMessage("SALE_EXPORT_VALUE").">".htmlspecialcharsbx($agent["STATE"])."</".GetMessage("SALE_EXPORT_VALUE").">
									</".GetMessage("SALE_EXPORT_ADDRESS_FIELD").">";
						}
						if(strlen($agent["TOWN"])>0)
						{
							$address .= "<".GetMessage("SALE_EXPORT_ADDRESS_FIELD").">
										<".GetMessage("SALE_EXPORT_TYPE").">".GetMessage("SALE_EXPORT_SMALL_CITY")."</".GetMessage("SALE_EXPORT_TYPE").">
										<".GetMessage("SALE_EXPORT_VALUE").">".htmlspecialcharsbx($agent["TOWN"])."</".GetMessage("SALE_EXPORT_VALUE").">
									</".GetMessage("SALE_EXPORT_ADDRESS_FIELD").">";
						}
						if(strlen($agent["CITY"])>0)
						{
							$address .= "<".GetMessage("SALE_EXPORT_ADDRESS_FIELD").">
										<".GetMessage("SALE_EXPORT_TYPE").">".GetMessage("SALE_EXPORT_CITY")."</".GetMessage("SALE_EXPORT_TYPE").">
										<".GetMessage("SALE_EXPORT_VALUE").">".htmlspecialcharsbx($agent["CITY"])."</".GetMessage("SALE_EXPORT_VALUE").">
									</".GetMessage("SALE_EXPORT_ADDRESS_FIELD").">";
						}
						if(strlen($agent["STREET"])>0)
						{
							$address .= "<".GetMessage("SALE_EXPORT_ADDRESS_FIELD").">
										<".GetMessage("SALE_EXPORT_TYPE").">".GetMessage("SALE_EXPORT_STREET")."</".GetMessage("SALE_EXPORT_TYPE").">
										<".GetMessage("SALE_EXPORT_VALUE").">".htmlspecialcharsbx($agent["STREET"])."</".GetMessage("SALE_EXPORT_VALUE").">
									</".GetMessage("SALE_EXPORT_ADDRESS_FIELD").">";
						}
						if(strlen($agent["HOUSE"])>0)
						{
							$address .= "<".GetMessage("SALE_EXPORT_ADDRESS_FIELD").">
										<".GetMessage("SALE_EXPORT_TYPE").">".GetMessage("SALE_EXPORT_HOUSE")."</".GetMessage("SALE_EXPORT_TYPE").">
										<".GetMessage("SALE_EXPORT_VALUE").">".htmlspecialcharsbx($agent["HOUSE"])."</".GetMessage("SALE_EXPORT_VALUE").">
									</".GetMessage("SALE_EXPORT_ADDRESS_FIELD").">";
						}
						if(strlen($agent["BUILDING"])>0)
						{
							$address .= "<".GetMessage("SALE_EXPORT_ADDRESS_FIELD").">
										<".GetMessage("SALE_EXPORT_TYPE").">".GetMessage("SALE_EXPORT_BUILDING")."</".GetMessage("SALE_EXPORT_TYPE").">
										<".GetMessage("SALE_EXPORT_VALUE").">".htmlspecialcharsbx($agent["BUILDING"])."</".GetMessage("SALE_EXPORT_VALUE").">
									</".GetMessage("SALE_EXPORT_ADDRESS_FIELD").">";
						}
						if(strlen($agent["FLAT"])>0)
						{
							$address .= "<".GetMessage("SALE_EXPORT_ADDRESS_FIELD").">
										<".GetMessage("SALE_EXPORT_TYPE").">".GetMessage("SALE_EXPORT_FLAT")."</".GetMessage("SALE_EXPORT_TYPE").">
										<".GetMessage("SALE_EXPORT_VALUE").">".htmlspecialcharsbx($agent["FLAT"])."</".GetMessage("SALE_EXPORT_VALUE").">
									</".GetMessage("SALE_EXPORT_ADDRESS_FIELD").">";
						}

						if($agent["IS_FIZ"]=="Y")
						{
							$arResultStat["CONTACTS"]++;
							?>
								<<?php 
echo GetMessage("SALE_EXPORT_FULL_NAME");
?>
><?php 
echo htmlspecialcharsbx($agent["FULL_NAME"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_FULL_NAME");
?>
>
								<?
								if(strlen($agent["SURNAME"])>0)
								{
									?><<?php 
echo GetMessage("SALE_EXPORT_SURNAME");
?>
><?php 
echo htmlspecialcharsbx($agent["SURNAME"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_SURNAME");
?>
><?
								}
								if(strlen($agent["NAME"])>0)
								{
									?><<?php 
echo GetMessage("SALE_EXPORT_NAME");
?>
><?php 
echo htmlspecialcharsbx($agent["NAME"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_NAME");
?>
><?
								}
								if(strlen($agent["SECOND_NAME"])>0)
								{
									?><<?php 
echo GetMessage("SALE_EXPORT_MIDDLE_NAME");
?>
><?php 
echo htmlspecialcharsbx($agent["SECOND_NAME"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_MIDDLE_NAME");
?>
><?
								}
								if(strlen($agent["BIRTHDAY"])>0)
								{
									?><<?php 
echo GetMessage("SALE_EXPORT_BIRTHDAY");
?>
><?php 
echo htmlspecialcharsbx($agent["BIRTHDAY"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_BIRTHDAY");
?>
><?
								}
								if(strlen($agent["MALE"])>0)
								{
									?><<?php 
echo GetMessage("SALE_EXPORT_SEX");
?>
><?php 
echo htmlspecialcharsbx($agent["MALE"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_SEX");
?>
><?
								}
								if(strlen($agent["INN"])>0)
								{
									?><<?php 
echo GetMessage("SALE_EXPORT_INN");
?>
><?php 
echo htmlspecialcharsbx($agent["INN"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_INN");
?>
><?
								}
								if(strlen($agent["KPP"])>0)
								{
									?><<?php 
echo GetMessage("SALE_EXPORT_KPP");
?>
><?php 
echo htmlspecialcharsbx($agent["KPP"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_KPP");
?>
><?
								}
								?>
								<<?php 
echo GetMessage("SALE_EXPORT_REGISTRATION_ADDRESS");
?>
>
									<?php 
echo $address;
?>
								</<?php 
echo GetMessage("SALE_EXPORT_REGISTRATION_ADDRESS");
?>
>
							<?
						}
						else
						{
							$arResultStat["COMPANIES"]++;
							?>
							<<?php 
echo GetMessage("SALE_EXPORT_OFICIAL_NAME");
?>
><?php 
echo htmlspecialcharsbx($agent["FULL_NAME"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_OFICIAL_NAME");
?>
>
							<<?php 
echo GetMessage("SALE_EXPORT_UR_ADDRESS");
?>
>
								<?php 
echo $address;
?>
							</<?php 
echo GetMessage("SALE_EXPORT_UR_ADDRESS");
?>
>
							<?
							if(strlen($agent["INN"])>0)
							{
								?><<?php 
echo GetMessage("SALE_EXPORT_INN");
?>
><?php 
echo htmlspecialcharsbx($agent["INN"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_INN");
?>
><?
							}
							if(strlen($agent["KPP"])>0)
							{
								?><<?php 
echo GetMessage("SALE_EXPORT_KPP");
?>
><?php 
echo htmlspecialcharsbx($agent["KPP"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_KPP");
?>
><?
							}
							if(strlen($agent["EGRPO"])>0)
							{
								?><<?php 
echo GetMessage("SALE_EXPORT_EGRPO");
?>
><?php 
echo htmlspecialcharsbx($agent["EGRPO"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_EGRPO");
?>
><?
							}
							if(strlen($agent["OKVED"])>0)
							{
								?><<?php 
echo GetMessage("SALE_EXPORT_OKVED");
?>
><?php 
echo htmlspecialcharsbx($agent["OKVED"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_OKVED");
?>
><?
							}
							if(strlen($agent["OKDP"])>0)
							{
								?><<?php 
echo GetMessage("SALE_EXPORT_OKDP");
?>
><?php 
echo htmlspecialcharsbx($agent["OKDP"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_OKDP");
?>
><?
							}
							if(strlen($agent["OKOPF"])>0)
							{
								?><<?php 
echo GetMessage("SALE_EXPORT_OKOPF");
?>
><?php 
echo htmlspecialcharsbx($agent["OKOPF"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_OKOPF");
?>
><?
							}
							if(strlen($agent["OKFC"])>0)
							{
								?><<?php 
echo GetMessage("SALE_EXPORT_OKFC");
?>
><?php 
echo htmlspecialcharsbx($agent["OKFC"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_OKFC");
?>
><?
							}
							if(strlen($agent["OKPO"])>0)
							{
								?><<?php 
echo GetMessage("SALE_EXPORT_OKPO");
?>
><?php 
echo htmlspecialcharsbx($agent["OKPO"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_OKPO");
?>
><?
							}
							if(strlen($agent["ACCOUNT_NUMBER"])>0)
							{
								?>
								<<?php 
echo GetMessage("SALE_EXPORT_MONEY_ACCOUNTS");
?>
>
									<<?php 
echo GetMessage("SALE_EXPORT_MONEY_ACCOUNT");
?>
>
										<<?php 
echo GetMessage("SALE_EXPORT_ACCOUNT_NUMBER");
?>
><?php 
echo htmlspecialcharsbx($agent["ACCOUNT_NUMBER"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_ACCOUNT_NUMBER");
?>
>
										<<?php 
echo GetMessage("SALE_EXPORT_BANK");
?>
>
											<<?php 
echo GetMessage("SALE_EXPORT_ITEM_NAME");
?>
><?php 
echo htmlspecialcharsbx($agent["B_NAME"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_ITEM_NAME");
?>
>
											<<?php 
echo GetMessage("SALE_EXPORT_ADDRESS");
?>
>
												<<?php 
echo GetMessage("SALE_EXPORT_PRESENTATION");
?>
><?php 
echo htmlspecialcharsbx($agent["B_ADDRESS_FULL"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_PRESENTATION");
?>
>
												<?
												if(strlen($agent["B_INDEX"])>0)
												{
													?><<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
>
													<<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
><?php 
echo GetMessage("SALE_EXPORT_POST_CODE");
?>
</<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
>
													<<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
><?php 
echo htmlspecialcharsbx($agent["B_INDEX"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
>
												</<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
><?
												}
												if(strlen($agent["B_COUNTRY"])>0)
												{
													?><<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
>
													<<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
><?php 
echo GetMessage("SALE_EXPORT_COUNTRY");
?>
</<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
>
													<<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
><?php 
echo htmlspecialcharsbx($agent["B_COUNTRY"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
>
												</<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
><?
												}
												if(strlen($agent["B_REGION"])>0)
												{
													?><<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
>
													<<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
><?php 
echo GetMessage("SALE_EXPORT_REGION");
?>
</<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
>
													<<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
><?php 
echo htmlspecialcharsbx($agent["B_REGION"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
>
												</<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
><?
												}
												if(strlen($agent["B_STATE"])>0)
												{
													?><<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
>
													<<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
><?php 
echo GetMessage("SALE_EXPORT_STATE");
?>
</<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
>
													<<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
><?php 
echo htmlspecialcharsbx($agent["B_STATE"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
>
												</<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
><?
												}
												if(strlen($agent["B_TOWN"])>0)
												{
													?><<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
>
													<<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
><?php 
echo GetMessage("SALE_EXPORT_SMALL_CITY");
?>
</<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
>
													<<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
><?php 
echo htmlspecialcharsbx($agent["B_TOWN"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
>
												</<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
><?
												}
												if(strlen($agent["B_CITY"])>0)
												{
													?><<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
>
													<<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
><?php 
echo GetMessage("SALE_EXPORT_CITY");
?>
</<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
>
													<<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
><?php 
echo htmlspecialcharsbx($agent["B_CITY"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
>
												</<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
><?
												}
												if(strlen($agent["B_STREET"])>0)
												{
													?><<?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($agent["B_STREET"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
>
												</<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
><?
												}
												if(strlen($agent["B_HOUSE"])>0)
												{
													?><<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
>
													<<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
><?php 
echo GetMessage("SALE_EXPORT_HOUSE");
?>
</<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
>
													<<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
><?php 
echo htmlspecialcharsbx($agent["B_HOUSE"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
>
												</<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
><?
												}
												if(strlen($agent["B_BUILDING"])>0)
												{
													?><<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
>
													<<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
><?php 
echo GetMessage("SALE_EXPORT_BUILDING");
?>
</<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
>
													<<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
><?php 
echo htmlspecialcharsbx($agent["B_BUILDING"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
>
												</<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
><?
												}
												if(strlen($agent["B_FLAT"])>0)
												{
													?><<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
>
													<<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
><?php 
echo GetMessage("SALE_EXPORT_FLAT");
?>
</<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
>
													<<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
><?php 
echo htmlspecialcharsbx($agent["B_FLAT"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
>
												</<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
><?
												}
												?>
											</<?php 
echo GetMessage("SALE_EXPORT_ADDRESS");
?>
>
											<?
											if(strlen($agent["B_BIK"])>0)
											{
												?><<?php 
echo GetMessage("SALE_EXPORT_BIC");
?>
><?php 
echo htmlspecialcharsbx($agent["B_BIK"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_BIC");
?>
><?
											}
											?>
										</<?php 
echo GetMessage("SALE_EXPORT_BANK");
?>
>
									</<?php 
echo GetMessage("SALE_EXPORT_MONEY_ACCOUNT");
?>
>
								</<?php 
echo GetMessage("SALE_EXPORT_MONEY_ACCOUNTS");
?>
>
								<?
							}
						}
						if(strlen($agent["F_ADDRESS_FULL"])>0)
						{
							?>
							<<?php 
echo GetMessage("SALE_EXPORT_ADDRESS");
?>
>
								<<?php 
echo GetMessage("SALE_EXPORT_PRESENTATION");
?>
><?php 
echo htmlspecialcharsbx($agent["F_ADDRESS_FULL"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_PRESENTATION");
?>
>
								<?
								if(strlen($agent["F_INDEX"])>0)
								{
									?>
									<<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
>
										<<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
><?php 
echo GetMessage("SALE_EXPORT_POST_CODE");
?>
</<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
>
										<<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
><?php 
echo htmlspecialcharsbx($agent["F_INDEX"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
>
									</<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
>
									<?
								}
								if(strlen($agent["F_COUNTRY"])>0)
								{
									?>
									<<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
>
										<<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
><?php 
echo GetMessage("SALE_EXPORT_COUNTRY");
?>
</<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
>
										<<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
><?php 
echo htmlspecialcharsbx($agent["F_COUNTRY"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
>
									</<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
>
									<?
								}
								if(strlen($agent["F_REGION"])>0)
								{
									?>
									<<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
>
										<<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
><?php 
echo GetMessage("SALE_EXPORT_REGION");
?>
</<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
>
										<<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
><?php 
echo htmlspecialcharsbx($agent["F_REGION"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
>
									</<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
>
									<?
								}
								if(strlen($agent["F_STATE"])>0)
								{
									?>
									<<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
>
										<<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
><?php 
echo GetMessage("SALE_EXPORT_STATE");
?>
</<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
>
										<<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
><?php 
echo htmlspecialcharsbx($agent["F_STATE"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
>
									</<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
>
									<?
								}
								if(strlen($agent["F_TOWN"])>0)
								{
									?>
									<<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
>
										<<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
><?php 
echo GetMessage("SALE_EXPORT_SMALL_CITY");
?>
</<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
>
										<<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
><?php 
echo htmlspecialcharsbx($agent["F_TOWN"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
>
									</<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
>
									<?
								}
								if(strlen($agent["F_CITY"])>0)
								{
									?>
									<<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
>
										<<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
><?php 
echo GetMessage("SALE_EXPORT_CITY");
?>
</<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
>
										<<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
><?php 
echo htmlspecialcharsbx($agent["F_CITY"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
>
									</<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
>
									<?
								}
								if(strlen($agent["F_STREET"])>0)
								{
									?>
									<<?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($agent["F_STREET"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
>
									</<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
>
									<?
								}
								if(strlen($agent["F_HOUSE"])>0)
								{
									?>
									<<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
>
										<<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
><?php 
echo GetMessage("SALE_EXPORT_HOUSE");
?>
</<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
>
										<<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
><?php 
echo htmlspecialcharsbx($agent["F_HOUSE"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
>
									</<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
>
									<?
								}
								if(strlen($agent["F_BUILDING"])>0)
								{
									?>
									<<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
>
										<<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
><?php 
echo GetMessage("SALE_EXPORT_BUILDING");
?>
</<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
>
										<<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
><?php 
echo htmlspecialcharsbx($agent["F_BUILDING"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
>
									</<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
>
									<?
								}
								if(strlen($agent["F_FLAT"])>0)
								{
									?>
									<<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
>
										<<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
><?php 
echo GetMessage("SALE_EXPORT_FLAT");
?>
</<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
>
										<<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
><?php 
echo htmlspecialcharsbx($agent["F_FLAT"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
>
									</<?php 
echo GetMessage("SALE_EXPORT_ADDRESS_FIELD");
?>
>
									<?
								}
								?>
							</<?php 
echo GetMessage("SALE_EXPORT_ADDRESS");
?>
>
							<?
						}
						if(strlen($agent["PHONE"])>0 || strlen($agent["EMAIL"])>0)
						{
							?>
							<<?php 
echo GetMessage("SALE_EXPORT_CONTACTS");
?>
>
								<?
								if(strlen($agent["PHONE"])>0)
								{
									?>
									<<?php 
echo GetMessage("SALE_EXPORT_CONTACT");
?>
>
										<<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
><?php 
echo GetMessage("SALE_EXPORT_WORK_PHONE");
?>
</<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
>
										<<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
><?php 
echo htmlspecialcharsbx($agent["PHONE"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
>
									</<?php 
echo GetMessage("SALE_EXPORT_CONTACT");
?>
>
									<?
								}
								if(strlen($agent["EMAIL"])>0)
								{
									?>
									<<?php 
echo GetMessage("SALE_EXPORT_CONTACT");
?>
>
										<<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
><?php 
echo GetMessage("SALE_EXPORT_MAIL");
?>
</<?php 
echo GetMessage("SALE_EXPORT_TYPE");
?>
>
										<<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
><?php 
echo htmlspecialcharsbx($agent["EMAIL"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
>
									</<?php 
echo GetMessage("SALE_EXPORT_CONTACT");
?>
>
									<?
								}
								?>
							</<?php 
echo GetMessage("SALE_EXPORT_CONTACTS");
?>
>
							<?
						}
						if(strlen($agent["CONTACT_PERSON"])>0)
						{
							?>
							<<?php 
echo GetMessage("SALE_EXPORT_REPRESENTATIVES");
?>
>
								<<?php 
echo GetMessage("SALE_EXPORT_REPRESENTATIVE");
?>
>
									<<?php 
echo GetMessage("SALE_EXPORT_CONTRAGENT");
?>
>
										<<?php 
echo GetMessage("SALE_EXPORT_RELATION");
?>
><?php 
echo GetMessage("SALE_EXPORT_CONTACT_PERSON");
?>
</<?php 
echo GetMessage("SALE_EXPORT_RELATION");
?>
>
										<<?php 
echo GetMessage("SALE_EXPORT_ID");
?>
><?php 
echo md5($agent["CONTACT_PERSON"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_ID");
?>
>
										<<?php 
echo GetMessage("SALE_EXPORT_ITEM_NAME");
?>
><?php 
echo htmlspecialcharsbx($agent["CONTACT_PERSON"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_ITEM_NAME");
?>
>
									</<?php 
echo GetMessage("SALE_EXPORT_CONTRAGENT");
?>
>
								</<?php 
echo GetMessage("SALE_EXPORT_REPRESENTATIVE");
?>
>
							</<?php 
echo GetMessage("SALE_EXPORT_REPRESENTATIVES");
?>
>
							<?
						}?>
						<<?php 
echo GetMessage("SALE_EXPORT_ROLE");
?>
><?php 
echo GetMessage("SALE_EXPORT_BUYER");
?>
</<?php 
echo GetMessage("SALE_EXPORT_ROLE");
?>
>
					</<?php 
echo GetMessage("SALE_EXPORT_CONTRAGENT");
?>
>
				</<?php 
echo GetMessage("SALE_EXPORT_CONTRAGENTS");
?>
>

				<<?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");
?>
>
				<?
				$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");
?>
>
					<?
				}
				if($i != -1)
					echo "</".GetMessage("SALE_EXPORT_TAXES").">";
				?>
				<?if(IntVal($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 
echo GetMessage("SALE_EXPORT_ITEMS");
?>
>
				<?
				$dbBasket = CSaleBasket::GetList(
						array("NAME" => "ASC"),
						array("ORDER_ID" => $arOrder["ID"])
					);
				$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 
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");
?>
>
						<?
						if(IntVal($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 
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");
?>
>
							<?
							$dbProp = CSaleBasket::GetPropsList(Array("SORT" => "ASC", "ID" => "ASC"), Array("BASKET_ID" => $arBasket["ID"], "!CODE" => array("CATALOG.XML_ID", "PRODUCT.XML_ID")));
							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 
echo GetMessage("SALE_EXPORT_PROPERTIES_VALUES");
?>
>
						<?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 
echo GetMessage("SALE_EXPORT_ITEM");
?>
>
					<?
					$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 
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 
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");
?>
>
						<?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 
echo GetMessage("SALE_EXPORT_ITEM");
?>
>
					<?
				}
				?>
				</<?php 
echo GetMessage("SALE_EXPORT_ITEMS");
?>
>
				<<?php 
echo GetMessage("SALE_EXPORT_PROPERTIES_VALUES");
?>
>
					<?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");
?>
>
						<?
					}
					if(strlen($arOrder["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 $arOrder["PAY_VOUCHER_NUM"];
?>
</<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
>
						</<?php 
echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
?>
>
						<?
					}
					if(IntVal($arOrder["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[$arOrder["PAY_SYSTEM_ID"]]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
>
						</<?php 
echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
?>
>
						<?
					}
					if(strlen($arOrder["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 $arOrder["DATE_ALLOW_DELIVERY"];
?>
</<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
>
						</<?php 
echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
?>
>
						<?
					}
					if(strlen($arOrder["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[$arOrder["DELIVERY_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_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 $arOrder["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");
?>
><?$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");
?>
>

					<?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");
?>
>
						<?
					}
					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");
?>
>
						<?
					}
					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");
?>
>
						<?
					}
					$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");
?>
>
					<?
					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 
echo GetMessage("SALE_EXPORT_PROPERTIES_VALUES");
?>
>
			</<?php 
echo GetMessage("SALE_EXPORT_DOCUMENT");
?>
>
			<?
			if ($crmMode)
			{
				$c = ob_get_clean();
				$c = CharsetConverter::ConvertCharset($c, $arCharSets[$arOrder["LID"]], "utf-8");
				echo $c;
			}
		}
		?>
		</<?php 
echo GetMessage("SALE_EXPORT_COM_INFORMATION");
?>
>
		<?
		return $arResultStat;
	}
Example #8
0
        $bUseDeliveryHandlers = false;
        ob_start();
        ?>
				<td width="40%" align="right">
					<?php 
        echo GetMessage("SOE_DELIVERY_COM");
        ?>
:
				</td>
				<td width="60%">
					<script language="JavaScript">
					<!--
					var arDeliveryPrice = new Array();
					var arDeliveryCurrency = new Array();
					<?php 
        $dbDelivery = CSaleDelivery::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("LID" => $str_LID, 'ACTIVE' => 'Y'), false, false, array("ID", "NAME", "SORT", "PRICE", "CURRENCY"));
        $arDeliveries = array();
        while ($arDelivery = $dbDelivery->GetNext()) {
            $bUseDelivery = true;
            $arDeliveries[] = $arDelivery;
            ?>
arDeliveryPrice[<?php 
            echo $arDelivery["ID"];
            ?>
]=<?php 
            echo $arDelivery["PRICE"];
            ?>
;<?php 
            ?>
arDeliveryCurrency[<?php 
            echo $arDelivery["ID"];
Example #9
0
 public function getDeliveryOptions($locationId = null, $from = null)
 {
     if (empty($locationId)) {
         $locationId = $this->getLocationId();
     }
     if (empty($locationId)) {
         throw new \Exception('Для получения служб доставки нужно указать место доставки ' . __METHOD__);
     }
     $filter = array('COMPABILITY' => array('WEIGHT' => $this->getWeight(), 'PRICE' => $this->getTotal(), 'LOCATION_FROM' => !empty($from) ? $from : \COption::GetOptionString('sale', 'location', false, SITE_ID), 'LOCATION_TO' => $locationId, 'ITEMS' => $this->getItemsRaw()));
     $delivery = array();
     $res = \CSaleDeliveryHandler::GetList(array('SORT' => 'ASC'), $filter);
     while ($deliveryItem = $res->Fetch()) {
         if (!is_array($deliveryItem) || !is_array($deliveryItem['PROFILES'])) {
             continue;
         }
         foreach ($deliveryItem['PROFILES'] as $key => $profile) {
             $deliveryProfile = array('ID' => $deliveryItem['SID'] . ':' . $key, 'SID' => $deliveryItem['SID'], 'PROFILE' => $key, 'NAME' => $deliveryItem['NAME'], 'TITLE' => $profile['TITLE'], 'DESCRIPTION' => $deliveryItem['DESCRIPTION'], 'DESCRIPTION_INNER' => $deliveryItem['DESCRIPTION_INNER'], 'BASE_CURRENCY' => $deliveryItem['BASE_CURRENCY'], 'HANDLER' => $deliveryItem['HANDLER'], 'DELIVERY' => $deliveryItem);
             $delivery[] = $deliveryProfile;
         }
     }
     $res = \CSaleDelivery::GetList(array('SORT' => 'ASC', 'NAME' => 'ASC'), array('LID' => SITE_ID, '+<=WEIGHT_FROM' => $this->getWeight(), '+>=WEIGHT_TO' => $this->getWeight(), 'ACTIVE' => 'Y', 'LOCATION' => $locationId));
     while ($deliveryItem = $res->Fetch()) {
         $deliveryDescription = \CSaleDelivery::GetByID($deliveryItem['ID']);
         $deliveryItem['DESCRIPTION'] = htmlspecialcharsbx($deliveryDescription['DESCRIPTION']);
         $delivery[] = $deliveryItem;
     }
     foreach ($delivery as $k => $deliveryItem) {
         if ($deliveryItem['NAME'] == 'Самовывоз') {
             continue;
         }
         if (empty($deliveryItem['SID'])) {
             continue;
         }
         /**
          * TODO
          * dimensions
          */
         $arOrderTmpDel = array('PRICE' => $this->getTotal(), 'WEIGHT' => $this->getWeight() / 1000, 'DIMENSIONS' => array(10, 10, 10), 'LOCATION_FROM' => COption::GetOptionInt('sale', 'location'), 'LOCATION_TO' => $locationId, 'ITEMS' => $this->getItemsRaw());
         $price = \CSaleDeliveryHandler::CalculateFull($deliveryItem['SID'], $deliveryItem['PROFILE'], $arOrderTmpDel, 'RUB');
         $delivery[$k]['PRICE'] = $price['VALUE'];
     }
     return $delivery;
 }
Example #10
0
 /**
  * Functions DoInstall and DoUninstall are
  * All other functions are optional
  */
 function DoInstall()
 {
     global $APPLICATION, $step, $arResult;
     if (!in_array('curl', get_loaded_extensions())) {
         $APPLICATION->ThrowException(GetMessage("INTAROCRM_CURL_ERR"));
         return false;
     }
     if (!date_default_timezone_get()) {
         if (!ini_get('date.timezone')) {
             $APPLICATION->ThrowException(GetMessage("DATE_TIMEZONE_ERR"));
             return false;
         }
     }
     include $this->INSTALL_PATH . '/../classes/general/RestApi.php';
     include $this->INSTALL_PATH . '/../classes/general/Response/ApiResponse.php';
     include $this->INSTALL_PATH . '/../classes/general/ICrmOrderActions.php';
     include $this->INSTALL_PATH . '/../classes/general/ICMLLoader.php';
     include $this->INSTALL_PATH . '/../classes/general/Exception/InvalidJsonException.php';
     include $this->INSTALL_PATH . '/../classes/general/Exception/CurlException.php';
     include $this->INSTALL_PATH . '/../classes/general/RestNormalizer.php';
     $step = intval($_REQUEST['step']);
     if (file_exists($_SERVER["DOCUMENT_ROOT"] . '/bitrix/modules/intaro.intarocrm/classes/general/config/options.xml')) {
         $options = simplexml_load_file($_SERVER["DOCUMENT_ROOT"] . '/bitrix/modules/intaro.intarocrm/classes/general/config/options.xml');
         foreach ($options->contragents->contragent as $contragent) {
             $type["NAME"] = $APPLICATION->ConvertCharset((string) $contragent, 'utf-8', SITE_CHARSET);
             $type["ID"] = (string) $contragent["id"];
             $arResult['contragentType'][] = $type;
             unset($type);
         }
         foreach ($options->fields->field as $field) {
             $type["NAME"] = $APPLICATION->ConvertCharset((string) $field, 'utf-8', SITE_CHARSET);
             $type["ID"] = (string) $field["id"];
             if ($field["group"] == 'custom') {
                 $arResult['customFields'][] = $type;
             } elseif (!$field["group"]) {
                 $arResult['orderProps'][] = $type;
             } else {
                 $groups = explode(",", (string) $field["group"]);
                 foreach ($groups as $group) {
                     $type["GROUP"][] = trim($group);
                 }
                 $arResult['legalDetails'][] = $type;
             }
             unset($type);
         }
     }
     if ($step == 11) {
         $arResult['arSites'] = array();
         $rsSites = CSite::GetList($by, $sort, array('ACTIVE' => 'Y'));
         while ($ar = $rsSites->Fetch()) {
             $arResult['arSites'][] = $ar;
         }
         if (count($arResult['arSites']) < 2) {
             $step = 2;
         }
     }
     if ($step <= 1) {
         if (!CModule::IncludeModule("sale")) {
             $arResult['errCode'] = 'ERR_SALE';
         }
         if (!CModule::IncludeModule("iblock")) {
             $arResult['errCode'] = 'ERR_IBLOCK';
         }
         if (!CModule::IncludeModule("catalog")) {
             $arResult['errCode'] = 'ERR_CATALOG';
         }
         $arResult['arSites'] = array();
         $rsSites = CSite::GetList($by, $sort, array('ACTIVE' => 'Y'));
         while ($ar = $rsSites->Fetch()) {
             $arResult['arSites'][] = $ar;
         }
         $APPLICATION->IncludeAdminFile(GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php');
     } else {
         if ($step == 11) {
             //new page
             if (!CModule::IncludeModule("sale")) {
                 $arResult['errCode'] = 'ERR_SALE';
             }
             if (!CModule::IncludeModule("iblock")) {
                 $arResult['errCode'] = 'ERR_IBLOCK';
             }
             if (!CModule::IncludeModule("catalog")) {
                 $arResult['errCode'] = 'ERR_CATALOG';
             }
             if (isset($arResult['errCode']) && $arResult['errCode']) {
                 $APPLICATION->IncludeAdminFile(GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php');
                 return;
             }
             $api_host = htmlspecialchars(trim($_POST[$this->CRM_API_HOST_OPTION]));
             $api_key = htmlspecialchars(trim($_POST[$this->CRM_API_KEY_OPTION]));
             // form correct url
             $api_host = parse_url($api_host);
             if ($api_host['scheme'] != 'https') {
                 $api_host['scheme'] = 'https';
             }
             $api_host = $api_host['scheme'] . '://' . $api_host['host'];
             if (!$api_host || !$api_key) {
                 $arResult['errCode'] = 'ERR_FIELDS_API_HOST';
                 $APPLICATION->IncludeAdminFile(GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php');
                 return;
             }
             $this->INTARO_CRM_API = new RetailCrm\RestApi($api_host, $api_key);
             //api key ok and sites list
             try {
                 $arResult['sitesList'] = $APPLICATION->ConvertCharsetArray($this->INTARO_CRM_API->sitesList()->sites, 'utf-8', SITE_CHARSET);
             } catch (\RetailCrm\Exception\CurlException $e) {
                 ICrmOrderActions::eventLog('intaro.crm/install/index.php', 'RetailCrm\\RestApi::sitesList', $e->getCode() . ': ' . $e->getMessage());
                 $arResult['errCode'] = 'ERR_' . $e->getCode();
                 $APPLICATION->IncludeAdminFile(GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php');
                 return;
             }
             COption::SetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, $api_host);
             COption::SetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, $api_key);
             $APPLICATION->IncludeAdminFile(GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step11.php');
         } else {
             if ($step == 2) {
                 //доставки, оплаты, типы заказов
                 if (!CModule::IncludeModule("sale")) {
                     $arResult['errCode'] = 'ERR_SALE';
                 }
                 if (!CModule::IncludeModule("iblock")) {
                     $arResult['errCode'] = 'ERR_IBLOCK';
                 }
                 if (!CModule::IncludeModule("catalog")) {
                     $arResult['errCode'] = 'ERR_CATALOG';
                 }
                 if (isset($arResult['errCode']) && $arResult['errCode']) {
                     $APPLICATION->IncludeAdminFile(GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php');
                     return;
                 }
                 $arResult['arSites'] = array();
                 $rsSites = CSite::GetList($by, $sort, array('ACTIVE' => 'Y'));
                 while ($ar = $rsSites->Fetch()) {
                     if (!$ar["SERVER_NAME"]) {
                         $arResult['errCode'] = 'URL_NOT_FOUND';
                         $APPLICATION->IncludeAdminFile(GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php');
                         return;
                     } else {
                         $arResult['arSites'][] = $ar;
                     }
                 }
                 if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' && isset($_POST['ajax']) && $_POST['ajax'] == 1) {
                     $api_host = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, 0);
                     $api_key = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, 0);
                     $this->INTARO_CRM_API = new \RetailCrm\RestApi($api_host, $api_key);
                     //prepare crm lists
                     try {
                         $arResult['orderTypesList'] = $this->INTARO_CRM_API->orderTypesList()->orderTypes;
                     } catch (\RetailCrm\Exception\CurlException $e) {
                         ICrmOrderActions::eventLog('intaro.crm/install/index.php', 'RetailCrm\\RestApi::orderTypesList::CurlException', $e->getCode() . ': ' . $e->getMessage());
                         $APPLICATION->RestartBuffer();
                         header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET);
                         die(json_encode(array("success" => false)));
                     }
                     try {
                         $arResult['deliveryTypesList'] = $this->INTARO_CRM_API->deliveryTypesList()->deliveryTypes;
                         $arResult['deliveryServicesList'] = $this->INTARO_CRM_API->deliveryServicesList()->deliveryServices;
                         $arResult['paymentTypesList'] = $this->INTARO_CRM_API->paymentTypesList()->paymentTypes;
                         $arResult['paymentStatusesList'] = $this->INTARO_CRM_API->paymentStatusesList()->paymentStatuses;
                         // --statuses
                         $arResult['paymentList'] = $this->INTARO_CRM_API->orderStatusesList()->statuses;
                         $arResult['paymentGroupList'] = $this->INTARO_CRM_API->orderStatusGroupsList()->statusGroups;
                         // -- statuses groups
                     } catch (\RetailCrm\Exception\CurlException $e) {
                         ICrmOrderActions::eventLog('intaro.crm/install/index.php', 'RetailCrm\\RestApi::*List::CurlException', $e->getCode() . ': ' . $e->getMessage());
                     }
                     //bitrix orderTypesList -- personTypes
                     $dbOrderTypesList = CSalePersonType::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("ACTIVE" => "Y"), false, false, array());
                     //form order types ids arr
                     $orderTypesArr = array();
                     if ($arOrderTypesList = $dbOrderTypesList->Fetch()) {
                         do {
                             $arResult['bitrixOrderTypesList'][] = $arOrderTypesList;
                             $orderTypesArr[$arOrderTypesList['ID']] = htmlspecialchars(trim($_POST['order-type-' . $arOrderTypesList['ID']]));
                         } while ($arOrderTypesList = $dbOrderTypesList->Fetch());
                     }
                     //bitrix deliveryTypesList
                     $dbDeliveryTypesList = CSaleDelivery::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("ACTIVE" => "Y"), false, false, array());
                     //form delivery types ids arr
                     $deliveryTypesArr = array();
                     if ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch()) {
                         do {
                             $arResult['bitrixDeliveryTypesList'][] = $arDeliveryTypesList;
                             $deliveryTypesArr[$arDeliveryTypesList['ID']] = htmlspecialchars(trim($_POST['delivery-type-' . $arDeliveryTypesList['ID']]));
                         } while ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch());
                     }
                     //bitrix deliveryServicesList
                     $dbDeliveryServicesList = CSaleDeliveryHandler::GetList(array('SORT' => 'ASC', 'NAME' => 'ASC'), array('ACTIVE' => 'Y', 'SITE_ID' => $arResult['arSites'][0]['LID']));
                     //form delivery services ids arr
                     if ($arDeliveryServicesList = $dbDeliveryServicesList->Fetch()) {
                         do {
                             //auto delivery types
                             $deliveryTypesArr[$arDeliveryServicesList['SID']] = htmlspecialchars(trim($_POST['delivery-type-' . $arDeliveryServicesList['SID']]));
                         } while ($arDeliveryServicesList = $dbDeliveryServicesList->Fetch());
                     }
                     //bitrix paymentTypesList
                     $dbPaymentTypesList = CSalePaySystem::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("ACTIVE" => "Y"));
                     //form payment types ids arr
                     $paymentTypesArr = array();
                     if ($arPaymentTypesList = $dbPaymentTypesList->Fetch()) {
                         do {
                             $arResult['bitrixPaymentTypesList'][] = $arPaymentTypesList;
                             $paymentTypesArr[$arPaymentTypesList['ID']] = htmlspecialchars(trim($_POST['payment-type-' . $arPaymentTypesList['ID']]));
                         } while ($arPaymentTypesList = $dbPaymentTypesList->Fetch());
                     }
                     //bitrix paymentStatusesList
                     $dbPaymentStatusesList = CSaleStatus::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("LID" => "ru", "ACTIVE" => "Y"));
                     //form payment statuses ids arr
                     $paymentStatusesArr['YY'] = htmlspecialchars(trim($_POST['payment-status-YY']));
                     if ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch()) {
                         do {
                             $arResult['bitrixPaymentStatusesList'][$arPaymentStatusesList['ID']] = $arPaymentStatusesList;
                             $paymentStatusesArr[$arPaymentStatusesList['ID']] = htmlspecialchars(trim($_POST['payment-status-' . $arPaymentStatusesList['ID']]));
                         } while ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch());
                     }
                     $arResult['bitrixPaymentStatusesList'][] = array('ID' => 'YY', 'NAME' => GetMessage('CANCELED'));
                     //form payment ids arr
                     $paymentArr = array();
                     $paymentArr['Y'] = htmlspecialchars(trim($_POST['payment-Y']));
                     $paymentArr['N'] = htmlspecialchars(trim($_POST['payment-N']));
                     COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_TYPES_ARR, serialize(ICrmOrderActions::clearArr($orderTypesArr)));
                     COption::SetOptionString($this->MODULE_ID, $this->CRM_DELIVERY_TYPES_ARR, serialize(ICrmOrderActions::clearArr($deliveryTypesArr)));
                     COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT_TYPES, serialize(ICrmOrderActions::clearArr($paymentTypesArr)));
                     COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT_STATUSES, serialize(ICrmOrderActions::clearArr($paymentStatusesArr)));
                     COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT, serialize(ICrmOrderActions::clearArr($paymentArr)));
                     // generate updated select inputs
                     $input = array();
                     foreach ($arResult['bitrixDeliveryTypesList'] as $bitrixDeliveryType) {
                         $input['delivery-type-' . $bitrixDeliveryType['ID']] = '<select name="delivery-type-' . $bitrixDeliveryType['ID'] . '" class="typeselect">';
                         $input['delivery-type-' . $bitrixDeliveryType['ID']] .= '<option value=""></option>';
                         foreach ($arResult['deliveryTypesList'] as $deliveryType) {
                             if ($deliveryTypesArr[$bitrixDeliveryType['ID']] == $deliveryType['code']) {
                                 $input['delivery-type-' . $bitrixDeliveryType['ID']] .= '<option value="' . $deliveryType['code'] . '" selected>';
                             } else {
                                 $input['delivery-type-' . $bitrixDeliveryType['ID']] .= '<option value="' . $deliveryType['code'] . '">';
                             }
                             $input['delivery-type-' . $bitrixDeliveryType['ID']] .= $APPLICATION->ConvertCharset($deliveryType['name'], 'utf-8', SITE_CHARSET);
                             $input['delivery-type-' . $bitrixDeliveryType['ID']] .= '</option>';
                         }
                         $input['delivery-type-' . $bitrixDeliveryType['ID']] .= '</select>';
                     }
                     foreach ($arResult['bitrixPaymentTypesList'] as $bitrixPaymentType) {
                         $input['payment-type-' . $bitrixPaymentType['ID']] = '<select name="payment-type-' . $bitrixPaymentType['ID'] . '" class="typeselect">';
                         $input['payment-type-' . $bitrixPaymentType['ID']] .= '<option value=""></option>';
                         foreach ($arResult['paymentTypesList'] as $paymentType) {
                             if ($paymentTypesArr[$bitrixPaymentType['ID']] == $paymentType['code']) {
                                 $input['payment-type-' . $bitrixPaymentType['ID']] .= '<option value="' . $paymentType['code'] . '" selected>';
                             } else {
                                 $input['payment-type-' . $bitrixPaymentType['ID']] .= '<option value="' . $paymentType['code'] . '">';
                             }
                             $input['payment-type-' . $bitrixPaymentType['ID']] .= $APPLICATION->ConvertCharset($paymentType['name'], 'utf-8', SITE_CHARSET);
                             $input['payment-type-' . $bitrixPaymentType['ID']] .= '</option>';
                         }
                         $input['payment-type-' . $bitrixPaymentType['ID']] .= '</select>';
                     }
                     foreach ($arResult['bitrixPaymentStatusesList'] as $bitrixPaymentStatus) {
                         $input['payment-status-' . $bitrixPaymentStatus['ID']] = '<select name="payment-status-' . $bitrixPaymentStatus['ID'] . '" class="typeselect">';
                         $input['payment-status-' . $bitrixPaymentStatus['ID']] .= '<option value=""></option>';
                         foreach ($arResult['paymentGroupList'] as $orderStatusGroup) {
                             if (empty($orderStatusGroup['statuses'])) {
                                 continue;
                             }
                             $input['payment-status-' . $bitrixPaymentStatus['ID']] .= '<optgroup label="' . $orderStatusGroup['name'] . '">';
                             foreach ($orderStatusGroup['statuses'] as $payment) {
                                 if (!isset($arResult['paymentList'][$payment])) {
                                     continue;
                                 }
                                 if ($paymentStatusesArr[$bitrixPaymentStatus['ID']] == $arResult['paymentList'][$payment]['code']) {
                                     $input['payment-status-' . $bitrixPaymentStatus['ID']] .= '<option value="' . $arResult['paymentList'][$payment]['code'] . '" selected>';
                                 } else {
                                     $input['payment-status-' . $bitrixPaymentStatus['ID']] .= '<option value="' . $arResult['paymentList'][$payment]['code'] . '">';
                                 }
                                 $input['payment-status-' . $bitrixPaymentStatus['ID']] .= $APPLICATION->ConvertCharset($arResult['paymentList'][$payment]['name'], 'utf-8', SITE_CHARSET);
                                 $input['payment-status-' . $bitrixPaymentStatus['ID']] .= '</option>';
                             }
                             $input['payment-status-' . $bitrixPaymentStatus['ID']] .= '</optgroup>';
                         }
                         $input['payment-status-' . $bitrixPaymentStatus['ID']] .= '</select>';
                     }
                     foreach ($arResult['bitrixPaymentList'] as $bitrixPayment) {
                         $input['payment-' . $bitrixPayment['ID']] = '<select name="payment-' . $bitrixPayment['ID'] . '" class="typeselect">';
                         $input['payment-' . $bitrixPayment['ID']] .= '<option value=""></option>';
                         foreach ($arResult['paymentStatusesList'] as $paymentStatus) {
                             if ($paymentArr[$bitrixPayment['ID']] == $paymentStatus['code']) {
                                 $input['payment-' . $bitrixPayment['ID']] .= '<option value="' . $paymentStatus['code'] . '" selected>';
                             } else {
                                 $input['payment-' . $bitrixPayment['ID']] .= '<option value="' . $paymentStatus['code'] . '">';
                             }
                             $input['payment-' . $bitrixPayment['ID']] .= $APPLICATION->ConvertCharset($paymentStatus['name'], 'utf-8', SITE_CHARSET);
                             $input['payment-' . $bitrixPayment['ID']] .= '</option>';
                         }
                         $input['payment-' . $bitrixPayment['ID']] .= '</select>';
                     }
                     foreach ($arResult['bitrixOrderTypesList'] as $bitrixOrderType) {
                         $input['order-type-' . $bitrixOrderType['ID']] = '<select name="order-type-' . $bitrixOrderType['ID'] . '" class="typeselect">';
                         $input['order-type-' . $bitrixOrderType['ID']] .= '<option value=""></option>';
                         foreach ($arResult['orderTypesList'] as $orderType) {
                             if ($orderTypesArr[$bitrixOrderType['ID']] == $orderType['code']) {
                                 $input['order-type-' . $bitrixOrderType['ID']] .= '<option value="' . $orderType['code'] . '" selected>';
                             } else {
                                 $input['order-type-' . $bitrixOrderType['ID']] .= '<option value="' . $orderType['code'] . '">';
                             }
                             $input['order-type-' . $bitrixOrderType['ID']] .= $APPLICATION->ConvertCharset($orderType['name'], 'utf-8', SITE_CHARSET);
                             $input['order-type-' . $bitrixOrderType['ID']] .= '</option>';
                         }
                         $input['order-type-' . $bitrixOrderType['ID']] .= '</select>';
                     }
                     $APPLICATION->RestartBuffer();
                     header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET);
                     die(json_encode(array("success" => true, "result" => $input)));
                 }
                 if (count($arResult['arSites']) > 1) {
                     // api load
                     $api_host = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, 0);
                     $api_key = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, 0);
                     foreach ($arResult['arSites'] as $site) {
                         if ($_POST['sites-id-' . $site['LID']] && !empty($_POST['sites-id-' . $site['LID']])) {
                             $siteCode[$site['LID']] = htmlspecialchars(trim($_POST['sites-id-' . $site['LID']]));
                         }
                     }
                     if (count($arResult['arSites']) != count($siteCode)) {
                         $arResult['errCode'] = 'ERR_FIELDS_API_HOST';
                         $APPLICATION->IncludeAdminFile(GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step11.php');
                         return;
                     }
                     $this->INTARO_CRM_API = new \RetailCrm\RestApi($api_host, $api_key);
                     COption::SetOptionString($this->MODULE_ID, $this->CRM_SITES_LIST, serialize($siteCode));
                 } else {
                     //если 1 сайт
                     $api_host = htmlspecialchars(trim($_POST[$this->CRM_API_HOST_OPTION]));
                     $api_key = htmlspecialchars(trim($_POST[$this->CRM_API_KEY_OPTION]));
                     // form correct url
                     $api_host = parse_url($api_host);
                     if ($api_host['scheme'] != 'https') {
                         $api_host['scheme'] = 'https';
                     }
                     $api_host = $api_host['scheme'] . '://' . $api_host['host'];
                     if (!$api_host || !$api_key) {
                         $arResult['errCode'] = 'ERR_FIELDS_API_HOST';
                         $APPLICATION->IncludeAdminFile(GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php');
                         return;
                     }
                     $this->INTARO_CRM_API = new \RetailCrm\RestApi($api_host, $api_key);
                     try {
                         $this->INTARO_CRM_API->paymentStatusesList()->paymentStatuses;
                     } catch (\RetailCrm\Exception\CurlException $e) {
                         ICrmOrderActions::eventLog('intaro.crm/install/index.php', 'RetailCrm\\RestApi::paymentStatusesList::CurlException', $e->getCode() . ': ' . $e->getMessage());
                         $arResult['errCode'] = 'ERR_' . $e->getCode();
                         $APPLICATION->IncludeAdminFile(GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php');
                         return;
                     }
                     COption::SetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, $api_host);
                     COption::SetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, $api_key);
                 }
                 //prepare crm lists
                 try {
                     $arResult['orderTypesList'] = $this->INTARO_CRM_API->orderTypesList()->orderTypes;
                     $arResult['deliveryTypesList'] = $this->INTARO_CRM_API->deliveryTypesList()->deliveryTypes;
                     $arResult['deliveryServicesList'] = $this->INTARO_CRM_API->deliveryServicesList()->deliveryServices;
                     $arResult['paymentTypesList'] = $this->INTARO_CRM_API->paymentTypesList()->paymentTypes;
                     $arResult['paymentStatusesList'] = $this->INTARO_CRM_API->paymentStatusesList()->paymentStatuses;
                     // --statuses
                     $arResult['paymentList'] = $this->INTARO_CRM_API->orderStatusesList()->statuses;
                     $arResult['paymentGroupList'] = $this->INTARO_CRM_API->orderStatusGroupsList()->statusGroups;
                     // -- statuses groups
                 } catch (\RetailCrm\Exception\CurlException $e) {
                     ICrmOrderActions::eventLog('intaro.crm/install/index.php', 'RetailCrm\\RestApi::*List::CurlException', $e->getCode() . ': ' . $e->getMessage());
                 }
                 //bitrix orderTypesList -- personTypes
                 $dbOrderTypesList = CSalePersonType::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("ACTIVE" => "Y"), false, false, array());
                 if ($arOrderTypesList = $dbOrderTypesList->Fetch()) {
                     do {
                         $arResult['bitrixOrderTypesList'][] = $arOrderTypesList;
                     } while ($arOrderTypesList = $dbOrderTypesList->Fetch());
                 }
                 //bitrix deliveryTypesList
                 $dbDeliveryTypesList = CSaleDelivery::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("ACTIVE" => "Y"), false, false, array());
                 if ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch()) {
                     do {
                         $arResult['bitrixDeliveryTypesList'][] = $arDeliveryTypesList;
                     } while ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch());
                 }
                 // bitrix deliveryServicesList
                 $dbDeliveryServicesList = CSaleDeliveryHandler::GetList(array('SORT' => 'ASC', 'NAME' => 'ASC'), array('ACTIVE' => 'Y', 'SITE_ID' => $arResult['arSites'][0]['LID']));
                 if ($arDeliveryServicesList = $dbDeliveryServicesList->Fetch()) {
                     do {
                         $arResult['bitrixDeliveryTypesList'][] = array('ID' => $arDeliveryServicesList['SID'], 'NAME' => $arDeliveryServicesList['NAME']);
                     } while ($arDeliveryServicesList = $dbDeliveryServicesList->Fetch());
                 }
                 //bitrix paymentTypesList
                 $dbPaymentTypesList = CSalePaySystem::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("ACTIVE" => "Y"));
                 if ($arPaymentTypesList = $dbPaymentTypesList->Fetch()) {
                     do {
                         $arResult['bitrixPaymentTypesList'][] = $arPaymentTypesList;
                     } while ($arPaymentTypesList = $dbPaymentTypesList->Fetch());
                 }
                 //bitrix paymentStatusesList --statuses
                 $dbPaymentStatusesList = CSaleStatus::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("LID" => "ru", "ACTIVE" => "Y"));
                 if ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch()) {
                     do {
                         $arResult['bitrixPaymentStatusesList'][$arPaymentStatusesList['ID']] = $arPaymentStatusesList;
                     } while ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch());
                 }
                 $arResult['bitrixPaymentStatusesList'][] = array('ID' => 'YY', 'NAME' => GetMessage('CANCELED'));
                 $APPLICATION->IncludeAdminFile(GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step2.php');
             } else {
                 if ($step == 3) {
                     //сопостовление свойств заказа
                     if (!CModule::IncludeModule("sale")) {
                         //handler
                     }
                     if (isset($_POST['back']) && $_POST['back']) {
                         $APPLICATION->IncludeAdminFile(GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php');
                     }
                     // api load
                     $api_host = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, 0);
                     $api_key = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, 0);
                     $this->INTARO_CRM_API = new \RetailCrm\RestApi($api_host, $api_key);
                     //bitrix orderTypesList -- personTypes
                     $dbOrderTypesList = CSalePersonType::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("ACTIVE" => "Y"), false, false, array());
                     //form order types ids arr
                     $orderTypesArr = array();
                     $arResult['bitrixOrderTypesList'] = array();
                     if ($arOrderTypesList = $dbOrderTypesList->Fetch()) {
                         do {
                             $orderTypesArr[$arOrderTypesList['ID']] = htmlspecialchars(trim($_POST['order-type-' . $arOrderTypesList['ID']]));
                             $arResult['bitrixOrderTypesList'][] = $arOrderTypesList;
                         } while ($arOrderTypesList = $dbOrderTypesList->Fetch());
                     }
                     //bitrix deliveryTypesList
                     $dbDeliveryTypesList = CSaleDelivery::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("ACTIVE" => "Y"), false, false, array());
                     //bitrix deliveryServicesList
                     $rsSites = CSite::GetList($by, $sort, array());
                     while ($ar = $rsSites->Fetch()) {
                         $arResult['arSites'][] = $ar;
                     }
                     $dbDeliveryServicesList = CSaleDeliveryHandler::GetList(array('SORT' => 'ASC', 'NAME' => 'ASC'), array('ACTIVE' => 'Y', 'SITE_ID' => $arResult['arSites'][0]['LID']));
                     //form delivery types / services ids arr
                     $deliveryTypesArr = array();
                     if (htmlspecialchars(trim($_POST['delivery-types-export'])) == 'false') {
                         if ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch()) {
                             do {
                                 $deliveryTypesArr[$arDeliveryTypesList['ID']] = htmlspecialchars(trim($_POST['delivery-type-' . $arDeliveryTypesList['ID']]));
                             } while ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch());
                         }
                         if ($arDeliveryServicesList = $dbDeliveryServicesList->Fetch()) {
                             do {
                                 //auto delivery types
                                 $deliveryTypesArr[$arDeliveryServicesList['SID']] = htmlspecialchars(trim($_POST['delivery-type-' . $arDeliveryServicesList['SID']]));
                             } while ($arDeliveryServicesList = $dbDeliveryServicesList->Fetch());
                         }
                     } elseif (htmlspecialchars(trim($_POST['delivery-types-export'])) == 'true') {
                         // send to intaro crm and save delivery types!
                         if ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch()) {
                             do {
                                 // parse id
                                 $arId = array();
                                 $resultDeliveryTypeId = 0;
                                 if (strpos($arDeliveryTypesList['ID'], ":") !== false) {
                                     $arId = explode(":", $arDeliveryTypesList['ID']);
                                 }
                                 if ($arId) {
                                     $resultDeliveryTypeId = $arId[0];
                                 } else {
                                     $resultDeliveryTypeId = $arDeliveryTypesList['ID'];
                                 }
                                 $deliveryTypesArr[$arDeliveryTypesList['ID']] = $resultDeliveryTypeId;
                                 // send to crm
                                 try {
                                     $this->INTARO_CRM_API->deliveryTypeEdit(ICrmOrderActions::clearArr(array('code' => $resultDeliveryTypeId, 'name' => ICrmOrderActions::toJSON($arDeliveryTypesList['NAME']), 'defaultCost' => $arDeliveryTypesList['PRICE'], 'description' => ICrmOrderActions::toJSON($arDeliveryTypesList['DESCRIPTION']), 'paymentTypes' => '')));
                                 } catch (\RetailCrm\Exception\CurlException $e) {
                                     ICrmOrderActions::eventLog('intaro.crm/install/index.php', 'RetailCrm\\RestApi::deliveryTypeEdit::CurlException', $e->getCode() . ': ' . $e->getMessage());
                                 }
                             } while ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch());
                         }
                         if ($arDeliveryServicesList = $dbDeliveryServicesList->Fetch()) {
                             do {
                                 $deliveryTypesArr[$arDeliveryServicesList['SID']] = $arDeliveryServicesList['SID'];
                                 // send to crm
                                 try {
                                     $this->INTARO_CRM_API->deliveryTypeEdit(ICrmOrderActions::clearArr(array('code' => $arDeliveryServicesList['SID'], 'name' => ICrmOrderActions::toJSON($arDeliveryServicesList['NAME']), 'defaultCost' => 0, 'description' => ICrmOrderActions::toJSON($arDeliveryTypesList['DESCRIPTION']), 'paymentTypes' => '')));
                                 } catch (\RetailCrm\Exception\CurlException $e) {
                                     ICrmOrderActions::eventLog('intaro.crm/install/index.php', 'RetailCrm\\RestApi::deliveryTypeEdit::CurlException', $e->getCode() . ': ' . $e->getMessage());
                                 }
                                 foreach ($arDeliveryServicesList['PROFILES'] as $id => $profile) {
                                     // send to crm
                                     try {
                                         $this->INTARO_CRM_API->deliveryServiceEdit(ICrmOrderActions::clearArr(array('code' => $arDeliveryServicesList['SID'] . '-' . $id, 'name' => ICrmOrderActions::toJSON($profile['TITLE']), 'deliveryType' => $arDeliveryServicesList['SID'])));
                                     } catch (\RetailCrm\Exception\CurlException $e) {
                                         ICrmOrderActions::eventLog('intaro.crm/install/index.php', 'IntaroCrm\\RestApi::deliveryServiceEdit::CurlException', $e->getCode() . ': ' . $e->getMessage());
                                     }
                                 }
                             } while ($arDeliveryServicesList = $dbDeliveryServicesList->Fetch());
                         }
                     }
                     //bitrix paymentTypesList
                     $dbPaymentTypesList = CSalePaySystem::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("ACTIVE" => "Y"));
                     //form payment types ids arr
                     $paymentTypesArr = array();
                     if ($arPaymentTypesList = $dbPaymentTypesList->Fetch()) {
                         do {
                             $paymentTypesArr[$arPaymentTypesList['ID']] = htmlspecialchars(trim($_POST['payment-type-' . $arPaymentTypesList['ID']]));
                         } while ($arPaymentTypesList = $dbPaymentTypesList->Fetch());
                     }
                     //bitrix paymentStatusesList
                     $dbPaymentStatusesList = CSaleStatus::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("LID" => "ru", "ACTIVE" => "Y"));
                     //form payment statuses ids arr
                     $paymentStatusesArr['YY'] = htmlspecialchars(trim($_POST['payment-status-YY']));
                     if ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch()) {
                         do {
                             $paymentStatusesArr[$arPaymentStatusesList['ID']] = htmlspecialchars(trim($_POST['payment-status-' . $arPaymentStatusesList['ID']]));
                         } while ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch());
                     }
                     //form payment ids arr
                     $paymentArr = array();
                     $paymentArr['Y'] = htmlspecialchars(trim($_POST['payment-Y']));
                     $paymentArr['N'] = htmlspecialchars(trim($_POST['payment-N']));
                     //form orderProps
                     $dbProp = CSaleOrderProps::GetList(array(), array());
                     while ($arProp = $dbProp->GetNext()) {
                         $arResult['arProp'][$arProp['PERSON_TYPE_ID']][] = $arProp;
                     }
                     COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_TYPES_ARR, serialize(ICrmOrderActions::clearArr($orderTypesArr)));
                     COption::SetOptionString($this->MODULE_ID, $this->CRM_DELIVERY_TYPES_ARR, serialize(ICrmOrderActions::clearArr($deliveryTypesArr)));
                     COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT_TYPES, serialize(ICrmOrderActions::clearArr($paymentTypesArr)));
                     COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT_STATUSES, serialize(ICrmOrderActions::clearArr($paymentStatusesArr)));
                     COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT, serialize(ICrmOrderActions::clearArr($paymentArr)));
                     COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_LAST_ID, 0);
                     COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_DISCHARGE, 1);
                     COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_FAILED_IDS, serialize(array()));
                     $APPLICATION->IncludeAdminFile(GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step3.php');
                 } else {
                     if ($step == 4) {
                         //выгрузка старых заказов
                         if (!CModule::IncludeModule("sale")) {
                             //handler
                         }
                         if (isset($_POST['back']) && $_POST['back']) {
                             $APPLICATION->IncludeAdminFile(GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step2.php');
                         }
                         if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' && isset($_POST['ajax']) && $_POST['ajax'] == 1) {
                             ICrmOrderActions::uploadOrders();
                             // each 50
                             $lastUpOrderId = COption::GetOptionString($this->MODULE_ID, $this->CRM_ORDER_LAST_ID, 0);
                             $countLeft = (int) CSaleOrder::GetList(array("ID" => "ASC"), array('>ID' => $lastUpOrderId), array());
                             $countAll = (int) CSaleOrder::GetList(array("ID" => "ASC"), array(), array());
                             if (!isset($_POST['finish'])) {
                                 $finish = 0;
                             } else {
                                 $finish = (int) $_POST['finish'];
                             }
                             $percent = round(100 - $countLeft * 100 / $countAll, 1);
                             if (!$countLeft) {
                                 $finish = 1;
                             }
                             $APPLICATION->RestartBuffer();
                             header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET);
                             die(json_encode(array("finish" => $finish, "percent" => $percent)));
                         }
                         if (isset($_POST['back']) && $_POST['back']) {
                             $APPLICATION->IncludeAdminFile(GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step2.php');
                         }
                         //bitrix orderTypesList -- personTypes
                         $dbOrderTypesList = CSalePersonType::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("ACTIVE" => "Y"), false, false, array());
                         //form order types ids arr
                         $orderTypesArr = array();
                         $orderTypesList = array();
                         if ($arOrderTypesList = $dbOrderTypesList->Fetch()) {
                             do {
                                 $orderTypesArr[$arOrderTypesList['ID']] = htmlspecialchars(trim($_POST['order-type-' . $arOrderTypesList['ID']]));
                                 $orderTypesList[] = $arOrderTypesList;
                             } while ($arOrderTypesList = $dbOrderTypesList->Fetch());
                         }
                         $orderPropsArr = array();
                         foreach ($orderTypesList as $orderType) {
                             $propsCount = 0;
                             $_orderPropsArr = array();
                             foreach ($arResult['orderProps'] as $orderProp) {
                                 if (!(int) htmlspecialchars(trim($_POST['address-detail-' . $orderType['ID']])) && $propsCount > 4) {
                                     break;
                                 }
                                 $_orderPropsArr[$orderProp['ID']] = htmlspecialchars(trim($_POST['order-prop-' . $orderProp['ID'] . '-' . $orderType['ID']]));
                                 $propsCount++;
                             }
                             $orderPropsArr[$orderType['ID']] = $_orderPropsArr;
                         }
                         //legal details props
                         $legalDetailsArr = array();
                         foreach ($orderTypesList as $orderType) {
                             $_legalDetailsArr = array();
                             foreach ($arResult['legalDetails'] as $legalDetails) {
                                 $_legalDetailsArr[$legalDetails['ID']] = htmlspecialchars(trim($_POST['legal-detail-' . $legalDetails['ID'] . '-' . $orderType['ID']]));
                             }
                             $legalDetailsArr[$orderType['ID']] = $_legalDetailsArr;
                         }
                         $customFieldsArr = array();
                         foreach ($orderTypesList as $orderType) {
                             $_customFieldsArr = array();
                             foreach ($arResult['customFields'] as $custom) {
                                 $_customFieldsArr[$custom['ID']] = htmlspecialchars(trim($_POST['custom-fields-' . $custom['ID'] . '-' . $orderType['ID']]));
                             }
                             $customFieldsArr[$orderType['ID']] = $_customFieldsArr;
                         }
                         //contragents type list
                         $contragentTypeArr = array();
                         //сделать проверки
                         foreach ($orderTypesList as $orderType) {
                             $contragentTypeArr[$orderType['ID']] = htmlspecialchars(trim($_POST['contragent-type-' . $orderType['ID']]));
                         }
                         COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_PROPS, serialize(ICrmOrderActions::clearArr($orderPropsArr)));
                         COption::SetOptionString($this->MODULE_ID, $this->CRM_CUSTOM_FIELDS, serialize(ICrmOrderActions::clearArr($customFieldsArr)));
                         COption::SetOptionString($this->MODULE_ID, $this->CRM_LEGAL_DETAILS, serialize(ICrmOrderActions::clearArr($legalDetailsArr)));
                         COption::SetOptionString($this->MODULE_ID, $this->CRM_CONTRAGENT_TYPE, serialize(ICrmOrderActions::clearArr($contragentTypeArr)));
                         $APPLICATION->IncludeAdminFile(GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step4.php');
                     } else {
                         if ($step == 5) {
                             //экспорт каталога
                             if (!CModule::IncludeModule("iblock")) {
                                 $arResult['errCode'] = 'ERR_IBLOCK';
                             }
                             if (!CModule::IncludeModule("catalog")) {
                                 $arResult['errCode'] = 'ERR_CATALOG';
                             }
                             $arResult['PRICE_TYPES'] = array();
                             $dbPriceType = CCatalogGroup::GetList(array("SORT" => "ASC"), array(), array(), array(), array("ID", "NAME", "BASE"));
                             while ($arPriceType = $dbPriceType->Fetch()) {
                                 $arResult['PRICE_TYPES'][$arPriceType['ID']] = $arPriceType;
                             }
                             $APPLICATION->IncludeAdminFile(GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step5.php');
                         } else {
                             if ($step == 6) {
                                 //регистрация модуля
                                 if (!CModule::IncludeModule("iblock")) {
                                     $arResult['errCode'] = 'ERR_IBLOCK';
                                 }
                                 if (!CModule::IncludeModule("catalog")) {
                                     $arResult['errCode'] = 'ERR_CATALOG';
                                 }
                                 if (isset($arResult['errCode']) && $arResult['errCode']) {
                                     $APPLICATION->IncludeAdminFile(GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step5.php');
                                     return;
                                 }
                                 if (isset($_POST['back']) && $_POST['back']) {
                                     $APPLICATION->IncludeAdminFile(GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step3.php');
                                 }
                                 if (!isset($_POST['IBLOCK_EXPORT'])) {
                                     $arResult['errCode'] = 'ERR_FIELDS_IBLOCK';
                                 } else {
                                     $iblocks = $_POST['IBLOCK_EXPORT'];
                                 }
                                 $iblockProperties = array("article" => "article", "manufacturer" => "manufacturer", "color" => "color", "weight" => "weight", "size" => "size", "length" => "length", "width" => "width", "height" => "height");
                                 $propertiesSKU = array();
                                 $propertiesUnitSKU = array();
                                 foreach ($iblockProperties as $prop) {
                                     foreach ($_POST['IBLOCK_PROPERTY_SKU' . '_' . $prop] as $iblock => $val) {
                                         $propertiesSKU[$iblock][$prop] = $val;
                                     }
                                     foreach ($_POST['IBLOCK_PROPERTY_UNIT_SKU' . '_' . $prop] as $iblock => $val) {
                                         $propertiesUnitSKU[$iblock][$prop] = $val;
                                     }
                                 }
                                 $propertiesProduct = array();
                                 $propertiesUnitProduct = array();
                                 foreach ($iblockProperties as $prop) {
                                     foreach ($_POST['IBLOCK_PROPERTY_PRODUCT' . '_' . $prop] as $iblock => $val) {
                                         $propertiesProduct[$iblock][$prop] = $val;
                                     }
                                     foreach ($_POST['IBLOCK_PROPERTY_UNIT_PRODUCT' . '_' . $prop] as $iblock => $val) {
                                         $propertiesUnitProduct[$iblock][$prop] = $val;
                                     }
                                 }
                                 if (!isset($_POST['SETUP_FILE_NAME'])) {
                                     $arResult['errCode'] = 'ERR_FIELDS_FILE';
                                 } else {
                                     $filename = $_POST['SETUP_FILE_NAME'];
                                 }
                                 if (!isset($_POST['TYPE_LOADING'])) {
                                     $typeLoading = 0;
                                 } else {
                                     $typeLoading = $_POST['TYPE_LOADING'];
                                 }
                                 if (!isset($_POST['SETUP_PROFILE_NAME'])) {
                                     $profileName = "";
                                 } else {
                                     $profileName = $_POST['SETUP_PROFILE_NAME'];
                                 }
                                 if ($typeLoading != 'none' && $profileName == "") {
                                     $arResult['errCode'] = 'ERR_FIELDS_PROFILE';
                                 }
                                 if ($filename == "") {
                                     $arResult['errCode'] = 'ERR_FIELDS_FILE';
                                 }
                                 if (isset($arResult['errCode']) && $arResult['errCode']) {
                                     $arOldValues = array('IBLOCK_EXPORT' => $iblocks, 'IBLOCK_PROPERTY_SKU' => $propertiesSKU, 'IBLOCK_PROPERTY_UNIT_SKU' => $propertiesUnitSKU, 'IBLOCK_PROPERTY_PRODUCT' => $propertiesProduct, 'IBLOCK_PROPERTY_UNIT_PRODUCT' => $propertiesUnitProduct, 'SETUP_FILE_NAME' => $filename, 'SETUP_PROFILE_NAME' => $profileName);
                                     global $oldValues;
                                     $oldValues = $arOldValues;
                                     $APPLICATION->IncludeAdminFile(GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step5.php');
                                     return;
                                 }
                                 RegisterModule($this->MODULE_ID);
                                 RegisterModuleDependences("sale", "OnSalePayOrder", $this->MODULE_ID, "ICrmOrderEvent", "onSalePayOrder");
                                 RegisterModuleDependences("sale", "OnSaleCancelOrder", $this->MODULE_ID, "ICrmOrderEvent", "onSaleCancelOrder");
                                 RegisterModuleDependences("sale", "OnBeforeOrderAccountNumberSet", $this->MODULE_ID, "ICrmOrderEvent", "onBeforeOrderAccountNumberSet");
                                 RegisterModuleDependences("sale", "OnOrderNewSendEmail", $this->MODULE_ID, "ICrmOrderEvent", "onSendOrderMail");
                                 RegisterModuleDependences("sale", "OnOrderUpdate", $this->MODULE_ID, "ICrmOrderEvent", "onUpdateOrder");
                                 RegisterModuleDependences("sale", "OnBeforeOrderAdd", $this->MODULE_ID, "ICrmOrderEvent", "onBeforeOrderAdd");
                                 RegisterModuleDependences("sale", "OnSaleBeforeReserveOrder", $this->MODULE_ID, "ICrmOrderEvent", "OnSaleBeforeReserveOrder");
                                 RegisterModuleDependences("sale", "OnSaleReserveOrder", $this->MODULE_ID, "ICrmOrderEvent", "onSaleReserveOrder");
                                 COption::SetOptionString($this->MODULE_ID, $this->CRM_CATALOG_BASE_PRICE, htmlspecialchars(trim($_POST['price-types'])));
                                 COption::SetOptionString($this->MODULE_ID, $this->CRM_CATALOG_IBLOCKS, $iblocks);
                                 $this->CopyFiles();
                                 if (isset($_POST['LOAD_NOW'])) {
                                     $rsSites = CSite::GetList($by, $sort, array('ACTIVE' => 'Y'));
                                     while ($ar = $rsSites->Fetch()) {
                                         if ($ar['DEF'] == 'Y') {
                                             $SERVER_NAME = $ar['SERVER_NAME'];
                                             //разделить потом с учетом многосайтовости
                                         }
                                     }
                                     $loader = new ICMLLoader();
                                     $loader->iblocks = $iblocks;
                                     $loader->propertiesUnitProduct = $propertiesUnitProduct;
                                     $loader->propertiesProduct = $propertiesProduct;
                                     $loader->propertiesUnitSKU = $propertiesUnitSKU;
                                     $loader->propertiesSKU = $propertiesSKU;
                                     $loader->filename = $filename;
                                     $loader->serverName = $SERVER_NAME;
                                     $loader->application = $APPLICATION;
                                     $loader->Load();
                                 }
                                 if ($typeLoading == 'agent' || $typeLoading == 'cron') {
                                     if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/' . $this->INTARO_CRM_EXPORT . '_run.php')) {
                                         $dbProfile = CCatalogExport::GetList(array(), array("FILE_NAME" => $this->INTARO_CRM_EXPORT));
                                         while ($arProfile = $dbProfile->Fetch()) {
                                             if ($arProfile["DEFAULT_PROFILE"] != "Y") {
                                                 CAgent::RemoveAgent("CCatalogExport::PreGenerateExport(" . $arProfile['ID'] . ");", "catalog");
                                                 CCatalogExport::Delete($arProfile['ID']);
                                             }
                                         }
                                     }
                                     $ar = $this->GetProfileSetupVars($iblocks, $propertiesProduct, $propertiesUnitProduct, $propertiesSKU, $propertiesUnitSKU, $filename);
                                     $PROFILE_ID = CCatalogExport::Add(array("LAST_USE" => false, "FILE_NAME" => $this->INTARO_CRM_EXPORT, "NAME" => $profileName, "DEFAULT_PROFILE" => "N", "IN_MENU" => "N", "IN_AGENT" => "N", "IN_CRON" => "N", "NEED_EDIT" => "N", "SETUP_VARS" => $ar));
                                     if (intval($PROFILE_ID) <= 0) {
                                         $arResult['errCode'] = 'ERR_IBLOCK';
                                         return;
                                     }
                                     if ($typeLoading == 'agent') {
                                         $dateAgent = new DateTime();
                                         $intAgent = new DateInterval('PT60S');
                                         // PT60S - 60 sec;
                                         $dateAgent->add($intAgent);
                                         CAgent::AddAgent("CCatalogExport::PreGenerateExport(" . $PROFILE_ID . ");", "catalog", "N", 86400, $dateAgent->format('d.m.Y H:i:s'), "Y", $dateAgent->format('d.m.Y H:i:s'), 30);
                                         CCatalogExport::Update($PROFILE_ID, array("IN_AGENT" => "Y"));
                                     } else {
                                         $agent_period = 24;
                                         $agent_php_path = "/usr/local/php/bin/php";
                                         if (!file_exists($_SERVER["DOCUMENT_ROOT"] . CATALOG_PATH2EXPORTS . "cron_frame.php")) {
                                             CheckDirPath($_SERVER["DOCUMENT_ROOT"] . CATALOG_PATH2EXPORTS);
                                             $tmp_file_size = filesize($_SERVER["DOCUMENT_ROOT"] . CATALOG_PATH2EXPORTS_DEF . "cron_frame.php");
                                             $fp = fopen($_SERVER["DOCUMENT_ROOT"] . CATALOG_PATH2EXPORTS_DEF . "cron_frame.php", "rb");
                                             $tmp_data = fread($fp, $tmp_file_size);
                                             fclose($fp);
                                             $tmp_data = str_replace("#DOCUMENT_ROOT#", $_SERVER["DOCUMENT_ROOT"], $tmp_data);
                                             $tmp_data = str_replace("#PHP_PATH#", $agent_php_path, $tmp_data);
                                             $fp = fopen($_SERVER["DOCUMENT_ROOT"] . CATALOG_PATH2EXPORTS . "cron_frame.php", "ab");
                                             fwrite($fp, $tmp_data);
                                             fclose($fp);
                                         }
                                         $cfg_data = "";
                                         if (file_exists($_SERVER["DOCUMENT_ROOT"] . "/bitrix/crontab/crontab.cfg")) {
                                             $cfg_file_size = filesize($_SERVER["DOCUMENT_ROOT"] . "/bitrix/crontab/crontab.cfg");
                                             $fp = fopen($_SERVER["DOCUMENT_ROOT"] . "/bitrix/crontab/crontab.cfg", "rb");
                                             $cfg_data = fread($fp, $cfg_file_size);
                                             fclose($fp);
                                         }
                                         CheckDirPath($_SERVER["DOCUMENT_ROOT"] . CATALOG_PATH2EXPORTS . "logs/");
                                         if ($arProfile["IN_CRON"] == "Y") {
                                             // remove
                                             $cfg_data = preg_replace("#^.*?" . preg_quote(CATALOG_PATH2EXPORTS) . "cron_frame.php +" . $PROFILE_ID . " *>.*?\$#im", "", $cfg_data);
                                         } else {
                                             $strTime = "0 */" . $agent_period . " * * * ";
                                             if (strlen($cfg_data) > 0) {
                                                 $cfg_data .= "\n";
                                             }
                                             $cfg_data .= $strTime . $agent_php_path . " -f " . $_SERVER["DOCUMENT_ROOT"] . CATALOG_PATH2EXPORTS . "cron_frame.php " . $PROFILE_ID . " >" . $_SERVER["DOCUMENT_ROOT"] . CATALOG_PATH2EXPORTS . "logs/" . $PROFILE_ID . ".txt\n";
                                         }
                                         CCatalogExport::Update($PROFILE_ID, array("IN_CRON" => "Y"));
                                         CheckDirPath($_SERVER["DOCUMENT_ROOT"] . "/bitrix/crontab/");
                                         $cfg_data = preg_replace("#[\r\n]{2,}#im", "\n", $cfg_data);
                                         $fp = fopen($_SERVER["DOCUMENT_ROOT"] . "/bitrix/crontab/crontab.cfg", "wb");
                                         fwrite($fp, $cfg_data);
                                         fclose($fp);
                                         $arRetval = array();
                                         @exec("crontab " . $_SERVER["DOCUMENT_ROOT"] . "/bitrix/crontab/crontab.cfg", $arRetval, $return_var);
                                     }
                                 }
                                 //agent
                                 $dateAgent = new DateTime();
                                 $intAgent = new DateInterval('PT60S');
                                 // PT60S - 60 sec;
                                 $dateAgent->add($intAgent);
                                 CAgent::AddAgent("ICrmOrderActions::orderAgent();", $this->MODULE_ID, "N", 600, $dateAgent->format('d.m.Y H:i:s'), "Y", $dateAgent->format('d.m.Y H:i:s'), 30);
                                 $api_host = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, 0);
                                 $api_key = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, 0);
                                 $this->INTARO_CRM_API = new \RetailCrm\RestApi($api_host, $api_key);
                                 try {
                                     $this->INTARO_CRM_API->statisticUpdate();
                                 } catch (\RetailCrm\Exception\CurlException $e) {
                                     ICrmOrderActions::eventLog('intaro.crm/install/index.php', 'RetailCrm\\RestApi::statisticUpdate::CurlException', $e->getCode() . ': ' . $e->getMessage());
                                 }
                                 // in fin order
                                 COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_HISTORY_DATE, date('Y-m-d H:i:s'));
                                 $APPLICATION->IncludeAdminFile(GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step6.php');
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Example #11
0
 } catch (\RetailCrm\Exception\CurlException $e) {
     ICrmOrderActions::eventLog('intaro.crm/options.php', 'RetailCrm\\RestApi::*List::CurlException', $e->getCode() . ': ' . $e->getMessage());
     echo CAdminMessage::ShowMessage(GetMessage('ERR_' . $e->getCode()));
 } catch (InvalidArgumentException $e) {
     $badKey = true;
     echo CAdminMessage::ShowMessage(GetMessage('ERR_403'));
 }
 //bitrix orderTypesList -- personTypes
 $dbOrderTypesList = CSalePersonType::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("ACTIVE" => "Y"), false, false, array());
 if ($arOrderTypesList = $dbOrderTypesList->Fetch()) {
     do {
         $arResult['bitrixOrderTypesList'][] = $arOrderTypesList;
     } while ($arOrderTypesList = $dbOrderTypesList->Fetch());
 }
 //bitrix deliveryTypesList
 $dbDeliveryTypesList = CSaleDelivery::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("ACTIVE" => "Y"), false, false, array());
 if ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch()) {
     do {
         $arResult['bitrixDeliveryTypesList'][] = $arDeliveryTypesList;
     } while ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch());
 }
 // bitrix deliveryServicesList
 $dbDeliveryServicesList = CSaleDeliveryHandler::GetList(array('SORT' => 'ASC', 'NAME' => 'ASC'), array('ACTIVE' => 'Y', 'SITE_ID' => $arResult['arSites'][0]['LID']));
 if ($arDeliveryServicesList = $dbDeliveryServicesList->Fetch()) {
     do {
         $arResult['bitrixDeliveryTypesList'][] = array('ID' => $arDeliveryServicesList['SID'], 'NAME' => $arDeliveryServicesList['NAME']);
     } while ($arDeliveryServicesList = $dbDeliveryServicesList->Fetch());
 }
 //bitrix paymentTypesList
 $dbPaymentTypesList = CSalePaySystem::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("ACTIVE" => "Y"));
 if ($arPaymentTypesList = $dbPaymentTypesList->Fetch()) {
Example #12
0
?>
<form method="post" action="<?php 
echo $APPLICATION->GetCurPage();
?>
?lang=<?php 
echo LANGUAGE_ID;
?>
" name="ymform">
<?php 
if (CSaleYMHandler::isActive(false)) {
    $tabControl->Begin();
    foreach ($arTabs as $arTab) {
        $tabControl->BeginNextTab();
        $siteSetts = CSaleYMHandler::getSettingsBySiteId($arTab["SITE_ID"]);
        $arDeliveryFilter = array("LID" => $arTab["SITE_ID"], "ACTIVE" => "Y");
        $dbDeliveryList = CSaleDelivery::GetList(array("NAME" => "ASC"), $arDeliveryFilter, false, false, array("ID", "NAME"));
        $arDeliveryList = array();
        while ($arDelivery = $dbDeliveryList->Fetch()) {
            $arDeliveryList[$arDelivery["ID"]] = $arDelivery["NAME"];
        }
        $dbResultList = CSalePersonType::GetList("NAME", "ASC", array("LID" => $arTab["SITE_ID"], "ACTIVE" => "Y"));
        $arPersonTypes = array();
        while ($arPT = $dbResultList->Fetch()) {
            $arPersonTypes[$arPT['ID']] = $arPT['NAME'];
        }
        if (isset($siteSetts["PERSON_TYPE"]) && array_key_exists($siteSetts["PERSON_TYPE"], $arPersonTypes)) {
            $personTypeId = $siteSetts["PERSON_TYPE"];
        } else {
            reset($arPersonTypes);
            $personTypeId = key($arPersonTypes);
        }
Example #13
0
    // разбиваем элементы по разделам
    foreach ($arElements as $arElem)
    {
        $sectionID = $arElem['SECTION_ID'];
        if (!isset($arModifiers[$sectionID]))
        {
            $arModifiers[$sectionID] = array(
                'ID'   => $arElem['SECTION_ID'],
                'NAME' => $arElem['SECTION_NAME']
            );
        }
        $arModifiers[$sectionID]['ITEMS'][] = $arElem;
    }
}

$rsDelivery = CSaleDelivery::GetList(array('SORT' => 'ASC'));
while ($arItem = $rsDelivery->Fetch())
{
    $arDelivery[] = array(
        'ID' => $arItem['ID'],
        'NAME' => $arItem['NAME']
    );
}

$rsOrderProps = CSaleOrderProps::GetList();
while ($arItem = $rsOrderProps->Fetch())
{
    $arOrderProps[] = $arItem;
}

$aTabs = array(
Example #14
0
    $dbRes = CSaleOrderProps::GetOrderPropsRelations(array("PROPERTY_ID" => $ID, "ENTITY_TYPE" => "D"));
    while ($arRes = $dbRes->Fetch()) {
        $arDeliverySystemID[] = $arRes["ENTITY_ID"];
    }
}
?>
					<option value="" <?php 
echo count($arDeliverySystemID) <= 0 ? "selected" : "";
?>
><?php 
echo GetMessage("SALE_PROPERTY_SELECT_ALL");
?>
</option>
				<?php 
$arDeliveryOptions = array();
$dbResultList = CSaleDelivery::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("ACTIVE" => "Y"), false, false, array("ID", "NAME", "ACTIVE", "SORT"));
while ($arDeliverySystem = $dbResultList->Fetch()) {
    $selected = in_array($arDeliverySystem["ID"], $arDeliverySystemID) ? " selected=\"selected\"" : "";
    $arDeliveryOptions[] = "<option value=\"" . intval($arDeliverySystem["ID"]) . "\"" . $selected . ">" . htmlspecialcharsbx($arDeliverySystem["NAME"]) . " [" . $arDeliverySystem["ID"] . "]</option>";
}
$dbDeliveryServices = CSaleDeliveryHandler::GetList(array("SORT" => "ASC"), array("SITE_ID" => trim($arPersonType["LID"])));
while ($arDeliveryService = $dbDeliveryServices->GetNext()) {
    $dsName = strlen($arDeliveryService["LID"]) > 0 ? " (" . $arDeliveryService["LID"] . ")" : "";
    foreach ($arDeliveryService["PROFILES"] as $profileId => $arDeliveryProfile) {
        if ($arDeliveryProfile["ACTIVE"] != "Y") {
            continue;
        }
        $id = $arDeliveryService["SID"] . ":" . $profileId;
        $selected = in_array($id, $arDeliverySystemID) ? " selected=\"selected\"" : "";
        $arDeliveryOptions[] = "<option" . $selected . " value=\"" . $id . "\">" . $arDeliveryService["NAME"] . " (" . $arDeliveryProfile["TITLE"] . ") [" . $id . "] " . $dsName . "</option>";
    }
Example #15
0
 protected function getDeliveryOptions($delivery, $price, $weight = 0)
 {
     $arResult = array();
     $locationId = $this->locationMapper->getLocationByCityName($delivery["region"]["name"]);
     if ($locationId > 0) {
         foreach ($this->mapDelivery as $deliveryId => $deliveryType) {
             if ($deliveryType == "") {
                 continue;
             }
             $filter = array("ID" => $deliveryId, "LID" => $this->siteId, "ACTIVE" => "Y", "LOCATION" => $locationId, "+<=ORDER_PRICE_FROM" => $price, "+>=ORDER_PRICE_TO" => $price);
             if (intval($weight) > 0) {
                 $filter["+<=WEIGHT_FROM"] = $weight;
                 $filter["+>=WEIGHT_TO"] = $weight;
             }
             $dbDelivery = CSaleDelivery::GetList(array("SORT" => "ASC", "NAME" => "ASC"), $filter);
             if ($arDelivery = $dbDelivery->Fetch()) {
                 $arDates = $this->getDeliveryDates($arDelivery["PERIOD_FROM"], $arDelivery["PERIOD_TO"], $arDelivery["PERIOD_TYPE"]);
                 if (!empty($arDates)) {
                     $arDeliveryTmp = array("id" => $arDelivery["ID"], "type" => $deliveryType, "serviceName" => substr($arDelivery["NAME"], 0, 50), "price" => round(floatval($arDelivery["PRICE"]), 2), "dates" => $arDates);
                     if ($deliveryType == "PICKUP" && !empty($this->outlets)) {
                         foreach ($this->outlets as $outlet) {
                             $arDeliveryTmp["outlets"][] = array("id" => intval($outlet));
                         }
                     }
                     $arResult[] = $arDeliveryTmp;
                 }
             }
         }
     }
     return $arResult;
 }
Example #16
0
                break;
            case "activate":
            case "deactivate":
                $arFields = array("ACTIVE" => $_REQUEST['action'] == "activate" ? "Y" : "N");
                if (!CSaleDelivery::Update($ID, $arFields)) {
                    if ($ex = $APPLICATION->GetException()) {
                        $lAdmin->AddGroupError($ex->GetString(), $ID);
                    } else {
                        $lAdmin->AddGroupError(GetMessage("SDAN_ERROR_UPDATE"), $ID);
                    }
                }
                break;
        }
    }
}
$dbResultList = CSaleDelivery::GetList(array($by => $order), $arFilter, false, false, array("*"));
$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" => "LID", "content" => GetMessage('SALE_LID'), "sort" => "LID", "default" => true), array("id" => "WEIGHT", "content" => GetMessage("SALE_WEIGHT"), "sort" => "", "default" => true), array("id" => "ORDER_PRICE", "content" => GetMessage("SALE_ORDER_PRICE"), "sort" => "", "default" => true), array("id" => "SORT", "content" => GetMessage("SALE_SORT"), "sort" => "SORT", "default" => true), array("id" => "ACTIVE", "content" => GetMessage("SALE_ACTIVE"), "sort" => "ACTIVE", "default" => true), array("id" => "PRICE", "content" => GetMessage("SALE_PRICE"), "sort" => "PRICE", "default" => true)));
$arVisibleColumns = $lAdmin->GetVisibleHeaderColumns();
while ($arCCard = $dbResultList->NavNext(true, "f_")) {
    $row =& $lAdmin->AddRow($f_ID, $arCCard, "sale_delivery_edit.php?ID=" . $f_ID . "&lang=" . LANG, GetMessage("SALE_EDIT_DESCR"));
    $row->AddField("ID", "<a href=\"sale_delivery_edit.php?ID=" . $f_ID . "&lang=" . LANG . "\">" . $f_ID . "</a>");
    $row->AddField("NAME", $f_NAME);
    $row->AddField("LID", $f_LID);
    $fieldValue = "";
    if (IntVal($f_WEIGHT_FROM) > 0) {
        $fieldValue .= " " . GetMessage("SALE_FROM") . " " . $f_WEIGHT_FROM;
    }
    if (IntVal($f_WEIGHT_TO) > 0) {
Example #17
0
				$arDeliveryServicesList = array();
				while ($arDeliveryService = $rsDeliveryServicesList->Fetch())
				{
					if (!is_array($arDeliveryService) || !is_array($arDeliveryService["PROFILES"])) continue;

					foreach ($arDeliveryService["PROFILES"] as $profile_id => $arDeliveryProfile)
					{
						$delivery_id = $arDeliveryService["SID"].":".$profile_id;
						?><option value="<?echo htmlspecialcharsbx($delivery_id)?>"<?if (is_array($filter_delivery) && in_array($delivery_id, $filter_delivery)) echo " selected"?>>[<?echo htmlspecialcharsbx($delivery_id)?>] <?echo htmlspecialcharsbx($arDeliveryService["NAME"].": ".$arDeliveryProfile["TITLE"])?></option><?
					}
				}

				/*Old Delivery*/
				$dbDelivery = CSaleDelivery::GetList(
							array("SORT"=>"ASC", "NAME"=>"ASC"),
							array(
									"ACTIVE" => "Y",
								)
					);

				while ($arDelivery = $dbDelivery->GetNext())
				{
					?><option value="<?echo $arDelivery["ID"]?>"<?if (is_array($filter_delivery) && in_array($arDelivery["ID"], $filter_delivery)) echo " selected"?>>[<?echo $arDelivery["ID"]?>] <?echo $arDelivery["NAME"]?></option><?
				}
				?>
			</select>
		</td>
	</tr>
	<tr>
		<td><?echo GetMessage("SALE_F_CANCELED")?>:</td>
		<td>
			<select name="filter_canceled">
</option>
				<?php 
}
?>
			</select>
		</td>
	</tr>

<?php 
$arStoreList = array();
$dbList = CCatalogStore::GetList(array("ID" => "DESC"), array("ACTIVE" => "Y"), false, false, array("ID", "TITLE", "ADDRESS", "DESCRIPTION", "IMAGE_ID", "PHONE", "SCHEDULE", "LOCATION_ID", "GPS_N", "GPS_S"));
while ($arList = $dbList->Fetch()) {
    $arStoreList[] = $arList;
}
if (count($arStoreList) > 0) {
    $dbList = CSaleDelivery::GetList(array(), array("ID" => $str_ID), false, false, array("STORE"));
    $arList = $dbList->Fetch();
    $str_STORE = $arList["STORE"];
    $arStore = array();
    if (strlen($str_STORE) > 0) {
        $arStore = unserialize($str_STORE);
    }
    ?>
	<tr>
		<td width="40%" valign="top"><?php 
    echo GetMessage("SDEN_STORE");
    ?>
:</td>
		<td width="60%" valign="top">
			<select name="STORE[]" size="5" multiple>
			<?php 
Example #19
0
        } else {
            $ID = CSaleDelivery::Add($arFields);
            if ($ID <= 0) {
                $strError .= GetMessage("ERROR_ADD_DELIVERY") . "<br>";
            }
        }
    }
    if (strlen($strError) > 0) {
        $bInitVars = True;
    }
    if (strlen($save) > 0 && strlen($strError) <= 0) {
        LocalRedirect("sale_delivery.php?lang=" . LANG . GetFilterParams("filter_", false));
    }
}
if ($ID > 0) {
    $db_delivery = CSaleDelivery::GetList(array("SORT" => "ASC"), array("ID" => $ID));
    $db_delivery->ExtractFields("str_");
    $arDeliveryDescription = CSaleDelivery::GetByID($ID);
    $str_DESCRIPTION = $arDeliveryDescription["DESCRIPTION"];
} else {
    $str_ACTIVE = 'Y';
}
if ($bInitVars) {
    $DB->InitTableVarsForEdit("b_sale_delivery", "", "str_");
}
$sDocTitle = $ID > 0 ? str_replace("#ID#", $ID, GetMessage("SALE_EDIT_RECORD")) : GetMessage("SALE_NEW_RECORD");
$APPLICATION->SetTitle($sDocTitle);
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
/*********************************************************************/
/********************  BODY  *****************************************/
/*********************************************************************/
Example #20
0
            }
            CSaleBasket::Add($arFields);
        }
        LocalRedirect($arParams["PATH_TO_BASKET"]);
    }
}
//Save statuses for Filter form
$dbStatus = CSaleStatus::GetList(array("SORT" => "ASC"), array("LID" => LANGUAGE_ID));
while ($arStatus = $dbStatus->GetNext()) {
    $arResult["INFO"]["STATUS"][$arStatus["ID"]] = $arStatus;
}
$dbPaySystem = CSalePaySystem::GetList(array("SORT" => "ASC"));
while ($arPaySystem = $dbPaySystem->GetNext()) {
    $arResult["INFO"]["PAY_SYSTEM"][$arPaySystem["ID"]] = $arPaySystem;
}
$dbDelivery = CSaleDelivery::GetList(array("SORT" => "ASC"));
while ($arDelivery = $dbDelivery->GetNext()) {
    $arResult["INFO"]["DELIVERY"][$arDelivery["ID"]] = $arDelivery;
}
$arResult["INFO"]["DELIVERY_HANDLERS"] = array();
$dbDelivery = CSaleDeliveryHandler::GetList(array(), array(array("SITE_ID" => SITE_ID)));
while ($arDeliveryHandler = $dbDelivery->GetNext()) {
    $arResult["INFO"]["DELIVERY_HANDLERS"][$arDeliveryHandler["SID"]] = $arDeliveryHandler;
}
$arResult["CURRENT_PAGE"] = $APPLICATION->GetCurPage();
//Preparing filter
$arFilter = array();
$arFilter["USER_ID"] = IntVal($USER->GetID());
if (strlen($_REQUEST["del_filter"]) > 0) {
    unset($_REQUEST["filter_id"]);
    unset($_REQUEST["filter_date_from"]);
Example #21
0
	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");
?>
=.">
		<?
		$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")
				);
			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);
					$arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"]] =  ($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"]."_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"];
				}
			}

			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"]];
					}
				}
			}
			?>
			<<?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");
?>
>
				<?
				if($bNewVersion)
				{
					?>
					<<?php 
echo GetMessage("SALE_EXPORT_VERSION");
?>
><?php 
echo IntVal($arOrder["VERSION"]) > 0 ? $arOrder["VERSION"] : 0;
?>
</<?php 
echo GetMessage("SALE_EXPORT_VERSION");
?>
>
					<?
					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");
?>
><?
					}
				}
				if ($crmMode)
				{
					?><DateUpdate><?php 
echo $DB->FormatDate($arOrder["DATE_UPDATE"], $dateFormat, "YYYY-MM-DD HH:MI:SS");
?>
</DateUpdate><?
				}

				$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");
?>
>
				<?
				$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");
?>
>
					<?
				}
				if($i != -1)
					echo "</".GetMessage("SALE_EXPORT_TAXES").">";
				?>
				<?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");
?>
>
					<?
				}

				$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");
?>
>
					<?
					/*
					$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");
?>
>
				<?
				$dbBasket = CSaleBasket::GetList(
						array("NAME" => "ASC"),
						array("ORDER_ID" => $arOrder["ID"]),
						false,
						false,
						array("ID", "NOTES", "PRODUCT_XML_ID", "CATALOG_XML_ID", "NAME", "PRICE", "QUANTITY", "DISCOUNT_PRICE", "VAT_RATE", "MEASURE_CODE")
					);
				$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");
?>
>
						<?
						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");
?>
>
							<?
						}
						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");
?>
>
							<?
						}
						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 
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");
?>
>
							<?
							$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 
echo GetMessage("SALE_EXPORT_PROPERTIES_VALUES");
?>
>
						<?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 
echo $storeBasket;
?>
					</<?php 
echo GetMessage("SALE_EXPORT_ITEM");
?>
>
					<?
					$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");
?>
>
						<?
						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");
?>
>
						<?
						}
						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 
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");
?>
>
						<?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 
echo GetMessage("SALE_EXPORT_ITEM");
?>
>
					<?
				}
				?>
				</<?php 
echo GetMessage("SALE_EXPORT_ITEMS");
?>
>
				<<?php 
echo GetMessage("SALE_EXPORT_PROPERTIES_VALUES");
?>
>
					<?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");
?>
>
						<?
					}
					if(strlen($arOrder["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($arOrder["PAY_VOUCHER_NUM"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
>
						</<?php 
echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
?>
>
						<?
					}
					if(IntVal($arOrder["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[$arOrder["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($arOrder["PAY_SYSTEM_ID"]);
?>
</<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
>
						</<?php 
echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
?>
>
						<?
					}
					if(strlen($arOrder["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 $arOrder["DATE_ALLOW_DELIVERY"];
?>
</<?php 
echo GetMessage("SALE_EXPORT_VALUE");
?>
>
						</<?php 
echo GetMessage("SALE_EXPORT_PROPERTY_VALUE");
?>
>
						<?
					}
					if(strlen($arOrder["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[$arOrder["DELIVERY_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_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 $arOrder["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");
?>
><?$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");
?>
>
					<?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");
?>
>
						<?
					}
					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");
?>
>
						<?
					}
					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");
?>
>
						<?
					}
					$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");
?>
>
					<?
					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");
?>
>
								<?
							}
						}
					}

					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 
echo GetMessage("SALE_EXPORT_PROPERTIES_VALUES");
?>
>
			</<?php 
echo GetMessage("SALE_EXPORT_DOCUMENT");
?>
>
			<?
			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");
?>
>
		<?
		return $arResultStat;
	}
 public static function getSyncData()
 {
     $arD2PS = array();
     $dbD2PS = self::GetList();
     while ($arTmpD2PS = $dbD2PS->Fetch()) {
         $arD2PS[] = $arTmpD2PS;
     }
     static $arPS = null;
     if (is_null($arPS)) {
         $arPS = array();
         $dbPS = CSalePaySystem::GetList();
         while ($arTmpPS = $dbPS->Fetch()) {
             $arPS[] = $arTmpPS;
         }
     }
     static $arDS = null;
     if (is_null($arDS)) {
         $arDS = array();
         $dbDS = CSaleDeliveryHandler::GetList();
         while ($arTmpDS = $dbDS->Fetch()) {
             $arDS[] = $arTmpDS;
         }
         $dbDS = CSaleDelivery::GetList();
         while ($arTmpDS = $dbDS->Fetch()) {
             if (!isset($arTmpDS["SID"])) {
                 $arTmpDS["SID"] = $arTmpDS["ID"];
             }
             $arDS[] = $arTmpDS;
         }
     }
     return array("D2PS" => $arD2PS, "DS" => $arDS, "PS" => $arPS);
 }
Example #23
0
 function ShowStep()
 {
     $wizard =& $this->GetWizard();
     $arResult = $wizard->GetVars(true);
     $dbSite = CSite::GetByID($arResult["siteID"]);
     $arSite = $dbSite->GetNext();
     CModule::IncludeModule("currency");
     $dbCurrency = CCurrency::GetList($b = "SORT", $o = "ASC", $arResult["siteID"]);
     while ($arCur = $dbCurrency->GetNext()) {
         $arCurrency[$arCur["CURRENCY"]] = $arCur["FULL_NAME"];
     }
     $dbUGroup = CGroup::GetList($b = "c_sort", $o = "ASC", array("ACTIVE" => "Y"));
     while ($arUGroup = $dbUGroup->GetNext()) {
         $arGroups[$arUGroup["ID"]] = $arUGroup["NAME"];
     }
     CModule::IncludeModule("sale");
     $dbPersonType = CSalePersonType::GetList(array("SORT" => "ASC"), array("ACTIVE" => "Y", "LID" => $arResult["siteID"]));
     while ($arPersonType = $dbPersonType->GetNext()) {
         $arPersons[$arPersonType["ID"]] = $arPersonType["NAME"];
     }
     $dbPaySystem = CSalePaySystem::GetList(array("SORT" => "ASC"), array("ACTIVE" => "Y", "LID" => $arResult["siteID"]));
     while ($arPaySystem = $dbPaySystem->GetNext()) {
         $arPaySystems[$arPaySystem["ID"]] = $arPaySystem["NAME"];
     }
     $dbDelivery = CSaleDeliveryHandler::GetList(array("SORT" => "ASC"), array("SITE_ID" => $arResult["siteID"], "ACTIVE" => "Y"));
     while ($arDelivery = $dbDelivery->GetNext()) {
         $arDeliveries[$arDelivery["SID"] . "_new"] = $arDelivery["NAME"] . " " . GetMessage("WW_STEP8_1");
     }
     $dbDelivery = CSaleDelivery::GetList(array("SORT" => "ASC"), array("LID" => $arResult["siteID"], "ACTIVE" => "Y"));
     while ($arDelivery = $dbDelivery->GetNext()) {
         $arDeliveries[$arDelivery["ID"]] = $arDelivery["NAME"];
     }
     $this->content = GetMessage("WW_2") . "<br />";
     $this->content .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"/bitrix/wizards/bitrix/sale.install/styles.css\">";
     $this->content .= "<table class=\"data-table\">";
     $this->content .= "<tr><th>" . GetMessage("WW_STEP1_2") . "</th><td>[" . $arSite["ID"] . "] " . $arSite["NAME"] . "</td></tr>";
     $this->content .= "<tr><th>" . GetMessage("WW_STEP1_3") . "</th><td>" . $arResult["orderEmail"] . "</td></tr>";
     $this->content .= "<tr><th>" . GetMessage("WW_STEP1_5") . "</th><td>" . $arResult["currencyID"] . " (" . $arCurrency[$arResult["currencyID"]] . ")" . "</td></tr>";
     $this->content .= "<tr><th>" . GetMessage("WW_3") . "</th><td>";
     foreach ($arResult["groupID"] as $v) {
         $this->content .= $arGroups[$v] . "<br />";
     }
     $this->content .= "</td></tr>";
     $this->content .= "<tr><th>" . GetMessage("WW_4") . "</th><td>";
     foreach ($arResult["personType"] as $v) {
         $this->content .= $arPersons[$v] . "<br />";
     }
     $this->content .= "</td></tr>";
     $this->content .= "<tr><th>" . GetMessage("WW_5") . "</th><td>";
     $arPS = array();
     foreach ($arResult["paySystem"] as $v) {
         if (!empty($v)) {
             foreach ($v as $v1) {
                 if (!in_array($v1, $arPS)) {
                     $arPS[] = $v1;
                 }
             }
         }
     }
     foreach ($arPS as $v) {
         $this->content .= $arPaySystems[$v] . "<br />";
     }
     $this->content .= "</td></tr>";
     $this->content .= "<tr><th>" . GetMessage("WW_6") . "</th><td>";
     if (!empty($arResult["delivery"])) {
         foreach ($arResult["delivery"] as $v) {
             $this->content .= $arDeliveries[$v] . "<br />";
         }
     }
     $this->content .= "</td></tr>";
     $this->content .= "</table>";
 }
Example #24
0
	/**
	 * <p>Метод осуществляет продление подписки с кодом ID.</p> <p><b>Примечание</b>. Метод использует внутреннюю транзакцию. Если у вас используется <b>MySQL</b> и <b>InnoDB</b>, и ранее была открыта транзакция, то ее необходимо закрыть до подключения метода.</p>
	 *
	 *
	 *
	 *
	 * @param int $ID  Код записи с информацией о продлении.
	 *
	 *
	 *
	 * @return bool <p>Метод возвращает <i>true</i> в случае успешного продления или <i>false</i>
	 * в случае ошибки.</p><br><br>
	 *
	 * @static
	 * @link http://dev.1c-bitrix.ru/api_help/sale/classes/csalerecurring/csalerecurring.nextpayment.php
	 * @author Bitrix
	 */
	public static function NextPayment($ID)
	{
		global $DB;
		global $USER;

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

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

		$arOrder = CSaleOrder::GetByID($arRecur["ORDER_ID"]);
		if (!$arOrder)
		{
			$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arRecur["ORDER_ID"], GetMessage("SKGR_NO_ORDER1")), "NO_ORDER");
			return False;
		}


		$bSuccess = True;
		$newOrderID = IntVal($arRecur["ORDER_ID"]);

		/** @var $productProvider IBXSaleProductProvider */
		if ($productProvider = CSaleBasket::GetProductProvider($arRecur))
		{
			$arProduct = $productProvider::RecurringOrderProduct(array(
				"PRODUCT_ID" => $arRecur["PRODUCT_ID"],
				"USER_ID"    => $arOrder["USER_ID"]
			));
		}
		else
		{
			$arProduct = CSaleRecurring::ExecuteCallbackFunction(
					$arRecur["CALLBACK_FUNC"],
					$arRecur["MODULE"],
					$arRecur["PRODUCT_ID"],
					$arOrder["USER_ID"]
				);
		}

		if (!$arProduct || !is_array($arProduct) || count($arProduct) <= 0)
		{
			CSaleRecurring::CancelRecurring($arRecur["ID"], "Y", "Product is not found");

			/*
			$arFields = array(
					"CANCELED" => "Y",
					"DATE_CANCELED" => Date(CDatabase::DateFormatToPHP(CLang::GetDateFormat("FULL", LANG))),
					"CANCELED_REASON" => "Product is not found"
				);
			CSaleRecurring::Update($arRecur["ID"], $arFields);
			*/
			//CSaleRecurring::Delete($arRecur["ID"]);

			return True;
		}

		if ($arProduct["WITHOUT_ORDER"] == "Y" || $arRecur["SUCCESS_PAYMENT"] == "Y")
		{
			$baseSiteCurrency = CSaleLang::GetLangCurrency($arOrder["LID"]);
			$productPrice = roundEx(CCurrencyRates::ConvertCurrency($arProduct["PRICE"], $arProduct["CURRENCY"], $baseSiteCurrency), SALE_VALUE_PRECISION);

			// Delivery
			$deliveryPrice = 0;
			$deliveryID = 0;
			$arOrder["DELIVERY_ID"] = IntVal($arOrder["DELIVERY_ID"]);
			if ($arOrder["DELIVERY_ID"] > 0)
			{
				$deliveryLocation = 0;
				$dbOrderPropValues = CSaleOrderPropsValue::GetList(
						array(),
						array(
								"ORDER_ID" => $arRecur["ORDER_ID"],
								"PROP_IS_LOCATION" => "Y"
							),
						false,
						false,
						array("VALUE")
					);
				if ($arOrderPropValues = $dbOrderPropValues->Fetch())
					$deliveryLocation = IntVal($arOrderPropValues["VALUE"]);

				$dbDelivery = CSaleDelivery::GetList(
						array("SORT" => "ASC", "NAME" => "ASC"),
						array(
								"LID" => $arOrder["LID"],
								"WEIGHT" => DoubleVal($arProduct["WEIGHT"]) * DoubleVal($arProduct["QUANTITY"]), // Changed by Sigurd, 2007-08-16
								"ORDER_PRICE" => $productPrice * DoubleVal($arProduct["QUANTITY"]),
								"ACTIVE" => "Y",
								"LOCATION" => $deliveryLocation
							)
					);
				while ($arDelivery = $dbDelivery->Fetch())
				{
					$deliveryPriceTmp = roundEx(CCurrencyRates::ConvertCurrency($arDelivery["PRICE"], $arDelivery["CURRENCY"], $baseSiteCurrency), SALE_VALUE_PRECISION);
					if (IntVal($arDelivery["ID"]) == $arOrder["DELIVERY_ID"])
					{
						$deliveryID = IntVal($arDelivery["ID"]);
						$deliveryPrice = $deliveryPriceTmp;
						break;
					}
					if ($deliveryPriceTmp < $deliveryPrice || $deliveryID <= 0)
					{
						$deliveryID = IntVal($arDelivery["ID"]);
						$deliveryPrice = $deliveryPriceTmp;
					}
				}

				if ($deliveryID <= 0)
				{
					$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGR_NO_DELIVERY"), "NO_DELIVERY");
					return False;
				}
			}

			// Sale discounts
			$discount = 0;
			$discountPrice = $productPrice;
			$discountProduct = 0;
			$dbDiscount = CSaleDiscount::GetList(
					array("SORT" => "ASC"),
					array(
							"LID" => $arOrder["LID"],
							"ACTIVE" => "Y",
							"!>ACTIVE_FROM" => Date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL"))),
							"!<ACTIVE_TO" => Date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL"))),
							"<=PRICE_FROM" => $productPrice,
							">=PRICE_TO" => $productPrice,
							"USER_GROUPS" => $USER->GetUserGroup($arOrder['USER_ID']),
						)
				);
			if ($arDiscount = $dbDiscount->Fetch())
			{
				if ($arDiscount["DISCOUNT_TYPE"] == "P")
				{
					$discountProduct = roundEx($productPrice * $arDiscount["DISCOUNT_VALUE"] / 100, SALE_VALUE_PRECISION);
					$discount = roundEx($discountProduct * DoubleVal($arProduct["QUANTITY"]), SALE_VALUE_PRECISION); // Changed by Sigurd, 2007-08-16
					$discountPrice = $productPrice - $discountProduct;
				}
				else
				{
					$discountValue = CCurrencyRates::ConvertCurrency($arDiscount["DISCOUNT_VALUE"], $arDiscount["CURRENCY"], $baseSiteCurrency);
					$discountValue = roundEx($discountValue, SALE_VALUE_PRECISION);

					$discountProduct = roundEx(1.0 * $discountValue / DoubleVal($arProduct["QUANTITY"]), SALE_VALUE_PRECISION);// Changed by Sigurd, 2007-08-16
					$discount = roundEx($curDiscount * DoubleVal($arProduct["QUANTITY"]), SALE_VALUE_PRECISION);
					$discountPrice = $productPrice - $discountProduct;
				}
			}

			$bUseVat = false;
			$vatRate = 0;
			if(DoubleVal($arProduct["VAT_RATE"]) > 0)
			{
				$bUseVat = true;
				$vatRate = $arProduct["VAT_RATE"];
			}

			// Tax
			$arTaxExempt = array();
			$dbUserGroups = CUser::GetUserGroupEx($arOrder["USER_ID"]);
			while ($arUserGroups = $dbUserGroups->Fetch())
			{
				$dbTaxExemptTmp = CSaleTax::GetExemptList(array("GROUP_ID" => $arUserGroups["GROUP_ID"]));
				while ($arTaxExemptTmp = $dbTaxExemptTmp->Fetch())
				{
					$arTaxExemptTmp["TAX_ID"] = IntVal($arTaxExemptTmp["TAX_ID"]);
					if (!in_array($arTaxExemptTmp["TAX_ID"], $arTaxExempt))
						$arTaxExempt[] = $arTaxExemptTmp["TAX_ID"];
				}
			}

			$taxPrice = 0;
			$taxVatPrice = 0;
			if(!$bUseVat)
			{
				$taxLocation = 0;
				$dbOrderPropValues = CSaleOrderPropsValue::GetList(
						array(),
						array(
								"ORDER_ID" => $arRecur["ORDER_ID"],
								"PROP_IS_LOCATION4TAX" => "Y"
							),
						false,
						false,
						array("VALUE")
					);
				if ($arOrderPropValues = $dbOrderPropValues->Fetch())
					$taxLocation = IntVal($arOrderPropValues["VALUE"]);

				$arTaxList = array();
				$dbTaxRateTmp = CSaleTaxRate::GetList(
						array("APPLY_ORDER" => "ASC"),
						array(
								"LID" => $arOrder["LID"],
								"PERSON_TYPE_ID" => $arOrder["PERSON_TYPE_ID"],
								"ACTIVE" => "Y",
								"LOCATION" => $taxLocation
							)
					);
				while ($arTaxRateTmp = $dbTaxRateTmp->Fetch())
				{
					if (!in_array(IntVal($arTaxRateTmp["TAX_ID"]), $arTaxExempt))
					{
						$arTaxList[] = $arTaxRateTmp;
					}
				}
			}
			else
			{
				$arTaxList[] = Array(
							"ID" => 0,
							"TAX_NAME" => GetMessage("SKGR_VAT"),
							"IS_PERCENT" => "Y",
							"VALUE" => $vatRate*100,
							"VALUE_MONEY" => 0,
							"APPLY_ORDER" => 100,
							"IS_IN_PRICE" => "Y",
							"CODE" => "VAT"
				);
			}


			$arTaxSums = array();

			if (!empty($arTaxList))
			{
				if(!$bUseVat)
				{
					$taxPriceTmp = CSaleOrderTax::CountTaxes(
							$discountPrice * DoubleVal($arProduct["QUANTITY"]),
							$arTaxList,
							$baseSiteCurrency
						);

					for ($di = 0, $intCount = count($arTaxList); $di < $intCount; $di++)
					{
						$arTaxList[$di]["VALUE_MONEY"] += $arTaxList[$di]["TAX_VAL"];
					}

					for ($di = 0, $intCount = count($arTaxList); $di < $intCount; $di++)
					{
						$arTaxSums[$arTaxList[$di]["TAX_ID"]]["VALUE"] = $arTaxList[$di]["VALUE_MONEY"];
						$arTaxSums[$arTaxList[$di]["TAX_ID"]]["NAME"] = $arTaxList[$di]["NAME"];
						if ($arTaxList[$di]["IS_IN_PRICE"] != "Y")
						{
							$taxPrice += $arTaxList[$di]["VALUE_MONEY"];
						}
					}
				}
				else
				{
					$arTaxList[0]["VALUE_MONEY"] = (($discountPrice / ($vatRate +1)) * $vatRate) * DoubleVal($arProduct["QUANTITY"]);
					$taxVatPrice = $arTaxList[0]["VALUE_MONEY"];
				}
			}


			// Changed by Sigurd, 2007-08-16
			$totalOrderPrice = $discountPrice * DoubleVal($arProduct["QUANTITY"]) + $deliveryPrice + $taxPrice;

			$arProduct["WITHOUT_ORDER"] = (($arProduct["WITHOUT_ORDER"]=="Y") ? "Y" : "N");
			if ($arProduct["WITHOUT_ORDER"] == "N")
			{
				$DB->StartTransaction();

				// Saving
				$arSaleUser = CSaleUser::GetList(Array(), Array("USER_ID" => $arOrder["USER_ID"]));
				if(!empty($arSaleUser))
				{
					$currentFUser = $arSaleUser["ID"];
				}
				else
				{
					$currentFUser = CSaleUser::_Add(
							array(
									"=DATE_INSERT" => $DB->GetNowFunction(),
									"=DATE_UPDATE" => $DB->GetNowFunction(),
									"USER_ID" => $arOrder["USER_ID"]
								)
						);
				}

				$arFields = array(
						"FUSER_ID" => $currentFUser,
						"PRODUCT_ID" => $arProduct["PRODUCT_ID"],
						"PRODUCT_NAME" => $arProduct["PRODUCT_NAME"],
						"PRODUCT_URL" => $arProduct["PRODUCT_URL"],
						"PRODUCT_PRICE_ID" => $arProduct["PRODUCT_PRICE_ID"],
						"PRICE" => $arProduct["PRICE"],
						"CURRENCY" => $arProduct["CURRENCY"],
						"WEIGHT" => $arProduct["WEIGHT"],
						"QUANTITY" => $arProduct["QUANTITY"],
						"LID" => $arOrder["LID"],
						"DELAY" => "N",
						"CAN_BUY" => "Y",
						"NAME" => $arProduct["NAME"],
						"CALLBACK_FUNC" => $arProduct["CALLBACK_FUNC"],
						"ORDER_CALLBACK_FUNC" => $arProduct["ORDER_CALLBACK_FUNC"],
						"CANCEL_CALLBACK_FUNC" => $arProduct["CANCEL_CALLBACK_FUNC"],
						"PAY_CALLBACK_FUNC" => $arProduct["PAY_CALLBACK_FUNC"],
						"PRODUCT_PROVIDER_CLASS" => $arProduct["PRODUCT_PROVIDER_CLASS"],
						"MODULE" => $arRecur["MODULE"],
						"NOTES" => $arProduct["CATALOG_GROUP_NAME"],
						"DETAIL_PAGE_URL" => $arProduct["DETAIL_PAGE_URL"],
						"VATE_RATE" => $arProduct["VATE_RATE"],
						"PRODUCT_XML_ID" => $arProduct["PRODUCT_XML_ID"],
						"RENEWAL" => "Y"
					);

				$basketID = CSaleBasket::Add($arFields);

				$basketID = IntVal($basketID);
				if ($basketID <= 0)
					$bSuccess = False;

				if ($bSuccess)
				{
					if (CModule::IncludeModule("statistic"))
						CStatistic::Set_Event("eStore", "add2basket", $arFields["PRODUCT_ID"]);

					$arFields = array(
							"LID" => $arOrder["LID"],
							"PERSON_TYPE_ID" => $arOrder["PERSON_TYPE_ID"],
							"PAYED" => "N",
							"CANCELED" => "N",
							"STATUS_ID" => "N",
							"PRICE_DELIVERY" => $deliveryPrice,
							"ALLOW_DELIVERY" => "N",
							"PRICE" => $totalOrderPrice,
							"CURRENCY" => $baseSiteCurrency,
							"DISCOUNT_VALUE" => $discount,
							"USER_ID" => $arOrder["USER_ID"],
							"PAY_SYSTEM_ID" => $arOrder["PAY_SYSTEM_ID"],
							"DELIVERY_ID" => $deliveryID,
							"USER_DESCRIPTION" => $arOrder["USER_DESCRIPTION"],
							"TAX_VALUE" => (($bUseVat)? $taxVatPrice : $taxPrice),
							"STAT_GID" => $arOrder["STAT_GID"],
							"RECURRING_ID" => $arRecur["ID"]
						);

					$newOrderID = CSaleOrder::Add($arFields);

					$newOrderID = IntVal($newOrderID);
					if ($newOrderID <= 0)
						$bSuccess = False;
				}

				if ($bSuccess)
				{
					$arDiscounts = array();
					$arDiscounts[$basketID] = $discountProduct;
					CSaleBasket::OrderBasket($newOrderID, $currentFUser, $arOrder["LID"], $arDiscounts);
				}

				if ($bSuccess)
				{
					for ($it = 0, $intCount = count($arTaxList); $it < $intCount; $it++)
					{
						$arFields = array(
							"ORDER_ID" => $newOrderID,
							"TAX_NAME" => $arTaxList[$it]["TAX_NAME"],
							"IS_PERCENT" => $arTaxList[$it]["IS_PERCENT"],
							"VALUE" => ($arTaxList[$it]["IS_PERCENT"]=="Y") ? $arTaxList[$it]["VALUE"] : RoundEx(CCurrencyRates::ConvertCurrency($arTaxList[$it]["VALUE"], $arTaxList[$it]["CURRENCY"], $baseSiteCurrency), 2),
							"VALUE_MONEY" => $arTaxList[$it]["VALUE_MONEY"],
							"APPLY_ORDER" => $arTaxList[$it]["APPLY_ORDER"],
							"IS_IN_PRICE" => $arTaxList[$it]["IS_IN_PRICE"],
							"CODE" => $arTaxList[$it]["CODE"]
							);
						CSaleOrderTax::Add($arFields);
					}

					$dbOrderPropValues = CSaleOrderPropsValue::GetList(
							array(),
							array("ORDER_ID" => $arRecur["ORDER_ID"]),
							false,
							false,
							array("ORDER_PROPS_ID", "NAME", "CODE", "VALUE", "PROP_IS_PAYER", "PROP_IS_EMAIL")
						);
					while ($arOrderPropValues = $dbOrderPropValues->Fetch())
					{
						$arFields = array(
							"ORDER_ID" => $newOrderID,
							"ORDER_PROPS_ID" => $arOrderPropValues["ORDER_PROPS_ID"],
							"NAME" => $arOrderPropValues["NAME"],
							"CODE" => $arOrderPropValues["CODE"],
							"VALUE" => $arOrderPropValues["VALUE"]
							);
						CSaleOrderPropsValue::Add($arFields);

						if ($arOrderPropValues["PROP_IS_PAYER"] == "Y")
							$payerName = $arOrderPropValues["VALUE"];
						if ($arOrderPropValues["PROP_IS_EMAIL"] == "Y")
							$payerEMail = $arOrderPropValues["VALUE"];
					}
				}

				if ($bSuccess)
				{
					if (CModule::IncludeModule("statistic"))
						CStatistic::Set_Event("eStore", "order_create", $newOrderID);
				}

				if ($bSuccess)
				{
					$strOrderList = "";
					$dbBasketTmp = CSaleBasket::GetList(
						array("NAME" => "ASC"),
						array("ORDER_ID" => $newOrderID)
					);
					while ($arBasketTmp = $dbBasketTmp->Fetch())
					{
						$strOrderList .= $arBasketTmp["NAME"]." - ".$arBasketTmp["QUANTITY"]." ".GetMessage("SALE_QUANTITY_UNIT");
						$strOrderList .= "\n";
					}

					if (strlen($payerName) <= 0 || strlen($payerEMail) <= 0)
					{
						$dbUser = CUser::GetByID($arOrder["USER_ID"]);
						if ($arUser = $dbUser->Fetch())
						{
							if (strlen($payerName) <= 0)
								$payerName = $arUser["NAME"].((strlen($arUser["NAME"])<=0 || strlen($arUser["LAST_NAME"])<=0) ? "" : " ").$arUser["LAST_NAME"];
							if (strlen($payerEMail) <= 0)
								$payerEMail = $arUser["EMAIL"];
						}
					}

					$arFields = Array(
						"ORDER_ID" => $newOrderID,
						"ORDER_DATE" => Date($DB->DateFormatToPHP(CLang::GetDateFormat("SHORT", $arOrder["LID"]))),
						"ORDER_USER" => $payerName,
						"PRICE" => SaleFormatCurrency($totalOrderPrice, $baseSiteCurrency),
						"BCC" => COption::GetOptionString("sale", "order_email", "order@".$SERVER_NAME),
						"EMAIL" => $payerEMail,
						"ORDER_LIST" => $strOrderList,
						"SALE_EMAIL" => COption::GetOptionString("sale", "order_email", "order@".$SERVER_NAME)
					);
					$eventName = "SALE_NEW_ORDER_RECURRING";

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

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

				if ($bSuccess)
					$DB->Commit();
				else
					$DB->Rollback();
			}
		}
		else
		{
			$totalOrderPrice = $arOrder["PRICE"];
			$baseSiteCurrency = $arOrder["CURRENCY"];
		}

		$res = False;
		if ($bSuccess)
		{
			$res = CSaleUserAccount::Pay($arOrder["USER_ID"], $totalOrderPrice, $baseSiteCurrency, $newOrderID, True);
			if ($res)
			{
				if ($arProduct["WITHOUT_ORDER"] == "N")
				{
					CSaleOrder::PayOrder($newOrderID, "Y", False, False, $arRecur["ID"]);
					CSaleOrder::DeliverOrder($newOrderID, "Y", $arRecur["ID"]);
					CSaleOrder::DeductOrder($newOrderID, "Y", "", true, array(), $arRecur["ID"]);
				}
				else
				{
					/** @var $productProvider IBXSaleProductProvider */
					if ($productProvider = CSaleBasket::GetProductProvider($arProduct))
					{
						$r = $productProvider::DeliverProduct(array(
							"PRODUCT_ID" => $arProduct["PRODUCT_ID"],
							"USER_ID"    => $arOrder["USER_ID"],
							"PAID"       => true
						));
					}
					else
					{
						$r = CSaleBasket::ExecuteCallbackFunction(
							$arProduct["PAY_CALLBACK_FUNC"],
							$arRecur["MODULE"],
							$arProduct["PRODUCT_ID"],
							$arOrder["USER_ID"],
							true
						);
					}
				}

				$arFields = array(
					"ORDER_ID" => $newOrderID,
					"PRODUCT_NAME" => $arProduct["PRODUCT_NAME"],
					"PRODUCT_URL" => $arProduct["PRODUCT_URL"],
					"PRICE_TYPE" => $arProduct["PRICE_TYPE"],
					"RECUR_SCHEME_TYPE" => $arProduct["RECUR_SCHEME_TYPE"],
					"RECUR_SCHEME_LENGTH" => $arProduct["RECUR_SCHEME_LENGTH"],
					"WITHOUT_ORDER" => $arProduct["WITHOUT_ORDER"],
					"PRIOR_DATE" => Date($GLOBALS["DB"]->DateFormatToPHP(CLang::GetDateFormat("FULL", SITE_ID))),
					"NEXT_DATE" => $arProduct["NEXT_DATE"],
					"REMAINING_ATTEMPTS" => (Defined("SALE_PROC_REC_ATTEMPTS") ? SALE_PROC_REC_ATTEMPTS : 3),
					"SUCCESS_PAYMENT" => "Y"
				);

				CSaleRecurring::Update($arRecur["ID"], $arFields);
			}
			else
			{
				$arFields = array(
						"ORDER_ID" => $newOrderID,
						"PRODUCT_NAME" => $arProduct["PRODUCT_NAME"],
						"PRODUCT_URL" => $arProduct["PRODUCT_URL"],
						"PRICE_TYPE" => $arProduct["PRICE_TYPE"],
						"RECUR_SCHEME_LENGTH" => $arProduct["RECUR_SCHEME_LENGTH"],
						"RECUR_SCHEME_TYPE" => $arProduct["RECUR_SCHEME_TYPE"],
						"WITHOUT_ORDER" => $arProduct["WITHOUT_ORDER"],
						"NEXT_DATE" => Date($GLOBALS["DB"]->DateFormatToPHP(CLang::GetDateFormat("FULL", SITE_ID)), time() + SALE_PROC_REC_TIME + CTimeZone::GetOffset()),
						"REMAINING_ATTEMPTS" => (IntVal($arRecur["REMAINING_ATTEMPTS"]) - 1),
						"SUCCESS_PAYMENT" => "N"
					);
				CSaleRecurring::Update($arRecur["ID"], $arFields);

				if ((IntVal($arRecur["REMAINING_ATTEMPTS"]) - 1) <= 0)
				{
					CSaleRecurring::CancelRecurring($arRecur["ID"], "Y", "Can't pay order");
					/*
					$arFields["CANCELED"] = "Y";
					$arFields["DATE_CANCELED"] = Date(CDatabase::DateFormatToPHP(CLang::GetDateFormat("FULL", LANG)));
					$arFields["CANCELED_REASON"] = "Can't pay order";
					*/
				}
			}
		}

		return $res;
	}
Example #25
0
 public static function getDeliveriesInfo($arDeliveryIds)
 {
     if (!is_array($arDeliveryIds)) {
         return false;
     }
     static $arDeliveries = array();
     $arTmpSD = array();
     foreach ($arDeliveryIds as $deliveryId) {
         if (!$deliveryId || is_null($deliveryId)) {
             continue;
         }
         if (!isset($arDeliveries[$deliveryId])) {
             if (strpos($deliveryId, ":") !== false) {
                 $arId = explode(":", $deliveryId);
                 $dbDelivery = CSaleDeliveryHandler::GetList(array(), array("SID" => $arId[0]));
                 if ($arDelivery = $dbDelivery->Fetch()) {
                     $arDeliveries[$deliveryId] = htmlspecialcharsEx($arDelivery["NAME"]);
                     if (strlen($arId[1]) > 0 && isset($arDelivery["PROFILES"][$arId[1]]["TITLE"])) {
                         $arDeliveries[$deliveryId] .= " / " . htmlspecialcharsEx($arDelivery["PROFILES"][$arId[1]]["TITLE"]);
                     }
                 }
             } else {
                 $arTmpSD[] = $deliveryId;
             }
         }
     }
     if (is_array($arTmpSD)) {
         $dbDelivery = CSaleDelivery::GetList(array(), array("ID" => $arTmpSD), false, false, array("ID", "NAME"));
         while ($arDelivery = $dbDelivery->Fetch()) {
             $arDeliveries[$arDelivery["ID"]] = htmlspecialcharsbx($arDelivery["NAME"]);
         }
     }
     return $arDeliveries;
 }
Example #26
0
 /**
  * @param string $siteId Site id.
  * @return array List of diliveries for given site.
  */
 public static function getDeliveryList($siteId)
 {
     $arDeliveryFilter = array("LID" => $siteId, "ACTIVE" => "Y");
     $dbDeliveryList = \CSaleDelivery::GetList(array("NAME" => "ASC"), $arDeliveryFilter, false, false, array("ID", "NAME"));
     $arDeliveryList = array();
     while ($arDelivery = $dbDeliveryList->Fetch()) {
         $arDeliveryList[$arDelivery["ID"]] = $arDelivery["NAME"];
     }
     return $arDeliveryList;
 }
Example #27
0
 }
 $dbGroup = CSaleLocationGroup::GetList();
 if ($arGroup = $dbGroup->Fetch()) {
     $arLocation4Delivery[] = array("LOCATION_ID" => $arGroup["ID"], "LOCATION_TYPE" => "G");
 } else {
     $groupLang = array(array("LID" => "en", "NAME" => "Group 1"));
     if ($bRus) {
         $groupLang[] = array("LID" => $lang, "NAME" => GetMessage("SALE_WIZARD_GROUP"));
     }
     $locationGroupID = CSaleLocationGroup::Add(array("SORT" => 150, "LOCATION_ID" => $arLocationArr, "LANG" => $groupLang));
 }
 //Location group
 if (IntVal($locationGroupID) > 0) {
     $arLocation4Delivery[] = array("LOCATION_ID" => $locationGroupID, "LOCATION_TYPE" => "G");
 }
 $dbDelivery = CSaleDelivery::GetList(array(), array("LID" => WIZARD_SITE_ID));
 if (!$dbDelivery->Fetch()) {
     //delivery handler
     $arFields = array("NAME" => GetMessage("SALE_WIZARD_COUR"), "LID" => WIZARD_SITE_ID, "PERIOD_FROM" => 0, "PERIOD_TO" => 0, "PERIOD_TYPE" => "D", "WEIGHT_FROM" => 0, "WEIGHT_TO" => 0, "ORDER_PRICE_FROM" => 0, "ORDER_PRICE_TO" => 0, "ORDER_CURRENCY" => $defCurrency, "ACTIVE" => "Y", "PRICE" => $bRus ? "500" : "30", "CURRENCY" => $defCurrency, "SORT" => 100, "DESCRIPTION" => GetMessage("SALE_WIZARD_COUR_DESCR"), "LOCATIONS" => $arLocation4Delivery);
     if ($delivery["courier"] != "Y") {
         $arFields["ACTIVE"] = "N";
     }
     CSaleDelivery::Add($arFields);
     $arFields = array("NAME" => GetMessage("SALE_WIZARD_COUR1"), "LID" => WIZARD_SITE_ID, "PERIOD_FROM" => 0, "PERIOD_TO" => 0, "PERIOD_TYPE" => "D", "WEIGHT_FROM" => 0, "WEIGHT_TO" => 0, "ORDER_PRICE_FROM" => 0, "ORDER_PRICE_TO" => 0, "ORDER_CURRENCY" => $defCurrency, "ACTIVE" => "Y", "PRICE" => 0, "CURRENCY" => $defCurrency, "SORT" => 200, "DESCRIPTION" => GetMessage("SALE_WIZARD_COUR1_DESCR"), "LOCATIONS" => $arLocation4Delivery);
     if ($delivery["self"] != "Y") {
         $arFields["ACTIVE"] = "N";
     }
     CSaleDelivery::Add($arFields);
 }
 $dbDelivery = CSaleDeliveryHandler::GetList();
 if (!$dbDelivery->Fetch()) {
Example #28
0
<?php

define("NOT_CHECK_PERMISSIONS", true);
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
__IncludeLang($_SERVER['DOCUMENT_ROOT'] . '/bitrix/components/bitrix/sale.order.ajax/lang/' . LANGUAGE_ID . '/map.php');
CModule::IncludeModule('sale');
CModule::IncludeModule('catalog');
$location = "";
$arStore = array();
$arStoreId = array();
if ($_REQUEST["delivery"]) {
    $deliveryId = IntVal($_REQUEST["delivery"]);
    $dbDelivery = CSaleDelivery::GetList(array("SORT" => "ASC"), array("ID" => $deliveryId), false, false, array("ID", "STORE"));
    $arDelivery = $dbDelivery->Fetch();
    if (count($arDelivery) > 0 && strlen($arDelivery["STORE"]) > 0) {
        $arStore = unserialize($arDelivery["STORE"]);
        foreach ($arStore as $val) {
            $arStoreId[$val] = $val;
        }
    }
    $arStore = array();
    $arStoreLocation = array("yandex_scale" => 11, "PLACEMARKS" => array());
    $dbList = CCatalogStore::GetList(array("ID" => "DESC"), array("ACTIVE" => "Y", "ID" => $arStoreId), false, false, array("ID", "TITLE", "ADDRESS", "DESCRIPTION", "IMAGE_ID", "PHONE", "SCHEDULE", "GPS_N", "GPS_S"));
    while ($arStoreTmp = $dbList->Fetch()) {
        $arStore[$arStoreTmp["ID"]] = $arStoreTmp;
        if (floatval($arStoreLocation["yandex_lat"]) <= 0) {
            $arStoreLocation["yandex_lat"] = $arStoreTmp["GPS_N"];
        }
        if (floatval($arStoreLocation["yandex_lon"]) <= 0) {
            $arStoreLocation["yandex_lon"] = $arStoreTmp["GPS_S"];
        }
Example #29
0
	/**
	 * @param bool|string $strControlID
	 * @return array|bool
	 */
	public static function GetControls($strControlID = false)
	{
		$arSalePersonTypes = array();
		$arFilter = array();
		if (static::$boolInit)
		{
			if (isset(static::$arInitParams['SITE_ID']))
				$arFilter['LID'] = static::$arInitParams['SITE_ID'];
		}
		$rsPersonTypes = CSalePersonType::GetList(array(), $arFilter, false, false, array('ID', 'NAME', 'LIDS'));
		while ($arPersonType = $rsPersonTypes->Fetch())
		{
			$arPersonType['ID'] = intval($arPersonType['ID']);
			$arSalePersonTypes[$arPersonType['ID']] = $arPersonType['NAME'].'('.implode(' ', $arPersonType['LIDS']).')';
		}

		$arSalePaySystemList = array();
		$arFilter = array();
		$rsPaySystems = CSalePaySystem::GetList(array(), $arFilter, false, false, array('ID', 'NAME'));
		while ($arPaySystem = $rsPaySystems->Fetch())
		{
			$arSalePaySystemList[$arPaySystem['ID']] = $arPaySystem['NAME'];
		}

		$arSaleDeliveryList = array();
		$arFilter = array();
		if (static::$boolInit)
		{
			if (isset(static::$arInitParams['SITE_ID']))
				$arFilter['LID'] = static::$arInitParams['SITE_ID'];
		}

		$rsDeliverySystems = CSaleDelivery::GetList(array(), $arFilter, false, false, array('ID', 'LID', 'NAME'));
		while ($arDelivery = $rsDeliverySystems->Fetch())
		{
			$arSaleDeliveryList[$arDelivery['ID']] = $arDelivery['NAME'].' ('.$arDelivery['LID'].')';
		}

		$arFilter = array();
		if (static::$boolInit)
		{
			if (isset(static::$arInitParams['SITE_ID']))
				$arFilter['SITE'] = static::$arInitParams['SITE_ID'];
		}

		$rsDeliveryHandlers = CSaleDeliveryHandler::GetList(array(),$arFilter);
		while ($arDeliveryHandler = $rsDeliveryHandlers->Fetch())
		{
			$boolSep = true;
			if (!empty($arDeliveryHandler['PROFILES']) && is_array($arDeliveryHandler['PROFILES']))
			{
				foreach ($arDeliveryHandler['PROFILES'] as $key => $arProfile)
				{
					$arSaleDeliveryList[$arDeliveryHandler['SID'].':'.$key] = $arDeliveryHandler['NAME'];
				}
			}
		}

		$arLabels = array(
			BT_COND_LOGIC_EQ => Loc::getMessage('BT_SALE_AMOUNT_LOGIC_EQ_LABEL'),
			BT_COND_LOGIC_NOT_EQ => Loc::getMessage('BT_SALE_AMOUNT_LOGIC_NOT_EQ_LABEL'),
			BT_COND_LOGIC_GR => Loc::getMessage('BT_SALE_AMOUNT_LOGIC_GR_LABEL'),
			BT_COND_LOGIC_LS => Loc::getMessage('BT_SALE_AMOUNT_LOGIC_LS_LABEL'),
			BT_COND_LOGIC_EGR => Loc::getMessage('BT_SALE_AMOUNT_LOGIC_EGR_LABEL'),
			BT_COND_LOGIC_ELS => Loc::getMessage('BT_SALE_AMOUNT_LOGIC_ELS_LABEL')
		);
		$arLabelsWeight = array(
			BT_COND_LOGIC_EQ => Loc::getMessage('BT_SALE_WEIGHT_LOGIC_EQ_LABEL'),
			BT_COND_LOGIC_NOT_EQ => Loc::getMessage('BT_SALE_WEIGHT_LOGIC_NOT_EQ_LABEL'),
			BT_COND_LOGIC_GR => Loc::getMessage('BT_SALE_WEIGHT_LOGIC_GR_LABEL'),
			BT_COND_LOGIC_LS => Loc::getMessage('BT_SALE_WEIGHT_LOGIC_LS_LABEL'),
			BT_COND_LOGIC_EGR => Loc::getMessage('BT_SALE_WEIGHT_LOGIC_EGR_LABEL'),
			BT_COND_LOGIC_ELS => Loc::getMessage('BT_SALE_WEIGHT_LOGIC_ELS_LABEL')
		);

		$arControlList = array(
			'CondSaleOrderSumm' => array(
				'ID' => 'CondSaleOrderSumm',
				'FIELD' => 'ORDER_PRICE',
				'FIELD_TYPE' => 'double',
				'LABEL' => Loc::getMessage('BT_MOD_SALE_COND_CMP_SALE_ORDER_SUMM_LABEL_EXT'),
				'PREFIX' => Loc::getMessage('BT_MOD_SALE_COND_CMP_SALE_ORDER_SUMM_PREFIX_EXT'),
				'LOGIC' => static::GetLogicEx(array_keys($arLabels), $arLabels),
				'JS_VALUE' => array(
					'type' => 'input'
				)
			),
			'CondSalePersonType' => array(
				'ID' => 'CondSalePersonType',
				'FIELD' => 'PERSON_TYPE_ID',
				'FIELD_TYPE' => 'int',
				'LABEL' => Loc::getMessage('BT_MOD_SALE_COND_CMP_SALE_PERSON_TYPE_LABEL'),
				'PREFIX' => Loc::getMessage('BT_MOD_SALE_COND_CMP_SALE_PERSON_TYPE_PREFIX'),
				'LOGIC' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ)),
				'JS_VALUE' => array(
					'type' => 'select',
					'multiple' => 'Y',
					'values' => $arSalePersonTypes,
					'show_value' => 'Y'
				),
				'PHP_VALUE' => array(
					'VALIDATE' => 'list'
				)
			),
			'CondSalePaySystem' => array(
				'ID' => 'CondSalePaySystem',
				'FIELD' => 'PAY_SYSTEM_ID',
				'FIELD_TYPE' => 'int',
				'LABEL' => Loc::getMessage('BT_MOD_SALE_COND_CMP_SALE_PAY_SYSTEM_LABEL'),
				'PREFIX' => Loc::getMessage('BT_MOD_SALE_COND_CMP_SALE_PAY_SYSTEM_PREFIX'),
				'LOGIC' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ)),
				'JS_VALUE' => array(
					'type' => 'select',
					'multiple' => 'Y',
					'values' => $arSalePaySystemList,
					'show_value' => 'Y'
				),
				'PHP_VALUE' => array(
					'VALIDATE' => 'list'
				)
			),
			'CondSaleDelivery' => array(
				'ID' => 'CondSaleDelivery',
				'FIELD' => 'DELIVERY_ID',
				'FIELD_TYPE' => 'string',
				'FIELD_LENGTH' => 50,
				'LABEL' => Loc::getMessage('BT_MOD_SALE_COND_CMP_SALE_DELIVERY_LABEL'),
				'PREFIX' => Loc::getMessage('BT_MOD_SALE_COND_CMP_SALE_DELIVERY_PREFIX'),
				'LOGIC' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ)),
				'JS_VALUE' => array(
					'type' => 'select',
					'multiple' => 'Y',
					'values' => $arSaleDeliveryList,
					'show_value' => 'Y'
				),
				'PHP_VALUE' => array(
					'VALIDATE' => 'list'
				)
			),
			'CondSaleOrderWeight' => array(
				'ID' => 'CondSaleOrderWeight',
				'FIELD' => 'ORDER_WEIGHT',
				'FIELD_TYPE' => 'double',
				'LABEL' => Loc::getMessage('BT_MOD_SALE_COND_SALE_ORDER_WEIGHT_LABEL'),
				'PREFIX' => Loc::getMessage('BT_MOD_SALE_COND_SALE_ORDER_WEIGHT_PREFIX'),
				'LOGIC' => static::GetLogicEx(array_keys($arLabelsWeight), $arLabelsWeight),
				'JS_VALUE' => array(
					'type' => 'input'
				)
			)
		);
		foreach ($arControlList as &$control)
		{
			$control['EXECUTE_MODULE'] = 'sale';
			$control['MODULE_ID'] = 'sale';
			$control['MODULE_ENTITY'] = 'sale';
			$control['ENTITY'] = 'ORDER';
			$control['MULTIPLE'] = 'N';
			$control['GROUP'] = 'N';
		}
		unset($control);

		if ($strControlID === false)
		{
			return $arControlList;
		}
		elseif (isset($arControlList[$strControlID]))
		{
			return $arControlList[$strControlID];
		}
		else
		{
			return false;
		}
	}
Example #30
0
File: class.php Project: ASDAFF/mp
 /**
  * Read some data from database, using cache. Under some info we mean status list, delivery system list and so on.
  * This will be a shared cache between sale.personal.order.list and sale.personal.order.detail, so beware of collisions.
  * @throws Exception
  * @return void
  */
 protected function obtainDataReferences()
 {
     $obCache = new CPHPCache();
     if ($obCache->StartDataCache($this->arParams["CACHE_TIME"], LANGUAGE_ID . SITE_ID)) {
         try {
             $cachedData = array();
             /////////////////////
             /////////////////////
             // Person type
             $dbPType = CSalePersonType::GetList(array("SORT" => "ASC"));
             while ($arPType = $dbPType->Fetch()) {
                 $cachedData['PERSON_TYPE'][$arPType["ID"]] = $arPType;
             }
             // Tax list
             $dbTaxList = CSaleOrderTax::GetList(array("APPLY_ORDER" => "ASC"));
             while ($arTaxList = $dbTaxList->Fetch()) {
                 $cachedData['TAX'] = $arTaxList;
             }
             // Save statuses for Filter form
             $dbStatus = CSaleStatus::GetList(array("SORT" => "ASC"), array("LID" => LANGUAGE_ID));
             while ($arStatus = $dbStatus->Fetch()) {
                 $cachedData['STATUS'][$arStatus["ID"]] = $arStatus;
             }
             $dbPaySystem = CSalePaySystem::GetList(array("SORT" => "ASC"));
             while ($arPaySystem = $dbPaySystem->Fetch()) {
                 $cachedData['PAYSYS'][$arPaySystem["ID"]] = $arPaySystem;
             }
             $dbDelivery = CSaleDelivery::GetList(array("SORT" => "ASC"));
             while ($arDelivery = $dbDelivery->Fetch()) {
                 $cachedData['DELIVERY'][$arDelivery["ID"]] = $arDelivery;
             }
             $dbDelivery = CSaleDeliveryHandler::GetList(array(), array(array("SITE_ID" => SITE_ID)));
             while ($arDeliveryHandler = $dbDelivery->Fetch()) {
                 $cachedData['DELIVERY_HANDLERS'][$arDeliveryHandler["SID"]] = $arDeliveryHandler;
             }
             /////////////////////
             /////////////////////
         } catch (Exception $e) {
             $obCache->AbortDataCache();
             throw $e;
         }
         $obCache->EndDataCache($cachedData);
     } else {
         $cachedData = $obCache->GetVars();
     }
     $this->dbResult = array_merge($this->dbResult, $cachedData);
 }