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][= $row ?>][0][youtube]"/>
= Html::endTag('div') ?>
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']); ?>
-
-
+