diff --git a/.gitignore b/.gitignore index 562a2df..1387438 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,7 @@ nbproject .buildpath .project .settings - +main-local.php # windows thumbnail cache Thumbs.db diff --git a/common/config/main.php b/common/config/main.php index cb2878a..bd1feec 100755 --- a/common/config/main.php +++ b/common/config/main.php @@ -26,6 +26,7 @@ ] ] ], + 'modules' => [ 'permit' => [ 'class' => 'common\components\developeruz\db_rbac\Yii2DbRbac', @@ -86,6 +87,7 @@ 'options', ], 'components' => [ + 'cache' => [ 'class' => 'yii\caching\FileCache', ], diff --git a/common/models/Chat.php b/common/models/Chat.php index 40abb9c..17fce86 100644 --- a/common/models/Chat.php +++ b/common/models/Chat.php @@ -19,6 +19,8 @@ use Yii; */ class Chat extends \yii\db\ActiveRecord { + public $newMessage; + /** * @inheritdoc */ @@ -75,6 +77,41 @@ class Chat extends \yii\db\ActiveRecord */ public function getMessages() { - return $this->hasMany(Message::className(), ['chat_id' => 'chat_id'])->orderBy('message_id') ; + return $this->hasMany(Message::className(), ['chat_id' => 'chat_id']) ; + + } + + + public function getAllMessages(){ + $messages = $this->hasMany(Message::className(), ['chat_id' => 'chat_id'])->orderBy('message_id'); + $messages_clone = clone($messages); + Message::updateAll(['status' => 0], ['message_id' => $messages->select(['message_id'])->where(['status' => 1])->column()]); + + return $messages_clone; + } + + + public function getInterlocutor(){ + if($this->from_user == \Yii::$app->user->id){ + return UserInfo::findOne(['user_id'=>$this->to_user]); + } else { + return UserInfo::findOne(['user_id'=>$this->from_user]); + } + } + + public function hasNewMessage(){ + $newMessages = $this->getMessages()->where(['status'=>'1', ]) + ->andWhere(['<>','user_id', \Yii::$app->user->id])->all(); + if($newMessages){ + + $this->newMessage = $newMessages; + + return true; + + } else { + return false; + } } + + } diff --git a/common/models/Job.php b/common/models/Job.php index 3a9f38c..8bb288a 100755 --- a/common/models/Job.php +++ b/common/models/Job.php @@ -28,6 +28,34 @@ class Job extends \yii\db\ActiveRecord return 'job'; } + + /** + * @inheritdoc + */ + public function behaviors() + { + return [ + 'slug' => [ + 'class' => 'common\behaviors\Slug', + 'in_attribute' => 'name', + 'out_attribute' => 'link', + 'translit' => true + ] + ]; + } + + public function beforeSave($insert) + { + $this->date_start = \Yii::$app->formatter->asDatetime($this->date_start, 'Y-MM-d HH:mm:ss'); + + if($this->date_end) { + $this->date_end = \Yii::$app->formatter->asDatetime($this->date_end, 'Y-MM-d HH:mm:ss'); + } + + + return parent::beforeSave($insert); // TODO: Change the autogenerated stub + } + /** * @inheritdoc */ diff --git a/common/models/Message.php b/common/models/Message.php index fa700fd..5a008da 100644 --- a/common/models/Message.php +++ b/common/models/Message.php @@ -23,6 +23,9 @@ class Message extends \yii\db\ActiveRecord public $file; + const NEW_MESSAGE = 1; + const READ_MESSAGE = 0; + /** * @inheritdoc */ @@ -40,6 +43,7 @@ class Message extends \yii\db\ActiveRecord [['chat_id', 'user_id', 'status'], 'integer'], [['text'], 'string'], [['date','file'], 'safe'], + [['status'], 'default', 'value' => self::NEW_MESSAGE], [['files'], 'string', 'max' => 255], [['chat_id'], 'exist', 'skipOnError' => true, 'targetClass' => Chat::className(), 'targetAttribute' => ['chat_id' => 'chat_id']], ]; @@ -76,7 +80,12 @@ class Message extends \yii\db\ActiveRecord public function getFilesList(){ $files = json_decode($this->files); - return File::findAll($files); + if(!empty($files)){ + return File::findAll($files); + } else { + return false; + } + } diff --git a/common/models/Project.php b/common/models/Project.php index b58dd36..9390d4d 100644 --- a/common/models/Project.php +++ b/common/models/Project.php @@ -41,6 +41,8 @@ return 'project'; } + + /** * @inheritdoc */ @@ -58,6 +60,12 @@ 'updatedAtAttribute' => false, 'value' => new Expression('NOW()'), ], + 'slug' => [ + 'class' => 'common\behaviors\Slug', + 'in_attribute' => 'name', + 'out_attribute' => 'link', + 'translit' => true + ] ]; } diff --git a/common/models/Team.php b/common/models/Team.php index 48ac79e..631346a 100644 --- a/common/models/Team.php +++ b/common/models/Team.php @@ -34,6 +34,11 @@ return 'team'; } + + + + + /** * @inheritdoc */ @@ -51,6 +56,12 @@ 'updatedAtAttribute' => false, 'value' => new Expression('NOW()'), ], + 'slug' => [ + 'class' => 'common\behaviors\Slug', + 'in_attribute' => 'name', + 'out_attribute' => 'link', + 'translit' => true + ] ]; } diff --git a/common/models/Vacancy.php b/common/models/Vacancy.php index fa8cb8e..1a30cfc 100644 --- a/common/models/Vacancy.php +++ b/common/models/Vacancy.php @@ -54,6 +54,12 @@ 'updatedAtAttribute' => false, 'value' => new Expression('NOW()'), ], + 'slug' => [ + 'class' => 'common\behaviors\Slug', + 'in_attribute' => 'name', + 'out_attribute' => 'link', + 'translit' => true + ] ]; } @@ -72,10 +78,14 @@ 'string', ], [ - [ 'employmentInput', 'specializationInput' ], + [ 'employmentInput', 'specializationInput', ], 'safe', ], [ + ['salary_currency'], + 'integer' + ], + [ [ 'employmentInput', 'specializationInput' ], 'default', 'value' => [], diff --git a/common/widgets/views/youtube_field.php b/common/widgets/views/youtube_field.php index 3541550..f6abbb2 100644 --- a/common/widgets/views/youtube_field.php +++ b/common/widgets/views/youtube_field.php @@ -21,7 +21,7 @@ ]) ?>
- + ' : '' ?>' name="Fields[youtube][][0][youtube]"/>
diff --git a/frontend/config/main.php b/frontend/config/main.php index 1644ebb..f7d1c1f 100755 --- a/frontend/config/main.php +++ b/frontend/config/main.php @@ -38,7 +38,8 @@ return [ 'css' => [] ], 'yii\web\JqueryAsset' =>[ - 'js' => [] + 'js' => ['//code.jquery.com/jquery-2.1.4.min.js'], + 'jsOptions' => ['position' => \yii\web\View::POS_HEAD] ] ], ], @@ -82,7 +83,7 @@ return [ 'company/portfolio//' => 'company/portfolio-filter', 'company/portfolio-view//' => 'company/portfolio-view', 'company/blog-view//' => 'company/blog-view', - 'company/vacancy-view//' => 'company/vacancy-view', + 'company/vacancy-view//' => 'company/vacancy-view', 'company//' => 'company/', 'chat/message/'=> 'chat/message', 'tender/view/' => 'tender/view', diff --git a/frontend/controllers/AccountsController.php b/frontend/controllers/AccountsController.php index e0b4c8d..4832b15 100755 --- a/frontend/controllers/AccountsController.php +++ b/frontend/controllers/AccountsController.php @@ -1081,9 +1081,11 @@ $currencies = Currency::getCurrencyDropdown(); $post = \Yii::$app->request->post(); if(!empty( $post )) { + $vacancy->load($post); $vacancy->validate(); if(!$vacancy->hasErrors()) { + $vacancy->save(); Fields::saveFieldData(Yii::$app->request->post('Fields'), $vacancy->vacancy_id, Vacancy::className(), 'ru'); $vacancy->unlinkAll('employments', true); diff --git a/frontend/controllers/ChatController.php b/frontend/controllers/ChatController.php index b994254..45a82ce 100755 --- a/frontend/controllers/ChatController.php +++ b/frontend/controllers/ChatController.php @@ -39,7 +39,17 @@ class ChatController extends Controller public function actionList() { - return $this->render('list'); + + $chat = new ActiveDataProvider([ + 'query' => Chat::find(), + 'pagination' => [ + 'pageSize' => 5, + ], + ]); + + return $this->render('list',[ + 'chat' => $chat + ]); } public function actionMessage($user_id) @@ -64,7 +74,6 @@ class ChatController extends Controller $chat->from_user = $user->id; $chat->to_user = $user_id; $chat->save(); - } diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php index 16b3d90..8ebc610 100755 --- a/frontend/controllers/SiteController.php +++ b/frontend/controllers/SiteController.php @@ -143,7 +143,7 @@ class SiteController extends Controller */ public function actionLogin() { - $this->layout = 'admin'; + if (!\Yii::$app->user->isGuest) { return $this->goHome(); diff --git a/frontend/views/accounts/_blog_form.php b/frontend/views/accounts/_blog_form.php index c5fddd2..c4ebd86 100644 --- a/frontend/views/accounts/_blog_form.php +++ b/frontend/views/accounts/_blog_form.php @@ -29,12 +29,6 @@ use yii\helpers\Html; ->textInput (['class'=> 'custom-input-2 fix-input-2']); ?> -
-
- field($blog, 'link') - ->textInput (['class'=> 'custom-input-2 fix-input-2']); ?> -
-
diff --git a/frontend/views/accounts/_portfolio_form.php b/frontend/views/accounts/_portfolio_form.php index 1089b55..06b057b 100644 --- a/frontend/views/accounts/_portfolio_form.php +++ b/frontend/views/accounts/_portfolio_form.php @@ -38,12 +38,7 @@
-
-
- field($portfolio, 'link') - ->textInput([ 'class' => 'custom-input-2 fix-input-2' ]); ?> -
-
+
diff --git a/frontend/views/accounts/_projects_form.php b/frontend/views/accounts/_projects_form.php index b25e4cc..e065131 100644 --- a/frontend/views/accounts/_projects_form.php +++ b/frontend/views/accounts/_projects_form.php @@ -35,13 +35,6 @@
-
- field($project, 'link') - ->textInput (['class'=> 'custom-input-2']) ?> -
-
- -
field($project, 'project_pid') ->dropDownList($projects, [ 'prompt' => 'Родительский проект' ]) ?> diff --git a/frontend/views/accounts/_team_form.php b/frontend/views/accounts/_team_form.php index d091e2b..a1b22ef 100644 --- a/frontend/views/accounts/_team_form.php +++ b/frontend/views/accounts/_team_form.php @@ -49,12 +49,6 @@
-
-
- field($team, 'link') - ->textInput([ 'class' => 'custom-input-2' ]) ?> -
-
diff --git a/frontend/views/accounts/_vacancy_form.php b/frontend/views/accounts/_vacancy_form.php index 9f11ad5..07fca30 100644 --- a/frontend/views/accounts/_vacancy_form.php +++ b/frontend/views/accounts/_vacancy_form.php @@ -32,12 +32,7 @@
-
-
- field($vacancy, 'link') - ->textInput (['class'=> 'custom-input-2']); ?> -
-
+
diff --git a/frontend/views/chat/_chat_list_view.php b/frontend/views/chat/_chat_list_view.php new file mode 100644 index 0000000..2ac5338 --- /dev/null +++ b/frontend/views/chat/_chat_list_view.php @@ -0,0 +1,45 @@ + + +hasNewMessage()):?> +
+
+
+ interlocutor->image));?> +
+
+
+
interlocutor->name ?>
+ +
(Есть непрочитанные)
+
+
+
Написать сообщение
+ ', ['chat/message', 'user_id' =>$model->interlocutor->user_id ], ['class'=>'cabinet-message-write' ] );?> +
+ +
+
+
+ interlocutor->image));?> +
+
+
+
interlocutor->name ?>
+ +
(Все прочитаны)
+
+
+
Написать сообщение
+ ', ['chat/message', 'user_id' =>$model->interlocutor->user_id ], ['class'=>'cabinet-message-write' ] );?> +
+ diff --git a/frontend/views/chat/list.php b/frontend/views/chat/list.php index bd2a2d8..dbbff39 100755 --- a/frontend/views/chat/list.php +++ b/frontend/views/chat/list.php @@ -1,8 +1,9 @@ title = 'Мой профиль'; +$this->title = 'Мой профиль'; $this->params['breadcrumbs'][] = $this->title; ?>
@@ -11,92 +12,19 @@ $this->params['breadcrumbs'][] = $this->title;
-
-
-
- -
-
-
-
Иванов Иван
- -
(Есть непрочитанные)
-
- -
-
Оставить заметку
-
-
-
-
-
- -
-
-
-
Петров Петр
- -
(Все прочитаны)
-
- -
-
Оставить заметку
-
-
-
-
-
- -
-
-
-
Петров Петр
- -
(Все прочитаны)
-
- -
-
Оставить заметку
-
-
-
-
-
- -
-
-
-
Петров Петр
- -
(Все прочитаны)
-
- -
-
Оставить заметку
-
-
+ $chat, + 'itemView'=>'_chat_list_view', + 'itemOptions' => [ + 'tag' => false, + ], + 'layout' => "{items}\n" + ] ); + ?> -
diff --git a/frontend/views/chat/message.php b/frontend/views/chat/message.php index 067b8e2..195b54a 100755 --- a/frontend/views/chat/message.php +++ b/frontend/views/chat/message.php @@ -91,7 +91,7 @@ $this->registerJsFile("/js/forms.js");
- messages as $message):?> + allMessages as $message):?> isMy()):?>
user->minImg($message->user->image,48,48))?>
diff --git a/frontend/views/company/_vacancy_list_view.php b/frontend/views/company/_vacancy_list_view.php index bb02715..020147a 100644 --- a/frontend/views/company/_vacancy_list_view.php +++ b/frontend/views/company/_vacancy_list_view.php @@ -2,12 +2,13 @@ use frontend\helpers\TextHelper; use yii\bootstrap\Html; use yii\helpers\Url; +use yii\i18n\Formatter; ?>
name, Url::toRoute( ['company/vacancy-view', 'company_id' => $model->user_id,'link' => $model->link]), ['class' => 'performer-vacant-reclam-bl-title']) ?> -
city ?> date_add ?> salary ?> salaryCurrency->label ?>
+
city ?> formatter->asDatetime($model->date_add, 'Y-MM-dd') ?> salary ?> salaryCurrency->label ?>
description, 200, '...') ?> ', ['vacancy-view', 'company_id' => $model->user_id,'vacancy_id' => $model->vacancy_id], ['class' => 'performer-vacant-reclam-bl-content-read']) ?> diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index ee38f3c..ac763d0 100755 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -25,7 +25,6 @@ AppAsset::register($this); <?= Html::encode($this->title) ?> - head() ?> -- libgit2 0.21.4