SearchController.php
3.95 KB
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
125
126
127
128
129
130
131
132
<?php
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\data\ActiveDataProvider;
use yii\data\Pagination;
use yii\web\Controller;
use frontend\models\OptionsToValues;
use common\models\Page;
use frontend\models\Option;
/**
* Site controller
*/
class SearchController extends Controller
{
public $defaultAction = 'common';
/**
* @inheritdoc
*/
public function actions()
{
return [
'error' => [
'class' => 'yii\web\ErrorAction',
],
'captcha' => [
'class' => 'yii\captcha\CaptchaAction',
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : NULL,
],
];
}
public function actionProject()
{
$model = new TenderSearch();
$dataProvider = $model->search(Yii::$app->request->queryParams);
$dataProvider->query->andWhere(['hidden' => 0]);
$dataProvider->setPagination([
'pageSize' => 10,
]);
$specialization = Specialization::specializationsList();
$currencies = Currency::getCurrencyDropdown();
$payments = Payment::find()->select(['name', 'payment_id'])->asArray()->indexBy('payment_id')->column();
return $this->render('project', [
'model' => $model,
'dataProvider' => $dataProvider,
'specialization' => $specialization,
'currencies' => $currencies,
'payments' => $payments,
]);
}
public function actionCustomer()
{
$model = new CustomerSearch();
$dataProvider = $model->search(Yii::$app->request->queryParams);
$dataProvider->setPagination([
'pageSize' => 5,
]);
$model->load(Yii::$app->request->queryParams);
return $this->render('customer', [
'model' => $model,
'dataProvider' => $dataProvider,
]);
}
public function actionPerformer()
{
$specialization = Specialization::specializationsList();
$searchModel = new SearchPerformerForm();
return $this->render('performer',[
'dataProvider' => $searchModel->search(Yii::$app->request->queryParams),
'specialization' => $specialization,
'model'=> $searchModel
]);
}
public function actionVacancy()
{
$searchModel = new SearchVacancyForm();
$specialization = Specialization::specializationsList();
$query = $searchModel->search(Yii::$app->request->queryParams);
$countQuery = clone $query;
$pagination = new Pagination([
'totalCount' => $countQuery->count(),
'pageSize' => 15,
]);
$vacancy = $query->offset($pagination->offset)
->limit($pagination->limit);
$dataProvider = new ActiveDataProvider([
'query' => $vacancy,
'pagination' => false,
'sort' => [
'defaultOrder' => [
'date_add' => SORT_DESC,
'name' => SORT_ASC,
],
],
]);
return $this->render('vacancy',[
'dataProvider' => $dataProvider,
'specialization' => $specialization,
'model'=> $searchModel,
'pagination'=> $pagination
]);
}
}