+
+
+
+
+
+
+
+
+
+
+
+
+ {Pjax id="staff-list"}
+ {GridView::widget([
+ 'dataProvider' => $dataProvider,
+ 'filterModel' => $searchModel,
+ 'layout'=> \app\helpers\CommonGrid::getLayout(),
+ 'tableOptions' => [
+ 'class' => 'table table-striped table-bordered table-hover',
+ 'style' => 'background:#fff;min-width:700px;'
+ ],
+ 'rowOptions' => \app\helpers\CommonGrid::rows("staff", true),
+ 'columns' => [
+ [
+ 'class' => 'yii\grid\SerialColumn',
+ 'contentOptions' => ['class' => 'text-center'],
+ 'headerOptions' => ['class' => 'text-center', 'style' => 'width:3%']
+ ],
+ [
+ 'header' => "
",
+ 'format' => 'raw',
+ 'contentOptions' => ['class' => 'text-center'],
+ 'headerOptions' => ['class' => 'text-center', 'style' => 'width:3%'],
+ 'value' => \app\helpers\CommonGrid::checkbox("staff", false)
+ ],
+ 'code',
+ 'name',
+ 'card_number',
+ [
+ 'attribute' => 'department_id',
+ 'filter' => $departmentArray,
+ 'value' => \app\helpers\StaffGrid::department($departmentArray)
+ ],
+ [
+ 'attribute' => 'gender',
+ 'filter' => $genderArray,
+ 'value' => \app\helpers\StaffGrid::gender($genderArray)
+ ],
+ [
+ 'attribute' => 'birthday',
+ 'value' => \app\helpers\StaffGrid::birthday()
+ ],
+ 'email',
+ 'phone',
+ [
+ 'attribute' => 'date_in',
+ 'value' => \app\helpers\StaffGrid::dateIn()
+ ],
+ 'address'
+ ]
+ ])}
+ {/Pjax}
+
+{/block}
\ No newline at end of file
diff --git a/web/data/excel/1602319719_staff_20201010154609.xlsx b/web/data/excel/1602319719_staff_20201010154609.xlsx
new file mode 100644
index 00000000..8b4c5dca
Binary files /dev/null and b/web/data/excel/1602319719_staff_20201010154609.xlsx differ
diff --git a/web/data/excel/1602320488_staff_20201010155211.xlsx b/web/data/excel/1602320488_staff_20201010155211.xlsx
new file mode 100644
index 00000000..0d2992d4
Binary files /dev/null and b/web/data/excel/1602320488_staff_20201010155211.xlsx differ
diff --git a/web/data/excel/1602320930_staff_20201010155211.xlsx b/web/data/excel/1602320930_staff_20201010155211.xlsx
new file mode 100644
index 00000000..0d2992d4
Binary files /dev/null and b/web/data/excel/1602320930_staff_20201010155211.xlsx differ
diff --git a/web/data/excel/1602320972_staff_20201010155211.xlsx b/web/data/excel/1602320972_staff_20201010155211.xlsx
new file mode 100644
index 00000000..0d2992d4
Binary files /dev/null and b/web/data/excel/1602320972_staff_20201010155211.xlsx differ
diff --git a/web/js/common.js b/web/js/common.js
index 1e1c2ee6..7fd53c90 100644
--- a/web/js/common.js
+++ b/web/js/common.js
@@ -224,16 +224,21 @@ common.success = function (id) {
$("#" + id).addClass("has-success").removeClass("has-error");
$("#" + id).find(".help-block").addClass("hidden");
};
-common.form = function (e, obj) {
+common.form = function (e, obj, bigSize) {
+ var size = bigSize | false;
common.modalBlock(true);
$.ajax({
url: $(e).attr('data-href'),
type: 'POST',
success: function (data) {
common.modalBlock(false);
- common.modalOpen(data.form, false, data.title);
+ common.modalOpen(data.form, size, data.title);
if (obj === 'department')
$('#Pid').select2();
+ if (obj === 'staff') {
+ $('#Department').select2();
+ common.dateTimePickerByClass("DatePicker", "DD/MM/YYYY");
+ }
},
error: function (jqXHR, textStatus, errorThrown) {
common.modalBlock(false);
@@ -263,6 +268,22 @@ common.tree = function (e) {
$("#sub-tree-" + $(e).attr("data")).removeClass("hidden");
}
};
+common.validatePhone = function (PhoneNumber) {
+ var pattern = /^[0-9]{10,11}$/;
+ if (pattern.test(PhoneNumber)) {
+ return true;
+ } else {
+ return false;
+ }
+};
+common.validateEmail = function (Email) {
+ var pattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
+ if (pattern.test(Email)) {
+ return true;
+ } else {
+ return false;
+ }
+};
/**
* =========================
diff --git a/web/js/staff.js b/web/js/staff.js
new file mode 100644
index 00000000..c153c3e6
--- /dev/null
+++ b/web/js/staff.js
@@ -0,0 +1,225 @@
+$(function () {
+ common.checkboxInit("staff");
+ btnUpload($("input[name='upload_file_url']").val(), "", '.xls,.xlsx', 3500);
+});
+
+function validate() {
+ var error = 0;
+ var Name = $("input[name='Name']").val();
+ if (Name === "") {
+ common.error("name", "Tên nhân viên không được để trống");
+ error++;
+ } else {
+ common.success("name");
+ }
+
+ var Code = $("input[name='Code']").val();
+ if (Code === "") {
+ common.error("code", "Mã nhân viên không được để trống");
+ error++;
+ } else {
+ common.success("code");
+ }
+
+ var Email = $("input[name='Email']").val();
+ if (Email !== "") {
+ if (common.validateEmail(Email) == false) {
+ common.error("email", "Định dạng email không đúng");
+ error++;
+ } else {
+ common.success("email");
+ }
+ }
+ var Phone = $("input[name='Phone']").val();
+ if (Phone !== "") {
+ if (common.validatePhone(Phone) == false) {
+ common.error("phone", "Định dạng số điện thoại không đúng");
+ error++;
+ } else {
+ common.success("phone");
+ }
+ }
+ return error == 0 ? true : false;
+}
+
+function save(e) {
+ if (validate()) {
+ common.modalBlock(true);
+ $.ajax({
+ url: $(e).attr('data-href'),
+ type: 'POST',
+ data: {
+ Name: $("input[name='Name']").val(),
+ Code: $("input[name='Code']").val(),
+ Gender: $("select[name='Gender']").val(),
+ BirthDay: $("input[name='BirthDay']").val(),
+ Email: $("input[name='Email']").val(),
+ Phone: $("input[name='Phone']").val(),
+ CardNumber: $("input[name='CardNumber']").val(),
+ Department: $("select[name='Department']").val(),
+ DateIn: $("input[name='DateIn']").val(),
+ Address: $("textarea[name='Address']").val()
+ },
+ success: function (data) {
+ common.modalBlock(false);
+ if (data.status) {
+ notification.success("Đã lưu thông tin", 1000);
+ $.pjax.reload({container: '#staff-list'});
+ $("#staff-list").on('pjax:success', function () {
+ common.checkboxInit("staff");
+ });
+ $("#myModal").modal("hide");
+ } else {
+ if (data.type === "code") {
+ common.error("code", "Mã nhân viên đã tồn tại");
+ } else if (data.type === "card") {
+ common.error("card_number", "Số thẻ đã tồn tại");
+ } else {
+ notification.danger("Có lỗi xảy ra, không lưu được dữ liệu!", 1000);
+ }
+ }
+ },
+ error: function (jqXHR, textStatus, errorThrown) {
+ common.modalBlock(false);
+ common.ajaxError();
+ }
+ });
+ }
+}
+
+function _form(e) {
+ var lists = [];
+ $.each($("input[name='checkbox-staff']:checked"), function () {
+ lists.push($(this).val());
+ });
+ if (lists.length == 0) {
+ alert("Vui lòng lựa chọn đối tượng để thay đổi!");
+ return;
+ }
+ if (lists.length > 1) {
+ alert("Tác vụ này không thể lựa chọn nhiều hơn một đối tượng!");
+ return;
+ }
+ common.modalBlock(true);
+ $.ajax({
+ url: $(e).attr('data-href') + "?id=" + lists[0],
+ type: 'POST',
+ success: function (data) {
+ common.modalBlock(false);
+ common.modalOpen(data.form, true, data.title);
+ $('#Department').select2();
+ common.dateTimePickerByClass("DatePicker", "DD/MM/YYYY");
+ },
+ error: function (jqXHR, textStatus, errorThrown) {
+ common.modalBlock(false);
+ common.ajaxError();
+ }
+ });
+}
+
+function _delete(e) {
+ var lists = [];
+ $.each($("input[name='checkbox-staff']:checked"), function () {
+ lists.push($(this).val());
+ });
+ if (lists.length == 0) {
+ alert("Vui lòng lựa chọn đối tượng để xóa!");
+ return;
+ }
+ if (confirm("Bạn có chắc chắn muốn xóa các đối tượng đã lựa chọn không?")) {
+ common.modalBlock(true);
+ $.ajax({
+ url: $(e).attr('data-href'),
+ type: 'POST',
+ data: {
+ lists: lists
+ },
+ success: function (data) {
+ common.modalBlock(false);
+ notification.danger("Đã xóa dữ liệu", 1000);
+ $.pjax.reload({container: '#staff-list'});
+ $("#staff-list").on('pjax:success', function () {
+ common.checkboxInit("staff");
+ });
+ },
+ error: function (jqXHR, textStatus, errorThrown) {
+ common.modalBlock(false);
+ common.ajaxError();
+ }
+ });
+ }
+}
+
+function _export(e) {
+ window.location = $(e).attr("data-href");
+}
+
+function btnUpload(mUrl, className, extension, fileSize) {
+ var fData = {
+ UploadFile: true,
+ Name: className
+ };
+ fData[common.csrfParam] = common.csrf;
+ new afuButton({
+ uploadURI: mUrl,
+ formData: fData,
+ wrap: {
+ tagName: 'div',
+ classes: ''
+ },
+ fileExtension: extension,
+ fileSizeLimit: fileSize,
+ classes: 'btn btn-default file-paperclip-' + className,
+ fakeInputContent: '