Example #1
0
 public function actionCronUnread()
 {
     $html = '';
     $count = 0;
     $post = Yii::$app->request->post();
     // permission
     $role = new Role();
     $condition = [];
     if (!$role->isAdministrator) {
         $position = $role->getPosition();
         $stationIds = Station::getByRole($position, Yii::$app->user->id);
         $condition[] = ['in', 'station_id', $stationIds];
     }
     $condition[] = ['=', 'read', Warning::STATUS_UNREAD];
     $warnings = Warning::getWarning('warning_time DESC', 0, $condition);
     if (!empty($warnings)) {
         $count = count($warnings);
         $html = Show::warningsTable($warnings);
     }
     $data['html'] = $html;
     $data['count'] = $count;
     print json_encode($data);
 }