fbdb1f1c
Yarik
test
|
1
|
<?php
|
9a26e63d
Yarik
Commit
|
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
namespace frontend\controllers;
use common\models\Currency;
use common\models\CustomerSearch;
use common\models\Payment;
use common\models\Specialization;
use common\models\TenderSearch;
use frontend\models\SearchPerformerForm;
use frontend\models\SearchVacancyForm;
use Yii;
use frontend\models\Options;
use frontend\models\OptionValues;
use yii\base\InvalidParamException;
use yii\data\ActiveDataProvider;
use yii\data\Pagination;
use yii\db\ActiveQuery;
use yii\web\Controller;
use frontend\models\OptionsToValues;
use common\models\Page;
use frontend\models\Option;
|
fbdb1f1c
Yarik
test
|
22
23
|
/**
|
2fd40ee7
Yarik
test
|
24
|
* Site controller
|
fbdb1f1c
Yarik
test
|
25
|
*/
|
2fd40ee7
Yarik
test
|
26
|
class SearchController extends Controller
|
fbdb1f1c
Yarik
test
|
27
|
{
|
6dd6c4bf
Administrator
17.02.16
|
28
|
|
2fd40ee7
Yarik
test
|
29
|
public $defaultAction = 'common';
|
fbdb1f1c
Yarik
test
|
30
|
|
2fd40ee7
Yarik
test
|
31
32
33
34
35
36
37
38
|
/**
* @inheritdoc
*/
public function actions()
{
return [
'error' => [
'class' => 'yii\web\ErrorAction',
|
f94a00a6
Yarik
test
|
39
|
],
|
2fd40ee7
Yarik
test
|
40
41
42
43
44
45
46
|
'captcha' => [
'class' => 'yii\captcha\CaptchaAction',
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : NULL,
],
];
}
|
93a7a3c1
Yarik
test
|
47
48
49
50
51
52
|
public function actionCommon($action)
{
$query = \Yii::$app->request->get('query');
$actions = [
1 => 'project',
2 => 'performer',
|
9a26e63d
Yarik
Commit
|
53
|
3 => 'customer',
|
93a7a3c1
Yarik
test
|
54
55
|
];
if(!array_key_exists($action, $actions)) {
|
9a26e63d
Yarik
Commit
|
56
57
58
59
|
return $this->redirect([
'/',
'query' => $query,
]);
|
93a7a3c1
Yarik
test
|
60
61
62
|
} else {
switch($action) {
case 1:
|
9a26e63d
Yarik
Commit
|
63
64
65
66
67
|
return $this->redirect([
'search/' . $actions[ $action ],
'TenderSearch[info]' => $query,
]);
break;
|
93a7a3c1
Yarik
test
|
68
|
case 2:
|
9a26e63d
Yarik
Commit
|
69
70
71
72
|
return $this->redirect([
'search/' . $actions[ $action ],
'SearchPerformerForm[search]' => $query,
]);
|
93a7a3c1
Yarik
test
|
73
74
|
break;
case 3:
|
9a26e63d
Yarik
Commit
|
75
76
77
78
|
return $this->redirect([
'search/' . $actions[ $action ],
'CustomerSearch[info]' => $query,
]);
|
93a7a3c1
Yarik
test
|
79
80
81
82
83
84
|
break;
}
}
return false;
}
|
2fd40ee7
Yarik
test
|
85
86
|
public function actionProject()
{
|
ad6304d6
Yarik
test
|
87
88
|
$model = new TenderSearch();
$dataProvider = $model->search(Yii::$app->request->queryParams);
|
9a26e63d
Yarik
Commit
|
89
|
$dataProvider->query->andWhere([ 'hidden' => 0 ]);
|
ad6304d6
Yarik
test
|
90
91
|
$dataProvider->setPagination([
'pageSize' => 10,
|
2fd40ee7
Yarik
test
|
92
|
]);
|
ad6304d6
Yarik
test
|
93
94
|
$specialization = Specialization::specializationsList();
$currencies = Currency::getCurrencyDropdown();
|
9a26e63d
Yarik
Commit
|
95
96
97
98
99
100
101
102
|
$payments = Payment::find()
->select([
'name',
'payment_id',
])
->asArray()
->indexBy('payment_id')
->column();
|
2fd40ee7
Yarik
test
|
103
|
return $this->render('project', [
|
9a26e63d
Yarik
Commit
|
104
105
|
'model' => $model,
'dataProvider' => $dataProvider,
|
ad6304d6
Yarik
test
|
106
|
'specialization' => $specialization,
|
9a26e63d
Yarik
Commit
|
107
108
|
'currencies' => $currencies,
'payments' => $payments,
|
2fd40ee7
Yarik
test
|
109
110
111
112
113
114
115
116
117
118
|
]);
}
public function actionCustomer()
{
$model = new CustomerSearch();
$dataProvider = $model->search(Yii::$app->request->queryParams);
$dataProvider->setPagination([
'pageSize' => 5,
]);
|
2fd40ee7
Yarik
test
|
119
|
$model->load(Yii::$app->request->queryParams);
|
2fd40ee7
Yarik
test
|
120
121
122
|
return $this->render('customer', [
'model' => $model,
'dataProvider' => $dataProvider,
|
2fd40ee7
Yarik
test
|
123
124
125
|
]);
}
|
cda2c1c9
Administrator
add yii jquery
|
126
127
128
|
public function actionPerformer()
{
$specialization = Specialization::specializationsList();
|
dafc9daf
Administrator
add yii jquery
|
129
|
|
9a26e63d
Yarik
Commit
|
130
|
$specializations = Specialization::getSorted()->all();
|
a2cb610b
Yarik
Commit
|
131
|
|
cda2c1c9
Administrator
add yii jquery
|
132
|
$searchModel = new SearchPerformerForm();
|
eb7e82fb
Administrator
29.02.16
|
133
|
|
9a26e63d
Yarik
Commit
|
134
135
136
|
return $this->render('performer', [
'dataProvider' => $searchModel->search(Yii::$app->request->queryParams),
'specialization' => $specialization,
|
a2cb610b
Yarik
Commit
|
137
|
'specializations' => $specializations,
|
9a26e63d
Yarik
Commit
|
138
|
'model' => $searchModel,
|
cda2c1c9
Administrator
add yii jquery
|
139
140
|
]);
}
|
35b03e57
Administrator
add yii jquery
|
141
|
|
cda2c1c9
Administrator
add yii jquery
|
142
143
|
public function actionVacancy()
{
|
cda2c1c9
Administrator
add yii jquery
|
144
|
$searchModel = new SearchVacancyForm();
|
35b03e57
Administrator
add yii jquery
|
145
|
|
cda2c1c9
Administrator
add yii jquery
|
146
|
$specialization = Specialization::specializationsList();
|
eb7e82fb
Administrator
29.02.16
|
147
|
|
cda2c1c9
Administrator
add yii jquery
|
148
|
$query = $searchModel->search(Yii::$app->request->queryParams);
|
eb7e82fb
Administrator
29.02.16
|
149
|
|
cda2c1c9
Administrator
add yii jquery
|
150
|
$countQuery = clone $query;
|
eb7e82fb
Administrator
29.02.16
|
151
|
|
2fd40ee7
Yarik
test
|
152
153
154
155
|
$pagination = new Pagination([
'totalCount' => $countQuery->count(),
'pageSize' => 15,
]);
|
eb7e82fb
Administrator
29.02.16
|
156
|
|
2fd40ee7
Yarik
test
|
157
|
$vacancy = $query->offset($pagination->offset)
|
9a26e63d
Yarik
Commit
|
158
|
->limit($pagination->limit);
|
eb7e82fb
Administrator
29.02.16
|
159
|
|
cda2c1c9
Administrator
add yii jquery
|
160
|
$dataProvider = new ActiveDataProvider([
|
2fd40ee7
Yarik
test
|
161
162
163
164
165
166
167
168
169
|
'query' => $vacancy,
'pagination' => false,
'sort' => [
'defaultOrder' => [
'date_add' => SORT_DESC,
'name' => SORT_ASC,
],
],
]);
|
eb7e82fb
Administrator
29.02.16
|
170
|
|
9a26e63d
Yarik
Commit
|
171
172
|
return $this->render('vacancy', [
'dataProvider' => $dataProvider,
|
cda2c1c9
Administrator
add yii jquery
|
173
|
'specialization' => $specialization,
|
9a26e63d
Yarik
Commit
|
174
175
|
'model' => $searchModel,
'pagination' => $pagination,
|
2fd40ee7
Yarik
test
|
176
|
]);
|
cda2c1c9
Administrator
add yii jquery
|
177
|
|
2fd40ee7
Yarik
test
|
178
|
}
|
eb7e82fb
Administrator
29.02.16
|
179
|
|
7fc05ac5
Yarik
test
|
180
|
}
|