update socket
This commit is contained in:
parent
6bee84075c
commit
adadd350ba
23
assets/DashboardAsset.php
Normal file
23
assets/DashboardAsset.php
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace app\assets;
|
||||
|
||||
use yii\web\AssetBundle;
|
||||
|
||||
class LogsAsset extends AssetBundle {
|
||||
|
||||
public $basePath = '@webroot';
|
||||
public $baseUrl = '@web';
|
||||
public $css = [
|
||||
];
|
||||
public $js = [
|
||||
'js/dashboard.js'
|
||||
];
|
||||
public $depends = [
|
||||
'yii\web\YiiAsset',
|
||||
'app\assets\AppAsset',
|
||||
// 'yii\jui\JuiAsset',
|
||||
'yii\bootstrap\BootstrapAsset',
|
||||
];
|
||||
|
||||
}
|
|
@ -9,7 +9,7 @@ $config = [
|
|||
'id' => 'basic',
|
||||
'homeUrl' => ['/dashboard'],
|
||||
'name' => 'BeetInnovators ANPR',
|
||||
'defaultRoute' => 'logs',
|
||||
'defaultRoute' => 'dashboard',
|
||||
'basePath' => dirname(__DIR__),
|
||||
'bootstrap' => ['log'],
|
||||
'timeZone' => 'Asia/Ho_Chi_Minh',
|
||||
|
|
80
controllers/DashboardController.php
Normal file
80
controllers/DashboardController.php
Normal file
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
|
||||
namespace app\controllers;
|
||||
|
||||
use Yii;
|
||||
use app\models\Logs;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
|
||||
/**
|
||||
* LogsController implements the CRUD actions for Logs model.
|
||||
*/
|
||||
class DashboardController extends Controller {
|
||||
|
||||
public function init() {
|
||||
parent::init();
|
||||
if (Yii::$app->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()
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
|
@ -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 "<div style='cursor:pointer;' onclick='openForm(this, \"{$field}\");' data-id='{$post['id']}' data-text='{$post['value']}'>{$post['value']}</div>";
|
||||
}
|
||||
}
|
||||
|
||||
public function actionExport($from = "", $to = "") {
|
||||
if ($from === "") {
|
||||
$from = "00:00 " . date("d/m/Y");
|
||||
}
|
||||
if ($to === "") {
|
||||
$to = "23:59 " . date("d/m/Y");
|
||||
}
|
||||
$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');
|
||||
|
||||
$lists = Logs::find()->andWhere(["OR", ["BETWEEN", 'time_in', $f, $t], ["BETWEEN", 'time_out', $f, $t]])->orderBy(['time_in' => SORT_ASC])->all();
|
||||
$objPHPExcel = new \PHPExcel();
|
||||
$count = 1;
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
$toExcelFile[] = [
|
||||
"STT",
|
||||
"Biến số",
|
||||
"Loại xe",
|
||||
"Tên công ty",
|
||||
"Lái xe",
|
||||
"Điện thoại",
|
||||
"CMT",
|
||||
"Factory",
|
||||
"SEAL_NO",
|
||||
"Thời gian vào",
|
||||
"Thời gian ra",
|
||||
"Nội dung khác"
|
||||
];
|
||||
foreach ($lists as $k => $v) {
|
||||
$ExportData[] = $count++;
|
||||
$ExportData[] = $v->vehicle->plate;
|
||||
$ExportData[] = $v->vehicle->type;
|
||||
$ExportData[] = $v->vehicle->company;
|
||||
$ExportData[] = $v->vehicle->driver;
|
||||
$ExportData[] = $v->vehicle->telephone;
|
||||
$ExportData[] = $v->vehicle->indentity_card;
|
||||
$ExportData[] = $v->factory;
|
||||
$ExportData[] = $v->seal_no;
|
||||
$ExportData[] = $v->time_in == 0 ? "" : date("H:i:s d/m/Y", $v->time_in);
|
||||
$ExportData[] = $v->time_out == 0 ? "" : date("H:i:s d/m/Y", $v->time_out);
|
||||
$ExportData[] = $v->note;
|
||||
$toExcelFile[] = $ExportData;
|
||||
unset($ExportData);
|
||||
}
|
||||
$totals = count($lists) + 2;
|
||||
$activeSheet = $objPHPExcel->getActiveSheet();
|
||||
$activeSheet->setCellValue("A1", "DANH SÁCH XE RA VÀO TỪ {$from} ĐẾN {$to}");
|
||||
$activeSheet->mergeCells('A1:L1');
|
||||
$activeSheet->getRowDimension('1')->setRowHeight(50);
|
||||
$activeSheet->getStyle("A2:L2")->getFont()->setBold(true);
|
||||
$activeSheet->getStyle("A1")->getFont()->setBold(true)->setName('Time New Roman')->setSize(13);
|
||||
$activeSheet->getStyle("A2:L" . $totals)->getFont()->setName('Time New Roman')->setSize(10);
|
||||
$activeSheet->getColumnDimension('A')->setWidth(5);
|
||||
$activeSheet->getColumnDimension('B')->setWidth(12);
|
||||
$activeSheet->getColumnDimension('C')->setWidth(10);
|
||||
$activeSheet->getColumnDimension('D')->setWidth(30);
|
||||
$activeSheet->getColumnDimension('E')->setWidth(15);
|
||||
$activeSheet->getColumnDimension('F')->setWidth(15);
|
||||
$activeSheet->getColumnDimension('G')->setWidth(15);
|
||||
$activeSheet->getColumnDimension('H')->setWidth(12);
|
||||
$activeSheet->getColumnDimension('I')->setWidth(10);
|
||||
$activeSheet->getColumnDimension('J')->setWidth(15);
|
||||
$activeSheet->getColumnDimension('K')->setWidth(15);
|
||||
$activeSheet->getColumnDimension('L')->setWidth(20);
|
||||
$style = array(
|
||||
'alignment' => array(
|
||||
'horizontal' => \PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
|
||||
'vertical' => \PHPExcel_Style_Alignment::VERTICAL_CENTER,
|
||||
'wrap' => true
|
||||
)
|
||||
);
|
||||
$activeSheet->getStyle("A1:L2")->applyFromArray($style);
|
||||
$activeSheet->getStyle("A2:L2")->applyFromArray([
|
||||
'fill' => array(
|
||||
'type' => \PHPExcel_Style_Fill::FILL_SOLID,
|
||||
'color' => array('rgb' => '00c0ef')
|
||||
)
|
||||
]);
|
||||
$rowCount = 2;
|
||||
for ($i = 0; $i < count($toExcelFile); $i++) {
|
||||
$column = 'A';
|
||||
$row = $toExcelFile[$i];
|
||||
for ($j = 0; $j < count($row); $j++) {
|
||||
if (!isset($row[$j]))
|
||||
$value = NULL;
|
||||
elseif ($row[$j] != "")
|
||||
$value = strip_tags($row[$j]);
|
||||
else
|
||||
$value = "";
|
||||
$activeSheet->setCellValue($column . $rowCount, $value);
|
||||
$column = chr(ord($column) + 1);
|
||||
}
|
||||
$rowCount++;
|
||||
}
|
||||
|
||||
$activeSheet->getStyle("A2:L" . $totals)->applyFromArray([
|
||||
'alignment' => [
|
||||
'horizontal' => \PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
|
||||
'vertical' => \PHPExcel_Style_Alignment::VERTICAL_CENTER,
|
||||
'wrap' => true
|
||||
],
|
||||
'borders' => [
|
||||
'allborders' => [
|
||||
'style' => \PHPExcel_Style_Border::BORDER_THIN
|
||||
]
|
||||
]
|
||||
]);
|
||||
$activeSheet->getStyle("D3:D" . $totals)->applyFromArray([
|
||||
'alignment' => [
|
||||
'horizontal' => \PHPExcel_Style_Alignment::HORIZONTAL_LEFT,
|
||||
'wrap' => true
|
||||
]
|
||||
]);
|
||||
|
||||
$activeSheet->setCellValue("B" . ($totals + 3), "Tổng số lượt xe vào:");
|
||||
$activeSheet->setCellValue("B" . ($totals + 4), "Tổng số lượt xe ra:");
|
||||
$activeSheet->mergeCells("B" . ($totals + 3) . ":C" . ($totals + 3));
|
||||
$activeSheet->mergeCells("B" . ($totals + 4) . ":C" . ($totals + 4));
|
||||
|
||||
$activeSheet->setCellValue("D" . ($totals + 3), Logs::find()->andWhere(["BETWEEN", "time_in", $f, $t])->count());
|
||||
$activeSheet->setCellValue("D" . ($totals + 4), Logs::find()->andWhere(["BETWEEN", "time_out", $f, $t])->count());
|
||||
|
||||
$activeSheet->getStyle("B" . ($totals + 3) . ":B" . ($totals + 5))->getFont()->setBold(true)->setItalic(true)->setName('Time New Roman')->setSize(11);
|
||||
$activeSheet->getStyle("D" . ($totals + 3) . ":D" . ($totals + 5))->getFont()->setItalic(true)->setName('Time New Roman')->setSize(11);
|
||||
|
||||
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
ob_end_clean();
|
||||
header('Content-type: application/vnd.ms-excel');
|
||||
header('Content-Disposition: attachment; filename="bao-cao.xlsx"');
|
||||
header('Cache-Control: max-age=0');
|
||||
$objWriter->save('php://output');
|
||||
exit();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -138,4 +138,151 @@ class LogsUnknowController 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 = LogsUnknow::findOne($post['id']);
|
||||
$field = $post['field'];
|
||||
if ($logs) {
|
||||
$logs->$field = $post['value'];
|
||||
$logs->save();
|
||||
}
|
||||
return "<div style='cursor:pointer;' onclick='openForm(this, \"{$field}\");' data-id='{$post['id']}' data-text='{$post['value']}'>{$post['value']}</div>";
|
||||
}
|
||||
}
|
||||
|
||||
public function actionExport($from = "", $to = "") {
|
||||
if ($from === "") {
|
||||
$from = "00:00 " . date("d/m/Y");
|
||||
}
|
||||
if ($to === "") {
|
||||
$to = "23:59 " . date("d/m/Y");
|
||||
}
|
||||
$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');
|
||||
|
||||
$lists = LogsUnknow::find()->andWhere(["OR", ["BETWEEN", 'time_in', $f, $t], ["BETWEEN", 'time_out', $f, $t]])->orderBy(['time_in' => SORT_ASC])->all();
|
||||
$objPHPExcel = new \PHPExcel();
|
||||
$count = 1;
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
$toExcelFile[] = [
|
||||
"STT",
|
||||
"Biến số",
|
||||
"Loại xe",
|
||||
"Tên công ty",
|
||||
"Lái xe",
|
||||
"Điện thoại",
|
||||
"CMT",
|
||||
"Factory",
|
||||
"SEAL_NO",
|
||||
"Thời gian vào",
|
||||
"Thời gian ra",
|
||||
"Nội dung khác"
|
||||
];
|
||||
foreach ($lists as $k => $v) {
|
||||
$ExportData[] = $count++;
|
||||
$ExportData[] = $v->plate;
|
||||
$ExportData[] = "";
|
||||
$ExportData[] = "";
|
||||
$ExportData[] = "";
|
||||
$ExportData[] = "";
|
||||
$ExportData[] = "";
|
||||
$ExportData[] = $v->factory;
|
||||
$ExportData[] = $v->seal_no;
|
||||
$ExportData[] = $v->time_in == 0 ? "" : date("H:i:s d/m/Y", $v->time_in);
|
||||
$ExportData[] = $v->time_out == 0 ? "" : date("H:i:s d/m/Y", $v->time_out);
|
||||
$ExportData[] = $v->note;
|
||||
$toExcelFile[] = $ExportData;
|
||||
unset($ExportData);
|
||||
}
|
||||
$totals = count($lists) + 2;
|
||||
$activeSheet = $objPHPExcel->getActiveSheet();
|
||||
$activeSheet->setCellValue("A1", "DANH SÁCH XE KHÔNG RÕ NGUỒN GỐC RA VÀO TỪ {$from} ĐẾN {$to}");
|
||||
$activeSheet->mergeCells('A1:L1');
|
||||
$activeSheet->getRowDimension('1')->setRowHeight(50);
|
||||
$activeSheet->getStyle("A2:L2")->getFont()->setBold(true);
|
||||
$activeSheet->getStyle("A1")->getFont()->setBold(true)->setName('Time New Roman')->setSize(13);
|
||||
$activeSheet->getStyle("A2:L" . $totals)->getFont()->setName('Time New Roman')->setSize(10);
|
||||
$activeSheet->getColumnDimension('A')->setWidth(5);
|
||||
$activeSheet->getColumnDimension('B')->setWidth(12);
|
||||
$activeSheet->getColumnDimension('C')->setWidth(10);
|
||||
$activeSheet->getColumnDimension('D')->setWidth(30);
|
||||
$activeSheet->getColumnDimension('E')->setWidth(15);
|
||||
$activeSheet->getColumnDimension('F')->setWidth(15);
|
||||
$activeSheet->getColumnDimension('G')->setWidth(15);
|
||||
$activeSheet->getColumnDimension('H')->setWidth(12);
|
||||
$activeSheet->getColumnDimension('I')->setWidth(10);
|
||||
$activeSheet->getColumnDimension('J')->setWidth(15);
|
||||
$activeSheet->getColumnDimension('K')->setWidth(15);
|
||||
$activeSheet->getColumnDimension('L')->setWidth(20);
|
||||
$style = array(
|
||||
'alignment' => array(
|
||||
'horizontal' => \PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
|
||||
'vertical' => \PHPExcel_Style_Alignment::VERTICAL_CENTER,
|
||||
'wrap' => true
|
||||
)
|
||||
);
|
||||
$activeSheet->getStyle("A1:L2")->applyFromArray($style);
|
||||
$activeSheet->getStyle("A2:L2")->applyFromArray([
|
||||
'fill' => array(
|
||||
'type' => \PHPExcel_Style_Fill::FILL_SOLID,
|
||||
'color' => array('rgb' => '00c0ef')
|
||||
)
|
||||
]);
|
||||
$rowCount = 2;
|
||||
for ($i = 0; $i < count($toExcelFile); $i++) {
|
||||
$column = 'A';
|
||||
$row = $toExcelFile[$i];
|
||||
for ($j = 0; $j < count($row); $j++) {
|
||||
if (!isset($row[$j]))
|
||||
$value = NULL;
|
||||
elseif ($row[$j] != "")
|
||||
$value = strip_tags($row[$j]);
|
||||
else
|
||||
$value = "";
|
||||
$activeSheet->setCellValue($column . $rowCount, $value);
|
||||
$column = chr(ord($column) + 1);
|
||||
}
|
||||
$rowCount++;
|
||||
}
|
||||
|
||||
$activeSheet->getStyle("A2:L" . $totals)->applyFromArray([
|
||||
'alignment' => [
|
||||
'horizontal' => \PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
|
||||
'vertical' => \PHPExcel_Style_Alignment::VERTICAL_CENTER,
|
||||
'wrap' => true
|
||||
],
|
||||
'borders' => [
|
||||
'allborders' => [
|
||||
'style' => \PHPExcel_Style_Border::BORDER_THIN
|
||||
]
|
||||
]
|
||||
]);
|
||||
$activeSheet->getStyle("D3:D" . $totals)->applyFromArray([
|
||||
'alignment' => [
|
||||
'horizontal' => \PHPExcel_Style_Alignment::HORIZONTAL_LEFT,
|
||||
'wrap' => true
|
||||
]
|
||||
]);
|
||||
|
||||
$activeSheet->setCellValue("B" . ($totals + 3), "Tổng số lượt xe vào:");
|
||||
$activeSheet->setCellValue("B" . ($totals + 4), "Tổng số lượt xe ra:");
|
||||
$activeSheet->mergeCells("B" . ($totals + 3) . ":C" . ($totals + 3));
|
||||
$activeSheet->mergeCells("B" . ($totals + 4) . ":C" . ($totals + 4));
|
||||
|
||||
$activeSheet->setCellValue("D" . ($totals + 3), LogsUnknow::find()->andWhere(["BETWEEN", "time_in", $f, $t])->count());
|
||||
$activeSheet->setCellValue("D" . ($totals + 4), LogsUnknow::find()->andWhere(["BETWEEN", "time_out", $f, $t])->count());
|
||||
|
||||
$activeSheet->getStyle("B" . ($totals + 3) . ":B" . ($totals + 5))->getFont()->setBold(true)->setItalic(true)->setName('Time New Roman')->setSize(11);
|
||||
$activeSheet->getStyle("D" . ($totals + 3) . ":D" . ($totals + 5))->getFont()->setItalic(true)->setName('Time New Roman')->setSize(11);
|
||||
|
||||
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
ob_end_clean();
|
||||
header('Content-type: application/vnd.ms-excel');
|
||||
header('Content-Disposition: attachment; filename="bao-cao.xlsx"');
|
||||
header('Cache-Control: max-age=0');
|
||||
$objWriter->save('php://output');
|
||||
exit();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ class VehicleController extends Controller {
|
|||
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
|
||||
//
|
||||
// public function actionImport() {
|
||||
// $file_type = \PHPExcel_IOFactory::identify("data/data.xlsx");
|
||||
// $objReader = \PHPExcel_IOFactory::createReader($file_type);
|
||||
|
@ -165,12 +165,12 @@ class VehicleController extends Controller {
|
|||
// if ($k > 1) {
|
||||
// $model = new Vehicle();
|
||||
// $kq[] = $model->create([
|
||||
// 'plate' => $this->formatPlate($row["B"]),
|
||||
// 'plate' => $this->format($row["B"]),
|
||||
// 'type' => $row["C"],
|
||||
// 'company' => $row["D"],
|
||||
// 'vehicle_type' => $row["E"],
|
||||
// 'driver' => $row["F"],
|
||||
// 'telephone' => $this->formatPlate($row["G"]),
|
||||
// 'telephone' => $this->format($row["G"]),
|
||||
// 'indentity_card' => strval($row["H"])
|
||||
// ]);
|
||||
// }
|
||||
|
@ -180,11 +180,77 @@ class VehicleController extends Controller {
|
|||
// echo "</pre>";
|
||||
// exit();
|
||||
// }
|
||||
//
|
||||
|
||||
public function format($plate) {
|
||||
$p1 = str_replace("-", "", $plate);
|
||||
$p2 = str_replace(".", "", $p1);
|
||||
return str_replace(" ", "", $p2);
|
||||
$p3 = str_replace("\n", "", $p2);
|
||||
return str_replace(" ", "", $p3);
|
||||
}
|
||||
//
|
||||
// public function actionExport() {
|
||||
// set_time_limit(3600);
|
||||
// $vehicles = Vehicle::find()->orderBy(['plate' => SORT_ASC])->all();
|
||||
// $connection = Yii::$app->getDb();
|
||||
// foreach ($vehicles as $k => $v) {
|
||||
// $command = $connection->createCommand("SELECT * FROM `vehicle` WHERE `plate`<>'{$v->plate}' AND levenshtein('%{$v->plate}', `plate`) BETWEEN 0 AND 1");
|
||||
// $result = $command->queryAll();
|
||||
// $temp = [];
|
||||
// foreach ($result as $key => $value) {
|
||||
// $temp[] = $value['plate'];
|
||||
// }
|
||||
// $v->levenshtein_plate_2 = json_encode($temp);
|
||||
// $v->save();
|
||||
// }
|
||||
// exit();
|
||||
//
|
||||
// $objPHPExcel = new \PHPExcel();
|
||||
// $count = 1;
|
||||
// $objPHPExcel->setActiveSheetIndex(0);
|
||||
// $toExcelFile[] = [
|
||||
// "STT",
|
||||
// "Biển số",
|
||||
// "Gần giống",
|
||||
// "Công ty",
|
||||
// "Lái xe"
|
||||
// ];
|
||||
// foreach ($vehicles as $k => $v) {
|
||||
// $ExportData[] = $count++;
|
||||
// $ExportData[] = $v->plate;
|
||||
// $connection = Yii::$app->getDb();
|
||||
// $command = $connection->createCommand("SELECT * FROM `vehicle` WHERE levenshtein(':plate_query', `plate`) BETWEEN 0 AND 2 AND `plate`<>':plate_query'", [':plate_query' => $v->plate]);
|
||||
// $result = $command->queryAll();
|
||||
// $ExportData[] = count($result);
|
||||
// $ExportData[] = $v->company;
|
||||
// $ExportData[] = $v->driver;
|
||||
// $toExcelFile[] = $ExportData;
|
||||
// unset($ExportData);
|
||||
// }
|
||||
// $activeSheet = $objPHPExcel->getActiveSheet();
|
||||
// $rowCount = 1;
|
||||
// for ($i = 0; $i < count($toExcelFile); $i++) {
|
||||
// $column = 'A';
|
||||
// $row = $toExcelFile[$i];
|
||||
// for ($j = 0; $j < count($row); $j++) {
|
||||
// if (!isset($row[$j]))
|
||||
// $value = NULL;
|
||||
// elseif ($row[$j] != "")
|
||||
// $value = strip_tags($row[$j]);
|
||||
// else
|
||||
// $value = "";
|
||||
// $activeSheet->setCellValue($column . $rowCount, $value);
|
||||
// $column = chr(ord($column) + 1);
|
||||
// }
|
||||
// $rowCount++;
|
||||
// }
|
||||
//
|
||||
// $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
// ob_end_clean();
|
||||
// header('Content-type: application/vnd.ms-excel');
|
||||
// header('Content-Disposition: attachment; filename="bao-cao.xlsx"');
|
||||
// header('Cache-Control: max-age=0');
|
||||
// $objWriter->save('php://output');
|
||||
// exit();
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
@ -26,11 +26,17 @@ class LogsGrid {
|
|||
public static function plateIn() {
|
||||
return function($model) {
|
||||
if ($model->time_in) {
|
||||
$style = "width:100px";
|
||||
$style = "width:100px;cursor:pointer;";
|
||||
$image = $model->plate_image_in;
|
||||
return Html::img(Yii::$app->request->hostInfo . "/AIParking_Intops_Server/web/data/uploads/" . $image, [
|
||||
'class' => "img-thumbnail",
|
||||
"style" => $style
|
||||
"style" => $style,
|
||||
"data" => [
|
||||
"toggle" => "popover-hover",
|
||||
"img" => Yii::$app->request->hostInfo . "/AIParking_Intops_Server/web/data/uploads/" . $model->frame_image_in,
|
||||
"size" => "min"
|
||||
],
|
||||
"onclick" => "resizeImage(this);"
|
||||
]);
|
||||
} else {
|
||||
return "";
|
||||
|
@ -38,24 +44,20 @@ class LogsGrid {
|
|||
};
|
||||
}
|
||||
|
||||
public static function cardId() {
|
||||
return function($model) {
|
||||
if ($model->card_id != 0) {
|
||||
return sprintf("%06d", $model->card_id);
|
||||
} else {
|
||||
return "<i class='text-red'>Thẻ đã bị xóa!</i>";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static function plateOut() {
|
||||
return function($model) {
|
||||
if ($model->time_out) {
|
||||
$style = "width:100px";
|
||||
$style = "width:100px;cursor:pointer;";
|
||||
$image = $model->plate_image_out;
|
||||
return Html::img(Yii::$app->request->hostInfo . "/AIParking_Intops_Server/web/data/uploads/" . $image, [
|
||||
'class' => "img-thumbnail",
|
||||
"style" => $style
|
||||
"style" => $style,
|
||||
"data" => [
|
||||
"toggle" => "popover-hover",
|
||||
"img" => Yii::$app->request->hostInfo . "/AIParking_Intops_Server/web/data/uploads/" . $model->frame_image_out,
|
||||
"size" => "min"
|
||||
],
|
||||
"onclick" => "resizeImage(this);"
|
||||
]);
|
||||
} else {
|
||||
return "";
|
||||
|
@ -85,4 +87,58 @@ class LogsGrid {
|
|||
};
|
||||
}
|
||||
|
||||
public static function driver() {
|
||||
return function($model) {
|
||||
$ls = explode("/", $model->vehicle->driver);
|
||||
return implode("<br>", $ls);
|
||||
};
|
||||
}
|
||||
|
||||
public static function telephone() {
|
||||
return function($model) {
|
||||
$ls = explode("/", $model->vehicle->telephone);
|
||||
return implode("<br>", $ls);
|
||||
};
|
||||
}
|
||||
|
||||
public static function cmt() {
|
||||
return function($model) {
|
||||
$ls = explode("/", $model->vehicle->indentity_card);
|
||||
return implode("<br>", $ls);
|
||||
};
|
||||
}
|
||||
|
||||
public static function factory() {
|
||||
return function($model) {
|
||||
$text = $model->factory;
|
||||
if ($model->factory == null)
|
||||
$text = "<i class='text-red'>không có</i>";
|
||||
|
||||
$data = "<div style='cursor:pointer;' onclick='openForm(this, \"factory\");' data-id='{$model->id}' data-text='{$model->factory}'>{$text}</div>";
|
||||
return $data;
|
||||
};
|
||||
}
|
||||
|
||||
public static function sealNo() {
|
||||
return function($model) {
|
||||
$text = $model->seal_no;
|
||||
if ($model->seal_no == null)
|
||||
$text = "<i class='text-red'>không có</i>";
|
||||
|
||||
$data = "<div style='cursor:pointer;' onclick='openForm(this, \"seal_no\");' data-id='{$model->id}' data-text='{$model->seal_no}'>{$text}</div>";
|
||||
return $data;
|
||||
};
|
||||
}
|
||||
|
||||
public static function note() {
|
||||
return function($model) {
|
||||
$text = $model->note;
|
||||
if ($model->note == null)
|
||||
$text = "<i class='text-red'>không có</i>";
|
||||
|
||||
$data = "<div style='cursor:pointer;' onclick='openForm(this, \"note\");' data-id='{$model->id}' data-text='{$model->note}'>{$text}</div>";
|
||||
return $data;
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -52,6 +52,9 @@ class LogsSearch extends Logs {
|
|||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
'sort' => [
|
||||
'defaultOrder' => ['time_in' => SORT_DESC, 'time_out' => SORT_DESC]
|
||||
]
|
||||
]);
|
||||
|
||||
$this->load($params);
|
||||
|
|
|
@ -32,7 +32,7 @@ class Vehicle extends \yii\db\ActiveRecord {
|
|||
*/
|
||||
public function rules() {
|
||||
return [
|
||||
[['plate', 'type'], 'required'],
|
||||
[['plate'], 'required'],
|
||||
[['company', 'vehicle_type'], 'string'],
|
||||
[['plate', 'type'], 'string', 'max' => 20],
|
||||
[['driver', 'telephone', 'indentity_card'], 'string', 'max' => 200],
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
[
|
||||
'options' => ['class' => 'sidebar-menu tree', 'data-widget' => 'tree'],
|
||||
'items' => [
|
||||
['label' => 'Bảng điều khiển', 'url' => ['/dashboard'], 'icon' => 'dashboard'],
|
||||
['label' => 'Thống kê', 'url' => ['/logs'], 'icon' => 'bar-chart'],
|
||||
['label' => 'Danh sách xe', 'url' => ['/vehicle'], 'icon' => 'truck'],
|
||||
['label' => 'Người dùng', 'url' => ['/user'], 'icon' => 'users', 'visible' => Yii::$app->user->can("administrator")],
|
||||
|
|
114
views/dashboard/index.tpl
Normal file
114
views/dashboard/index.tpl
Normal file
|
@ -0,0 +1,114 @@
|
|||
{extends file=$smarty.current_dir|cat:'/../extends.tpl'}
|
||||
{use class="yii\helpers\Url"}
|
||||
{use class="yii\grid\GridView"}
|
||||
{use class="app\assets\DashboardAsset"}
|
||||
{DashboardAsset::register($this)|void}
|
||||
{block name='content'}
|
||||
<input type="hidden" value="{Url::to(['/logs/save'])}" name="saveUrl">
|
||||
<input type="hidden" value="{date("d/m/Y")}" name="currentDay">
|
||||
<h2 class="text-center" style="font-family: Time New Roman;color:#009;font-weight: bold;">{"XE RA/VÀO NGÀY "|cat:date("d/m/Y")|upper}</h2>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="text-left" style="margin-bottom: 10px;font-size: 20px;">
|
||||
Tổng số xe vào: <b class="text-green" id="totals-in">{$in}</b>
|
||||
<br>
|
||||
Tổng số xe ra: <b class="text-red" id="totals-out">{$out}</b>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 text-right">
|
||||
<a href="{Url::to(['/logs'])}" class="btn btn-primary" target="_blank">
|
||||
<i class="fa fa-bar-chart"></i> Thống kê
|
||||
</a>
|
||||
<a href="{Url::to(['/logs-unknow'])}" class="btn btn-danger" target="_blank">
|
||||
<i class="fa fa-truck"></i> Xe khác
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<table class="table table-striped table-bordered" style="background:#fff;min-width:700px;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Biển số</th>
|
||||
<th>Loại xe</th>
|
||||
<th style="width: 15%;">Tên công ty</th>
|
||||
<th style="width: 10%;">Lái xe</th>
|
||||
<th>Điện thoại</th>
|
||||
<th style="width: 7%;">CMT</th>
|
||||
<th>Factory</th>
|
||||
<th>SEAL_NO</th>
|
||||
<th style="width: 8%;">Ảnh biển vào</th>
|
||||
<th style="width: 7%;">Thời gian vào</th>
|
||||
<th style="width: 8%;">Ảnh biển ra</th>
|
||||
<th style="width: 7%;">Thời gian ra</th>
|
||||
<th>Nội dung khác</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="logs-lists">
|
||||
{foreach from=$results item=arr}
|
||||
<tr id="logs-{$arr->id}">
|
||||
<td>{$arr->vehicle->plate}</td>
|
||||
<td>{$arr->vehicle->type}</td>
|
||||
<td>{$arr->vehicle->company}</td>
|
||||
<td>
|
||||
{$data=explode("/",$arr->vehicle->driver)}
|
||||
{implode("<br>",$data)}
|
||||
</td>
|
||||
<td>
|
||||
{$data=explode("/",$arr->vehicle->telephone)}
|
||||
{implode("<br>",$data)}
|
||||
</td>
|
||||
<td>
|
||||
{$data=explode("/",$arr->vehicle->indentity_card)}
|
||||
{implode("<br>",$data)}
|
||||
</td>
|
||||
<td>
|
||||
<div style='cursor:pointer;' onclick='openForm(this, "factory");' data-id='{$arr->id}' data-text='{$arr->factory}'>
|
||||
{if $arr->factory == null}
|
||||
<i class='text-red'>không có</i>
|
||||
{else}
|
||||
{$arr->factory}
|
||||
{/if}
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div style='cursor:pointer;' onclick='openForm(this, "seal_no");' data-id='{$arr->id}' data-text='{$arr->seal_no}'>
|
||||
{if $arr->seal_no == null}
|
||||
<i class='text-red'>không có</i>
|
||||
{else}
|
||||
{$arr->seal_no}
|
||||
{/if}
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
{if $arr->time_in}
|
||||
<img src="{Yii::$app->request->hostInfo}/AIParking_Intops_Server/web/data/uploads/{$arr->plate_image_in}" class="img-thumbnail" style="width:100%;">
|
||||
{/if}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
{if $arr->time_in}
|
||||
{$common->formatTime($arr->time_in,"H:i:s d/m/Y")}
|
||||
{/if}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
{if $arr->time_out}
|
||||
<img src="{Yii::$app->request->hostInfo}/AIParking_Intops_Server/web/data/uploads/{$arr->plate_image_out}" class="img-thumbnail" style="width:100%;">
|
||||
{/if}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
{if $arr->time_out}
|
||||
{$common->formatTime($arr->time_out,"H:i:s d/m/Y")}
|
||||
{/if}
|
||||
</td>
|
||||
<td>
|
||||
<div style='cursor:pointer;' onclick='openForm(this, "note");' data-id='{$arr->id}' data-text='{$arr->note}'>
|
||||
{if $arr->note == null}
|
||||
<i class='text-red'>không có</i>
|
||||
{else}
|
||||
{$arr->note}
|
||||
{/if}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
{/block}
|
|
@ -4,6 +4,7 @@
|
|||
{use class="app\assets\LogsAsset"}
|
||||
{LogsAsset::register($this)|void}
|
||||
{block name='content'}
|
||||
<input type="hidden" value="{Url::to(['/logs-unknow/save'])}" name="saveUrl">
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
<div class="form-group">
|
||||
|
@ -44,8 +45,16 @@
|
|||
'columns' => [
|
||||
['class' => 'yii\grid\SerialColumn'],
|
||||
'plate',
|
||||
'factory',
|
||||
'seal_no',
|
||||
[
|
||||
'attribute' => 'factory',
|
||||
'format' => 'raw',
|
||||
'value' => \app\helpers\LogsGrid::factory()
|
||||
],
|
||||
[
|
||||
'attribute' => 'seal_no',
|
||||
'format' => 'raw',
|
||||
'value' => \app\helpers\LogsGrid::sealNo()
|
||||
],
|
||||
[
|
||||
'attribute' => "plate_image_in",
|
||||
'format' => 'raw',
|
||||
|
@ -74,7 +83,11 @@
|
|||
'headerOptions' => ['style' => 'width:5%'],
|
||||
'value' => \app\helpers\LogsGrid::timeOut()
|
||||
],
|
||||
'note'
|
||||
[
|
||||
'attribute' => 'note',
|
||||
'format' => 'raw',
|
||||
'value' => \app\helpers\LogsGrid::note()
|
||||
]
|
||||
]
|
||||
])}
|
||||
{/block}
|
|
@ -4,6 +4,15 @@
|
|||
{use class="app\assets\LogsAsset"}
|
||||
{LogsAsset::register($this)|void}
|
||||
{block name='content'}
|
||||
<style>
|
||||
.img-thumbnail{
|
||||
max-width: inherit;
|
||||
}
|
||||
.popover{
|
||||
max-width:600px;
|
||||
}
|
||||
</style>
|
||||
<input type="hidden" value="{Url::to(['/logs/save'])}" name="saveUrl">
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
<div class="form-group">
|
||||
|
@ -31,7 +40,12 @@
|
|||
<i class="fa fa-download"></i> Xuất báo cáo
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-md-2 col-md-push-4">
|
||||
<div class="col-md-1 col-md-push-3">
|
||||
<button class="btn btn-info" onclick="window.location.reload(true);">
|
||||
<i class="fa fa-refresh"></i> Làm mới
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-md-2 col-md-push-3">
|
||||
<a href="{Url::to(['/logs-unknow'])}" class="btn btn-danger">
|
||||
<i class="fa fa-truck"></i> Xe khác
|
||||
</a>
|
||||
|
@ -62,23 +76,33 @@
|
|||
],
|
||||
[
|
||||
'attribute' => 'driver',
|
||||
'value' => 'vehicle.driver'
|
||||
'format' => 'raw',
|
||||
'value' => \app\helpers\LogsGrid::driver()
|
||||
],
|
||||
[
|
||||
'attribute' => 'telephone',
|
||||
'value' => 'vehicle.telephone'
|
||||
'format' => 'raw',
|
||||
'value' => \app\helpers\LogsGrid::telephone()
|
||||
],
|
||||
[
|
||||
'attribute' => 'cmt',
|
||||
'value' => 'vehicle.indentity_card'
|
||||
'format' => 'raw',
|
||||
'value' => \app\helpers\LogsGrid::cmt()
|
||||
],
|
||||
[
|
||||
'attribute' => 'factory',
|
||||
'format' => 'raw',
|
||||
'value' => \app\helpers\LogsGrid::factory()
|
||||
],
|
||||
[
|
||||
'attribute' => 'seal_no',
|
||||
'format' => 'raw',
|
||||
'value' => \app\helpers\LogsGrid::sealNo()
|
||||
],
|
||||
'factory',
|
||||
'seal_no',
|
||||
[
|
||||
'attribute' => "plate_image_in",
|
||||
'format' => 'raw',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['style' => 'width:8%'],
|
||||
'value' => \app\helpers\LogsGrid::plateIn()
|
||||
],
|
||||
[
|
||||
|
@ -92,7 +116,6 @@
|
|||
'attribute' => "plate_image_out",
|
||||
'format' => 'raw',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['style' => 'width:8%'],
|
||||
'value' => \app\helpers\LogsGrid::plateOut()
|
||||
],
|
||||
[
|
||||
|
@ -102,7 +125,11 @@
|
|||
'headerOptions' => ['style' => 'width:5%'],
|
||||
'value' => \app\helpers\LogsGrid::timeOut()
|
||||
],
|
||||
'note'
|
||||
[
|
||||
'attribute' => 'note',
|
||||
'format' => 'raw',
|
||||
'value' => \app\helpers\LogsGrid::note()
|
||||
]
|
||||
]
|
||||
])}
|
||||
{/block}
|
109
web/js/dashboard.js
Normal file
109
web/js/dashboard.js
Normal file
|
@ -0,0 +1,109 @@
|
|||
$(function () {
|
||||
var socket = io.connect("http://localhost:4004");
|
||||
socket.on('logs', function (data) {
|
||||
var date = new Date(data.time * 1000);
|
||||
var day = "0" + date.getDate();
|
||||
var month = "0" + (date.getMonth() + 1);
|
||||
var year = date.getFullYear();
|
||||
var formattedDay = day + "/" + month + "/" + year;
|
||||
if ($("input[name='currentDay']").val() !== formattedDay) {
|
||||
window.location.reload(true);
|
||||
}
|
||||
renderNewLogs(data);
|
||||
});
|
||||
});
|
||||
|
||||
function openForm(e, field) {
|
||||
var html = `<input type="text" class="form-control" value="` + $(e).data("text") + `" data-id="` + $(e).data("id") + `" data-field="` + field + `" onchange="_save(this);" autofocus>`;
|
||||
$(e).closest("td").html(html);
|
||||
}
|
||||
|
||||
function _save(e) {
|
||||
$.ajax({
|
||||
url: $("input[name='saveUrl']").val(),
|
||||
type: 'POST',
|
||||
data: {
|
||||
id: $(e).data("id"),
|
||||
field: $(e).data("field"),
|
||||
value: $(e).val()
|
||||
},
|
||||
success: function (data) {
|
||||
$(e).closest("td").html(data);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
common.ajaxError();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function formatTime(unix_timestamp) {
|
||||
var date = new Date(unix_timestamp * 1000);
|
||||
var hours = date.getHours();
|
||||
var minutes = "0" + date.getMinutes();
|
||||
var seconds = "0" + date.getSeconds();
|
||||
|
||||
var day = "0" + date.getDate();
|
||||
var month = "0" + (date.getMonth() + 1);
|
||||
var year = date.getFullYear();
|
||||
|
||||
var formattedTime = hours + ':' + minutes.substr(-2) + ':' + seconds.substr(-2);
|
||||
var formattedDay = day + "/" + month + "/" + year;
|
||||
return formattedTime + " " + formattedDay;
|
||||
}
|
||||
|
||||
function renderNewLogs(data) {
|
||||
var imageIn = "";
|
||||
var timeIn = "";
|
||||
var imageOut = "";
|
||||
var timeOut = "";
|
||||
if (data.type == "in") {
|
||||
imageIn = `<img src="/AIParking_Intops_Server/web/data/uploads/` + data.image + `" class="img-thumbnail" style="width:100%;">`;
|
||||
timeIn = formatTime(data.time);
|
||||
$("#totals-in").html(parseInt($("#totals-in").html()) + 1);
|
||||
}
|
||||
if (data.type == "out") {
|
||||
if (data.logs) {
|
||||
imageIn = `<img src="/AIParking_Intops_Server/web/data/uploads/` + data.logs.plate_image_in + `" class="img-thumbnail" style="width:100%;">`;
|
||||
timeIn = formatTime(data.logs.time_in);
|
||||
} else {
|
||||
imageIn = "";
|
||||
timeIn = "";
|
||||
}
|
||||
imageOut = `<img src="/AIParking_Intops_Server/web/data/uploads/` + data.image + `" class="img-thumbnail" style="width:100%;">`;
|
||||
timeOut = formatTime(data.time);
|
||||
$("#totals-out").html(parseInt($("#totals-out").html()) + 1);
|
||||
}
|
||||
var driver = data.vehicleInfo.driver.split("/");
|
||||
var telephone = data.vehicleInfo.telephone.split("/");
|
||||
var cmt = data.vehicleInfo.indentity_card.split("/");
|
||||
var html = `<tr id="logs-` + data.id + `">
|
||||
<td>` + data.vehicleInfo.plate + `</td>
|
||||
<td>` + data.vehicleInfo.type + `</td>
|
||||
<td>` + data.vehicleInfo.company + `</td>
|
||||
<td>` + driver.join("<br>") + `</td>
|
||||
<td>` + telephone.join("<br>") + `</td>
|
||||
<td>` + cmt.join("<br>") + `</td>
|
||||
<td>
|
||||
<div style='cursor:pointer;' onclick='openForm(this, "factory");' data-id='` + data.id + `' data-text=''>
|
||||
<i class='text-red'>không có</i>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div style='cursor:pointer;' onclick='openForm(this, "seal_no");' data-id='` + data.id + `' data-text=''>
|
||||
<i class='text-red'>không có</i>
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-center">` + imageIn + `</td>
|
||||
<td class="text-center">` + timeIn + `</td>
|
||||
<td class="text-center">` + imageOut + `</td>
|
||||
<td class="text-center">` + timeOut + `</td>
|
||||
<td>
|
||||
<div style='cursor:pointer;' onclick='openForm(this, "note");' data-id='` + data.id + `' data-text=''>
|
||||
<i class='text-red'>không có</i>
|
||||
</div>
|
||||
</td>
|
||||
</tr>`;
|
||||
$("#logs-" + data.id).remove();
|
||||
$("#logs-lists").prepend(html);
|
||||
}
|
|
@ -1,8 +1,56 @@
|
|||
$(function () {
|
||||
common.dateTimePicker("from");
|
||||
common.dateTimePicker("to");
|
||||
$('[data-toggle="popover-hover"]').popover({
|
||||
html: true,
|
||||
trigger: 'hover',
|
||||
placement: 'left',
|
||||
container: 'body',
|
||||
content: function () {
|
||||
return '<img src="' + $(this).data('img') + '" style="max-width:500px;" />';
|
||||
}
|
||||
});
|
||||
// setTimeout(function () {
|
||||
// window.location.reload(true);
|
||||
// }, 30000);
|
||||
});
|
||||
|
||||
function resizeImage(e) {
|
||||
var size = $(e).attr("data-size");
|
||||
if (size === "min") {
|
||||
$(e).attr("style", "width:200px;cursor:pointer;");
|
||||
$(e).attr("data-size", "max");
|
||||
}
|
||||
if (size === "max") {
|
||||
$(e).attr("style", "width:100px;cursor:pointer;");
|
||||
$(e).attr("data-size", "min");
|
||||
}
|
||||
}
|
||||
|
||||
function openForm(e, field) {
|
||||
var html = `<input type="text" class="form-control" value="` + $(e).data("text") + `" data-id="` + $(e).data("id") + `" data-field="` + field + `" onchange="_save(this);" autofocus>`;
|
||||
$(e).closest("td").html(html);
|
||||
}
|
||||
|
||||
function _save(e) {
|
||||
$.ajax({
|
||||
url: $("input[name='saveUrl']").val(),
|
||||
type: 'POST',
|
||||
data: {
|
||||
id: $(e).data("id"),
|
||||
field: $(e).data("field"),
|
||||
value: $(e).val()
|
||||
},
|
||||
success: function (data) {
|
||||
$(e).closest("td").html(data);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
common.ajaxError();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function search(e) {
|
||||
window.location = $(e).attr("data-href") + "?from=" + $("input[name='FromTime']").val() + "&to=" + $("input[name='ToTime']").val();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user