Esempio n. 1
0
 public function writeLog($action)
 {
     $activity = new UserActivity();
     $activity->nik = Yii::$app->user->id;
     $activity->action = $action;
     $activity->save();
 }
 /**
  * Finds the UserActivity model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return UserActivity the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = UserActivity::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = UserActivity::find()->orderBy('timestamp desc');
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]);
     $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;
     }
     $dataProvider->query->joinWith(['nik0' => function ($q) {
         $q->from('base');
     }]);
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'timestamp' => $this->timestamp]);
     $query->andFilterWhere(['like', 'action', $this->action]);
     $query->andFilterWhere(['like', 'user_activity.nik', $this->nik]);
     $query->andFilterWhere(['like', 'base.nama', $this->nama]);
     return $dataProvider;
 }
Esempio n. 4
0
</h3>
				</div>
				<div class="icon">
				  <i class="fa fa-user"></i>
				</div>
			  </div>
		  </a>
		</div><!-- ./col -->
		<div class="col-lg-4 col-xs-6">
		  <!-- small box -->
		  <a href="admin/user-activity">
			  <div class="small-box bg-yellow">
				<div class="inner">
				  <p>Aktivitas User Hari Ini</p>
				  <h3><?php 
echo UserActivity::find()->where('timestamp like "' . \Yii::$app->formatter->asDate('now', 'php:Y-m-d') . '%"')->count();
?>
</h3>
				</div>
				<div class="icon">
				  <i class="fa fa-bar-chart"></i>
				</div>
			  </div>
		  </a>
		</div><!-- ./col -->
	  </div><!-- /.row -->
	  <!-- Main row -->
	  <div class="row">
		<!-- Left col -->
		<div class="col-lg-12">
		  <!-- Custom tabs (Charts with tabs)-->
    private function exportAktivitasUser()
    {
        $isi = UserActivity::find()->orderBy('timestamp desc')->asArray()->all();
        //VarDumper::dump($isi,5678);
        $filename = 'Data_Aktivitas_User-' . Date('YmdGis') . '.xls';
        header("Content-type: application/msexcel");
        header("Content-Disposition: attachment; filename=" . $filename);
        header("Pragma: no-cache");
        header("Expires: 0");
        echo "<style> .str{ mso-number-format:\\@; } </style>";
        echo '<table border="1" width="100%">
			<thead>
				<tr>
					<th>NIK</th>
					<th>Nama</th>
					<th>Aksi</th>
					<th>Timestamp</th>
				</tr>
			</thead>';
        foreach ($isi as $data) {
            $nama = DataManagement::findOne($data['nik'])->nama;
            echo '
			<tr>
				<td>' . $data['nik'] . '</td>
				<td>' . $nama . '</td>
				<td>' . $data['action'] . '</td>
				<td>' . $data['timestamp'] . '</td>
			</tr>
			';
        }
    }