Example #1
0
 /**
  * @inheritdoc
  */
 public function markAsRead(Message &$dialog)
 {
     $result = Message::updateAll(['read' => Message::STATUS_READ], ArrayHelper::merge($dialog->getAttributes(['from', 'to']), ['read' => Message::STATUS_UNREAD]));
     if ($result) {
         $dialog->read = Message::STATUS_READ;
     }
 }
Example #2
0
 public function addMessage()
 {
     foreach ($this->receiver as $receiverId) {
         $message = new Message();
         $message['subject'] = $this->subject;
         $message['content'] = $this->content;
         $message['create_at'] = $this->create_at;
         $message['status'] = $this->status;
         $message['sender_id'] = $this->sender_id;
         $message['receiver_id'] = $receiverId;
         $message->save();
     }
 }
Example #3
0
 public function actionRead($id)
 {
     $model = Message::findOne(['id' => $id]);
     $model['status'] = 1;
     $model->save();
     return $this->render('read', ['model' => $model]);
 }
 /**
  * Updates an existing PageData model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id_page
  * @param string $language
  * @return mixed
  */
 public function actionUpdate($id_page, $language)
 {
     $model = $this->findModel($id_page, $language);
     $model->setScenario('update');
     //if (!Yii::$app->user->can('ownAction', ['model' => $model])) {
     //    throw new ForbiddenHttpException('You are not allowed to perform this action.');
     //}
     /* copy to other languages */
     $languages = Message::getLocaleList();
     $q = new Query();
     $pageLang = $q->select(['language'])->from('{{%core_page_data}}')->where(['id_page' => $id_page])->all();
     foreach ($pageLang as $pl) {
         if (in_array($pl['language'], array_keys($languages))) {
             unset($languages[$pl['language']]);
         }
     }
     //var_dump($languages);
     /* submitted */
     if (Yii::$app->request->isPost) {
         /* page data */
         $model->load(Yii::$app->request->post());
         $model->page->load(Yii::$app->request->post());
         $model->page->save();
         $model->save();
         return $this->redirect(['update', 'id_page' => $model->id_page, 'language' => $model->language]);
     } else {
         return $this->render('update', ['model' => $model, 'languages' => $languages]);
     }
 }
Example #5
0
 public function actionIndexWithDescriptions()
 {
     if (isset($_POST['Room'])) {
         $roomsInput = $_POST['Room'];
         foreach ($roomsInput as $item) {
             $sourceMessage = \common\models\SourceMessage::findOne(['message' => $item['description']]);
             // If null, I need to create source message
             if ($sourceMessage == null) {
                 $sourceMessage = new \common\models\SourceMessage();
             }
             $sourceMessage->category = 'app';
             $sourceMessage->message = $item['description']['en'];
             $sourceMessage->save();
             $otherLanguages = ['zh-cn'];
             foreach ($otherLanguages as $otherLang) {
                 $message = \common\models\Message::findOne(['id' => $sourceMessage->id, 'language' => $otherLang]);
                 if ($message == null) {
                     $message = new \common\models\Message();
                 }
                 $message->id = $sourceMessage->id;
                 $message->language = $otherLang;
                 $message->translation = $item['description'][$otherLang];
                 $message->save();
             }
             // Room to update
             $roomToUpdate = \frontend\models\BaseRoom::findOne($item['id']);
             $roomToUpdate->description = $item['description']['en'];
             $roomToUpdate->save();
         }
     }
     $rooms = BaseRoom::find()->all();
     return $this->render('indexWithDescriptions', ['rooms' => $rooms]);
 }
 /**
  * 查看具体信息
  * @param $userId
  * @return string
  */
 public function actionList($userId)
 {
     $userId1 = Yii::$app->user->id;
     $userId2 = $userId;
     $messages = Message::getDialogue($userId1, $userId2);
     return $this->render('list', ['messages' => $messages]);
 }
Example #7
0
 /**
  * 获取聊天消息
  */
 public function actionMessageHistory()
 {
     $sendId = \common\util\Cookie::getInstance()->getCookie('bhy_id')->value;
     $list = Message::getInstance()->getMessageHistory($sendId, \Yii::$app->request->get('id'));
     $status = Message::getInstance()->getMessageStatus($sendId, \Yii::$app->request->get('id'));
     $this->renderAjax(['status' => 1, 'data' => ['status' => $status, 'messageList' => $list]]);
 }
