3use \Bitrix\Sale\Internals\DeliveryPaySystemTable;
4use \Bitrix\Sale\Delivery;
13 if(!is_array($oldDeliveryIds))
14 $oldDeliveryIds = trim(strval($oldDeliveryIds)) !=
"" ?
array($oldDeliveryIds) :
array();
16 if(!is_array($oldProfiles))
17 $oldProfiles = trim(strval($oldProfiles)) !=
"" ?
array($oldProfiles) :
array();
19 if(empty($oldDeliveryIds) && empty($oldProfiles))
26 if(!empty($oldDeliveryIds))
33 foreach($oldDeliveryIds as $id)
42 if(!empty($oldProfiles))
49 foreach($oldProfiles as $id)
55 $res = Delivery\Services\Table::getList(
array(
57 'select' =>
array(
"ID")
62 while($delivery =
$res->fetch())
98 if(is_array($arGroupBy) && !empty($arGroupBy))
99 $params[
'group'] = array_intersect($arGroupBy,
array(
"DELIVERY_ID",
"PAYSYSTEM_ID"));
117 while($record =
$res->fetch())
119 if($record[
'LINK_DIRECTION'] ==
'D')
121 if(!in_array($record[
"DELIVERY_ID"], $restricted[
'D']))
122 $restricted[
'D'][] = $record[
"DELIVERY_ID"];
124 elseif($record[
'LINK_DIRECTION'] ==
'P')
126 if(!in_array($record[
"DELIVERY_ID"], $restricted[
'P']))
127 $restricted[
'P'][] = $record[
"PAYSYSTEM_ID"];
130 $deliveryId = $record[
"DELIVERY_ID"];
131 $linkDirection = $record[
"LINK_DIRECTION"];
132 unset($record[
"LINK_DIRECTION"]);
135 $record[
"DELIVERY_ID"] = $delivery[
"SID"];
136 $record[
"DELIVERY_PROFILE_ID"] = isset($delivery[
"PROFILE"]) ? $delivery[
"PROFILE"] :
null;
137 $records[] = $record;
139 if(!empty($deliveryChildrenList[$deliveryId]))
141 foreach($deliveryChildrenList[$deliveryId] as $childrenId)
143 if($linkDirection ==
'D' && !in_array($childrenId, $restricted[
'D']))
144 $restricted[
'D'][] = $childrenId;
148 $record[
"DELIVERY_ID"] = $delivery[
"SID"];
149 $record[
"DELIVERY_PROFILE_ID"] = isset($delivery[
"PROFILE"]) ? $delivery[
"PROFILE"] :
null;
150 $records[] = $record;
155 foreach(self::getFullDeliveryList() as $dlvId)
157 if(in_array($dlvId, $restricted[
'D']))
164 "DELIVERY_ID" => $delivery[
"SID"],
165 "DELIVERY_PROFILE_ID" => isset($delivery[
"PROFILE"]) ? $delivery[
"PROFILE"] :
null
168 foreach(self::getFullPaySystemList() as $psId)
170 if(in_array($psId, $restricted[
'P']))
173 if(self::isRecordExists($record[
"DELIVERY_ID"], $record[
"DELIVERY_PROFILE_ID"], $psId, $records))
176 $record[
"PAYSYSTEM_ID"] = $psId;
177 $records[] = $record;
182 $result->InitFromArray($records);
186 protected static function isRecordExists($dlvId, $profile, $paySystemId, $records)
190 "DELIVERY_ID" => $dlvId,
191 "DELIVERY_PROFILE_ID" => $profile,
192 "PAYSYSTEM_ID" => $paySystemId
223 $parentId = intval($dlvParams[
"PARENT_ID"]);
243 'filter' =>
array(
'ACTIVE' =>
'Y')
246 while($ps =
$dbRes->fetch())
254 if($deliveryId ==
'')
259 $psInList = $dInList = $together =
false;
262 while($arPSRec = $dbPSRec->Fetch())
264 $psInRecord = $dInRecord =
false;
266 if($arPSRec[
"PAYSYSTEM_ID"] == $paySystemId)
267 $psInList = $psInRecord =
true;
269 if($arPSRec[
"DELIVERY_ID"] == $arDelivery[
"SID"]
272 is_null($arPSRec[
"DELIVERY_PROFILE_ID"])
274 $arPSRec[
"DELIVERY_PROFILE_ID"] == $arDelivery[
"PROFILE"]
278 $dInList = $dInRecord =
true;
281 if($dInRecord && $psInRecord)
290 elseif (!$psInList || !$dInList)
304 if(isset(
$arFields[
"DELIVERY_PROFILE_ID"]))
312 foreach (
$arFields[
"PAYSYSTEM_ID"] as $psId)
332 $arUpdateFields =
array(
"PAYSYSTEM_ID" =>
$ID);
342 $arRecords =
array();
349 if(!isset($delivery[
"SID"]))
352 $arUpdateFields[
"DELIVERY_ID"] = $delivery[
"SID"];
354 if(isset($delivery[
"PROFILE"]))
355 $arUpdateFields[
"DELIVERY_PROFILE_ID"] = $delivery[
"PROFILE"];
357 $arUpdateFields[
"DELIVERY_PROFILE_ID"] =
null;
360 $arRecords[] = $arUpdateFields;
373 $delParams .=
"PAYSYSTEM_ID=".intval(
$arFilter[
"PAYSYSTEM_ID"]);
382 $code .=
":".$arFilter[
"DELIVERY_PROFILE_ID"];
390 if(intval($deliveryId) > 0)
391 $delParams .=
"DELIVERY_ID=".intval($deliveryId);
415 $arFields[
"DELIVERY_ID"] .=
":".$arFields[
"DELIVERY_PROFILE_ID"];
static getConnection($name="")
static getActiveList($calculatingOnly=false, $restrictedIds=null)
static getList(array $params=array())
static getIdByCode($code)
static convertEmptyAllAgent()
static convertDeliveryIds($oldDeliveryIds=array(), $oldProfiles=array())
static isPaySystemApplicable($paySystemId, $deliveryId)
static GetList($arFilter=array(), $arGroupBy=false, $arSelectFields=array())
static getDeliveryChildrenList()
static getFullPaySystemList()
static UpdatePaySystem($ID, $arFields)
static getFullDeliveryList()
static UpdateDelivery($ID, $arFields)
static isRecordExists($dlvId, $profile, $paySystemId, $records)
static getDeliverySIDAndProfile($deliveryId)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']