3namespace Sale\Handlers\Delivery;
6use Bitrix\Sale\Shipment;
7use Bitrix\Main\Localization\Loc;
8use Bitrix\Main\ArgumentNullException;
9use Bitrix\Sale\Delivery\Services\Manager;
10use Bitrix\Sale\Delivery\CalculationResult;
12Loc::loadMessages(__FILE__);
19class SpsrProfile
extends \Bitrix\Sale\Delivery\Services\Base
22 protected $spsrHandler =
null;
24 protected $serviceType = 0;
26 protected static $whetherAdminExtraServicesShow =
true;
28 protected static $isProfile =
true;
35 public function __construct(
array $initParams)
37 if(empty($initParams[
"PARENT_ID"]))
38 throw new ArgumentNullException(
'initParams[PARENT_ID]');
40 parent::__construct($initParams);
41 $this->spsrHandler = Manager::getObjectById($this->parentId);
43 if(!($this->spsrHandler instanceof SpsrHandler))
44 throw new ArgumentNullException(
'this->spsrHandler is not instance of SpsrHandler');
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'];
51 if($this->
id <= 0 && $this->serviceType > 0)
53 $srvRes = $this->spsrHandler->getServiceTypes();
54 $srvTypes = $srvRes->getData();
56 if(!empty($srvTypes[$this->serviceType]))
58 $this->name = $srvTypes[$this->serviceType][
'Name'];
59 $this->description = $srvTypes[$this->serviceType][
'ShortDescription'];
63 $this->inheritParams();
69 protected function getProfileType(): string
71 return (
string)$this->serviceType;
77 public static function getClassTitle()
79 return Loc::getMessage(
"SALE_DLV_SRV_SPSR_PROFILE_TITLE");
85 public static function getClassDescription()
87 return Loc::getMessage(
"SALE_DLV_SRV_SPSR_PROFILE_DESCRIPTION");
95 protected function inheritParams()
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();
103 $parentES = \Bitrix\Sale\Delivery\ExtraServices\Manager::getExtraServicesList($this->parentId);
104 $allowEsCodes = self::getProfileES($this->serviceType);
106 if(!empty($parentES))
108 foreach($parentES as $esFields)
111 $esFields[
'CODE'] <>
''
112 && !$this->extraServices->getItemByCode($esFields[
'CODE'])
113 && in_array($esFields[
'CODE'], $allowEsCodes)
116 $this->extraServices->addItem($esFields, $this->currency);
125 protected function calculateConcrete(Shipment $shipment)
127 return (
new CalculationResult())->addError(
new Error(Loc::getMessage(
'The company no longer exists')));
130 public function isCalculatePriceImmediately()
132 return $this->spsrHandler->isCalculatePriceImmediately();
138 protected function getConfigStructure()
140 $srvRes = $this->spsrHandler->getServiceTypes();
141 $srvList = $srvRes->getData();
145 "TITLE" => Loc::getMessage(
"SALE_DLV_SRV_SPSR_PROFILE_MAIN_TITLE"),
146 "DESCRIPTION" => Loc::getMessage(
"SALE_DLV_SRV_SPSR_PROFILE_MAIN_DSCR"),
148 "SERVICE_TYPE_NAME" =>
array(
150 "NAME" => Loc::getMessage(
"SALE_DLV_SRV_SPSR_PROFILE_ST"),
152 "DEFAULT" => $srvList[$this->serviceType][
'Name']
154 "SERVICE_TYPE" =>
array(
156 "NAME" =>
"SERVICE_TYPE",
158 "DEFAULT" => $this->serviceType
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']
176 public function getParentService()
178 return $this->spsrHandler;
184 public function getEmbeddedExtraServicesList()
187 $allowEsCodes = self::getProfileES($this->serviceType);
189 foreach($this->spsrHandler->getEmbeddedExtraServicesList() as
$code =>
$params)
190 if(in_array(
$code, $allowEsCodes))
199 public function isCompatible(Shipment $shipment)
208 public static function getProfileES($profileId)
210 $extraServices =
array(
211 20 =>
array(
'SMS_RECV',
'SMS',
'TO_BE_CALLED_FOR'),
212 21 =>
array(
'BY_HAND',
'SMS',
'SMS_RECV'),
213 22 =>
array(
'BY_HAND',
'SMS',
'SMS_RECV'),
214 23 =>
array(
'BY_HAND',
'SMS',
'SMS_RECV',
'TO_BE_CALLED_FOR'),
215 24 =>
array(
'BY_HAND',
'SMS',
'SMS_RECV',
'TO_BE_CALLED_FOR',
'PLAT_TYPE',
'ICD'),
216 25 =>
array(
'BY_HAND',
'SMS',
'SMS_RECV',
'TO_BE_CALLED_FOR',
'PLAT_TYPE',
'ICD'),
217 26 =>
array(
'SMS',
'SMS_RECV',
'TO_BE_CALLED_FOR',
'PLAT_TYPE',
'ICD'),
218 27 =>
array(
'TO_BE_CALLED_FOR'),
219 28 =>
array(
'BY_HAND',
'SMS',
'SMS_RECV',
'TO_BE_CALLED_FOR',
'ICD',
'TO_BE_CALLED_FOR'),
220 35 =>
array(
'BY_HAND',
'SMS',
'SMS_RECV',
'TO_BE_CALLED_FOR',
'ICD',
'TO_BE_CALLED_FOR'),
221 36 =>
array(
'BY_HAND',
'SMS',
'SMS_RECV',
'TO_BE_CALLED_FOR',
'ICD',
'TO_BE_CALLED_FOR'),
224 return isset($extraServices[$profileId]) ? $extraServices[$profileId] :
array();
230 public static function install()
232 SpsrHandler::install();
238 public static function unInstall()
240 SpsrHandler::unInstall();
246 public static function isInstalled()
248 SpsrHandler::isInstalled();
254 public static function isProfile()
256 return self::$isProfile;
262 public static function whetherAdminExtraServicesShow()
264 return self::$whetherAdminExtraServicesShow;
</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(!function_exists(__NAMESPACE__.'\\___972068685'))
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']