diff --git a/common/models/Specialization.php b/common/models/Specialization.php
index 1c94e8d..410c19e 100755
--- a/common/models/Specialization.php
+++ b/common/models/Specialization.php
@@ -3,6 +3,7 @@
namespace common\models;
use Yii;
+use yii\helpers\ArrayHelper;
/**
* This is the model class for table "specialization".
@@ -63,4 +64,15 @@ class Specialization extends \yii\db\ActiveRecord
return $this->hasMany(self::className(), ['specialization_pid' => 'specialization_id']);
}
+ public function hasChildrenInArray($array){
+ $array = ArrayHelper::map($array,'specialization_id', 'specialization_name','specialization_pid');
+
+ if(isset($array[$this->specialization_id])){
+ return $array[$this->specialization_id];
+ } else {
+ return false;
+ }
+
+ }
+
}
diff --git a/common/models/User.php b/common/models/User.php
index 2f3b21d..a632bf1 100755
--- a/common/models/User.php
+++ b/common/models/User.php
@@ -51,12 +51,17 @@
return '{{%user}}';
}
+
+
/**
* @inheritdoc
*/
public function behaviors()
{
return [
+ [
+ 'class' => 'common\behaviors\ShowImage',
+ ],
TimestampBehavior::className(),
];
}
diff --git a/frontend/controllers/SearchController.php b/frontend/controllers/SearchController.php
index 6c386e7..cce4259 100755
--- a/frontend/controllers/SearchController.php
+++ b/frontend/controllers/SearchController.php
@@ -1,32 +1,35 @@
joinWith([ 'user' ])
- ->where([
- 'is_customer' => 1,
- 'user.type' => 2,
- ]);
-
- $companies = new ActiveDataProvider([
- 'query' => $query,
- 'pagination' => [
- 'pageSize' => 3,
- ],
- ]);
- return $this->render('company', [
- 'companies' => $companies,
- ]);
- }
- public function actionPerformer()
- {
- $query = UserInfo::find()
- ->joinWith([ 'user' ])
- ->where([
- 'is_customer' => 1,
- 'user.type' => 1,
- ]);
-
- $performer = new ActiveDataProvider([
- 'query' => $query,
- 'pagination' => [
- 'pageSize' => 3,
- ],
- ]);
+ public function actionPerformer()
+ {
- return $this->render('performer', [
- 'performer' => $performer,
- ]);
+
+ $specializationArray = [];
+
+ $specialization = Specialization::find()->where(['specialization_id'=> Specialization::find()->select('specialization_id')
+ ->andWhere('specialization_pid != 0')
+ ->column()])
+ ->all();
+
+ foreach(ArrayHelper::index($specialization,'specialization_id') as $spec){
+ $array = $spec->hasChildrenInArray($specialization);
+ if($array){
+ $specializationArray[$spec->specialization_name] = $array;
+ }
}
+
+ $searchModel = new SearchPerformerForm();
+
+
+ return $this->render('performer',[
+ 'dataProvider' => $searchModel->search(Yii::$app->request->queryParams),
+ 'specialization' => $specializationArray,
+ 'model'=> $searchModel
+ ]);
+ }
+
public function actionVacancy()
{
$query = Vacancy::find();
- $countQuery = clone $query;
+ $countQuery = clone $query;
$pagination = new Pagination([
'totalCount' => $countQuery->count(),
diff --git a/frontend/models/SearchPerformerForm.php b/frontend/models/SearchPerformerForm.php
new file mode 100644
index 0000000..679ed56
--- /dev/null
+++ b/frontend/models/SearchPerformerForm.php
@@ -0,0 +1,229 @@
+ 0,
+ ]
+
+ ];
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function attributeLabels()
+ {
+ return [
+ 'city' => 'Город',
+ 'specialization' => 'Специализация',
+ 'type' => 'Тип исполнителя',
+ 'additional_parameters' => 'Тип исполнителя',
+ 'working_conditions' => 'Условия работы',
+ 'rating' => 'Рейтинг',
+ 'online' => 'Статус',
+ 'search' => 'Найти'
+ ];
+ }
+
+ /**
+ * Sends an email to the specified email address using the information collected by this model.
+ * @param string $email the target email address
+ * @return boolean whether the email was sent
+ */
+ public function sendEmail($email)
+ {
+ return Yii::$app->mailer->compose()
+ ->setTo($email)
+ ->setFrom([$this->email => $this->name])
+ ->setSubject($this->subject)
+ ->setTextBody($this->body)
+ ->send();
+ }
+
+ /**
+ * Creates data provider instance with search query applied
+ *
+ * @param array $params
+ *
+ * @return ActiveDataProvider
+ */
+ public function search($params)
+ {
+
+ $this->load($params);
+
+ $query = User::find()
+ ->select(['user.*', 'company_info.*','user_info.*'])
+ ->distinct(true)
+ ->joinWith(['userInfo','specializations','companyInfo'])
+ ->where(['user_info.is_freelancer' => 1]);
+
+
+ $dataProvider = new ActiveDataProvider([
+ 'query' => $query,
+ 'pagination' => [
+ 'pageSize' => 3,
+ ],
+ ]);
+
+ $dataProvider->setSort([
+ 'defaultOrder' => [
+ 'name' => SORT_ASC,
+ ],
+ 'attributes' => [
+ 'name' => [
+ 'asc' => [
+ 'company_info.name' => SORT_ASC,
+ 'firstname' => SORT_ASC,
+ 'lastname' => SORT_ASC,
+ ],
+ 'desc' => [
+ 'company_info.name' => SORT_DESC,
+ 'firstname' => SORT_DESC,
+ 'lastname' => SORT_DESC,
+ ],
+ 'default' => SORT_ASC,
+ 'label' => 'Название',
+ ],
+ 'visit' => [
+ 'asc' => [
+ 'user_info.date_visit' => SORT_ASC,
+ ],
+ 'desc' => [
+ 'user_info.date_visit' => SORT_DESC,
+ ],
+ 'default' => SORT_DESC,
+ 'label' => 'Последний визит',
+ ],
+ 'city' => [
+ 'asc' => [
+ 'user_info.city' => SORT_ASC,
+ ],
+ 'desc' => [
+ 'user_info.city' => SORT_DESC,
+ ],
+ 'default' => SORT_ASC,
+ 'label' => 'Город',
+ ],
+ ],
+ ]);
+
+
+ if (!$this->validate()) {
+
+
+ // uncomment the following line if you do not want to any records when validation fails
+ // $query->where('0=1');
+ return $dataProvider;
+ }
+
+ $query->andFilterWhere([
+ 'user_info.city' => $this->city,
+ 'specialization.specialization_id' => $this->specialization,
+ 'user.type' => $this->type,
+
+ ]);
+
+ $query->andFilterWhere([
+ '>=', 'user_info.rating', $this->rating,
+ ]);
+
+ if($this->online == 1) {
+ $query->andWhere([
+ '>=',
+ 'user_info.date_visit',
+ date('Y-m-d H:i:s.u', time() - 1800),
+ ]);
+ }
+
+ foreach($this->working_conditions as $working_conditions){
+ if($working_conditions=='guarantee'){
+ $query->andWhere([
+ '<>',
+ 'user_info.guarantee',
+ ''
+ ]);
+ }else if($working_conditions=='prepayment'){
+ $query->andWhere([
+ 'user_info.prepayment'=>0,
+
+ ]);
+ }else {
+ $query->andFilterWhere([
+ 'user_info.'.$working_conditions => 1,
+ ]);
+ }
+
+ }
+
+ foreach($this->additional_parameters as $additional_parameters){
+
+ switch ($additional_parameters) {
+ case 'with_portfolio':
+ $query->andFilterWhere([
+ 'user.id'=>ArrayHelper::toArray(Portfolio::find()->select('user_id')->column()),
+ ]);
+ break;
+ case 'with_comments':
+ $query->andFilterWhere([
+ 'user.id'=>ArrayHelper::toArray(Portfolio::find()->select('user_id')->column()),
+ ]);
+ break;
+ case 'only_free':
+ $query->andFilterWhere([
+ 'user_info.busy'=>0,
+ ]);
+ break;
+ }
+ }
+
+
+ if(!empty( $this->search)){
+
+ $query->andFilterWhere([
+ 'or',
+ ['like', 'user.firstname', $this->search],
+ ['like', 'user.lastname', $this->search],
+ ['like', 'company_info.name', $this->search]
+ ]);
+ }
+
+
+
+
+ return $dataProvider;
+ }
+}
+
diff --git a/frontend/views/accounts/general.php b/frontend/views/accounts/general.php
index 77e332f..4fff6e9 100755
--- a/frontend/views/accounts/general.php
+++ b/frontend/views/accounts/general.php
@@ -27,7 +27,7 @@
- = $form->field($user, 'isPerformer', [ 'template' => "{input}\n{label}\n{error}" ])
+ = $form->field($user_info, 'is_freelancer', [ 'template' => "{input}\n{label}\n{error}" ])
->label('
Я - исполнитель')
->checkbox([
'class' => 'custom-check disabled admin-check',
@@ -41,7 +41,7 @@
- = $form->field($user, 'isCustomer', [ 'template' => "{input}\n{label}\n{error}" ])
+ = $form->field($user_info, 'is_customer', [ 'template' => "{input}\n{label}\n{error}" ])
->label('
Я - заказчик')
->checkbox([
'class' => 'custom-check disabled admin-check',
diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php
index ac763d0..5568fb1 100755
--- a/frontend/views/layouts/main.php
+++ b/frontend/views/layouts/main.php
@@ -89,7 +89,7 @@ AppAsset::register($this);
= Html::a('Список проектов', ['search/project'])?>
= Html::a('Список вакансий', ['search/vacancy'])?>
- = Html::a('Список заказчиков', ['site/index'])?>
+ = Html::a('Список заказчиков', ['search/customer'])?>
@@ -103,8 +103,8 @@ AppAsset::register($this);
- = Html::a('Список проектантов', ['search/performer'])?>
- = Html::a('Список проектных компаний', ['search/company'])?>
+ = Html::a('Список проектантов', ['search/performer','SearchPerformerForm[type]'=>'1'])?>
+ = Html::a('Список проектных компаний', ['search/performer','SearchPerformerForm[type]'=>'2'])?>
@@ -120,7 +120,7 @@ AppAsset::register($this);
= Html::a('Список проектантов', ['search/performer'])?>
= Html::a('Список проектов', ['search/project'])?>
- = Html::a('Список заказчиков', ['site/index'])?>
+ = Html::a('Список заказчиков', ['search/customer'])?>
diff --git a/frontend/views/search/_performer_list_view.php b/frontend/views/search/_performer_list_view.php
index 65a1a36..3da863b 100644
--- a/frontend/views/search/_performer_list_view.php
+++ b/frontend/views/search/_performer_list_view.php
@@ -7,7 +7,7 @@ use yii\helpers\Url;
- user->getPortfolios()->limit(4)->all(), 'cover'); ?>
+ getPortfolios()->limit(4)->all(), 'cover'); ?>
@@ -34,16 +34,16 @@ use yii\helpers\Url;
- = Html::img($model->minImg($model->image, '48','48'))?>
+ = Html::img($model->minImg($model->userInfo->image, '48','48'))?>
- member):?>
+ userInfo->member):?>
PRO
NEW
-
= $model->user->name?>
+
= $model->name?>
@@ -53,11 +53,11 @@ use yii\helpers\Url;
-
30 отзывов, = $model->city?>
+
30 отзывов, = $model->userInfo->city?>
- busy):?>
+ userInfo->busy):?>
= Html::img('/images/sidebar-ico/ico_work_01.png');?>
занят
= Html::img('/images/sidebar-ico/ico-9.png');?>
свободен
@@ -68,15 +68,15 @@ use yii\helpers\Url;
- География работ: = implode(',',array_filter(ArrayHelper::getColumn($model->user->portfolios, 'city'))) ?>
+ География работ: = implode(',',array_filter(ArrayHelper::getColumn($model->portfolios, 'city'))) ?>
-
Последний визит: = $model->lastVisit ?>
- = Html::a(count($model->user->portfolios)." работа в портфолио",[Url::toRoute(['performer/portfolio','performer_id'=>$model->user_id])], ['class' => "search-worker-blocks-jobs-portfolio" ])?>
+
Последний визит: = $model->userInfo->lastVisit ?>
+ = Html::a(count($model->portfolios)." работа в портфолио",[Url::toRoute(['performer/portfolio','performer_id'=>$model->userInfo->user_id])], ['class' => "search-worker-blocks-jobs-portfolio" ])?>
Добавить в закладки
Предложить проект
diff --git a/frontend/views/search/company.php b/frontend/views/search/company.php
deleted file mode 100755
index 4638c62..0000000
--- a/frontend/views/search/company.php
+++ /dev/null
@@ -1,166 +0,0 @@
-title = 'My Yii Application';
-?>
-
-
-
-
-
-
-
-
Найти исполнителя
-
Компании готовые приступить к работе 145
-
-
-
-
- =
- ListView::widget( [
- 'dataProvider' => $companies,
- 'itemView'=>'_company_list_view',
- 'layout' => "{items}\n
{pager}
",
- 'itemOptions' =>[
- 'tag' => false
- ]
-
- ] );
- ?>
-
-
-
-
-
-
-
-
-
-
diff --git a/frontend/views/search/customer.php b/frontend/views/search/customer.php
index c3f75c9..fa3b08b 100644
--- a/frontend/views/search/customer.php
+++ b/frontend/views/search/customer.php
@@ -171,136 +171,6 @@
'itemView' => '_customer_list_view',
]);
?>
-
-
-
-
-
-
-
-
+
+
+ =
+
+ $form->field ($model, 'working_conditions')
+ ->checkboxList (
+ [
+ 'guarantee' => 'С гарантией',
+ 'contract' => 'С договором',
+ 'estimate' => 'Со сметой',
+ 'prepayment' => 'Без предоплаты'
+ ],
+ [
+ 'item' => function($index, $label, $name, $checked, $value) {
+ $return = '
';
+ $return .= ' ';
+ $return .= ' '.$label.' ';
+ $return .= '
';
+ return $return;
+ }
+ ]
+ );
+ ?>
+
+
+
+ field($model, 'rating', [
+ 'template' => "{label}
{$model->rating}
{input}\n{hint}\n{error}",
+ 'labelOptions' => [
+ 'class' => 'blocks-check-title',
+ ],
+ ])
+ ->widget(SliderInput::className(), [
+ 'clientOptions' => [
+ 'min' => 0,
+ 'max' => 5,
+ 'step' => 0.5,
+ ],
+ 'clientEvents' => [
+ 'slide' => "function( event, ui ) {
+ $( '#{$form->id}-rating' ).text(ui.value);
+ $('input[name=\"{$model->formName()}[rating]\"]').val(ui.value);
+
+ }",
+ ],
+ ]);
+ ?>
+
+
+
+
+ =
+ $form->field($model, 'online', [
+ 'options' => [
+ 'class' => 'blocks-check-list-wrapp',
+ ],
+ 'template' => "
{label}
\n{input}\n{hint}\n{error}",
+ ])
+ ->radioList([
+ '' => 'Все',
+ 1 => 'Онлайн',
+ ], [
+ 'item' => function($index, $label, $name, $checked, $value) use ($model) {
+ return "
{$label}
";
+ },
+ 'unselect' => NULL,
+ ]);
+ ?>
+
+
+
+ =
+ $form->field ($model, 'additional_parameters')
+ ->checkboxList (
+ [
+ 'with_portfolio' => 'Только с портфолио',
+ 'with_comments' => 'Только с отзывами',
+ 'only_free' => 'Только свободные',
+ ],
+ [
+ 'item' => function($index, $label, $name, $checked, $value) {
+ $return = '
';
+ $return .= ' ';
+ $return .= ' '.$label.' ';
+ $return .= '
';
+ return $return;
+ }
+ ]
+ );
+ ?>
+
+ = Html::submitInput('Найти') ?>
+
+
+ end();
+ ?>
Найти исполнителя
-
Проектанты готовые приступить к работе 145
+
Проектанты готовые приступить к работе = $dataProvider->totalCount ?>
-
-
Добавить себя в каталог
+ 'get', 'action' => [''], 'options' => ['class' => 'search-worker-form']]);
+ ?>
+
+ = $form2->field($model, 'search', ['options' => ['tag' => 'span']])->label(false)->textInput(['placeholder' => $model->getAttributeLabel('search')]);?>
+
+ = Html::submitInput('Найти');?>
+
+ end();
+ ?>
+
+
+ = Html::a('Добавить себя в каталог',Url::toRoute('accounts/service'),['class'=>'add-to-catalog-search-worker'])?>
+
Сортировать:
@@ -198,8 +198,9 @@ $this->title = 'My Yii Application';
=
+
ListView::widget( [
- 'dataProvider' => $performer,
+ 'dataProvider' => $dataProvider,
'itemView'=>'_performer_list_view',
'layout' => "{items}\n
{pager}
"
] );
@@ -209,19 +210,9 @@ $this->title = 'My Yii Application';
-
-
-
-
diff --git a/frontend/web/css/style.css b/frontend/web/css/style.css
index d6cc0f9..a5233ed 100755
--- a/frontend/web/css/style.css
+++ b/frontend/web/css/style.css
@@ -6655,6 +6655,18 @@ input[disabled], select[disabled] {
}
.right_search_perform_foto-wr {vertical-align: middle}
.section-box-customer .search-worker-blocks {margin-top: 20px}
+
+.search-work-form .control-label{
+ width: 100%;
+ font-size: 13px;
+ font-weight: 700;
+ margin-bottom: 5px;
+}
+
+.search-work-form .form-group{
+ margin-bottom: 16px;
+
+}
.form_site_logn-wr {
width: 240px;
margin: 0 auto;
--
libgit2 0.21.4