Commit cda2c1c964dfe19fba7ddffe90f03161e1801818

Authored by Administrator
1 parent dafc9daf

add yii jquery

backend/controllers/CurrencyController.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace backend\controllers;
  4 +
  5 +use yii\base\Controller;
  6 +use yii\filters\VerbFilter;
  7 +
  8 +class CurrencyController extends Controller{
  9 + /**
  10 + * @inheritdoc
  11 + */
  12 + public function behaviors()
  13 + {
  14 + return [
  15 + 'verbs' => [
  16 + 'class' => VerbFilter::className(),
  17 + 'actions' => [
  18 + 'delete' => ['POST'],
  19 + ],
  20 + ],
  21 + ];
  22 + }
  23 +
  24 + /**
  25 + * Lists all Specialization models.
  26 + * @return mixed
  27 + */
  28 + public function actionIndex()
  29 + {
  30 + return $this->render('index', [
  31 +
  32 + ]);
  33 + }
  34 +
  35 +
  36 +}
0 37 \ No newline at end of file
... ...
backend/views/currency/index.php 0 → 100644
  1 +<?php
  2 +
  3 +die('sdfsdf');
0 4 \ No newline at end of file
... ...
common/models/VacancySpecialization.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace common\models;
  4 +
  5 +use Yii;
  6 +
  7 +/**
  8 + * This is the model class for table "vacancy_specialization".
  9 + *
  10 + * @property integer $vacancy_specialization_id
  11 + * @property integer $vacancy_id
  12 + * @property integer $specialization_id
  13 + *
  14 + * @property Specialization $specialization
  15 + * @property Vacancy $vacancy
  16 + */
  17 +class VacancySpecialization extends \yii\db\ActiveRecord
  18 +{
  19 + /**
  20 + * @inheritdoc
  21 + */
  22 + public static function tableName()
  23 + {
  24 + return 'vacancy_specialization';
  25 + }
  26 +
  27 + /**
  28 + * @inheritdoc
  29 + */
  30 + public function rules()
  31 + {
  32 + return [
  33 + [['vacancy_id', 'specialization_id'], 'integer'],
  34 + [['specialization_id'], 'exist', 'skipOnError' => true, 'targetClass' => Specialization::className(), 'targetAttribute' => ['specialization_id' => 'specialization_id']],
  35 + [['vacancy_id'], 'exist', 'skipOnError' => true, 'targetClass' => Vacancy::className(), 'targetAttribute' => ['vacancy_id' => 'vacancy_id']],
  36 + ];
  37 + }
  38 +
  39 + /**
  40 + * @inheritdoc
  41 + */
  42 + public function attributeLabels()
  43 + {
  44 + return [
  45 + 'vacancy_specialization_id' => 'Vacancy Specialization ID',
  46 + 'vacancy_id' => 'Vacancy ID',
  47 + 'specialization_id' => 'Specialization ID',
  48 + ];
  49 + }
  50 +
  51 + /**
  52 + * @return \yii\db\ActiveQuery
  53 + */
  54 + public function getSpecialization()
  55 + {
  56 + return $this->hasOne(Specialization::className(), ['specialization_id' => 'specialization_id']);
  57 + }
  58 +
  59 + /**
  60 + * @return \yii\db\ActiveQuery
  61 + */
  62 + public function getVacancy()
  63 + {
  64 + return $this->hasOne(Vacancy::className(), ['vacancy_id' => 'vacancy_id']);
  65 + }
  66 +}
... ...
console/migrations/m160312_143616_project_add_field_total_budget.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\db\Migration;
  4 +
  5 +class m160312_143616_project_add_field_total_budget extends Migration
  6 +{
  7 + public function up()
  8 + {
  9 + $this->addColumn('{{%project}}', 'total_budget', $this->integer());
  10 + }
  11 +
  12 + public function down()
  13 + {
  14 + $this->dropColumn('{{%project}}', 'total_budget');
  15 +
  16 + }
  17 +}
... ...
frontend/controllers/CompanyController.php
... ... @@ -8,6 +8,8 @@ use common\models\Gallery;
8 8 use common\models\Portfolio;
9 9 use common\models\PortfolioSpecialization;
10 10 use common\models\Team;
  11 +use common\models\Vacancy;
  12 +use common\models\VacancySpecialization;
