diff --git a/common/models/Blog.php b/common/models/Blog.php index 3fa1339..6f65f0a 100644 --- a/common/models/Blog.php +++ b/common/models/Blog.php @@ -64,7 +64,7 @@ { return [ [ - [ 'name' ], + [ 'name', 'description' ], 'required', ], [ diff --git a/common/models/BlogSearch.php b/common/models/BlogSearch.php index fe65ff4..9f4c9eb 100644 --- a/common/models/BlogSearch.php +++ b/common/models/BlogSearch.php @@ -16,6 +16,8 @@ class BlogSearch extends Blog { + public $date_add_from; + public $date_add_to; /** * @inheritdoc */ @@ -38,9 +40,25 @@ 'date_add', 'description', 'cover', + 'date_add_from', + 'date_add_to', ], 'safe', ], + [ + [ + 'date_add_from', + ], + 'default', + 'value' => date('Y-m-d', 0), + ], + [ + [ + 'date_add_to', + ], + 'default', + 'value' => date('Y-m-d'), + ], ]; } @@ -89,17 +107,19 @@ ]); $query->andFilterWhere([ + 'between', + 'date_add', + $this->date_add_from, + $this->date_add_to, + ]); + + $query->andFilterWhere([ 'like', 'name', $this->name, ]) ->andFilterWhere([ 'like', - 'link', - $this->link, - ]) - ->andFilterWhere([ - 'like', 'description', $this->description, ]) diff --git a/common/models/GallerySearch.php b/common/models/GallerySearch.php index 0d5d4ac..5e8d422 100644 --- a/common/models/GallerySearch.php +++ b/common/models/GallerySearch.php @@ -13,6 +13,8 @@ class GallerySearch extends Gallery { + public $date_add_from; + public $date_add_to; /** * @inheritdoc */ @@ -33,9 +35,25 @@ 'date_add', 'cover', 'photo', + 'date_add_from', + 'date_add_to', ], 'safe', ], + [ + [ + 'date_add_from', + ], + 'default', + 'value' => date('Y-m-d', 0), + ], + [ + [ + 'date_add_to', + ], + 'default', + 'value' => date('Y-m-d'), + ], ]; } @@ -86,6 +104,13 @@ ]); $query->andFilterWhere([ + 'between', + 'date_add', + $this->date_add_from, + $this->date_add_to, + ]); + + $query->andFilterWhere([ 'like', 'name', $this->name, diff --git a/common/models/PortfolioSearch.php b/common/models/PortfolioSearch.php index 56d2b01..e55d070 100644 --- a/common/models/PortfolioSearch.php +++ b/common/models/PortfolioSearch.php @@ -13,6 +13,8 @@ class PortfolioSearch extends Portfolio { + public $date_add_from; + public $date_add_to; /** * @inheritdoc */ @@ -39,9 +41,25 @@ 'description', 'cover', 'specializationString', + 'date_add_from', + 'date_add_to', ], 'safe', ], + [ + [ + 'date_add_from', + ], + 'default', + 'value' => date('Y-m-d', 0), + ], + [ + [ + 'date_add_to', + ], + 'default', + 'value' => date('Y-m-d'), + ], ]; } @@ -79,7 +97,19 @@ return $dataProvider; } - $query->joinWith('specializations'); + $query2 = [ ]; + if(!empty( $this->specializationString )) { + $query2 = Portfolio::find() + ->select([ 'portfolio.portfolio_id' ], 'DISTINCT') + ->joinWith([ 'specializations' ]) + ->where([ + 'like', + 'specialization_name', + $this->specializationString, + ]) + ->asArray() + ->column(); + } $query->andWhere([ 'user_id' => \Yii::$app->user->getId() ]); @@ -93,6 +123,19 @@ ]); $query->andFilterWhere([ + 'between', + 'date_add', + $this->date_add_from, + $this->date_add_to, + ]); + + $query->andFilterWhere( + [ + 'portfolio_id' => $query2, + ] + ); + + $query->andFilterWhere([ 'like', 'name', $this->name, @@ -126,11 +169,6 @@ 'like', 'cover', $this->cover, - ]) - ->andFilterWhere([ - 'like', - 'specialization.specialization_name', - $this->specializationString, ]); return $dataProvider; diff --git a/common/models/Project.php b/common/models/Project.php index ae5ffbb..812aafe 100644 --- a/common/models/Project.php +++ b/common/models/Project.php @@ -116,12 +116,12 @@ 'value' => [ ], ], [ - ['deadline'], + [ 'deadline' ], 'integer', 'min' => 1, ], [ - ['deadline'], + [ 'deadline' ], 'default', 'value' => 1, ], @@ -190,6 +190,7 @@ { return $this->getSpecializations() ->asArray() + ->indexBy('specialization_id') ->column(); } diff --git a/common/models/ProjectSearch.php b/common/models/ProjectSearch.php index 49e4ab8..47fb0ef 100644 --- a/common/models/ProjectSearch.php +++ b/common/models/ProjectSearch.php @@ -87,7 +87,19 @@ return $dataProvider; } - $query->joinWith('specializations'); + $query2 = [ ]; + if(!empty( $this->specializationString )) { + $query2 = Project::find() + ->select([ 'project.project_id' ], 'DISTINCT') + ->joinWith([ 'specializations' ]) + ->where([ + 'like', + 'specialization_name', + $this->specializationString, + ]) + ->asArray() + ->column(); + } $query->andWhere([ 'user_id' => \Yii::$app->user->getId() ]); @@ -104,6 +116,12 @@ 'contractual' => $this->contractual, ]); + $query->andFilterWhere( + [ + 'project_id' => $query2, + ] + ); + $query->andFilterWhere([ 'like', 'name', @@ -143,11 +161,6 @@ 'like', 'file', $this->file, - ]) - ->andFilterWhere([ - 'like', - 'specialization.specialization_name', - $this->specializationString, ]); return $dataProvider; diff --git a/common/models/User.php b/common/models/User.php index 5908d85..fe8a81b 100755 --- a/common/models/User.php +++ b/common/models/User.php @@ -26,6 +26,7 @@ */ class User extends ActiveRecord implements IdentityInterface, UserRbacInterface { + const STATUS_DELETED = 0; const STATUS_ACTIVE = 10; @@ -294,7 +295,6 @@ /** * Returns name of the User - * * @return string */ public function getUserName() @@ -304,7 +304,6 @@ /** * Return array of all User's roles - * * @return array */ public function getRoles() @@ -315,9 +314,10 @@ } /** - * @param Role[] $roles User roles returned by [ManagerInterface]->[getRolesByUser($id)] - * @param ManagerInterface $auth Auth manager - * @param array $result + * @param Role[] $roles User roles returned by + * [ManagerInterface]->[getRolesByUser($id)] + * @param ManagerInterface $auth Auth manager + * @param array $result * * @return array */ @@ -339,7 +339,6 @@ /** * Return UserInfo for this User - * * @return \yii\db\ActiveQuery */ public function getUserInfo() @@ -349,9 +348,7 @@ /** * Check if User is Performer - * * currently in development mode - * * @return bool */ public function getIsPerformer() @@ -361,7 +358,6 @@ /** * Return CompanyInfo for this User - * * @return \yii\db\ActiveQuery */ public function getCompanyInfo() @@ -371,7 +367,6 @@ /** * Return array of User's phones - * * @return array */ public function getPhones() @@ -381,7 +376,6 @@ /** * Return array of User's site - * * @return array */ public function getSite() @@ -391,7 +385,6 @@ /** * Return full address of User in view like: - * * {country}, {city}, {street}, {house} * @return string */ @@ -402,7 +395,6 @@ /** * Return relative interval of time from User registration date until now. - * * @return string */ public function getLiveTime() @@ -414,9 +406,7 @@ /** * Check if User is Customer - * * currently in development - * * @return bool */ public function getIsCustomer() @@ -426,7 +416,6 @@ /** * Return array of payments types accepted by the user. - * * @return ActiveQuery */ public function getPayments() @@ -437,7 +426,6 @@ /** * Return array of Payment IDs, accepted by the user. - * * @return integer[] */ public function getPaymentInput() @@ -459,7 +447,6 @@ /** * Return array of Specializations in which the User works. - * * @return ActiveQuery */ public function getSpecializations() @@ -470,7 +457,6 @@ /** * Return array of User's blogs - * * @return ActiveQuery */ public function getBlog() @@ -480,7 +466,6 @@ /** * Return array of User's jobs. - * * @return ActiveQuery */ public function getJobs() @@ -490,24 +475,23 @@ /** * Return ActiveRecord of current User's place of work. - * * @return ActiveQuery */ public function getCurrentJob() { - return $this->hasOne(Job::className(), ['user_id' => 'id'])->where(['current' => 1]); + return $this->hasOne(Job::className(), [ 'user_id' => 'id' ]) + ->where([ 'current' => 1 ]); } /** * Return array of User's specialization IDs - * * @return integer[] */ public function getSpecializationInput() { return $this->getSpecializations() ->asArray() - ->indexBy('specialization_id') + ->indexBy('specialization_id') ->column(); } @@ -523,7 +507,6 @@ /** * Return array of User's portfolios. - * * @return ActiveQuery */ public function getPortfolios() @@ -533,7 +516,6 @@ /** * Return array of User's projects. - * * @return ActiveQuery */ public function getProjects() @@ -543,7 +525,6 @@ /** * Return array of company's Team members. - * * @return ActiveQuery */ public function getTeams() @@ -553,7 +534,6 @@ /** * Return array of company's Vacancies. - * * @return ActiveQuery */ public function getVacancies() diff --git a/frontend/controllers/AccountsController.php b/frontend/controllers/AccountsController.php index df7a5b9..464e482 100755 --- a/frontend/controllers/AccountsController.php +++ b/frontend/controllers/AccountsController.php @@ -115,8 +115,7 @@ $post = \Yii::$app->request->post(); if($blog->load($post) && $blog->save()) { return $this->redirect([ - 'blog-update', - 'id' => $blog->blog_id, + 'blog', ]); } else { return $this->render('_blog_form', [ 'blog' => $blog ]); diff --git a/frontend/views/accounts/_projects_form.php b/frontend/views/accounts/_projects_form.php index 6ce1cfb..4d4b071 100644 --- a/frontend/views/accounts/_projects_form.php +++ b/frontend/views/accounts/_projects_form.php @@ -62,7 +62,7 @@
  • - field($project, "specializationInput[{$child_second->specialization_id}]")->checkbox(['value' => $child_second->specialization_id, 'label' => $child_second->specialization_name, 'uncheck' => null, 'checked' => 'checked']) ?> + field($project, "specializationInput[{$child_second->specialization_id}]")->checkbox(['value' => $child_second->specialization_id, 'label' => $child_second->specialization_name, 'uncheck' => null,]) ?>
  • diff --git a/frontend/views/accounts/blog.php b/frontend/views/accounts/blog.php index bb554f2..7faba8d 100644 --- a/frontend/views/accounts/blog.php +++ b/frontend/views/accounts/blog.php @@ -8,6 +8,8 @@ use yii\grid\ActionColumn; use yii\grid\GridView; use yii\helpers\Html; + use yii\jui\DatePicker; + use yii\widgets\ActiveField; $this->title = 'Блог'; $this->params[ 'breadcrumbs' ][] = $this->title; @@ -26,7 +28,39 @@ 'label' => 'ID', ], 'name', - 'date_add', + [ + 'attribute' => 'date_add', + 'filter' => "
    +". +DatePicker::widget([ + 'model' => $searchModel, + 'attribute' => 'date_add_from', + 'language' => 'ru', + 'dateFormat' => 'yyyy-MM-dd', + 'clientOptions' => [ + 'changeYear' => true, + 'changeMonth' => true, + ], +]). +" + + + +". + DatePicker::widget([ + 'model' => $searchModel, + 'attribute' => 'date_add_to', + 'language' => 'ru', + 'dateFormat' => 'yyyy-MM-dd', + 'clientOptions' => [ + 'changeYear' => true, + 'changeMonth' => true, + ], + ]) +." +
    ", + 'format' => 'html', + ], 'view_count', [ 'class' => ActionColumn::className(), diff --git a/frontend/views/accounts/gallery.php b/frontend/views/accounts/gallery.php index f7f5747..57b71fb 100755 --- a/frontend/views/accounts/gallery.php +++ b/frontend/views/accounts/gallery.php @@ -7,6 +7,7 @@ use yii\data\ActiveDataProvider; use yii\grid\GridView; use yii\helpers\Html; + use yii\jui\DatePicker; $this->title = 'Галерея'; $this->params[ 'breadcrumbs' ][] = $this->title; @@ -27,24 +28,38 @@ 'filterOptions' => ['class' => 'text-center'] ], 'name', - 'date_add', [ - 'attribute' => 'type', - 'value' => function($model, $key, $index, $column) { - switch($model->type) { - case 2: - return 'Видео'; - break; - default: - return 'Фото'; - break; - } - }, - 'label' => 'Фото или Видео', - 'filter' => [ - 1 => 'Фото', - 2 => 'Видео', - ] + 'attribute' => 'date_add', + 'filter' => "
    +". + DatePicker::widget([ + 'model' => $searchModel, + 'attribute' => 'date_add_from', + 'language' => 'ru', + 'dateFormat' => 'yyyy-MM-dd', + 'clientOptions' => [ + 'changeYear' => true, + 'changeMonth' => true, + ], + ]). + " + + + +". + DatePicker::widget([ + 'model' => $searchModel, + 'attribute' => 'date_add_to', + 'language' => 'ru', + 'dateFormat' => 'yyyy-MM-dd', + 'clientOptions' => [ + 'changeYear' => true, + 'changeMonth' => true, + ], + ]) + ." +
    ", + 'format' => 'html', ], [ 'class' => 'yii\grid\ActionColumn', diff --git a/frontend/views/accounts/portfolio.php b/frontend/views/accounts/portfolio.php index 60f0d0b..2b487bb 100755 --- a/frontend/views/accounts/portfolio.php +++ b/frontend/views/accounts/portfolio.php @@ -8,6 +8,7 @@ use yii\grid\ActionColumn; use yii\grid\GridView; use yii\helpers\Html; + use yii\jui\DatePicker; $this->title = 'Портфолио'; $this->params[ 'breadcrumbs' ][] = $this->title; @@ -26,7 +27,39 @@ 'label' => 'ID', ], 'name', - 'date_add', + [ + 'attribute' => 'date_add', + 'filter' => "
    +". + DatePicker::widget([ + 'model' => $searchModel, + 'attribute' => 'date_add_from', + 'language' => 'ru', + 'dateFormat' => 'yyyy-MM-dd', + 'clientOptions' => [ + 'changeYear' => true, + 'changeMonth' => true, + ], + ]). + " + + + +". + DatePicker::widget([ + 'model' => $searchModel, + 'attribute' => 'date_add_to', + 'language' => 'ru', + 'dateFormat' => 'yyyy-MM-dd', + 'clientOptions' => [ + 'changeYear' => true, + 'changeMonth' => true, + ], + ]) + ." +
    ", + 'format' => 'html', + ], 'view_count', [ 'attribute' => 'specializationString', -- libgit2 0.21.4