update biface local
This commit is contained in:
parent
73b44eb2af
commit
efb4113001
23
assets/CaptureLogsAsset.php
Normal file
23
assets/CaptureLogsAsset.php
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace app\assets;
|
||||
|
||||
use yii\web\AssetBundle;
|
||||
|
||||
class CaptureLogsAsset extends AssetBundle {
|
||||
|
||||
public $basePath = '@webroot';
|
||||
public $baseUrl = '@web';
|
||||
public $css = [
|
||||
];
|
||||
public $js = [
|
||||
'js/capture-logs.js'
|
||||
];
|
||||
public $depends = [
|
||||
'yii\web\YiiAsset',
|
||||
'app\assets\AppAsset',
|
||||
'yii\jui\JuiAsset',
|
||||
'yii\bootstrap\BootstrapAsset',
|
||||
];
|
||||
|
||||
}
|
|
@ -5,6 +5,8 @@ namespace app\controllers;
|
|||
use Yii;
|
||||
use yii\web\Controller;
|
||||
use yii\filters\VerbFilter;
|
||||
use yii\helpers\FileHelper;
|
||||
use app\models\CaptureLogs;
|
||||
|
||||
/**
|
||||
* CardController implements the CRUD actions for Card model.
|
||||
|
@ -51,4 +53,37 @@ class ApiController extends Controller {
|
|||
}
|
||||
}
|
||||
|
||||
public function actionGetLogs() {
|
||||
if (Yii::$app->request->post()) {
|
||||
$post = Yii::$app->request->bodyParams;
|
||||
$time = date_format(date_create_from_format('Y-m-d H:i:s', $post['time']), 'U');
|
||||
$key = $this->generateRandomString();
|
||||
$RootFolder = Yii::getAlias('@webroot') . "/data/uploads";
|
||||
$targetPath = $RootFolder . "/face";
|
||||
$fileName = "face_" . $key . "_" . $time . ".png";
|
||||
FileHelper::createDirectory($targetPath, 0777);
|
||||
file_put_contents($targetPath . "/" . $fileName, base64_decode($post['image']));
|
||||
|
||||
if ($post["id"] == 0) {
|
||||
$model = new CaptureLogs();
|
||||
$model->create([
|
||||
"Time" => $time,
|
||||
"Image" => $fileName
|
||||
]);
|
||||
}
|
||||
Yii::$app->response->format = "json";
|
||||
return ["status" => "success"];
|
||||
}
|
||||
}
|
||||
|
||||
public function generateRandomString($length = 10) {
|
||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$charactersLength = strlen($characters);
|
||||
$randomString = '';
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
||||
}
|
||||
return $randomString;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,21 +6,14 @@ use Yii;
|
|||
use app\models\CaptureLogs;
|
||||
use app\models\CaptureLogsSearch;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
use yii\helpers\Url;
|
||||
|
||||
/**
|
||||
* ScriptController implements the CRUD actions for Script model.
|
||||
* CaptureLogsController implements the CRUD actions for CaptureLogs model.
|
||||
*/
|
||||
class CaptureLogsController extends Controller {
|
||||
|
||||
public function init() {
|
||||
parent::init();
|
||||
if (Yii::$app->user->isGuest) {
|
||||
return $this->redirect(['/site/login']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -35,20 +28,71 @@ class CaptureLogsController extends Controller {
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all Script models.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionIndex() {
|
||||
$this->view->title = "Ảnh mẫu";
|
||||
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.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -170,7 +170,7 @@ class ConfigController extends Controller {
|
|||
]
|
||||
];
|
||||
$ip = "192.168.0.42";
|
||||
$tempConfig = json_decode(file_get_contents("http://localhost:4004/ReadAPIConfig", false, stream_context_create($options)), true);
|
||||
$tempConfig = json_decode(file_get_contents("http://192.168.1.241:4004/ReadAPIConfig", false, stream_context_create($options)), true);
|
||||
if ($tempConfig['status']) {
|
||||
$t = json_decode($tempConfig['data'], true);
|
||||
$temp = explode("/", $t['url']);
|
||||
|
|
93
controllers/ListManagementController.php
Normal file
93
controllers/ListManagementController.php
Normal file
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
|
||||
namespace app\controllers;
|
||||
|
||||
use Yii;
|
||||
use app\models\ListManagement;
|
||||
use app\models\ListManagementSearch;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
|
||||
/**
|
||||
* ListMamagementController implements the CRUD actions for ListMamagement model.
|
||||
*/
|
||||
class ListManagementController 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 = "List management";
|
||||
$searchModel = new ListManagementSearch();
|
||||
$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,
|
||||
'f' => $f,
|
||||
't' => $t,
|
||||
'typeArray' => ListManagement::$typeArray
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionView($id) {
|
||||
return $this->render('view', [
|
||||
'model' => $this->findModel($id),
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionCreate() {
|
||||
$model = new ListManagement();
|
||||
if (Yii::$app->request->post()) {
|
||||
$data = Yii::$app->request->post();
|
||||
$data['image'] = \app\models\CaptureLogs::findOne($data['id'])->image;
|
||||
return $model->create($data);
|
||||
}
|
||||
}
|
||||
|
||||
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 = ListManagement::findOne($id)) !== null) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
|
||||
}
|
|
@ -5,7 +5,6 @@ namespace app\helpers;
|
|||
use Yii;
|
||||
use yii\helpers\Html;
|
||||
use yii\helpers\Url;
|
||||
use app\models\common;
|
||||
|
||||
class CaptureLogsGrid {
|
||||
|
||||
|
@ -29,4 +28,38 @@ class CaptureLogsGrid {
|
|||
return "{update} {delete}";
|
||||
}
|
||||
|
||||
public static function time() {
|
||||
return function($model) {
|
||||
return date("H:i:s d/m/Y", $model->time);
|
||||
};
|
||||
}
|
||||
|
||||
public static function image() {
|
||||
return function($model) {
|
||||
return Html::img("/BiFace/data/uploads/face/" . $model->image, [
|
||||
"class" => "img-thumbnail",
|
||||
"style" => "width: 150px;height:150px;"
|
||||
]);
|
||||
};
|
||||
}
|
||||
|
||||
public static function status($statusArray) {
|
||||
return function($model) use ($statusArray) {
|
||||
return $statusArray[$model->status];
|
||||
};
|
||||
}
|
||||
|
||||
public static function rows() {
|
||||
return function($model, $index, $widget, $grid) {
|
||||
return [
|
||||
"ondblclick" => "_form(this);",
|
||||
"style" => "cursor: pointer;",
|
||||
"data" => [
|
||||
"id" => $model->id,
|
||||
"img" => "/BiFace/data/uploads/face/" . $model->image
|
||||
]
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
71
helpers/ListManagementGrid.php
Normal file
71
helpers/ListManagementGrid.php
Normal file
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
namespace app\helpers;
|
||||
|
||||
use Yii;
|
||||
use yii\helpers\Html;
|
||||
use yii\helpers\Url;
|
||||
|
||||
class ListManagementGrid {
|
||||
|
||||
static $path = "";
|
||||
|
||||
public static function path() {
|
||||
return self::$path;
|
||||
}
|
||||
|
||||
public static function engineNameFunc() {
|
||||
return function ($data) {
|
||||
return $data->app->app_name;
|
||||
};
|
||||
}
|
||||
|
||||
public static function getLayout() {
|
||||
return "{items}<div class='row'><div class='col-md-4'>{summary}</div><div class='col-md-8 text-right'>{pager}</div></div>";
|
||||
}
|
||||
|
||||
public static function actionTemplate() {
|
||||
return "{update} {delete}";
|
||||
}
|
||||
|
||||
public static function time() {
|
||||
return function($model) {
|
||||
return date("H:i:s d/m/Y", $model->time);
|
||||
};
|
||||
}
|
||||
|
||||
public static function birthday() {
|
||||
return function($model) {
|
||||
return date("d/m/Y", $model->birthday);
|
||||
};
|
||||
}
|
||||
|
||||
public static function image() {
|
||||
return function($model) {
|
||||
return Html::img("/BiFace/data/uploads/face/" . $model->image, [
|
||||
"class" => "img-thumbnail",
|
||||
"style" => "width: 150px;height:150px;"
|
||||
]);
|
||||
};
|
||||
}
|
||||
|
||||
public static function type($typeArray) {
|
||||
return function($model) use ($typeArray) {
|
||||
return $typeArray[$model->type];
|
||||
};
|
||||
}
|
||||
|
||||
public static function rows() {
|
||||
return function($model, $index, $widget, $grid) {
|
||||
return [
|
||||
"ondblclick" => "_form(this);",
|
||||
"style" => "cursor: pointer;",
|
||||
"data" => [
|
||||
"id" => $model->id,
|
||||
"img" => "/BiFace/data/uploads/face/" . $model->image
|
||||
]
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
}
|
|
@ -7,44 +7,64 @@ use Yii;
|
|||
/**
|
||||
* This is the model class for table "capture_logs".
|
||||
*
|
||||
* @property int $ID
|
||||
* @property int $Time
|
||||
* @property string $Image
|
||||
* @property int $Status
|
||||
* @property string $Remark
|
||||
* @property int $id
|
||||
* @property int $time
|
||||
* @property string $image
|
||||
* @property int $status
|
||||
* @property string $remark
|
||||
*/
|
||||
class CaptureLogs extends \yii\db\ActiveRecord
|
||||
{
|
||||
class CaptureLogs extends \yii\db\ActiveRecord {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
public static function tableName() {
|
||||
return 'capture_logs';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
public function rules() {
|
||||
return [
|
||||
[['Time', 'Status'], 'integer'],
|
||||
[['Image', 'Remark'], 'string'],
|
||||
[['time', 'status'], 'integer'],
|
||||
[['image', 'remark'], 'string'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
public function attributeLabels() {
|
||||
return [
|
||||
'ID' => 'ID',
|
||||
'Time' => 'Time',
|
||||
'Image' => 'Image',
|
||||
'Status' => 'Status',
|
||||
'Remark' => 'Remark',
|
||||
'id' => 'ID',
|
||||
'time' => 'Time',
|
||||
'image' => 'Image',
|
||||
'status' => 'Status',
|
||||
'remark' => 'Remark',
|
||||
];
|
||||
}
|
||||
|
||||
public function create($data) {
|
||||
$r = $this->load([
|
||||
'time' => $data['Time'],
|
||||
'image' => $data["Image"],
|
||||
'status' => 0,
|
||||
'remark' => ''
|
||||
], '');
|
||||
if ($r) {
|
||||
try {
|
||||
$this->save();
|
||||
return $this->id;
|
||||
} catch (\Exception $ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static $statusArray = [
|
||||
0 => "Unknown",
|
||||
1 => "List management"
|
||||
];
|
||||
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@ class CaptureLogsSearch extends CaptureLogs
|
|||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['ID', 'Time', 'Status'], 'integer'],
|
||||
[['Image', 'Remark'], 'safe'],
|
||||
[['id', 'time', 'status'], 'integer'],
|
||||
[['image', 'remark'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -59,13 +59,13 @@ class CaptureLogsSearch extends CaptureLogs
|
|||
|
||||
// grid filtering conditions
|
||||
$query->andFilterWhere([
|
||||
'ID' => $this->ID,
|
||||
'Time' => $this->Time,
|
||||
'Status' => $this->Status,
|
||||
'id' => $this->id,
|
||||
'time' => $this->time,
|
||||
'status' => $this->status,
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['like', 'Image', $this->Image])
|
||||
->andFilterWhere(['like', 'Remark', $this->Remark]);
|
||||
$query->andFilterWhere(['like', 'image', $this->image])
|
||||
->andFilterWhere(['like', 'remark', $this->remark]);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
|
|
82
models/ListManagement.php
Normal file
82
models/ListManagement.php
Normal file
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "list_management".
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $type
|
||||
* @property string $name
|
||||
* @property string $image
|
||||
* @property string $gender
|
||||
* @property int $birthday
|
||||
* @property string $telephone
|
||||
* @property string $address
|
||||
* @property int $time
|
||||
*/
|
||||
class ListManagement extends \yii\db\ActiveRecord {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName() {
|
||||
return 'list_management';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules() {
|
||||
return [
|
||||
[['type', 'name', 'gender', 'telephone', 'address', 'image'], 'string'],
|
||||
[['birthday', 'time'], 'integer'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels() {
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'type' => 'Type',
|
||||
'name' => 'Name',
|
||||
'image' => 'Registration Image',
|
||||
'gender' => 'Gender',
|
||||
'birthday' => 'Birthday',
|
||||
'telephone' => 'Telephone',
|
||||
'address' => 'Address',
|
||||
'time' => 'Registration time'
|
||||
];
|
||||
}
|
||||
|
||||
public function create($data) {
|
||||
$r = $this->load([
|
||||
'type' => $data['type'],
|
||||
'name' => $data['name'],
|
||||
'image' => $data['image'],
|
||||
'gender' => $data['gender'],
|
||||
'birthday' => $data['birthday'] === "" ? 0 : date_format(date_create_from_format('d/m/Y', $data['birthday']), 'U'),
|
||||
'telephone' => $data['telephone'],
|
||||
'address' => $data['address'],
|
||||
'time' => time()
|
||||
], '');
|
||||
if ($r) {
|
||||
try {
|
||||
$this->save();
|
||||
return $this->id;
|
||||
} catch (\Exception $ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static $typeArray = [
|
||||
"wl" => "Whitelist",
|
||||
"bl" => "Blacklist"
|
||||
];
|
||||
|
||||
}
|
72
models/ListManagementSearch.php
Normal file
72
models/ListManagementSearch.php
Normal file
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use app\models\ListManagement;
|
||||
|
||||
/**
|
||||
* ListMamagementSearch represents the model behind the search form of `app\models\ListManagement`.
|
||||
*/
|
||||
class ListManagementSearch extends ListManagement {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules() {
|
||||
return [
|
||||
[['id', 'birthday'], 'integer'],
|
||||
[['type', 'name', 'gender', 'telephone', 'address'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function scenarios() {
|
||||
// bypass scenarios() implementation in the parent class
|
||||
return Model::scenarios();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
public function search($params) {
|
||||
$query = ListManagement::find();
|
||||
|
||||
// add conditions that should always apply here
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
]);
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
// grid filtering conditions
|
||||
$query->andFilterWhere([
|
||||
'id' => $this->id,
|
||||
'birthday' => $this->birthday,
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['like', 'type', $this->type])
|
||||
->andFilterWhere(['like', 'name', $this->name])
|
||||
->andFilterWhere(['like', 'gender', $this->gender])
|
||||
->andFilterWhere(['like', 'telephone', $this->telephone])
|
||||
->andFilterWhere(['like', 'address', $this->address]);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
copy.src.files=false
|
||||
copy.src.on.open=false
|
||||
copy.src.target=
|
||||
remote.connection=bf_local-799e1d
|
||||
remote.connection=missing-config
|
||||
remote.directory=/BiFace_Server_Lite
|
||||
remote.upload=ON_SAVE
|
||||
run.as=REMOTE
|
||||
run.as=LOCAL
|
||||
url=http://localhost/
|
||||
|
|
|
@ -51,6 +51,16 @@ use yii\widgets\ActiveForm;
|
|||
<i class="fa fa-refresh"></i> Reset thiết bị
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?php echo yii\helpers\Url::to(['/list-management']); ?>">
|
||||
<i class="fa fa-list"></i> List Management
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?php echo yii\helpers\Url::to(['/capture-logs']); ?>">
|
||||
<i class="fa fa-camera"></i> Capture log
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="navbar-custom-menu">
|
||||
|
|
|
@ -1,22 +1,142 @@
|
|||
{extends file=$smarty.current_dir|cat:'/../extends.tpl'}
|
||||
{use class="yii\helpers\Url"}
|
||||
{use class="yii\grid\GridView"}
|
||||
{use class="app\assets\CaptureLogsAsset"}
|
||||
{CaptureLogsAsset::register($this)|void}
|
||||
{block name='content'}
|
||||
|
||||
<style>
|
||||
.row{
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
input{
|
||||
width: 100%;
|
||||
}
|
||||
.table-striped > tbody > tr:nth-of-type(odd){
|
||||
background-color: rgb(210, 210, 210);
|
||||
}
|
||||
</style>
|
||||
<div class="row">
|
||||
<div class="col-md-10" style="max-height: 850px;overflow-y: auto;">
|
||||
{GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'filterModel' => $searchModel,
|
||||
'layout'=> \app\helpers\CaptureLogsGrid::getLayout(),
|
||||
'tableOptions' => [
|
||||
'class' => 'table table-striped table-bordered',
|
||||
'style' => 'background:#fff;min-width:700px;'
|
||||
],
|
||||
'rowOptions' => \app\helpers\CaptureLogsGrid::rows(),
|
||||
'columns' => [
|
||||
['class' => 'yii\grid\SerialColumn'],
|
||||
'Time',
|
||||
'Image',
|
||||
'Status',
|
||||
'Remark'
|
||||
[
|
||||
'class' => 'yii\grid\SerialColumn',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center']
|
||||
],
|
||||
[
|
||||
'attribute' => 'time',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center'],
|
||||
'value' => \app\helpers\CaptureLogsGrid::time()
|
||||
],
|
||||
[
|
||||
'attribute' => 'image',
|
||||
'format' => "raw",
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center'],
|
||||
'value' => \app\helpers\CaptureLogsGrid::image()
|
||||
],
|
||||
[
|
||||
'attribute' => 'status',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center'],
|
||||
'value' => \app\helpers\CaptureLogsGrid::status($statusArray)
|
||||
],
|
||||
[
|
||||
'attribute' => 'remark',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center']
|
||||
]
|
||||
]
|
||||
])}
|
||||
</div>
|
||||
<div class="col-md-2" style="padding-right: 30px;">
|
||||
<h4>Tìm kiếm dữ liệu</h4>
|
||||
<div class="form-group">
|
||||
<label class="control-label">Từ</label>
|
||||
<input type="text" class="form-control datepicker" value="{$f|date_format:"H:i d/m/Y"}" name="From">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">Đến</label>
|
||||
<input type="text" class="form-control datepicker" value="{$t|date_format:"H:i d/m/Y"}" name="To">
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<button class="btn btn-info" onclick="_search(this);" data-href="{Url::to(['/capture-logs'])}">
|
||||
<i class="fa fa-search"></i> Tìm kiếm
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="width: 500px;position: absolute;right:0;top: 250px;" id='form' class="hidden">
|
||||
<div class="panel panel-info">
|
||||
<div class="panel-heading text-bold">
|
||||
List management
|
||||
<i class="fa fa-remove pull-right" style="cursor: pointer;" onclick="_close();"></i>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-center">
|
||||
<img src="" class="img-thumbnail" id="FaceImage" style="width: 150px;height: 150px;">
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-right">Type</div>
|
||||
<div class="col-md-8">
|
||||
<select style="width: 100%;height: 26px;" name="Type">
|
||||
<option value="wl">White list</option>
|
||||
<option value="bl">Black list</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-right">Name</div>
|
||||
<div class="col-md-8">
|
||||
<input type="text" name="Name">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-right">Gender</div>
|
||||
<div class="col-md-8">
|
||||
<select style="width: 100%;height: 26px;" name="Gender">
|
||||
<option value="Male">Male</option>
|
||||
<option value="Female">Female</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-right">Birthday</div>
|
||||
<div class="col-md-8">
|
||||
<input type="text" name="Birthday" id="birthday">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-right">Telephone</div>
|
||||
<div class="col-md-8">
|
||||
<input type="text" name="Telephone">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-right">Address</div>
|
||||
<div class="col-md-8">
|
||||
<input type="text" name="Address">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<input type="hidden" value="" name="CaptureLogsID">
|
||||
<button onclick="_save(this);" data-href='{Url::to(["/list-management/create"])}'>Save</button>
|
||||
<button onclick="_close();">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/block}
|
163
views/list-management/index.tpl
Normal file
163
views/list-management/index.tpl
Normal file
|
@ -0,0 +1,163 @@
|
|||
{extends file=$smarty.current_dir|cat:'/../extends.tpl'}
|
||||
{use class="yii\helpers\Url"}
|
||||
{use class="yii\grid\GridView"}
|
||||
{*use class="app\assets\CaptureLogsAsset"}
|
||||
{CaptureLogsAsset::register($this)|void*}
|
||||
{block name='content'}
|
||||
<style>
|
||||
.row{
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
input{
|
||||
width: 100%;
|
||||
}
|
||||
.table-striped > tbody > tr:nth-of-type(odd){
|
||||
background-color: rgb(210, 210, 210);
|
||||
}
|
||||
</style>
|
||||
<div class="row">
|
||||
<div class="col-md-10" style="max-height: 850px;overflow-y: auto;">
|
||||
{GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'layout'=> \app\helpers\ListManagementGrid::getLayout(),
|
||||
'tableOptions' => [
|
||||
'class' => 'table table-striped table-bordered',
|
||||
'style' => 'background:#fff;min-width:700px;'
|
||||
],
|
||||
'rowOptions' => \app\helpers\ListManagementGrid::rows(),
|
||||
'columns' => [
|
||||
[
|
||||
'class' => 'yii\grid\SerialColumn',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center']
|
||||
],
|
||||
[
|
||||
'attribute' => 'type',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center'],
|
||||
'value' => \app\helpers\ListManagementGrid::type($typeArray)
|
||||
],
|
||||
[
|
||||
'attribute' => 'name',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center']
|
||||
],
|
||||
[
|
||||
'attribute' => 'gender',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center']
|
||||
],
|
||||
[
|
||||
'attribute' => 'image',
|
||||
'format' => "raw",
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center'],
|
||||
'value' => \app\helpers\ListManagementGrid::image()
|
||||
],
|
||||
[
|
||||
'attribute' => 'time',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center'],
|
||||
'value' => \app\helpers\ListManagementGrid::time()
|
||||
],
|
||||
[
|
||||
'attribute' => 'birthday',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center'],
|
||||
'value' => \app\helpers\ListManagementGrid::birthday()
|
||||
],
|
||||
[
|
||||
'attribute' => 'telephone',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center']
|
||||
],
|
||||
[
|
||||
'attribute' => 'address',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center']
|
||||
]
|
||||
]
|
||||
])}
|
||||
</div>
|
||||
<div class="col-md-2" style="padding-right: 30px;">
|
||||
<h4>Tìm kiếm dữ liệu</h4>
|
||||
<div class="form-group">
|
||||
<label class="control-label">Từ</label>
|
||||
<input type="text" class="form-control datepicker" value="{$f|date_format:"H:i d/m/Y"}" name="From">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">Đến</label>
|
||||
<input type="text" class="form-control datepicker" value="{$t|date_format:"H:i d/m/Y"}" name="To">
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<button class="btn btn-info" onclick="_search(this);" data-href="{Url::to(['/capture-logs'])}">
|
||||
<i class="fa fa-search"></i> Tìm kiếm
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="width: 500px;position: absolute;right:0;top: 250px;" id='form' class="hidden">
|
||||
<div class="panel panel-info">
|
||||
<div class="panel-heading text-bold">
|
||||
List management
|
||||
<i class="fa fa-remove pull-right" style="cursor: pointer;" onclick="_close();"></i>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-center">
|
||||
<img src="" class="img-thumbnail" id="FaceImage" style="width: 150px;height: 150px;">
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-right">Type</div>
|
||||
<div class="col-md-8">
|
||||
<select style="width: 100%;height: 26px;" name="Type">
|
||||
<option value="wl">White list</option>
|
||||
<option value="bl">Black list</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-right">Name</div>
|
||||
<div class="col-md-8">
|
||||
<input type="text" name="Name">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-right">Gender</div>
|
||||
<div class="col-md-8">
|
||||
<select style="width: 100%;height: 26px;" name="Gender">
|
||||
<option value="Male">Male</option>
|
||||
<option value="Female">Female</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-right">Birthday</div>
|
||||
<div class="col-md-8">
|
||||
<input type="text" name="Birthday" id="birthday">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-right">Telephone</div>
|
||||
<div class="col-md-8">
|
||||
<input type="text" name="Telephone">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-right">Address</div>
|
||||
<div class="col-md-8">
|
||||
<input type="text" name="Address">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<input type="hidden" value="" name="CaptureLogsID">
|
||||
<button onclick="_save(this);" data-href='{Url::to(["/list-management/create"])}'>Save</button>
|
||||
<button onclick="_close();">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/block}
|
|
@ -673,4 +673,8 @@ body::-webkit-scrollbar {
|
|||
}
|
||||
.font-grey-cascade {
|
||||
color: #95A5A6!important;
|
||||
}
|
||||
|
||||
.skin-blue .main-header .navbar .nav>li>a{
|
||||
font-size:23px !important;
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
// comment out the following two lines when deployed to production
|
||||
//defined('YII_DEBUG') or define('YII_DEBUG', true);
|
||||
//defined('YII_ENV') or define('YII_ENV', 'dev');
|
||||
defined('YII_DEBUG') or define('YII_DEBUG', true);
|
||||
defined('YII_ENV') or define('YII_ENV', 'dev');
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
require __DIR__ . '/../vendor/yiisoft/yii2/Yii.php';
|
||||
|
|
48
web/js/capture-logs.js
Normal file
48
web/js/capture-logs.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
$(function () {
|
||||
common.dateTimePickerByClass("datepicker", "HH:mm DD/MM/YYYY");
|
||||
common.dateTimePickerDay("birthday");
|
||||
});
|
||||
|
||||
function _search(e) {
|
||||
window.location = $(e).attr("data-href") + "?from=" + $("input[name='From']").val() + "&to=" + $("input[name='To']").val();
|
||||
}
|
||||
|
||||
function _form(e) {
|
||||
$("#form").removeClass("hidden");
|
||||
$("input[name='CaptureLogsID']").val($(e).attr("data-id"));
|
||||
$("#FaceImage").attr("src", $(e).attr("data-img"));
|
||||
}
|
||||
|
||||
function _close() {
|
||||
$("#form").addClass("hidden");
|
||||
}
|
||||
|
||||
function _save(e) {
|
||||
var name = $("input[name='Name']").val();
|
||||
if (name === "") {
|
||||
alert("Hãy nhập tên!");
|
||||
return;
|
||||
}
|
||||
common.modalBlock(true);
|
||||
$.ajax({
|
||||
url: $(e).attr("data-href"),
|
||||
type: 'POST',
|
||||
data: {
|
||||
name: name,
|
||||
type: $("select[name='Type']").val(),
|
||||
gender: $("select[name='Gender']").val(),
|
||||
birthday: $("input[name='Birthday']").val(),
|
||||
telephone: $("input[name='Telephone']").val(),
|
||||
address: $("input[name='Address']").val(),
|
||||
id: $("input[name='CaptureLogsID']").val()
|
||||
},
|
||||
success: function (data) {
|
||||
alert("Đã thêm dữ liệu thành công!");
|
||||
window.location.reload(true);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
common.ajaxError();
|
||||
}
|
||||
});
|
||||
}
|
|
@ -241,6 +241,14 @@ common.dateTimePickerHour = function (id) {
|
|||
format: 'HH:mm'
|
||||
});
|
||||
};
|
||||
common.dateTimePickerByClass = function (cls, format) {
|
||||
$('.' + cls).datetimepicker({
|
||||
locale: 'vi',
|
||||
ignoreReadonly: true,
|
||||
sideBySide: true,
|
||||
format: format
|
||||
});
|
||||
};
|
||||
common.checkAll = function (id, cls) {
|
||||
$('#' + id).on('ifChecked', function (event) {
|
||||
$('.' + cls).iCheck('check');
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user