Ejemplo n.º 1
0
 public static function preparePreregistrationReqData($arOrder, $profileId, $arConfig)
 {
     $result = array();
     $result["sender"] = array("inn" => $arConfig["INN"]["VALUE"], "city" => static::getFilialAndCity($arConfig["CITY_DELIVERY"]["VALUE"]), "title" => $arConfig["NAME"]["VALUE"], "phone" => $arConfig["PHONE"]["VALUE"]);
     $inn = "";
     $city = "";
     $title = "";
     $phone = "";
     $address = "";
     if (isset($extraParams["location"])) {
         $city = $extraParams["location"];
     }
     $dbOrderProps = \CSaleOrderPropsValue::GetOrderProps($arOrder["ID"]);
     while ($arOrderProps = $dbOrderProps->Fetch()) {
         if ($arOrderProps["CODE"] == "COMPANY" || $arOrderProps["CODE"] == "FIO") {
             $title = $arOrderProps["VALUE"];
         }
         if ($arOrderProps["CODE"] == "INN") {
             $inn = $arOrderProps["VALUE"];
         }
         if ($arOrderProps["CODE"] == "PHONE") {
             $phone = $arOrderProps["VALUE"];
         }
         if ($arOrderProps["CODE"] == "LOCATION") {
             $location = $arOrderProps["VALUE"];
             $locDelivery = Adapter::mapLocation($location);
             // todo: if more than one
             $city = static::getFilialAndCity(key($locDelivery));
         }
         if ($arOrderProps["CODE"] == "ADDRESS") {
             $address = $arOrderProps["VALUE"];
         }
     }
     $arPacks = \CSaleDeliveryHelper::getBoxesFromConfig($profileId, $arConfig);
     $arPackagesParams = \CSaleDeliveryHelper::getRequiredPacks($arOrder["ITEMS"], $arPacks, 0);
     $result["cargos"] = array(array("common" => array("positionsCount" => count($arPackagesParams), "decription" => GetMessage("SALE_DH_PECOM_DESCRIPTION_GOODS"), "orderNumber" => $arOrder["ACCOUNT_NUMBER"], "paymentForm" => $arConfig["PAYMENT_FORM"]["VALUE"], "accompanyingDocuments" => false), "receiver" => array("inn" => $inn, "city" => $city, "title" => $title, "phone" => $phone, "addressStock" => $address), "services" => array("transporting" => array("payer" => array("type" => 1)), "hardPacking" => array("enabled" => \CDeliveryPecom::isConfCheckedVal($arConfig, 'SERVICE_OTHER_RIGID_PACKING'), "payer" => array("type" => \CDeliveryPecom::getConfValue($arConfig, 'SERVICE_OTHER_RIGID_PAYER'))), "palletTransporting" => array("enabled" => !\CDeliveryPecom::isConfCheckedVal($arConfig, 'SERVICE_OTHER_RIGID_PACKING') && \CDeliveryPecom::isConfCheckedVal($arConfig, 'SERVICE_OTHER_PALLETE'), "payer" => array("type" => \CDeliveryPecom::getConfValue($arConfig, 'SERVICE_OTHER_PALLETE_PAYER'))), "insurance" => array("enabled" => \CDeliveryPecom::isConfCheckedVal($arConfig, 'SERVICE_OTHER_INSURANCE'), "payer" => array("type" => \CDeliveryPecom::getConfValue($arConfig, 'SERVICE_OTHER_INSURANCE_PAYER')), "cost" => intval($arOrder["PRICE"])), "sealing" => array("enabled" => \CDeliveryPecom::isConfCheckedVal($arConfig, 'SERVICE_OTHER_PLOMBIR_ENABLE'), "payer" => array("type" => \CDeliveryPecom::getConfValue($arConfig, 'SERVICE_OTHER_PLOMBIR_PAYER'))), "strapping" => array("enabled" => false), "documentsReturning" => array("enabled" => false), "delivery" => array("enabled" => \CDeliveryPecom::isConfCheckedVal($arConfig, 'SERVICE_DELIVERY_ENABLED'), "payer" => array("type" => \CDeliveryPecom::getConfValue($arConfig, 'SERVICE_OTHER_DELIVERY_PAYER'))))));
     return $result;
 }
