Esempio n. 1
0
			}
			if ($bErrorField)
				$errorMessage .= GetMessage("SALE_NO_FIELD")." \"".$arOrderProps["NAME"]."\".<br />";
		}
	}

	if (strlen($errorMessage) <= 0)
	{
		$arFields = array("NAME" => $NAME);
		if (!CSaleOrderUserProps::Update($ID, $arFields))
			$errorMessage .= GetMessage("SALE_ERROR_EDIT_PROF")."<br />";
	}

	if (strlen($errorMessage) <= 0)
	{
		CSaleOrderUserPropsValue::DeleteAll($ID);

		$dbOrderProps = CSaleOrderProps::GetList(
				array("SORT" => "ASC", "NAME" => "ASC"),
				array(
						"PERSON_TYPE_ID" => $arUserProps["PERSON_TYPE_ID"],
						"USER_PROPS" => "Y", "ACTIVE" => "Y", "UTIL" => "N"
					),
				false,
				false,
				array("ID", "PERSON_TYPE_ID", "NAME", "TYPE", "REQUIED", "DEFAULT_VALUE", "SORT", "USER_PROPS", "IS_LOCATION", "PROPS_GROUP_ID", "SIZE1", "SIZE2", "DESCRIPTION", "IS_EMAIL", "IS_PROFILE_NAME", "IS_PAYER", "IS_LOCATION4TAX", "CODE", "SORT")
			);
		while ($arOrderProps = $dbOrderProps->GetNext())
		{
			$curVal = $_POST["ORDER_PROP_".$arOrderProps["ID"]];
			if ($arOrderProps["TYPE"]=="MULTISELECT")
Esempio n. 2
0
    static function Update($profileID, $arFields) {
        global $DB;

        $result = new WS_SaleUserProfilesErrorsContainer();
        if (empty($profileID)) {
            return $result->addErrorString(GetMessage("ws.saleuserprofiles_save_error_required_id"));
        }
        $DB->StartTransaction();

        if (!empty($arFields["PROPS"])) {
            $props = $arFields["PROPS"];
            unset($arFields["PROPS"]);
        }

        // сохраняем поля
        if (!empty($arFields)) {
            if(!$profileID = CSaleOrderUserProps::Update($profileID, $arFields)){
                $result->addErrorString(GetMessage("ws.saleuserprofiles_save_error_save_fields"));
            } else {
                $arFields = CSaleOrderUserProps::GetByID($profileID);
            }
        }

        // сохраняем свойства
        if (!empty($props) && !$result->getErrorsAsString()) {
            // удаляем все свойства
            CSaleOrderUserPropsValue::DeleteAll($profileID);
            $res = CSaleOrderProps::GetList(array(), array("PERSON_TYPE_ID" => $arFields["PERSON_TYPE_ID"], "USER_PROPS" => "Y"), false, false, array());
            while ($arRes = $res->Fetch()) {
                if ($arRes['REQUIED'] === 'Y' && empty($props[$arRes['ID']])) {
                    $result->addErrorString(GetMessage("ws.saleuserprofiles_save_error_required_field") . "\"" . $arRes["NAME"] . "\"");
                    continue;
                }

                $arValueTemp = $props[$arRes['ID']];
                if (is_array($arValueTemp)) {
                    $arValueTemp = "";

                    for ($i = 0; $i < count($props[$arRes['ID']]); $i++) {
                        if ($i > 0) {
                            $arValueTemp .= ",";
                        }
                        $arValueTemp .= $props[$arRes['ID']][$i];
                    }

                }

                $arProp = array(
                    "VALUE" => $arValueTemp,
                    "NAME" => $arRes["NAME"],
                    "ORDER_PROPS_ID" => $arRes['ID'],
                    "USER_PROPS_ID" => $profileID
                );
                CSaleOrderUserPropsValue::Add($arProp);
            }
        }

        if ($result->getErrorsAsString()) {
            $DB->Rollback();
        } else {
            $DB->Commit();
        }
        return $result;
    }