51 if(
count($arErrors)>0)
53 foreach($arErrors as
$error)
59 if(
count($profileFields)>0)
61 $profile =
new static();
63 $profile->setFields($profileFields);
76 return $this->
getField(
'PERSON_TYPE_ID');
90 public function getId()
94 return $profile->getField(
'USER_PROFILE_ID');
102 return $this->
getField(
'USER_PROFILE_ID');
125 $property =
$params[
"ORDER_PROP"];
127 $propertyOrders = static::getPropertyOrdersByPersonalTypeId($profile->getPersonalTypeId());
129 if(is_array($propertyOrders))
131 foreach($propertyOrders as $filedsProperty)
133 $propertyId = $filedsProperty[
"ID"];
134 if(array_key_exists($propertyId, $property))
136 $propertyByConfigValue = $property[$propertyId];
137 if($profile->profileGetId()<=0)
139 if(!empty($propertyByConfigValue))
142 "NAME" =>
$fields[
"AGENT_NAME"],
143 "USER_ID" => $profile->getUserId(),
144 "PERSON_TYPE_ID" => $profile->getPersonalTypeId(),
146 "VERSION_1C" =>
$fields[
"VERSION_1C"]
149 $profile->setField(
"USER_PROFILE_ID", $profileId);
154 "USER_PROPS_ID" => $profile->profileGetId(),
155 "ORDER_PROPS_ID" => $propertyId,
156 "NAME" => $filedsProperty[
"NAME"],
157 "VALUE" => $propertyByConfigValue
177 $criterion = $this->getCurrentCriterion($profile);
180 $property =
$params[
"ORDER_PROP"];
182 if($criterion->equals(
$fields))
184 $fieldsProfileUpdate =
array(
185 "VERSION_1C" =>
$fields[
"VERSION_1C"],
186 "NAME" =>
$fields[
"AGENT_NAME"],
187 "USER_ID" => $profile->getUserId()
190 \CSaleOrderUserProps::Update($profile->profileGetId(), $fieldsProfileUpdate);
193 $profileFields = static::getFieldsUserProfile($profile->profileGetId());
194 foreach($profileFields as $fieldsProfile)
196 $fieldsProfileByProperty[$fieldsProfile[
"ORDER_PROPS_ID"]] =
array(
"ID" => $fieldsProfile[
"ID"],
"VALUE" => $fieldsProfile[
"VALUE"]);
199 $propertyOrders = static::getPropertyOrdersByPersonalTypeId($profile->getPersonalTypeId());
200 foreach($propertyOrders as $filedsProperty)
202 $propertyId = $filedsProperty[
"ID"];
203 if(array_key_exists($propertyId, $property))
205 $propertyByConfigValue = $property[$propertyId];
206 if(!empty($propertyByConfigValue))
209 "USER_PROPS_ID" => $profile->getField(
"USER_PROFILE_ID"),
210 "ORDER_PROPS_ID" => $propertyId,
211 "NAME" => $filedsProperty[
"NAME"],
212 "VALUE" => $propertyByConfigValue
215 if(empty($fieldsProfileByProperty[$propertyId]))
217 \CSaleOrderUserPropsValue::Add(
$fields);
219 elseif($fieldsProfileByProperty[$propertyId][
"VALUE"] != $propertyByConfigValue)
221 \CSaleOrderUserPropsValue::Update($fieldsProfileByProperty[$propertyId][
"ID"],
$fields);
268 array(
"ID",
"NAME",
"USER_ID",
"PERSON_TYPE_ID",
"XML_ID",
"VERSION_1C")
270 if (
$ar = $r->Fetch())
284 if(intval($profileId) <= 0)
288 while (
$ar = $r->Fetch())
303 static $profiles =
null;
305 if($profiles[
$fields[
'XML_ID']] ===
null)
308 $profile = static::getUserProfile(
array(
'XML_ID'=>
$fields[
'XML_ID']));
312 $result[
'USER_ID'] = $profile[
'USER_ID'];
313 $result[
'PERSON_TYPE_ID'] = $profile[
'PERSON_TYPE_ID'];
315 $result[
'USER_PROFILE_ID'] = $profile[
'ID'];
316 $result[
'USER_PROFILE_VERSION'] = $profile[
'VERSION_1C'];
318 $profileFields = static::getFieldsUserProfile($profile[
'ID']);
319 if(!empty($profileFields))
321 foreach($profileFields as $profileField)
323 $result[
'USER_PROPS'][$profileField[
"ORDER_PROPS_ID"]] = $profileField[
"VALUE"];
337 $result[
'USER_PROFILE_ID'] =
null;
338 $result[
'USER_PROFILE_VERSION'] =
null;
342 if(
count($arErrors)>0)
348 return $profiles[
$fields[
'XML_ID']];
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)