11 13 use Yii;
12 14 use yii\data\ActiveDataProvider;
13 15 use yii\data\ArrayDataProvider;
... ... @@ -285,9 +287,28 @@ class CompanyController extends Controller
285 287 $company = User::findOne($company_id);
286 288 $vacancy = $company->getVacancies()->where(['link' => $link])->with(['employments'])->one();
287 289  
  290 +
  291 + $specialization_id = $vacancy->getSpecializations()->select('specialization_id')->column();
  292 +
  293 + $vacancy_id = VacancySpecialization::find()->where(['specialization_id'=>$specialization_id])->select('vacancy_id')->column();
  294 +
  295 +
  296 + $similar_vacancies = Vacancy::find()
  297 + ->where([
  298 + 'city' => $vacancy->city,
  299 + 'vacancy_id' => $vacancy_id
  300 + ])
  301 + ->andFilterWhere([
  302 + '<>',
  303 + 'vacancy_id',
  304 + $vacancy->vacancy_id
  305 + ])->limit(3)
  306 + ->all();
  307 +
288 308 return $this->render('vacancy-view',[
289 309 'company' => $company,
290 310 'vacancy' => $vacancy,
  311 + 'similar_vacancies' => $similar_vacancies
291 312 ]);
292 313 }
293 314  
... ...
frontend/controllers/SearchController.php
... ... @@ -7,6 +7,7 @@ use common\models\Specialization;
7 7 use common\models\UserInfo;
8 8 use common\models\Vacancy;
9 9 use frontend\models\SearchPerformerForm;
  10 +use frontend\models\SearchVacancyForm;
