Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
company.php
1<?php
3
8
9Loc::loadMessages(__FILE__);
10
15class Company extends Restriction
16{
17 public static $easeSort = 200;
18 protected static $preparedData = array();
19
23 public static function getClassTitle()
24 {
25 return Loc::getMessage("SALE_CASHBOX_RSTR_BY_COMPANY_TITLE");
26 }
27
31 public static function getClassDescription()
32 {
33 return Loc::getMessage("SALE_CASHBOX_RSTR_BY_COMPANY_DESC");
34 }
35
42 public static function check($params, array $restrictionParams, $serviceId = 0)
43 {
44 if (is_array($restrictionParams) && isset($restrictionParams['COMPANY']))
45 {
46 $diff = array_diff($params, $restrictionParams['COMPANY']);
47 return empty($diff);
48 }
49
50 return true;
51 }
52
57 protected static function extractParams(Entity $entity)
58 {
59 $result = array();
60
61 if ($entity instanceof Sale\Payment ||
62 $entity instanceof Sale\Shipment ||
63 $entity instanceof Sale\Order
64 )
65 {
66 $result[] = $entity->getField('COMPANY_ID');
67 }
68
69 return $result;
70 }
71
75 protected static function getCompanyList()
76 {
77 static $result = null;
78
79 if($result !== null)
80 return $result;
81
82 $result = array();
83
84 $dbResultList = Sale\Services\Company\Manager::getList(array(
85 'select' => array("ID", "NAME", "ACTIVE"),
86 'filter' => array("ACTIVE" => "Y"),
87 'order' => array("SORT"=>"ASC", "NAME"=>"ASC")
88 ));
89
90 while ($item = $dbResultList->fetch())
91 $result[$item["ID"]] = $item["NAME"];
92
93 return $result;
94 }
95
100 public static function getParamsStructure($entityId = 0)
101 {
102 $result = array(
103 "COMPANY" => array(
104 "TYPE" => "ENUM",
105 'MULTIPLE' => 'Y',
106 "LABEL" => Loc::getMessage("SALE_CASHBOX_RSTR_BY_COMPANY"),
107 "OPTIONS" => self::getCompanyList()
108 )
109 );
110
111 return $result;
112 }
113
118 public static function getSeverity($mode)
119 {
120 return Manager::SEVERITY_STRICT;
121 }
122
126 public static function isAvailable()
127 {
128 return IsModuleInstalled('crm') ? false : true;
129 }
130
131}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static extractParams(Entity $entity)
Definition company.php:57
static check($params, array $restrictionParams, $serviceId=0)
Definition company.php:42