Exemple #1
0
 /**
  * @param string $siteId Site id.
  * @return array List of person types for given site.
  */
 public static function getPersonTypesList($siteId)
 {
     $dbResultList = \CSalePersonType::GetList("NAME", "ASC", array("LID" => $siteId, "ACTIVE" => "Y"));
     $arPersonTypes = array();
     while ($arPT = $dbResultList->Fetch()) {
         $arPersonTypes[$arPT['ID']] = $arPT['NAME'];
     }
     return $arPersonTypes;
 }
	function CheckFields($ACTION, &$arFields)
	{
		global $DB, $USER;

		if ((is_set($arFields, "NAME") || $ACTION=="ADD") && strlen($arFields["NAME"]) <= 0)
		{
			$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGPSA_NO_NAME"), "ERROR_NO_NAME");
			return false;
		}
		if ((is_set($arFields, "PAY_SYSTEM_ID") || $ACTION=="ADD") && IntVal($arFields["PAY_SYSTEM_ID"]) <= 0)
		{
			$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGPSA_NO_CODE"), "ERROR_NO_PAY_SYSTEM_ID");
			return false;
		}
		if ((is_set($arFields, "PERSON_TYPE_ID") || $ACTION=="ADD") && IntVal($arFields["PERSON_TYPE_ID"]) <= 0)
		{
			$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGPSA_NO_ID_TYPE"), "ERROR_NO_PERSON_TYPE_ID");
			return false;
		}

		if (is_set($arFields, "NEW_WINDOW") && $arFields["NEW_WINDOW"] != "Y")
			$arFields["NEW_WINDOW"] = "N";
		if (is_set($arFields, "HAVE_PAYMENT") && $arFields["HAVE_PAYMENT"] != "Y")
			$arFields["HAVE_PAYMENT"] = "N";
		if (is_set($arFields, "HAVE_ACTION") && $arFields["HAVE_ACTION"] != "Y")
			$arFields["HAVE_ACTION"] = "N";
		if (is_set($arFields, "HAVE_RESULT") && $arFields["HAVE_RESULT"] != "Y")
			$arFields["HAVE_RESULT"] = "N";
		if (is_set($arFields, "HAVE_PREPAY") && $arFields["HAVE_PREPAY"] != "Y")
			$arFields["HAVE_PREPAY"] = "N";
		if (is_set($arFields, "HAVE_RESULT_RECEIVE") && $arFields["HAVE_RESULT_RECEIVE"] != "Y")
			$arFields["HAVE_RESULT_RECEIVE"] = "N";
		if (is_set($arFields, "ENCODING") && strlen($arFields["ENCODING"]) <= 0)
			$arFields["ENCODING"] = false;

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

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

		return True;
	}
 protected function addPaysysHandler($psid)
 {
     $a_ps_act = array();
     $fields = array("PAY_SYSTEM_ID" => $psid, "NAME" => Loc::getMessage("DEVTM_ERIP_PS_ACTION_NAME"), "ACTION_FILE" => "/bitrix/php_interface/include/sale_payment/" . $this->MODULE_ID, "NEW_WINDOW" => "N", "HAVE_PREPAY" => "N", "HAVE_RESULT" => "N", "HAVE_ACTION" => "N", "HAVE_PAYMENT" => "Y", "HAVE_RESULT_RECEIVE" => "Y", "ENCODING" => "utf-8");
     $db_pt = CSalePersonType::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array());
     while ($pt = $db_pt->Fetch()) {
         $fields["PERSON_TYPE_ID"] = $pt["ID"];
         $id = CSalePaySystemAction::Add($fields);
         if ($id != false) {
             $a_ps_act[] = $id;
         }
     }
     return $a_ps_act;
 }
