Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
bysite.php
1<?php
3
5use \Bitrix\Main\Localization\Loc;
9
10Loc::loadMessages(__FILE__);
11
17class BySite extends Base
18{
19 public static function getClassTitle()
20 {
21 return Loc::getMessage("SALE_DLVR_RSTR_BY_SITE_NAME");
22 }
23
24 public static function getClassDescription()
25 {
26 return Loc::getMessage("SALE_DLVR_RSTR_BY_SITE_DESCRIPT");
27 }
28 public static function check($siteId, array $restrictionParams, $deliveryId = 0)
29 {
30 if(empty($restrictionParams))
31 return true;
32
33 $result = true;
34
35 if($siteId <> '' && isset($restrictionParams["SITE_ID"]) && is_array($restrictionParams["SITE_ID"]))
36 $result = in_array($siteId, $restrictionParams["SITE_ID"]);
37
38 return $result;
39 }
40
41 protected static function extractParams(Entity $entity)
42 {
43 if ($entity instanceof CollectableEntity)
44 {
46 $collection = $entity->getCollection();
47
49 $order = $collection->getOrder();
50 }
51 elseif ($entity instanceof Order)
52 {
54 $order = $entity;
55 }
56
57 if (!$order)
58 return false;
59
60 return $order->getSiteId();
61 }
62
63 public static function getParamsStructure($entityId = 0)
64 {
65 $siteList = array();
66
67 $rsSite = \Bitrix\Main\SiteTable::getList();
68
69 while ($site = $rsSite->fetch())
70 $siteList[$site["LID"]] = $site["NAME"]." (".$site["LID"].")";
71
72 return array(
73 "SITE_ID" => array(
74 "TYPE" => "ENUM",
75 'MULTIPLE' => 'Y',
76 "DEFAULT" => SITE_ID,
77 "LABEL" => Loc::getMessage("SALE_DLVR_RSTR_BY_SITE_SITE_ID"),
78 "OPTIONS" => $siteList
79 )
80 );
81 }
82
83 public static function getSeverity($mode)
84 {
85 if($mode == Manager::MODE_MANAGER)
87
88 return parent::getSeverity($mode);
89 }
90
94 public static function isAvailable()
95 {
96 return IsModuleInstalled('bitrix24') ? false : true;
97 }
98}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static getParamsStructure($entityId=0)
Definition bysite.php:63
static check($siteId, array $restrictionParams, $deliveryId=0)
Definition bysite.php:28