Ejemplo n.º 2
0
function fGetBuyerType($PERSON_TYPE_ID, $LID, $USER_ID = '', $ORDER_ID = 0, $formVarsSubmit = false)
{
	global $locationZipID, $locationID, $DELIVERY_LOCATION, $DELIVERY_LOCATION_ZIP;
	$resultHtml = "<script>locationZipID = 0;locationID = 0;</script><table width=\"100%\" id=\"order_type_props\" class=\"edit-table\">";

	//select person type
	$arPersonTypeList = array();
	$personTypeSelect = "<select name='buyer_type_id' id='buyer_type_id' OnChange='fBuyerChangeType(this);' >";
	$dbPersonType = CSalePersonType::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("ACTIVE" => "Y"));
	while ($arPersonType = $dbPersonType->GetNext())
	{
		if (!in_array($LID, $arPersonType["LIDS"]))
			continue;

		if (!isset($PERSON_TYPE_ID) OR $PERSON_TYPE_ID == "")
			$PERSON_TYPE_ID = $arPersonType["ID"];

		$class = "";
		if (intval($arPersonType["ID"]) == intval($PERSON_TYPE_ID))
			$class = " selected";

		$personTypeSelect .= "<option value=\"".$arPersonType["ID"]."\" ".$class.">".$arPersonType["NAME"]." [".$arPersonType["ID"]."]</option>";
	}
	$personTypeSelect .= "</select>";

	$userComment = "";
	$userDisplay = "none";
	if (intval($ORDER_ID) > 0)
	{
		$dbOrder = CSaleOrder::GetList(
			array(),
			array("ID" => $ORDER_ID, "ACTIVE" => "Y"),
			false,
			false,
			array()
		);
		$arOrder = $dbOrder->Fetch();
		$userComment = $arOrder["USER_DESCRIPTION"];
		$userDisplay = "table-row";
	}

	if ($formVarsSubmit && $_REQUEST["btnTypeBuyer"] == "btnBuyerNew")
		$userDisplay = "none";
	elseif ($formVarsSubmit && $_REQUEST["btnTypeBuyer"] == "btnBuyerExist")
		$userDisplay = "table-row";

	$resultHtml .= "<tr id=\"btnBuyerExistField\" style=\"display:".$userDisplay."\">
			<td class=\"adm-detail-content-cell-l\" width=\"40%\">".GetMessage("NEWO_BUYER").":</td>
			<td class=\"adm-detail-content-cell-r\" width=\"60%\"><div id=\"user_name\">".fGetUserName($USER_ID)."</div></td></tr>";

	$resultHtml .= "<tr class=\"adm-detail-required-field\">
		<td class=\"adm-detail-content-cell-l\" width=\"40%\">".GetMessage("SOE_PERSON_TYPE").":</td>
		<td class=\"adm-detail-content-cell-r\" width=\"60%\">".$personTypeSelect."</td>
	</tr>";

	$bShowTrProfile = "none";
	if ($formVarsSubmit && $_POST["btnTypeBuyer"] == "btnBuyerExist")
		$bShowTrProfile = "table-row";

	$resultHtml .= "<tr id=\"buyer_profile_display\" style=\"display:".$bShowTrProfile."\" class=\"adm-detail-required-field\">
		<td class=\"adm-detail-content-cell-l\">".GetMessage("NEWO_BUYER_PROFILE").":</td>
		<td class=\"adm-detail-content-cell-r\">
			<div id=\"buyer_profile_select\">";

			if ($formVarsSubmit && $_POST["btnTypeBuyer"] == "btnBuyerExist")
			{
				$resultHtml .= fUserProfile(intval($_POST["user_id"]), intval($_POST["buyer_type_id"]), $default = '');
			}

	$resultHtml .= "</div></td>
	</tr>";

	if ($ORDER_ID <= 0)
	{
		$arCountProps = fGetCountProfileProps($PERSON_TYPE_ID);
		$resultHtml .= "<tr id=\"btnBuyerNewField\">";
		if (count($arCountProps) < 3)
		{
			$resultHtml .= "<td colspan=2>
					<table width=\"100%\" class=\"edit-table\" >";
					if (intval($arCountProps["IS_EMAIL"]) <= 0)
						$resultHtml .= "<tr class=\"adm-detail-required-field\">
							<td class=\"adm-detail-content-cell-l\" width=\"40%\">".GetMessage("NEWO_BUYER_REG_MAIL")."</td>
							<td class=\"adm-detail-content-cell-r\"><input type=\"text\" name=\"NEW_BUYER_EMAIL\" size=\"30\" value=\"".htmlspecialcharsbx(trim($_REQUEST["NEW_BUYER_EMAIL"]))."\" tabindex=\"1\" /></td>
						</tr>";
					if (intval($arCountProps["IS_PAYER"]) <= 0)
						$resultHtml .= "<tr class=\"adm-detail-required-field\">
							<td class=\"adm-detail-content-cell-l\">".GetMessage("NEWO_BUYER_REG_LASTNAME")."</td>
							<td class=\"adm-detail-content-cell-r\"><input type=\"text\" name=\"NEW_BUYER_LAST_NAME\" size=\"30\" value=\"".htmlspecialcharsbx(trim($_REQUEST["NEW_BUYER_LAST_NAME"]))."\" tabindex=\"3\" /></td>
						</tr>
						<tr class=\"adm-detail-required-field\">
							<td class=\"adm-detail-content-cell-l\">".GetMessage("NEWO_BUYER_REG_NAME")."</td>
							<td class=\"adm-detail-content-cell-r\"><input type=\"text\" name=\"NEW_BUYER_NAME\" size=\"30\" value=\"".htmlspecialcharsbx(trim($_REQUEST["NEW_BUYER_NAME"]))."\" tabindex=\"2\" /></td>
						</tr>";
					$resultHtml .= "</table>
				</td>";
		}
		$resultHtml .= "</tr>";
	}

	$arPropertiesList = array();
	$dbProperties = CSaleOrderProps::GetList(
		array("GROUP_SORT" => "ASC", "PROPS_GROUP_ID" => "ASC", "SORT" => "ASC", "NAME" => "ASC"),
		array("PERSON_TYPE_ID" => $PERSON_TYPE_ID, "ACTIVE" => "Y", "RELATED" => false),
		false,
		false,
		array("*")
	);
	while($property = $dbProperties->Fetch())
	{
		$arPropertiesList[$property['ID']] = $property;
	}

	// getting values
	$arPropValues = array();
	if ($formVarsSubmit) // from request
	{
		$locationIndexForm = "";
		foreach ($_POST as $key => $value)
		{
			if (substr($key, 0, strlen("CITY_ORDER_PROP_")) == "CITY_ORDER_PROP_")
			{
				$arPropValues[intval(substr($key, strlen("CITY_ORDER_PROP_")))] = htmlspecialcharsbx($value);
				$locationIndexForm = intval(substr($key, strlen("CITY_ORDER_PROP_")));
			}
			if (substr($key, 0, strlen("ORDER_PROP_")) == "ORDER_PROP_")
			{
				if ($locationIndexForm != intval(substr($key, strlen("ORDER_PROP_"))) && !is_array($value))
					$arPropValues[intval(substr($key, strlen("ORDER_PROP_")))] = htmlspecialcharsbx($value);
			}
		}
		$userComment = $_POST["USER_DESCRIPTION"];
	}
	elseif ($ORDER_ID == "" AND $USER_ID != "") // from profile
	{
		//profile
		$userProfile = array();
		$userProfile = CSaleOrderUserProps::DoLoadProfiles($USER_ID, $PERSON_TYPE_ID);
		$arPropValues = $userProfile[$PERSON_TYPE_ID]["VALUES"];
	}
	elseif ($ORDER_ID != "") // from order properties
	{
		$dbPropValuesList = CSaleOrderPropsValue::GetList(
			array(),
			array("ORDER_ID" => $ORDER_ID, "ACTIVE" => "Y"),
			false,
			false,
			array("ID", "ORDER_PROPS_ID", "NAME", "VALUE", "CODE")
		);
		while ($arPropValuesList = $dbPropValuesList->Fetch())
		{
			// from db
			if(CSaleLocation::isLocationProMigrated() && $arPropertiesList[$arPropValuesList['ORDER_PROPS_ID']]['TYPE'] == 'LOCATION')
				$arPropValuesList["VALUE"] = CSaleLocation::getLocationIDbyCODE($arPropValuesList["VALUE"]);

			$arPropValues[intval($arPropValuesList["ORDER_PROPS_ID"])] = htmlspecialcharsbx($arPropValuesList["VALUE"]);
		}
	}

	$location2townFldMap = array();
	$arDisableFieldForLocation = array();
	//select field (town) for disable
	$dbProperties = CSaleOrderProps::GetList(
		array(),
		array("PERSON_TYPE_ID" => $PERSON_TYPE_ID, "ACTIVE" => "Y", ">INPUT_FIELD_LOCATION" => 0),
		false,
		false,
		array("INPUT_FIELD_LOCATION")
	);
	while ($arProperties = $dbProperties->Fetch())
	{
		$arDisableFieldForLocation[$arProperties["INPUT_FIELD_LOCATION"]] = $arProperties["INPUT_FIELD_LOCATION"];
	}

	//show town if location is another
	$arEnableTownProps = array();
	$dbOrderProps = CSaleOrderPropsValue::GetOrderProps($ORDER_ID);
	while ($arOrderProps = $dbOrderProps->Fetch())
	{
		if($arOrderProps["TYPE"] == "LOCATION" && $arOrderProps["ACTIVE"] == "Y" && $arOrderProps["IS_LOCATION"] == "Y")
		{
			if (in_array($arOrderProps["INPUT_FIELD_LOCATION"], $arDisableFieldForLocation))
			{
				if(CSaleLocation::isLocationProMigrated())
				{
					if(CSaleLocation::checkLocationIsAboveCity($arPropValues[$arOrderProps["ORDER_PROPS_ID"]]))
						unset($arDisableFieldForLocation[$arOrderProps["INPUT_FIELD_LOCATION"]]);
				}
				else
				{
					$arLocation = CSaleLocation::GetByID($arPropValues[$arOrderProps["ORDER_PROPS_ID"]]);
					if (intval($arLocation["CITY_ID"]) <= 0)
						unset($arDisableFieldForLocation[$arOrderProps["INPUT_FIELD_LOCATION"]]);
				}
			}

			$location2townFldMap[$arOrderProps['ORDER_PROPS_ID']] = $arOrderProps['INPUT_FIELD_LOCATION'];
		}
	}

	$propertyGroupID = -1;

	foreach($arPropertiesList as $arProperties)
	{
		if (intval($arProperties["PROPS_GROUP_ID"]) != $propertyGroupID)
		{
			$resultHtml .= "<tr><td colspan=\"2\" style=\"text-align:center;font-weight:bold;font-size:14px;color:rgb(75, 98, 103);\" >".htmlspecialcharsEx($arProperties["GROUP_NAME"])."\n</td>\n</tr>";
			$propertyGroupID = intval($arProperties["PROPS_GROUP_ID"]);
		}

		if (intval($arProperties["PROPS_GROUP_ID"]) != $propertyGroupID)
			$propertyGroupID = intval($arProperties["PROPS_GROUP_ID"]);

		$adit = "";
		$requiredField = "";
		if ($arProperties["REQUIED"] == "Y" || $arProperties["IS_PROFILE_NAME"] == "Y" || $arProperties["IS_LOCATION"] == "Y" || $arProperties["IS_LOCATION4TAX"] == "Y" || $arProperties["IS_PAYER"] == "Y" || $arProperties["IS_ZIP"] == "Y")
		{
			$adit = " class=\"adm-detail-required-field\"";
			$requiredField = " class=\"adm-detail-content-cell-l\"";
		}

		$isTownProperty = in_array($arProperties["ID"], $location2townFldMap) || $arProperties['CODE'] == 'CITY';

		//delete town from location
		if (in_array($arProperties["ID"], $arDisableFieldForLocation))
			$resultHtml .= "<tr style=\"display:none;\" id=\"town_location_".$arProperties["ID"]."\"".$adit.">\n";
		else
			$resultHtml .= "<tr id=\"town_location_".$arProperties["ID"]."\"".$adit.($isTownProperty ? " class=\"-bx-order-property-city\"" : '').">\n";

		if(($arProperties["TYPE"] == "MULTISELECT" || $arProperties["TYPE"] == "TEXTAREA" || $arProperties["TYPE"] == "FILE") || ($ORDER_ID <= 0 && $arProperties["IS_PROFILE_NAME"] == "Y") )
			$resultHtml .= "<td valign=\"top\" class=\"adm-detail-content-cell-l\" width=\"40%\">\n";
		else
			$resultHtml .= "<td align=\"right\" width=\"40%\" ".$requiredField.">\n";

		$resultHtml .= $arProperties["NAME"].":</td>";

		$curVal = $arPropValues[intval($arProperties["ID"])];

		if($arProperties["IS_EMAIL"] == "Y" || $arProperties["IS_PAYER"] == "Y")
		{
			if(strlen($arProperties["DEFAULT_VALUE"]) <= 0 && intval($USER_ID) > 0)
			{
				$rsUser = CUser::GetByID($USER_ID);
				if ($arUser = $rsUser->Fetch())
				{
					if($arProperties["IS_EMAIL"] == "Y")
						$arProperties["DEFAULT_VALUE"] = $arUser["EMAIL"];
					else
					{
						if (strlen($arUser["LAST_NAME"]) > 0)
							$arProperties["DEFAULT_VALUE"] .= $arUser["LAST_NAME"];
						if (strlen($arUser["NAME"]) > 0)
							$arProperties["DEFAULT_VALUE"] .= " ".$arUser["NAME"];
						if (strlen($arUser["SECOND_NAME"]) > 0 AND strlen($arUser["NAME"]) > 0)
							$arProperties["DEFAULT_VALUE"] .= " ".$arUser["SECOND_NAME"];
					}
				}
			}
		}

		$resultHtml .= "<td class=\"adm-detail-content-cell-r\" width=\"60%\">";

		if ($arProperties["TYPE"] == "CHECKBOX")
		{
			$resultHtml .= '<input type="checkbox" class="inputcheckbox" ';
			$resultHtml .= 'name="ORDER_PROP_'.$arProperties["ID"].'" value="Y"';
			$resultHtml .= 'id="ORDER_PROP_'.$arProperties["ID"].'" ';
			if ($curVal=="Y" || !isset($curVal) && $arProperties["DEFAULT_VALUE"]=="Y")
				$resultHtml .= " checked";
			$resultHtml .= '>';
		}
		elseif ($arProperties["TYPE"] == "TEXT")
		{
			$change = "";
			if ($arProperties["IS_ZIP"] == "Y")
			{
				$DELIVERY_LOCATION_ZIP = $curVal;
				$resultHtml .= '<script> locationZipID = \''.$arProperties["ID"].'\';</script>';
				$locationZipID = ((isset($curVal)) ? htmlspecialcharsEx($curVal) : htmlspecialcharsex($arProperties["DEFAULT_VALUE"]));
			}

			if ($arProperties["IS_PAYER"] == "Y" && intval($USER_ID) <= 0)
			{
				$resultHtml .= '<div id="BREAK_NAME"';
				if ($ORDER_ID > 0 || ($formVarsSubmit && $_REQUEST["btnTypeBuyer"] == "btnBuyerExist"))
					$resultHtml .= ' style="display:none"';
				$resultHtml .= '>';

				$BREAK_LAST_NAME_TMP = GetMessage('NEWO_BREAK_LAST_NAME');
				if (isset($_REQUEST["BREAK_LAST_NAME"]) && strlen($_REQUEST["BREAK_LAST_NAME"]) > 0)
					$BREAK_LAST_NAME_TMP = htmlspecialcharsbx(trim($_REQUEST["BREAK_LAST_NAME"]));

				$NEWO_BREAK_NAME_TMP = GetMessage('NEWO_BREAK_NAME');
				if (isset($_REQUEST["BREAK_NAME"]) && strlen($_REQUEST["BREAK_NAME"]) > 0)
					$NEWO_BREAK_NAME_TMP = htmlspecialcharsbx(trim($_REQUEST["BREAK_NAME"]));

				$BREAK_SECOND_NAME_TMP = GetMessage('NEWO_BREAK_SECOND_NAME');
				if (isset($_REQUEST["BREAK_SECOND_NAME"]) && strlen($_REQUEST["BREAK_SECOND_NAME"]) > 0)
					$BREAK_SECOND_NAME_TMP = htmlspecialcharsbx(trim($_REQUEST["BREAK_SECOND_NAME"]));

				$resultHtml .= "<div class=\"fio newo_break_active\"><input onblur=\"if (this.value==''){this.value='".CUtil::JSEscape(GetMessage('NEWO_BREAK_LAST_NAME'))."';BX.addClass(this.parentNode,'newo_break_active');}\" onfocus=\"if (this.value=='".CUtil::JSEscape(GetMessage('NEWO_BREAK_LAST_NAME'))."') {this.value='';BX.removeClass(this.parentNode,'newo_break_active');}\" type=\"text\" name=\"BREAK_LAST_NAME\" id=\"BREAK_LAST_NAME\" size=\"30\" value=\"".$BREAK_LAST_NAME_TMP."\" /></div>";
				$resultHtml .= "<div class=\"fio newo_break_active\"><input onblur=\"if (this.value==''){this.value='".CUtil::JSEscape(GetMessage('NEWO_BREAK_NAME'))."';BX.addClass(this.parentNode,'newo_break_active');}\" onfocus=\"if (this.value=='".CUtil::JSEscape(GetMessage('NEWO_BREAK_NAME'))."') {this.value='';BX.removeClass(this.parentNode,'newo_break_active');}\" type=\"text\" name=\"BREAK_NAME\" id=\"BREAK_NAME_BUYER\" size=\"30\" value=\"".$NEWO_BREAK_NAME_TMP."\" /></div>";
				$resultHtml .= "<div class=\"fio newo_break_active\"><input onblur=\"if (this.value==''){this.value='".CUtil::JSEscape(GetMessage('NEWO_BREAK_SECOND_NAME'))."';BX.addClass(this.parentNode,'newo_break_active');}\" onfocus=\"if (this.value=='".CUtil::JSEscape(GetMessage('NEWO_BREAK_SECOND_NAME'))."') {this.value='';BX.removeClass(this.parentNode,'newo_break_active');}\" type=\"text\" name=\"BREAK_SECOND_NAME\" id=\"BREAK_SECOND_NAME\" size=\"30\" value=\"".$BREAK_SECOND_NAME_TMP."\" /></div>";
				$resultHtml .= '</div>';

				$resultHtml .= '<div id="NO_BREAK_NAME"';
				if ($ORDER_ID <= 0)
					$tmpNone = ' style="display:none"';
				if ($formVarsSubmit && $_REQUEST["btnTypeBuyer"] == "btnBuyerExist")
					$tmpNone = ' style="display:block"';
				$resultHtml .= $tmpNone.'>';
			}

			$resultHtml .= '<input type="text" maxlength="250" ';
			$resultHtml .= 'size="30" ';
			$resultHtml .= 'value="'.((isset($curVal)) ? $curVal : $arProperties["DEFAULT_VALUE"]).'" ';
			$resultHtml .= 'name="ORDER_PROP_'.$arProperties["ID"].'" ';
			$resultHtml .= ($arProperties["IS_ZIP"] == "Y" ? 'class="-bx-property-is-zip" ' : '');
			$resultHtml .= 'id="ORDER_PROP_'.$arProperties["ID"].'" '.$change.'>';

			if ($arProperties["IS_PAYER"] == "Y" && intval($USER_ID) <= 0)
				$resultHtml .= '</div>';
		}
		elseif ($arProperties["TYPE"] == "SELECT")
		{
			$size = (intval($arProperties["SIZE1"]) > 0) ? intval($arProperties["SIZE1"]) : 5;

			$resultHtml .= '<select name="ORDER_PROP_'.$arProperties["ID"].'" ';
			$resultHtml .= 'id="ORDER_PROP_'.$arProperties["ID"].'" ';
			$resultHtml .= 'size='.$size.' ';
			$resultHtml .= 'class="typeselect">';
			$dbVariants = CSaleOrderPropsVariant::GetList(
				array("SORT" => "ASC"),
				array("ORDER_PROPS_ID" => $arProperties["ID"]),
				false,
				false,
				array("*")
			);
			while ($arVariants = $dbVariants->Fetch())
			{
				$resultHtml .= '<option value="'.htmlspecialcharsex($arVariants["VALUE"]).'"';
				if ($arVariants["VALUE"] == $curVal || !isset($curVal) && $arVariants["VALUE"] == $arProperties["DEFAULT_VALUE"])
					$resultHtml .= " selected";
				$resultHtml .= '>'.htmlspecialcharsEx($arVariants["NAME"]).'</option>';
			}
			$resultHtml .= '</select>';
		}
		elseif ($arProperties["TYPE"] == "MULTISELECT")
		{
			$size = (intval($arProperties["SIZE1"]) > 0) ? intval($arProperties["SIZE1"]) : 5;

			$resultHtml .= '<select multiple name="ORDER_PROP_'.$arProperties["ID"].'[]" ';
			$resultHtml .= 'id="ORDER_PROP_'.$arProperties["ID"].'" ';
			$resultHtml .= 'size='.$size.' ';
			$resultHtml .= 'class="typeselect" type="multyselect">';

			if (!is_array($curVal))
			{
				if (strlen($curVal) > 0 OR $ORDER_ID != "")
					$curVal = explode(",", $curVal);
				else
					$curVal = explode(",", $arProperties["DEFAULT_VALUE"]);

				$arCurVal = array();
				$countCurVal = count($curVal);
				for ($i = 0; $i < $countCurVal; $i++)
					$arCurVal[$i] = Trim($curVal[$i]);
			}
			else
				$arCurVal = $curVal;

			$dbVariants = CSaleOrderPropsVariant::GetList(
				array("SORT" => "ASC"),
				array("ORDER_PROPS_ID" => $arProperties["ID"]),
				false,
				false,
				array("*")
			);
			while ($arVariants = $dbVariants->Fetch())
			{
				$resultHtml .= '<option value="'.htmlspecialcharsex($arVariants["VALUE"]).'"';
				if (in_array($arVariants["VALUE"], $arCurVal))
					$resultHtml .= " selected";
				$resultHtml .= '>'.htmlspecialcharsEx($arVariants["NAME"]).'</option>';
			}
			$resultHtml .= '</select>';
		}
		elseif ($arProperties["TYPE"] == "TEXTAREA")
		{
			$resultHtml .= '<textarea ';
			$resultHtml .= 'rows="4" ';
			$resultHtml .= 'cols="40" ';
			$resultHtml .= 'name="ORDER_PROP_'.$arProperties["ID"].'" ';
			$resultHtml .= 'id="ORDER_PROP_'.$arProperties["ID"].'" type="textarea">';
			$resultHtml .= ((isset($curVal)) ? $curVal : $arProperties["DEFAULT_VALUE"]);
			$resultHtml .= '</textarea>';
		}
		elseif ($arProperties["TYPE"] == "LOCATION")
		{
			$countryID = "";
			$cityID = "";
			$cityList = "";
			$DELIVERY_LOCATION = $arPropValues[intval($arProperties["ID"])];

			$locationID = $curVal;

			$tmpLocation = '';
			ob_start();
			?>

			<?if($arProperties['IS_LOCATION'] == 'Y'):?>

				<?
				$funcId = 'changeLocationCity_'.$arProperties['ID'];
				?>

				<script>
					window['<?php 
echo $funcId;
?>
'] = function(node, info){
						fChangeLocationCity(node, info, <?php 
echo intval($location2townFldMap[$arProperties['ID']]);
?>
)
					}
					window.orderNewLocationPropId = <?php 
echo intval($arProperties['ID']);
?>
;
				</script>

			<?endif?>

			<?
			CSaleLocation::proxySaleAjaxLocationsComponent(
				array(
					"SITE_ID" => $LID,
					"AJAX_CALL" => "N",
					"COUNTRY_INPUT_NAME" => "ORDER_PROP_".$arProperties["ID"],
					"REGION_INPUT_NAME" => "REGION_ORDER_PROP_".$arProperties["ID"],
					"CITY_INPUT_NAME" => "CITY_ORDER_PROP_".$arProperties["ID"],
					"CITY_OUT_LOCATION" => "Y",
					"ALLOW_EMPTY_CITY" => "Y",
					"LOCATION_VALUE" => $curVal,
					"COUNTRY" => "",
					"ONCITYCHANGE" => "fChangeLocationCity();",
					"PUBLIC" => "N",
				),
				array(
					"JS_CALLBACK" => $arProperties['IS_LOCATION'] == 'Y' ? $funcId : false,
					"ID" => $curVal,
					"CODE" => '',
					"SHOW_DEFAULT_LOCATIONS" => 'Y',
					"JS_CONTROL_GLOBAL_ID" => intval($arProperties["ID"])
				),
				'',
				false,
				'location-selector-wrapper'
			);

			$tmpLocation = ob_get_contents();
			ob_end_clean();

			$resultHtml .= '<script>var locationID = \''.$arProperties["ID"].'\';</script>';
			$resultHtml .= $tmpLocation;
		}
		elseif ($arProperties["TYPE"] == "RADIO")
		{
			$dbVariants = CSaleOrderPropsVariant::GetList(
				array("SORT" => "ASC"),
				array("ORDER_PROPS_ID" => $arProperties["ID"]),
				false,
				false,
				array("*")
			);
			$resultHtml .= '<div id="ORDER_PROP_'.$arProperties["ID"].'" type="radio">';// type="radio"
			while ($arVariants = $dbVariants->Fetch())
			{
				$resultHtml .= '<input type="radio" class="inputradio" ';
				$resultHtml .= 'name="ORDER_PROP_'.$arProperties["ID"].'" ';
				$resultHtml .= 'value="'.htmlspecialcharsex($arVariants["VALUE"]).'"';
				if ($arVariants["VALUE"] == $curVal || !isset($curVal) && $arVariants["VALUE"] == $arProperties["DEFAULT_VALUE"])
					$resultHtml .= " checked";
				$resultHtml .= '>'.htmlspecialcharsEx($arVariants["NAME"]).'<br>';
			}
			$resultHtml .= '</div>';
		}
		elseif ($arProperties["TYPE"] == "FILE")
		{
			$arValues = array();
			$arTmpValues = array();
			if (isset($arPropValues[$arProperties["ID"]]))
			{
				$arTmpValues = explode(", ", $arPropValues[$arProperties["ID"]]);
				foreach ($arTmpValues as $key => $value)
					$arValues[$value] = $value;
			}

			$resultHtml .= fShowFilePropertyField("ORDER_PROP_".$arProperties["ID"], $arProperties, $arValues, $arProperties["SIZE1"], $formVarsSubmit);
		}

		if (strlen($arProperties["DESCRIPTION"]) > 0)
		{
			$resultHtml .= "<br><small>".htmlspecialcharsEx($arProperties["DESCRIPTION"])."</small>";
		}
		$resultHtml .= "\n</td>\n</tr>";

	}//end while

	$resultHtml .= "<tr>\n<td valign=\"top\" class=\"adm-detail-content-cell-l\">".GetMessage("SOE_BUYER_COMMENT").":
			</td>
			<td class=\"adm-detail-content-cell-r\">
				<textarea name=\"USER_DESCRIPTION\" rows=\"4\" cols=\"40\">".htmlspecialcharsbx($userComment)."</textarea>
			</td>
		</tr>";

	$resultHtml .= "</table>";
	return $resultHtml;
}
Ejemplo n.º 3
0
						array(
							"ORDER_ID" => $ID,
							"PERSON_TYPE_ID" => $arPersonType["ID"],
							"ACTIVE" => "Y",
							">INPUT_FIELD_LOCATION" => 0
						),
						false,
						false,
						array("INPUT_FIELD_LOCATION")
					);
					while ($arProperties = $dbProperties->Fetch())
						$arTownOrderProps[$arProperties["INPUT_FIELD_LOCATION"]] = $arProperties["INPUT_FIELD_LOCATION"];

					$arEnableTownProps = array();
					$arOrderPropsValue = array();
					$dbOrderProps = CSaleOrderPropsValue::GetOrderProps($ID);
					while ($arOrderProps = $dbOrderProps->Fetch())
					{
						$arOrderPropsValue[] = $arOrderProps;
						if ($arOrderProps["TYPE"] == "LOCATION" && $arOrderProps["ACTIVE"] == "Y" && $arOrderProps["IS_LOCATION"] == "Y" && in_array($arOrderProps["INPUT_FIELD_LOCATION"], $arTownOrderProps))
						{
							if(CSaleLocation::isLocationProMigrated())
							{
								$arEnableTownProps[$arOrderProps["INPUT_FIELD_LOCATION"]] = CSaleLocation::checkLocationIsAboveCity($arOrderProps["VALUE"]);
							}
							else
							{
								$arLocation = CSaleLocation::GetByID($arOrderProps["VALUE"]);
								if (IntVal($arLocation["CITY_ID"]) <= 0)
									$arEnableTownProps[$arOrderProps["INPUT_FIELD_LOCATION"]] = true;
								else
Ejemplo n.º 4
0
/**
 * событие вызывается перед отправкой письма о новом заказе
 * @param $orderID
 * @param $eventName
 * @param $arFields
 */
function bxModifySaleMails($order_id, &$eventName, &$arFieldsEmail)
{
                                             
    //unset($_SESSION['OnBeforeOrderAddHandler']);
    //$_SESSION['OnBeforeOrderAddHandler']['bxModifySaleMails']='bxModifySaleMails';
    //$_SESSION['OnBeforeOrderAddHandler']['id']=$order_id;
    //$_SESSION['OnBeforeOrderAddHandler']['arFields']=$arFieldsorder_old;
    $basket_props="";
    $post['INFO']="";
    $id_product=array();
    if(
        (CModule::IncludeModule("main"))
        &&
        (CModule::IncludeModule("iblock"))
        &&
        (CModule::IncludeModule("catalog"))
        &&
        (CModule::IncludeModule("sale"))
    ){


        /**
         * получаем параметры сформировавшегося старого заказа
         */
        $arFieldsorder_old = CSaleOrder::GetByID($order_id);
        /*
        echo "<pre>";
        var_dump($arFieldsorder_old);die();
        echo "</pre>";*/
        /**
         * выборка свойства сформировавшегося заказа по id заказа
         */
        $db_props = CSaleOrderPropsValue::GetOrderProps($order_id);
        $arFields_props = array();

        while ($arProps = $db_props->Fetch())
        {
            $arFields_props_old[$arProps['CODE']]=$arProps;

        }
        //_debug($arFields_props_old);

        /**
         * выборка из корзины по id заказа
         * получаем масси id продукта
         */
         
         $rsUser = CUser::GetByID(CUser::GetID());
         $arUser = $rsUser->Fetch();
         /*if (!$ORDER_ID = CSaleOrder::Add(array(
                                        "LID"              => SITE_ID,
                                        "PERSON_TYPE_ID"   => 1,
                                        "PAYED"            => "N",
                                        "CANCELED"         => "N",
                                        "STATUS_ID"        => "N",
                                        "PRICE"            => 0,
                                        "CURRENCY"         => CSaleLang::GetLangCurrency(SITE_ID),
                                        "USER_ID"          => $arUser['ID'],
                                        "PAY_SYSTEM_ID"    => $arFieldsorder_old['PAY_SYSTEM_ID'],
                                        "PRICE_DELIVERY"   => 0,
                                        "DELIVERY_ID"      => $arFieldsorder_old['DELIVERY_ID'],
                                        "DISCOUNT_VALUE"   => $arFieldsorder_old['DISCOUNT_VALUE'],
                                        "TAX_VALUE"        => $arFieldsorder_old['TAX_VALUE'],
                                        "USER_DESCRIPTION" => $post['INFO']
         ))){

                                        $rows['msg'] = 'Ошибка создания заказа';
                                        $fail          = true;
        }else{
                                        $rows['msg']=$ORDER_ID;
                                        //continue;
        }*/

        $dbBasketItems = CSaleBasket::GetList(
            array("ID" => "ASC"),
            array(
                "LID" => SITE_ID,
                "ORDER_ID" => $order_id
            ),
            false,
            false,
            array()
        );
        while ($arItem = $dbBasketItems->Fetch()){
            $id_product[] = $arItem['PRODUCT_ID'];
            $products_basket[$arItem['PRODUCT_ID']]=$arItem;
        }
        
        foreach($products_basket as $product){
            $price_product+=$product['PRICE']*$product['QUANTITY'];
            $products_descriptions.=$product['NAME']." - ".$product['QUANTITY']." шт: ".intval($product['PRICE'])." руб <br/>";
        
        }
        $price_product+=$arFieldsorder_old["PRICE_DELIVERY"];
        //$_SESSION['OnBeforeOrderAddHandler']['products_basket']=$products_basket;

        /**
         * получаем массив id партнеров из продукта
         */
        //var_dump($id_product);die();         

        if($id_product){
            $id_partner=array();
            $partner_product=array();
            $arSelect = Array("ID", "NAME","IBLOCK_ID","PROPERTY_PARTNER");
            $arFilter = Array("ID"=>$id_product, "ACTIVE"=>"Y");
            $res = CIBlockElement::GetList(Array(), $arFilter, false, false, $arSelect);
            
            while($ob = $res->GetNextElement())
            {
                $arFields = $ob->GetFields();
                $partner_product[$arFields['PROPERTY_PARTNER_VALUE']][]=$products_basket[$arFields['ID']];
                if($arFields['PROPERTY_PARTNER_VALUE']){
                    $id_partner[]=$arFields['PROPERTY_PARTNER_VALUE'];
                }
            }
            //$_SESSION['OnBeforeOrderAddHandler']['id_partner']=$id_partner;

            /**
             * получаем массив данных партнера
             */
         
            if($id_partner){
                            
                            
                $delivery_sum = null;
                $arSelect2 = Array("ID", "IBLOCK_ID", "NAME","PROPERTY_*");
                $arFilter2 = Array("IBLOCK_ID"=>9, "ACTIVE"=>"Y","ID"=>$id_partner,);
                $res2 = CIBlockElement::GetList(Array(), $arFilter2, false, false, $arSelect2);
                /**
                 * eсли в выборке корзине в продуктах больше чем один партнер
                 * то разбиваем заказ по количеству партнеров
                 */
                if (intval($res2->SelectedRowsCount())>0){
                    while($ob2 = $res2->GetNextElement()){
                        $arFields_partners = $ob2->GetFields();
                        $arProperties_partners = $ob2->GetProperties();
                        //_debug($arProperties_partners);
                        //$price_product=0;
                        //$products_descriptions="";
                        $arEventFields=array();
                        //echo $arFields_partners['ID'];
                        
                        
                        if($partner_product[$arFields_partners['ID']]){

                            $i=0;
                            $size_of_productpartner=sizeof($partner_product[$arFields_partners['ID']]);
                            foreach($partner_product[$arFields_partners['ID']] as $key_price=>$item_price){
                                //_debug($item_price);
                                $quantity=1;
                                /**
                                 * формируем новый пустой заказ
                                 */
                                if(!$i){


                                    if (!$ORDER_ID = CSaleOrder::Add(array(
                                        "LID"              => SITE_ID,
                                        "PERSON_TYPE_ID"   => 1,
                                        "PAYED"            => "N",
                                        "CANCELED"         => "N",
                                        "STATUS_ID"        => "N",
                                        "PRICE"            => 0,
                                        "CURRENCY"         => CSaleLang::GetLangCurrency(SITE_ID),
                                        "USER_ID"          => $arUser['ID'],
                                        "PAY_SYSTEM_ID"    => $arFieldsorder_old['PAY_SYSTEM_ID'],
                                        "PRICE_DELIVERY"   => 0,
                                        "DELIVERY_ID"      => $arFieldsorder_old['DELIVERY_ID'],
                                        "DISCOUNT_VALUE"   => $arFieldsorder_old['DISCOUNT_VALUE'],
                                        "TAX_VALUE"        => $arFieldsorder_old['TAX_VALUE'],
                                        "USER_DESCRIPTION" => $post['INFO']
                                    ))){

                                        $rows['msg'] = 'Ошибка создания заказа';
                                        $fail          = true;
                                    }else{
                                        $rows['msg']=$ORDER_ID;
                                        //continue;
                                    }
                                }

                                /**
                                 * добавляем по id заказа в корзину товары партнера
                                 */
                                if (!Add2BasketByProductID($item_price['PRODUCT_ID'], $item_price['QUANTITY'], array(
                                    'ORDER_ID' => $ORDER_ID,
                                ), $basket_props)) {
                                    $rows['err'] = 'Ошибка добавления товара в заказ';
                                    $fail          = true;
                                }

                                /*$price_product+=$item_price['PRICE']*$item_price['QUANTITY'];
                                $products_descriptions.=$item_price['NAME']." - ".$item_price['QUANTITY']." шт: ".intval($item_price['PRICE'])." руб <br/>";
                                */


                                $i++;
                                /**
                                 * обновляем параметры нового заказа на актуальные
                                 */
                                if($size_of_productpartner==$i){
                                    if (!$fail) {
                                        $dbBasketItems = CSaleBasket::GetList(
                                            array("NAME" => "ASC", "ID" => "ASC"), array(
                                                "LID"      => SITE_ID,
                                                "ORDER_ID" => $ORDER_ID
                                            ), false, false, array(
                                                "ID", "NAME", "QUANTITY", "CURRENCY", "CAN_BUY", "PRICE", "WEIGHT", "DISCOUNT_PRICE"
                                            )
                                        );

                                        $summ          = $weight        = 0;
                                        $strOrderList  = "";


                                        $arBasket      = array();
                                        while ($arBasketItems = $dbBasketItems->GetNext()) {
                                            $strOrderList .= $arBasketItems["NAME"] . " - " . $arBasketItems["QUANTITY"] . " шт на " . SaleFormatCurrency($arBasketItems["PRICE"] * $arBasketItems["QUANTITY"], $arBasketItems["CURRENCY"]);
                                            $strOrderList .= "\n";
                                            $rows['summ']=$summ += roundEx($arBasketItems["PRICE"], SALE_VALUE_PRECISION) * DoubleVal($arBasketItems["QUANTITY"]);
                                            $weight += doubleval($arBasketItems['WEIGHT']);
                                            $arBasket[] = $arBasketItems;
                                        }
                                        $arOrderForDiscount = array(
                                            'SITE_ID'      => SITE_ID,
                                            'USER_ID'      => $arUser['ID'],
                                            'ORDER_PRICE'  => $summ,
                                            'ORDER_WEIGHT' => $weight,
                                            'BASKET_ITEMS' => $arBasket,
                                        );
                                        $arDiscountOptions  = array();
                                        $arDiscountErrors   = array();
                                        CSaleDiscount::DoProcessOrder($arOrderForDiscount, $arDiscountOptions, $arDiscountErrors);
                                        if($_REQUEST['comment'])
                                            $arOrderForDiscount['COMMENTS'] = $_REQUEST['comment'];
                                        if($arProperties_partners['DOSTAVKA']['VALUE']){
                                            $arOrderForDiscount["PRICE_DELIVERY"] = $arProperties_partners['DOSTAVKA']['VALUE'];
                                            $arOrderForDiscount["DELIVERY_ID"] = 3;
                                            $summ += intval($arProperties_partners['DOSTAVKA']['VALUE']);
                                            $arOrderForDiscount['ORDER_PRICE']=$summ;
                                        }
                                        $arOrderForDiscount['PRICE_BEFORE'] = $summ;
                                        $arOrderForDiscount['PRICE']        = $summ;
                                        $arOrderForDiscount['WEIGHT']       = $arOrderForDiscount['ORDER_WEIGHT'];
                                        /**
                                         * обновляем заказ
                                         */
                                        if (!CSaleOrder::Update($ORDER_ID, $arOrderForDiscount)) {
                                            $rows['err'] = 'Ошибка расчета цены заказа.';
                                            $fail          = true;
                                        }else{

                                            /**
                                             * перезагружаем свойства заказ из старого
                                             */
                                            $db_props_new = CSaleOrderPropsValue::GetOrderProps($ORDER_ID);
                                            $arFields_props_new = array();
                                            while ($arProps_new = $db_props_new->Fetch())
                                            {
                                                //_debug($arProps_new);
                                                foreach($arFields_props_old as $key_props_old=>$item_props_old){
                                                    if($arProps_new['CODE']==$key_props_old){
                                                        CSaleOrderPropsValue::Update($arProps_new['ID'], array("VALUE"=>$item_props_old['VALUE']));
                                                        unset($arFields_props_old[$key_props_old]);
                                                    }
                                                }

                                            }
                                            if(sizeof($arFields_props_old)>0){
                                                foreach($arFields_props_old as $key_props_old2=>$item_props_old2){
                                                    CSaleOrderPropsValue::Add(array(
                                                        'NAME'           => $item_props_old2['NAME'],
                                                        'CODE'           => $item_props_old2['CODE'],
                                                        'ORDER_PROPS_ID' => $item_props_old2['ORDER_PROPS_ID'],
                                                        'ORDER_ID'       => $ORDER_ID,
                                                        'VALUE'          => $item_props_old2['VALUE']
                                                    ));
                                                }
                                            }
                                            /**
                                             * добавляем в свойство заказа id партнера для дальнейшей фильтрации по партнерским заказам
                                             */
                                            CSaleOrderPropsValue::Add(array(
                                                'NAME'           => "Привязка по партнеру",
                                                'CODE'           => "PATNERID",
                                                'ORDER_PROPS_ID' => 21,
                                                'ORDER_ID'       => $ORDER_ID,
                                                'VALUE'          => $arFields_partners['ID']
                                            ));


                                            //$price_product+=$arProperties_partners['DOSTAVKA']['VALUE'];
                                            //$price_product+=$arFieldsorder_old["PRICE_DELIVERY"];
                                            /**
                                             * отправляем данные о товаре Партнерам
                                             */
           
                                            if($arFields_partners['NAME']){  //если есть партнер у товара                              
                                                $arEventFields = Array(
                                                    "ORDER_ID"=> $ORDER_ID,
                                                    "ORDER_DATE"=> date("d.m.Y H:i:s"),
                                                    "ORDER_USER"=> $arFields_partners['NAME'],
                                                    "PRICE"=> $price_product,
                                                    "EMAIL"=> $arProperties_partners['EMAIL']['VALUE'],
                                                    "ORDER_LIST"=> $products_descriptions,
                                                    //"DELIVERY_PRICE"=>$arProperties_partners['DOSTAVKA']['VALUE']
                                                    "DELIVERY_PRICE"=>$arFieldsorder_old["PRICE_DELIVERY"]
                                                );
                                                $event = new CEvent;
                                                $event->SendImmediate("SALE_NEW_ORDERPARTNER", SITE_ID, $arEventFields);
                                            }
                                            
                                            
                                        }
                                    }
                                    //                        if(!$fail){
                                    //                            $ar_res_product=CCatalogProduct::GetByID($PRODUCT['ID']);
                                    //                            $arFields_quant = array(
                                    //                                'QUANTITY' => $ar_res_product['QUANTITY']-1
                                    //                            );
                                    //                            CCatalogProduct::Update($PRODUCT['ID'], $arFields_quant);
                                    //                        }

                                }

                            }
                        }
                    }
                    /**
                     * удаляем старый заказ после разбивки на новые
                     */
                    if($ORDER_ID ){
                        CSaleOrder::Delete($order_id);
                    }
                }
            }
            
            
            $arEventFields = Array(
                "ORDER_ID" =>$order_id,
                "ORDER_DATE" =>date("d.m.Y H:i:s"),
                "ORDER_USER" =>$arUser['NAME'],
                "PRICE" =>$price_product,
                "EMAIL" => $arUser['EMAIL'],
                "ORDER_LIST" =>$products_descriptions,
                "DELIVERY_PRICE"=>$arFieldsorder_old["PRICE_DELIVERY"]
            );
            $event = new CEvent;
            $event->SendImmediate("SALE_NEW_BILET", SITE_ID, $arEventFields); 
            
            
        }
    }
    //$_SESSION['OnBeforeOrderAddHandler']['rows']=$rows;
    return false;

}
Ejemplo n.º 5
0
 private function getOrderProps($arOrder)
 {
     $dbOrderProps = CSaleOrderPropsValue::GetOrderProps($arOrder["ID"]);
     $orderPropsCodes = array("FIO", "EMAIL", "PHONE", "ZIP", "CITY", "ADDRESS");
     while ($arOrderProps = $dbOrderProps->GetNext()) {
         $arOrder["PROPS"][] = $arOrderProps;
         if (in_array($arOrderProps["CODE"], $orderPropsCodes)) {
             $idx = "CUSTOMER_" . $arOrderProps["CODE"];
             $arOrder[$idx] = $arOrderProps["VALUE"];
         }
         if ($arOrderProps["TYPE"] == "LOCATION") {
             $arVal = CSaleLocation::GetByID($arOrderProps["VALUE"], LANG);
             if (strlen($arOrderProps["CODE"]) > 0) {
                 $arOrder["CUSTOMER_LOCATION"] = htmlspecialcharsEx($arVal["COUNTRY_NAME"] . (strlen($arVal["COUNTRY_NAME"]) <= 0 || strlen($arVal["CITY_NAME"]) <= 0 ? "" : " - ") . $arVal["CITY_NAME"]);
             } else {
                 $arOrder["CUSTOMER_LOCATION"] = htmlspecialcharsEx($arVal["COUNTRY_NAME"] . (strlen($arVal["COUNTRY_NAME"]) <= 0 || strlen($arVal["CITY_NAME"]) <= 0 ? "" : " - ") . $arVal["CITY_NAME"]);
             }
         }
     }
     return $arOrder;
 }
Ejemplo n.º 6
0
 protected static function getPhoneEmail($orderId)
 {
     $result = array("EMAIL" => "", "PHONE" => "");
     $dbOrderProps = \CSaleOrderPropsValue::GetOrderProps($orderId);
     while ($arOrderProps = $dbOrderProps->Fetch()) {
         if ($arOrderProps["CODE"] == "EMAIL") {
             $result["EMAIL"] = $arOrderProps["VALUE"];
         }
         if ($arOrderProps["CODE"] == "PHONE") {
             $result["PHONE"] = $arOrderProps["VALUE"];
         }
     }
     return $result;
 }
Ejemplo n.º 7
0
	$row->AddField("BASKET_QUANTITY", $fieldQuantity);
	$row->AddField("BASKET_PRODUCT_ID", $fieldProductID);
	$row->AddField("BASKET_PRICE", $fieldPrice);
	$row->AddField("BASKET_WEIGHT", $fieldWeight);
	$row->AddField("BASKET_NOTES", $fieldNotes);
	$row->AddField("BASKET_DISCOUNT_PRICE", $fieldDiscountPrice);
	$row->AddField("BASKET_CATALOG_XML_ID", $fieldCatalogXML);
	$row->AddField("BASKET_PRODUCT_XML_ID", $fieldProductXML);
	$row->AddField("BASKET_DISCOUNT_NAME", $fieldDiscountName);
	$row->AddField("BASKET_DISCOUNT_VALUE", $fieldDiscountValue);
	$row->AddField("BASKET_DISCOUNT_COUPON", $fieldDiscountCoupon);
	$row->AddField("BASKET_VAT_RATE", $fieldVatRate);

	if ($bNeedProps)
	{
		$dbProps = CSaleOrderPropsValue::GetOrderProps($arOrder["ID"]);
		while ($arProps = $dbProps->GetNext())
		{
			if (array_key_exists($arProps["ORDER_PROPS_ID"], $arOrderProps) || array_key_exists($arProps["CODE"], $arOrderPropsCode))
			{
				if($arProps["TYPE"] == "MULTISELECT" || $arProps["TYPE"] == "SELECT" || $arProps["TYPE"] == "RADIO")
				{
					if($arProps["TYPE"] == "MULTISELECT")
					{
						$valMulti = "";
						$curVal = explode(",", $arProps["VALUE"]);
						$bNeedLine = false;
						foreach ($curVal as $val)
						{
							if ($bNeedLine)
								$valMulti .= "<hr size=\"1\" width=\"90%\">";
Ejemplo n.º 8
0
	public function formAndSendDataToGP($type, $options = array(), $arFields) {
		$ID = intVal($options['ID']);
		if ($ID) {
			CModule::IncludeModule('sale');
			$order = CSaleOrder::GetList(array(), array("ID" => $ID), false, false, array("MARKED", "PERSON_TYPE_ID"))->Fetch();
			if ($order['MARKED'] == 'Y') { $order_is_marked = true; } else { $order_is_marked = false; }
			
			if ($arFields['PERSON_TYPE_ID'] > 0) {
				$person_type_id = $arFields['PERSON_TYPE_ID'];
			} elseif ($order['PERSON_TYPE_ID'] > 0) {
				$person_type_id = $order['PERSON_TYPE_ID'];
			}
			
			if ($person_type_id) {
				// get $_POST keys for needed parameters from module options
				/*$keys_list = array(
					'customer_name', 'customer_phone', 'customer_email', 'delivery_address', 'location', 'city',
					'GP_PHONE_ADDITIONAL', 'GP_FLOOR', 'GP_ENTRY', 'GP_INTERCOM_CODE', 'GP_ORDER_ID'
				);*/
                $keys_list = array(
                    'customer_name', 
                    'customer_email', 
                    'customer_phone', 
                    'delivery_city', 
                    'delivery_alt_city',  
                    'delivery_address', 
                    'delivery_address_street', 
                    'delivery_address_house', 
                    'delivery_address_building', 
                    'delivery_address_housing', 
                    'delivery_address_apartment', 
                    'customer_second_phone',  
                    'floor', 
                    'porch', 
                    'intercom_code', 
                    'comments', 
                    //'system_choosen',
                    'gp_order_id_0'
                );
                foreach ($keys_list as $key) {
					$post_key[$key] = COption::GetOptionString(self::$MODULE_ID, 'match_id_'.$person_type_id.'_'.$key);
				}
				$filename = $_SERVER['DOCUMENT_ROOT'] . '/templog.log';
				file_put_contents($filename, var_export($post_key, true), FILE_APPEND | LOCK_EX);
				file_put_contents($filename, var_export($_POST, true), FILE_APPEND | LOCK_EX);
                
                $arOrder = CSaleOrder::GetByID($ID);
                
                if($options["ACTION"] == "ORDER"){
                    //var_dump($arOrder["ACCOUNT_NUMBER"]);die();
                
                    $db_props = CSaleOrderPropsValue::GetOrderProps($ID);
                    $arFields_props = array();
                            
                    while ($arProps = $db_props->Fetch())
                    {
                        $_POST["ORDER_PROP_".$arProps["ORDER_PROPS_ID"]]=$arProps["VALUE"];
                    }
                    $_POST['PAY_SYSTEM_ID'] = $arOrder["PAY_SYSTEM_ID"];
                    
                    $_POST[$post_key['comments']] = $arOrder["USER_DESCRIPTION"];
                }
                
				// get city for delivery_address
				/*if ($_POST[$post_key['delivery_city']]) {
					$city_name = $_POST[$post_key['delivery_city']] . ' ';
				} else*/
                
                if ($_POST[$post_key['delivery_city']] || $_POST['CITY_'.$post_key['delivery_city']]) {
					if ($_POST[$post_key['delivery_city']]) {
						$city_id = $_POST[$post_key['delivery_city']];
					} else {
						$city_id = $_POST['CITY_'.$post_key['delivery_city']];
					}
					$cityRes = CSaleLocation::GetList(
						array(), array("LID" => LANGUAGE_ID, "ID" => $city_id), false, array("nTopCount" => 1), array('CITY_NAME')
					);
					if ($cityAr = $cityRes->Fetch()) {
						$city_name = $cityAr['CITY_NAME'] . ' ';
					} else {
						$city_name = '';
					}
				}
                
                if($_POST[$post_key['delivery_alt_city']]){
                    $city_name = $_POST[$post_key['delivery_alt_city']];
                }
				
				// set parameters
                if($_POST[$post_key['customer_name']]){
	               $post_data['order']['customer_name'] = $_POST[$post_key['customer_name']];
                }
                if($_POST[$post_key['customer_email']]){
	               $post_data['order']['customer_email'] = $_POST[$post_key['customer_email']];
                }elseif($_POST["NEW_BUYER_EMAIL"]){
                    $post_data['order']['customer_email'] = $_POST["NEW_BUYER_EMAIL"];
                }else{
                    //get email from id
                    if($_POST["user_id"]){
                        $user_id = $_POST["user_id"];
                    }else{
                        $user_id = $arOrder["USER_ID"];
                    }
                    $rsUser = CUser::GetByID($user_id);
                    $arUser = $rsUser->Fetch();
                    if($arUser["EMAIL"]){
	                   $post_data['order']['customer_email'] = $arUser["EMAIL"];
                    }
                }
                
                //var_dump($_POST);die();
                
                if($_POST[$post_key['customer_phone']]){
	               $post_data['order']['customer_phone'] = $_POST[$post_key['customer_phone']];
                }
                if($city_name){
	               $post_data['order']['delivery_city'] = $city_name;
                }
                if($_POST[$post_key['delivery_address']] && $_POST[$post_key['delivery_address_street']]){
                    $post_data['order']['delivery_address'] = $_POST[$post_key['delivery_address']].", ".$_POST[$post_key['delivery_address_street']];
				}
                if($_POST[$post_key['delivery_address']] && !$_POST[$post_key['delivery_address_street']]){
                    $post_data['order']['delivery_address'] = $_POST[$post_key['delivery_address']];
				}
                if(!$_POST[$post_key['delivery_address']] && $_POST[$post_key['delivery_address_street']]){
                    $post_data['order']['delivery_address'] = $_POST[$post_key['delivery_address_street']];
				}
                if($_POST[$post_key['delivery_address_house']]){
	               $post_data['order']['delivery_address_house'] = $_POST[$post_key['delivery_address_house']];
                }
                if($_POST[$post_key['delivery_address_building']]){
	               $post_data['order']['delivery_address_building'] = $_POST[$post_key['delivery_address_building']];
                }
                if($_POST[$post_key['delivery_address_housing']]){
	               $post_data['order']['delivery_address_housing'] = $_POST[$post_key['delivery_address_housing']];
                }
                if($_POST[$post_key['delivery_address_apartment']]){
	               $post_data['order']['delivery_address_apartment'] = $_POST[$post_key['delivery_address_apartment']];
                }
                if($_POST[$post_key['customer_second_phone']]){
	               $post_data['order']['customer_second_phone'] = $_POST[$post_key['customer_second_phone']];
                }
                if($_POST[$post_key['floor']]){
	               $post_data['order']['floor'] = $_POST[$post_key['floor']];
                }
                if($_POST[$post_key['porch']]){
	               $post_data['order']['porch'] = $_POST[$post_key['porch']];
                }
                if($_POST[$post_key['intercom_code']]){
	               $post_data['order']['intercom_code'] = $_POST[$post_key['intercom_code']];
                }
                if($_POST[$post_key['comments']]){
	               $post_data['order']['comments'] = $_POST[$post_key['comments']];
                }
                
				//$post_data['order']['comments'] =  $_POST['USER_DESCRIPTION'];
				$post_data['api_auth_token'] = COption::GetOptionString(self::$MODULE_ID, 'secret_key');
				if (isset($options['widget_token']) && $options['widget_token']) { $post_data['order']['widget_token'] = $options['widget_token']; }
				$post_data['order']['widget_token'] = $_POST['widget_token'];
				//$post_data['order']['shop_order_code'] = $ID;
                $post_data['order']['shop_order_code'] = $arOrder["ACCOUNT_NUMBER"];
				//$post_data['order']['customer_name'] = $_POST[$post_key['customer_name']] ? $_POST[$post_key['customer_name']] : ($arFields['ORDER_USER'] ? $arFields['ORDER_USER'] : '');
				//$post_data['order']['customer_phone'] = $_POST[$post_key['customer_phone']];
				//$post_data['order']['customer_email'] = $_POST[$post_key['customer_email']];
				//$post_data['order']['delivery_address'] = $city_name . $_POST[$post_key['delivery_address']];
				//if ($_POST[$post_key['GP_PHONE_ADDITIONAL']]) { $post_data['order']['customer_second_phone'] = $_POST[$post_key['GP_PHONE_ADDITIONAL']]; }
				//if (intVal($_POST[$post_key['GP_FLOOR']])) { $post_data['order']['floor'] = intVal($_POST[$post_key['GP_FLOOR']]); }
				//if ($_POST[$post_key['GP_ENTRY']]) { $post_data['order']['porch'] = $_POST[$post_key['GP_ENTRY']]; }
				//if ($_POST[$post_key['GP_INTERCOM_CODE']]) { $post_data['order']['intercom_code'] = $_POST[$post_key['GP_INTERCOM_CODE']]; }

				$post_data['order']['payment_type'] = COption::GetOptionString(self::$MODULE_ID, 'paysystem_match_'.intVal($_POST['PAY_SYSTEM_ID']));
				
				// set products list for parameters
				if (!isset($_POST['PRODUCT']) || empty($_POST['PRODUCT'])) {
					$products = array();
					$productRes = CSaleBasket::GetList(
						array(), array("ORDER_ID" => $ID), false, false, array('PRODUCT_ID', 'PRICE_DEFAULT', 'PRICE', 'QUANTITY', 'WEIGHT', 'NAME')
					);
					while ($productAr = $productRes->Fetch()) {
						$products[] = $productAr;
					}
				} else {
					$products = $_POST['PRODUCT'];
				}
				
				// set products list parameters
				$cell = 0;
				foreach ($products as $arProduct) {
					// $post_data['order']['good_attributes'][$cell]['size'] = 'medium';
					$post_data['order']['good_attributes'][$cell]['shop_good_code'] = $arProduct['PRODUCT_ID'];
					$post_data['order']['good_attributes'][$cell]['estimated_price'] = $arProduct['PRICE_DEFAULT'];
					$post_data['order']['good_attributes'][$cell]['price'] = $arProduct['PRICE'];
					$post_data['order']['good_attributes'][$cell]['count'] = $arProduct['QUANTITY'];
					$post_data['order']['good_attributes'][$cell]['weight'] = $arProduct['WEIGHT'];
					$post_data['order']['good_attributes'][$cell]['name'] = $arProduct['NAME'];
					$cell++;
				}
			}
		}
		
		// send data to GP server
		if ($options["URL"]) {
		  
		    $arConfig = self::$CONFIG;
            
			$stop_send = false;
			$ch = curl_init();
			
			if (intVal($_POST[$post_key['gp_order_id']]) == 0) {
				$type = "POST";
				//$options["URL"] = COption::GetOptionString(self::$MODULE_ID, 'POST_url');
                $options["URL"] = COption::GetOptionString(self::$MODULE_ID, 'gp_script_url') . $arConfig["POST_URL"];
			}
			
			if ($type == "POST" && !empty($post_data['widget_token'])) {
				$post_data['with_draft'] = true;
			}elseif($type == "POST" && empty($post_data['widget_token'])){
			    $post_data['with_draft'] = false;
			}
			
			// set data for sending to GP server
			$send_data = json_encode($post_data);
            
            			
			if ($type == "POST") {
				curl_setopt($ch, CURLOPT_POST, true);
			} elseif ($type == "PATCH") {
				curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
			} else {
				$stop_send = true;
			}
			curl_setopt($ch, CURLOPT_URL, $options["URL"]);
			curl_setopt($ch, CURLOPT_POSTFIELDS, $send_data);
			curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8'));
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
			if (!$stop_send) {
				$result = json_decode(curl_exec($ch), true);
			}
			curl_close($ch);
            
			if (is_array($result['error_message']) && count($result['error_message']) == 1) {
				$comment = implode("\r\n", $result['error_message']);
                
                $comment = CGPWidget::Translate($comment);
                
				CSaleOrder::SetMark($ID, $comment);
			} elseif (is_array($result['error_message']) && count($result['error_message']) > 1) {
				$comment = $result['error_message'];
                $ar_comment = "";
                
                foreach($comment as $com){
                    $ar_comment .= CGPWidget::Translate($com).". ";
                }
                
				CSaleOrder::SetMark($ID, $ar_comment);
                
			} elseif ($result) {
				if ($order_is_marked) {
					CSaleOrder::UnsetMark($ID);
				}
				if (intVal($_POST[$post_key['gp_order_id_0']]) == 0 && $result['id']/* && intVal($_POST[$post_key['gp_order_id']]) != $result['id']*/) {
					// $_POST[$post_key['gp_order_id']] = $result['id'];
					if ($gp_order_id_prop_id = intVal(str_replace("ORDER_PROP_", "", $post_key['gp_order_id_0']))) {
						$gp_order_id_res = CSaleOrderPropsValue::GetList(array(), array("ORDER_ID" => $ID, "ORDER_PROPS_ID" => $gp_order_id_prop_id));
						if ($gp_order_id_ar = $gp_order_id_res->Fetch()) {
							$gp_order_id_prop_value_id = $gp_order_id_ar['ID'];
							if ($gp_order_id_prop_value_id) {
								$gp_order_id_add_result = CSaleOrderPropsValue::Update($gp_order_id_prop_value_id, array("ORDER_ID" => $ID, "VALUE" => $result['id']));
							}
						} else {
							$gp_order_id_prop_res = CSaleOrderProps::GetList(array(), array("ID" => $gp_order_id_prop_id));
							if ($gp_order_id_prop_ar = $gp_order_id_prop_res->Fetch()) {
								$gp_order_id_add_result = CSaleOrderPropsValue::Add(array("ORDER_ID" => $ID, "ORDER_PROPS_ID" => $gp_order_id_prop_id, "VALUE" => $result['id'], "NAME" => $gp_order_id_prop_ar['NAME'], "CODE" => $gp_order_id_prop_ar['CODE']));
							}
						}
					}
				}
			}
            /*
            echo "<pre>";
            var_dump($_POST);
            
            var_dump($post_data);
            
            var_dump($result);
            echo "</pre>";
            die();*/
		}

		// log everything
		$filename = $_SERVER['DOCUMENT_ROOT'] . '/templog.log';
		$data = array($type, date('d.m.Y h:i:s'), "ORDER" => $ID, "URL" => $options["URL"], "SEND" => $send_data, "RESULT" => $result, "ARFIELDS" => $arFields);
		// $data = array($type, date('d.m.Y h:i:s'), "ORDER" => $ID, "URL" => $options["URL"], "SEND" => $send_data, "gpid" => array('add' => $m, 'res' => $gp_order_id_add_result, '1' => array($gp_order_id_prop_value_id, array("ORDER_ID" => $ID, "VALUE" => $result['id'])),  'ar' => $gp_order_id_ar, 'val' => $gp_order_id_prop_value_id, 'post_gpoid' => $result['id'], "ORDER_ID" => $ID, 'ORDER_PROPS_ID' => str_replace("ORDER_PROP_", "", $post_key['gp_order_id'])), array($_POST[$post_key['gp_order_id']], $post_key['gp_order_id']), "RESULT" => $result);
		// $data = array($type, date('d.m.Y h:i:s'), $ID, $send_data, $result, $city_name, $city_id, $post_key, $_POST);
		file_put_contents($filename, var_export($data, true), FILE_APPEND | LOCK_EX);
	}
Ejemplo n.º 9
0
         }
     }
     if (strlen($PRODUCT_XML_ID) <= 0) {
         $PRODUCT_XML_ID = $arBasket["PRODUCT_ID"];
     }
     echo "\t\t\t<" . GetMessage("Article") . " " . GetMessage("Catalog") . "=\"" . $CATALOG_XML_ID . "\" " . GetMessage("Product") . "=\"" . $PRODUCT_XML_ID . "\" " . GetMessage("Unit") . "=\"\" " . GetMessage("Amount") . "=\"" . $arBasket["QUANTITY"] . "\" " . GetMessage("Price") . "=\"" . $arBasket["PRICE"] . "\" " . GetMessage("Sum") . "=\"" . DoubleVal($arBasket["PRICE"]) * IntVal($arBasket["QUANTITY"]) . "\" " . GetMessage("Description") . "=\"" . htmlspecialcharsbx($arBasket["NAME"]) . "\"/>\n";
 }
 echo "\t\t</" . GetMessage("Document") . ">\n";
 if (!in_array("BC" . $f_USER_ID, $arContra)) {
     $arContra[] = "BC" . $f_USER_ID;
     $db_user = CUser::GetByID($f_USER_ID);
     $arUser = $db_user->Fetch();
     $contra_mail = "";
     $contra_name = $arUser["NAME"] . " " . $arUser["LAST_NAME"];
     $contra_other = "";
     $db_props = CSaleOrderPropsValue::GetOrderProps($f_ID);
     while ($arProps = $db_props->Fetch()) {
         if ($arProps["IS_EMAIL"] == "Y") {
             $contra_mail = $arProps["VALUE"];
         }
         if ($arProps["IS_PAYER"] == "Y") {
             $contra_name = $arProps["VALUE"];
         }
         if ($arProps["TYPE"] == "LOCATION") {
             $arLocs = CSaleLocation::GetByID($arProps["VALUE"], LANG);
             $contra_other .= $arProps["PROPERTY_NAME"] . "=" . $arLocs["COUNTRY_NAME"] . " - " . $arLocs["CITY_NAME"];
         } else {
             $contra_other .= $arProps["PROPERTY_NAME"] . "=" . $arProps["VALUE"];
         }
         $contra_other .= " // ";
     }
Ejemplo n.º 10
0
function fGetBuyerType($PERSON_TYPE_ID, $LID, $USER_ID = '', $ORDER_ID = 0, $formVarsSubmit = false)
{
    global $locationZipID, $locationID, $DELIVERY_LOCATION, $DELIVERY_LOCATION_ZIP;
    $resultHtml = "<script>locationZipID = 0;locationID = 0;</script><table width=\"100%\" id=\"order_type_props\" class=\"edit-table\">";
    //select person type
    $arPersonTypeList = array();
    $personTypeSelect = "<select name='buyer_type_id' id='buyer_type_id' OnChange='fBuyerChangeType(this);' >";
    $dbPersonType = CSalePersonType::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("ACTIVE" => "Y"));
    while ($arPersonType = $dbPersonType->GetNext()) {
        if (!in_array($LID, $arPersonType["LIDS"])) {
            continue;
        }
        if (!isset($PERSON_TYPE_ID) or $PERSON_TYPE_ID == "") {
            $PERSON_TYPE_ID = $arPersonType["ID"];
        }
        $class = "";
        if (IntVal($arPersonType["ID"]) == IntVal($PERSON_TYPE_ID)) {
            $class = " selected";
        }
        $personTypeSelect .= "<option value=\"" . $arPersonType["ID"] . "\" " . $class . ">" . $arPersonType["NAME"] . " [" . $arPersonType["ID"] . "]</option>";
    }
    $personTypeSelect .= "</select>";
    $userComment = "";
    $userDisplay = "none";
    if (IntVal($ORDER_ID) > 0) {
        $dbOrder = CSaleOrder::GetList(array(), array("ID" => $ORDER_ID, "ACTIVE" => "Y"), false, false, array());
        $arOrder = $dbOrder->Fetch();
        $userComment = $arOrder["USER_DESCRIPTION"];
        $userDisplay = "table-row";
    }
    if ($formVarsSubmit && $_REQUEST["btnTypeBuyer"] == "btnBuyerNew") {
        $userDisplay = "none";
    } elseif ($formVarsSubmit && $_REQUEST["btnTypeBuyer"] == "btnBuyerExist") {
        $userDisplay = "table-row";
    }
    $resultHtml .= "<tr id=\"btnBuyerExistField\" style=\"display:" . $userDisplay . "\">\n\t\t\t<td class=\"adm-detail-content-cell-l\" width=\"40%\">" . GetMessage("NEWO_BUYER") . ":</td>\n\t\t\t<td class=\"adm-detail-content-cell-r\" width=\"60%\"><div id=\"user_name\">" . fGetUserName($USER_ID) . "</div></td></tr>";
    $resultHtml .= "<tr class=\"adm-detail-required-field\">\n\t\t<td class=\"adm-detail-content-cell-l\" width=\"40%\">" . GetMessage("SOE_PERSON_TYPE") . ":</td>\n\t\t<td class=\"adm-detail-content-cell-r\" width=\"60%\">" . $personTypeSelect . "</td>\n\t</tr>";
    $bShowTrProfile = "none";
    if ($formVarsSubmit && $_POST["btnTypeBuyer"] == "btnBuyerExist") {
        $bShowTrProfile = "table-row";
    }
    $resultHtml .= "<tr id=\"buyer_profile_display\" style=\"display:" . $bShowTrProfile . "\" class=\"adm-detail-required-field\">\n\t\t<td class=\"adm-detail-content-cell-l\">" . GetMessage("NEWO_BUYER_PROFILE") . ":</td>\n\t\t<td class=\"adm-detail-content-cell-r\">\n\t\t\t<div id=\"buyer_profile_select\">";
    if ($formVarsSubmit && $_POST["btnTypeBuyer"] == "btnBuyerExist") {
        $resultHtml .= fUserProfile(IntVal($_POST["user_id"]), IntVal($_POST["buyer_type_id"]), $default = '');
    }
    $resultHtml .= "</div></td>\n\t</tr>";
    if ($ORDER_ID <= 0) {
        $arCountProps = fGetCountProfileProps($PERSON_TYPE_ID);
        $resultHtml .= "<tr id=\"btnBuyerNewField\">";
        if (count($arCountProps) < 3) {
            $resultHtml .= "<td colspan=2>\n\t\t\t\t\t<table width=\"100%\" class=\"edit-table\" >";
            if (IntVal($arCountProps["IS_EMAIL"]) <= 0) {
                $resultHtml .= "<tr class=\"adm-detail-required-field\">\n\t\t\t\t\t\t\t<td class=\"adm-detail-content-cell-l\" width=\"40%\">" . GetMessage("NEWO_BUYER_REG_MAIL") . "</td>\n\t\t\t\t\t\t\t<td class=\"adm-detail-content-cell-r\"><input type=\"text\" name=\"NEW_BUYER_EMAIL\" size=\"30\" value=\"" . htmlspecialcharsbx(trim($_REQUEST["NEW_BUYER_EMAIL"])) . "\" tabindex=\"1\" /></td>\n\t\t\t\t\t\t</tr>";
            }
            if (IntVal($arCountProps["IS_PAYER"]) <= 0) {
                $resultHtml .= "<tr class=\"adm-detail-required-field\">\n\t\t\t\t\t\t\t<td class=\"adm-detail-content-cell-l\">" . GetMessage("NEWO_BUYER_REG_LASTNAME") . "</td>\n\t\t\t\t\t\t\t<td class=\"adm-detail-content-cell-r\"><input type=\"text\" name=\"NEW_BUYER_LAST_NAME\" size=\"30\" value=\"" . htmlspecialcharsbx(trim($_REQUEST["NEW_BUYER_LAST_NAME"])) . "\" tabindex=\"3\" /></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr class=\"adm-detail-required-field\">\n\t\t\t\t\t\t\t<td class=\"adm-detail-content-cell-l\">" . GetMessage("NEWO_BUYER_REG_NAME") . "</td>\n\t\t\t\t\t\t\t<td class=\"adm-detail-content-cell-r\"><input type=\"text\" name=\"NEW_BUYER_NAME\" size=\"30\" value=\"" . htmlspecialcharsbx(trim($_REQUEST["NEW_BUYER_NAME"])) . "\" tabindex=\"2\" /></td>\n\t\t\t\t\t\t</tr>";
            }
            $resultHtml .= "</table>\n\t\t\t\t</td>";
        }
        $resultHtml .= "</tr>";
    }
    $arPropValues = array();
    if ($formVarsSubmit) {
        $locationIndexForm = "";
        foreach ($_POST as $key => $value) {
            if (substr($key, 0, strlen("CITY_ORDER_PROP_")) == "CITY_ORDER_PROP_") {
                $arPropValues[IntVal(substr($key, strlen("CITY_ORDER_PROP_")))] = htmlspecialcharsbx($value);
                $locationIndexForm = IntVal(substr($key, strlen("CITY_ORDER_PROP_")));
            }
            if (substr($key, 0, strlen("ORDER_PROP_")) == "ORDER_PROP_") {
                if ($locationIndexForm != IntVal(substr($key, strlen("ORDER_PROP_")))) {
                    $arPropValues[IntVal(substr($key, strlen("ORDER_PROP_")))] = htmlspecialcharsbx($value);
                }
            }
        }
        $userComment = $_POST["USER_DESCRIPTION"];
    } elseif ($ORDER_ID == "" and $USER_ID != "") {
        //profile
        $userProfile = array();
        $userProfile = CSaleOrderUserProps::DoLoadProfiles($USER_ID, $PERSON_TYPE_ID);
        $arPropValues = $userProfile[$PERSON_TYPE_ID]["VALUES"];
    } elseif ($ORDER_ID != "") {
        $dbPropValuesList = CSaleOrderPropsValue::GetList(array(), array("ORDER_ID" => $ORDER_ID, "ACTIVE" => "Y"), false, false, array("ID", "ORDER_PROPS_ID", "NAME", "VALUE", "CODE"));
        while ($arPropValuesList = $dbPropValuesList->Fetch()) {
            $arPropValues[IntVal($arPropValuesList["ORDER_PROPS_ID"])] = htmlspecialcharsbx($arPropValuesList["VALUE"]);
        }
    }
    //select field (town) for disable
    $arDisableFieldForLocation = array();
    $dbProperties = CSaleOrderProps::GetList(array(), array("PERSON_TYPE_ID" => $PERSON_TYPE_ID, "ACTIVE" => "Y", ">INPUT_FIELD_LOCATION" => 0), false, false, array("INPUT_FIELD_LOCATION"));
    while ($arProperties = $dbProperties->Fetch()) {
        $arDisableFieldForLocation[$arProperties["INPUT_FIELD_LOCATION"]] = $arProperties["INPUT_FIELD_LOCATION"];
    }
    //show town if location is another
    $arEnableTownProps = array();
    $dbOrderProps = CSaleOrderPropsValue::GetOrderProps($ORDER_ID);
    while ($arOrderProps = $dbOrderProps->Fetch()) {
        if ($arOrderProps["TYPE"] == "LOCATION" && $arOrderProps["ACTIVE"] == "Y" && $arOrderProps["IS_LOCATION"] == "Y" && in_array($arOrderProps["INPUT_FIELD_LOCATION"], $arDisableFieldForLocation)) {
            $arLocation = CSaleLocation::GetByID($arPropValues[$arOrderProps["ORDER_PROPS_ID"]]);
            if (IntVal($arLocation["CITY_ID"]) <= 0) {
                unset($arDisableFieldForLocation[$arOrderProps["INPUT_FIELD_LOCATION"]]);
            }
        }
    }
    $dbProperties = CSaleOrderProps::GetList(array("GROUP_SORT" => "ASC", "PROPS_GROUP_ID" => "ASC", "SORT" => "ASC", "NAME" => "ASC"), array("PERSON_TYPE_ID" => $PERSON_TYPE_ID, "ACTIVE" => "Y"), false, false, array("*"));
    $propertyGroupID = -1;
    while ($arProperties = $dbProperties->Fetch()) {
        if (IntVal($arProperties["PROPS_GROUP_ID"]) != $propertyGroupID) {
            $resultHtml .= "<tr><td colspan=\"2\" style=\"text-align:center;font-weight:bold;font-size:14px;color:rgb(75, 98, 103);\" >" . htmlspecialcharsEx($arProperties["GROUP_NAME"]) . "\n</td>\n</tr>";
            $propertyGroupID = IntVal($arProperties["PROPS_GROUP_ID"]);
        }
        if (IntVal($arProperties["PROPS_GROUP_ID"]) != $propertyGroupID) {
            $propertyGroupID = IntVal($arProperties["PROPS_GROUP_ID"]);
        }
        $adit = "";
        $requiredField = "";
        if ($arProperties["REQUIED"] == "Y" || $arProperties["IS_PROFILE_NAME"] == "Y" || $arProperties["IS_LOCATION"] == "Y" || $arProperties["IS_LOCATION4TAX"] == "Y" || $arProperties["IS_PAYER"] == "Y" || $arProperties["IS_ZIP"] == "Y") {
            $adit = " class=\"adm-detail-required-field\"";
            $requiredField = " class=\"adm-detail-content-cell-l\"";
        }
        //delete town from location
        if (in_array($arProperties["ID"], $arDisableFieldForLocation)) {
            $resultHtml .= "<tr style=\"display:none;\" id=\"town_location_" . $arProperties["ID"] . "\"" . $adit . ">\n";
        } else {
            $resultHtml .= "<tr id=\"town_location_" . $arProperties["ID"] . "\"" . $adit . ">\n";
        }
        if ($arProperties["TYPE"] == "MULTISELECT" || $arProperties["TYPE"] == "TEXTAREA" || $ORDER_ID <= 0 && $arProperties["IS_PROFILE_NAME"] == "Y") {
            $resultHtml .= "<td valign=\"top\" class=\"adm-detail-content-cell-l\" width=\"40%\">\n";
        } else {
            $resultHtml .= "<td align=\"right\" width=\"40%\" " . $requiredField . ">\n";
        }
        $resultHtml .= htmlspecialcharsEx($arProperties["NAME"]) . ":</td>";
        $curVal = $arPropValues[IntVal($arProperties["ID"])];
        if ($arProperties["IS_EMAIL"] == "Y" || $arProperties["IS_PAYER"] == "Y") {
            if (strlen($arProperties["DEFAULT_VALUE"]) <= 0 && IntVal($USER_ID) > 0) {
                $rsUser = CUser::GetByID($USER_ID);
                if ($arUser = $rsUser->Fetch()) {
                    if ($arProperties["IS_EMAIL"] == "Y") {
                        $arProperties["DEFAULT_VALUE"] = $arUser["EMAIL"];
                    } else {
                        if (strlen($arUser["LAST_NAME"]) > 0) {
                            $arProperties["DEFAULT_VALUE"] .= $arUser["LAST_NAME"];
                        }
                        if (strlen($arUser["NAME"]) > 0) {
                            $arProperties["DEFAULT_VALUE"] .= " " . $arUser["NAME"];
                        }
                        if (strlen($arUser["SECOND_NAME"]) > 0 and strlen($arUser["NAME"]) > 0) {
                            $arProperties["DEFAULT_VALUE"] .= " " . $arUser["SECOND_NAME"];
                        }
                    }
                }
            }
        }
        $resultHtml .= "<td class=\"adm-detail-content-cell-r\" width=\"60%\">";
        if ($arProperties["TYPE"] == "CHECKBOX") {
            $resultHtml .= '<input type="checkbox" class="inputcheckbox" ';
            $resultHtml .= 'name="ORDER_PROP_' . $arProperties["ID"] . '" value="Y"';
            $resultHtml .= 'id="ORDER_PROP_' . $arProperties["ID"] . '" ';
            if ($curVal == "Y" || !isset($curVal) && $arProperties["DEFAULT_VALUE"] == "Y") {
                $resultHtml .= " checked";
            }
            $resultHtml .= '>';
        } elseif ($arProperties["TYPE"] == "TEXT") {
            $change = "";
            if ($arProperties["IS_ZIP"] == "Y") {
                $DELIVERY_LOCATION_ZIP = $curVal;
                $resultHtml .= '<script> locationZipID = \'' . $arProperties["ID"] . '\';</script>';
                $locationZipID = isset($curVal) ? htmlspecialcharsEx($curVal) : htmlspecialcharsex($arProperties["DEFAULT_VALUE"]);
            }
            if ($arProperties["IS_PAYER"] == "Y" && IntVal($USER_ID) <= 0) {
                $resultHtml .= '<div id="BREAK_NAME"';
                if ($ORDER_ID > 0 || $formVarsSubmit && $_REQUEST["btnTypeBuyer"] == "btnBuyerExist") {
                    $resultHtml .= ' style="display:none"';
                }
                $resultHtml .= '>';
                $BREAK_LAST_NAME_TMP = GetMessage('NEWO_BREAK_LAST_NAME');
                if (isset($_REQUEST["BREAK_LAST_NAME"]) && strlen($_REQUEST["BREAK_LAST_NAME"]) > 0) {
                    $BREAK_LAST_NAME_TMP = htmlspecialcharsbx(trim($_REQUEST["BREAK_LAST_NAME"]));
                }
                $NEWO_BREAK_NAME_TMP = GetMessage('NEWO_BREAK_NAME');
                if (isset($_REQUEST["BREAK_NAME"]) && strlen($_REQUEST["BREAK_NAME"]) > 0) {
                    $NEWO_BREAK_NAME_TMP = htmlspecialcharsbx(trim($_REQUEST["BREAK_NAME"]));
                }
                $BREAK_SECOND_NAME_TMP = GetMessage('NEWO_BREAK_SECOND_NAME');
                if (isset($_REQUEST["BREAK_SECOND_NAME"]) && strlen($_REQUEST["BREAK_SECOND_NAME"]) > 0) {
                    $BREAK_SECOND_NAME_TMP = htmlspecialcharsbx(trim($_REQUEST["BREAK_SECOND_NAME"]));
                }
                $resultHtml .= "<div class=\"fio newo_break_active\"><input onblur=\"if (this.value==''){this.value='" . GetMessage('NEWO_BREAK_LAST_NAME') . "';BX.addClass(this.parentNode,'newo_break_active');}\" onfocus=\"if (this.value=='" . GetMessage('NEWO_BREAK_LAST_NAME') . "') {this.value='';BX.removeClass(this.parentNode,'newo_break_active');}\" type=\"text\" name=\"BREAK_LAST_NAME\" id=\"BREAK_LAST_NAME\" size=\"30\" value=\"" . $BREAK_LAST_NAME_TMP . "\" /></div>";
                $resultHtml .= "<div class=\"fio newo_break_active\"><input onblur=\"if (this.value==''){this.value='" . GetMessage('NEWO_BREAK_NAME') . "';BX.addClass(this.parentNode,'newo_break_active');}\" onfocus=\"if (this.value=='" . GetMessage('NEWO_BREAK_NAME') . "') {this.value='';BX.removeClass(this.parentNode,'newo_break_active');}\" type=\"text\" name=\"BREAK_NAME\" id=\"BREAK_NAME_BUYER\" size=\"30\" value=\"" . $NEWO_BREAK_NAME_TMP . "\" /></div>";
                $resultHtml .= "<div class=\"fio newo_break_active\"><input onblur=\"if (this.value==''){this.value='" . GetMessage('NEWO_BREAK_SECOND_NAME') . "';BX.addClass(this.parentNode,'newo_break_active');}\" onfocus=\"if (this.value=='" . GetMessage('NEWO_BREAK_SECOND_NAME') . "') {this.value='';BX.removeClass(this.parentNode,'newo_break_active');}\" type=\"text\" name=\"BREAK_SECOND_NAME\" id=\"BREAK_SECOND_NAME\" size=\"30\" value=\"" . $BREAK_SECOND_NAME_TMP . "\" /></div>";
                $resultHtml .= '</div>';
                $resultHtml .= '<div id="NO_BREAK_NAME"';
                if ($ORDER_ID <= 0) {
                    $tmpNone = ' style="display:none"';
                }
                if ($formVarsSubmit && $_REQUEST["btnTypeBuyer"] == "btnBuyerExist") {
                    $tmpNone = ' style="display:block"';
                }
                $resultHtml .= $tmpNone . '>';
            }
            $resultHtml .= '<input type="text" maxlength="250" ';
            $resultHtml .= 'size="30" ';
            $resultHtml .= 'value="' . (isset($curVal) ? $curVal : $arProperties["DEFAULT_VALUE"]) . '" ';
            $resultHtml .= 'name="ORDER_PROP_' . $arProperties["ID"] . '" ';
            $resultHtml .= 'id="ORDER_PROP_' . $arProperties["ID"] . '" ' . $change . '>';
            if ($arProperties["IS_PAYER"] == "Y" && IntVal($USER_ID) <= 0) {
                $resultHtml .= '</div>';
            }
        } elseif ($arProperties["TYPE"] == "SELECT") {
            $resultHtml .= '<select name="ORDER_PROP_' . $arProperties["ID"] . '" ';
            $resultHtml .= 'id="ORDER_PROP_' . $arProperties["ID"] . '" ';
            $resultHtml .= 'size="5" ';
            $resultHtml .= 'class="typeselect">';
            $dbVariants = CSaleOrderPropsVariant::GetList(array("SORT" => "ASC"), array("ORDER_PROPS_ID" => $arProperties["ID"]), false, false, array("*"));
            while ($arVariants = $dbVariants->Fetch()) {
                $resultHtml .= '<option value="' . htmlspecialcharsex($arVariants["VALUE"]) . '"';
                if ($arVariants["VALUE"] == $curVal || !isset($curVal) && $arVariants["VALUE"] == $arProperties["DEFAULT_VALUE"]) {
                    $resultHtml .= " selected";
                }
                $resultHtml .= '>' . htmlspecialcharsEx($arVariants["NAME"]) . '</option>';
            }
            $resultHtml .= '</select>';
        } elseif ($arProperties["TYPE"] == "MULTISELECT") {
            $resultHtml .= '<select multiple name="ORDER_PROP_' . $arProperties["ID"] . '[]" ';
            $resultHtml .= 'id="ORDER_PROP_' . $arProperties["ID"] . '" ';
            $resultHtml .= 'size="5" ';
            $resultHtml .= 'class="typeselect" type="multyselect">';
            if (!is_array($curVal)) {
                if (strlen($curVal) > 0 or $ORDER_ID != "") {
                    $curVal = explode(",", $curVal);
                } else {
                    $curVal = explode(",", $arProperties["DEFAULT_VALUE"]);
                }
                $arCurVal = array();
                $countCurVal = count($curVal);
                for ($i = 0; $i < $countCurVal; $i++) {
                    $arCurVal[$i] = Trim($curVal[$i]);
                }
            } else {
                $arCurVal = $curVal;
            }
            $dbVariants = CSaleOrderPropsVariant::GetList(array("SORT" => "ASC"), array("ORDER_PROPS_ID" => $arProperties["ID"]), false, false, array("*"));
            while ($arVariants = $dbVariants->Fetch()) {
                $resultHtml .= '<option value="' . htmlspecialcharsex($arVariants["VALUE"]) . '"';
                if (in_array($arVariants["VALUE"], $arCurVal)) {
                    $resultHtml .= " selected";
                }
                $resultHtml .= '>' . htmlspecialcharsEx($arVariants["NAME"]) . '</option>';
            }
            $resultHtml .= '</select>';
        } elseif ($arProperties["TYPE"] == "TEXTAREA") {
            $resultHtml .= '<textarea ';
            $resultHtml .= 'rows="4" ';
            $resultHtml .= 'cols="40" ';
            $resultHtml .= 'name="ORDER_PROP_' . $arProperties["ID"] . '" ';
            $resultHtml .= 'id="ORDER_PROP_' . $arProperties["ID"] . '" type="textarea">';
            $resultHtml .= isset($curVal) ? $curVal : $arProperties["DEFAULT_VALUE"];
            $resultHtml .= '</textarea>';
        } elseif ($arProperties["TYPE"] == "LOCATION") {
            $countryID = "";
            $cityID = "";
            $cityList = "";
            $DELIVERY_LOCATION = $arPropValues[IntVal($arProperties["ID"])];
            $locationID = $curVal;
            $tmpLocation = '';
            ob_start();
            $tmpLocation = $GLOBALS["APPLICATION"]->IncludeComponent('bitrix:sale.ajax.locations', '', array("SITE_ID" => $LID, "AJAX_CALL" => "N", "COUNTRY_INPUT_NAME" => "ORDER_PROP_" . $arProperties["ID"], "REGION_INPUT_NAME" => "REGION_ORDER_PROP_" . $arProperties["ID"], "CITY_INPUT_NAME" => "CITY_ORDER_PROP_" . $arProperties["ID"], "CITY_OUT_LOCATION" => "Y", "ALLOW_EMPTY_CITY" => "Y", "LOCATION_VALUE" => $curVal, "COUNTRY" => "", "ONCITYCHANGE" => "fRecalProduct('', '', 'N');", "PUBLIC" => "N"), null, array('HIDE_ICONS' => 'Y'));
            $tmpLocation = ob_get_contents();
            ob_end_clean();
            $resultHtml .= '<script>var locationID = \'' . $arProperties["ID"] . '\';</script>';
            $resultHtml .= $tmpLocation;
        } elseif ($arProperties["TYPE"] == "RADIO") {
            $dbVariants = CSaleOrderPropsVariant::GetList(array("SORT" => "ASC"), array("ORDER_PROPS_ID" => $arProperties["ID"]), false, false, array("*"));
            $resultHtml .= '<div id="ORDER_PROP_' . $arProperties["ID"] . '">';
            // type="radio"
            while ($arVariants = $dbVariants->Fetch()) {
                $resultHtml .= '<input type="radio" class="inputradio" ';
                $resultHtml .= 'name="ORDER_PROP_' . $arProperties["ID"] . '" ';
                $resultHtml .= 'value="' . htmlspecialcharsex($arVariants["VALUE"]) . '"';
                if ($arVariants["VALUE"] == $curVal || !isset($curVal) && $arVariants["VALUE"] == $arProperties["DEFAULT_VALUE"]) {
                    $resultHtml .= " checked";
                }
                $resultHtml .= '>' . htmlspecialcharsEx($arVariants["NAME"]) . '<br>';
            }
            $resultHtml .= '</div>';
        }
        if (strlen($arProperties["DESCRIPTION"]) > 0) {
            $resultHtml .= "<br><small>" . htmlspecialcharsEx($arProperties["DESCRIPTION"]) . "</small>";
        }
        $resultHtml .= "\n</td>\n</tr>";
    }
    //end while
    $resultHtml .= "<tr>\n<td valign=\"top\" class=\"adm-detail-content-cell-l\">" . GetMessage("SOE_BUYER_COMMENT") . ":\n\t\t\t</td>\n\t\t\t<td class=\"adm-detail-content-cell-r\">\n\t\t\t\t<textarea name=\"USER_DESCRIPTION\" rows=\"4\" cols=\"40\">" . htmlspecialcharsbx($userComment) . "</textarea>\n\t\t\t</td>\n\t\t</tr>";
    $resultHtml .= "</table>";
    return $resultHtml;
}
Ejemplo n.º 11
0
    function OnOrderNewSendEmailHandler($orderID, &$eventName, &$arFields)
    {
        // Поменять вид списка товаров
        if (!CModule::IncludeModule('sale') || !CModule::IncludeModule('catalog')) return;
        //global $pre_defined_variables, $DB;

        $arOrder = CSaleOrder::GetById($orderID);

        $dbBasketItems = CSaleBasket::GetList(array("NAME" => "ASC"), array("ORDER_ID" => $orderID), false, false, array("ID", "NAME", "QUANTITY", "PRICE", "CURRENCY", "DETAIL_PAGE_URL"));
        $strOrderList = "";
        $strOrderList .= '<table width="100%">';
        $strOrderList .= '<thead><tr>';
        foreach(array("Название","Количество","Цена","Сумма") as $th) $strOrderList .= '<th>'.$th.'</th>';
        $strOrderList .= '</tr></thead>';

        $strOrderList .= '<tbody>';

        $price_total = 0;
        $arBasketItems = array();
        while ($arBasketItem = $dbBasketItems->Fetch())
        {
            $dbProp = CSaleBasket::GetPropsList(Array("SORT" => "ASC", "NAME" => "ASC"), Array("BASKET_ID" => $arBasketItem["ID"], "!CODE" => array("CATALOG.XML_ID", "PRODUCT.XML_ID")));
            while($arProp = $dbProp -> GetNext())
                $arBasketItem["PROPS"][] = $arProp;
            $arBasketItems[] = $arBasketItem;

            $strOrderList .= '<tr>';
            $strOrderList .= '<td>';
            $strOrderList .= '<a href="http://www.zakrepi.ru'.$arBasketItem["DETAIL_PAGE_URL"].'" target="_blank">'.$arBasketItem["NAME"].'</a>';
            // Из свойств товара заказа показать лишь стандартные и название филиала
            foreach($arBasketItem['PROPS'] as &$arProp)
            {
                $strOrderList .= '<div style="font-size:80%">'.$arProp['NAME'].': '.$arProp['VALUE'].'</div>';
            }
            $strOrderList .= '</td>';
            $strOrderList .= '<td style="text-align: center;">'.$arBasketItem["QUANTITY"].'&nbsp;шт.</td>';
            $strOrderList .= '<td style="text-align: center;">'.SaleFormatCurrency($arBasketItem["PRICE"], $arBasketItem["CURRENCY"]).'</td>';
            $strOrderList .= '<td style="text-align: center;">'.SaleFormatCurrency($arBasketItem["PRICE"] * $arBasketItem["QUANTITY"], $arBasketItem["CURRENCY"]).'</td>';
            $strOrderList .= '</tr>';
            $price_total += $arBasketItem["PRICE"] * $arBasketItem["QUANTITY"];
            $price_currency = $arBasketItem["CURRENCY"];
        }
        $price_total_formatted = $price_currency? SaleFormatCurrency($price_total, $price_currency): '0';
        $strOrderList .= '<tr><td colspan="3" style="text-align:right;">Общая стоимость:&nbsp;</td><td style="text-align: center;">'.$price_total_formatted.'</td></tr>';


        //Получаем стоимость доставки цену и общую сумму вместе с ценой доставки

        // Указываем способ доставки
        // $arOrder['PRICE'] - Общая стоимость
        $arFields['DELIVERY'] = '';
        if (strlen($arOrder['DELIVERY_ID']))
        {

            if (is_string($arOrder['DELIVERY_ID']))
            {

                $sid = explode(":", $arOrder['DELIVERY_ID']);
                $dbDeliv = CSaleDeliveryHandler::GetBySID($sid[0]);
                $arDeliv = $dbDeliv->GetNext();
                $arFields['DELIVERY'] = '<p><b>Способ доставки:</b> '.$arDeliv['NAME'].'</p>';
                $price_total += $arOrder['PRICE_DELIVERY'];

                $strOrderList .= '<tr><td colspan="3" style="text-align:right;">Стоимость доставки:&nbsp;</td><td style="text-align: center;">'.SaleFormatCurrency($arOrder['PRICE_DELIVERY'], $price_currency).'</td></tr>';

                $strOrderList .= '<tr><td colspan="3" style="text-align:right;">Итого:&nbsp;</td><td style="text-align: center;">'.SaleFormatCurrency($price_total, $price_currency).'</td></tr>';

                $arFields['ALL_PRICE'] = '<p><b>Итого: </b>'.SaleFormatCurrency($price_total, $price_currency).'</p>';
            }
            else{
                $arDelivery = CSaleDelivery::GetById($arOrder['DELIVERY_ID']);
                if ($arDelivery)
                {
                    $value = $arDelivery['NAME'];
                    $value_name = $arDelivery['NAME'];
                    $value_price = '';
                    if ($arDelivery['PRICE']<=0)
                    {
                        $value .= ', Бесплатно';
                        $value_price = 'Бесплатно';
                    }
                    else
                    {
                        $value .= ', '.SaleFormatCurrency($arDelivery['PRICE'], $arDelivery['CURRENCY']);

                        $value_price = SaleFormatCurrency($arDelivery['PRICE'], $arDelivery['CURRENCY']);

                        $strOrderList .= '<tr><td colspan="3" style="text-align:right;">Стоимость доставки:&nbsp;</td><td style="text-align: center;">'.$value_price.'</td></tr>';
                    }
                    $arFields['DELIVERY'] = '<p><b>Способ доставки:</b> '.$value_name.'</p>';
                    $price_total += $arDelivery['PRICE'];

                    $strOrderList .= '<tr><td colspan="3" style="text-align:right;">Итого:&nbsp;</td><td style="text-align: center;">'.SaleFormatCurrency($price_total, $price_currency).'</td></tr>';

                    $arFields['ALL_PRICE'] = '<p><b>Итого: </b>'.SaleFormatCurrency($price_total, $price_currency).'</p>';
                }
            }
        }


        $strOrderList .= '</tbody>';
        $strOrderList .= '</table>';
        $arFields["ORDER_LIST_NEW"] = $strOrderList;



        // Указываем свойства заказа - Начало
        /* $arProps = array();
         $dbProps = CSaleOrderPropsValue::GetOrderProps($orderID);
         while ($arProp = $dbProps->Fetch())
         {
             $arProps[$arProp['CODE']] = $arProp;

             $val = $arProp['VALUE'];
             if ($arProp['TYPE']=="LOCATION") {
                 $v = CSaleLocation::GetByID($val);
                 $val = $v['CITY_NAME_LANG'];
             } elseif (in_array($arProp['TYPE'], array("SELECT", "MULTISELECT", "RADIO"))) {
                 $v = CSaleOrderPropsVariant::GetByValue($arProp['ORDER_PROPS_ID'], $val);
                 $val = $v['NAME'];
             }

             $arProp['VALUE_FORMATTED'] = $val;

         }*/

        // Получаем список исключенных свойств в зависимости от выбранной службы доставки
        /*$delivery_id = $arOrder['DELIVERY_ID'];
        $EXCLUDE_PROPS = $pre_defined_variables['ORDER_MAKE']["EXCLUDE_PROP_ON_DELIVERY_ID"];
        if (array_key_exists($delivery_id, $EXCLUDE_PROPS))
            $EXCLUDE_PROP = $EXCLUDE_PROPS[$delivery_id];
        else
            $EXCLUDE_PROP = array();
        $EXCLUDE_PROP = array_merge(array('AGREE'), $EXCLUDE_PROP);

        // Выводим свойства
        $strPropsList = '';
        foreach($arProps as $prop_code=>&$arProp)
        {
            if (in_array($prop_code, $EXCLUDE_PROP)) continue;

            $strPropsList .= '<p>';
            $value = strlen(trim($arProp['VALUE']))? $arProp['VALUE']: '<i>не указано</i>';
            $strPropsList .= '<b>'.$arProp['NAME'].':</b> '.$value;
            $strPropsList .= '</p>';
        }
        $arFields['PROPS_LIST'] = $strPropsList;*/
        // Указываем свойства заказа - Конец



        // Указываем способ оплаты
        $arFields['PAY_SYSTEM'] = '';
        if (strlen($arOrder['PAY_SYSTEM_ID']))
        {
            $arPaySystem = CSalePaySystem::GetByID($arOrder['PAY_SYSTEM_ID'], $arOrder['PERSON_TYPE_ID']);
            if ($arPaySystem)
            {
                $value = strlen(trim($arPaySystem['PSA_NAME']))? $arPaySystem['PSA_NAME']: $arPaySystem['NAME'];
                if($arOrder['PAY_SYSTEM_ID'] == 1 || $arOrder['PAY_SYSTEM_ID'] == 2)
                {
                    $arFields['PAY_SYSTEM'] = '<p><b>Способ оплаты:</b> <a href="http://www.zakrepi.ru/checkout/?ORDER_ID='.$orderID.'" target="_blank">'.$value.'</a></p>';
                }
                else
                {
                    $arFields['PAY_SYSTEM'] = '<p><b>Способ оплаты:</b> '.$value.'</p>';
                }
            }
        }

        // Получаем склад, указанный при доставке
        $arFields['STORE_LIST'] = '';
        $arFields['STORE_LIST_NEUTRAL'] = '';
        $arFields['STORE_EMAIL'] = '';
        $arStores = array();



        if ($arOrder['DELIVERY_ID'] == 1)
        {
            $dbStores = CCatalogStore::GetList(array(), array('ID'=>1), false, false, array());
            $arStore = $dbStores->Fetch();


            $strStoreList = '';
            if ($arStore)
            {
                // Получаем свойства склада в нужном порядке
                $prop_codes = array('TITLE'=>'', 'ADDRESS'=>'Адрес', 'PHONE'=>'Телефон', 'SCHEDULE'=>'Время работы');
                // Выводим склад
                $strStoreList = '<span style="font-size: 90%">';
                $have_value = false; $prev_value = false;
                foreach($prop_codes as $prop_code=>&$name)
                {
                    if ($prev_value)
                    {
                        $strStoreList .= ', ';
                        $prev_value = false;
                    }

                    if (strlen(trim($arStore[$prop_code])))
                    {
                        $have_value = true;
                        if (strlen($name))
                        {
                            $strStoreList .= $name.': ';
                        }
                        $strStoreList .= trim($arStore[$prop_code]);
                        $prev_value = true;
                    }

                }
                $strStoreList .= '</span><br />';
                // Добавляем поле списка складов в почтовый шаблон
                //$arFields['STORE_LIST_NEUTRAL'] = '<p>Указанный '$strStoreList;
                if (strlen($have_value))
                {
                    $arFields['STORE_LIST_NEUTRAL'] = '<p><b>Пункт выдачи:</b></p>' . $strStoreList;
                    $arFields['STORE_LIST'] = '<p><b>Пожалуйста, сообщите номер вашего заказа для оплаты по адресу:</b></p>' . $strStoreList;
                }

            }
        }
        else if($arOrder['DELIVERY_ID'] > 1)
        {
            $strStoreList = '';
            $arOrderProps = CSaleOrderPropsValue::GetOrderProps($arOrder['ID']);
            while ($arProps = $arOrderProps->Fetch())
            {
                switch ($arProps['CODE']) {
                    case 'CITY':
                        $strStoreList .= $arProps['NAME'].': '.$arProps['VALUE'];
                        break;
                    case 'STREET':
                        $strStoreList .= '<br/>'.$arProps['NAME'].': '.$arProps['VALUE'];
                        break;
                    case 'HOUSE':
                        $strStoreList .= '<br/>'.$arProps['NAME'].': '.$arProps['VALUE'];
                        break;
                    case 'KORPUS':
                        if($arProps['VALUE']!='')
                            $strStoreList .= '<br/>'.$arProps['NAME'].': '.$arProps['VALUE'];
                        break;
                    case 'FLAT':
                        if($arProps['VALUE']!='')
                            $strStoreList .= '<br/>'.$arProps['NAME'].': '.$arProps['VALUE'];
                        break;
                }
            }

            $arFields['STORE_LIST_NEUTRAL'] = '<div><p><b>Доставка по адресу:</b></p>' . $strStoreList.'</div>';
        }
        else if(is_string($arOrder['DELIVERY_ID']))
        {
            $strStoreList = '';
            $arOrderProps = CSaleOrderPropsValue::GetOrderProps($arOrder['ID']);
            while ($arProps = $arOrderProps->Fetch())
            {
                switch ($arProps['CODE']) {
                    case 'CITY':
                        $strStoreList .= $arProps['NAME'].': '.$arProps['VALUE'];
                        break;
                    case 'STREET':
                        $strStoreList .= '<br/>'.$arProps['NAME'].': '.$arProps['VALUE'];
                        break;
                    case 'HOUSE':
                        $strStoreList .= '<br/>'.$arProps['NAME'].': '.$arProps['VALUE'];
                        break;
                    case 'KORPUS':
                        if($arProps['VALUE']!='')
                            $strStoreList .= '<br/>'.$arProps['NAME'].': '.$arProps['VALUE'];
                        break;
                    case 'FLAT':
                        if($arProps['VALUE']!='')
                            $strStoreList .= '<br/>'.$arProps['NAME'].': '.$arProps['VALUE'];
                        break;
                }
            }

            $arFields['STORE_LIST_NEUTRAL'] = '<div><p><b>Доставка по адресу:</b></p>' . $strStoreList.'</div>';
        }

        //Получение данных пользователя
        $rsUser = CUser::GetByID($arOrder['USER_ID']);
        $arUser = $rsUser->Fetch();

        if(in_array(5, CUser::GetUserGroup($arOrder['USER_ID'])))
        {
            $arFields['STORE_PHONE'] = $arUser['WORK_PHONE'];
            $arFields['STORE_NAME_USER'] = '******'.$arUser['NAME'].' '.$arUser['LAST_NAME'];
        }
        else if(in_array(6, CUser::GetUserGroup($arOrder['USER_ID'])))
        {
            $arFields['STORE_PHONE'] = $arUser['WORK_PHONE'];
            $arFields['STORE_NAME_USER'] = '******'.$arUser['WORK_COMPANY'].' Контактное лицо '.$arUser['UF_CONTACT_MANAGER'];
        }
    }
Ejemplo n.º 12
0
	<form method="POST" action="pbrf_orders.php?lang=<?php 
    echo LANGUAGE_ID;
    echo $_GET["return_url"] ? "&amp;return_url=" . urlencode($_GET["return_url"]) : "";
    ?>
&amp;order=<?php 
    echo $_GET["order"];
    ?>
" enctype="multipart/form-data" name="editform">
<?php 
    $tabControl->Begin();
    $tabControl->BeginNextTab();
    //получаем данные по заказу
    $order = CSaleOrder::GetByID($id_order);
    //получаем данные по пользователю
    $user = CUser::GetByID($order["USER_ID"]);
    $props = CSaleOrderPropsValue::GetOrderProps($id_order);
    //получаем данные по заказу
    $fio = $zip = $country = $address = "";
    while (is_array($pr = $props->Fetch())) {
        //отбираем данные по ФИО, индексу и адресу
        if ($pr["CODE"] == "FIO") {
            $fio = $pr["VALUE"];
        }
        if ($pr["CODE"] == "ZIP") {
            $zip = $pr["VALUE"];
        }
        if ($pr["CODE"] == "LOCATION") {
            $country = $pr["VALUE"];
        }
        if ($pr["CODE"] == "ADDRESS") {
            $address = $pr["VALUE"];
Ejemplo n.º 13
0
        $products[$ii]['ProductName'] = $arItems['NAME'];
        $products[$ii]['ProductPrice'] = number_format($arItems['PRICE'], 2, '.', '');
        $products[$ii]['ProductItemsNum'] = number_format($arItems['QUANTITY'], 2, '.', '');
        $quantitys += $arItems['QUANTITY'];
        $ii++;
    }
}
if ($order_info['PRICE_DELIVERY'] > 0) {
    $products[$ii]['ProductId'] = '00001';
    $products[$ii]['ProductName'] = 'Delivery';
    $products[$ii]['ProductPrice'] = number_format($order_info['PRICE_DELIVERY'], 2, '.', '');
    $products[$ii]['ProductItemsNum'] = number_format(1, 2, '.', '');
    $quantitys += 1;
}
$ii = 0;
$db_props = CSaleOrderPropsValue::GetOrderProps($order_id);
while ($arProps = $db_props->Fetch()) {
    if ($arProps['CODE'] == 'PHONE') {
        $userEnteredFields[$ii]['FieldTag'] = 'PhoneNumber';
        $userEnteredFields[$ii]['FieldValue'] = $arProps['VALUE'];
        $user_phone = $arProps['VALUE'];
    }
    if ($arProps['CODE'] == 'FIO') {
        $DeliveryLastname = $arProps['VALUE'];
    }
    if ($arProps['CODE'] == 'ADDRESS') {
        $DeliveryStreet = $arProps['VALUE'];
    }
    if ($arProps['CODE'] == 'EMAIL') {
        $userEnteredFields[$ii]['FieldTag'] = 'E-Mail';
        $userEnteredFields[$ii]['FieldValue'] = $arProps['VALUE'];
Ejemplo n.º 14
0
</a> -->
		<?endif?>

	</div>

	<?if(!empty($arResult['ORDERS'])):?>
		<?
		$flag = false; 
		?>
		<?foreach($arResult["ORDER_BY_STATUS"] as $key => $group):?>

			<?foreach($group as $k => $order):?>
				<?
				$deliveryId = false;
				$delivery = false;
				$rs = CSaleOrderPropsValue::GetOrderProps($order['ORDER']['ID']);
				while ($x = $rs->Fetch()) {
					if ($x['CODE'] == 'delivery_id') {
						$deliveryId = $x['VALUE'];
						break;
					}
				}

				if(intval($order["ORDER"]["DELIVERY_ID"])) {
					$delivery = $arResult["INFO"]["DELIVERY"][$order["ORDER"]["DELIVERY_ID"]]["NAME"];
				} elseif(strpos($order["ORDER"]["DELIVERY_ID"], ":") !== false) {
					$arId = explode(":", $order["ORDER"]["DELIVERY_ID"]);
					$delivery = $arResult["INFO"]["DELIVERY_HANDLERS"][$arId[0]]["NAME"] . '(' . $arResult["INFO"]["DELIVERY_HANDLERS"][$arId[0]]["PROFILES"][$arId[1]]["TITLE"] . ')';
				}
				?>
Ejemplo n.º 15
0
 /**
  * Function gets order properties from database
  * @param mixed[] $cached Cached data taken from obtainDataCachedStructure()
  * @return void
  */
 protected function obtainProps(&$cached)
 {
     if (empty($this->dbResult["ID"])) {
         return;
     }
     $props = array();
     $dbOrderProps = CSaleOrderPropsValue::GetOrderProps($this->dbResult["ID"]);
     $iGroup = -1;
     while ($arOrderProps = $dbOrderProps->GetNext()) {
         if (empty($this->arParams["PROP_" . $this->dbResult["PERSON_TYPE_ID"]]) || !in_array($arOrderProps["ORDER_PROPS_ID"], $this->arParams["PROP_" . $this->dbResult["PERSON_TYPE_ID"]])) {
             if ($arOrderProps["ACTIVE"] == "Y" && $arOrderProps["UTIL"] == "N") {
                 $arOrderPropsTmp = $arOrderProps;
                 if ($iGroup != intval($arOrderProps["PROPS_GROUP_ID"])) {
                     $arOrderPropsTmp["SHOW_GROUP_NAME"] = "Y";
                     $iGroup = intval($arOrderProps["PROPS_GROUP_ID"]);
                 }
                 if ($arOrderProps["TYPE"] == "SELECT" || $arOrderProps["TYPE"] == "RADIO") {
                     $arVal = CSaleOrderPropsVariant::GetByValue($arOrderProps["ORDER_PROPS_ID"], $arOrderProps["VALUE"]);
                     $arOrderPropsTmp["VALUE"] = htmlspecialcharsEx($arVal["NAME"]);
                 } elseif ($arOrderProps["TYPE"] == "MULTISELECT") {
                     $arOrderPropsTmp["VALUE"] = "";
                     $curVal = explode(",", $arOrderProps["VALUE"]);
                     for ($i = 0, $intCount = count($curVal); $i < $intCount; $i++) {
                         $arVal = CSaleOrderPropsVariant::GetByValue($arOrderProps["ORDER_PROPS_ID"], $curVal[$i]);
                         if ($i > 0) {
                             $arOrderPropsTmp["VALUE"] .= ", ";
                         }
                         $arOrderPropsTmp["VALUE"] .= htmlspecialcharsEx($arVal["NAME"]);
                     }
                 } elseif ($arOrderProps["TYPE"] == "LOCATION") {
                     $locationName = "";
                     if (CSaleLocation::isLocationProMigrated()) {
                         $locationName = Location\Admin\LocationHelper::getLocationStringById($arOrderProps["VALUE"]);
                     } else {
                         $arVal = CSaleLocation::GetByID($arOrderProps["VALUE"], LANGUAGE_ID);
                         $locationName .= !strlen($arVal["COUNTRY_NAME"]) ? "" : $arVal["COUNTRY_NAME"];
                         if (strlen($arVal["COUNTRY_NAME"]) && strlen($arVal["REGION_NAME"])) {
                             $locationName .= " - " . $arVal["REGION_NAME"];
                         } elseif (strlen($arVal["REGION_NAME"])) {
                             $locationName .= $arVal["REGION_NAME"];
                         }
                         if (strlen($arVal["COUNTRY_NAME"]) || strlen($arVal["REGION_NAME"])) {
                             $locationName .= " - " . $arVal["CITY_NAME"];
                         } elseif (strlen($arVal["CITY_NAME"])) {
                             $locationName .= $arVal["CITY_NAME"];
                         }
                     }
                     $arOrderPropsTmp["VALUE"] = $locationName;
                 } elseif ($arOrderProps["TYPE"] == "FILE") {
                     if (strpos($arOrderProps["VALUE"], ",") !== false) {
                         $fileValue = "";
                         $values = explode(",", $arOrderProps["VALUE"]);
                         if (self::isNonemptyArray($values)) {
                             foreach ($values as $fileId) {
                                 $fileValue .= CFile::ShowFile(trim($fileId), 0, 90, 90, true) . "<br/>";
                             }
                         }
                         $arOrderPropsTmp["VALUE"] = $fileValue;
                     } else {
                         $arOrderPropsTmp["VALUE"] = CFile::ShowFile($arOrderProps["VALUE"], 0, 90, 90, true);
                     }
                 }
                 $props[] = $arOrderPropsTmp;
             }
         }
     }
     $cached["ORDER_PROPS"] = $props;
 }
Ejemplo n.º 16
0
        }
        
		if ($order = CSaleOrder::GetByID($ID)) {
			if($order['DELIVERY_ID'] == 'goparcel:simple') {
				// status
				if (CGPWidget::StatusExists($json['order']['status'])) {
					$status_match = COption::GetOptionString($moduleID, "status_match_".$json['order']['status']);
					if ($status_match && $status_match != $order['STATUS_ID']) {
						$res = CSaleOrder::StatusOrder($order['ID'], $status_match);
						if (!$res) { $error[] = 'could not change order.status to ['.$status_match.']'; } else {
							$message[] = 'order '.$order['ID'].' changed status to ['.$status_match.']';
						}
					}
				} else { $error[] = 'invalid order.status'; }
				if (SITE_ID && $order['ID']) {
					$order_props_res = CSaleOrderPropsValue::GetOrderProps($order['ID']);
					while ($order_props_ar = $order_props_res->Fetch()) {
						$order_props[] = $order_props_ar;
					}
                    $gp_prop_list = array(
                        'customer_name', 
                        'customer_email', 
                        'customer_phone', 
                        //'index', 
                        //'location', 
                        //'location_city_name', 
                        'delivery_city', 
                        'delivery_address', 
                        'delivery_address_street', 
                        'delivery_address_house', 
                        'delivery_address_building', 
Ejemplo n.º 17
0
/**
 * [getOrederLk description]
 * @param  int $idUser
 * @return array
 */
function getOrederLk($idUser)
{
    CModule::IncludeModule('iblock');
    CModule::IncludeModule('sale');
    $arFilter = array("USER_ID" => $idUser);
    $db_sales = CSaleOrder::GetList(array("DATE_INSERT" => "DESC"), $arFilter);
    if ($ar_sales = $db_sales->Fetch()) {
        $db_props = CSaleOrderPropsValue::GetOrderProps($ar_sales["ID"]);
        $arPropsAll = array();
        while ($arProps = $db_props->Fetch()) {
            $ar_sales["PROPERTIES"][] = $arProps;
        }
        $arFields = array();
        $dbBasketItems = CSaleBasket::GetList(array("NAME" => "ASC", "ID" => "ASC"), array("LID" => SITE_ID, "ORDER_ID" => $ar_sales["ID"]), false, false, array());
        while ($arItems = $dbBasketItems->Fetch()) {
            $db_res = CSaleBasket::GetPropsList(array("SORT" => "ASC", "NAME" => "ASC"), array("BASKET_ID" => $arItems['ID']), false, array());
            while ($ar_res = $db_res->Fetch()) {
                $arPropOrderItems[] = $ar_res;
            }
            $arProducts = getItemCart($arItems["PRODUCT_ID"]);
            $arItems["PRODUCTS"] = $arProducts;
            $arItems["PROP_ORDER_ITEMS"] = $arPropOrderItems;
            $ar_sales["ITEMS"][] = $arItems;
        }
        return $ar_sales;
    }
}