Exemple #4
0
 function CheckFields($ACTION, &$arFields, $ID = 0)
 {
     if ((is_set($arFields, "PERSON_TYPE_ID") || $ACTION == "ADD") && IntVal($arFields["PERSON_TYPE_ID"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SALE_EXPORT_NO_PERSON_TYPE_ID"), "EMPTY_PERSON_TYPE_ID");
         return false;
     }
     if (is_set($arFields, "PERSON_TYPE_ID")) {
         $arResult = CSalePersonType::GetByID($arFields["PERSON_TYPE_ID"]);
         if (!$arResult) {
             $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["PERSON_TYPE_ID"], GetMessage("SALE_EXPORT_ERROR_PERSON_TYPE_ID")), "ERROR_NO_PERSON_TYPE_ID");
             return false;
         }
     }
     return True;
 }
 function CheckFields($ACTION, &$arFields)
 {
     global $DB;
     if ((is_set($arFields, "TAX_ID") || $ACTION == "ADD") && IntVal($arFields["TAX_ID"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGTR_EMPTY_TAX_ID"), "ERROR_NO_TAX_ID");
         return false;
     }
     if ((is_set($arFields, "PERSON_TYPE_ID") || $ACTION == "ADD") && IntVal($arFields["PERSON_TYPE_ID"]) <= 0) {
         $arFields["PERSON_TYPE_ID"] = false;
     }
     if (is_set($arFields, "VALUE") || $ACTION == "ADD") {
         $arFields["VALUE"] = str_replace(",", ".", $arFields["VALUE"]);
         $arFields["VALUE"] = DoubleVal($arFields["VALUE"]);
     }
     if ((is_set($arFields, "IS_PERCENT") || $ACTION == "ADD") && $arFields["IS_PERCENT"] != "N") {
         $arFields["IS_PERCENT"] = "Y";
     }
     if ($arFields["IS_PERCENT"] == "Y") {
         $arFields["CURRENCY"] = false;
     } elseif ($arFields["IS_PERCENT"] == "N" && (!is_set($arFields, "CURRENCY") || strlen($arFields["CURRENCY"]) <= 0)) {
         return False;
     } elseif (!is_set($arFields, "IS_PERCENT") && (is_set($arFields, "CURRENCY") && $arFields["CURRENCY"] !== false)) {
         return False;
     }
     if (is_set($arFields, "TAX_ID")) {
         if (!($arTax = CSaleTax::GetByID($arFields["TAX_ID"]))) {
             $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["TAX_ID"], GetMessage("SKGTR_NO_TAX")), "ERROR_NO_TAX");
             return false;
         }
     }
     if (is_set($arFields, "PERSON_TYPE_ID") && $arFields["PERSON_TYPE_ID"] !== false) {
         if (!($arPersonType = CSalePersonType::GetByID($arFields["PERSON_TYPE_ID"]))) {
             $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["PERSON_TYPE_ID"], GetMessage("SKGTR_NO_PERS_TYPE")), "ERROR_NO_PERSON_TYPE");
             return false;
         }
     }
     if ((is_set($arFields, "IS_IN_PRICE") || $ACTION == "ADD") && $arFields["IS_IN_PRICE"] != "Y") {
         $arFields["IS_IN_PRICE"] = "N";
     }
     if ((is_set($arFields, "ACTIVE") || $ACTION == "ADD") && $arFields["ACTIVE"] != "N") {
         $arFields["ACTIVE"] = "Y";
     }
     if ((is_set($arFields, "APPLY_ORDER") || $ACTION == "ADD") && IntVal($arFields["APPLY_ORDER"]) <= 0) {
         $arFields["APPLY_ORDER"] = "100";
     }
     return true;
 }
 public static function GetSettingsArray()
 {
     $arSaleProps = array();
     if (CModule::IncludeModule('sale')) {
         $rsPersonType = CSalePersonType::GetList(array('SORT' => 'ASC', 'NAME' => 'ASC'), array('ACTIVE' => 'Y'));
         while ($rsPersonRow = $rsPersonType->GetNext()) {
             $arSaleProps[] = $rsPersonRow;
         }
         foreach ($arSaleProps as $arSalePropKey => $arSalePropVal) {
             $rsOrderProps = CSaleOrderProps::GetList(array('SORT' => 'ASC'), array('PERSON_TYPE_ID' => $arSalePropVal['ID'], 'UTIL' => 'N'));
             while ($rsOrderPropRow = $rsOrderProps->GetNext()) {
                 $arSaleProps[$arSalePropKey]['PROPERTIES'][] = $rsOrderPropRow;
             }
         }
     }
     return $arSaleProps;
 }
 public static function FormatInvoicePersonTypeChanged($arData)
 {
     $info = GetMessage("CRM_INVOICE_EVENT_INFO_PERSON_TYPE_CHANGED");
     foreach ($arData as $param => $value) {
         if ($param == "PERSON_TYPE_ID") {
             $res = CSalePersonType::GetByID($value);
             $value = "\"" . $res["NAME"] . "\"";
             if ($res["NAME"] === 'CRM_CONTACT') {
                 $value = '"' . GetMessage('CRM_PERSON_TYPE_CONTACT') . '"';
             } else {
                 if ($res["NAME"] === 'CRM_COMPANY') {
                     $value = '"' . GetMessage('CRM_PERSON_TYPE_COMPANY') . '"';
                 }
             }
         }
         $info = str_replace("#" . $param . "#", $value, $info);
     }
     return array("INFO" => $info);
 }
 public static function CheckFields($ACTION, &$arFields, $ID = 0)
 {
     global $DB, $USER;
     if (is_set($arFields, "PERSON_TYPE_ID") && $ACTION != "ADD") {
         unset($arFields["PERSON_TYPE_ID"]);
     }
     if ((is_set($arFields, "PERSON_TYPE_ID") || $ACTION == "ADD") && IntVal($arFields["PERSON_TYPE_ID"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGOPG_EMPTY_PERS_TYPE"), "ERROR_NO_PERSON_TYPE");
         return false;
     }
     if ((is_set($arFields, "NAME") || $ACTION == "ADD") && strlen($arFields["NAME"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGOPG_EMPTY_GROUP"), "ERROR_NO_NAME");
         return false;
     }
     if (is_set($arFields, "PERSON_TYPE_ID")) {
         if (!($arPersonType = CSalePersonType::GetByID($arFields["PERSON_TYPE_ID"]))) {
             $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["PERSON_TYPE_ID"], GetMessage("SKGOPG_NO_PERS_TYPE")), "ERROR_NO_PERSON_TYPE");
             return false;
         }
     }
     return True;
 }
Exemple #9
0
$arResultProps = array();
$PERSON_TYPE = isset($_POST["PERSON_TYPE"]) ? (int) $_POST["PERSON_TYPE"] : 0;
$PROFILE_ID = isset($_POST["PROFILE_ID"]) ? (int) $_POST["PROFILE_ID"] : '';
$PROFILE_ID_OLD = isset($_POST["PROFILE_ID_OLD"]) ? (int) $_POST["PROFILE_ID_OLD"] : '';
$PAYSYSTEM_ID = isset($_POST["PAYSYSTEM_ID"]) ? htmlspecialcharsbx($_POST["PAYSYSTEM_ID"]) : '';
$DELIVERY_ID = isset($_POST["DELIVERY_ID"]) ? htmlspecialcharsbx($_POST["DELIVERY_ID"]) : '';
$ORDER_DESCRIPTION = htmlspecialcharsbx(trim($_POST["ORDER_DESCRIPTION"]));
$ORDER_ID = isset($_REQUEST["ORDER_ID"]) ? (int) $_REQUEST["ORDER_ID"] : '';
$currentUserId = (int) $USER->GetID();
if ((int) $ORDER_ID <= 0) {
    DiscountCouponsManager::init();
    /*
     * person type
     */
    $arPersonTypeList = array();
    $dbPersonType = CSalePersonType::GetList(array("ID" => "ASC", "NAME" => "ASC"), array("ACTIVE" => "Y", 'LID' => SITE_ID));
    while ($arPersonType = $dbPersonType->GetNext()) {
        $arPersonType["CHECKED"] = 'N';
        if ($PERSON_TYPE <= 0) {
            $PERSON_TYPE = $arPersonType["ID"];
            $arPersonType["CHECKED"] = "Y";
        } else {
            if (isset($_POST["PERSON_TYPE"]) && $_POST["PERSON_TYPE"] == $arPersonType["ID"]) {
                $arPersonType["CHECKED"] = "Y";
            }
        }
        $arPersonTypeList[$arPersonType["ID"]] = $arPersonType;
    }
    $arResultProps["PERSON_TYPE"] = $arPersonTypeList;
    /*
     * user profile
Exemple #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."\">
			<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;
}
?>
<input type="hidden" name="id" value="<?php 
echo $ID;
?>
">
<?php 
$tabControl->EndEpilogContent();
$urlForm = "";
if ($ID > 0) {
    $urlForm = "&id=" . $ID;
}
$tabControl->Begin(array("FORM_ACTION" => $APPLICATION->GetCurPage() . "?lang=" . LANG . $urlForm));
//TAB EDIT PROFILE
$tabControl->BeginNextFormTab();
if (!empty($arProfile) && !empty($arUser)) {
    $dbPersonType = CSalePersonType::GetList(array(), array("ACTIVE" => "Y", "ID" => $PERSON_TYPE));
    $arPersonType = $dbPersonType->GetNext();
    $LID = $arPersonType["LID"];
    $arFilterProps = array("PERSON_TYPE_ID" => $PERSON_TYPE, "ACTIVE" => "Y");
    if ($saleModulePermissions >= "U" && $saleModulePermissions < "W") {
        $arFilterProps["USER_PROPS"] = "Y";
        $arFilterProps["UTIL"] = "N";
    }
    $tabControl->AddViewField("CODE_USER", GetMessage("BUYER_PE_USER") . ":", "[<a href=\"/bitrix/admin/user_edit.php?ID=" . $arUser["ID"] . "&lang=" . LANGUAGE_ID . "\">" . $arUser["ID"] . "</a>] (" . $arUser["LOGIN"] . ") " . $userFIO);
    $tabControl->AddEditField("CODE_PROFILE_NAME", GetMessage("BUYER_PE_PROFILE_NAME") . ":", false, array("size" => 30, "maxlength" => 255), htmlspecialcharsEx($profileName));
    $propertyGroupID = "";
    $dbProperties = CSaleOrderProps::GetList(array("GROUP_SORT" => "ASC", "PROPS_GROUP_ID" => "ASC", "SORT" => "ASC", "NAME" => "ASC"), $arFilterProps, false, false, array("*"));
    $userProfile = CSaleOrderUserProps::DoLoadProfiles($USER_ID, $PERSON_TYPE);
    $curVal = "";
    while ($arProperties = $dbProperties->Fetch()) {
        $curVal = $userProfile[$ID]["VALUES"][IntVal($arProperties["ID"])];
Exemple #12
0
 /**
  * Function returns reference data as shared cache between this component and sale.personal.order.list.
  *
  * @throws Exception
  * @return void
  */
 protected function obtainDataReferences()
 {
     if ($this->startCache(array('spo-shared'))) {
         try {
             $cachedData = array();
             /////////////////////
             /////////////////////
             // Person type
             $dbPType = CSalePersonType::GetList(array("SORT" => "ASC"));
             while ($arPType = $dbPType->Fetch()) {
                 $cachedData['PERSON_TYPE'][$arPType["ID"]] = $arPType;
             }
             // Save statuses for Filter form
             $dbStatus = CSaleStatus::GetList(array("SORT" => "ASC"), array("LID" => LANGUAGE_ID));
             while ($arStatus = $dbStatus->Fetch()) {
                 $cachedData['STATUS'][$arStatus["ID"]] = $arStatus;
             }
             $dbPaySystem = CSalePaySystem::GetList(array("SORT" => "ASC"));
             while ($arPaySystem = $dbPaySystem->Fetch()) {
                 $arPaySystem['NAME'] = htmlspecialcharsbx($arPaySystem['NAME']);
                 $cachedData['PAYSYS'][$arPaySystem["ID"]] = $arPaySystem;
             }
             $cachedData['DELIVERY'] = array();
             $shipmentIds = array();
             foreach ($this->dbResult['SHIPMENT'] as $shipment) {
                 $shipmentIds[] = $shipment['DELIVERY_ID'];
             }
             $dbDelivery = \Bitrix\Sale\Delivery\Services\Table::getList(array('select' => array('ID', 'NAME', 'PARENT_NAME' => 'PARENT.NAME', 'PARENT_CLASS_NAME' => 'PARENT.CLASS_NAME'), 'filter' => array('ID' => $shipmentIds)));
             $deliveryService = array();
             while ($delivery = $dbDelivery->fetch()) {
                 $deliveryService[$delivery['ID']] = $delivery;
             }
             foreach ($deliveryService as $delivery) {
                 $cachedData['DELIVERY'][$delivery["ID"]] = array();
                 if ($delivery['PARENT_NAME']) {
                     $cachedData['DELIVERY'][$delivery["ID"]]['NAME'] = htmlspecialcharsbx($delivery['PARENT_NAME'] . ':' . $delivery['NAME']);
                 } else {
                     $cachedData['DELIVERY'][$delivery["ID"]]['NAME'] = htmlspecialcharsbx($delivery['NAME']);
                 }
             }
             /////////////////////
             /////////////////////
         } catch (Exception $e) {
             $this->abortCache();
             throw $e;
         }
         $this->endCache($cachedData);
     } else {
         $cachedData = $this->getCacheData();
     }
     $this->dbResult = array_merge($this->dbResult, $this->adaptCachedReferences($cachedData));
 }
Exemple #13
0
	/**
	 * @param bool|string $strControlID
	 * @return array|bool
	 */
	public static function GetControls($strControlID = false)
	{
		$arSalePersonTypes = array();
		$arFilter = array();
		if (static::$boolInit)
		{
			if (isset(static::$arInitParams['SITE_ID']))
				$arFilter['LID'] = static::$arInitParams['SITE_ID'];
		}
		$rsPersonTypes = CSalePersonType::GetList(array(), $arFilter, false, false, array('ID', 'NAME', 'LIDS'));
		while ($arPersonType = $rsPersonTypes->Fetch())
		{
			$arPersonType['ID'] = intval($arPersonType['ID']);
			$arSalePersonTypes[$arPersonType['ID']] = $arPersonType['NAME'].'('.implode(' ', $arPersonType['LIDS']).')';
		}

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

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

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

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

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

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

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

		if ($strControlID === false)
		{
			return $arControlList;
		}
		elseif (isset($arControlList[$strControlID]))
		{
			return $arControlList[$strControlID];
		}
		else
		{
			return false;
		}
	}
Exemple #14
0
{
	if(!$bInitVars)
		$arResult = $arUserProps;
	else
	{
		foreach($_POST as $k => $v)
		{
			$arResult[$k] = htmlspecialcharsbx($v);
			$arResult['~'.$k] = $v;
		}
	}

	$arResult["ERROR_MESSAGE"] = $errorMessage;

	$arResult["TITLE"] = str_replace("#ID#", $arUserProps["ID"], GetMessage("SPPD_PROFILE_NO"));
	$arResult["PERSON_TYPE"] = CSalePersonType::GetByID($arUserProps["PERSON_TYPE_ID"]);
	$arResult["PERSON_TYPE"]["NAME"] = htmlspecialcharsEx($arResult["PERSON_TYPE"]["NAME"]);

	// get prop description
	$arrayTmp = Array();
	$propsOfTypeLocation = array();
	$dbOrderPropsGroup = CSaleOrderPropsGroup::GetList(
				array("SORT" => "ASC", "NAME" => "ASC"),
				array("PERSON_TYPE_ID" => $arUserProps["PERSON_TYPE_ID"]),
				false,
				false,
				array("ID", "PERSON_TYPE_ID", "NAME", "SORT")
			);
	while ($arOrderPropsGroup = $dbOrderPropsGroup->GetNext())
	{
		$arrayTmp[$arOrderPropsGroup["ID"]] = $arOrderPropsGroup;
 function CheckFields($ACTION, &$arFields, $ID = 0)
 {
     global $DB, $USER;
     if (is_set($arFields, "PERSON_TYPE_ID") && $ACTION != "ADD") {
         unset($arFields["PERSON_TYPE_ID"]);
     }
     if ((is_set($arFields, "PERSON_TYPE_ID") || $ACTION == "ADD") && IntVal($arFields["PERSON_TYPE_ID"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGOP_EMPTY_PERS_TYPE"), "ERROR_NO_PERSON_TYPE");
         return false;
     }
     if ((is_set($arFields, "NAME") || $ACTION == "ADD") && strlen($arFields["NAME"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGOP_EMPTY_PROP_NAME"), "ERROR_NO_NAME");
         return false;
     }
     if ((is_set($arFields, "TYPE") || $ACTION == "ADD") && strlen($arFields["TYPE"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGOP_EMPTY_PROP_TYPE"), "ERROR_NO_TYPE");
         return false;
     }
     if (is_set($arFields, "REQUIED") && $arFields["REQUIED"] != "Y") {
         $arFields["REQUIED"] = "N";
     }
     if (is_set($arFields, "USER_PROPS") && $arFields["USER_PROPS"] != "Y") {
         $arFields["USER_PROPS"] = "N";
     }
     if (is_set($arFields, "IS_LOCATION") && $arFields["IS_LOCATION"] != "Y") {
         $arFields["IS_LOCATION"] = "N";
     }
     if (is_set($arFields, "IS_LOCATION4TAX") && $arFields["IS_LOCATION4TAX"] != "Y") {
         $arFields["IS_LOCATION4TAX"] = "N";
     }
     if (is_set($arFields, "IS_EMAIL") && $arFields["IS_EMAIL"] != "Y") {
         $arFields["IS_EMAIL"] = "N";
     }
     if (is_set($arFields, "IS_PROFILE_NAME") && $arFields["IS_PROFILE_NAME"] != "Y") {
         $arFields["IS_PROFILE_NAME"] = "N";
     }
     if (is_set($arFields, "IS_PAYER") && $arFields["IS_PAYER"] != "Y") {
         $arFields["IS_PAYER"] = "N";
     }
     if (is_set($arFields, "IS_FILTERED") && $arFields["IS_FILTERED"] != "Y") {
         $arFields["IS_FILTERED"] = "N";
     }
     if (is_set($arFields, "IS_ZIP") && $arFields["IS_ZIP"] != "Y") {
         $arFields["IS_ZIP"] = "N";
     }
     if (is_set($arFields, "IS_LOCATION") && is_set($arFields, "TYPE") && $arFields["IS_LOCATION"] == "Y" && $arFields["TYPE"] != "LOCATION") {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGOP_WRONG_PROP_TYPE"), "ERROR_WRONG_TYPE1");
         return false;
     }
     if (is_set($arFields, "IS_LOCATION4TAX") && is_set($arFields, "TYPE") && $arFields["IS_LOCATION4TAX"] == "Y" && $arFields["TYPE"] != "LOCATION") {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGOP_WRONG_PROP_TYPE"), "ERROR_WRONG_TYPE2");
         return false;
     }
     if ((is_set($arFields, "PROPS_GROUP_ID") || $ACTION == "ADD") && IntVal($arFields["PROPS_GROUP_ID"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGOP_EMPTY_PROP_GROUP"), "ERROR_NO_GROUP");
         return false;
     }
     if (is_set($arFields, "PERSON_TYPE_ID")) {
         if (!($arPersonType = CSalePersonType::GetByID($arFields["PERSON_TYPE_ID"]))) {
             $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["PERSON_TYPE_ID"], GetMessage("SKGOP_NO_PERS_TYPE")), "ERROR_NO_PERSON_TYPE");
             return false;
         }
     }
     return True;
 }
Exemple #16
0
 function CheckFields($ACTION, &$arFields, $ID = 0)
 {
     if (is_set($arFields, "SITE_ID") && strlen($arFields["SITE_ID"]) > 0) {
         $arFields["LID"] = $arFields["SITE_ID"];
     }
     if ((is_set($arFields, "LID") || $ACTION == "ADD") && strlen($arFields["LID"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGO_EMPTY_SITE"), "EMPTY_SITE_ID");
         return false;
     }
     if ((is_set($arFields, "PERSON_TYPE_ID") || $ACTION == "ADD") && IntVal($arFields["PERSON_TYPE_ID"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGO_EMPTY_PERS_TYPE"), "EMPTY_PERSON_TYPE_ID");
         return false;
     }
     if ((is_set($arFields, "USER_ID") || $ACTION == "ADD") && IntVal($arFields["USER_ID"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGO_EMPTY_USER_ID"), "EMPTY_USER_ID");
         return false;
     }
     if (is_set($arFields, "PAYED") && $arFields["PAYED"] != "Y") {
         $arFields["PAYED"] = "N";
     }
     if (is_set($arFields, "CANCELED") && $arFields["CANCELED"] != "Y") {
         $arFields["CANCELED"] = "N";
     }
     if (is_set($arFields, "STATUS_ID") && strlen($arFields["STATUS_ID"]) <= 0) {
         $arFields["STATUS_ID"] = "N";
     }
     if (is_set($arFields, "ALLOW_DELIVERY") && $arFields["ALLOW_DELIVERY"] != "Y") {
         $arFields["ALLOW_DELIVERY"] = "N";
     }
     if (is_set($arFields, "PRICE") || $ACTION == "ADD") {
         $arFields["PRICE"] = str_replace(",", ".", $arFields["PRICE"]);
         $arFields["PRICE"] = DoubleVal($arFields["PRICE"]);
     }
     if (is_set($arFields, "PRICE_DELIVERY") || $ACTION == "ADD") {
         $arFields["PRICE_DELIVERY"] = str_replace(",", ".", $arFields["PRICE_DELIVERY"]);
         $arFields["PRICE_DELIVERY"] = DoubleVal($arFields["PRICE_DELIVERY"]);
     }
     if (is_set($arFields, "SUM_PAID") || $ACTION == "ADD") {
         $arFields["SUM_PAID"] = str_replace(",", ".", $arFields["SUM_PAID"]);
         $arFields["SUM_PAID"] = DoubleVal($arFields["SUM_PAID"]);
     }
     if (is_set($arFields, "DISCOUNT_VALUE") || $ACTION == "ADD") {
         $arFields["DISCOUNT_VALUE"] = str_replace(",", ".", $arFields["DISCOUNT_VALUE"]);
         $arFields["DISCOUNT_VALUE"] = DoubleVal($arFields["DISCOUNT_VALUE"]);
     }
     if (is_set($arFields, "TAX_VALUE") || $ACTION == "ADD") {
         $arFields["TAX_VALUE"] = str_replace(",", ".", $arFields["TAX_VALUE"]);
         $arFields["TAX_VALUE"] = DoubleVal($arFields["TAX_VALUE"]);
     }
     if (!is_set($arFields, "LOCKED_BY") && (!is_set($arFields, "UPDATED_1C") || is_set($arFields, "UPDATED_1C") && $arFields["UPDATED_1C"] != "Y")) {
         $arFields["UPDATED_1C"] = "N";
     }
     if ((is_set($arFields, "CURRENCY") || $ACTION == "ADD") && strlen($arFields["CURRENCY"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGO_EMPTY_CURRENCY"), "EMPTY_CURRENCY");
         return false;
     }
     if (is_set($arFields, "CURRENCY")) {
         if (!($arCurrency = CCurrency::GetByID($arFields["CURRENCY"]))) {
             $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["CURRENCY"], GetMessage("SKGO_WRONG_CURRENCY")), "ERROR_NO_CURRENCY");
             return false;
         }
     }
     if (is_set($arFields, "LID")) {
         $dbSite = CSite::GetByID($arFields["LID"]);
         if (!$dbSite->Fetch()) {
             $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["LID"], GetMessage("SKGO_WRONG_SITE")), "ERROR_NO_SITE");
             return false;
         }
     }
     if (is_set($arFields, "USER_ID")) {
         $dbUser = CUser::GetByID($arFields["USER_ID"]);
         if (!$dbUser->Fetch()) {
             $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["USER_ID"], GetMessage("SKGO_WRONG_USER")), "ERROR_NO_USER_ID");
             return false;
         }
     }
     if (is_set($arFields, "PERSON_TYPE_ID")) {
         if (!($arPersonType = CSalePersonType::GetByID($arFields["PERSON_TYPE_ID"]))) {
             $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["PERSON_TYPE_ID"], GetMessage("SKGO_WRONG_PERSON_TYPE")), "ERROR_NO_PERSON_TYPE");
             return false;
         }
     }
     if (is_set($arFields, "PAY_SYSTEM_ID") && IntVal($arFields["PAY_SYSTEM_ID"]) > 0) {
         if (!($arPaySystem = CSalePaySystem::GetByID(IntVal($arFields["PAY_SYSTEM_ID"])))) {
             $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["PAY_SYSTEM_ID"], GetMessage("SKGO_WRONG_PS")), "ERROR_NO_PAY_SYSTEM");
             return false;
         }
     }
     if (is_set($arFields, "DELIVERY_ID") && (strpos($arFields["DELIVERY_ID"], ":") !== false || IntVal($arFields["DELIVERY_ID"]) > 0)) {
         if (strpos($arFields["DELIVERY_ID"], ":") !== false) {
             $arId = explode(":", $arFields["DELIVERY_ID"]);
             $obDelivery = new CSaleDeliveryHandler();
             if ($arDelivery = $obDelivery->GetBySID($arId[0])) {
                 if ($arDelivery = $arDelivery->Fetch()) {
                     if (!is_set($arDelivery["PROFILES"], $arId[1])) {
                         $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["DELIVERY_ID"], GetMessage("SKGO_WRONG_DELIVERY")), "ERROR_NO_DELIVERY");
                         return false;
                     }
                 }
             } else {
                 $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["DELIVERY_ID"], GetMessage("SKGO_WRONG_DELIVERY")), "ERROR_NO_DELIVERY");
                 return false;
             }
         } else {
             if (!($arDelivery = CSaleDelivery::GetByID(IntVal($arFields["DELIVERY_ID"])))) {
                 $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["DELIVERY_ID"], GetMessage("SKGO_WRONG_DELIVERY")), "ERROR_NO_DELIVERY");
                 return false;
             }
         }
     }
     if (is_set($arFields, "STATUS_ID")) {
         if (!($arStatus = CSaleStatus::GetByID($arFields["STATUS_ID"]))) {
             $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["STATUS_ID"], GetMessage("SKGO_WRONG_STATUS")), "ERROR_NO_STATUS_ID");
             return false;
         }
     }
     return True;
 }
Exemple #17
0
	$LID = $str_LID;
	$str_DELIVERY_ID = (isset($_POST["DELIVERY_ID"]) && strlen($_POST["DELIVERY_ID"]) > 0) ? $_POST["DELIVERY_ID"] : $str_DELIVERY_ID;
	$str_PAY_SYSTEM_ID = (isset($_POST["PAY_SYSTEM_ID"]) && intval($_POST["PAY_SYSTEM_ID"]) > 0) ? intval($_POST["PAY_SYSTEM_ID"]) : $str_PAY_SYSTEM_ID;
}

