コード例 #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;
 }
コード例 #2
0
ファイル: order.php プロジェクト: k-kalashnikov/geekcon_new
 function CheckFields($ACTION, &$arFields, $ID = 0)
 {
     if (is_set($arFields, "SITE_ID") && strlen($arFields["SITE_ID"]) > 0) {
         $arFields["LID"] = $arFields["SITE_ID"];
     }
     if ((is_set($arFields, "LID") || $ACTION == "ADD") && strlen($arFields["LID"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGO_EMPTY_SITE"), "EMPTY_SITE_ID");
         return false;
     }
     if ((is_set($arFields, "PERSON_TYPE_ID") || $ACTION == "ADD") && IntVal($arFields["PERSON_TYPE_ID"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGO_EMPTY_PERS_TYPE"), "EMPTY_PERSON_TYPE_ID");
         return false;
     }
     if ((is_set($arFields, "USER_ID") || $ACTION == "ADD") && IntVal($arFields["USER_ID"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGO_EMPTY_USER_ID"), "EMPTY_USER_ID");
         return false;
     }
     if (is_set($arFields, "PAYED") && $arFields["PAYED"] != "Y") {
         $arFields["PAYED"] = "N";
     }
     if (is_set($arFields, "CANCELED") && $arFields["CANCELED"] != "Y") {
         $arFields["CANCELED"] = "N";
     }
     if (is_set($arFields, "STATUS_ID") && strlen($arFields["STATUS_ID"]) <= 0) {
         $arFields["STATUS_ID"] = "N";
     }
     if (is_set($arFields, "ALLOW_DELIVERY") && $arFields["ALLOW_DELIVERY"] != "Y") {
         $arFields["ALLOW_DELIVERY"] = "N";
     }
     if (is_set($arFields, "PRICE") || $ACTION == "ADD") {
         $arFields["PRICE"] = str_replace(",", ".", $arFields["PRICE"]);
         $arFields["PRICE"] = DoubleVal($arFields["PRICE"]);
     }
     if (is_set($arFields, "PRICE_DELIVERY") || $ACTION == "ADD") {
         $arFields["PRICE_DELIVERY"] = str_replace(",", ".", $arFields["PRICE_DELIVERY"]);
         $arFields["PRICE_DELIVERY"] = DoubleVal($arFields["PRICE_DELIVERY"]);
     }
     if (is_set($arFields, "SUM_PAID") || $ACTION == "ADD") {
         $arFields["SUM_PAID"] = str_replace(",", ".", $arFields["SUM_PAID"]);
         $arFields["SUM_PAID"] = DoubleVal($arFields["SUM_PAID"]);
     }
     if (is_set($arFields, "DISCOUNT_VALUE") || $ACTION == "ADD") {
         $arFields["DISCOUNT_VALUE"] = str_replace(",", ".", $arFields["DISCOUNT_VALUE"]);
         $arFields["DISCOUNT_VALUE"] = DoubleVal($arFields["DISCOUNT_VALUE"]);
     }
     if (is_set($arFields, "TAX_VALUE") || $ACTION == "ADD") {
         $arFields["TAX_VALUE"] = str_replace(",", ".", $arFields["TAX_VALUE"]);
         $arFields["TAX_VALUE"] = DoubleVal($arFields["TAX_VALUE"]);
     }
     if (!is_set($arFields, "LOCKED_BY") && (!is_set($arFields, "UPDATED_1C") || is_set($arFields, "UPDATED_1C") && $arFields["UPDATED_1C"] != "Y")) {
         $arFields["UPDATED_1C"] = "N";
     }
     if ((is_set($arFields, "CURRENCY") || $ACTION == "ADD") && strlen($arFields["CURRENCY"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGO_EMPTY_CURRENCY"), "EMPTY_CURRENCY");
         return false;
     }
     if (is_set($arFields, "CURRENCY")) {
         if (!($arCurrency = CCurrency::GetByID($arFields["CURRENCY"]))) {
             $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["CURRENCY"], GetMessage("SKGO_WRONG_CURRENCY")), "ERROR_NO_CURRENCY");
             return false;
         }
     }
     if (is_set($arFields, "LID")) {
         $dbSite = CSite::GetByID($arFields["LID"]);
         if (!$dbSite->Fetch()) {
             $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["LID"], GetMessage("SKGO_WRONG_SITE")), "ERROR_NO_SITE");
             return false;
         }
     }
     if (is_set($arFields, "USER_ID")) {
         $dbUser = CUser::GetByID($arFields["USER_ID"]);
         if (!$dbUser->Fetch()) {
             $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["USER_ID"], GetMessage("SKGO_WRONG_USER")), "ERROR_NO_USER_ID");
             return false;
         }
     }
     if (is_set($arFields, "PERSON_TYPE_ID")) {
         if (!($arPersonType = CSalePersonType::GetByID($arFields["PERSON_TYPE_ID"]))) {
             $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["PERSON_TYPE_ID"], GetMessage("SKGO_WRONG_PERSON_TYPE")), "ERROR_NO_PERSON_TYPE");
             return false;
         }
     }
     if (is_set($arFields, "PAY_SYSTEM_ID") && IntVal($arFields["PAY_SYSTEM_ID"]) > 0) {
         if (!($arPaySystem = CSalePaySystem::GetByID(IntVal($arFields["PAY_SYSTEM_ID"])))) {
             $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["PAY_SYSTEM_ID"], GetMessage("SKGO_WRONG_PS")), "ERROR_NO_PAY_SYSTEM");
             return false;
         }
     }
     if (is_set($arFields, "DELIVERY_ID") && (strpos($arFields["DELIVERY_ID"], ":") !== false || IntVal($arFields["DELIVERY_ID"]) > 0)) {
         if (strpos($arFields["DELIVERY_ID"], ":") !== false) {
             $arId = explode(":", $arFields["DELIVERY_ID"]);
             $obDelivery = new CSaleDeliveryHandler();
             if ($arDelivery = $obDelivery->GetBySID($arId[0])) {
                 if ($arDelivery = $arDelivery->Fetch()) {
                     if (!is_set($arDelivery["PROFILES"], $arId[1])) {
                         $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["DELIVERY_ID"], GetMessage("SKGO_WRONG_DELIVERY")), "ERROR_NO_DELIVERY");
                         return false;
                     }
                 }
             } else {
                 $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["DELIVERY_ID"], GetMessage("SKGO_WRONG_DELIVERY")), "ERROR_NO_DELIVERY");
                 return false;
             }
         } else {
             if (!($arDelivery = CSaleDelivery::GetByID(IntVal($arFields["DELIVERY_ID"])))) {
                 $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["DELIVERY_ID"], GetMessage("SKGO_WRONG_DELIVERY")), "ERROR_NO_DELIVERY");
                 return false;
             }
         }
     }
     if (is_set($arFields, "STATUS_ID")) {
         if (!($arStatus = CSaleStatus::GetByID($arFields["STATUS_ID"]))) {
             $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["STATUS_ID"], GetMessage("SKGO_WRONG_STATUS")), "ERROR_NO_STATUS_ID");
             return false;
         }
     }
     return True;
 }