Example #8
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $this->scenario = 'search';
     $query = Message::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 100], 'sort' => ['defaultOrder' => ['created_at' => SORT_DESC]]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_user_id' => $this->created_user_id, 'updated_user_id' => $this->updated_user_id, 'for_document_id' => $this->for_document_id, 'for_user_id' => $this->for_user_id, 'parent_message_id' => $this->parent_message_id]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'attachment', $this->attachment])->andFilterWhere(['like', 'created_user_name', $this->created_user_name])->andFilterWhere(['like', 'updated_user_name', $this->updated_user_name])->andFilterWhere(['like', 'created_ip', $this->created_ip])->andFilterWhere(['>=', 'id', $this->id_from])->andFilterWhere(['<=', 'id', $this->id_till]);
     for ($i = 1; $i <= Message::OPTIONS_COUNT; $i++) {
         $option = 'option_' . $i;
         $query->andFilterWhere(['like', $option, $this->{$option}]);
     }
     if ($this->created_at_from) {
         $query->andFilterWhere(['>=', 'created_at', CFF::FormatData($this->created_at_from, false) . ' 00:00:00']);
     }
     if ($this->created_at_till) {
         $query->andFilterWhere(['<=', 'created_at', CFF::FormatData($this->created_at_till, false) . ' 23:59:00']);
     }
     if ($this->updated_at_from) {
         $query->andFilterWhere(['>=', 'updated_at', CFF::FormatData($this->updated_at_from, false) . ' 00:00:00']);
     }
     if ($this->updated_at_till) {
         $query->andFilterWhere(['<=', 'updated_at', CFF::FormatData($this->updated_at_till, false) . ' 23:59:00']);
     }
     return $dataProvider;
 }
Example #9
0
 /**
  * Finds the Message model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Message the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Message::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #10
0
 public function run()
 {
     $q = Message::find();
     if ($this->home_club_only && !Yii::$app->user->isGuest) {
         $golfer = Golfer::me();
         if ($golfer->facility_id) {
             $q->andWhere(['facility_id' => [0, $golfer->facility_id]]);
         }
     }
     return $this->render('latest-messages', ['dataProvider' => new ActiveDataProvider(['query' => $q->orderBy('created_at desc'), 'pagination' => ['pageSize' => $this->messages_count]])]);
 }
Example #11
0
 public function search($params)
 {
     $query = Message::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'message_start' => $this->message_start, 'message_end' => $this->message_end, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'subject', $this->subject])->andFilterWhere(['like', 'body', $this->body])->andFilterWhere(['like', 'message_type', $this->message_type])->andFilterWhere(['like', 'status', $this->status]);
     return $dataProvider;
 }
Example #12
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Message::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'receive', $this->receive])->andFilterWhere(['like', 'unread', $this->unread])->andFilterWhere(['like', 'sender', $this->sender]);
     return $dataProvider;
 }
 /**
  * @inheritdoc
  */
 public function run()
 {
     //$currentLang=Yii::$app->language;
     $langs = array_reverse(Message::getLocaleList());
     echo Html::beginTag('div', ['class' => 'language-selection']);
     foreach ($langs as $code => $lang) {
         $c = strtolower(substr($code, -2));
         $icon = Flag::widget(['tag' => 'span', 'country' => $c, 'squared' => false, 'options' => []]);
         echo Html::a($icon, $this->langUrl($code), ['title' => $lang]);
     }
     echo Html::endTag('div');
 }
 /**
  * Index
  * @return string
  */
 public function actionIndex()
 {
     $searchModel = new MessageSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     /* new lang list */
     $langs = Core::getLocaleList();
     $currents = Message::getLocaleList([Yii::$app->sourceLanguage]);
     foreach ($currents as $key => $name) {
         unset($langs[$key]);
     }
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'langs' => $langs]);
 }
