-
Notifications
You must be signed in to change notification settings - Fork 13
/
Module.php
124 lines (91 loc) · 3.5 KB
/
Module.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
namespace pistol88\order;
use pistol88\order\behaviors\ShippingCost;
use yii;
class Module extends \yii\base\Module
{
const EVENT_ORDER_CREATE = 'create';
const EVENT_ORDER_DELETE = 'delete';
const EVENT_ELEMENT_DELETE = 'delete_element';
public $orderStatuses = ['new' => 'Новый', 'approve' => 'Подтвержден', 'cancel' => 'Отменен', 'process' => 'В обработке', 'done' => 'Выполнен'];
public $defaultStatus = 'new';
public $successUrl = '/order/info/thanks/';
public $orderCreateRedirect = 'order/view';
public $robotEmail = "no-reply@localhost";
public $dateFormat = 'd.m.Y H:i:s';
public $robotName = 'Robot';
public $ordersEmail = false;
public $currency = ' р.';
public $currencyPosition = 'after';
public $priceFormat = [2, '.', ''];
public $adminRoles = ['admin', 'superadmin'];
public $cartCustomFields = ['Остаток' => 'amount'];
public $paymentFormAction = false;
public $paymentFreeTypeIds = false;
public $superadminRole = 'superadmin';
public $createOrderButton = true;
public $operatorRoles = ['manager', 'admin', 'superadmin'];
public $operatorOpenStatus = 'process';
public $userModel = '\pistol88\client\models\Client';
public $userSearchModel = '\pistol88\client\models\client\ClientSearch';
public $userModelCustomFields = [];
public $productModel = 'pistol88\shop\models\Product';
public $productSearchModel = 'pistol88\shop\models\product\ProductSearch';
public $productCategories = null;
public $orderColumns = ['client_name', 'phone', 'email', 'payment_type_id', 'shipping_type_id'];
public $elementModels = []; //depricated
public $sellers = null; //collable, return seller list
public $sellerModel = '\common\models\User';
public $workers = [];
public $elementToOrderUrl = false;
public $showPaymentColumn = false;
private $mail;
public $discountDescriptionCallback = '';
public function init()
{
if(yii::$app->has('cart') && $orderShippingType = yii::$app->session->get('orderShippingType')) {
if($orderShippingType > 0) {
yii::$app->cart->attachBehavior('ShippingCost', new ShippingCost);
}
}
return parent::init();
}
public function getMail()
{
if ($this->mail === null) {
$this->mail = yii::$app->getMailer();
$this->mail->viewPath = __DIR__ . '/mails';
if ($this->robotEmail !== null) {
$this->mail->messageConfig['from'] = $this->robotName === null ? $this->robotEmail : [$this->robotEmail => $this->robotName];
}
}
return $this->mail;
}
public function getWorkersList()
{
if(is_callable($this->workers)) {
$values = $this->workers;
return $values();
} else {
return $this->workers;
}
return [];
}
public function getProductCategoriesList()
{
if(is_callable($this->productCategories))
{
$values = $this->productCategories;
return $values();
}
return [];
}
public function getSellerList()
{
if(is_callable($this->sellers)) {
$values = $this->sellers;
return $values();
}
return [];
}
}