コード例 #3
0
ファイル: html.php プロジェクト: webgksupport/alpina
     $arCells[++$n] = array(1 => $n, htmlspecialcharsbx($productName), roundEx($arBasket["QUANTITY"], SALE_VALUE_PRECISION), $arBasket["MEASURE_NAME"] ? htmlspecialcharsbx($arBasket["MEASURE_NAME"]) : 'pza', SaleFormatCurrency($arBasket["VATLESS_PRICE"], $arBasket["CURRENCY"], false), roundEx($arBasket["VAT_RATE"] * 100, SALE_VALUE_PRECISION) . "%", SaleFormatCurrency($arBasket["VATLESS_PRICE"] * $arBasket["QUANTITY"], $arBasket["CURRENCY"], false));
     $arProps[$n] = array();
     foreach ($arBasket["PROPS"] as $vv) {
         $arProps[$n][] = htmlspecialcharsbx(sprintf("%s: %s", $vv["NAME"], $vv["VALUE"]));
     }
     $sum += doubleval($arBasket["VATLESS_PRICE"] * $arBasket["QUANTITY"]);
     $vat = max($vat, $arBasket["VAT_RATE"]);
     if ($arBasket["VAT_RATE"] > 0) {
         if (!isset($vats[$arBasket["VAT_RATE"]])) {
             $vats[$arBasket["VAT_RATE"]] = 0;
         }
         $vats[$arBasket["VAT_RATE"]] += ($arBasket["PRICE"] - $arBasket["VATLESS_PRICE"]) * $arBasket["QUANTITY"];
     }
 } while ($arBasket = $dbBasket->Fetch());
 if (DoubleVal($GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["PRICE_DELIVERY"]) > 0) {
     $arDelivery_tmp = CSaleDelivery::GetByID($GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["DELIVERY_ID"]);
     $sDeliveryItem = "Envío";
     if (strlen($arDelivery_tmp["NAME"]) > 0) {
         $sDeliveryItem .= sprintf(" (%s)", $arDelivery_tmp["NAME"]);
     }
     $arCells[++$n] = array(1 => $n, htmlspecialcharsbx($sDeliveryItem), 1, '', SaleFormatCurrency($GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["PRICE_DELIVERY"] / (1 + $vat), $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["CURRENCY"], false), roundEx($vat * 100, SALE_VALUE_PRECISION) . "%", SaleFormatCurrency($GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["PRICE_DELIVERY"] / (1 + $vat), $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["CURRENCY"], false));
     $sum += roundEx(doubleval($GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["PRICE_DELIVERY"] / (1 + $vat)), SALE_VALUE_PRECISION);
     if ($vat > 0) {
         $vats[$vat] += roundEx($GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["PRICE_DELIVERY"] * $vat / (1 + $vat), SALE_VALUE_PRECISION);
     }
 }
 $items = $n;
 if ($sum < $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["PRICE"]) {
     $arCells[++$n] = array(1 => null, null, null, null, null, "Sub Total:", SaleFormatCurrency($sum, $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["CURRENCY"], false));
 }
 if (!empty($vats)) {
コード例 #4
0
ファイル: order_detail.php プロジェクト: akniyev/arteva.ru
							<span id="allow_delivery_name">
								<?
								$arDeliveryName = array();
								$arDeliveryData = array();
								if (strpos($arOrder["DELIVERY_ID"], ":") !== false)
								{
									$arDeliveryName = explode(":", $arOrder["DELIVERY_ID"]);

									$dbDelivery = CSaleDeliveryHandler::GetBySID($arDeliveryName[0]);
									$arDeliveryData = $dbDelivery->Fetch();

									echo "[".$arDeliveryData["SID"]."] ".htmlspecialcharsEx($arDeliveryData["NAME"])." (".$arOrder["LID"].")";
								}
								elseif (intval($arOrder["DELIVERY_ID"]) > 0)
								{
									$arDeliveryData = CSaleDelivery::GetByID($arOrder["DELIVERY_ID"]);
									echo htmlspecialcharsbx($arDeliveryData["NAME"]);
								}
								else
									echo GetMessage("SOD_NONE");
								?>
							</span>
						</td>
					</tr>
					<?
					if (!empty($arDeliveryName)):
					?>
					<tr>
						<td><?php 
echo GetMessage("SOD_DELIVERY_SERVICE_NAME");
?>
コード例 #5
0
 $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;
     if (!empty($arUserResult["DELIVERY_ID"]) && strpos($arUserResult["DELIVERY_ID"], ":") === false) {
         if (IntVal($arUserResult["DELIVERY_ID"]) == IntVal($arDelivery["ID"])) {
             $bFound = true;
         }
     }
     if (IntVal($arUserResult["DELIVERY_ID"]) == IntVal($arDelivery["ID"])) {
         $arResult["DELIVERY_PRICE"] = roundEx(CCurrencyRates::ConvertCurrency($arDelivery["PRICE"], $arDelivery["CURRENCY"], $arResult["BASE_LANG_CURRENCY"]), SALE_VALUE_PRECISION);
     }
 }
 if (!$bFound && !empty($arUserResult["DELIVERY_ID"]) && strpos($arUserResult["DELIVERY_ID"], ":") === false) {
     $arUserResult["DELIVERY_ID"] = "";
 }
 $arStore = array();