Example #15
0
 public static function getMessageBySensor($sensorId, $value)
 {
     if ($sensorId > 0) {
         $message = Message::findOne(['sensor_id' => $sensorId, 'active' => self::STATUS_ACTIVE]);
         if ($value == 1) {
             return $message['message_1'];
         }
         if ($value == 0) {
             return $message['message_0'];
         }
     }
     return 'null';
 }
 /**
  * page view
  * @param $id
  * @return string
  * @throws NotFoundHttpException
  * @internal param $name
  */
 public function actionPage($id)
 {
     $model = Page::findOne($id);
     if (!$model) {
         throw new NotFoundHttpException(Yii::t('app', 'The requested page does not exist.'));
     }
     /* found */
     if ($model->content->language !== Yii::$app->language) {
         Yii::$app->session->setFlash('info', Yii::t('app', 'This page has no {CUR_LANG} version. You are currently viewing the {LANGUAGE} version.', ['CUR_LANG' => Message::getLocaleList()[Yii::$app->language], 'LANGUAGE' => Message::getLocaleList()[$model->content->language]]));
     }
     /* seo */
     /* metaData */
     $title = $model->content->title;
     $keywords = $model->content->keywords;
     $description = $model->content->description;
     $metaTags[] = ['name' => 'keywords', 'content' => $keywords];
     $metaTags[] = ['name' => 'description', 'content' => $description];
     /* Facebook */
     $metaTags[] = ['property' => 'og:title', 'content' => $title];
     $metaTags[] = ['property' => 'og:description', 'content' => $description];
     $metaTags[] = ['property' => 'og:type', 'content' => 'article'];
     // article, product, profile etc
     $metaTags[] = ['property' => 'og:image', 'content' => $model->content->thumbnail];
     //best 1200 x 630
     $metaTags[] = ['property' => 'og:url', 'content' => $model->content->getViewUrl(true)];
     if ($appId = Setting::getValue('fbAppId')) {
         $metaTags[] = ['property' => 'fb:app_id', 'content' => $appId];
     }
     //$metaTags[]=['property' => 'fb:app_id', 'content' => ''];
     //$metaTags[]=['property' => 'fb:admins', 'content' => ''];
     /* Twitter */
     $metaTags[] = ['name' => 'twitter:card', 'content' => 'summary_large_image'];
     $metaTags[] = ['name' => 'twitter:site', 'content' => Setting::getValue('twitterSite')];
     //        $metaTags[]=['name'=>'twitter:title', 'content'=>$title];
     //        $metaTags[]=['name'=>'twitter:description', 'content'=>$description];
     //        $metaTags[]=['name'=>'twitter:image', 'content'=>''];
     //        $metaTags[]=['name'=>'twitter:data1', 'content'=>''];
     //        $metaTags[]=['name'=>'twitter:label1', 'content'=>''];
     //        $metaTags[]=['name'=>'twitter:data2', 'content'=>''];
     //        $metaTags[]=['name'=>'twitter:label2', 'content'=>''];
     /* jsonld */
     $imageObject = $model->content->getImageObject();
     $jsonLd = (object) ['@type' => 'Article', 'http://schema.org/name' => $title, 'http://schema.org/headline' => $description, 'http://schema.org/articleBody' => $model->content->content, 'http://schema.org/dateCreated' => Yii::$app->formatter->asDate($model->content->created_at, 'php:c'), 'http://schema.org/dateModified' => Yii::$app->formatter->asDate($model->content->updated_at, 'php:c'), 'http://schema.org/datePublished' => Yii::$app->formatter->asDate($model->content->created_at, 'php:c'), 'http://schema.org/url' => Yii::$app->request->absoluteUrl, 'http://schema.org/image' => (object) ['@type' => 'ImageObject', 'http://schema.org/url' => !empty($imageObject['url']) ? $imageObject['url'] : '', 'http://schema.org/width' => !empty($imageObject['width']) ? $imageObject['width'] : '', 'http://schema.org/height' => !empty($imageObject['height']) ? $imageObject['height'] : ''], 'http://schema.org/author' => (object) ['@type' => 'Organization', 'http://schema.org/name' => Yii::$app->name], 'http://schema.org/publisher' => (object) ['@type' => 'Organization', 'http://schema.org/name' => Yii::$app->name, 'http://schema.org/logo' => (object) ['@type' => 'ImageObject', 'http://schema.org/url' => Yii::$app->urlManager->createAbsoluteUrl(Yii::$app->homeUrl . '/images/logo.png')]], 'http://schema.org/mainEntityOfPage' => (object) ['@type' => 'WebPage', '@id' => Yii::$app->request->absoluteUrl]];
     /* OK */
     $data['title'] = $title;
     $data['metaTags'] = $metaTags;
     $data['jsonLd'] = $jsonLd;
     $this->registerMetaTagJsonLD($data);
     return $this->render('page', ['model' => $model]);
 }
