update CRUD list-management
This commit is contained in:
parent
efb4113001
commit
6030ccd0a5
23
assets/ListManagementAsset.php
Normal file
23
assets/ListManagementAsset.php
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace app\assets;
|
||||
|
||||
use yii\web\AssetBundle;
|
||||
|
||||
class ListManagementAsset extends AssetBundle {
|
||||
|
||||
public $basePath = '@webroot';
|
||||
public $baseUrl = '@web';
|
||||
public $css = [
|
||||
];
|
||||
public $js = [
|
||||
'js/list-management.js'
|
||||
];
|
||||
public $depends = [
|
||||
'yii\web\YiiAsset',
|
||||
'app\assets\AppAsset',
|
||||
'yii\jui\JuiAsset',
|
||||
'yii\bootstrap\BootstrapAsset',
|
||||
];
|
||||
|
||||
}
|
|
@ -7,6 +7,7 @@ use yii\web\Controller;
|
|||
use yii\filters\VerbFilter;
|
||||
use yii\helpers\FileHelper;
|
||||
use app\models\CaptureLogs;
|
||||
use app\models\ListManagement;
|
||||
|
||||
/**
|
||||
* CardController implements the CRUD actions for Card model.
|
||||
|
@ -76,6 +77,25 @@ class ApiController extends Controller {
|
|||
}
|
||||
}
|
||||
|
||||
public function actionGetAllFeatures() {
|
||||
$listManagement = ListManagement::find()->all();
|
||||
$allFeatures = [];
|
||||
foreach ($listManagement as $key => $value) {
|
||||
$features = json_decode($value->image, true);
|
||||
$f = [];
|
||||
foreach ($features as $k => $v) {
|
||||
$f[] = $v['features'];
|
||||
}
|
||||
$allFeatures[] = [
|
||||
"id" => $value->id,
|
||||
"name" => $value->name,
|
||||
"features" => $f
|
||||
];
|
||||
}
|
||||
Yii::$app->response->format = "json";
|
||||
return $allFeatures;
|
||||
}
|
||||
|
||||
public function generateRandomString($length = 10) {
|
||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$charactersLength = strlen($characters);
|
||||
|
|
|
@ -8,6 +8,8 @@ use app\models\ListManagementSearch;
|
|||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
use app\models\CaptureLogs;
|
||||
use app\models\common;
|
||||
|
||||
/**
|
||||
* ListMamagementController implements the CRUD actions for ListMamagement model.
|
||||
|
@ -28,7 +30,7 @@ class ListManagementController extends Controller {
|
|||
];
|
||||
}
|
||||
|
||||
public function actionIndex($from = "", $to = "") {
|
||||
public function actionIndex($from = "", $to = "", $name = "", $type = "all", $gender = "all") {
|
||||
$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 !== "") {
|
||||
|
@ -39,13 +41,20 @@ class ListManagementController extends Controller {
|
|||
$searchModel = new ListManagementSearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
$dataProvider->query->andWhere(["BETWEEN", "time", $f, $t]);
|
||||
if ($name !== "")
|
||||
$dataProvider->query->andWhere(["LIKE", "name", $name]);
|
||||
if ($type !== "all")
|
||||
$dataProvider->query->andWhere(["type" => $type]);
|
||||
if ($gender !== "all")
|
||||
$dataProvider->query->andWhere(["gender" => $gender]);
|
||||
$dataProvider->query->orderBy(["time" => SORT_DESC]);
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
'f' => $f,
|
||||
't' => $t,
|
||||
'typeArray' => ListManagement::$typeArray
|
||||
'typeArray' => ListManagement::$typeArray,
|
||||
'genderArray' => ListManagement::$genderArray
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -57,29 +66,95 @@ class ListManagementController extends Controller {
|
|||
|
||||
public function actionCreate() {
|
||||
$model = new ListManagement();
|
||||
Yii::$app->response->format = "json";
|
||||
if (Yii::$app->request->post()) {
|
||||
$data = Yii::$app->request->post();
|
||||
$data['image'] = \app\models\CaptureLogs::findOne($data['id'])->image;
|
||||
return $model->create($data);
|
||||
$listManagement = ListManagement::findOne(['name' => $data['name']]);
|
||||
$url = CaptureLogs::findOne($data['id'])->image;
|
||||
if ($listManagement) {
|
||||
$images = json_decode($listManagement->image, true);
|
||||
$add = true;
|
||||
foreach ($images as $key => $value) {
|
||||
if ($value['url'] === $url)
|
||||
$add = false;
|
||||
}
|
||||
if ($add) {
|
||||
$features = json_decode(common::requestToEngine("/get-feature", [
|
||||
"image_paths" => [
|
||||
["url" => "/home/sonhh/Pictures/10929_HongBI.jpg", "type" => "raw"]
|
||||
]
|
||||
]), true);
|
||||
$images[] = ["url" => $url, "features" => $features['results'][0]['feature']];
|
||||
$listManagement->image = json_encode($images);
|
||||
$listManagement->time = time();
|
||||
return $listManagement->save();
|
||||
}
|
||||
} else {
|
||||
$features = json_decode(common::requestToEngine("/get-feature", [
|
||||
"image_paths" => [
|
||||
["url" => "sex.png", "type" => "raw"]
|
||||
]
|
||||
]), true);
|
||||
$data['image'] = json_encode([
|
||||
["url" => $url, "features" => $features['results'][0]['feature']]
|
||||
]);
|
||||
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]);
|
||||
public function actionFormUpdate() {
|
||||
if (Yii::$app->request->post()) {
|
||||
$data = Yii::$app->request->post();
|
||||
$ListManagement = $this->findModel($data['id']);
|
||||
$images = json_decode($ListManagement->image, true);
|
||||
Yii::$app->response->format = "json";
|
||||
return [
|
||||
"type" => $ListManagement->type,
|
||||
"name" => $ListManagement->name,
|
||||
"gender" => $ListManagement->gender,
|
||||
"birthday" => date("d/m/Y", $ListManagement->birthday),
|
||||
"telephone" => $ListManagement->telephone,
|
||||
"address" => $ListManagement->address,
|
||||
"image" => "/BiFace/data/uploads/face/" . $images[0]['url']
|
||||
];
|
||||
}
|
||||
|
||||
return $this->render('update', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionDelete($id) {
|
||||
$this->findModel($id)->delete();
|
||||
public function actionUpdate() {
|
||||
if (Yii::$app->request->post()) {
|
||||
$data = Yii::$app->request->post();
|
||||
$model = $this->findModel($data['id']);
|
||||
$model->type = $data['type'];
|
||||
$model->name = $data['name'];
|
||||
$model->gender = $data['gender'];
|
||||
$model->birthday = $data['birthday'] === "" ? 0 : date_format(date_create_from_format('d/m/Y', $data['birthday']), 'U');
|
||||
$model->telephone = $data['telephone'];
|
||||
$model->address = $data['address'];
|
||||
return $model->save();
|
||||
}
|
||||
}
|
||||
|
||||
return $this->redirect(['index']);
|
||||
public function actionDelete() {
|
||||
if (Yii::$app->request->post()) {
|
||||
$data = Yii::$app->request->post();
|
||||
return $this->findModel($data['id'])->delete();
|
||||
}
|
||||
}
|
||||
|
||||
public function actionDeleteFeature() {
|
||||
if (Yii::$app->request->post()) {
|
||||
$data = Yii::$app->request->post();
|
||||
$model = $this->findModel($data['id']);
|
||||
$images = json_decode($model->image, true);
|
||||
$features = [];
|
||||
foreach ($images as $key => $value) {
|
||||
if ($value['url'] !== $data['image'])
|
||||
$features[] = $value;
|
||||
}
|
||||
$model->image = json_encode($features);
|
||||
return $model->save();
|
||||
}
|
||||
}
|
||||
|
||||
protected function findModel($id) {
|
||||
|
@ -90,4 +165,11 @@ class ListManagementController extends Controller {
|
|||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
|
||||
public function actionBatchDelete() {
|
||||
if (Yii::$app->request->post()) {
|
||||
$data = Yii::$app->request->post();
|
||||
return ListManagement::deleteAll(["IN", "id", $data['lists']]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,10 +42,23 @@ class ListManagementGrid {
|
|||
|
||||
public static function image() {
|
||||
return function($model) {
|
||||
return Html::img("/BiFace/data/uploads/face/" . $model->image, [
|
||||
"class" => "img-thumbnail",
|
||||
"style" => "width: 150px;height:150px;"
|
||||
]);
|
||||
$images = json_decode($model->image, true);
|
||||
$return = [];
|
||||
foreach ($images as $key => $value) {
|
||||
$removeBtn = Html::button("<i class='fa fa-remove'></i>", [
|
||||
"class" => "btn btn-danger btn-xs",
|
||||
"style" => "position:absolute;top:0;right:0;visibility: hidden;",
|
||||
"onclick" => "_deleteFeature(this);",
|
||||
"data-img" => $value['url'],
|
||||
"data-id" => $model->id,
|
||||
"data-href" => Url::to(["/list-management/delete-feature"])
|
||||
]);
|
||||
$return[] = "<div class='feature-img'>" . Html::img("/BiFace/data/uploads/face/" . $value['url'], [
|
||||
"class" => "img-thumbnail",
|
||||
"style" => "width: 100px;height:100px;"
|
||||
]) . $removeBtn . "</div>";
|
||||
}
|
||||
return implode(" ", $return);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -58,11 +71,10 @@ class ListManagementGrid {
|
|||
public static function rows() {
|
||||
return function($model, $index, $widget, $grid) {
|
||||
return [
|
||||
"ondblclick" => "_form(this);",
|
||||
"ondblclick" => "_menu(this);",
|
||||
"style" => "cursor: pointer;",
|
||||
"data" => [
|
||||
"id" => $model->id,
|
||||
"img" => "/BiFace/data/uploads/face/" . $model->image
|
||||
"id" => $model->id
|
||||
]
|
||||
];
|
||||
};
|
||||
|
|
|
@ -78,5 +78,9 @@ class ListManagement extends \yii\db\ActiveRecord {
|
|||
"wl" => "Whitelist",
|
||||
"bl" => "Blacklist"
|
||||
];
|
||||
public static $genderArray = [
|
||||
"Male" => "Male",
|
||||
"Female" => "Female"
|
||||
];
|
||||
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ class common extends \yii\db\ActiveRecord {
|
|||
// $now = time();
|
||||
// $range = $now - $time;
|
||||
// if ($range > 60 * 60 * 12) {
|
||||
return date($format, $time);
|
||||
return date($format, $time);
|
||||
// } else {
|
||||
// return Yii::$app->formatter->asRelativeTime($time);
|
||||
// }
|
||||
|
@ -171,4 +171,14 @@ class common extends \yii\db\ActiveRecord {
|
|||
return $visible;
|
||||
}
|
||||
|
||||
public static function requestToEngine($path, $data) {
|
||||
return file_get_contents("http://192.168.2.158:2305" . $path, false, stream_context_create([
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
'method' => "POST",
|
||||
'content' => json_encode($data)
|
||||
]
|
||||
]));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
|
||||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
|
||||
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
||||
<group>
|
||||
<file>file:/E:/BiFace_Server_Lite/controllers/ConfigController.php</file>
|
||||
</group>
|
||||
<group/>
|
||||
</open-files>
|
||||
</project-private>
|
||||
|
|
|
@ -36,12 +36,12 @@ use yii\widgets\ActiveForm;
|
|||
<!-- Collect the nav links, forms, and other content for toggling -->
|
||||
<div class="collapse navbar-collapse pull-left" id="navbar-collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<li class="<?php if (Yii::$app->controller->id == "config") echo "active"; ?>">
|
||||
<a href="<?php echo yii\helpers\Url::to(['/config']); ?>">
|
||||
<i class="fa fa-cogs"></i> Cấu hình
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<li class="<?php if (Yii::$app->controller->id == "dashboard") echo "active"; ?>">
|
||||
<a href="<?php echo yii\helpers\Url::to(['/dashboard']); ?>">
|
||||
<i class="fa fa-database"></i> Dữ liệu
|
||||
</a>
|
||||
|
@ -51,12 +51,12 @@ use yii\widgets\ActiveForm;
|
|||
<i class="fa fa-refresh"></i> Reset thiết bị
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<li class="<?php if (Yii::$app->controller->id == "list-management") echo "active"; ?>">
|
||||
<a href="<?php echo yii\helpers\Url::to(['/list-management']); ?>">
|
||||
<i class="fa fa-list"></i> List Management
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<li class="<?php if (Yii::$app->controller->id == "capture-logs") echo "active"; ?>">
|
||||
<a href="<?php echo yii\helpers\Url::to(['/capture-logs']); ?>">
|
||||
<i class="fa fa-camera"></i> Capture log
|
||||
</a>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{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*}
|
||||
{use class="app\assets\ListManagementAsset"}
|
||||
{ListManagementAsset::register($this)|void}
|
||||
{block name='content'}
|
||||
<style>
|
||||
.row{
|
||||
|
@ -14,6 +14,17 @@
|
|||
.table-striped > tbody > tr:nth-of-type(odd){
|
||||
background-color: rgb(210, 210, 210);
|
||||
}
|
||||
.feature-img{
|
||||
display:inline-block;
|
||||
position: relative;
|
||||
}
|
||||
.feature-img:hover .btn{
|
||||
visibility: visible !important;
|
||||
}
|
||||
.table > tbody > tr.delete-choose > td{
|
||||
background-color: red;
|
||||
color: #fff;
|
||||
}
|
||||
</style>
|
||||
<div class="row">
|
||||
<div class="col-md-10" style="max-height: 850px;overflow-y: auto;">
|
||||
|
@ -27,7 +38,7 @@
|
|||
'rowOptions' => \app\helpers\ListManagementGrid::rows(),
|
||||
'columns' => [
|
||||
[
|
||||
'class' => 'yii\grid\SerialColumn',
|
||||
'attribute' => 'id',
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center']
|
||||
],
|
||||
|
@ -50,8 +61,6 @@
|
|||
[
|
||||
'attribute' => 'image',
|
||||
'format' => "raw",
|
||||
'contentOptions' => ['class' => 'text-center'],
|
||||
'headerOptions' => ['class' => 'text-center'],
|
||||
'value' => \app\helpers\ListManagementGrid::image()
|
||||
],
|
||||
[
|
||||
|
@ -89,11 +98,56 @@
|
|||
<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="form-group">
|
||||
<label class="control-label">Name</label>
|
||||
<input type="text" class="form-control" value="{Yii::$app->request->get("name")}" name="NameSearch">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">Type</label>
|
||||
<select class="form-control" name="TypeSearch">
|
||||
<option value="all">All</option>
|
||||
{html_options options=$typeArray selected=Yii::$app->request->get("type")}
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">Gender</label>
|
||||
<select class="form-control" name="GenderSearch">
|
||||
<option value="all">All</option>
|
||||
{html_options options=$genderArray selected=Yii::$app->request->get("gender")}
|
||||
</select>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<button class="btn btn-info" onclick="_search(this);" data-href="{Url::to(['/capture-logs'])}">
|
||||
<button class="btn btn-info" onclick="_search(this);" data-href="{Url::to(['/list-management'])}">
|
||||
<i class="fa fa-search"></i> Tìm kiếm
|
||||
</button>
|
||||
</div>
|
||||
<hr style="border-top: 1px solid #000;">
|
||||
<div>
|
||||
<input type="checkbox" name="BatchDelete" style="width: inherit;"> Xóa nhiều dữ liệu
|
||||
<br><br>
|
||||
<div class="hidden" id="delete-btn-group">
|
||||
<div class="text-center">
|
||||
<button onclick="checkAll(true);">Chọn toàn bộ trang</button>
|
||||
<button onclick="checkAll(false);">Bỏ chọn</button>
|
||||
</div>
|
||||
<br>
|
||||
<div class="text-center">
|
||||
<button class="btn btn-danger" onclick="batchDelete(this);" data-href="{Url::to(['/list-management/batch-delete'])}">Xác nhận xóa</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="width: 300px;position: absolute;" id="menu" class="hidden">
|
||||
<div class="panel panel-info">
|
||||
<div class="panel-heading text-bold">
|
||||
Operation menu
|
||||
<i class="fa fa-remove pull-right" style="cursor: pointer;" onclick="_closeMenu();"></i>
|
||||
</div>
|
||||
<div class="panel-body text-center">
|
||||
<button onclick="_formModified(this);" data-href='{Url::to(["/list-management/form-update"])}'>Modified list</button>
|
||||
<button onclick="_delete(this);" data-href="{Url::to(["/list-management/delete"])}">Delete list</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="width: 500px;position: absolute;right:0;top: 250px;" id='form' class="hidden">
|
||||
|
@ -112,8 +166,7 @@
|
|||
<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>
|
||||
{html_options options=$typeArray}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -127,8 +180,7 @@
|
|||
<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>
|
||||
{html_options options=$genderArray}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -153,8 +205,8 @@
|
|||
</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>
|
||||
<input type="hidden" value="" name="ListManagementID">
|
||||
<button onclick="_update(this);" data-href='{Url::to(["/list-management/update"])}'>Save</button>
|
||||
<button onclick="_close();">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
184
web/js/list-management.js
Normal file
184
web/js/list-management.js
Normal file
|
@ -0,0 +1,184 @@
|
|||
var x = 0, y = 0;
|
||||
$(function () {
|
||||
common.dateTimePickerByClass("datepicker", "HH:mm DD/MM/YYYY");
|
||||
common.dateTimePickerDay("birthday");
|
||||
$("tr").bind("click", function (event) {
|
||||
x = event.pageX;
|
||||
y = event.pageY;
|
||||
});
|
||||
$("input[name='BatchDelete']").change(function () {
|
||||
if (this.checked) {
|
||||
$("#delete-btn-group").removeClass("hidden");
|
||||
} else {
|
||||
$("tr").removeClass("delete-choose");
|
||||
$("#delete-btn-group").addClass("hidden");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function _search(e) {
|
||||
var location = $(e).attr("data-href") + "?from=" + $("input[name='From']").val() + "&to=" + $("input[name='To']").val();
|
||||
location = location + "&name=" + $("input[name='NameSearch']").val();
|
||||
location = location + "&type=" + $("select[name='TypeSearch']").val();
|
||||
location = location + "&gender=" + $("select[name='GenderSearch']").val();
|
||||
window.location = location;
|
||||
}
|
||||
|
||||
function _close() {
|
||||
$("#form").addClass("hidden");
|
||||
}
|
||||
|
||||
function _menu(e) {
|
||||
var isDelete = $("input[name='BatchDelete']").is(':checked');
|
||||
if (isDelete) {
|
||||
if ($(e).hasClass("delete-choose"))
|
||||
$(e).removeClass("delete-choose");
|
||||
else
|
||||
$(e).addClass("delete-choose");
|
||||
$("#menu").addClass("hidden");
|
||||
} else {
|
||||
$("input[name='ListManagementID']").val($(e).attr("data-id"));
|
||||
$("#menu").css({top: y, left: x}).removeClass("hidden");
|
||||
}
|
||||
}
|
||||
|
||||
function _closeMenu() {
|
||||
$("#menu").addClass("hidden");
|
||||
}
|
||||
|
||||
function _formModified(e) {
|
||||
_closeMenu();
|
||||
$("#form").removeClass("hidden");
|
||||
common.modalBlock(true);
|
||||
$.ajax({
|
||||
url: $(e).attr("data-href"),
|
||||
type: 'POST',
|
||||
data: {
|
||||
id: $("input[name='ListManagementID']").val()
|
||||
},
|
||||
success: function (data) {
|
||||
common.modalBlock(false);
|
||||
$("select[name='Type']").val(data.type);
|
||||
$("input[name='Name']").val(data.name);
|
||||
$("select[name='Gender']").val(data.gender);
|
||||
$("input[name='Birthday']").val(data.birthday);
|
||||
$("input[name='Telephone']").val(data.telephone);
|
||||
$("input[name='Address']").val(data.address);
|
||||
$("#FaceImage").attr("src", data.image);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
common.ajaxError();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function _update(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='ListManagementID']").val()
|
||||
},
|
||||
success: function (data) {
|
||||
alert("Cập nhật dữ liệu thành công!");
|
||||
window.location.reload(true);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
common.ajaxError();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function _delete(e) {
|
||||
if (confirm("Bạn có chắc chắn muốn xóa không?")) {
|
||||
common.modalBlock(true);
|
||||
$.ajax({
|
||||
url: $(e).attr("data-href"),
|
||||
type: 'POST',
|
||||
data: {
|
||||
id: $("input[name='ListManagementID']").val()
|
||||
},
|
||||
success: function (data) {
|
||||
window.location.reload(true);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
common.ajaxError();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function _deleteFeature(e) {
|
||||
if (confirm("Bạn có chắc chắn muốn xóa ảnh này không?")) {
|
||||
common.modalBlock(true);
|
||||
$.ajax({
|
||||
url: $(e).attr("data-href"),
|
||||
type: 'POST',
|
||||
data: {
|
||||
image: $(e).attr("data-img"),
|
||||
id: $(e).attr("data-id")
|
||||
},
|
||||
success: function (data) {
|
||||
common.modalBlock(false);
|
||||
$(e).closest("div").remove();
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
common.ajaxError();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function checkAll(status) {
|
||||
if (status)
|
||||
$("tr").addClass("delete-choose");
|
||||
else
|
||||
$("tr").removeClass("delete-choose");
|
||||
}
|
||||
|
||||
function batchDelete(e) {
|
||||
var check = $(".delete-choose");
|
||||
if (check.length == 0) {
|
||||
alert("Hãy chọn dữ liệu để xóa!");
|
||||
return;
|
||||
}
|
||||
var lists = [];
|
||||
$.each($(".delete-choose"), function () {
|
||||
if ($(this).attr("data-id") !== "")
|
||||
lists.push($(this).attr("data-id"));
|
||||
});
|
||||
if (confirm("Bạn có chắc chắn muốn xóa không?")) {
|
||||
common.modalBlock(true);
|
||||
$.ajax({
|
||||
url: $(e).attr("data-href"),
|
||||
type: 'POST',
|
||||
data: {
|
||||
lists: lists
|
||||
},
|
||||
success: function (data) {
|
||||
alert("Đã xóa dữ liệu!");
|
||||
window.location.reload(true);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
common.ajaxError();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user