1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
profile.php
См. документацию.
1<?php
2
3namespace Sale\Handlers\Delivery;
4
5use Bitrix\Main\Error;
6use Bitrix\Sale\Shipment;
7use Bitrix\Main\Localization\Loc;
8use Bitrix\Main\ArgumentNullException;
9use Bitrix\Sale\Delivery\Services\Manager;
10use Bitrix\Sale\Delivery\CalculationResult;
11
12Loc::loadMessages(__FILE__);
13
19class SpsrProfile extends \Bitrix\Sale\Delivery\Services\Base
20{
22 protected $spsrHandler = null;
24 protected $serviceType = 0;
25
26 protected static $whetherAdminExtraServicesShow = true;
28 protected static $isProfile = true;
29
35 public function __construct(array $initParams)
36 {
37 if(empty($initParams["PARENT_ID"]))
38 throw new ArgumentNullException('initParams[PARENT_ID]');
39
40 parent::__construct($initParams);
41 $this->spsrHandler = Manager::getObjectById($this->parentId);
42
43 if(!($this->spsrHandler instanceof SpsrHandler))
44 throw new ArgumentNullException('this->spsrHandler is not instance of SpsrHandler');
45
46 if(isset($initParams['PROFILE_ID']) && intval($initParams['PROFILE_ID']) > 0)
47 $this->serviceType = intval($initParams['PROFILE_ID']);
48 elseif(isset($this->config['MAIN']['SERVICE_TYPE']) && intval($this->config['MAIN']['SERVICE_TYPE']) > 0)
49 $this->serviceType = $this->config['MAIN']['SERVICE_TYPE'];
50
51 if($this->id <= 0 && $this->serviceType > 0)
52 {
53 $srvRes = $this->spsrHandler->getServiceTypes();
54 $srvTypes = $srvRes->getData();
55
56 if(!empty($srvTypes[$this->serviceType]))
57 {
58 $this->name = $srvTypes[$this->serviceType]['Name'];
59 $this->description = $srvTypes[$this->serviceType]['ShortDescription'];
60 }
61 }
62
63 $this->inheritParams();
64 }
65
69 protected function getProfileType(): string
70 {
71 return (string)$this->serviceType;
72 }
73
77 public static function getClassTitle()
78 {
79 return Loc::getMessage("SALE_DLV_SRV_SPSR_PROFILE_TITLE");
80 }
81
85 public static function getClassDescription()
86 {
87 return Loc::getMessage("SALE_DLV_SRV_SPSR_PROFILE_DESCRIPTION");
88 }
89
95 protected function inheritParams()
96 {
97 if($this->name == '') $this->name = $this->spsrHandler->getName();
98 if(intval($this->logotip) <= 0) $this->logotip = $this->spsrHandler->getLogotip();
99 if($this->description == '') $this->description = $this->spsrHandler->getDescription();
100 if(empty($this->trackingParams)) $this->trackingParams = $this->spsrHandler->getTrackingParams();
101 if($this->trackingClass == '') $this->trackingClass = $this->spsrHandler->getTrackingClass();
102
103 $parentES = \Bitrix\Sale\Delivery\ExtraServices\Manager::getExtraServicesList($this->parentId);
104 $allowEsCodes = self::getProfileES($this->serviceType);
105
106 if(!empty($parentES))
107 {
108 foreach($parentES as $esFields)
109 {
110 if(
111 $esFields['CODE'] <> ''
112 && !$this->extraServices->getItemByCode($esFields['CODE'])
113 && in_array($esFields['CODE'], $allowEsCodes)
114 )
115 {
116 $this->extraServices->addItem($esFields, $this->currency);
117 }
118 }
119 }
120 }
121
125 protected function calculateConcrete(Shipment $shipment)
126 {
127 return (new CalculationResult())->addError(new Error(Loc::getMessage('The company no longer exists')));
128 }
129
130 public function isCalculatePriceImmediately()
131 {
132 return $this->spsrHandler->isCalculatePriceImmediately();
133 }
134
138 protected function getConfigStructure()
139 {
140 $srvRes = $this->spsrHandler->getServiceTypes();
141 $srvList = $srvRes->getData();
142
143 $result = array(
144 "MAIN" => array(
145 "TITLE" => Loc::getMessage("SALE_DLV_SRV_SPSR_PROFILE_MAIN_TITLE"),
146 "DESCRIPTION" => Loc::getMessage("SALE_DLV_SRV_SPSR_PROFILE_MAIN_DSCR"),
147 "ITEMS" => array(
148 "SERVICE_TYPE_NAME" => array(
149 "TYPE" => "STRING",
150 "NAME" => Loc::getMessage("SALE_DLV_SRV_SPSR_PROFILE_ST"),
151 "READONLY" => true,
152 "DEFAULT" => $srvList[$this->serviceType]['Name']
153 ),
154 "SERVICE_TYPE" => array(
155 "TYPE" => "STRING",
156 "NAME" =>"SERVICE_TYPE",
157 "HIDDEN" => true,
158 "DEFAULT" => $this->serviceType
159 ),
160 "DESCRIPTION_INNER" => array(
161 "TYPE" => "DELIVERY_READ_ONLY",
162 "NAME" => Loc::getMessage("SALE_DLV_SRV_SPSR_INNER_DESCR"),
163 "ID" => "adm-sale-delivery-spsr-description_inner",
164 "DEFAULT" => $srvList[$this->serviceType]['Description']
165 )
166 )
167 )
168 );
169
170 return $result;
171 }
172
176 public function getParentService()
177 {
178 return $this->spsrHandler;
179 }
180
184 public function getEmbeddedExtraServicesList()
185 {
186 $result = array();
187 $allowEsCodes = self::getProfileES($this->serviceType);
188
189 foreach($this->spsrHandler->getEmbeddedExtraServicesList() as $code => $params)
190 if(in_array($code, $allowEsCodes))
192
193 return $result;
194 }
195
199 public function isCompatible(Shipment $shipment)
200 {
201 return false;
202 }
203
208 public static function getProfileES($profileId)
209 {
210 $extraServices = array(
211 20 => array('SMS_RECV', 'SMS', 'TO_BE_CALLED_FOR'), //colibri
212 21 => array('BY_HAND', 'SMS', 'SMS_RECV'), //gepard-express 13
213 22 => array('BY_HAND', 'SMS', 'SMS_RECV'), //gepard-express 18
214 23 => array('BY_HAND', 'SMS', 'SMS_RECV', 'TO_BE_CALLED_FOR'), //gepard-express
215 24 => array('BY_HAND', 'SMS', 'SMS_RECV', 'TO_BE_CALLED_FOR', 'PLAT_TYPE', 'ICD'), //pelican-standart
216 25 => array('BY_HAND', 'SMS', 'SMS_RECV', 'TO_BE_CALLED_FOR', 'PLAT_TYPE', 'ICD'), //pelican-econom
217 26 => array('SMS', 'SMS_RECV', 'TO_BE_CALLED_FOR', 'PLAT_TYPE', 'ICD'), //bizon-cargo
218 27 => array('TO_BE_CALLED_FOR'), //fraxt
219 28 => array('BY_HAND', 'SMS', 'SMS_RECV', 'TO_BE_CALLED_FOR', 'ICD', 'TO_BE_CALLED_FOR'), //pelican-online
220 35 => array('BY_HAND', 'SMS', 'SMS_RECV', 'TO_BE_CALLED_FOR', 'ICD', 'TO_BE_CALLED_FOR'), //gepard-online
221 36 => array('BY_HAND', 'SMS', 'SMS_RECV', 'TO_BE_CALLED_FOR', 'ICD', 'TO_BE_CALLED_FOR'), //zebra-online
222 );
223
224 return isset($extraServices[$profileId]) ? $extraServices[$profileId] : array();
225 }
226
230 public static function install()
231 {
232 SpsrHandler::install();
233 }
234
238 public static function unInstall()
239 {
240 SpsrHandler::unInstall();
241 }
242
246 public static function isInstalled()
247 {
248 SpsrHandler::isInstalled();
249 }
250
254 public static function isProfile()
255 {
256 return self::$isProfile;
257 }
258
262 public static function whetherAdminExtraServicesShow()
263 {
264 return self::$whetherAdminExtraServicesShow;
265 }
266}
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
Определения options.php:195
if(!function_exists(__NAMESPACE__.'\\___972068685'))
Определения license.php:1
trait Error
Определения error.php:11
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799