Example #17
0
 /**
  * ajax 删除用户的消息
  * @return string
  */
 public function actionDeleteUserMessageByUserId()
 {
     $post = Yii::$app->request->post();
     $user = Yii::$app->user->identity;
     $data = [];
     if ($post['messageId']) {
         if (Message::deleteMessageByUserId($post['messageId'], $user->getId())) {
             $data['msg'] = '成功删除一条消息!';
         } else {
             $data['msg'] = '删除失败,请稍后再试!';
         }
     } else {
         $data['msg'] = '系统异常!';
     }
     return json_encode($data);
 }
Example #18
0
 /**
  * Updates an existing SourceMessage model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $lang = Lang::find()->all();
     foreach ($lang as $i) {
         $model_content[$i->code] = Message::findOne(['id' => $id, 'language' => $i->code]);
     }
     if ($model->load(Yii::$app->request->post()) && Model::loadMultiple($model_content, Yii::$app->request->post()) && Model::validateMultiple($model_content) && $model->save()) {
         foreach ($model_content as $key => $content) {
             $content->save(false);
         }
         return $this->redirect(['/message']);
     } else {
         return $this->render('update', ['model' => $model, 'model_content' => $model_content]);
     }
 }
Example #19
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Message::find()->joinWith(['member' => function ($query) {
         $query->from(['member' => 'member']);
     }])->orderBy(['created_at' => SORT_DESC]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!Yii::$app->user->identity->isAdmin()) {
         $this->member_id = Yii::$app->user->identity->id;
     }
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'member_id' => $this->member_id, 'type' => $this->type]);
     if ($this->created_at) {
         $date = explode(' - ', $this->created_at);
         if (count($date) == 2) {
             $query->andFilterWhere(['>=', $this::tableName() . '.created_at', $date[0] . ' 00:00:00']);
             $query->andFilterWhere(['<=', $this::tableName() . '.created_at', $date[1] . ' 23:59:59']);
         }
     }
     if ($this->updated_at) {
         $date = explode(' - ', $this->updated_at);
         if (count($date) == 2) {
             $query->andFilterWhere(['>=', $this::tableName() . '.updated_at', $date[0] . ' 00:00:00']);
             $query->andFilterWhere(['<=', $this::tableName() . '.updated_at', $date[1] . ' 23:59:59']);
         }
     }
     $query->andFilterWhere(['like', 'message.title', $this->title])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'member.username', $this->membername])->orderBy(['created_at' => SORT_DESC]);
     if ($this->replied_content == 1) {
         $query->andFilterWhere(['>', 'replied_content', '']);
     } else {
         if ($this->replied_content == 2) {
             $query->andFilterWhere(['=', 'replied_content', null]);
         }
     }
     var_dump($query->createCommand()->getRawSql());
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Message::find();
     $query->joinWith(['source']);
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['is_translated' => SORT_ASC]]]);
     $dataProvider->sort->attributes['message'] = ['asc' => ['{{%core_source_message}}.message' => SORT_ASC], 'desc' => ['{{%core_source_message}}.message' => SORT_DESC]];
     $dataProvider->sort->attributes['category'] = ['asc' => ['{{%core_source_message}}.category' => SORT_ASC], 'desc' => ['{{%core_source_message}}.category' => SORT_DESC]];
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'is_translated' => $this->is_translated]);
     $query->andFilterWhere(['like', 'language', $this->language])->andFilterWhere(['like', 'translation', $this->translation])->andFilterWhere(['like', '{{%core_source_message}}.message', $this->message])->andFilterWhere(['like', '{{%core_source_message}}.category', $this->category]);
     //$query->andFilterWhere([
     //    'DATE(FROM_UNIXTIME(`created_at`))' => $this->created_at,
     //]);
     return $dataProvider;
 }
Example #21
0
 public static function DialogList($user)
 {
     $query = Message::find()->where(['and', "sender_id={$user}", "recipient_id!={$user}"])->orWhere(['and', "sender_id!={$user}", "recipient_id={$user}"]);
     $message_list = new ActiveDataProvider(['query' => $query]);
     $message_list->query->orderBy(['datetime' => SORT_DESC, 'id' => SORT_DESC]);
     $count = $message_list->count;
     $messages = $message_list->getModels();
     $dialog_list = array();
     foreach ($messages as $message) {
         if ($message->sender_id == Yii::$app->user->id) {
             $dialog_list[$message->recipient_id][] = $message;
         } elseif ($message->recipient_id == Yii::$app->user->id) {
             $dialog_list[$message->sender_id][] = $message;
         }
     }
     ArrayHelper::multisort($dialog_list, ['id'], SORT_DESC);
     $result = array();
     foreach ($dialog_list as $dialog) {
         $result[] = $dialog[0];
     }
     return $result;
 }
Example #22
0
 public function actionDeleteUser()
 {
     $selection = (array) Yii::$app->request->post('selection');
     foreach ($selection as $id) {
         if ($id != Yii::$app->params['adminId']) {
             User::deleteAll(['id' => $id]);
             Post::deleteAll(['user_id' => $id]);
             PostNotification::deleteAll(['action_id' => $id]);
             PostNotification::deleteAll(['receiver_id' => $id]);
             Comment::deleteAll(['user_id' => $id]);
             Like::deleteAll(['user_id' => $id]);
             Message::deleteAll(['sender_id' => $id]);
             Message::deleteAll(['receiver_id' => $id]);
             Relationship::deleteAll(['user_id_1' => $id]);
             Relationship::deleteAll(['user_id_2' => $id]);
             RelationshipNotification::deleteAll(['action_id' => $id]);
             RelationshipNotification::deleteAll(['receive_id' => $id]);
             Schedule::deleteAll(['own_id' => $id]);
             ScheduleNotification::deleteAll(['action_id' => $id]);
             ScheduleNotification::deleteAll(['receiver_id' => $id]);
         }
     }
     return $this->render('user-manage');
 }
Example #23
0
 /**
  *Ta与我的交谈
  */
 public function actionTaMeMessage($uid)
 {
     $this->layout = false;
     $this->view->title = 'Ta的私信';
     $model = new Message();
     $a_models = $model->getList($uid, 'users_friends', $this->pageSize, null);
     return $this->render('ta-me-message', ['a_models' => $a_models, 'uid' => $uid, 'ta_me' => 1, 'ajax_url' => Yii::$app->urlManager->createUrl(['comment/list', 'page' => '#page#', 'sort' => 1, 'self' => 1, 'ajax' => 1, 'uid' => $uid, 'ta_me' => 1])]);
 }
