diff --git a/assets/DashboardAsset.php b/assets/DashboardAsset.php new file mode 100644 index 00000000..bb204590 --- /dev/null +++ b/assets/DashboardAsset.php @@ -0,0 +1,23 @@ + 'basic', 'homeUrl' => ['/dashboard'], 'name' => 'BeetInnovators ANPR', - 'defaultRoute' => 'logs', + 'defaultRoute' => 'dashboard', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log'], 'timeZone' => 'Asia/Ho_Chi_Minh', diff --git a/controllers/DashboardController.php b/controllers/DashboardController.php new file mode 100644 index 00000000..dea74264 --- /dev/null +++ b/controllers/DashboardController.php @@ -0,0 +1,80 @@ +user->isGuest) { + return $this->redirect(['/site/login']); + } + } + + /** + * {@inheritdoc} + */ + public function behaviors() { + return [ + 'verbs' => [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + ]; + } + + /** + * Lists all Logs models. + * @return mixed + */ + public function actionIndex() { + $this->view->title = "Bảng điều khiển"; + $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'); + + $logs = Logs::find()->andWhere(["OR", ["BETWEEN", 'time_in', $f, $t], ["BETWEEN", 'time_out', $f, $t]])->orderBy(['time_in' => SORT_DESC, 'time_out' => SORT_DESC])->all(); + + $temp = []; + $in = 0; + $out = 0; + foreach ($logs as $k => $v) { + if ($v->time_out) { + $temp[$v->id] = $v->time_out; + } else { + $temp[$v->id] = $v->time_in; + } + if ($v->time_in) + $in++; + if ($v->time_out) + $out++; + } + arsort($temp); + + $results = []; + foreach ($temp as $k => $v) { + foreach ($logs as $key => $value) { + if ($value->id == $k) + $results[] = $value; + } + } + + return $this->render('index', [ + "results" => $results, + "in" => $in, + "out" => $out, + "common" => new \app\models\common() + ]); + } + +} diff --git a/controllers/LogsController.php b/controllers/LogsController.php index a865987b..9212e5b5 100644 --- a/controllers/LogsController.php +++ b/controllers/LogsController.php @@ -53,7 +53,6 @@ class LogsController extends Controller { $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'); $dataProvider->query->andWhere(["OR", ["BETWEEN", 'time_in', $f, $t], ["BETWEEN", 'time_out', $f, $t]]); - return $this->render('index', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, @@ -138,4 +137,151 @@ class LogsController extends Controller { throw new NotFoundHttpException('The requested page does not exist.'); } + public function actionSave() { + if (Yii::$app->request->post()) { + $post = Yii::$app->request->post(); + $logs = Logs::findOne($post['id']); + $field = $post['field']; + if ($logs) { + $logs->$field = $post['value']; + $logs->save(); + } + return "
Biển số | +Loại xe | +Tên công ty | +Lái xe | +Điện thoại | +CMT | +Factory | +SEAL_NO | +Ảnh biển vào | +Thời gian vào | +Ảnh biển ra | +Thời gian ra | +Nội dung khác | +
---|---|---|---|---|---|---|---|---|---|---|---|---|
{$arr->vehicle->plate} | +{$arr->vehicle->type} | +{$arr->vehicle->company} | +
+ {$data=explode("/",$arr->vehicle->driver)}
+ {implode(" ",$data)} + |
+
+ {$data=explode("/",$arr->vehicle->telephone)}
+ {implode(" ",$data)} + |
+
+ {$data=explode("/",$arr->vehicle->indentity_card)}
+ {implode(" ",$data)} + |
+
+
+ {if $arr->factory == null}
+ không có
+ {else}
+ {$arr->factory}
+ {/if}
+
+ |
+
+
+ {if $arr->seal_no == null}
+ không có
+ {else}
+ {$arr->seal_no}
+ {/if}
+
+ |
+
+ {if $arr->time_in}
+ |
+ + {if $arr->time_in} + {$common->formatTime($arr->time_in,"H:i:s d/m/Y")} + {/if} + | +
+ {if $arr->time_out}
+ |
+ + {if $arr->time_out} + {$common->formatTime($arr->time_out,"H:i:s d/m/Y")} + {/if} + | +
+
+ {if $arr->note == null}
+ không có
+ {else}
+ {$arr->note}
+ {/if}
+
+ |
+