Blame view

frontend/controllers/SearchController.php 3.6 KB
fbdb1f1c   Yarik   test
1
  <?php
35b03e57   Administrator   add yii jquery
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
  namespace frontend\controllers;
  
  use common\models\CustomerSearch;
  use common\models\Project;
  use common\models\Specialization;
  use common\models\UserInfo;
  use common\models\Vacancy;
  use frontend\models\SearchPerformerForm;
  use Yii;
  use common\models\LoginForm;
  use frontend\models\PasswordResetRequestForm;
  use frontend\models\ResetPasswordForm;
  use frontend\models\SignupForm;
  use frontend\models\ContactForm;
  use frontend\models\Options;
  use frontend\models\OptionValues;
  use yii\base\InvalidParamException;
  use yii\data\ActiveDataProvider;
  use yii\data\Pagination;
  use yii\helpers\ArrayHelper;
  use yii\web\BadRequestHttpException;
  use yii\web\Controller;
  use yii\filters\VerbFilter;
  use yii\filters\AccessControl;
  use frontend\models\OptionsToValues;
  use yii\validators\EmailValidator;
  use common\models\User;
  use yii\helpers\VarDumper;
  use common\models\Page; 
  use frontend\models\Option;
  use common\models\Social;
fbdb1f1c   Yarik   test
33
34
  
      /**
2fd40ee7   Yarik   test
35
       * Site controller
fbdb1f1c   Yarik   test
36
       */
2fd40ee7   Yarik   test
37
      class SearchController extends Controller
fbdb1f1c   Yarik   test
38
      {
6dd6c4bf   Administrator   17.02.16
39
  
2fd40ee7   Yarik   test
40
          public $defaultAction = 'common';
fbdb1f1c   Yarik   test
41
  
2fd40ee7   Yarik   test
42
43
44
45
46
47
48
49
          /**
           * @inheritdoc
           */
          public function actions()
          {
              return [
                  'error'   => [
                      'class' => 'yii\web\ErrorAction',
f94a00a6   Yarik   test
50
                  ],
2fd40ee7   Yarik   test
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
                  'captcha' => [
                      'class'           => 'yii\captcha\CaptchaAction',
                      'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : NULL,
                  ],
              ];
          }
  
          public function actionProject()
          {
              $projects = new ActiveDataProvider([
                  'query'      => Project::find(),
                  'pagination' => [
                      'pageSize' => 9,
                  ],
              ]);
              return $this->render('project', [
                  'projects' => $projects,
              ]);
          }
  
          public function actionCustomer()
          {
              $model = new CustomerSearch();
              $dataProvider = $model->search(Yii::$app->request->queryParams);
              $dataProvider->setPagination([
                  'pageSize' => 5,
              ]);
2fd40ee7   Yarik   test
78
              $model->load(Yii::$app->request->queryParams);
2fd40ee7   Yarik   test
79
80
81
              return $this->render('customer', [
                  'model'        => $model,
                  'dataProvider' => $dataProvider,
2fd40ee7   Yarik   test
82
83
84
              ]);
          }
  
2fd40ee7   Yarik   test
85
  
2fd40ee7   Yarik   test
86
  
35b03e57   Administrator   add yii jquery
87
88
      public function actionPerformer()
      {
eb7e82fb   Administrator   29.02.16
89
  
35b03e57   Administrator   add yii jquery
90
  
dafc9daf   Administrator   add yii jquery
91
92
93
          $specializationArray = Specialization::specializationsList();
  
  
eb7e82fb   Administrator   29.02.16
94
  
35b03e57   Administrator   add yii jquery
95
96
97
98
99
100
101
102
103
104
105
  
          $searchModel = new SearchPerformerForm();
  
  
          return $this->render('performer',[
              'dataProvider' => $searchModel->search(Yii::$app->request->queryParams),
              'specialization' => $specializationArray,
              'model'=> $searchModel
          ]);
      }
  
2fd40ee7   Yarik   test
106
107
          public function actionVacancy()
          {
eb7e82fb   Administrator   29.02.16
108
  
2fd40ee7   Yarik   test
109
              $query = Vacancy::find();
eb7e82fb   Administrator   29.02.16
110
  
35b03e57   Administrator   add yii jquery
111
          $countQuery = clone $query;
eb7e82fb   Administrator   29.02.16
112
  
2fd40ee7   Yarik   test
113
114
115
116
              $pagination = new Pagination([
                  'totalCount' => $countQuery->count(),
                  'pageSize'   => 15,
              ]);
eb7e82fb   Administrator   29.02.16
117
  
2fd40ee7   Yarik   test
118
119
              $vacancy = $query->offset($pagination->offset)
                               ->limit($pagination->limit);
eb7e82fb   Administrator   29.02.16
120
  
2fd40ee7   Yarik   test
121
122
123
124
125
126
127
128
129
130
              $provider = new ActiveDataProvider([
                  'query'      => $vacancy,
                  'pagination' => false,
                  'sort'       => [
                      'defaultOrder' => [
                          'date_add' => SORT_DESC,
                          'name'     => SORT_ASC,
                      ],
                  ],
              ]);
eb7e82fb   Administrator   29.02.16
131
  
2fd40ee7   Yarik   test
132
133
134
135
136
              return $this->render('vacancy', [
                  'provider'   => $provider,
                  'pagination' => $pagination,
              ]);
          }
eb7e82fb   Administrator   29.02.16
137
  
7fc05ac5   Yarik   test
138
      }