Example #24
0
echo $form->field($model, 'message_type')->dropDownList(Message::getLocalizedConstants('TYPE_'));
?>

    <?php 
echo $form->field($model, 'facility_id')->dropDownList(['' => ''] + ArrayHelper::map(Facility::find()->asArray()->all(), 'id', 'name'));
?>

    <?php 
echo $form->field($model, 'message_start')->widget(DateTimePicker::classname(), ['pluginOptions' => ['format' => 'yyyy-mm-dd hh:ii:ss', 'todayHighlight' => true]]);
?>

    <?php 
echo $form->field($model, 'message_end')->widget(DateTimePicker::classname(), ['pluginOptions' => ['format' => 'yyyy-mm-dd hh:ii:ss', 'todayHighlight' => true]]);
?>

    <?php 
echo $form->field($model, 'status')->dropDownList(Message::getLocalizedConstants('STATUS_'));
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('igolf', 'Create') : Yii::t('igolf', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>
Example #25
0
<?php

use yii\helpers\Html;
/* @var $this \yii\web\View */
/* @var $content string */
$model = \common\models\User::findOne(['id' => Yii::$app->user->getId()]);
$postCount = \common\models\Post::find()->where(['user_id' => $model['id']])->count();
$friendCount = \common\models\Relationship::find()->where(['user_id_1' => $model['id'], 'status' => 1])->count() + \common\models\Relationship::find()->where(['user_id_2' => $model['id'], 'status' => 1])->count();
$listNewRelNotify = \common\models\RelationshipNotification::find()->where(['receive_id' => Yii::$app->user->getId()])->orderBy('status')->limit(20)->asArray()->all();
$newRelNotifyCount = \common\models\RelationshipNotification::find()->where(['receive_id' => Yii::$app->user->getId(), 'status' => 0])->count();
$listNewMsgNotify = \common\models\Message::find()->where(['receiver_id' => Yii::$app->user->getId()])->orderBy('is_notified')->limit(20)->asArray()->all();
$newMsgNotifyCount = \common\models\Message::find()->where(['receiver_id' => Yii::$app->user->getId(), 'is_notified' => 0])->count();
?>

<header class="main-header">

    <?php 
echo Html::a('<span class="logo-mini">APP</span><span class="logo-lg">' . Yii::$app->name . '</span>', Yii::$app->homeUrl, ['class' => 'logo']);
?>

    <nav class="navbar navbar-static-top" role="navigation">

        <a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button">
            <span class="sr-only">Toggle navigation</span>
        </a>

        <div class="navbar-custom-menu">

            <ul class="nav navbar-nav">

                <!-- Messages: style can be found in dropdown.less-->
Example #26
0
<?php

/**
 * Created by PhpStorm.
 * User: Nguyen
 * Date: 11/12/2015
 * Time: 4:16 PM
 */
use yii\widgets\LinkPager;
$this->title = 'Tin nhắn';
$this->params['breadcrumbs'][] = $this->title;
$newCount = \common\models\Message::find()->where(['receiver_id' => Yii::$app->user->getId(), 'status' => 0])->count();
?>

<div class="row">
    <div class="col-md-3">
        <a href="?r=message/compose" class="btn btn-primary btn-block margin-bottom">Soạn</a>
        <div class="box box-solid">
            <div class="box-header with-border">
                <h3 class="box-title">Danh mục</h3>
                <div class="box-tools">
                    <button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
                </div>
            </div>
            <div class="box-body no-padding">
                <ul class="nav nav-pills nav-stacked">
                    <li class="active"><a href="#"><i class="fa fa-inbox"></i> Tin đã nhận <span class="label label-primary pull-right"><?php 
echo $newCount;
?>
</span></a></li>
                    <li><a href="?r=message/show-outbox"><i class="fa fa-envelope-o"></i> Tin đã gửi</a></li>
Example #27
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMessages()
 {
     return $this->hasMany(Message::className(), ['facility_id' => 'id']);
 }
 public function actionMakeOldMessageNotification()
 {
     Message::updateAll(['is_notified' => 1], 'is_notified=0 AND receiver_id=' . \Yii::$app->user->getId());
 }
Example #29
0
                    <?php 
echo Html::submitButton('<span class="glyphicon glyphicon-search"></span> Найти', ['class' => 'btn btn-primary']);
?>
                    <?php 
echo Html::a('<span class="glyphicon glyphicon-repeat"></span> Сбросить', ['/message'], ['class' => 'btn btn-default']);
?>
                </div>
                <div class="row">
                    <div class="col-sm-6">
                        <?php 
echo FieldRange::widget(['form' => $form, 'model' => $model, 'label' => 'ID', 'separator' => 'от ... до', 'attribute1' => 'id_from', 'attribute2' => 'id_till', 'type' => FieldRange::INPUT_TEXT]);
?>
                    </div>
                    <div class="col-sm-6">
                        <?php 
echo $form->field($model, 'status')->widget(Select2::classname(), ['language' => 'ru', 'data' => Message::getStatuses(), 'options' => ['placeholder' => ''], 'pluginOptions' => ['allowClear' => true]]);
?>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-6">
                        <?php 
echo FieldRange::widget(['form' => $form, 'model' => $model, 'label' => 'Дата создания', 'separator' => 'от ... до', 'attribute1' => 'created_at_from', 'attribute2' => 'created_at_till', 'type' => FieldRange::INPUT_DATETIME]);
?>
                    </div>
                    <div class="col-sm-6">
                        <?php 
echo FieldRange::widget(['form' => $form, 'model' => $model, 'label' => 'Дата редактирования', 'separator' => 'от ... до', 'attribute1' => 'updated_at_from', 'attribute2' => 'updated_at_till', 'type' => FieldRange::INPUT_DATETIME]);
?>
                    </div>
                </div>
Example #30
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMessages()
 {
     return $this->hasMany(Message::className(), ['parent_message_id' => 'id']);
 }