Example #1
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;
}
Example #2
0
	if (isset($userId) AND isset($buyerType) AND (!isset($profileDefault) OR $profileDefault == ""))
	{
		$id = intval($id);
		$userId = intval($userId);
		$buyerType = intval($buyerType);
		$LID = trim($LID);
		$currency = trim($currency);

		$arFuserItems = CSaleUser::GetList(array("USER_ID" => $userId));
		$fuserId = $arFuserItems["ID"];
		$arData = array();
		$arErrors = array();

		$arData["status"] = "ok";
		$arData["userProfileSelect"] = fUserProfile($userId, $buyerType);
		$arData["userName"] = fGetUserName($userId);

		$arShoppingCart = CSaleBasket::DoGetUserShoppingCart($LID, $userId, $fuserId, $arErrors, array());
		$arShoppingCart = fDeleteDoubleProduct($arShoppingCart, array(), 'N');
		$arData["userBasket"] = fGetFormatedProduct($userId, $LID, $arShoppingCart, $currency, 'basket');

		$viewedIterator = \Bitrix\Catalog\CatalogViewedProductTable::getList(
			array(
				"filter" => array("FUSER_ID" => $fuserId),
				"select" => array(
					"ID",
					"PRODUCT_ID",
					"LID" => "SITE_ID",
					"NAME" => "ELEMENT.NAME",
					"PREVIEW_PICTURE" => "ELEMENT.PREVIEW_PICTURE",
					"DETAIL_PICTURE" => "ELEMENT.DETAIL_PICTURE",
Example #3
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;
}