if (!isset($str_TAX_VALUE) OR $str_TAX_VALUE == "")
	$str_TAX_VALUE = 0;

if (intval($str_PERSON_TYPE_ID) <= 0)
{
	$str_PERSON_TYPE_ID = 0;
	$arFilter = array();
	$arFilter["ACTIVE"] = "Y";
	if(strlen($LID) > 0)
		$arFilter["LID"] = $LID;
	$dbPersonType = CSalePersonType::GetList(array("SORT" => "ASC", "NAME" => "ASC"), $arFilter, false, array('nTopCount' => 1), array('ID'));
	if($arPersonType = $dbPersonType->Fetch())
		$str_PERSON_TYPE_ID = $arPersonType["ID"];
}

$arFuserItems = CSaleUser::GetList(array("USER_ID" => intval($str_USER_ID)));
$FUSER_ID = $arFuserItems["ID"];

/*
 * form select site
 */
if ((!isset($LID) OR $LID == "") AND (defined('BX_PUBLIC_MODE') OR BX_PUBLIC_MODE == 1) )
{
	$arSitesShop = array();
	$arSitesTmp = array();
	$rsSites = CSite::GetList($by="id", $order="asc", array("ACTIVE" => "Y"));
Exemple #18
0
 function ShowStep()
 {
     $wizard =& $this->GetWizard();
     $arResult = $wizard->GetVars(true);
     $dbSite = CSite::GetByID($arResult["siteID"]);
     $arSite = $dbSite->GetNext();
     CModule::IncludeModule("currency");
     $dbCurrency = CCurrency::GetList($b = "SORT", $o = "ASC", $arResult["siteID"]);
     while ($arCur = $dbCurrency->GetNext()) {
         $arCurrency[$arCur["CURRENCY"]] = $arCur["FULL_NAME"];
     }
     $dbUGroup = CGroup::GetList($b = "c_sort", $o = "ASC", array("ACTIVE" => "Y"));
     while ($arUGroup = $dbUGroup->GetNext()) {
         $arGroups[$arUGroup["ID"]] = $arUGroup["NAME"];
     }
     CModule::IncludeModule("sale");
     $dbPersonType = CSalePersonType::GetList(array("SORT" => "ASC"), array("ACTIVE" => "Y", "LID" => $arResult["siteID"]));
     while ($arPersonType = $dbPersonType->GetNext()) {
         $arPersons[$arPersonType["ID"]] = $arPersonType["NAME"];
     }
     $dbPaySystem = CSalePaySystem::GetList(array("SORT" => "ASC"), array("ACTIVE" => "Y", "LID" => $arResult["siteID"]));
     while ($arPaySystem = $dbPaySystem->GetNext()) {
         $arPaySystems[$arPaySystem["ID"]] = $arPaySystem["NAME"];
     }
     $dbDelivery = CSaleDeliveryHandler::GetList(array("SORT" => "ASC"), array("SITE_ID" => $arResult["siteID"], "ACTIVE" => "Y"));
     while ($arDelivery = $dbDelivery->GetNext()) {
         $arDeliveries[$arDelivery["SID"] . "_new"] = $arDelivery["NAME"] . " " . GetMessage("WW_STEP8_1");
     }
     $dbDelivery = CSaleDelivery::GetList(array("SORT" => "ASC"), array("LID" => $arResult["siteID"], "ACTIVE" => "Y"));
     while ($arDelivery = $dbDelivery->GetNext()) {
         $arDeliveries[$arDelivery["ID"]] = $arDelivery["NAME"];
     }
     $this->content = GetMessage("WW_2") . "<br />";
     $this->content .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"/bitrix/wizards/bitrix/sale.install/styles.css\">";
     $this->content .= "<table class=\"data-table\">";
     $this->content .= "<tr><th>" . GetMessage("WW_STEP1_2") . "</th><td>[" . $arSite["ID"] . "] " . $arSite["NAME"] . "</td></tr>";
     $this->content .= "<tr><th>" . GetMessage("WW_STEP1_3") . "</th><td>" . $arResult["orderEmail"] . "</td></tr>";
     $this->content .= "<tr><th>" . GetMessage("WW_STEP1_5") . "</th><td>" . $arResult["currencyID"] . " (" . $arCurrency[$arResult["currencyID"]] . ")" . "</td></tr>";
     $this->content .= "<tr><th>" . GetMessage("WW_3") . "</th><td>";
     foreach ($arResult["groupID"] as $v) {
         $this->content .= $arGroups[$v] . "<br />";
     }
     $this->content .= "</td></tr>";
     $this->content .= "<tr><th>" . GetMessage("WW_4") . "</th><td>";
     foreach ($arResult["personType"] as $v) {
         $this->content .= $arPersons[$v] . "<br />";
     }
     $this->content .= "</td></tr>";
     $this->content .= "<tr><th>" . GetMessage("WW_5") . "</th><td>";
     $arPS = array();
     foreach ($arResult["paySystem"] as $v) {
         if (!empty($v)) {
             foreach ($v as $v1) {
                 if (!in_array($v1, $arPS)) {
                     $arPS[] = $v1;
                 }
             }
         }
     }
     foreach ($arPS as $v) {
         $this->content .= $arPaySystems[$v] . "<br />";
     }
     $this->content .= "</td></tr>";
     $this->content .= "<tr><th>" . GetMessage("WW_6") . "</th><td>";
     if (!empty($arResult["delivery"])) {
         foreach ($arResult["delivery"] as $v) {
             $this->content .= $arDeliveries[$v] . "<br />";
         }
     }
     $this->content .= "</td></tr>";
     $this->content .= "</table>";
 }
Exemple #19
0
							"NAME" => $val["NAME"],
							"CODE" => $val["CODE"],
							"VALUE" => $val["VALUE"],
						);
					CSaleOrderPropsValue::Add($arFields);
				}
				return $orderID;
			}
		}

		$personType = $arGeneralInfo["personType"]["ur"];
		if(IntVal($arGeneralInfo["personType"]["fiz"]) > 0)
			$personType = $arGeneralInfo["personType"]["fiz"];
		if(IntVal($personType) <= 0)
		{
			$dbPerson = CSalePersonType::GetList(array(), Array("LID" => WIZARD_SITE_ID));
			if($arPerson = $dbPerson->Fetch())
			{
				$personType = $arPerson["ID"];
			}
		}
		if(IntVal($arGeneralInfo["paySystem"]["cash"][$personType]) > 0 )
			$paySystem = $arGeneralInfo["paySystem"]["cash"][$personType];
		elseif(IntVal($arGeneralInfo["paySystem"]["bill"][$personType]) > 0 )
			$paySystem = $arGeneralInfo["paySystem"]["bill"][$personType];
		elseif(IntVal($arGeneralInfo["paySystem"]["bill"][$personType]) > 0 )
			$paySystem = $arGeneralInfo["paySystem"]["sber"][$personType];
		elseif(IntVal($arGeneralInfo["paySystem"]["paypal"][$personType]) > 0 )
			$paySystem = $arGeneralInfo["paySystem"]["paypal"][$personType];
		else
		{
Exemple #20
0
            $optionsOrderProps[$code]['city'] = 'CITY';
        }
        if (array_search('ZIP', $optionsOrderProps[$code]) == false) {
            $optionsOrderProps[$code]['index'] = 'ZIP';
        }
    }
    
    $api = new RetailCrm\RestApi($api_host, $api_key);
    
    $order = $api->orderGet($idOrderCRM, $by = 'id');
    
    $log = new Logger();
    $log->write($order, 'order');
        
    $defaultOrderType = 1;
    $dbOrderTypesList = CSalePersonType::GetList(array(), array("ACTIVE" => "Y"));
    if ($arOrderTypesList = $dbOrderTypesList->Fetch()) {
        $defaultOrderType = $arOrderTypesList['ID'];
    }
    
    $GLOBALS['INTARO_CRM_FROM_HISTORY'] = true;

    if (function_exists('intarocrm_order_pre_persist')) {
        $order = intarocrm_order_pre_persist($order);
    }
                
    if (!isset($order['externalId'])) {
        // custom orderType function
        if (function_exists('intarocrm_set_order_type')) {
            $orderType = intarocrm_set_order_type($order);
            if ($orderType) {
Exemple #21
0
 /**
  * <p>Функция добавляет новый тип плательщика с параметрами из массива arFields </p>
  *
  *
  *
  *
  * @param array $arFields  Ассоциативный массив параметров нового типа плательщиков,
  * ключами в котором являются названия параметров, а значениями -
  * соответствующие значения.<br> Допустимые ключи:<ul> <li> <b>LID</b> - код
  * сайта, к которому привязан тип плательщика. (Может быть массивом
  * сайтов);</li> <li> <b>NAME</b> - название типа плательщика;</li> <li> <b>SORT</b> -
  * индекс сортировки.</li> <li> <b>ACTIVE</b> - флаг активности пользователя
  * [Y|N] .</li> </ul>
  *
  *
  *
  * @return Int <p>Возвращается код добавленного типа плательщика или <i>false</i> - в
  * случае ошибки.</p> <br><br>
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/sale/classes/csalepersontype/csalepersontype__add.a7f60787.php
  * @author Bitrix
  */
 public static function Add($arFields)
 {
     global $DB;
     if (!CSalePersonType::CheckFields("ADD", $arFields)) {
         return false;
     }
     $db_events = GetModuleEvents("sale", "OnBeforePersonTypeAdd");
     while ($arEvent = $db_events->Fetch()) {
         if (ExecuteModuleEventEx($arEvent, array(&$arFields)) === false) {
             return false;
         }
     }
     $arLID = array();
     if (is_set($arFields, "LID")) {
         if (is_array($arFields["LID"])) {
             $arLID = $arFields["LID"];
         } else {
             $arLID[] = $arFields["LID"];
         }
         $str_LID = "''";
         $arFields["LID"] = false;
         foreach ($arLID as $k => $v) {
             if (strlen($v) > 0) {
                 $str_LID .= ", '" . $DB->ForSql($v) . "'";
                 if (empty($arFields["LID"])) {
                     $arFields["LID"] = $v;
                 }
             } else {
                 unset($arLID[$k]);
             }
         }
     }
     $arInsert = $DB->PrepareInsert("b_sale_person_type", $arFields);
     $strSql = "INSERT INTO b_sale_person_type(" . $arInsert[0] . ") " . "VALUES(" . $arInsert[1] . ")";
     $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     $ID = IntVal($DB->LastID());
     if (count($arLID) > 0) {
         $strSql = "DELETE FROM b_sale_person_type_site WHERE PERSON_TYPE_ID=" . $ID;
         $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
         $strSql = "INSERT INTO b_sale_person_type_site(PERSON_TYPE_ID, SITE_ID) " . "SELECT " . $ID . ", LID " . "FROM b_lang " . "WHERE LID IN (" . $str_LID . ") ";
         $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
     }
     unset($GLOBALS["SALE_PERSON_TYPE_LIST_CACHE"]);
     $events = GetModuleEvents("sale", "OnPersonTypeAdd");
     while ($arEvent = $events->Fetch()) {
         ExecuteModuleEventEx($arEvent, array($ID, $arFields));
     }
     return $ID;
 }
Exemple #22
0
    static function SelectBoxPersonTypes($personID, $name, $htmlattrs = ""){
        if (empty($name)) {
            return false;
        }

        $html = '<select name="'.$name.'" '.$htmlattrs.'>';
        $res = CSalePersonType::GetList(Array(), Array());
        while ($arRes = $res->Fetch()) {
            $html .= '<option '.(($arRes['ID']==$personID)?'selected':'').' value="'.$arRes['ID'].'">'.$arRes["NAME"].'</option>';
        }
        $html .= '</select>';
        return $html;
    }
<input type="hidden" name="Update" value="Y">
<input type="hidden" name="lang" value="<?php 
echo LANG;
?>
">
<input type="hidden" name="ID" value="<?php 
echo $ID;
?>
">
<?php 
echo bitrix_sessid_post();
$aTabs = array(array("DIV" => "edit1", "TAB" => GetMessage("SPSN_TAB_PAYSYS"), "ICON" => "sale", "TITLE" => GetMessage("SPSN_TAB_PAYSYS_DESCR")), array("DIV" => "edit2", "TAB" => GetMessage("PPE_PERSON_TYPES"), "ICON" => "sale", "TITLE" => GetMessage("PPE_PERSON_TYPES")));
$aTabs1 = array();
$i = -1;
$arPersonTypeList = array();
$dbPersonType = CSalePersonType::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array());
while ($arPersonType = $dbPersonType->Fetch()) {
    $i++;
    $aTabs1[] = array("DIV" => "editP" . ($i + 2), "TAB" => htmlspecialcharsEx($arPersonType["NAME"]) . " (" . implode(", ", $arPersonType["LIDS"]) . ")", "ICON" => "sale", "TITLE" => str_replace("#PLTYPE#", htmlspecialcharsEx($arPersonType["NAME"]), GetMessage("SPSN_TAB_PAYSYS_DESCR_1")));
    $arPersonTypeList[$i] = $arPersonType;
}
$tabControl = new CAdminTabControl("tabControl", $aTabs);
$tabControl->Begin();
?>

<?php 
$tabControl->BeginNextTab();
?>
	<?php 
if ($ID > 0) {
    ?>
Exemple #24
0
 function CheckFields($ACTION, &$arFields, $ID = 0)
 {
     global $USER_FIELD_MANAGER, $DB, $APPLICATION;
     if (is_set($arFields, "SITE_ID") && strlen($arFields["SITE_ID"]) > 0) {
         $arFields["LID"] = $arFields["SITE_ID"];
     }
     if ((is_set($arFields, "LID") || $ACTION == "ADD") && strlen($arFields["LID"]) <= 0) {
         $APPLICATION->ThrowException(Loc::getMessage("SKGO_EMPTY_SITE"), "EMPTY_SITE_ID");
         return false;
     }
     if ((is_set($arFields, "PERSON_TYPE_ID") || $ACTION == "ADD") && IntVal($arFields["PERSON_TYPE_ID"]) <= 0) {
         $APPLICATION->ThrowException(Loc::getMessage("SKGO_EMPTY_PERS_TYPE"), "EMPTY_PERSON_TYPE_ID");
         return false;
     }
     if ((is_set($arFields, "USER_ID") || $ACTION == "ADD") && IntVal($arFields["USER_ID"]) <= 0) {
         $APPLICATION->ThrowException(Loc::getMessage("SKGO_EMPTY_USER_ID"), "EMPTY_USER_ID");
         return false;
     }
     if (is_set($arFields, "PAYED") && $arFields["PAYED"] != "Y") {
         $arFields["PAYED"] = "N";
     }
     if (is_set($arFields, "CANCELED") && $arFields["CANCELED"] != "Y") {
         $arFields["CANCELED"] = "N";
     }
     if (is_set($arFields, "STATUS_ID") && strlen($arFields["STATUS_ID"]) <= 0) {
         $arFields["STATUS_ID"] = "N";
     }
     if (is_set($arFields, "ALLOW_DELIVERY") && $arFields["ALLOW_DELIVERY"] != "Y") {
         $arFields["ALLOW_DELIVERY"] = "N";
     }
     if (is_set($arFields, "EXTERNAL_ORDER") && $arFields["EXTERNAL_ORDER"] != "Y") {
         $arFields["EXTERNAL_ORDER"] = "N";
     }
     if (is_set($arFields, "PRICE") || $ACTION == "ADD") {
         $arFields["PRICE"] = str_replace(",", ".", $arFields["PRICE"]);
         $arFields["PRICE"] = DoubleVal($arFields["PRICE"]);
     }
     if (is_set($arFields, "PRICE_DELIVERY") || $ACTION == "ADD") {
         $arFields["PRICE_DELIVERY"] = str_replace(",", ".", $arFields["PRICE_DELIVERY"]);
         $arFields["PRICE_DELIVERY"] = DoubleVal($arFields["PRICE_DELIVERY"]);
     }
     if (is_set($arFields, "SUM_PAID") || $ACTION == "ADD") {
         $arFields["SUM_PAID"] = str_replace(",", ".", $arFields["SUM_PAID"]);
         $arFields["SUM_PAID"] = DoubleVal($arFields["SUM_PAID"]);
     }
     if (is_set($arFields, "DISCOUNT_VALUE") || $ACTION == "ADD") {
         $arFields["DISCOUNT_VALUE"] = str_replace(",", ".", $arFields["DISCOUNT_VALUE"]);
         $arFields["DISCOUNT_VALUE"] = DoubleVal($arFields["DISCOUNT_VALUE"]);
     }
     if (is_set($arFields, "TAX_VALUE") || $ACTION == "ADD") {
         $arFields["TAX_VALUE"] = str_replace(",", ".", $arFields["TAX_VALUE"]);
         $arFields["TAX_VALUE"] = DoubleVal($arFields["TAX_VALUE"]);
     }
     if (!is_set($arFields, "LOCKED_BY") && (!is_set($arFields, "UPDATED_1C") || is_set($arFields, "UPDATED_1C") && $arFields["UPDATED_1C"] != "Y")) {
         $arFields["UPDATED_1C"] = "N";
         $arFields["~VERSION"] = "VERSION+0+1";
     }
     if ((is_set($arFields, "CURRENCY") || $ACTION == "ADD") && strlen($arFields["CURRENCY"]) <= 0) {
         $APPLICATION->ThrowException(Loc::getMessage("SKGO_EMPTY_CURRENCY"), "EMPTY_CURRENCY");
         return false;
     }
     if (is_set($arFields, "CURRENCY")) {
         if (!($arCurrency = CCurrency::GetByID($arFields["CURRENCY"]))) {
             $APPLICATION->ThrowException(str_replace("#ID#", $arFields["CURRENCY"], Loc::getMessage("SKGO_WRONG_CURRENCY")), "ERROR_NO_CURRENCY");
             return false;
         }
     }
     if (is_set($arFields, "LID")) {
         $dbSite = CSite::GetByID($arFields["LID"]);
         if (!$dbSite->Fetch()) {
             $APPLICATION->ThrowException(str_replace("#ID#", $arFields["LID"], Loc::getMessage("SKGO_WRONG_SITE")), "ERROR_NO_SITE");
             return false;
         }
     }
     if (is_set($arFields, "USER_ID")) {
         $dbUser = CUser::GetByID($arFields["USER_ID"]);
         if (!$dbUser->Fetch()) {
             $APPLICATION->ThrowException(str_replace("#ID#", $arFields["USER_ID"], Loc::getMessage("SKGO_WRONG_USER")), "ERROR_NO_USER_ID");
             return false;
         }
     }
     if (is_set($arFields, "PERSON_TYPE_ID")) {
         if (!($arPersonType = CSalePersonType::GetByID($arFields["PERSON_TYPE_ID"]))) {
             $APPLICATION->ThrowException(str_replace("#ID#", $arFields["PERSON_TYPE_ID"], Loc::getMessage("SKGO_WRONG_PERSON_TYPE")), "ERROR_NO_PERSON_TYPE");
             return false;
         }
     }
     if (is_set($arFields, "PAY_SYSTEM_ID") && IntVal($arFields["PAY_SYSTEM_ID"]) > 0) {
         if (!($arPaySystem = CSalePaySystem::GetByID(IntVal($arFields["PAY_SYSTEM_ID"])))) {
             $APPLICATION->ThrowException(str_replace("#ID#", $arFields["PAY_SYSTEM_ID"], Loc::getMessage("SKGO_WRONG_PS")), "ERROR_NO_PAY_SYSTEM");
             return false;
         }
     }
     if (is_set($arFields, "DELIVERY_ID") && IntVal($arFields["DELIVERY_ID"]) > 0) {
         if (!($delivery = \Bitrix\Sale\Delivery\Services\Table::getById($arFields["DELIVERY_ID"]))) {
             $APPLICATION->ThrowException(str_replace("#ID#", $arFields["DELIVERY_ID"], Loc::getMessage("SKGO_WRONG_DELIVERY")), "ERROR_NO_DELIVERY");
             return false;
         }
     }
     if (is_set($arFields, "STATUS_ID")) {
         if (!($arStatus = CSaleStatus::GetByID($arFields["STATUS_ID"]))) {
             $APPLICATION->ThrowException(str_replace("#ID#", $arFields["STATUS_ID"], Loc::getMessage("SKGO_WRONG_STATUS")), "ERROR_NO_STATUS_ID");
             return false;
         }
     }
     if (is_set($arFields, "ACCOUNT_NUMBER") && $ACTION == "UPDATE") {
         if (strlen($arFields["ACCOUNT_NUMBER"]) <= 0) {
             $APPLICATION->ThrowException(Loc::getMessage("SKGO_EMPTY_ACCOUNT_NUMBER"), "EMPTY_ACCOUNT_NUMBER");
             return false;
         } else {
             $dbres = $DB->Query("SELECT ID, ACCOUNT_NUMBER FROM b_sale_order WHERE ACCOUNT_NUMBER = '" . $DB->ForSql($arFields["ACCOUNT_NUMBER"]) . "'", true);
             if ($arRes = $dbres->GetNext()) {
                 if (is_array($arRes) && $arRes["ID"] != $ID) {
                     $APPLICATION->ThrowException(Loc::getMessage("SKGO_EXISTING_ACCOUNT_NUMBER"), "EXISTING_ACCOUNT_NUMBER");
                     return false;
                 }
             }
         }
     }
     if ($ACTION == "ADD") {
         $arFields["VERSION"] = 1;
     }
     if (!$USER_FIELD_MANAGER->CheckFields("ORDER", $ID, $arFields)) {
         return false;
     }
     return True;
 }
Exemple #25
0
 /**
  * Function returns reference data as shared cache between this component and sale.personal.order.list.
  *
  * @throws Exception
  * @return void
  */
 protected function obtainDataReferences()
 {
     if ($this->startCache(array('spo-shared'))) {
         try {
             $cachedData = array();
             /////////////////////
             /////////////////////
             // Person type
             $dbPType = CSalePersonType::GetList(array("SORT" => "ASC"));
             while ($arPType = $dbPType->Fetch()) {
                 $cachedData['PERSON_TYPE'][$arPType["ID"]] = $arPType;
             }
             // Save statuses for Filter form
             $dbStatus = CSaleStatus::GetList(array("SORT" => "ASC"), array("LID" => LANGUAGE_ID));
             while ($arStatus = $dbStatus->Fetch()) {
                 $cachedData['STATUS'][$arStatus["ID"]] = $arStatus;
             }
             $dbPaySystem = CSalePaySystem::GetList(array("SORT" => "ASC"));
             while ($arPaySystem = $dbPaySystem->Fetch()) {
                 $cachedData['PAYSYS'][$arPaySystem["ID"]] = $arPaySystem;
             }
             $dbDelivery = CSaleDelivery::GetList(array("SORT" => "ASC"));
             while ($arDelivery = $dbDelivery->Fetch()) {
                 $cachedData['DELIVERY'][$arDelivery["ID"]] = $arDelivery;
             }
             $dbDelivery = CSaleDeliveryHandler::GetList(array(), array(array("SITE_ID" => SITE_ID)));
             while ($arDeliveryHandler = $dbDelivery->Fetch()) {
                 $cachedData['DELIVERY_HANDLERS'][$arDeliveryHandler["SID"]] = $arDeliveryHandler;
             }
             /////////////////////
             /////////////////////
         } catch (Exception $e) {
             $this->abortCache();
             throw $e;
         }
         $this->endCache($cachedData);
     } else {
         $cachedData = $this->getCacheData();
     }
     $this->dbResult = array_merge($this->dbResult, $this->adaptCachedReferences($cachedData));
 }
         }
     }
     $arResultItem["DETAIL_PICTURE_SRC"] = "";
     if (isset($arResultItem["DETAIL_PICTURE"]) && intval($arResultItem["DETAIL_PICTURE"]) > 0) {
         $arImage = CFile::GetFileArray($arResultItem["DETAIL_PICTURE"]);
         if ($arImage) {
             $arFileTmp = CFile::ResizeImageGet($arImage, array("width" => "110", "height" => "110"), BX_RESIZE_IMAGE_PROPORTIONAL, true);
             $arResultItem["DETAIL_PICTURE_SRC"] = $arFileTmp["src"];
         }
     }
 }
 if (isset($arResultItem)) {
     unset($arResultItem);
 }
 /* Person Type Begin */
 $dbPersonType = CSalePersonType::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("LID" => SITE_ID, "ACTIVE" => "Y"));
 while ($arPersonType = $dbPersonType->GetNext()) {
     if ($arUserResult["PERSON_TYPE_ID"] == $arPersonType["ID"] || IntVal($arUserResult["PERSON_TYPE_ID"]) <= 0) {
         $arUserResult["PERSON_TYPE_ID"] = $arPersonType["ID"];
         $arPersonType["CHECKED"] = "Y";
     }
     $arResult["PERSON_TYPE"][$arPersonType["ID"]] = $arPersonType;
 }
 foreach (GetModuleEvents("sale", "OnSaleComponentOrderOneStepPersonType", true) as $arEvent) {
     ExecuteModuleEventEx($arEvent, array(&$arResult, &$arUserResult, &$arParams));
 }
 /* Person Type End */
 /* User Profiles Begin */
 $bFirst = false;
 $dbUserProfiles = CSaleOrderUserProps::GetList(array("DATE_UPDATE" => "DESC"), array("PERSON_TYPE_ID" => $arUserResult["PERSON_TYPE_ID"], "USER_ID" => IntVal($USER->GetID())));
 while ($arUserProfiles = $dbUserProfiles->GetNext()) {
Exemple #27
0
	public static function SelectBox($sFieldName, $sValue, $sDefaultValue = "", $bFullName = True, $JavaFunc = "", $sAddParams = "")
	{
		if (!isset($GLOBALS["SALE_PERSON_TYPE_LIST_CACHE"]) || !is_array($GLOBALS["SALE_PERSON_TYPE_LIST_CACHE"]) || count($GLOBALS["SALE_PERSON_TYPE_LIST_CACHE"])<1)
		{
			unset($GLOBALS["SALE_PERSON_TYPE_LIST_CACHE"]);
			$l = CSalePersonType::GetList(array("SORT" => "ASC", "NAME" => "ASC"));
			while ($arPersonType = $l->Fetch())
			{
				$GLOBALS["SALE_PERSON_TYPE_LIST_CACHE"][$arPersonType["ID"]] = Array("ID" => $arPersonType["ID"], "NAME" => $arPersonType["NAME"], "LID" => implode(", ", $arPersonType["LIDS"]));
			}
		}
		$s = '<select name="'.$sFieldName.'"';
		if (strlen($sAddParams)>0) $s .= ' '.$sAddParams.'';
		if (strlen($JavaFunc)>0) $s .= ' OnChange="'.$JavaFunc.'"';
		$s .= '>'."\n";
		$found = false;
		foreach ($GLOBALS["SALE_PERSON_TYPE_LIST_CACHE"] as $res)
		{
			$found = (IntVal($res["ID"]) == IntVal($sValue));
			$s1 .= '<option value="'.$res["ID"].'"'.($found ? ' selected':'').'>'.(($bFullName)?("[".$res["ID"]."] ".htmlspecialcharsbx($res["NAME"])." (".htmlspecialcharsbx($res["LID"]).")"):(htmlspecialcharsbx($res["NAME"]))).'</option>'."\n";
		}
		if (strlen($sDefaultValue)>0) 
			$s .= "<option value='' ".($found ? "" : "selected").">".htmlspecialcharsbx($sDefaultValue)."</option>";
		return $s.$s1.'</select>';
	}
Exemple #28
0
 public static function getPersonTypesNames($arPersonTypeIds)
 {
     $arPersonTypes = array();
     $dbPers = CSalePersonType::GetList(array(), array("ID" => $arPersonTypeIds), false, false, array("ID", "NAME"));
     while ($arPers = $dbPers->Fetch()) {
         $arPersonTypes[$arPers["ID"]] = htmlspecialcharsbx($arPers["NAME"]);
     }
     return $arPersonTypes;
 }
Exemple #29
0
 public function getBasketItems()
 {
     global $APPLICATION;
     if (self::$catalogIncluded === null) {
         self::$catalogIncluded = Loader::includeModule('catalog');
     }
     self::$iblockIncluded = self::$catalogIncluded;
     CSaleBasket::UpdateBasketPrices(CSaleBasket::GetBasketUserID(), SITE_ID);
     $bShowReady = false;
     $bShowDelay = false;
     $bShowSubscribe = false;
     $bShowNotAvail = false;
     $allSum = 0;
     $allWeight = 0;
     $allCurrency = CSaleLang::GetLangCurrency(SITE_ID);
     $allVATSum = 0;
     $arParents = array();
     $arResult["ITEMS"]["AnDelCanBuy"] = array();
     $arResult["ITEMS"]["DelDelCanBuy"] = array();
     $arResult["ITEMS"]["nAnCanBuy"] = array();
     $arResult["ITEMS"]["ProdSubscribe"] = array();
     $DISCOUNT_PRICE_ALL = 0;
     // BASKET PRODUCTS (including measures, ratio, iblock properties data)
     $arImgFields = array("PREVIEW_PICTURE", "DETAIL_PICTURE");
     $arBasketItems = array();
     $basketKey = 0;
     $basketIds = array();
     $arSku2Parent = array();
     $arSetParentWeight = array();
     $arElementId = array();
     $dbItems = CSaleBasket::GetList(array("ID" => "ASC"), array("FUSER_ID" => CSaleBasket::GetBasketUserID(), "LID" => SITE_ID, "ORDER_ID" => "NULL"), false, false, array("ID", "NAME", "CALLBACK_FUNC", "MODULE", "PRODUCT_ID", "QUANTITY", "DELAY", "CAN_BUY", "PRICE", "WEIGHT", "DETAIL_PAGE_URL", "NOTES", "CURRENCY", "VAT_RATE", "CATALOG_XML_ID", "PRODUCT_XML_ID", "SUBSCRIBE", "DISCOUNT_PRICE", "PRODUCT_PROVIDER_CLASS", "TYPE", "SET_PARENT_ID"));
     while ($arItem = $dbItems->GetNext()) {
         $arItem['PROPS'] = array();
         $arBasketItems[$basketKey] = $arItem;
         $basketIds[$arItem['ID']] =& $arBasketItems[$basketKey];
         $basketKey++;
         if (CSaleBasketHelper::isSetItem($arItem)) {
             continue;
         }
         $arElementId[] = $arItem["PRODUCT_ID"];
     }
     if (!empty($arElementId) && self::$catalogIncluded) {
         $productList = CCatalogSKU::getProductList($arElementId);
         if (!empty($productList)) {
             foreach ($productList as $offerId => $offerInfo) {
                 $offerInfo['PRODUCT_ID'] = $offerInfo['ID'];
                 $arElementId[] = $offerInfo['ID'];
                 $arSku2Parent[$offerId] = $offerInfo['ID'];
                 $arParents[$offerId] = $offerInfo;
             }
             unset($offerInfo, $offerId);
         }
         unset($productList);
         // get measures, ratio, sku props data and available quantity
         $arBasketItems = getMeasures($arBasketItems);
         $arBasketItems = getRatio($arBasketItems);
         $arBasketItems = $this->getAvailableQuantity($arBasketItems);
         $propsIterator = CSaleBasket::GetPropsList(array('BASKET_ID' => 'ASC', 'SORT' => 'ASC', 'ID' => 'ASC'), array('BASKET_ID' => array_keys($basketIds)));
         while ($property = $propsIterator->GetNext()) {
             $property['CODE'] = (string) $property['CODE'];
             if ($property['CODE'] == 'CATALOG.XML_ID' || $property['CODE'] == 'PRODUCT.XML_ID') {
                 continue;
             }
             if (!isset($basketIds[$property['BASKET_ID']])) {
                 continue;
             }
             $basketIds[$property['BASKET_ID']]['PROPS'][] = $property;
         }
         unset($property, $propsIterator, $basketIds);
     }
     // get product properties data
     $arProductData = getProductProps($arElementId, array_merge(array("ID"), $arImgFields, $this->arCustomSelectFields));
     foreach ($arBasketItems as &$arItem) {
         $quantityIsFloat = false;
         if (number_format(doubleval($arItem['QUANTITY']), 2, '.', '') != intval($arItem['QUANTITY'])) {
             $quantityIsFloat = true;
         }
         $arItem["QUANTITY"] = $quantityIsFloat === false && $this->quantityFloat != "Y" ? intval($arItem['QUANTITY']) : number_format(doubleval($arItem['QUANTITY']), 2, '.', '');
         $arItem["PRICE_VAT_VALUE"] = $arItem["PRICE"] / ($arItem["VAT_RATE"] + 1) * $arItem["VAT_RATE"];
         $arItem["PRICE_FORMATED"] = CCurrencyLang::CurrencyFormat($arItem["PRICE"], $arItem["CURRENCY"], true);
         $arItem["WEIGHT"] = doubleval($arItem["WEIGHT"]);
         $arItem["WEIGHT_FORMATED"] = roundEx(doubleval($arItem["WEIGHT"] / $this->weightKoef), SALE_WEIGHT_PRECISION) . " " . $this->weightUnit;
         if (CSaleBasketHelper::isSetItem($arItem)) {
             $arSetParentWeight[$arItem["SET_PARENT_ID"]] += $arItem["WEIGHT"] * $arItem["QUANTITY"];
         }
         if (isset($arProductData[$arItem['PRODUCT_ID']]) && is_array($arProductData[$arItem['PRODUCT_ID']])) {
             foreach ($arProductData[$arItem["PRODUCT_ID"]] as $key => $value) {
                 if (strpos($key, "PROPERTY_") !== false || in_array($key, $arImgFields)) {
                     $arItem[$key] = $value;
                 }
             }
         }
         if (array_key_exists($arItem["PRODUCT_ID"], $arSku2Parent)) {
             $arFieldsToFill = array_merge($this->arCustomSelectFields, $arImgFields);
             // fields to be filled with parents' values if empty
             foreach ($arFieldsToFill as $field) {
                 $fieldVal = in_array($field, $arImgFields) ? $field : $field . "_VALUE";
                 $parentId = $arSku2Parent[$arItem["PRODUCT_ID"]];
                 if ((!isset($arItem[$fieldVal]) || isset($arItem[$fieldVal]) && strlen($arItem[$fieldVal]) == 0) && (isset($arProductData[$parentId][$fieldVal]) && !empty($arProductData[$parentId][$fieldVal]))) {
                     $arItem[$fieldVal] = $arProductData[$parentId][$fieldVal];
                 }
             }
         }
         foreach ($arItem as $key => $value) {
             if (strpos($key, "PROPERTY_", 0) === 0 && strrpos($key, "_VALUE") == strlen($key) - 6) {
                 $code = str_replace(array("PROPERTY_", "_VALUE"), "", $key);
                 $propData = $this->arIblockProps[$code];
                 $arItem[$key] = CSaleHelper::getIblockPropInfo($value, $propData);
             }
         }
         $arItem["PREVIEW_PICTURE_SRC"] = "";
         if (isset($arItem["PREVIEW_PICTURE"]) && intval($arItem["PREVIEW_PICTURE"]) > 0) {
             $arImage = CFile::GetFileArray($arItem["PREVIEW_PICTURE"]);
             if ($arImage) {
                 $arFileTmp = CFile::ResizeImageGet($arImage, array("width" => "110", "height" => "110"), BX_RESIZE_IMAGE_PROPORTIONAL, true);
                 $arItem["PREVIEW_PICTURE_SRC"] = $arFileTmp["src"];
             }
         }
         $arItem["DETAIL_PICTURE_SRC"] = "";
         if (isset($arItem["DETAIL_PICTURE"]) && intval($arItem["DETAIL_PICTURE"]) > 0) {
             $arImage = CFile::GetFileArray($arItem["DETAIL_PICTURE"]);
             if ($arImage) {
                 $arFileTmp = CFile::ResizeImageGet($arImage, array("width" => "110", "height" => "110"), BX_RESIZE_IMAGE_PROPORTIONAL, true);
                 $arItem["DETAIL_PICTURE_SRC"] = $arFileTmp["src"];
             }
         }
     }
     unset($arItem);
     // get sku props data
     if (!empty($arBasketItems) && self::$catalogIncluded && isset($this->offersProps) && !empty($this->offersProps)) {
         $arBasketItems = $this->getSkuPropsData($arBasketItems, $arParents, $this->offersProps);
     }
     // count weight for set parent products
     foreach ($arBasketItems as &$arItem) {
         if (CSaleBasketHelper::isSetParent($arItem)) {
             $arItem["WEIGHT"] = $arSetParentWeight[$arItem["ID"]] / $arItem["QUANTITY"];
             $arItem["WEIGHT_FORMATED"] = roundEx(doubleval($arItem["WEIGHT"] / $this->weightKoef), SALE_WEIGHT_PRECISION) . " " . $this->weightUnit;
         }
     }
     if (isset($arItem)) {
         unset($arItem);
     }
     // fill item arrays for old templates
     foreach ($arBasketItems as &$arItem) {
         if (CSaleBasketHelper::isSetItem($arItem)) {
             continue;
         }
         $arItem['DISCOUNT_PRICE'] = (double) $arItem['DISCOUNT_PRICE'];
         $arItem['PRICE'] = (double) $arItem['PRICE'];
         $arItem['DISCOUNT_PRICE_PERCENT'] = 0;
         $arItem['DISCOUNT_PRICE_PERCENT_FORMATED'] = '';
         $arItem['FULL_PRICE'] = $arItem['PRICE'];
         if ($arItem['DISCOUNT_PRICE'] > 0) {
             if ($arItem['DISCOUNT_PRICE'] + $arItem['PRICE'] > 0) {
                 $arItem['DISCOUNT_PRICE_PERCENT'] = $arItem['DISCOUNT_PRICE'] * 100 / ($arItem['DISCOUNT_PRICE'] + $arItem['PRICE']);
                 $arItem['DISCOUNT_PRICE_PERCENT_FORMATED'] = roundEx($arItem['DISCOUNT_PRICE_PERCENT'], SALE_VALUE_PRECISION) . '%';
                 $arItem['FULL_PRICE'] = $arItem["PRICE"] + $arItem["DISCOUNT_PRICE"];
             }
         }
         $arItem['FULL_PRICE_FORMATED'] = CCurrencyLang::CurrencyFormat($arItem['FULL_PRICE'], $arItem['CURRENCY'], true);
         if ($arItem["CAN_BUY"] == "Y" && $arItem["DELAY"] == "N") {
             $allSum += $arItem["PRICE"] * $arItem["QUANTITY"];
             $allWeight += $arItem["WEIGHT"] * $arItem["QUANTITY"];
             $allVATSum += roundEx($arItem["PRICE_VAT_VALUE"] * $arItem["QUANTITY"], SALE_VALUE_PRECISION);
             $bShowReady = true;
             if ($arItem["DISCOUNT_PRICE"] > 0) {
                 $DISCOUNT_PRICE_ALL += $arItem["DISCOUNT_PRICE"] * $arItem["QUANTITY"];
             }
             $arResult["ITEMS"]["AnDelCanBuy"][] = $arItem;
         } elseif ($arItem["CAN_BUY"] == "Y" && $arItem["DELAY"] == "Y") {
             $bShowDelay = true;
             $arResult["ITEMS"]["DelDelCanBuy"][] = $arItem;
         } elseif ($arItem["CAN_BUY"] == "N" && $arItem["SUBSCRIBE"] == "Y") {
             $bShowSubscribe = true;
             $arResult["ITEMS"]["ProdSubscribe"][] = $arItem;
         } else {
             $bShowNotAvail = true;
             $arItem["NOT_AVAILABLE"] = true;
             $arResult["ITEMS"]["nAnCanBuy"][] = $arItem;
         }
     }
     unset($arItem);
     $arResult["ShowReady"] = $bShowReady ? "Y" : "N";
     $arResult["ShowDelay"] = $bShowDelay ? "Y" : "N";
     $arResult["ShowNotAvail"] = $bShowNotAvail ? "Y" : "N";
     $arResult["ShowSubscribe"] = $bShowSubscribe ? "Y" : "N";
     $arOrder = array('SITE_ID' => SITE_ID, 'USER_ID' => $GLOBALS["USER"]->GetID(), 'ORDER_PRICE' => $allSum, 'ORDER_WEIGHT' => $allWeight, 'BASKET_ITEMS' => $arResult["ITEMS"]["AnDelCanBuy"]);
     $arOptions = array('COUNT_DISCOUNT_4_ALL_QUANTITY' => $this->countDiscount4AllQuantity);
     $arErrors = array();
     CSaleDiscount::DoProcessOrder($arOrder, $arOptions, $arErrors);
     if (isset($arOrder['ORDER_PRICE'])) {
         $roundOrderFields = CSaleOrder::getRoundFields();
         foreach ($arOrder as $fieldName => $fieldValue) {
             if (in_array($fieldName, $roundOrderFields)) {
                 $arOrder[$fieldName] = roundEx($arOrder[$fieldName], SALE_VALUE_PRECISION);
             }
         }
     }
     if (!empty($arOrder['BASKET_ITEMS']) && is_array($arOrder['BASKET_ITEMS'])) {
         $arOrder['ORDER_PRICE'] = 0;
         $roundBasketFields = CSaleBasket::getRoundFields();
         foreach ($arOrder['BASKET_ITEMS'] as &$basketItem) {
             foreach ($basketItem as $fieldName => $fieldValue) {
                 if (in_array($fieldName, $roundBasketFields)) {
                     if (isset($basketItem[$fieldName])) {
                         $basketItem[$fieldName] = roundEx($basketItem[$fieldName], SALE_VALUE_PRECISION);
                     }
                 }
             }
             $arOrder['ORDER_PRICE'] += $basketItem['PRICE'] * $basketItem['QUANTITY'];
         }
         $arOrder['ORDER_PRICE'] = roundEx($arOrder['ORDER_PRICE'], SALE_VALUE_PRECISION);
     }
     $allSum = 0;
     $allWeight = 0;
     $allVATSum = 0;
     $DISCOUNT_PRICE_ALL = 0;
     $priceWithoutDiscount = 0;
     foreach ($arOrder["BASKET_ITEMS"] as &$arOneItem) {
         $allWeight += $arOneItem["WEIGHT"] * $arOneItem["QUANTITY"];
         $allSum += $arOneItem["PRICE"] * $arOneItem["QUANTITY"];
         if (array_key_exists('VAT_VALUE', $arOneItem)) {
             $arOneItem["PRICE_VAT_VALUE"] = $arOneItem["VAT_VALUE"];
         }
         $allVATSum += roundEx($arOneItem["PRICE_VAT_VALUE"] * $arOneItem["QUANTITY"], SALE_VALUE_PRECISION);
         $arOneItem["PRICE_FORMATED"] = CCurrencyLang::CurrencyFormat($arOneItem["PRICE"], $arOneItem["CURRENCY"], true);
         $arOneItem["FULL_PRICE"] = $arOneItem["PRICE"] + $arOneItem["DISCOUNT_PRICE"];
         $arOneItem["FULL_PRICE_FORMATED"] = CCurrencyLang::CurrencyFormat($arOneItem["FULL_PRICE"], $arOneItem["CURRENCY"], true);
         $arOneItem["SUM"] = CCurrencyLang::CurrencyFormat($arOneItem["PRICE"] * $arOneItem["QUANTITY"], $arOneItem["CURRENCY"], true);
         if (0 < doubleval($arOneItem["DISCOUNT_PRICE"] + $arOneItem["PRICE"])) {
             $arOneItem["DISCOUNT_PRICE_PERCENT"] = $arOneItem["DISCOUNT_PRICE"] * 100 / ($arOneItem["DISCOUNT_PRICE"] + $arOneItem["PRICE"]);
         } else {
             $arOneItem["DISCOUNT_PRICE_PERCENT"] = 0;
         }
         $arOneItem["DISCOUNT_PRICE_PERCENT_FORMATED"] = roundEx($arOneItem["DISCOUNT_PRICE_PERCENT"], SALE_VALUE_PRECISION) . "%";
         $DISCOUNT_PRICE_ALL += $arOneItem["DISCOUNT_PRICE"] * $arOneItem["QUANTITY"];
     }
     unset($arOneItem);
     $arResult["ITEMS"]["AnDelCanBuy"] = $arOrder["BASKET_ITEMS"];
     // fill grid data (for new templates with custom columns)
     foreach ($arResult["ITEMS"] as $type => $arItems) {
         foreach ($arItems as $k => $arItem) {
             $arResult["GRID"]["ROWS"][$arItem["ID"]] = $arItem;
         }
     }
     $arResult["allSum"] = roundEx($allSum, SALE_VALUE_PRECISION);
     $arResult["allWeight"] = $allWeight;
     $arResult["allWeight_FORMATED"] = roundEx(doubleval($allWeight / $this->weightKoef), SALE_WEIGHT_PRECISION) . " " . $this->weightUnit;
     $arResult["allSum_FORMATED"] = CCurrencyLang::CurrencyFormat($allSum, $allCurrency, true);
     $arResult["DISCOUNT_PRICE_FORMATED"] = CCurrencyLang::CurrencyFormat($arResult["DISCOUNT_PRICE"], $allCurrency, true);
     $arResult["PRICE_WITHOUT_DISCOUNT"] = CCurrencyLang::CurrencyFormat($allSum + $DISCOUNT_PRICE_ALL, $allCurrency, true);
     if ($this->priceVatShowValue == 'Y') {
         $arResult["allVATSum"] = roundEx($allVATSum, SALE_VALUE_PRECISION);
         $arResult["allVATSum_FORMATED"] = CCurrencyLang::CurrencyFormat($allVATSum, $allCurrency, true);
         $arResult["allSum_wVAT_FORMATED"] = CCurrencyLang::CurrencyFormat(doubleval($arResult["allSum"] - $allVATSum), $allCurrency, true);
     }
     $arResult['COUPON_LIST'] = array();
     $arResult['COUPON'] = '';
     if ($this->hideCoupon != "Y") {
         $arCoupons = DiscountCouponsManager::get(true, array(), true, true);
         if (!empty($arCoupons)) {
             foreach ($arCoupons as &$oneCoupon) {
                 if ($arResult['COUPON'] == '') {
                     $arResult['COUPON'] = $oneCoupon['COUPON'];
                 }
                 if ($oneCoupon['STATUS'] == DiscountCouponsManager::STATUS_NOT_FOUND || $oneCoupon['STATUS'] == DiscountCouponsManager::STATUS_FREEZE) {
                     $oneCoupon['JS_STATUS'] = 'BAD';
                 } elseif ($oneCoupon['STATUS'] == DiscountCouponsManager::STATUS_NOT_APPLYED || $oneCoupon['STATUS'] == DiscountCouponsManager::STATUS_ENTERED) {
                     $oneCoupon['JS_STATUS'] = 'ENTERED';
                 } else {
                     $oneCoupon['JS_STATUS'] = 'APPLYED';
                 }
                 $oneCoupon['JS_CHECK_CODE'] = '';
                 if (isset($oneCoupon['CHECK_CODE_TEXT'])) {
                     $oneCoupon['JS_CHECK_CODE'] = is_array($oneCoupon['CHECK_CODE_TEXT']) ? implode('<br>', $oneCoupon['CHECK_CODE_TEXT']) : $oneCoupon['CHECK_CODE_TEXT'];
                 }
                 $arResult['COUPON_LIST'][] = $oneCoupon;
             }
             unset($oneCoupon);
             $arResult['COUPON_LIST'] = array_values($arCoupons);
         }
         unset($arCoupons);
     }
     if (empty($arBasketItems)) {
         $arResult["ERROR_MESSAGE"] = Loc::getMessage("SALE_EMPTY_BASKET");
     }
     $arResult["DISCOUNT_PRICE_ALL"] = $DISCOUNT_PRICE_ALL;
     $arResult["DISCOUNT_PRICE_ALL_FORMATED"] = CCurrencyLang::CurrencyFormat($DISCOUNT_PRICE_ALL, $allCurrency, true);
     if ($this->usePrepayment == "Y") {
         if (doubleval($arResult["allSum"]) > 0) {
             $personType = array();
             $dbPersonType = CSalePersonType::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("LID" => SITE_ID, "ACTIVE" => "Y"));
             while ($arPersonType = $dbPersonType->Fetch()) {
                 $personType[] = $arPersonType["ID"];
             }
             if (!empty($personType)) {
                 $dbPaySysAction = CSalePaySystemAction::GetList(array(), array("PS_ACTIVE" => "Y", "HAVE_PREPAY" => "Y", "PERSON_TYPE_ID" => $personType), false, false, array("ID", "PAY_SYSTEM_ID", "PERSON_TYPE_ID", "NAME", "ACTION_FILE", "RESULT_FILE", "NEW_WINDOW", "PARAMS", "ENCODING", "LOGOTIP"));
                 if ($arPaySysAction = $dbPaySysAction->Fetch()) {
                     CSalePaySystemAction::InitParamarrays(false, false, $arPaySysAction["PARAMS"]);
                     $pathToAction = $_SERVER["DOCUMENT_ROOT"] . $arPaySysAction["ACTION_FILE"];
                     $pathToAction = str_replace("\\", "/", $pathToAction);
                     while (substr($pathToAction, strlen($pathToAction) - 1, 1) == "/") {
                         $pathToAction = substr($pathToAction, 0, strlen($pathToAction) - 1);
                     }
                     if (file_exists($pathToAction)) {
                         if (is_dir($pathToAction) && file_exists($pathToAction . "/pre_payment.php")) {
                             $pathToAction .= "/pre_payment.php";
                         }
                         try {
                             include_once $pathToAction;
                         } catch (\Bitrix\Main\SystemException $e) {
                             if ($e->getCode() == CSalePaySystemAction::GET_PARAM_VALUE) {
                                 $message = Loc::getMessage("SOA_TEMPL_ORDER_PS_ERROR");
                             } else {
                                 $message = $e->getMessage();
                             }
                             $arResult["ERROR_MESSAGE"] = $message;
                         }
                         $psPreAction = new CSalePaySystemPrePayment();
                         if ($psPreAction->init()) {
                             $orderData = array("PATH_TO_ORDER" => $this->pathToOrder, "AMOUNT" => $arResult["allSum"], "BASKET_ITEMS" => $arResult["ITEMS"]["AnDelCanBuy"]);
                             if (!$psPreAction->BasketButtonAction($orderData)) {
                                 if ($e = $APPLICATION->GetException()) {
                                     $arResult["WARNING_MESSAGE"][] = $e->GetString();
                                 }
                             }
                             $arResult["PREPAY_BUTTON"] = $psPreAction->BasketButtonShow();
                         }
                     }
                 }
             }
         }
     }
     return $arResult;
 }