コード例 #6
0
 }
 if (strstr($DELIVERY_ID, ':') === false) {
     $DELIVERY_ID = IntVal($DELIVERY_ID);
     $bUseOldDelivery = true;
 } else {
     $bUseOldDelivery = false;
 }
 $arDeliveryPrice = array();
 for ($i = 0; $i < count($arBasketList); $i++) {
     $arDeliveryPrice[$i] = 0;
 }
 $deliveryPrice = 0;
 if ($bNeedReCount) {
     if ($bUseOldDelivery) {
         if ($DELIVERY_ID > 0) {
             if ($arDelivery = CSaleDelivery::GetByID($DELIVERY_ID)) {
                 $deliveryPrice = roundEx(CCurrencyRates::ConvertCurrency($arDelivery["PRICE"], $arDelivery["CURRENCY"], $BASE_LANG_CURRENCY), SALE_VALUE_PRECISION);
             } else {
                 $errorMessage .= GetMessage("SOE_DELIVERY_NOT_FOUND") . "<br>";
             }
         }
     } else {
         list($DELIVERY_SERVICE, $DELIVERY_PROFILE) = explode(':', $DELIVERY_ID);
         if (strlen($DELIVERY_SERVICE) > 0 && strlen($DELIVERY_PROFILE) > 0) {
             $arDeliveryOrder = array("LOCATION_TO" => $DELIVERY_LOCATION, "LOCATION_FROM" => COption::GetOptionInt('sale', 'location', '', $LID), "WEIGHT" => $basketTotalWeight, "PRICE" => $basketTotalPrice + array_sum($arTaxPrice));
             $arDeliveryResult = CSaleDeliveryHandler::CalculateFull($DELIVERY_SERVICE, $DELIVERY_PROFILE, $arDeliveryOrder, $BASE_LANG_CURRENCY, $LID);
             //echo '<pre>'; print_r($arDeliveryResult ); echo '</pre>';
             //					die();
             if ($arDeliveryResult["RESULT"] != 'OK') {
                 if ($ex = $APPLICATION->GetException()) {
                     $errorMessage .= $ex->GetString() . '<br>';
コード例 #7
0
            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  *****************************************/
/*********************************************************************/
$aMenu = array(array("TEXT" => GetMessage("SDEN_2FLIST"), "LINK" => "/bitrix/admin/sale_delivery.php?lang=" . LANG . GetFilterParams("filter_"), "ICON" => "btn_list"));
if ($ID > 0 && $saleModulePermissions >= "W") {
コード例 #8
0
ファイル: Cart.class.php プロジェクト: ASDAFF/bitrix_lib
 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;
 }
コード例 #9
0
ファイル: order.php プロジェクト: ASDAFF/entask.ru
	function CheckFields($ACTION, &$arFields, $ID = 0)
	{
		global $USER_FIELD_MANAGER, $DB;

		if (is_set($arFields, "SITE_ID") && strlen($arFields["SITE_ID"]) > 0)
			$arFields["LID"] = $arFields["SITE_ID"];

		if ((is_set($arFields, "LID") || $ACTION=="ADD") && strlen($arFields["LID"])<=0)
		{
			$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGO_EMPTY_SITE"), "EMPTY_SITE_ID");
			return false;
		}
		if ((is_set($arFields, "PERSON_TYPE_ID") || $ACTION=="ADD") && IntVal($arFields["PERSON_TYPE_ID"])<=0)
		{
			$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGO_EMPTY_PERS_TYPE"), "EMPTY_PERSON_TYPE_ID");
			return false;
		}
		if ((is_set($arFields, "USER_ID") || $ACTION=="ADD") && IntVal($arFields["USER_ID"])<=0)
		{
			$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGO_EMPTY_USER_ID"), "EMPTY_USER_ID");
			return false;
		}

		if (is_set($arFields, "PAYED") && $arFields["PAYED"]!="Y")
			$arFields["PAYED"]="N";
		if (is_set($arFields, "CANCELED") && $arFields["CANCELED"]!="Y")
			$arFields["CANCELED"]="N";
		if (is_set($arFields, "STATUS_ID") && strlen($arFields["STATUS_ID"])<=0)
			$arFields["STATUS_ID"]="N";
		if (is_set($arFields, "ALLOW_DELIVERY") && $arFields["ALLOW_DELIVERY"]!="Y")
			$arFields["ALLOW_DELIVERY"]="N";
		if (is_set($arFields, "EXTERNAL_ORDER") && $arFields["EXTERNAL_ORDER"]!="Y")
			$arFields["EXTERNAL_ORDER"]="N";

		if (is_set($arFields, "PRICE") || $ACTION=="ADD")
		{
			$arFields["PRICE"] = str_replace(",", ".", $arFields["PRICE"]);
			$arFields["PRICE"] = DoubleVal($arFields["PRICE"]);
		}
		if (is_set($arFields, "PRICE_DELIVERY") || $ACTION=="ADD")
		{
			$arFields["PRICE_DELIVERY"] = str_replace(",", ".", $arFields["PRICE_DELIVERY"]);
			$arFields["PRICE_DELIVERY"] = DoubleVal($arFields["PRICE_DELIVERY"]);
		}
		if (is_set($arFields, "SUM_PAID") || $ACTION=="ADD")
		{
			$arFields["SUM_PAID"] = str_replace(",", ".", $arFields["SUM_PAID"]);
			$arFields["SUM_PAID"] = DoubleVal($arFields["SUM_PAID"]);
		}
		if (is_set($arFields, "DISCOUNT_VALUE") || $ACTION=="ADD")
		{
			$arFields["DISCOUNT_VALUE"] = str_replace(",", ".", $arFields["DISCOUNT_VALUE"]);
			$arFields["DISCOUNT_VALUE"] = DoubleVal($arFields["DISCOUNT_VALUE"]);
		}
		if (is_set($arFields, "TAX_VALUE") || $ACTION=="ADD")
		{
			$arFields["TAX_VALUE"] = str_replace(",", ".", $arFields["TAX_VALUE"]);
			$arFields["TAX_VALUE"] = DoubleVal($arFields["TAX_VALUE"]);
		}

		if(!is_set($arFields, "LOCKED_BY") && (!is_set($arFields, "UPDATED_1C") || (is_set($arFields, "UPDATED_1C") && $arFields["UPDATED_1C"] != "Y")))
		{
			$arFields["UPDATED_1C"] = "N";
			$arFields["~VERSION"] = "VERSION+0+1";
		}

		if ((is_set($arFields, "CURRENCY") || $ACTION=="ADD") && strlen($arFields["CURRENCY"])<=0)
		{
			$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGO_EMPTY_CURRENCY"), "EMPTY_CURRENCY");
			return false;
		}

		if (is_set($arFields, "CURRENCY"))
		{
			if (!($arCurrency = CCurrency::GetByID($arFields["CURRENCY"])))
			{
				$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["CURRENCY"], GetMessage("SKGO_WRONG_CURRENCY")), "ERROR_NO_CURRENCY");
				return false;
			}
		}

		if (is_set($arFields, "LID"))
		{
			$dbSite = CSite::GetByID($arFields["LID"]);
			if (!$dbSite->Fetch())
			{
				$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["LID"], GetMessage("SKGO_WRONG_SITE")), "ERROR_NO_SITE");
				return false;
			}
		}

		if (is_set($arFields, "USER_ID"))
		{
			$dbUser = CUser::GetByID($arFields["USER_ID"]);
			if (!$dbUser->Fetch())
			{
				$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["USER_ID"], GetMessage("SKGO_WRONG_USER")), "ERROR_NO_USER_ID");
				return false;
			}
		}

		if (is_set($arFields, "PERSON_TYPE_ID"))
		{
			if (!($arPersonType = CSalePersonType::GetByID($arFields["PERSON_TYPE_ID"])))
			{
				$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["PERSON_TYPE_ID"], GetMessage("SKGO_WRONG_PERSON_TYPE")), "ERROR_NO_PERSON_TYPE");
				return false;
			}
		}

		if (is_set($arFields, "PAY_SYSTEM_ID") && IntVal($arFields["PAY_SYSTEM_ID"]) > 0)
		{
			if (!($arPaySystem = CSalePaySystem::GetByID(IntVal($arFields["PAY_SYSTEM_ID"]))))
			{
				$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["PAY_SYSTEM_ID"], GetMessage("SKGO_WRONG_PS")), "ERROR_NO_PAY_SYSTEM");
				return false;
			}
		}

		if (is_set($arFields, "DELIVERY_ID") && (
				strpos($arFields["DELIVERY_ID"], ":") !== false
				||
				IntVal($arFields["DELIVERY_ID"]) > 0
			)
		)
		{
			if (strpos($arFields["DELIVERY_ID"], ":") !== false)
			{
				$arId = explode(":", $arFields["DELIVERY_ID"]);
				$obDelivery = new CSaleDeliveryHandler();
				if ($arDelivery = $obDelivery->GetBySID($arId[0]))
				{
					if ($arDelivery = $arDelivery->Fetch())
					{
						if (!is_set($arDelivery["PROFILES"], $arId[1]))
						{
							$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["DELIVERY_ID"], GetMessage("SKGO_WRONG_DELIVERY")), "ERROR_NO_DELIVERY");
							return false;
						}
					}
				}
				else
				{
					$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["DELIVERY_ID"], GetMessage("SKGO_WRONG_DELIVERY")), "ERROR_NO_DELIVERY");
					return false;
				}
			}
			else
			{
				if (!($arDelivery = CSaleDelivery::GetByID(IntVal($arFields["DELIVERY_ID"]))))
				{
					$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["DELIVERY_ID"], GetMessage("SKGO_WRONG_DELIVERY")), "ERROR_NO_DELIVERY");
					return false;
				}
			}
		}

		if (is_set($arFields, "STATUS_ID"))
		{
			if (!($arStatus = CSaleStatus::GetByID($arFields["STATUS_ID"])))
			{
				$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["STATUS_ID"], GetMessage("SKGO_WRONG_STATUS")), "ERROR_NO_STATUS_ID");
				return false;
			}
		}

		if (is_set($arFields, "ACCOUNT_NUMBER") && $ACTION=="UPDATE")
		{
			if (strlen($arFields["ACCOUNT_NUMBER"]) <= 0)
			{
				$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGO_EMPTY_ACCOUNT_NUMBER"), "EMPTY_ACCOUNT_NUMBER");
				return false;
			}
			else
			{
				$dbres = $DB->Query("SELECT ID, ACCOUNT_NUMBER FROM b_sale_order WHERE ACCOUNT_NUMBER = '".$DB->ForSql($arFields["ACCOUNT_NUMBER"])."'", true);
				if ($arRes = $dbres->GetNext())
				{
					if (is_array($arRes) && $arRes["ID"] != $ID)
					{
						$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGO_EXISTING_ACCOUNT_NUMBER"), "EXISTING_ACCOUNT_NUMBER");
						return false;
					}
				}
			}
		}

		if($ACTION == "ADD")
			$arFields["VERSION"] = 1;

		if (!$USER_FIELD_MANAGER->CheckFields("ORDER", $ID, $arFields))
		{
			return false;
		}

		return True;
	}
