38 public static function check($params, array $restrictionParams, $serviceId = 0)
40 if ((
int)$serviceId <= 0)
46 $paySystemIds = self::getPaySystemsByCompanyId($serviceId);
48 if (empty($paySystemIds))
51 $diff = array_diff($params, $paySystemIds);
61 protected static function extractParams(
Sale\Internals\
Entity $entity)
66 $paymentCollection =
null;
70 $paymentCollection = $entity->getCollection();
75 $shipmentCollection = $entity->getCollection();
76 if ($shipmentCollection)
79 $order = $shipmentCollection->getOrder();
81 $paymentCollection = $order->getPaymentCollection();
86 $paymentCollection = $entity->getPaymentCollection();
89 if ($paymentCollection !==
null)
92 foreach ($paymentCollection as $payment)
94 $paySystemId = $payment->getPaymentSystemId();
96 $result[] = $paySystemId;
110 $dbRes = Sale\PaySystem\Manager::getList(array(
'select' => array(
'ID',
'NAME')));
111 while ($paySystem = $dbRes->fetch())
112 $result[$paySystem[
'ID']] = $paySystem[
'NAME'].
' ['.$paySystem[
'ID'].
']';
124 "PAYSYSTEM" => array(
128 "OPTIONS" => self::getPaySystemList()
146 $dbRes = CompanyServiceTable::getList(
148 'select' => array(
'SERVICE_ID'),
150 'COMPANY_ID' => $companyId,
151 'SERVICE_TYPE' =>
Sale\Services\Company\Restrictions\Manager::SERVICE_TYPE_PAYMENT)
155 while ($data = $dbRes->fetch())
156 $result[] = $data[
'SERVICE_ID'];
166 public static function save(array $fields, $restrictionId = 0)
168 $serviceIds = $fields[
"PARAMS"];
169 $fields[
"PARAMS"] = array();
171 if ($restrictionId > 0)
173 $dbRes = CompanyServiceTable::getList(
175 'select' => array(
'SERVICE_ID'),
177 'SERVICE_TYPE' =>
Sale\Services\Company\Restrictions\Manager::SERVICE_TYPE_PAYMENT,
178 'COMPANY_ID' => $fields[
'SERVICE_ID']
183 while($data = $dbRes->fetch())
185 $key = array_search($data[
'SERVICE_ID'], $serviceIds[
'PAYSYSTEM']);
188 CompanyServiceTable::delete(array(
'COMPANY_ID' => $fields[
'SERVICE_ID'],
'SERVICE_ID' => $data[
'SERVICE_ID'],
'SERVICE_TYPE' =>
Sale\Services\Company\Restrictions\Manager::SERVICE_TYPE_PAYMENT));
192 unset($serviceIds[
'PAYSYSTEM'][$key]);
197 $result = parent::save($fields, $restrictionId);
199 $addFields = array(
'COMPANY_ID' => $fields[
'SERVICE_ID'],
'SERVICE_TYPE' =>
Sale\Services\Company\Restrictions\Manager::SERVICE_TYPE_PAYMENT);
200 foreach ($serviceIds[
'PAYSYSTEM'] as $id)
202 $addFields[
'SERVICE_ID'] = $id;
203 CompanyServiceTable::add($addFields);
216 return array(
"PAYSYSTEM" => self::getPaySystemsByCompanyId($entityId));
225 public static function delete($restrictionId, $entityId = 0)
227 $dbRes = CompanyServiceTable::getList(
229 'select' => array(
'SERVICE_ID'),
231 'SERVICE_TYPE' =>
Sale\Services\Company\Restrictions\Manager::SERVICE_TYPE_PAYMENT,
232 'COMPANY_ID' => $entityId
237 while ($data = $dbRes->fetch())
239 CompanyServiceTable::delete(array(
'COMPANY_ID' => $entityId,
'SERVICE_ID' => $data[
'SERVICE_ID'],
'SERVICE_TYPE' =>
Sale\Services\Company\Restrictions\Manager::SERVICE_TYPE_PAYMENT));
242 return parent::delete($restrictionId);
static loadMessages($file)
static getMessage($code, $replace=null, $language=null)