PageSourceSearch

https://qnu.edu.vn/App/Admin/app/controllers/LichTuanManageController.js

js qnu.edu.vn collected 2026-10-01 15:53:09 UTC 50,410 bytes, 1,127 lines download raw bytes

1app.controller('LichTuanManageController', function LichTuanController($rootScope, $scope, LichTuanManageService, $uibModal, $sce, ngAuthSettings, toaster, $timeout, $window, $location, FileUploader) {
2
3  //Property
4    $scope.LichTuan =
5    {
6        myModel: "",
7        _danhSach: [],
8        _danhSachLichTruong: [],
9        _danhSachLichDonVi: [],
10        _danhSachLichBaoVeLuanAn: []
11        , _today: moment().clone().hour(7).format("DD/MM/YYYY")
12        , _weekStart: moment().isoWeekday() != 7 ? moment().clone().startOf('week').day(1).hour(7).format("DD/MM/YYYY")
13            : moment().clone().startOf('week').day(-6).format("DD/MM/YYYY")
14
15        , _weekEnd: moment().isoWeekday() != 7 ? moment().clone().endOf('week').day(7).hour(7).format("DD/MM/YYYY")
16            : moment().clone().startOf('week').format("DD/MM/YYYY")
17        , _danhSachTep: []
18        , _danhSachTepLichTuan: []
19        , _danhSachSoVanBan: []
20        , _LichTuanSelected: []
21        , _fileLichTuan: {}
22        , _selected: []
23        , _dataTemp: {
24            SoVanBanSelected: -1, //all
25            danhSachVanBanDuocChon: [],
26            CapApDung: 1,//1 la lich truong ; 2 la lich phong ban ; 3 la ca nhan
27            isDeleted: 1, // là chưa xóa; 2 là đã xóa
28
29        }
30        //Property
31        , _pagingInfo: {
32            sNgayBatDau: "",
33            filter: "",//$stateParams.filter,
34            orderBy: "CapApDung",
35            sort: "CreatedOn DESC",
36            page: 1,//$stateParams.page, //1,
37            pageSize: 10,//$stateParams.pageSize, //10,
38            reverse: false,
39            search: null, // $stateParams.search, //null,
40            totalItems: 0,
41            maxSize: 3,
42            trangThai: "",
43            sNgayKetThuc: "",
44            tuanCuaNam: 0,
45            idDonVi: ""
46
47        }
48
49        , _initial: function () {
50
51        }
52
53        , _loadData: function () {
54            $scope._Resource = $rootScope.Resource;
55
56            var _weekStartDB = moment($scope.LichTuan._weekStart, ["DD/MM/YYYY", "MM/DD/YYYY"]).format("MM/DD/YYYY");
57            var _weekEndDB = moment($scope.LichTuan._weekEnd, ["DD/MM/YYYY", "MM/DD/YYYY"]).format("MM/DD/YYYY");
58            this._pagingInfo.filter = "";
59
60            this._pagingInfo.sNgayBatDau = _weekStartDB;
61            this._pagingInfo.sNgayKetThuc = _weekEndDB;
62
63            var idDonVi1 = $window.location.hostname;
64            var subdomain = idDonVi1.split('.')[0];
65            if (subdomain === 'www') {
66                subdomain = '';
67            }
68            this._pagingInfo.idDonVi = subdomain;
69
70            LichTuanManageService.Get(this._pagingInfo).then(
71                function (success) {
72                    $scope.LichTuan._danhSach = success.data["LichTuan"];
73                    $scope.LichTuan._danhSachLichTruong = success.data["LichTruong"];
74                    $scope.LichTuan._danhSachLichDonVi = success.data["LichDonVi"];
75                    $scope.LichTuan._danhSachLichBaoVeLuanAn = success.data["LichBaoVeLuanAn"];
76                    $scope.LichTuan.MoTaLich = success.data["MoTaLich"];
77                    $scope.LichTuan._danhSachTepLichTuan = success.data["TepLichTuan"];
78                    $scope.LichTuan._pagingInfo.totalItems = success.data["TotalRow"];
79                    $scope.IsQuyenDuyetLichCongTac = success.data["IsQuyenDuyetLichCongTac"];
80                    if (success.data["LichTuan"] && success.data["LichTuan"].length) {
81                        buildViewData(success.data["LichTuan"]);
82                    }
83                    // ẩn cột trc ngày 16/02
84                    var mocNgay = moment('16/02/2026', 'DD/MM/YYYY');
85                    var weekEnd = moment($scope.LichTuan._weekEnd, 'DD/MM/YYYY');
86
87                    $scope.ShowChuanBiColumn = weekEnd.isSameOrAfter(mocNgay);
88
89
90                },
91                function (error) {
92                    toaster.pop('error', $rootScope.Resource.MeasageError, $rootScope.Resource.tstConnectServer, 3000);
93                });
94        }
95        , _aClickThem: function () {
96            var modalInstance = $uibModal.open({
97                templateUrl: '/App/Views/Lich/ThemLichCongViec.tpl.html',
98                controller: 'ThemLichCongViecNewController',
99                size: 'lg',
100                backdrop: 'static',
101                keyboard: false,
102                resolve: {
103                    LichTuan: function () {
104                        return $scope.LichTuan._dataTemp.CapApDung;
105                    }
106                }
107            });
108
109            modalInstance.result.then(function (LichTuan) {
110                if (LichTuan != null) {
111                    $scope.LichTuan._danhSach.push(LichTuan);
112                    $scope.LichTuan._loadData();
113                }
114
115            }, function () {
116
117            });
118
119        }
120        , _aClickUpdate: function () {
121            if ($scope.LichTuan._selected.length == 1) {
122                $scope.LichTuan._LichTuanSelected = [];
123                angular.forEach($scope.LichTuan._danhSach, function (dt) {
124                    angular.forEach(dt.LichTuans, function (rs) {
125                        if (rs.Id === $scope.LichTuan._selected[0]) {
126                            $scope.LichTuan._LichTuanSelected.push(rs);
127                            return;
128                        }
129                    })
130                });
131                var modalInstance = $uibModal.open({
132                    templateUrl: '/App/Views/Lich/ThemLichCongViec.tpl.html',
133                    controller: 'ThemLichCongViecNewController',
134                    size: 'lg',
135
136                    resolve: {
137                        LichTuan: function () {
138                            return $scope.LichTuan._LichTuanSelected[0];
139                        }
140                    }
141                });
142                modalInstance.result.then(function (LichTuan) {
143                    //$scope.LichTuan._danhSach.push(LichTuan)
144                    $scope.LichTuan._loadData();
145                }, function fail(reason) {
146                    if (~reason.indexOf('backdrop')) {
147                        $scope.LichTuan._loadData();
148                    }
149                });
150            } else {
151                toaster.pop("error", $scope._Resource.MeasageError, $scope._Resource.MeasagePleaseSelectSchedule, 2000);
152            }
153        }
154        , _aClickDelete: function () {
155
156            if ($scope.LichTuan._selected.length >= 1) {
157                angular.forEach($scope.LichTuan._selected, function (dt) {
158
159                    LichTuanManageService.Delete(dt).then(function (success) {
160                        $('#confirmdelete').modal('hide');
161                        $('.modal-backdrop').hide();
162                        toaster.pop('success', $rootScope.Resource.Successfully, $rootScope.Resource.Successfully, 3000);
163                        $scope.LichTuan._loadData();
164                        $scope.LichTuan._selected = [];
165                    }, function (error) {
166                        toaster.pop("error", $scope._Resource.MeasageError, error.data, 2000);
167                    })
168                });
169
170            } else {
171                $('#confirmdelete').modal('hide');
172                $('.modal-backdrop').hide();
173                toaster.pop("error", $scope._Resource.MeasageError, $scope._Resource.MeasagePleaseSelectScheduleDelete, 2000);
174            }
175        }
176        , _aSaveMoTa: function () {
177            LichTuanManageService.SaveMoTaLich($scope.LichTuan.MoTaLich).then(function (success) {
178                toaster.pop('success', $rootScope.Resource.Successfully, $rootScope.Resource.Successfully, 3000);
179
180            }, function (error) {
181                toaster.pop("error", $scope._Resource.MeasageError, error.data, 2000);
182            })
183        }
184        , _XemLichDaXoa: function () {
185            if (this._dataTemp.isDeleted == 1) {
186                this._dataTemp.isDeleted = 2;
187                $("#Kiemtraxem").html("<i class='fa fa-trash'></i>" + $rootScope.Resource.btnTroVe);
188            }
189            else {
190                $("#Kiemtraxem").html("<i class='fa fa-trash'></i> " + $rootScope.Resource.btnThungRac)
191                this._dataTemp.isDeleted = 1;
192            }
193
194
195            this._loadData();
196        }
197        , _txtEnterSearch: function () {
198            this._loadData();
199        }
200        , _inClickXemTuanTruoc: function () {
201
202            $scope.LichTuan._pagingInfo.tuanCuaNam = 0;
203
204            $scope.getBuoi = function (ngayGioBD) {
205                var h = new Date(ngayGioBD).getHours();
206                return h < 12 ? 'Sáng' : 'Chiều';
207            };
208
209            $scope.LichTuan._selected = [];
210            $scope.LichTuan._pagingInfo.search = null;
211            if ($scope.LichTuan._weekStart == null) {
212                $scope.LichTuan._weekStart = moment().isoWeekday() != 7 ? moment().clone().startOf('week').day(1).hour(7).format("DD/MM/YYYY")
213                    : moment().clone().startOf('week').day(-6).format("DD/MM/YYYY");
214            }
215
216            $scope.LichTuan._weekEnd = moment($scope.LichTuan._weekStart, ["DD-MM-YYYY", "MM-DD-YYYY"]).day(7).format("DD/MM/YYYY");
217            var dayStart = moment($scope.LichTuan._weekStart, ["DD/MM/YYYY", "MM/DD/YYYY"]);
218            $scope.LichTuan._weekStart = dayStart.day(-6).format("DD/MM/YYYY");
219            var dayEnd = moment($scope.LichTuan._weekEnd, ["DD/MM/YYYY", "MM/DD/YYYY"]);
220            $scope.LichTuan._weekEnd = dayEnd.day(-7).format("DD/MM/YYYY");
221            //$('#tuancuanam').val($scope.LichTuan._weekEnd);
222
223            this._loadData();
224        }
225        , _inClickXemTuanSau: function () {
226
227            $scope.LichTuan._pagingInfo.tuanCuaNam = 0;
228
229            $scope.getBuoi = function (ngayGioBD) {
230                var h = new Date(ngayGioBD).getHours();
231                return h < 12 ? 'Sáng' : 'Chiều';
232            };
233
234            $scope.LichTuan._selected = [];
235            $scope.LichTuan._pagingInfo.search = null;
236            if ($scope.LichTuan._weekStart == null) {
237                $scope.LichTuan._weekStart = moment().isoWeekday() != 7 ? moment().clone().startOf('week').day(1).hour(7).format("DD/MM/YYYY")
238                    : moment().clone().startOf('week').day(-6).format("DD/MM/YYYY");
239            }
240
241            $scope.LichTuan._weekEnd = moment($scope.LichTuan._weekStart, ["DD/MM/YYYY", "MM/DD/YYYY"]).day(7).format("DD/MM/YYYY");
242            var dayStart = moment($scope.LichTuan._weekEnd, ["DD/MM/YYYY", "MM/DD/YYYY"]);
243            $scope.LichTuan._weekStart = dayStart.day(1).format("DD/MM/YYYY");
244            var dayEnd = moment($scope.LichTuan._weekEnd, ["DD/MM/YYYY", "MM/DD/YYYY"]);
245            $scope.LichTuan._weekEnd = dayEnd.day(7).format("DD/MM/YYYY");
246
247            this._loadData();
248        }
249        , _inClickXemTuanHienTai: function () {
250            $scope.LichTuan._selected = [];
251            $scope.LichTuan._pagingInfo.search = null;
252            //$scope.LichTuan._weekStart = moment().clone().startOf('week').day(1).hour(7).format("DD-MM-YYYY");
253            //$scope.LichTuan._weekEnd = moment().clone().endOf('week').day(7).hour(7).format("DD-MM-YYYY");
254
255            $scope.LichTuan._weekStart = moment().isoWeekday() != 7 ? moment().clone().startOf('week').day(1).hour(7).format("DD/MM/YYYY")
256                : moment().clone().startOf('week').day(-6).format("DD/MM/YYYY");
257
258            $scope.LichTuan._weekEnd = moment().isoWeekday() != 7 ? moment().clone().endOf('week').day(7).hour(7).format("DD/MM/YYYY")
259                : moment().clone().startOf('week').format("DD/MM/YYYY");
260            this._loadData();
261        }
262        , _inClickXemToday: function () {
263
264            if ($scope.LichTuan._danhSach != undefined && $scope.LichTuan._danhSach.length > 0) {
265                $scope.LichTuan._danhSach = $scope.LichTuan._danhSach.filter(x => x.Ngay == $scope.LichTuan._formatDate(new Date()));
266            } else {
267
268                $scope.LichTuan._selected = [];
269                $scope.LichTuan._pagingInfo.search = null;
270                $scope.LichTuan._weekStart = $scope.LichTuan._formatDate(new Date());
271                $scope.LichTuan._weekEnd = $scope.LichTuan._formatDate(new Date());
272                $scope.LichTuan._loadData();
273            }
274
275        }
276        , _formatDate: function (date) {
277            var d = moment(date).utcOffset('+07:00');
278            const day = String(d.date()).padStart(2, '0');
279            const month = String(d.month() + 1).padStart(2, '0');
280            const year = d.year();
281            return `${day}-${month}-${year}`;
282        }
283        // , _inClickXemToday: function () {
284        //     console.log("Now:", new Date());
285        //     console.log($scope.LichTuan._danhSach.map(x => ({
286        //         Thu: x.Thu,
287        //         Ngay: x.Ngay
288        //     })));
289        //     $scope.LichTuan._selected = [];
290        //     $scope.LichTuan._pagingInfo.search = null;
291        //     $scope.LichTuan._weekStart = moment().clone().hour(7).format("DD/MM/YYYY");
292        //     $scope.LichTuan._weekEnd = moment().clone().hour(7).format("DD/MM/YYYY");
293        //     $scope.LichTuan._loadData();
294        // }
295        , _updateSelected: function (action, id) {
296            if (action === 'add' && this._selected.indexOf(id) === -1) {
297                this._selected.push(id);
298            }
299            if (action === 'remove' && this._selected.indexOf(id) !== -1) {
300                this._selected.splice(this._selected.indexOf(id), 1);
301            }
302        }
303        , _updateSelection: function ($event, id) {
304            var checkbox = $event.target;
305            var action = (checkbox.checked ? 'add' : 'remove');
306            $scope.LichTuan._updateSelected(action, id);
307        }
308        , _isSelected: function (id) {
309            return this._selected.indexOf(id) >= 0;
310        }
311        , _getSelectedClass: function (entity) {
312            return $scope.LichTuan._isSelected(entity) ? 'selected' : '';
313        }
314        , _selectAll: function ($event) {
315            var checkbox = $event.target;
316            var action = (checkbox.checked ? 'add' : 'remove');
317            angular.forEach($scope.LichTuan._danhSach, function (dt) {
318                angular.forEach(dt.LichTuans, function (entity) {
319                    $scope.LichTuan._updateSelected(action, entity.Id);
320                })
321            });
322        }
323        , _isSelectedAll: function () {
324            var lenghCheck = 0;
325            angular.forEach($scope.LichTuan._danhSach, function (dt) {
326                angular.forEach(dt.LichTuans, function (entity) {
327                    lenghCheck++;
328                })
329            });
330            return lenghCheck == 0 ? false : this._selected.length === lenghCheck;
331
332        }
333        , _importExcel: function () {
334            if ($scope.LichTuan._danhSachTep.length == 0) {
335                toaster.pop("error", $scope._Resource.MeasageError, $scope._Resource.MeasageSelectFileExcel, 2000);
336                return;
337            }
338
339            LichTuanManageService.Import($scope.LichTuan._danhSachTep[0], this._dataTemp.CapApDung).then(function (success) {
340                toaster.pop('success', $rootScope.Resource.Successfully, $rootScope.Resource.Successfully, 3000);
341            }, function (error) {
342                toaster.pop('error', $rootScope.Resource.MeasageError, $rootScope.Resource.tstUnsuccessful, 3000);
343            });
344        }
345        , _exportExcel: function (value) {
346            LichTuanManageService.ExportExcel(this._pagingInfo, value).then(function (success) {
347                var href = ngAuthSettings.apiServiceBaseUri + "temp/Upload/reports.xls";
348
349                window.location.href = href;
350
351                toaster.pop('success', $rootScope.Resource.Successfully, $rootScope.Resource.Successfully, 3000);
352
353            }, function (error) {
354                toaster.pop("error", $scope._Resource.MeasageError, error.data, 2000);
355            })
356        }
357        , _clickDowloadWord: function () {
358            var href = ngAuthSettings.apiServiceBaseUri + "api/v1/reports/LichCongViec?filter=" + encodeURI(this._pagingInfo.filter) + "&sNgayKetThuc=" + encodeURI(this._pagingInfo.sNgayKetThuc);
359
360            window.location.href = href;
361        }
362        , _uploadLichTuan: function () {
363
364            if (this._danhSachTepLichTuan.length == 0) {
365                toaster.pop("error", $scope._Resource.MeasageError, "Chọn file upload", 2000);
366                return;
367            }
368
369            this._danhSachTepLichTuan[0].WeekOfYear = moment(this._weekStart, ["DD/MM/YYYY", "MM/DD/YYYY"]).isoWeek();
370            this._danhSachTepLichTuan[0].Year = moment(this._weekStart, ["DD/MM/YYYY", "MM/DD/YYYY"]).year();
371
372            LichTuanManageService.UploadLichTuan(this._danhSachTepLichTuan[0], this._pagingInfo.sNgayBatDau).then(function (success) {
373                toaster.pop('success', $rootScope.Resource.Successfully, $rootScope.Resource.Successfully, 3000);
374            }, function (error) {
375                toaster.pop('error', $rootScope.Resource.MeasageError, $rootScope.Resource.tstUnsuccessful, 3000);
376            })
377        }
378        , _aClickXoaTepLichTuan: function (tep) {
379
380            LichTuanManageService.XoaTepLichTuan(tep).then(function (success) {
381                toaster.pop('success', $rootScope.Resource.Successfully, $rootScope.Resource.Successfully, 3000);
382            }, function (error) {
383                toaster.pop('error', $rootScope.Resource.MeasageError, $rootScope.Resource.tstUnsuccessful, 3000);
384            })
385        }
386        , _inputKeyupSearch: function () {
387            if ($('#tuancuanam').val() == '') {
388                $scope.LichTuan.MoTaLich.Tuan = 1;
389            }
390            else {
391                //nếu nhập tuần lớn hơn 52 thì trả về tuần đầu tiên
392                if ($('#tuancuanam').val() > 52 || $('#tuancuanam').val() < 1) {
393                    $scope.LichTuan.MoTaLich.Tuan = 1;
394                    $('#tuancuanam').val($scope.LichTuan.MoTaLich.Tuan);
395                }
396                // ngược lại binding tuần mặc định
397                else {
398                    $scope.LichTuan.MoTaLich.Tuan = $('#tuancuanam').val();
399                }
400            }
401            if ($('#namHienTai').val() == '') {
402                $scope.LichTuan.MoTaLich.Nam = (new Date()).getFullYear();
403            }
404            else {
405                $scope.LichTuan.MoTaLich.Nam = $('#namHienTai').val();
406            }
407
408            $scope.LichTuan._pagingInfo.tuanCuaNam = $scope.LichTuan.MoTaLich.Tuan;
409
410            //lấy ngày đầu tiên của tuần
411            var ngayBatDau = $scope.LichTuan._getFirstDayByWeek($scope.LichTuan.MoTaLich.Tuan, $('#namHienTai').val());
412
413            var firstDay = moment(ngayBatDau).format('DD/MM/YYYY');
414
415            //lấy ngày cuối cùng của tuần
416            var ngayKetThuc = $scope.LichTuan._getLastDayByWeek($scope.LichTuan.MoTaLich.Tuan, $('#namHienTai').val());
417
418            var lastDay = moment(ngayKetThuc).format('DD/MM/YYYY');
419
420            $scope.LichTuan._weekStart = firstDay;
421            $scope.LichTuan._weekEnd = lastDay;
422
423            $scope.LichTuan._loadData();
424        }
425        , _getFirstDayByWeek: function (week, year) {
426            var d = new Date("Jan 01, " + year + " 01:00:00");
427            var dayMs = (24 * 60 * 60 * 1000);
428            var offSetTimeStart = dayMs * (d.getDay() - 1);
429            var w = d.getTime() + 604800000 * (week - 1) - offSetTimeStart; //reducing the offset here
430            var n1 = new Date(w);
431            //var n2 = new Date(w + 518400000);
432            return n1;
433
434        }
435        , _getLastDayByWeek: function (week, year) {
436            var d = new Date("Jan 01, " + year + " 01:00:00");
437            var dayMs = (24 * 60 * 60 * 1000);
438            var offSetTimeStart = dayMs * (d.getDay() - 1);
439            var w = d.getTime() + 604800000 * (week - 1) - offSetTimeStart; //reducing the offset here
440            //var n1 = new Date(w);
441            var n2 = new Date(w + 518400000);
442            return n2;
443        }
444        , _updateTrangThai: function (value) {
445            debugger;
446            if ($scope.LichTuan._selected.length >= 1) {
447                angular.forEach($scope.LichTuan._selected, function (dt) {
448                    LichTuanManageService.UpdateTrangThai(dt, value).then(function (success) {
449                        $scope.LichTuan._loadData();
450                    }, function (error) {
451                        toaster.pop('error', $rootScope.Resource.MeasageError, error.data/*$rootScope.Resource.tstUnsuccessful*/, 3000);
452                    })
453                });
454
455            } else {
456                toaster.pop("error", $scope._Resource.MeasageError, $scope._Resource.MeasagePleaseSelectScheduleUpdateStatus, 2000);
457            }
458        }
459        , _XoaLichTamThoi: function (value) {
460            if ($scope.LichTuan._selected.length >= 1) {
461                angular.forEach($scope.LichTuan._selected, function (dt) {
462                    LichTuanManageService.XoaLichTamThoi(dt, value).then(function (success) {
463                        toaster.pop('success', $rootScope.Resource.Successfully, $rootScope.Resource.Successfully, 3000);
464                        $scope.LichTuan._loadData();
465                        $scope.LichTuan._selected = [];
466                    }, function (error) {
467                        toaster.pop('error', $rootScope.Resource.MeasageError, error.data/*$rootScope.Resource.tstUnsuccessful*/, 3000);
468                    })
469                });
470
471            } else {
472                toaster.pop("error", $scope._Resource.MeasageError, $scope._Resource.tbDeleted, 2000);
473            }
474        }
475        , _selectChangeTrangThai: function () {
476            this._loadData();
477        }
478        , _LichTruong: function () {
479            this._dataTemp.CapApDung = 1;
480            this._loadData();
481        }
482        , _DonVi: function () {
483            this._dataTemp.CapApDung = 2;
484            this._loadData();
485        }
486        , _LichBaoVeLuanAn: function () {
487            this._dataTemp.CapApDung = 3;
488            this._loadData();
489        }
490        , _getParameterByName: function (name) {
491            var url = window.location.href;
492            name = name.replace(/[\[\]]/g, "\\$&");
493            var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
494                results = regex.exec(url);
495            if (!results) return null;
496            if (!results[2]) return '';
497            return decodeURIComponent(results[2].replace(/\+/g, " "));
498        }
499    };
500    $scope.viewFile = function (url) {
501        window.open(url, "_blank");
502    }
503    $scope.getTimePart = function (datetime) {
504        if (!datetime) return '';
505        var date = new Date(datetime);
506        var hours = date.getUTCHours().toString().padStart(2, '0');
507        var minutes = date.getUTCMinutes().toString().padStart(2, '0');
508        return hours + ":" + minutes;
509    }
510
511    $scope.getWeekNumber = function (dateInput) {
512        if (!dateInput) return null;
513
514        var date;
515
516        if (typeof dateInput === 'string') {
517            // xử lý trường hợp định dạng dd/MM/yyyy
518            if (dateInput.includes('/')) {
519                date = parseDateDDMMYYYY(dateInput);
520            } else {
521                // fallback nếu là yyyy-MM-dd
522                date = new Date(dateInput + "T00:00:00");
523            }
524        } else if (Object.prototype.toString.call(dateInput) === '[object Date]') {
525            date = dateInput;
526        } else {
527            return null;
528        }
529
530        if (isNaN(date.getTime())) return null;
531
532        var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
533        var dayNum = d.getUTCDay() || 7;
534        d.setUTCDate(d.getUTCDate() + 4 - dayNum);
535        var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
536        var weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
537        return weekNo;
538    };
539
540    function parseDateDDMMYYYY(str) {
541        var parts = str.split('/');
542        return new Date(parts[2], parts[1] - 1, parts[0]);
543    }
544    function buildViewData(list) {
545
546        angular.forEach(list, function (day) {
547
548            if (!day.LichTuans || !day.LichTuans.length) return;
549
550            // sort theo giờ trước
551            day.LichTuans.sort(function (a, b) {
552                return new Date(a.NgayGioBD) - new Date(b.NgayGioBD);
553            });
554
555            var buoiMap = {};
556
557            angular.forEach(day.LichTuans, function (item) {
558
559                if (!item.NgayGioBD) {
560                    item._buoi = '';
561                    item._timeText = '';
562                    return;
563                }
564
565                var d = new Date(item.NgayGioBD);
566                var h = d.getUTCHours(); // GIỮ NGUYÊN UTC NHƯ BẠN MUỐN
567
568                // BUỔI
569                var buoi = (h < 12) ? 'Sáng' : 'Chiều';
570                item._buoi = buoi;
571
572                // GIỜ
573                item._timeText =
574                    d.getUTCHours().toString().padStart(2, '0') + ':' +
575                    d.getUTCMinutes().toString().padStart(2, '0');
576
577                // gom nhóm
578                if (!buoiMap[buoi]) buoiMap[buoi] = [];
579                buoiMap[buoi].push(item);
580            });
581
582            // set rowspan + show flag
583            angular.forEach(buoiMap, function (rows) {
584                rows.forEach(function (item, idx) {
585                    item._showBuoi = idx === 0;
586                    item._buoiRowSpan = rows.length;
587                });
588            });
589
590            day.TotalRows = day.LichTuans.length;
591        });
592    }
593
594
595    $scope.LichTuan._loadData();
596
597});
598app.directive('myEnter', function () {
599    return function (scope, element, attrs) {
600        element.bind("keydown keypress", function (event) {
601            if (event.which === 13) {
602                scope.$apply(function () {
603                    scope.$eval(attrs.myEnter);
604                });
605
606                event.preventDefault();
607            }
608        });
609    };
610});
611app.controller('LichTodayManageController', function LichTodayController($rootScope, $scope, LichTuanManageService, $uibModal, $sce, ngAuthSettings, toaster, $timeout, $window, $location, FileUploader) {
612
613    $scope.LichTuan =
614    {
615        myModel: "",
616        _danhSach: [],
617        _danhSachLichTruong: [],
618        _danhSachLichDonVi: [],
619        _danhSachLichBaoVeLuanAn: []
620        , _today: moment().clone().hour(7).format("DD-MM-YYYY")
621        , _weekStart: moment().isoWeekday() != 7 ? moment().clone().startOf('week').day(1).hour(7).format("DD/MM/YYYY")
622            : moment().clone().startOf('week').day(-6).format("DD/MM/YYYY")
623
624        , _weekEnd: moment().isoWeekday() != 7 ? moment().clone().endOf('week').day(7).hour(7).format("DD/MM/YYYY")
625            : moment().clone().startOf('week').format("DD/MM/YYYY")
626        , _danhSachTep: []
627        , _danhSachTepLichTuan: []
628        , _danhSachSoVanBan: []
629        , _LichTuanSelected: []
630        , _fileLichTuan: {}
631        , _selected: []
632        , _dataTemp: {
633            SoVanBanSelected: -1, //all
634            danhSachVanBanDuocChon: [],
635            CapApDung: 1,//1 la lich truong ; 2 la lich phong ban ; 3 la ca nhan
636            isDeleted: 1, // là chưa xóa; 2 là đã xóa
637
638        }
639        //Property
640        , _pagingInfo: {
641            sNgayBatDau: "",
642            filter: "",//$stateParams.filter,
643            orderBy: "CapApDung",
644            sort: "CreatedOn DESC",
645            page: 1,//$stateParams.page, //1,
646            pageSize: 10,//$stateParams.pageSize, //10,
647            reverse: false,
648            search: null, // $stateParams.search, //null,
649            totalItems: 0,
650            maxSize: 3,
651            trangThai: "",
652            sNgayKetThuc: "",
653            tuanCuaNam: 0,
654
655        }
656
657        , _initial: function () {
658
659        }
660
661        , _loadData: function () {
662            $scope._Resource = $rootScope.Resource;
663
664
665
666            var _weekStartDB = moment($scope.LichTuan._today, ["DD/MM/YYYY", "MM/DD/YYYY"]).format("MM/DD/YYYY");
667            var _weekEndDB = moment($scope.LichTuan._today, ["DD/MM/YYYY", "MM/DD/YYYY"]).format("MM/DD/YYYY");
668            this._pagingInfo.filter = " 1=1 ";
669
670            if (this._pagingInfo.onlyView !== null) {
671                this._pagingInfo.filter += " AND LoaiCongViec IS NULL AND (TrangThai = 2 OR TrangThai = 4) ";
672            }
673
674
675
676            if (this._pagingInfo.trangThai !== null && this._pagingInfo.trangThai !== "") {
677                this._pagingInfo.filter += " AND LoaiCongViec IS NULL AND TrangThai = " + this._pagingInfo.trangThai + " ";
678            }
679
680            if (this._pagingInfo.tuanCuaNam == '') {
681                this._pagingInfo.tuanCuaNam == 1;
682            }
683
684            this._pagingInfo.sNgayBatDau = _weekStartDB;
685            this._pagingInfo.sNgayKetThuc = _weekEndDB;
686
687            if (this._pagingInfo.search !== null && this._pagingInfo.search !== "") {
688
689                this._pagingInfo.filter += " AND LoaiCongViec IS NULL AND FREETEXT  ( (NoiDung, ThanhPhan, DiaDiem , EmailNguoiTao), ' " + this._pagingInfo.search + " ')  ";
690            }
691
692
693            if (this._pagingInfo.tuanCuaNam == 0) {
694                this._pagingInfo.filter += " AND LoaiCongViec IS NULL AND CONVERT(date, NgayGioBD) >= '" + _weekStartDB +
695                    "' and CONVERT(date, NgayGioBD) <='" + _weekEndDB + "'";
696            }
697
698
699            if (this._pagingInfo.onlyView == null) {
700                this._pagingInfo.filter += " AND CapApDung=" + this._dataTemp.CapApDung;
701            }
702
703            this._pagingInfo.filter += " AND isDeleted= " + this._dataTemp.isDeleted; //1 la load lich chua xoa
704
705            LichTuanManageService.Get(this._pagingInfo).then(
706                function (success) {
707                    $scope.LichTuan._danhSach = success.data["LichTuan"];
708                    $scope.LichTuan._danhSachLichTruong = success.data["LichTruong"];
709                    $scope.LichTuan._danhSachLichDonVi = success.data["LichDonVi"];
710                    $scope.LichTuan._danhSachLichBaoVeLuanAn = success.data["LichBaoVeLuanAn"];
711                    $scope.LichTuan.MoTaLich = success.data["MoTaLich"];
712                    $scope.LichTuan._danhSachTepLichTuan = success.data["TepLichTuan"];
713                    $scope.LichTuan._pagingInfo.totalItems = success.data["TotalRow"];
714                    $scope.IsQuyenDuyetLichCongTac = success.data["IsQuyenDuyetLichCongTac"];
715                },
716                function (error) {
717                    toaster.pop('error', $rootScope.Resource.MeasageError, $rootScope.Resource.tstConnectServer, 3000);
718                });
719        }
720        , _aClickThem: function () {
721            var modalInstance = $uibModal.open({
722                templateUrl: '/App/Views/Lich/ThemLichCongViec.tpl.html',
723                controller: 'ThemLichCongViecNewController',
724                size: 'lg',
725                backdrop: 'static',
726                keyboard: false,
727                resolve: {
728                    LichTuan: function () {
729                        return $scope.LichTuan._dataTemp.CapApDung;
730                    }
731                }
732            });
733
734            modalInstance.result.then(function (LichTuan) {
735                if (LichTuan != null) {
736                    $scope.LichTuan._danhSach.push(LichTuan);
737                    $scope.LichTuan._loadData();
738                }
739
740            }, function () {
741
742            });
743
744        }
745        , _aClickUpdate: function () {
746            if ($scope.LichTuan._selected.length == 1) {
747                $scope.LichTuan._LichTuanSelected = [];
748                angular.forEach($scope.LichTuan._danhSach, function (dt) {
749                    angular.forEach(dt.LichTuans, function (rs) {
750                        if (rs.Id === $scope.LichTuan._selected[0]) {
751                            $scope.LichTuan._LichTuanSelected.push(rs);
752                            return;
753                        }
754                    })
755                });
756                var modalInstance = $uibModal.open({
757                    templateUrl: '/App/Views/Lich/ThemLichCongViec.tpl.html',
758                    controller: 'ThemLichCongViecNewController',
759                    size: 'lg',
760
761                    resolve: {
762                        LichTuan: function () {
763                            return $scope.LichTuan._LichTuanSelected[0];
764                        }
765                    }
766                });
767                modalInstance.result.then(function (LichTuan) {
768                    //$scope.LichTuan._danhSach.push(LichTuan)
769                    $scope.LichTuan._loadData();
770                }, function fail(reason) {
771                    if (~reason.indexOf('backdrop')) {
772                        $scope.LichTuan._loadData();
773                    }
774                });
775            } else {
776                toaster.pop("error", $scope._Resource.MeasageError, $scope._Resource.MeasagePleaseSelectSchedule, 2000);
777            }
778        }
779        , _aClickDelete: function () {
780
781            if ($scope.LichTuan._selected.length >= 1) {
782                angular.forEach($scope.LichTuan._selected, function (dt) {
783
784                    LichTuanManageService.Delete(dt).then(function (success) {
785                        $('#confirmdelete').modal('hide');
786                        $('.modal-backdrop').hide();
787                        toaster.pop('success', $rootScope.Resource.Successfully, $rootScope.Resource.Successfully, 3000);
788                        $scope.LichTuan._loadData();
789                        $scope.LichTuan._selected = [];
790                    }, function (error) {
791                        toaster.pop("error", $scope._Resource.MeasageError, error.data, 2000);
792                    })
793                });
794
795            } else {
796                $('#confirmdelete').modal('hide');
797                $('.modal-backdrop').hide();
798                toaster.pop("error", $scope._Resource.MeasageError, $scope._Resource.MeasagePleaseSelectScheduleDelete, 2000);
799            }
800        }
801        , _aSaveMoTa: function () {
802            LichTuanManageService.SaveMoTaLich($scope.LichTuan.MoTaLich).then(function (success) {
803                toaster.pop('success', $rootScope.Resource.Successfully, $rootScope.Resource.Successfully, 3000);
804
805            }, function (error) {
806                toaster.pop("error", $scope._Resource.MeasageError, error.data, 2000);
807            })
808        }
809        , _XemLichDaXoa: function () {
810            if (this._dataTemp.isDeleted == 1) {
811                this._dataTemp.isDeleted = 2;
812                $("#Kiemtraxem").html("<i class='fa fa-trash'></i>" + $rootScope.Resource.btnTroVe);
813            }
814            else {
815                $("#Kiemtraxem").html("<i class='fa fa-trash'></i> " + $rootScope.Resource.btnThungRac)
816                this._dataTemp.isDeleted = 1;
817            }
818
819
820            this._loadData();
821        }
822        , _txtEnterSearch: function () {
823            this._loadData();
824        }
825        , _inClickXemTuanTruoc: function () {
826
827            $scope.LichTuan._pagingInfo.tuanCuaNam = 0;
828
829            //if ($('#tuancuanam').val() <= 1) {
830            //    $scope.LichTuan.MoTaLich.Tuan = 52;
831            //    $('#tuancuanam').val($scope.LichTuan.MoTaLich.Tuan);
832            //    $('#namHienTai').val(parseInt($('#namHienTai').val()) - 1);
833            //}
834            //else {
835            //    var firstWeek = $('#tuancuanam').val(parseInt($('#tuancuanam').val()) - 1);
836            //    $scope.LichTuan.MoTaLich.Tuan = firstWeek;
837
838            //}
839
840            $scope.LichTuan._selected = [];
841            $scope.LichTuan._pagingInfo.search = null;
842            if ($scope.LichTuan._weekStart == null) {
843                $scope.LichTuan._weekStart = moment().isoWeekday() != 7 ? moment().clone().startOf('week').day(1).hour(7).format("DD/MM/YYYY")
844                    : moment().clone().startOf('week').day(-6).format("DD/MM/YYYY");
845            }
846
847            $scope.LichTuan._weekEnd = moment($scope.LichTuan._weekStart, ["DD-MM-YYYY", "MM-DD-YYYY"]).day(7).format("DD/MM/YYYY");
848            var dayStart = moment($scope.LichTuan._weekStart, ["DD/MM/YYYY", "MM/DD/YYYY"]);
849            $scope.LichTuan._weekStart = dayStart.day(-6).format("DD/MM/YYYY");
850            var dayEnd = moment($scope.LichTuan._weekEnd, ["DD/MM/YYYY", "MM/DD/YYYY"]);
851            $scope.LichTuan._weekEnd = dayEnd.day(-7).format("DD/MM/YYYY");
852            //$('#tuancuanam').val($scope.LichTuan._weekEnd);
853
854            this._loadData();
855        }
856        , _inClickXemTuanSau: function () {
857
858            $scope.LichTuan._pagingInfo.tuanCuaNam = 0;
859
860            //if ($('#tuancuanam').val() >= 52) {
861            //    $scope.LichTuan.MoTaLich.Tuan = 1;
862            //    $('#tuancuanam').val($scope.LichTuan.MoTaLich.Tuan);
863            //    $('#namHienTai').val(parseInt($('#namHienTai').val()) + 1);
864            //}
865            //else {
866            //    var lastWeek = $('#tuancuanam').val(parseInt($('#tuancuanam').val()) + 1);
867            //    $scope.LichTuan.MoTaLich.Tuan = lastWeek;
868            //}
869
870            $scope.LichTuan._selected = [];
871            $scope.LichTuan._pagingInfo.search = null;
872            if ($scope.LichTuan._weekStart == null) {
873                $scope.LichTuan._weekStart = moment().isoWeekday() != 7 ? moment().clone().startOf('week').day(1).hour(7).format("DD/MM/YYYY")
874                    : moment().clone().startOf('week').day(-6).format("DD/MM/YYYY");
875            }
876
877            $scope.LichTuan._weekEnd = moment($scope.LichTuan._weekStart, ["DD/MM/YYYY", "MM/DD/YYYY"]).day(7).format("DD/MM/YYYY");
878            var dayStart = moment($scope.LichTuan._weekEnd, ["DD/MM/YYYY", "MM/DD/YYYY"]);
879            $scope.LichTuan._weekStart = dayStart.day(1).format("DD/MM/YYYY");
880            var dayEnd = moment($scope.LichTuan._weekEnd, ["DD/MM/YYYY", "MM/DD/YYYY"]);
881            $scope.LichTuan._weekEnd = dayEnd.day(7).format("DD/MM/YYYY");
882
883            this._loadData();
884        }
885        , _inClickXemTuanHienTai: function () {
886            $scope.LichTuan._selected = [];
887            $scope.LichTuan._pagingInfo.search = null;
888            //$scope.LichTuan._weekStart = moment().clone().startOf('week').day(1).hour(7).format("DD-MM-YYYY");
889            //$scope.LichTuan._weekEnd = moment().clone().endOf('week').day(7).hour(7).format("DD-MM-YYYY");
890
891            $scope.LichTuan._weekStart = moment().isoWeekday() != 7 ? moment().clone().startOf('week').day(1).hour(7).format("DD/MM/YYYY")
892                : moment().clone().startOf('week').day(-6).format("DD/MM/YYYY");
893
894            $scope.LichTuan._weekEnd = moment().isoWeekday() != 7 ? moment().clone().endOf('week').day(7).hour(7).format("DD/MM/YYYY")
895                : moment().clone().startOf('week').format("DD/MM/YYYY");
896            this._loadData();
897        }
898        , _inClickXemToday: function () {
899
900            if ($scope.LichTuan._danhSach != undefined && $scope.LichTuan._danhSach.length > 0) {
901                $scope.LichTuan._danhSach = $scope.LichTuan._danhSach.filter(x => x.Ngay == $scope.LichTuan._formatDate(new Date()));
902            } else {
903
904                $scope.LichTuan._selected = [];
905                $scope.LichTuan._pagingInfo.search = null;
906                $scope.LichTuan._weekStart = $scope.LichTuan._formatDate(new Date());
907                $scope.LichTuan._weekEnd = $scope.LichTuan._formatDate(new Date());
908                $scope.LichTuan._loadData();
909            }
910
911        }
912        , _formatDate: function (date) {
913            var d = moment(date).utcOffset('+07:00');
914            const day = String(d.date()).padStart(2, '0');
915            const month = String(d.month() + 1).padStart(2, '0');
916            const year = d.year();
917            return `${day}-${month}-${year}`;
918        }
919        , _updateSelected: function (action, id) {
920            if (action === 'add' && this._selected.indexOf(id) === -1) {
921                this._selected.push(id);
922            }
923            if (action === 'remove' && this._selected.indexOf(id) !== -1) {
924                this._selected.splice(this._selected.indexOf(id), 1);
925            }
926        }
927        , _updateSelection: function ($event, id) {
928            var checkbox = $event.target;
929            var action = (checkbox.checked ? 'add' : 'remove');
930            $scope.LichTuan._updateSelected(action, id);
931        }
932        , _isSelected: function (id) {
933            return this._selected.indexOf(id) >= 0;
934        }
935        , _getSelectedClass: function (entity) {
936            return $scope.LichTuan._isSelected(entity) ? 'selected' : '';
937        }
938        , _selectAll: function ($event) {
939            var checkbox = $event.target;
940            var action = (checkbox.checked ? 'add' : 'remove');
941            angular.forEach($scope.LichTuan._danhSach, function (dt) {
942                angular.forEach(dt.LichTuans, function (entity) {
943                    $scope.LichTuan._updateSelected(action, entity.Id);
944                })
945            });
946        }
947        , _isSelectedAll: function () {
948            var lenghCheck = 0;
949            angular.forEach($scope.LichTuan._danhSach, function (dt) {
950                angular.forEach(dt.LichTuans, function (entity) {
951                    lenghCheck++;
952                })
953            });
954            return lenghCheck == 0 ? false : this._selected.length === lenghCheck;
955
956        }
957        , _importExcel: function () {
958            if ($scope.LichTuan._danhSachTep.length == 0) {
959                toaster.pop("error", $scope._Resource.MeasageError, $scope._Resource.MeasageSelectFileExcel, 2000);
960                return;
961            }
962
963            LichTuanManageService.Import($scope.LichTuan._danhSachTep[0], this._dataTemp.CapApDung).then(function (success) {
964                toaster.pop('success', $rootScope.Resource.Successfully, $rootScope.Resource.Successfully, 3000);
965            }, function (error) {
966                toaster.pop('error', $rootScope.Resource.MeasageError, $rootScope.Resource.tstUnsuccessful, 3000);
967            });
968        }
969        , _exportExcel: function (value) {
970            LichTuanManageService.ExportExcel(this._pagingInfo, value).then(function (success) {
971                var href = ngAuthSettings.apiServiceBaseUri + "temp/Upload/reports.xls";
972
973                window.location.href = href;
974
975                toaster.pop('success', $rootScope.Resource.Successfully, $rootScope.Resource.Successfully, 3000);
976
977            }, function (error) {
978                toaster.pop("error", $scope._Resource.MeasageError, error.data, 2000);
979            })
980        }
981        , _clickDowloadWord: function () {
982            var href = ngAuthSettings.apiServiceBaseUri + "api/v1/reports/LichCongViec?filter=" + encodeURI(this._pagingInfo.filter) + "&sNgayKetThuc=" + encodeURI(this._pagingInfo.sNgayKetThuc);
983
984            window.location.href = href;
985        }
986        , _uploadLichTuan: function () {
987
988            if (this._danhSachTepLichTuan.length == 0) {
989                toaster.pop("error", $scope._Resource.MeasageError, "Chọn file upload", 2000);
990                return;
991            }
992
993            this._danhSachTepLichTuan[0].WeekOfYear = moment(this._weekStart, ["DD/MM/YYYY", "MM/DD/YYYY"]).isoWeek();
994            this._danhSachTepLichTuan[0].Year = moment(this._weekStart, ["DD/MM/YYYY", "MM/DD/YYYY"]).year();
995
996            LichTuanManageService.UploadLichTuan(this._danhSachTepLichTuan[0], this._pagingInfo.sNgayBatDau).then(function (success) {
997                toaster.pop('success', $rootScope.Resource.Successfully, $rootScope.Resource.Successfully, 3000);
998            }, function (error) {
999                toaster.pop('error', $rootScope.Resource.MeasageError, $rootScope.Resource.tstUnsuccessful, 3000);
1000            })
1001        }
1002        , _aClickXoaTepLichTuan: function (tep) {
1003
1004            LichTuanManageService.XoaTepLichTuan(tep).then(function (success) {
1005                toaster.pop('success', $rootScope.Resource.Successfully, $rootScope.Resource.Successfully, 3000);
1006            }, function (error) {
1007                toaster.pop('error', $rootScope.Resource.MeasageError, $rootScope.Resource.tstUnsuccessful, 3000);
1008            })
1009        }
1010        , _inputKeyupSearch: function () {
1011            if ($('#tuancuanam').val() == '') {
1012                $scope.LichTuan.MoTaLich.Tuan = 1;
1013            }
1014            else {
1015                //nếu nhập tuần lớn hơn 52 thì trả về tuần đầu tiên
1016                if ($('#tuancuanam').val() > 52 || $('#tuancuanam').val() < 1) {
1017                    $scope.LichTuan.MoTaLich.Tuan = 1;
1018                    $('#tuancuanam').val($scope.LichTuan.MoTaLich.Tuan);
1019                }
1020                // ngược lại binding tuần mặc định
1021                else {
1022                    $scope.LichTuan.MoTaLich.Tuan = $('#tuancuanam').val();
1023                }
1024            }
1025            if ($('#namHienTai').val() == '') {
1026                $scope.LichTuan.MoTaLich.Nam = (new Date()).getFullYear();
1027            }
1028            else {
1029                $scope.LichTuan.MoTaLich.Nam = $('#namHienTai').val();
1030            }
1031
1032            $scope.LichTuan._pagingInfo.tuanCuaNam = $scope.LichTuan.MoTaLich.Tuan;
1033
1034            //lấy ngày đầu tiên của tuần
1035            var ngayBatDau = $scope.LichTuan._getFirstDayByWeek($scope.LichTuan.MoTaLich.Tuan, $('#namHienTai').val());
1036
1037            var firstDay = moment(ngayBatDau).format('DD/MM/YYYY');
1038
1039            //lấy ngày cuối cùng của tuần
1040            var ngayKetThuc = $scope.LichTuan._getLastDayByWeek($scope.LichTuan.MoTaLich.Tuan, $('#namHienTai').val());
1041
1042            var lastDay = moment(ngayKetThuc).format('DD/MM/YYYY');
1043
1044            $scope.LichTuan._weekStart = firstDay;
1045            $scope.LichTuan._weekEnd = lastDay;
1046
1047            $scope.LichTuan._loadData();
1048        }
1049        , _getFirstDayByWeek: function (week, year) {
1050            var d = new Date("Jan 01, " + year + " 01:00:00");
1051            var dayMs = (24 * 60 * 60 * 1000);
1052            var offSetTimeStart = dayMs * (d.getDay() - 1);
1053            var w = d.getTime() + 604800000 * (week - 1) - offSetTimeStart; //reducing the offset here
1054            var n1 = new Date(w);
1055            //var n2 = new Date(w + 518400000);
1056            return n1;
1057
1058        }
1059        , _getLastDayByWeek: function (week, year) {
1060            var d = new Date("Jan 01, " + year + " 01:00:00");
1061            var dayMs = (24 * 60 * 60 * 1000);
1062            var offSetTimeStart = dayMs * (d.getDay() - 1);
1063            var w = d.getTime() + 604800000 * (week - 1) - offSetTimeStart; //reducing the offset here
1064            //var n1 = new Date(w);
1065            var n2 = new Date(w + 518400000);
1066            return n2;
1067        }
1068        , _updateTrangThai: function (value) {
1069            debugger;
1070            if ($scope.LichTuan._selected.length >= 1) {
1071                angular.forEach($scope.LichTuan._selected, function (dt) {
1072                    LichTuanManageService.UpdateTrangThai(dt, value).then(function (success) {
1073                        $scope.LichTuan._loadData();
1074                    }, function (error) {
1075                        toaster.pop('error', $rootScope.Resource.MeasageError, error.data/*$rootScope.Resource.tstUnsuccessful*/, 3000);
1076                    })
1077                });
1078
1079            } else {
1080                toaster.pop("error", $scope._Resource.MeasageError, $scope._Resource.MeasagePleaseSelectScheduleUpdateStatus, 2000);
1081            }
1082        }
1083        , _XoaLichTamThoi: function (value) {
1084            if ($scope.LichTuan._selected.length >= 1) {
1085                angular.forEach($scope.LichTuan._selected, function (dt) {
1086                    LichTuanManageService.XoaLichTamThoi(dt, value).then(function (success) {
1087                        toaster.pop('success', $rootScope.Resource.Successfully, $rootScope.Resource.Successfully, 3000);
1088                        $scope.LichTuan._loadData();
1089                        $scope.LichTuan._selected = [];
1090                    }, function (error) {
1091                        toaster.pop('error', $rootScope.Resource.MeasageError, error.data/*$rootScope.Resource.tstUnsuccessful*/, 3000);
1092                    })
1093                });
1094
1095            } else {
1096                toaster.pop("error", $scope._Resource.MeasageError, $scope._Resource.tbDeleted, 2000);
1097            }
1098        }
1099        , _selectChangeTrangThai: function () {
1100            this._loadData();
1101        }
1102        , _LichTruong: function () {
1103            this._dataTemp.CapApDung = 1;
1104            this._loadData();
1105        }
1106        , _DonVi: function () {
1107            this._dataTemp.CapApDung = 2;
1108            this._loadData();
1109        }
1110        , _LichBaoVeLuanAn: function () {
1111            this._dataTemp.CapApDung = 3;
1112            this._loadData();
1113        }
1114    };
1115    $scope.getTimePart = function (datetime) {
1116        if (!datetime) return '';
1117        var date = new Date(datetime);
1118        var hours = date.getUTCHours().toString().padStart(2, '0');
1119        var minutes = date.getUTCMinutes().toString().padStart(2, '0');
1120        return hours + ":" + minutes;
1121    }
1122    function parseDateDDMMYYYY(str) {
1123        var parts = str.split('/');
1124        return new Date(parts[2], parts[1] - 1, parts[0]);
1125    }
1126    $scope.LichTuan._loadData();
1127});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.