コード例 #10
0
ファイル: order_change.php プロジェクト: rasuldev/torino
 public static function FormatOrderDeliverySystemChanged($arData)
 {
     $info = GetMessage("SOC_ORDER_DELIVERY_SYSTEM_CHANGED_INFO");
     foreach ($arData as $param => $value) {
         if ($param == "DELIVERY_ID") {
             if (strpos($value, ":") !== false) {
                 $arId = explode(":", $value);
                 $dbDelivery = CSaleDeliveryHandler::GetBySID($arId[0]);
                 $arDelivery = $dbDelivery->Fetch();
                 $value = "\"" . htmlspecialcharsEx($arDelivery["NAME"]) . "\"";
             } elseif (intval($value) > 0) {
                 $arDelivery = CSaleDelivery::GetByID($value);
                 $value = "\"" . $arDelivery["NAME"] . "\"";
             }
         }
         $info = str_replace("#" . $param . "#", $value, $info);
     }
     return array("NAME" => GetMessage("SOC_ORDER_DELIVERY_SYSTEM_CHANGED"), "INFO" => $info);
 }
コード例 #11
0
         }
     }
     if (IntVal($arUserResult["DELIVERY_LOCATION"]) > 0) {
         if (strlen($arUserResult["DELIVERY_ID"]) > 0 && strpos($arUserResult["DELIVERY_ID"], ":") !== false) {
             $delivery = explode(":", $arUserResult["DELIVERY_ID"]);
             $obDeliveryHandler = CSaleDeliveryHandler::GetBySID($delivery[0]);
             $arResult["DELIVERY_SUM"] = $obDeliveryHandler->Fetch();
             $arResult["DELIVERY_PROFILE_SUM"] = $delivery[1];
             $arOrderTmpDel = array("PRICE" => $arResult["ORDER_PRICE"], "WEIGHT" => $arResult["ORDER_WEIGHT"], "LOCATION_FROM" => COption::GetOptionInt('sale', 'location'), "LOCATION_TO" => $arUserResult["DELIVERY_LOCATION"], "LOCATION_ZIP" => $arUserResult["DELIVERY_LOCATION_ZIP"]);
             $arDeliveryPrice = CSaleDeliveryHandler::CalculateFull($delivery[0], $delivery[1], $arOrderTmpDel, $arResult["BASE_LANG_CURRENCY"]);
             if ($arDeliveryPrice["RESULT"] == "ERROR") {
                 $arResult["ERROR"][] = $arDeliveryPrice["TEXT"];
             } else {
                 $arResult["DELIVERY_PRICE"] = roundEx($arDeliveryPrice["VALUE"], SALE_VALUE_PRECISION);
             }
         } elseif (IntVal($arUserResult["DELIVERY_ID"]) > 0 && ($arDeliv = CSaleDelivery::GetByID($arUserResult["DELIVERY_ID"]))) {
             $arDeliv["NAME"] = htmlspecialcharsEx($arDeliv["NAME"]);
             $arResult["DELIVERY_SUM"] = $arDeliv;
             $arResult["DELIVERY_PRICE"] = roundEx(CCurrencyRates::ConvertCurrency($arDeliv["PRICE"], $arDeliv["CURRENCY"], $arResult["BASE_LANG_CURRENCY"]), SALE_VALUE_PRECISION);
         } elseif (IntVal($DELIVERY_ID) > 0) {
             $arResult["DELIVERY"] = "ERROR";
         }
         $arResult["DELIVERY_PRICE_FORMATED"] = SaleFormatCurrency($arResult["DELIVERY_PRICE"], $arResult["BASE_LANG_CURRENCY"]);
     }
 }
 /* Check Values End */
 /* Discounts begin */
 for ($i = 0; $i < count($arResult["BASKET_ITEMS"]); $i++) {
     $arResult["BASKET_ITEMS"][$i]["DISCOUNT_PRICE"] = $arResult["BASKET_ITEMS"][$i]["PRICE"];
 }
 $dbDiscount = CSaleDiscount::GetList(array("SORT" => "ASC"), array("LID" => SITE_ID, "ACTIVE" => "Y", "!>ACTIVE_FROM" => Date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL"))), "!<ACTIVE_TO" => Date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL"))), "<=PRICE_FROM" => $arResult["ORDER_PRICE"], ">=PRICE_TO" => $arResult["ORDER_PRICE"]), false, false, array("*"));
