public function actionIndex() { $model = new Messenger(); $projectResult = Project::find()->all(); if ($model->load(Yii::$app->request->post())) { $model->read_chk = 0; $model->del_chk = 0; $model->date = date("Y/m/d H:i:s"); $model->save(); } return $this->render('index', ['model' => $model, 'projectResult' => $projectResult]); }
public function actionMessengerdetail() { $this->layout = ''; $messengerCount = Messenger::find()->where(['read_chk' => 0])->count(); $messengerModel = Messenger::find()->limit(10)->orderBy(['date' => SORT_DESC])->all(); foreach ($messengerModel as $messengerModel) { $time = strtotime("now") - strtotime($messengerModel->date); if ($time < 30) { $alert = "a few seconds ago"; } elseif ($time >= 30 && $time < 60) { $alert = "30 seconds ago"; } elseif ($time >= 60 && $time < 120) { $alert = "a minute ago"; } elseif ($time >= 120 && $time < 3600) { $alert = floor($time / 60) . " minutes ago"; } elseif ($time >= 3600 && $time < 7200) { $alert = "a hour ago"; } elseif ($time >= 7200 && $time < 86400) { $alert = floor($time / 3600) . " hours ago"; } elseif ($time >= 86400 && $time < 172800) { $alert = "yesterday"; } else { $alert = $messengerModel->date; } //gioi han la so ban ghi show ra if ($messengerModel->read_chk == 0) { $echo[] = '<li style="background:#c4cffd;"> <a href="admin/messenger/detail?id=' . $messengerModel->messenger_id . '"> <div> <strong>' . $messengerModel->name . '</strong> <span class="pull-right text-muted"> <em>' . $alert . '</em> </span> </div> <div>' . $messengerModel->detail . '</div> </a> </li>'; } else { $echo[] = '<li> <a href="admin/messenger/detail?id=' . $messengerModel->messenger_id . '"> <div> <strong>' . $messengerModel->name . '</strong> <span class="pull-right text-muted"> <em>' . $alert . '</em> </span> </div> <div>' . $messengerModel->detail . '</div> </a> </li>'; } } if ($messengerCount < 10) { foreach ($echo as $echo) { echo $echo; } } else { $echo[] = '<li class="divider"></li> <li> <a class="text-center" href="#"> <strong>Read All Messages</strong> <i class="fa fa-angle-right"></i> </a> </li>'; foreach ($echo as $echo) { echo $echo; } } }
public function actionList() { $messengerModel = Messenger::find(); $messengerResult = $messengerModel->all(); return $this->render('list', ['messengerResult' => $messengerResult]); }
public function actionIndex() { $messengerModel = Messenger::find(); $messengerCount = $messengerModel->where(['read_chk' => 0])->count(); return $this->render('index', ['messengerCount' => $messengerCount]); }