1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Delivery |
5
|
|
|
* |
6
|
|
|
* @author Alexey Krupskiy <[email protected]> |
7
|
|
|
* @link http://inji.ru/ |
8
|
|
|
* @copyright 2015 Alexey Krupskiy |
9
|
|
|
* @license https://github.com/injitools/cms-Inji/blob/master/LICENSE |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Ecommerce; |
13
|
|
|
/** |
14
|
|
|
* Class Delivery |
15
|
|
|
* |
16
|
|
|
* @property int $id |
17
|
|
|
* @property int $delivery_provider_id |
18
|
|
|
* @property string $name |
19
|
|
|
* @property string $price_type |
20
|
|
|
* @property number $price |
21
|
|
|
* @property int $currency_id |
22
|
|
|
* @property string $price_text |
23
|
|
|
* @property number $max_cart_price |
24
|
|
|
* @property int $icon_file_id |
25
|
|
|
* @property string $info |
26
|
|
|
* @property bool $disabled |
27
|
|
|
* @property number $weight |
28
|
|
|
* @property string $date_create |
29
|
|
|
* @property \Files\File $icon |
30
|
|
|
* @property \Money\Currency $currency |
31
|
|
|
* @property \Ecommerce\Delivery\Field[] $fields |
32
|
|
|
* @property \Ecommerce\Delivery\Price[] $prices |
33
|
|
|
*/ |
34
|
|
|
class Delivery extends \Model { |
35
|
|
|
|
36
|
|
|
public static $objectName = 'Доставка'; |
37
|
|
|
public static $cols = [ |
38
|
|
|
//Основные параметры |
39
|
|
|
'name' => ['type' => 'text'], |
40
|
|
|
'delivery_provider_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'provider'], |
41
|
|
|
'price' => ['type' => 'decimal'], |
42
|
|
|
'currency_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'currency'], |
43
|
|
|
'price_text' => ['type' => 'textarea'], |
44
|
|
|
'max_cart_price' => ['type' => 'decimal'], |
45
|
|
|
'icon_file_id' => ['type' => 'image'], |
46
|
|
|
'info' => ['type' => 'html'], |
47
|
|
|
'disabled' => ['type' => 'bool'], |
48
|
|
|
//Системные |
49
|
|
|
'weight' => ['type' => 'number'], |
50
|
|
|
'date_create' => ['type' => 'dateTime'], |
51
|
|
|
//Менеджеры |
52
|
|
|
'field' => ['type' => 'dataManager', 'relation' => 'fields'], |
53
|
|
|
'priceChanger' => ['type' => 'dataManager', 'relation' => 'prices'] |
54
|
|
|
]; |
55
|
|
|
public static $labels = [ |
56
|
|
|
'name' => 'Название', |
57
|
|
|
'price_type' => 'Тип расчета стоимости', |
58
|
|
|
'price' => 'Стоимость', |
59
|
|
|
'price_text' => 'Текстовое описание стоимости (отображается вместо цены)', |
60
|
|
|
'max_cart_price' => 'Басплатно при', |
61
|
|
|
'icon_file_id' => 'Иконка', |
62
|
|
|
'currency_id' => 'Валюта', |
63
|
|
|
'info' => 'Дополнительная информация', |
64
|
|
|
'priceChanger' => 'Градация стоимости', |
65
|
|
|
'field' => 'Поля', |
66
|
|
|
'disabled' => 'Отключено', |
67
|
|
|
]; |
68
|
|
|
public static $dataManagers = [ |
69
|
|
|
'manager' => [ |
70
|
|
|
'name' => 'Варианты доставки', |
71
|
|
|
'cols' => [ |
72
|
|
|
'name', |
73
|
|
|
'delivery_provider_id', |
74
|
|
|
'price', |
75
|
|
|
'currency_id', |
76
|
|
|
'max_cart_price', |
77
|
|
|
'disabled', |
78
|
|
|
'field', |
79
|
|
|
'priceChanger', |
80
|
|
|
], |
81
|
|
|
'sortMode' => true |
82
|
|
|
], |
83
|
|
|
]; |
84
|
|
|
public static $forms = [ |
85
|
|
|
'manager' => [ |
86
|
|
|
'map' => [ |
87
|
|
|
['name','delivery_provider_id', 'disabled'], |
88
|
|
|
['price', 'currency_id'], |
89
|
|
|
['max_cart_price', 'icon_file_id'], |
90
|
|
|
['price_text'], |
91
|
|
|
['info'], |
92
|
|
|
['priceChanger'], |
93
|
|
|
['field'] |
94
|
|
|
] |
95
|
|
|
]]; |
96
|
|
|
|
97
|
|
|
public static function relations() { |
98
|
|
|
return [ |
99
|
|
|
'icon' => [ |
100
|
|
|
'model' => 'Files\File', |
101
|
|
|
'col' => 'icon_file_id' |
102
|
|
|
], |
103
|
|
|
'currency' => [ |
104
|
|
|
'model' => 'Money\Currency', |
105
|
|
|
'col' => 'currency_id' |
106
|
|
|
], |
107
|
|
|
'fields' => [ |
108
|
|
|
'type' => 'relModel', |
109
|
|
|
'model' => 'Ecommerce\Delivery\Field', |
110
|
|
|
'relModel' => 'Ecommerce\Delivery\DeliveryFieldLink' |
111
|
|
|
], |
112
|
|
|
'prices' => [ |
113
|
|
|
'type' => 'many', |
114
|
|
|
'model' => 'Ecommerce\Delivery\Price', |
115
|
|
|
'col' => 'delivery_id' |
116
|
|
|
], |
117
|
|
|
'provider' => [ |
118
|
|
|
'model' => 'Ecommerce\Delivery\Provider', |
119
|
|
|
'col' => 'delivery_provider_id' |
120
|
|
|
] |
121
|
|
|
]; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
} |
125
|
|
|
|