1 |
efrain |
1 |
require(['core/first', 'jquery', 'jqueryui', 'core/ajax', 'pnotify', 'select2', 'moment'], function(core, $, bootstrap, ajax, pnotify, select2, moment) {
|
|
|
2 |
$(document).ready(function() {
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
$('#form_custom #filter_from').datepicker({
|
|
|
6 |
dateFormat: "yy-mm-dd",
|
|
|
7 |
dayNamesMin: [ "Di", "Lu", "Ma", "Mi", "Ju", "Vi", "Sa" ],
|
|
|
8 |
monthNames: [ "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre" ],
|
|
|
9 |
onSelect: function (dateText, inst) {
|
|
|
10 |
|
|
|
11 |
$('#form_custom #filter_to').datepicker('option', 'minDate', moment(dateText).toDate());
|
|
|
12 |
$(this).datepicker( "hide" );
|
|
|
13 |
$('#div-local-cesa-reportes-custom').empty();
|
|
|
14 |
}
|
|
|
15 |
});
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
$('#form_custom #filter_to').datepicker({
|
|
|
19 |
dateFormat: "yy-mm-dd",
|
|
|
20 |
minDate: new Date(2023, 1 - 1, 1),
|
|
|
21 |
dayNamesMin: [ "Di", "Lu", "Ma", "Mi", "Ju", "Vi", "Sa" ],
|
|
|
22 |
monthNames: [ "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre" ],
|
|
|
23 |
onSelect: function (dateText, inst) {
|
|
|
24 |
$(this).datepicker( "hide" );
|
|
|
25 |
$('#div-local-cesa-reportes-custom').empty();
|
|
|
26 |
}
|
|
|
27 |
|
|
|
28 |
});
|
|
|
29 |
|
|
|
30 |
$('#form_custom #filter_userkeyword').change(function(e) {
|
|
|
31 |
e.preventDefault();
|
|
|
32 |
$('#div-local-cesa-reportes-custom').empty();
|
|
|
33 |
|
|
|
34 |
});
|
|
|
35 |
|
|
|
36 |
|
|
|
37 |
|
|
|
38 |
$.fn.reload = function() {
|
|
|
39 |
|
|
|
40 |
$('.ccn_preloader_load').show();
|
|
|
41 |
|
|
|
42 |
|
|
|
43 |
$('#div-local-cesa-reportes-custom').empty();
|
|
|
44 |
|
|
|
45 |
|
|
|
46 |
ajax.call([{
|
|
|
47 |
methodname: 'local_cesa_reportes_report_custom',
|
|
|
48 |
args: {
|
|
|
49 |
'filter_from': $('#form_custom #filter_from').val(),
|
|
|
50 |
'filter_to': $('#form_custom #filter_to').val(),
|
|
|
51 |
'filter_userkeyword': $('#form_custom #filter_userkeyword').val(),
|
|
|
52 |
},
|
|
|
53 |
|
|
|
54 |
|
|
|
55 |
}])[0].done(function(response) {
|
|
|
56 |
$('.ccn_preloader_load').hide();
|
|
|
57 |
|
|
|
58 |
var json = JSON.parse(response);
|
|
|
59 |
|
|
|
60 |
if(json.success) {
|
|
|
61 |
$('#div-local-cesa-reportes-custom').html(json.data);
|
|
|
62 |
}
|
|
|
63 |
return;
|
|
|
64 |
}).fail(function(err) {
|
|
|
65 |
$('.ccn_preloader_load').hide();
|
|
|
66 |
|
|
|
67 |
return;
|
|
|
68 |
|
|
|
69 |
});
|
|
|
70 |
}
|
|
|
71 |
|
|
|
72 |
$('#btn-recargar-reporte-custom').click(function(e) {
|
|
|
73 |
e.preventDefault();
|
|
|
74 |
$.fn.reload();
|
|
|
75 |
|
|
|
76 |
});
|
|
|
77 |
|
|
|
78 |
|
|
|
79 |
$('#btn-download-excel-custom').click(function(e) {
|
|
|
80 |
e.preventDefault();
|
|
|
81 |
|
|
|
82 |
$('.ccn_preloader_load').show();
|
|
|
83 |
$('#btn-download-excel-custom').prop('disabled', true);
|
|
|
84 |
|
|
|
85 |
ajax.call([{
|
|
|
86 |
methodname: 'local_cesa_reportes_excel_report_custom',
|
|
|
87 |
args: {
|
|
|
88 |
'filter_from': $('#form_custom #filter_from').val(),
|
|
|
89 |
'filter_to': $('#form_custom #filter_to').val(),
|
|
|
90 |
'filter_userkeyword': $('#form_custom #filter_userkeyword').val(),
|
|
|
91 |
},
|
|
|
92 |
}])[0].done(function(response) {
|
|
|
93 |
|
|
|
94 |
$('.ccn_preloader_load').hide();
|
|
|
95 |
$('#btn-download-excel-custom').prop('disabled', false);
|
|
|
96 |
|
|
|
97 |
var json = JSON.parse(response);
|
|
|
98 |
|
|
|
99 |
if(json.success) {
|
|
|
100 |
new pnotify({
|
|
|
101 |
title: false,
|
|
|
102 |
text: json.data,
|
|
|
103 |
type: 'success',
|
|
|
104 |
hide: true,
|
|
|
105 |
delay: 2000,
|
|
|
106 |
addclass: "stack-modal",
|
|
|
107 |
});
|
|
|
108 |
} else {
|
|
|
109 |
new pnotify({
|
|
|
110 |
title: false,
|
|
|
111 |
text: json.data,
|
|
|
112 |
type: 'error',
|
|
|
113 |
hide: true,
|
|
|
114 |
delay: 2000,
|
|
|
115 |
addclass: "stack-modal",
|
|
|
116 |
});
|
|
|
117 |
}
|
|
|
118 |
|
|
|
119 |
|
|
|
120 |
return;
|
|
|
121 |
}).fail(function(err) {
|
|
|
122 |
$('.ccn_preloader_load').hide();
|
|
|
123 |
$('#btn-download-excel-custom').prop('disabled', false);
|
|
|
124 |
|
|
|
125 |
return;
|
|
|
126 |
});
|
|
|
127 |
|
|
|
128 |
});
|
|
|
129 |
|
|
|
130 |
$.fn.reload();
|
|
|
131 |
|
|
|
132 |
dateText = $('#form_custom #filter_from').val().trim();
|
|
|
133 |
$('#form_custom #filter_to').datepicker('option', 'minDate', moment(dateText).toDate() );
|
|
|
134 |
|
|
|
135 |
|
|
|
136 |
});
|
|
|
137 |
});
|