コード例 #12
0
ファイル: csv.php プロジェクト: akniyev/itprom_dobrohost
     break;
 case "PAY_SYSTEM":
     if (IntVal($arOrder["PAY_SYSTEM_ID"]) > 0) {
         if (!isset($LOCAL_PAY_SYSTEM_CACHE[$arOrder["PAY_SYSTEM_ID"]]) || !is_array($LOCAL_PAY_SYSTEM_CACHE[$arOrder["PAY_SYSTEM_ID"]])) {
             if ($arPaySys = CSalePaySystem::GetByID($arOrder["PAY_SYSTEM_ID"])) {
                 $LOCAL_PAY_SYSTEM_CACHE[$arOrder["PAY_SYSTEM_ID"]] = htmlspecialcharsEx($arPaySys["NAME"]);
             }
         }
         $printValue = "[" . $arOrder["PAY_SYSTEM_ID"] . "] " . $LOCAL_PAY_SYSTEM_CACHE[$arOrder["PAY_SYSTEM_ID"]];
         echo "\"" . str_replace("\"", "\"\"", $printValue) . "\"";
     }
     break;
 case "DELIVERY":
     if (IntVal($arOrder["DELIVERY_ID"]) > 0) {
         if (!isset($LOCAL_DELIVERY_CACHE[$arOrder["DELIVERY_ID"]]) || !is_array($LOCAL_DELIVERY_CACHE[$arOrder["DELIVERY_ID"]])) {
             if ($arDelivery = CSaleDelivery::GetByID($arOrder["DELIVERY_ID"])) {
                 $LOCAL_DELIVERY_CACHE[$arOrder["DELIVERY_ID"]] = htmlspecialcharsEx($arDelivery["NAME"]);
             }
         }
         $printValue = "[" . $arOrder["DELIVERY_ID"] . "] " . $LOCAL_DELIVERY_CACHE[$arOrder["DELIVERY_ID"]];
         echo "\"" . str_replace("\"", "\"\"", $printValue) . "\"";
     }
     break;
 case "DATE_UPDATE":
     echo "\"" . str_replace("\"", "\"\"", $arOrder["DATE_UPDATE"]) . "\"";
     break;
 case "PS_STATUS":
     if ($arOrder["PS_STATUS"] == "Y") {
         $printValue = GetMessage("SEXC_SUCCESS") . " " . $arOrder["PS_RESPONSE_DATE"];
     } elseif ($arOrder["PS_STATUS"] == "N") {
         $printValue = GetMessage("SEXC_UNSUCCESS") . " " . $arOrder["PS_RESPONSE_DATE"];
コード例 #13
0
ファイル: basket_items.php プロジェクト: akniyev/arteva.ru
             </div>
         </li>
     <?endforeach?>
 </ul>
 <p class="header">Параметры заказа</p>
 <ul class="checkout-order-params">
     <li class="checkout-param">
         <span>Стоимость товаров</span>
         <span><?=number_format($arResult["allSum"]+$arResult["DISCOUNT_PRICE_ALL"], 0, 0, " ")?> руб.</span>
     </li>
     <li class="checkout-param">
         <span>Со скидкой</span>
         <span><?=number_format($arResult["allSum"], 0, 0, " ")?> руб.</span>
     </li>
     <li class="checkout-param">
         <?$arDeliv = CSaleDelivery::GetByID($_REQUEST["DELIVERY_ID"]);?>
         <span>Доставка</span>
         <span><?=$arDeliv["NAME"]?> — <?=$arDeliv["DESCRIPTION"]?></span>
     </li>
     <li class="checkout-param">
         <span>Адрес доставки</span>
         <span><?=$_REQUEST["ORDER_PROP_7"]?></span>
     </li>
     <li class="checkout-param">
         <span>Оплата</span>
         <span><?=getPaySystemName($_REQUEST["PAY_SYSTEM_ID"])?></span>
     </li>
 </ul>
 <p class="header">
     <a href="#" class="checkout-confirm-comment js-checkout-confirm-comment-trigger">Ваш комментарий</a>
 </p>
コード例 #14
0
			<tr>
				<td width="40%"><?php 
        echo GetMessage("P_ORDER_DELIVERY");
        ?>
:</td>
				<td width="60%">
					<?php 
        if (strpos($str_DELIVERY_ID, ":") !== false) {
            $arId = explode(":", $str_DELIVERY_ID);
            $dbDelivery = CSaleDeliveryHandler::GetBySID($arId[0]);
            $arDelivery = $dbDelivery->Fetch();
            //echo "<pre>"; print_r($arDelivery); echo "</pre>";
            echo "[" . $arDelivery["SID"] . "] " . htmlspecialcharsEx($arDelivery["NAME"]) . " (" . $str_LID . ")";
            echo "<br />[" . htmlspecialcharsEx($arId[1]) . "] " . htmlspecialcharsEx($arDelivery["PROFILES"][$arId[1]]["TITLE"]);
        } elseif (IntVal($str_DELIVERY_ID) > 0) {
            $arDelivery = CSaleDelivery::GetByID($str_DELIVERY_ID);
            echo "[" . $arDelivery["ID"] . "] " . $arDelivery["NAME"] . " (" . $arDelivery["LID"] . ")";
        } else {
            echo GetMessage("SOD_NONE");
        }
        ?>
				</td>
			</tr>
			<tr>
				<td width="40%">
					<?php 
        echo GetMessage("P_ORDER_ALLOW_DELIVERY");
        ?>
:
				</td>
				<form method="get" action="/bitrix/admin/sale_order_detail.php" name="change_delivery_form">
コード例 #15
0
ファイル: component.php プロジェクト: CheBurashka334/zakrepi
									$content = str_replace("charset=".SITE_CHARSET, "charset=".BX_SALE_ENCODING, $content);
								}
							}
						}
					}

					if ($arPaySysAction > 0)
						$arPaySysAction["LOGOTIP"] = CFile::GetFileArray($arPaySysAction["LOGOTIP"]);

					$arResult["PAY_SYSTEM"] = $arPaySysAction;
				}
			}
			$arResult["ORDER"] = $arOrder;

			if (!empty($arResult["ORDER"]["DELIVERY_ID"])){
				$arDeliv = CSaleDelivery::GetByID($arResult["ORDER"]["DELIVERY_ID"]);
				$arResult["ORDER_INFO"]["DELIVERY"] = $arDeliv;

				if (count($arResult["ORDER_INFO"]["DELIVERY"]) == 0 || is_string($arResult["ORDER"]["DELIVERY_ID"]))
				{
					$sid = explode(":", $arResult["ORDER"]["DELIVERY_ID"]);
					$dbDeliv = CSaleDeliveryHandler::GetBySID($sid[0]);
					if ($arDeliv = $dbDeliv->GetNext())
					{
						$arResult["ORDER_INFO"]["DELIVERY"] = $arDeliv;
					}
				}
			}
		}
	}
}
コード例 #16
0
 public static function FormatOrderDeliverySystemChanged($data)
 {
     $isOrderConverted = \Bitrix\Main\Config\Option::get("main", "~sale_converted_15", 'N');
     $info = GetMessage("SOC_ORDER_DELIVERY_SYSTEM_CHANGED_INFO");
     if (is_array($data)) {
         foreach ($data as $param => $value) {
             if ($param == "DELIVERY_ID") {
                 if (!array_key_exists('DELIVERY_NAME', $arData) && strval($arData['DELIVERY_NAME']) != '') {
                     if (strpos($value, ":") !== false) {
                         $arId = explode(":", $value);
                         $dbDelivery = CSaleDeliveryHandler::GetBySID($arId[0]);
                         $arDelivery = $dbDelivery->Fetch();
                         $value = "\"" . htmlspecialcharsEx($arDelivery["NAME"]) . "\"";
                     } elseif (intval($value) > 0) {
                         if ($isOrderConverted == "Y") {
                             $arDelivery = \Bitrix\Sale\Delivery\Services\Manager::getById($value);
                         } else {
                             $arDelivery = CSaleDelivery::GetByID($value);
                         }
                         $value = "\"" . $arDelivery["NAME"] . "\"";
                     }
                 } else {
                     $value = "\"" . $arData['DELIVERY_NAME'] . "\"";
                 }
             } elseif ($param == "DELIVERY_NAME") {
                 $value = "\"" . $value . "\"";
             } else {
                 continue;
             }
             $info = str_replace("#" . $param . "#", $value, $info);
         }
     } else {
         $info = $data;
     }
     return array("NAME" => GetMessage("SOC_ORDER_DELIVERY_SYSTEM_CHANGED"), "INFO" => $info);
 }