Exemple #30
0
						<td valign="middle"><?
						$strBuyerProfileUrl = '';
						if (CBXFeatures::IsFeatureEnabled('SaleAccounts'))
						{
							$strBuyerProfileUrl = '/bitrix/admin/sale_buyers_profile.php?USER_ID='.$arOrder["USER_ID"].'&lang='.LANGUAGE_ID;
						}
						else
						{
							$strBuyerProfileUrl = '/bitrix/admin/user_edit.php?ID='.$arOrder["USER_ID"].'&lang='.LANGUAGE_ID;
						}
						?><a href="<? echo $strBuyerProfileUrl; ?>"><? echo htmlspecialcharsEx($arUser["LOGIN"]); ?></a></td>
					</tr>
					<tr>
						<td valign="top"><?echo GetMessage("P_ORDER_PERS_TYPE")?>:</td>
						<td valign="middle"><?
							$arPersonType = CSalePersonType::GetByID($arOrder["PERSON_TYPE_ID"]);
							echo htmlspecialcharsEx($arPersonType["NAME"]);
							?>
						</td>
					</tr>
					<?

					//disabled town
					$arTownOrderProps = array();
					$dbProperties = CSaleOrderProps::GetList(
						array(),
						array(
							"ORDER_ID" => $ID,
							"PERSON_TYPE_ID" => $arPersonType["ID"],
							"ACTIVE" => "Y",
							">INPUT_FIELD_LOCATION" => 0