99 lines
2.8 KiB
PHP
99 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace app\controllers;
|
|
|
|
use Yii;
|
|
use app\models\CaptureLogs;
|
|
use app\models\CaptureLogsSearch;
|
|
use yii\web\Controller;
|
|
use yii\web\NotFoundHttpException;
|
|
use yii\filters\VerbFilter;
|
|
|
|
/**
|
|
* CaptureLogsController implements the CRUD actions for CaptureLogs model.
|
|
*/
|
|
class CaptureLogsController extends Controller {
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function behaviors() {
|
|
return [
|
|
'verbs' => [
|
|
'class' => VerbFilter::className(),
|
|
'actions' => [
|
|
'delete' => ['POST'],
|
|
],
|
|
],
|
|
];
|
|
}
|
|
|
|
public function actionIndex($from = "", $to = "") {
|
|
$f = date_format(date_create_from_format('H:i d/m/Y', "00:00 " . date("d/m/Y")), 'U');
|
|
$t = date_format(date_create_from_format('H:i d/m/Y', "23:59 " . date("d/m/Y")), 'U');
|
|
if ($from !== "" && $to !== "") {
|
|
$f = date_format(date_create_from_format('H:i d/m/Y', $from), 'U');
|
|
$t = date_format(date_create_from_format('H:i d/m/Y', $to), 'U');
|
|
}
|
|
|
|
$this->view->title = "Capture Log";
|
|
$searchModel = new CaptureLogsSearch();
|
|
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
|
$dataProvider->query->andWhere(["BETWEEN", "time", $f, $t]);
|
|
$dataProvider->query->orderBy(["time" => SORT_DESC]);
|
|
|
|
return $this->render('index', [
|
|
'searchModel' => $searchModel,
|
|
'dataProvider' => $dataProvider,
|
|
'statusArray' => CaptureLogs::$statusArray,
|
|
'f' => $f,
|
|
't' => $t
|
|
]);
|
|
}
|
|
|
|
public function actionView($id) {
|
|
return $this->render('view', [
|
|
'model' => $this->findModel($id),
|
|
]);
|
|
}
|
|
|
|
public function actionCreate() {
|
|
$model = new CaptureLogs();
|
|
|
|
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
|
return $this->redirect(['view', 'id' => $model->id]);
|
|
}
|
|
|
|
return $this->render('create', [
|
|
'model' => $model,
|
|
]);
|
|
}
|
|
|
|
public function actionUpdate($id) {
|
|
$model = $this->findModel($id);
|
|
|
|
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
|
return $this->redirect(['view', 'id' => $model->id]);
|
|
}
|
|
|
|
return $this->render('update', [
|
|
'model' => $model,
|
|
]);
|
|
}
|
|
|
|
public function actionDelete($id) {
|
|
$this->findModel($id)->delete();
|
|
|
|
return $this->redirect(['index']);
|
|
}
|
|
|
|
protected function findModel($id) {
|
|
if (($model = CaptureLogs::findOne($id)) !== null) {
|
|
return $model;
|
|
}
|
|
|
|
throw new NotFoundHttpException('The requested page does not exist.');
|
|
}
|
|
|
|
}
|