1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Server module for HiPanel. |
4
|
|
|
* |
5
|
|
|
* @link https://github.com/hiqdev/hipanel-module-server |
6
|
|
|
* @package hipanel-module-server |
7
|
|
|
* @license BSD-3-Clause |
8
|
|
|
* @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/) |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace hipanel\modules\server\controllers; |
12
|
|
|
|
13
|
|
|
use hipanel\base\CrudController; |
14
|
|
|
use hipanel\modules\finance\models\Tariff; |
15
|
|
|
use hipanel\modules\server\cart\ServerOrderProduct; |
16
|
|
|
use hipanel\modules\server\helpers\ServerHelper; |
17
|
|
|
use hipanel\filters\EasyAccessControl; |
18
|
|
|
use hiqdev\yii2\cart\actions\AddToCartAction; |
19
|
|
|
use Yii; |
20
|
|
|
|
21
|
|
|
class OrderController extends CrudController |
22
|
|
|
{ |
23
|
|
|
public function behaviors() |
24
|
|
|
{ |
25
|
|
|
return array_merge(parent::behaviors(), [ |
26
|
|
|
[ |
27
|
|
|
'class' => EasyAccessControl::class, |
28
|
|
|
'actions' => [ |
29
|
|
|
'add-to-cart' => 'server.pay', |
30
|
|
|
'*' => 'server.read', |
31
|
|
|
], |
32
|
|
|
], |
33
|
|
|
]); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function actions() |
37
|
|
|
{ |
38
|
|
|
return [ |
39
|
|
|
'add-to-cart' => [ |
40
|
|
|
'class' => AddToCartAction::class, |
41
|
|
|
'productClass' => ServerOrderProduct::class, |
42
|
|
|
'redirectToCart' => true, |
43
|
|
|
], |
44
|
|
|
]; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function actionOrder($id) |
48
|
|
|
{ |
49
|
|
|
$package = ServerHelper::getAvailablePackages(null, $id); |
50
|
|
|
$osImages = ServerHelper::getOsimages($package->tariff->type); |
51
|
|
|
|
52
|
|
|
return $this->render('order', [ |
53
|
|
|
'package' => $package, |
54
|
|
|
'product' => new ServerOrderProduct(['tariff_id' => $package->tariff->id]), |
55
|
|
|
'groupedOsimages' => ServerHelper::groupOsimages($osImages), |
|
|
|
|
56
|
|
|
'panels' => ServerHelper::getPanels(), |
57
|
|
|
]); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function actionIndex() |
61
|
|
|
{ |
62
|
|
|
return $this->render('index'); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
View Code Duplication |
public function actionXenSsd() |
|
|
|
|
66
|
|
|
{ |
67
|
|
|
return $this->render('xen_ssd', [ |
68
|
|
|
'packages' => ServerHelper::getAvailablePackages(Tariff::TYPE_XEN), |
69
|
|
|
'tariffTypes' => Yii::$app->params['vdsproduct'], |
70
|
|
|
]); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
View Code Duplication |
public function actionOpenVz() |
|
|
|
|
74
|
|
|
{ |
75
|
|
|
return $this->render('open_vz', [ |
76
|
|
|
'packages' => ServerHelper::getAvailablePackages(Tariff::TYPE_OPENVZ), |
77
|
|
|
'tariffTypes' => Yii::$app->params['vdsproduct'], |
78
|
|
|
]); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public function actionTariffsDetails() |
82
|
|
|
{ |
83
|
|
|
return $this->render('tariffs_details'); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function actionAdvantages() |
87
|
|
|
{ |
88
|
|
|
return $this->render('advantages'); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
public function actionWhatIsVds() |
92
|
|
|
{ |
93
|
|
|
return $this->render('what_is_vds'); |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.