Example #1
0
 public function actionLogin()
 {
     if (!Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new LoginForm();
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         //write log action
         Log::logAction(Yii::$app->user->id, Log::ACTION_LOGIN);
         return $this->goBack();
     } else {
         $this->layout = '//login';
         return $this->render('login', ['model' => $model]);
     }
 }
Example #2
0
<div class="log-index">

    <h4><?php 
echo Html::encode($this->title);
?>
</h4>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'user_id', 'value' => function ($model) {
    $user = User::findOne($model->user_id);
    return $user->username;
}], ['attribute' => 'action', 'filter' => LogModel::_prepareDataSelect($actionList, 'key', 'name', false), 'value' => function ($model) {
    $actionList = Log::actions();
    foreach ($actionList as $action) {
        if ($model->action === $action['key']) {
            return $action['name'];
        }
    }
}], ['attribute' => 'station_id', 'value' => function ($model) {
    $station = Station::findOne($model->station_id);
    return $station ? $station->name : '';
}], ['attribute' => 'related_id', 'value' => function ($model) {
    $equip = Equipment::findOne($model->related_id);
    return $equip ? $equip['name'] : '';
}], ['attribute' => 'time', 'filter' => false, 'value' => function ($model) {
    return $model->time > 0 ? date('d/m/Y h:i A', $model->time) : '';
}]]]);
?>
Example #3
0
 public function actionView($id)
 {
     $model = $this->findModel($id);
     // parse data
     $parseData = ['model' => $model];
     // set left menu
     $this->setDetailLeftMenu($id);
     // get equipment
     $parseData['equipments'] = $model->getEquipment($model->id, $model->equipment);
     // get power equipment
     $parseData['powerEquipments'] = $model->getPowerEquipment($model->id, $model->power_equipment);
     // get power equipment
     $parseData['dcEquipments'] = DcEquipmentStatus::findByStation($model->id);
     //write log action
     Log::logControl(Yii::$app->user->id, Log::ACTION_VIEW_STATION, $id);
     return $this->render('view', $parseData);
 }