Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
importsettings.php
1<?php
3
4
10
13{
18 static protected function loadCurrentSettings()
19 {
20 if(self::$currentSettings === null)
21 {
22 self::$currentSettings['import']['CURRENCY'] = \CSaleLang::GetLangCurrency(Option::get("sale", "1C_SITE_NEW_ORDERS"));
23 self::$currentSettings['import']['SITE_ID'] = Option::get("sale", "1C_SITE_NEW_ORDERS");
24
25 self::$currentSettings['finalStatusId'][Exchange\EntityType::ORDER_NAME] = "F";
26 self::$currentSettings['finalStatusId'][Exchange\EntityType::INVOICE_NAME] = "F";
27 self::$currentSettings['finalStatusOnDelivery'][Exchange\EntityType::ORDER_NAME] = Option::get("sale", "1C_FINAL_STATUS_ON_DELIVERY", "");
28 self::$currentSettings['finalStatusOnDelivery'][Exchange\EntityType::INVOICE_NAME] = Option::get("sale", "1C_FINAL_STATUS_ON_DELIVERY", "");
29
30 self::$currentSettings['changeStatusFor'][Exchange\EntityType::ORDER_NAME] = Option::get("sale", "1C_CHANGE_STATUS_FROM_1C", "Y");
31 self::$currentSettings['changeStatusFor'][Exchange\EntityType::SHIPMENT_NAME] = '';
32 self::$currentSettings['changeStatusFor'][Exchange\EntityType::PAYMENT_CASH_NAME] = '';
33 self::$currentSettings['changeStatusFor'][Exchange\EntityType::PAYMENT_CASH_LESS_NAME] = '';
34 self::$currentSettings['changeStatusFor'][Exchange\EntityType::PAYMENT_CARD_TRANSACTION_NAME] = '';
35
36 self::$currentSettings['changeStatusFor'][Exchange\EntityType::INVOICE_NAME] = Option::get("sale", "1C_CHANGE_STATUS_FROM_1C", "Y");
37 self::$currentSettings['changeStatusFor'][Exchange\EntityType::INVOICE_SHIPMENT_NAME] = '';
38 self::$currentSettings['changeStatusFor'][Exchange\EntityType::INVOICE_PAYMENT_CASH_NAME] = '';
39 self::$currentSettings['changeStatusFor'][Exchange\EntityType::INVOICE_PAYMENT_CASH_LESS_NAME] = '';
40 self::$currentSettings['changeStatusFor'][Exchange\EntityType::INVOICE_PAYMENT_CARD_TRANSACTION_NAME] = '';
41
42
43 self::$currentSettings['importableFor'][Exchange\EntityType::USER_PROFILE_NAME] = Option::get("sale", "1C_IMPORT_NEW_ORDERS", "Y");
44 self::$currentSettings['importableFor'][Exchange\EntityType::PROFILE_NAME] = Option::get("sale", "1C_IMPORT_NEW_ORDERS", "Y");
45 self::$currentSettings['importableFor'][Exchange\EntityType::USER_PROFILE_CONTACT_COMPANY_NAME] = Option::get("sale", "1C_IMPORT_NEW_ORDERS", "Y");
46 self::$currentSettings['importableFor'][Exchange\EntityType::ORDER_NAME] = Option::get("sale", "1C_IMPORT_NEW_ORDERS", "Y");
47 self::$currentSettings['importableFor'][Exchange\EntityType::SHIPMENT_NAME] = Option::get("sale", "1C_IMPORT_NEW_SHIPMENT", "Y");
48 self::$currentSettings['importableFor'][Exchange\EntityType::PAYMENT_CASH_NAME] = Option::get("sale", "1C_IMPORT_NEW_PAYMENT", "Y");
49 self::$currentSettings['importableFor'][Exchange\EntityType::PAYMENT_CASH_LESS_NAME] = Option::get("sale", "1C_IMPORT_NEW_PAYMENT", "Y");
50 self::$currentSettings['importableFor'][Exchange\EntityType::PAYMENT_CARD_TRANSACTION_NAME] = Option::get("sale", "1C_IMPORT_NEW_PAYMENT", "Y");
51
52 self::$currentSettings['importableFor'][Exchange\EntityType::INVOICE_NAME] = Option::get("sale", "1C_IMPORT_NEW_ORDERS", "Y");
53 self::$currentSettings['importableFor'][Exchange\EntityType::INVOICE_SHIPMENT_NAME] = Option::get("sale", "1C_IMPORT_NEW_SHIPMENT", "Y");;
54 self::$currentSettings['importableFor'][Exchange\EntityType::INVOICE_PAYMENT_CASH_NAME] = Option::get("sale", "1C_IMPORT_NEW_PAYMENT", "Y");;
55 self::$currentSettings['importableFor'][Exchange\EntityType::INVOICE_PAYMENT_CASH_LESS_NAME] = Option::get("sale", "1C_IMPORT_NEW_PAYMENT", "Y");;
56 self::$currentSettings['importableFor'][Exchange\EntityType::INVOICE_PAYMENT_CARD_TRANSACTION_NAME] = Option::get("sale", "1C_IMPORT_NEW_PAYMENT", "Y");;
57
58
59 self::$currentSettings['accountNumberPrefix'][Exchange\EntityType::ORDER_NAME] = Option::get("sale", "1C_SALE_ACCOUNT_NUMBER_SHOP_PREFIX", "");
60 self::$currentSettings['accountNumberPrefix'][Exchange\EntityType::SHIPMENT_NAME] = '';
61 self::$currentSettings['accountNumberPrefix'][Exchange\EntityType::PAYMENT_CASH_NAME] = '';
62 self::$currentSettings['accountNumberPrefix'][Exchange\EntityType::PAYMENT_CASH_LESS_NAME] = '';
63 self::$currentSettings['accountNumberPrefix'][Exchange\EntityType::PAYMENT_CARD_TRANSACTION_NAME] = '';
64
65 self::$currentSettings['accountNumberPrefix'][Exchange\EntityType::INVOICE_NAME] = Option::get("sale", "1C_SALE_ACCOUNT_NUMBER_SHOP_PREFIX", "");
66 self::$currentSettings['accountNumberPrefix'][Exchange\EntityType::INVOICE_SHIPMENT_NAME] = '';
67 self::$currentSettings['accountNumberPrefix'][Exchange\EntityType::INVOICE_PAYMENT_CASH_NAME] = '';
68 self::$currentSettings['accountNumberPrefix'][Exchange\EntityType::INVOICE_PAYMENT_CASH_LESS_NAME] = '';
69 self::$currentSettings['accountNumberPrefix'][Exchange\EntityType::INVOICE_PAYMENT_CARD_TRANSACTION_NAME] = '';
70
71
72 self::$currentSettings['paySystem'][Exchange\EntityType::PAYMENT_CASH_LESS_NAME] = Option::get("sale", "1C_IMPORT_DEFAULT_PS_B", "");
73 self::$currentSettings['paySystem'][Exchange\EntityType::PAYMENT_CASH_NAME] = Option::get("sale", "1C_IMPORT_DEFAULT_PS", "");
74 self::$currentSettings['paySystem'][Exchange\EntityType::PAYMENT_CARD_TRANSACTION_NAME] = Option::get("sale", "1C_IMPORT_DEFAULT_PS_A", "");
75
76 self::$currentSettings['paySystem'][Exchange\EntityType::INVOICE_PAYMENT_CASH_LESS_NAME] = Option::get("sale", "1C_IMPORT_DEFAULT_PS_B", "");
77 self::$currentSettings['paySystem'][Exchange\EntityType::INVOICE_PAYMENT_CASH_NAME] = Option::get("sale", "1C_IMPORT_DEFAULT_PS", "");
78 self::$currentSettings['paySystem'][Exchange\EntityType::INVOICE_PAYMENT_CARD_TRANSACTION_NAME] = Option::get("sale", "1C_IMPORT_DEFAULT_PS_A", "");
79
80
81 self::$currentSettings['paySystemDefault'][Exchange\EntityType::PAYMENT_CASH_LESS_NAME] = Manager::getInnerPaySystemId();
82 self::$currentSettings['paySystemDefault'][Exchange\EntityType::PAYMENT_CASH_NAME] = Manager::getInnerPaySystemId();
83 self::$currentSettings['paySystemDefault'][Exchange\EntityType::PAYMENT_CARD_TRANSACTION_NAME] = Manager::getInnerPaySystemId();
84
85 self::$currentSettings['paySystemDefault'][Exchange\EntityType::INVOICE_PAYMENT_CASH_NAME] = Manager::getInnerPaySystemId();
86 self::$currentSettings['paySystemDefault'][Exchange\EntityType::INVOICE_PAYMENT_CASH_LESS_NAME] = Manager::getInnerPaySystemId();
87 self::$currentSettings['paySystemDefault'][Exchange\EntityType::INVOICE_PAYMENT_CARD_TRANSACTION_NAME] = Manager::getInnerPaySystemId();
88
89
90 self::$currentSettings['shipmentService'][Exchange\EntityType::SHIPMENT_NAME] = Option::get("sale", "1C_IMPORT_DEFAULT_SHIPMENT_SERVICE", "");
91 self::$currentSettings['shipmentServiceDefault'][Exchange\EntityType::SHIPMENT_NAME] = EmptyDeliveryService::getEmptyDeliveryServiceId();
92
93 self::$currentSettings['shipmentService'][Exchange\EntityType::INVOICE_SHIPMENT_NAME] = Option::get("sale", "1C_IMPORT_DEFAULT_SHIPMENT_SERVICE", "");
94 self::$currentSettings['shipmentServiceDefault'][Exchange\EntityType::INVOICE_SHIPMENT_NAME] = EmptyDeliveryService::getEmptyDeliveryServiceId();
95
96
97 self::$currentSettings['canCreateOrder'][Exchange\EntityType::ORDER_NAME] = '';
98 self::$currentSettings['canCreateOrder'][Exchange\EntityType::SHIPMENT_NAME] = Option::get("sale", "1C_IMPORT_NEW_ORDER_NEW_SHIPMENT", "");
99 self::$currentSettings['canCreateOrder'][Exchange\EntityType::PAYMENT_CASH_NAME] = '';
100 self::$currentSettings['canCreateOrder'][Exchange\EntityType::PAYMENT_CASH_LESS_NAME] = '';
101 self::$currentSettings['canCreateOrder'][Exchange\EntityType::PAYMENT_CARD_TRANSACTION_NAME] = '';
102
103 self::$currentSettings['canCreateOrder'][Exchange\EntityType::INVOICE_NAME] = '';
104 self::$currentSettings['canCreateOrder'][Exchange\EntityType::INVOICE_SHIPMENT_NAME] = Option::get("sale", "1C_IMPORT_NEW_ORDER_NEW_SHIPMENT", "");
105 self::$currentSettings['canCreateOrder'][Exchange\EntityType::INVOICE_PAYMENT_CASH_NAME] = '';
106 self::$currentSettings['canCreateOrder'][Exchange\EntityType::INVOICE_PAYMENT_CASH_LESS_NAME] = '';
107 self::$currentSettings['canCreateOrder'][Exchange\EntityType::INVOICE_PAYMENT_CARD_TRANSACTION_NAME] = '';
108
109
110 //self::$currentSettings['shipmentBasketChangeQuantity'][EntityType::SHIPMENT_NAME] = Option::get("sale", "1C_IMPORT_UPDATE_BASKET_QUANTITY", "");
111
112
113 self::$currentSettings['collisionResolve'][Exchange\EntityType::ORDER_NAME] = Option::get("sale", "1C_IMPORT_COLLISION_RESOLVE", array(Exchange\EntityCollisionType::OrderFinalStatusName));
114 self::$currentSettings['collisionResolve'][Exchange\EntityType::SHIPMENT_NAME] = Option::get("sale", "1C_IMPORT_COLLISION_RESOLVE", array(Exchange\EntityCollisionType::ShipmentIsShippedName));
115 self::$currentSettings['collisionResolve'][Exchange\EntityType::PAYMENT_CASH_NAME] = Option::get("sale", "1C_IMPORT_COLLISION_RESOLVE", array(Exchange\EntityCollisionType::PaymentIsPayedName));
116 self::$currentSettings['collisionResolve'][Exchange\EntityType::PAYMENT_CASH_LESS_NAME] = Option::get("sale", "1C_IMPORT_COLLISION_RESOLVE", array(Exchange\EntityCollisionType::PaymentIsPayedName));
117 self::$currentSettings['collisionResolve'][Exchange\EntityType::PAYMENT_CARD_TRANSACTION_NAME] = Option::get("sale", "1C_IMPORT_COLLISION_RESOLVE", array(Exchange\EntityCollisionType::PaymentIsPayedName));
118
119 self::$currentSettings['collisionResolve'][Exchange\EntityType::INVOICE_NAME] = Option::get("sale", "1C_IMPORT_COLLISION_RESOLVE", array(Exchange\EntityCollisionType::OrderFinalStatusName));
120 self::$currentSettings['collisionResolve'][Exchange\EntityType::INVOICE_SHIPMENT_NAME] = Option::get("sale", "1C_IMPORT_COLLISION_RESOLVE", array(Exchange\EntityCollisionType::ShipmentIsShippedName));
121 self::$currentSettings['collisionResolve'][Exchange\EntityType::INVOICE_PAYMENT_CASH_NAME] = Option::get("sale", "1C_IMPORT_COLLISION_RESOLVE", array(Exchange\EntityCollisionType::PaymentIsPayedName));
122 self::$currentSettings['collisionResolve'][Exchange\EntityType::INVOICE_PAYMENT_CASH_LESS_NAME] = Option::get("sale", "1C_IMPORT_COLLISION_RESOLVE", array(Exchange\EntityCollisionType::PaymentIsPayedName));
123 self::$currentSettings['collisionResolve'][Exchange\EntityType::INVOICE_PAYMENT_CARD_TRANSACTION_NAME] = Option::get("sale", "1C_IMPORT_COLLISION_RESOLVE", array(Exchange\EntityCollisionType::PaymentIsPayedName));
124
125
126
127 if(!is_array(self::$currentSettings))
128 {
129 self::$currentSettings = array();
130 }
131 }
133 }
134
141 public function isImportableFor($entityTypeId)
142 {
143 $entityTypeName = $this->resolveName($entityTypeId);
144 return isset($this->settings['importableFor'][$entityTypeName]) && $this->settings['importableFor'][$entityTypeName] === 'Y';
145 }
146
153 public function paySystemIdFor($entityTypeId)
154 {
155 return $this->getValueFor($entityTypeId, 'paySystem');
156 }
157
164 public function paySystemIdDefaultFor($entityTypeId)
165 {
166 return $this->getValueFor($entityTypeId, 'paySystemDefault');
167 }
168
175 public function shipmentServiceFor($entityTypeId)
176 {
177 return $this->getValueFor($entityTypeId, 'shipmentService');
178 }
179
186 public function shipmentServiceDefaultFor($entityTypeId)
187 {
188 return $this->getValueFor($entityTypeId, 'shipmentServiceDefault');
189 }
190
197 public function finalStatusIdFor($entityTypeId)
198 {
199 return $this->getValueFor($entityTypeId, 'finalStatusId');
200 }
201
208 public function finalStatusOnDeliveryFor($entityTypeId)
209 {
210 return $this->getValueFor($entityTypeId, 'finalStatusOnDelivery');
211 }
212
219 public function changeStatusFor($entityTypeId)
220 {
221 $entityTypeName = $this->resolveName($entityTypeId);
222 return ($this->settings['changeStatusFor'][$entityTypeName] == 'Y' ? $this->settings['changeStatusFor'][$entityTypeName]: '');
223 }
224
231 public function canCreateOrder($entityTypeId)
232 {
233 $entityTypeName = $this->resolveName($entityTypeId);
234 return ($this->settings['canCreateOrder'][$entityTypeName] == 'Y' ? $this->settings['canCreateOrder'][$entityTypeName]: '');
235 }
236
240 public function getSiteId()
241 {
242 return $this->settings['import']['SITE_ID'] !== "" ? $this->settings['import']['SITE_ID']: Main\Application::getInstance()->getContext()->getSite();
243 }
244
248 public function getCurrency()
249 {
250 return $this->settings['import']['CURRENCY'];
251 }
252
259 public function getCollisionResolve($entityTypeId)
260 {
261 $entityTypeName = $this->resolveName($entityTypeId);
262 return is_array($this->settings['collisionResolve'][$entityTypeName]) ? $this->settings['collisionResolve'][$entityTypeName]:array();
263 }
264
268 public static function getCurrent()
269 {
270 return new static(static::loadCurrentSettings());
271 }
272}
getValueFor($entityTypeId, $name, $default='')