10 11 use Yii;
11 12 use common\models\LoginForm;
12 13 use frontend\models\PasswordResetRequestForm;
... ... @@ -84,31 +85,30 @@ use common\models\Social;
84 85  
85 86  
86 87  
87   - public function actionPerformer()
88   - {
89   -
90   -
91   - $specializationArray = Specialization::specializationsList();
92   -
  88 + public function actionPerformer()
  89 + {
  90 + $specialization = Specialization::specializationsList();
93 91  
  92 + $searchModel = new SearchPerformerForm();
94 93  
  94 + return $this->render('performer',[
  95 + 'dataProvider' => $searchModel->search(Yii::$app->request->queryParams),
  96 + 'specialization' => $specialization,
  97 + 'model'=> $searchModel
  98 + ]);
  99 + }
95 100  
96   - $searchModel = new SearchPerformerForm();
  101 + public function actionVacancy()
  102 + {
97 103  
98 104  
99   - return $this->render('performer',[
100   - 'dataProvider' => $searchModel->search(Yii::$app->request->queryParams),
101   - 'specialization' => $specializationArray,
102   - 'model'=> $searchModel
103   - ]);
104   - }
  105 + $searchModel = new SearchVacancyForm();
105 106  
106   - public function actionVacancy()
107   - {
  107 + $specialization = Specialization::specializationsList();
108 108  
109   - $query = Vacancy::find();
  109 + $query = $searchModel->search(Yii::$app->request->queryParams);
110 110  
111   - $countQuery = clone $query;
  111 + $countQuery = clone $query;
112 112  
113 113 $pagination = new Pagination([
114 114 'totalCount' => $countQuery->count(),
... ... @@ -116,9 +116,9 @@ use common\models\Social;
116 116 ]);
117 117  
118 118 $vacancy = $query->offset($pagination->offset)
119   - ->limit($pagination->limit);
  119 + ->limit($pagination->limit);
120 120  
121   - $provider = new ActiveDataProvider([
  121 + $dataProvider = new ActiveDataProvider([
122 122 'query' => $vacancy,
123 123 'pagination' => false,
124 124 'sort' => [
... ... @@ -129,10 +129,13 @@ use common\models\Social;
129 129 ],
130 130 ]);
131 131  
132   - return $this->render('vacancy', [
133   - 'provider' => $provider,
134   - 'pagination' => $pagination,
  132 + return $this->render('vacancy',[
  133 + 'dataProvider' => $dataProvider,
  134 + 'specialization' => $specialization,
  135 + 'model'=> $searchModel,
  136 + 'pagination'=> $pagination
135 137 ]);
  138 +
136 139 }
137 140  
138 141 }
... ...
frontend/models/SearchPerformerForm.php
... ... @@ -58,21 +58,6 @@ class SearchPerformerForm extends Model
58 58 }
59 59  
60 60 /**
61   - * Sends an email to the specified email address using the information collected by this model.
62   - * @param string $email the target email address
63   - * @return boolean whether the email was sent
64   - */
65   - public function sendEmail($email)
66   - {
67   - return Yii::$app->mailer->compose()
68   - ->setTo($email)
69   - ->setFrom([$this->email => $this->name])
70   - ->setSubject($this->subject)
71   - ->setTextBody($this->body)
72   - ->send();
73   - }
74   -
75   - /**
76 61 * Creates data provider instance with search query applied
77 62 *
78 63 * @param array $params
... ... @@ -92,10 +77,7 @@ class SearchPerformerForm extends Model
92 77  
93 78  
94 79 $dataProvider = new ActiveDataProvider([
95   - 'query' => $query,
96   - 'pagination' => [
97   - 'pageSize' => 3,
98   - ],
  80 + 'query' => $query
99 81 ]);
100 82  
101 83 $dataProvider->setSort([
... ...
frontend/models/SearchVacancyForm.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace frontend\models;
  4 +
  5 +use common\models\Portfolio;
  6 +use common\models\User;
  7 +use common\models\Vacancy;
  8 +use Yii;
  9 +use yii\base\Model;
  10 +use yii\data\ActiveDataProvider;
  11 +use yii\helpers\ArrayHelper;
  12 +
  13 +/**
  14 + * ContactForm is the model behind the contact form.
  15 + */
  16 +class SearchVacancyForm extends Model
  17 +{
  18 + public $city;
  19 + public $specialization;
  20 +
  21 +
  22 +
  23 + /**
  24 + * @inheritdoc
  25 + */
  26 + public function rules()
  27 + {
  28 + return [
  29 + [['specialization','city'], 'safe'],
  30 +
  31 + ];
  32 + }
  33 +
  34 + /**
  35 + * @inheritdoc
  36 + */
  37 + public function attributeLabels()
  38 + {
  39 + return [
  40 + 'city' => 'Город',
  41 + 'specialization' => 'Специализация'
  42 + ];
  43 + }
  44 +
  45 + /**
  46 + * Creates data provider instance with search query applied
  47 + *
  48 + * @param array $params
  49 + *
  50 + * @return ActiveDataProvider
  51 + */
  52 + public function search($params)
  53 + {
  54 +
  55 + $this->load($params);
  56 +
  57 + $query = Vacancy::find()
  58 + ->distinct(true)
  59 + ->joinWith(['specializations']);
  60 +
  61 +
  62 +
  63 +
  64 +
  65 +
  66 + if (!$this->validate()) {
  67 +
  68 +
  69 + // uncomment the following line if you do not want to any records when validation fails
  70 + // $query->where('0=1');
  71 + return $query;
  72 + }
  73 +
  74 + $query->andFilterWhere([
  75 + 'vacancy.city' => $this->city,
  76 + 'specialization.specialization_id' => $this->specialization,
  77 + ]);
  78 +
  79 +
  80 +
  81 +
  82 +
  83 + return $query;
  84 + }
  85 +}
  86 +
... ...
frontend/views/company/vacancy-view.php
... ... @@ -9,8 +9,9 @@
9 9 use common\models\Vacancy;
10 10 use yii\helpers\ArrayHelper;
11 11 use yii\helpers\Html;
  12 +use yii\helpers\Url;
12 13  
13   - $this->params[ 'company' ] = $company;
  14 +$this->params[ 'company' ] = $company;
14 15 $this->title = 'My Yii Application';
15 16 ?>
16 17 <div class="performer-vacancy-list style">
... ... @@ -65,20 +66,27 @@
65 66 <div class="performance-vacancy-similar-title style">Похожие вакансии</div>
66 67 <div class="style">
67 68  
  69 + <?php foreach($similar_vacancies as $similar_vacancy):?>
68 70 <div class="performance-vacancy-similar-blocks-wr style">
69   - <a href="#" class="performer-vacant-reclam-bl-title">Инженер-технолог строитель</a>
70   - <div class="performer-vacant-reclam-bl-title-two">Бровары, ищем в Киеве. 21 декабря 2015. 8000 грн.</div>
71   - </div>
72 71  
73   - <div class="performance-vacancy-similar-blocks-wr style">
74   - <a href="#" class="performer-vacant-reclam-bl-title">Разнорабочий (в Бровары)</a>
75   - <div class="performer-vacant-reclam-bl-title-two">Наш Дом. Киев.</div>
76   - </div>
  72 + <?= Html::a($similar_vacancy->name, Url::toRoute([
  73 + 'company/vacancy-view',
  74 + 'company_id' => $similar_vacancy->user_id,
  75 + 'link' => $similar_vacancy->link,
  76 + ]), [ 'class' => 'performer-vacant-reclam-bl-title' ]) ?>
77 77  
78   - <div class="performance-vacancy-similar-blocks-wr style">
79   - <a href="#" class="performer-vacant-reclam-bl-title">Замерщик по мебели (в Бровары)</a>
80   - <div class="performer-vacant-reclam-bl-title-two">Наш Дом. Киев. 5000 грн.</div>
  78 + <div class="performer-vacant-reclam-bl-title-two"><?= $similar_vacancy->city ?>. <?= \Yii::$app->formatter->asDatetime($similar_vacancy->date_add, 'Y-MM-dd') ?>.
  79 + <?php
  80 + if(!empty( $similar_vacancy->salary )) {
  81 + ?>
  82 + <?= $similar_vacancy->salary ?>
  83 + <?= $similar_vacancy->salaryCurrency->label ?>
  84 + <?php
  85 + }
  86 + ?></div>
81 87 </div>
  88 + <?php endforeach;?>
  89 +
82 90  
83 91 </div>
84 92 </div>
85 93 \ No newline at end of file
... ...
frontend/views/search/vacancy.php
1 1 <?php
2 2  
  3 +use kartik\select2\Select2;
3 4 use \yii\helpers\Html;
  5 +use yii\web\JsExpression;
  6 +use yii\widgets\ActiveForm;
4 7 use yii\widgets\LinkPager;
5 8 use yii\widgets\ListView;
6 9  
... ... @@ -15,36 +18,41 @@ $this-&gt;title = &#39;My Yii Application&#39;;
15 18 <div class="box-all">
16 19 <div class="performer-vacancy-sidebar-left-wr vacancy-general-sidebar-wr">
17 20 <div class="left-search-work">
18   - <form action="" class="search-work-form">
19   - <div class="blocks-check-list-wrapp">
20   - <div class="blocks-check-title"><label for="theme-1">Город</label></div>
21   - <select id="theme-1">
22   - <option selected value="">Любой</option>
23   - <option value="">Киев</option>
24   - <option value="">Житомир</option>
25   - <option value="">Львов</option>
26   - <option value="">Киев</option>
27   - <option value="">Житомир</option>
28   - <option value="">Львов</option>
29   - </select>
30   - </div>
31   - <div class="blocks-check-list-wrapp">
32   - <div class="blocks-check-title"><label for="theme-2">Специализация</label></div>
33   - <select id="theme-2">
34   - <option selected value="">Любая</option>
35   - <option value="">Киев</option>
36   - <option value="">Житомир</option>
37   - <option value="">Львов</option>
38   - <option value="">Киев</option>
39   - <option value="">Житомир</option>
40   - <option value="">Львов</option>
41   - </select>
42   - </div>
  21 + <?php
  22 + $form = ActiveForm::begin(['options'=>['class'=>'search-work-form'],'action'=>[''], 'method'=>'get']);
  23 + ?>
  24 +
  25 + <?=
  26 + $form->field($model, 'city')
  27 + ->widget(Select2::classname(), [
  28 + 'options' => [ 'placeholder' => 'Выбор города ...' ],
  29 + 'pluginOptions' => [
  30 + 'allowClear' => true,
  31 + 'minimumInputLength' => 3,
  32 + 'ajax' => [
  33 + 'url' => \yii\helpers\Url::to([ 'site/city' ]),
  34 + 'dataType' => 'json',
  35 + 'data' => new JsExpression('function(params) { return {q:params.term}; }'),
  36 + ],
  37 + 'escapeMarkup' => new JsExpression('function (markup) { return markup; }'),
  38 + 'templateResult' => new JsExpression('function(city) { return city.text; }'),
  39 + 'templateSelection' => new JsExpression('function (city) { return city.text; }'),
  40 + ],
  41 + ]);
  42 + ?>
  43 +
  44 + <?=
  45 + $form->field($model, 'specialization')
  46 + ->dropDownList($specialization, ['prompt' => 'Любая']);
  47 + ?>
  48 +
43 49  
44 50 <div class="blocks-check-list-submit">
45   - <input type="submit" value="Найти"/>
  51 + <?= Html::submitInput('Найти') ?>
46 52 </div>
47   - </form>
  53 + <?php
  54 + $form->end();
  55 + ?>
48 56 </div>
49 57 </div>
50 58 <div class="section-box performer-vacancy-vacant-wr">
... ... @@ -53,7 +61,7 @@ $this-&gt;title = &#39;My Yii Application&#39;;
53 61  
54 62 <?=
55 63 ListView::widget([
56   - 'dataProvider' => $provider,
  64 + 'dataProvider' => $dataProvider,
57 65 'itemView' => '_vacancy_list_view',
58 66 'summary' => false,
59 67 ]);
... ...