| 17019 |
efrain |
1 |
<?php
|
|
|
2 |
$acl = $this->viewModel()->getRoot()->getVariable('acl');
|
|
|
3 |
$currentUser = $this->currentUserHelper();
|
|
|
4 |
|
|
|
5 |
$roleName = $currentUser->getUserTypeId();
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
$routeDatatable = $this->url('habits/progress');
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/nprogress/nprogress.css'));
|
|
|
12 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/nprogress/nprogress.js'));
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/select2/js/select2.js'));
|
|
|
17 |
$this->inlineScript()->appendFile($this->basePath('assets/vendors/select2/js/i18n/es.js'));
|
|
|
18 |
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/select2/css/select2.css'));
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
$columns = "var columns = new Array(); \r\n";
|
|
|
25 |
$columns .= "columns[0] = 'date'; \r\n";
|
|
|
26 |
|
|
|
27 |
$i = 1;
|
|
|
28 |
foreach($categories as $category_id => $category_name)
|
|
|
29 |
{
|
|
|
30 |
$columns .= "columns[$i] = 'cat_{$category_id}'; \r\n";
|
|
|
31 |
$i++;
|
|
|
32 |
}
|
|
|
33 |
|
|
|
34 |
$columns .= "columns[$i] = 'content'; \r\n";
|
|
|
35 |
|
|
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
|
40 |
$this->inlineScript()->captureStart();
|
|
|
41 |
echo <<<JS
|
|
|
42 |
jQuery( document ).ready(function( $ ) {
|
|
|
43 |
|
|
|
44 |
$columns
|
|
|
45 |
var page = 1;
|
|
|
46 |
var maxPage = 1;
|
|
|
47 |
|
|
|
48 |
$.fn.loadRecords = function() {
|
|
|
49 |
|
|
|
50 |
NProgress.start();
|
|
|
51 |
$.ajax({
|
|
|
52 |
'dataType' : 'json',
|
|
|
53 |
'accept' : 'application/json',
|
|
|
54 |
'method' : 'get',
|
|
|
55 |
'url' : '$routeDatatable',
|
|
|
56 |
'data' : {
|
|
|
57 |
'id' : $('#form-filter #user_id').val(),
|
|
|
58 |
'page' : page
|
|
|
59 |
}
|
|
|
60 |
}).done(function(response) {
|
|
|
61 |
|
|
|
62 |
if(response['success']) {
|
|
|
63 |
|
|
|
64 |
total = parseInt(response['data']['total'])
|
|
|
65 |
maxPage = total / 10;
|
|
|
66 |
if(maxPage * 10 < total) {
|
|
|
67 |
maxPage++;
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
|
|
|
71 |
|
|
|
72 |
|
|
|
73 |
if(page >= maxPage) {
|
|
|
74 |
$('button.btn-load-more').hide();
|
|
|
75 |
} else {
|
|
|
76 |
$('button.btn-load-more').show();
|
|
|
77 |
}
|
|
|
78 |
|
|
|
79 |
|
|
|
80 |
response['data']['items'].forEach(function(item) {
|
|
|
81 |
|
|
|
82 |
var s = '<tr>';
|
|
|
83 |
|
|
|
84 |
columns.forEach(function(column) {
|
|
|
85 |
|
|
|
86 |
|
|
|
87 |
s += '<td>' + item[column] + '</td>';
|
|
|
88 |
|
|
|
89 |
|
|
|
90 |
});
|
|
|
91 |
|
|
|
92 |
console.log(s)
|
|
|
93 |
|
|
|
94 |
$('#gridTable tbody').append(s)
|
|
|
95 |
|
|
|
96 |
});
|
|
|
97 |
|
|
|
98 |
} else {
|
|
|
99 |
$.fn.showError(response['data']);
|
|
|
100 |
|
|
|
101 |
}
|
|
|
102 |
}).fail(function( jqXHR, textStatus, errorThrown) {
|
|
|
103 |
$.fn.showError(textStatus);
|
|
|
104 |
}).always(function() {
|
|
|
105 |
NProgress.done();
|
|
|
106 |
});
|
|
|
107 |
return false;
|
|
|
108 |
|
|
|
109 |
|
|
|
110 |
}
|
|
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
|
114 |
|
|
|
115 |
|
|
|
116 |
|
|
|
117 |
|
|
|
118 |
$('body').on('click', 'button.btn-load-more', function(e) {
|
|
|
119 |
e.preventDefault();
|
|
|
120 |
|
|
|
121 |
page = page + 1;
|
|
|
122 |
$.fn.loadRecords();
|
|
|
123 |
});
|
|
|
124 |
|
|
|
125 |
$('#form-filter #user_id').change(function(e) {
|
|
|
126 |
e.preventDefault();
|
|
|
127 |
|
|
|
128 |
|
|
|
129 |
$('#gridTable tbody').empty();
|
|
|
130 |
page = 1;
|
|
|
131 |
maxPage = 1;
|
|
|
132 |
$.fn.loadRecords();
|
|
|
133 |
|
|
|
134 |
|
|
|
135 |
});
|
|
|
136 |
|
|
|
137 |
$('#form-filter #user_id').select2({
|
|
|
138 |
theme: 'bootstrap-5',
|
|
|
139 |
width: '100%',
|
|
|
140 |
//dropdownParent: $('#modal'),
|
|
|
141 |
});
|
|
|
142 |
|
|
|
143 |
$.fn.loadRecords();
|
|
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
|
147 |
|
|
|
148 |
});
|
|
|
149 |
JS;
|
|
|
150 |
$this->inlineScript()->captureEnd();
|
|
|
151 |
?>
|
|
|
152 |
|
|
|
153 |
|
|
|
154 |
<div class="container">
|
|
|
155 |
<div class="card">
|
|
|
156 |
<div class="card-header">
|
|
|
157 |
<h6 class="card-title">LABEL_PROGRESS</h6>
|
|
|
158 |
</div>
|
|
|
159 |
<div class="card-body">
|
|
|
160 |
<form name="form-filter" id="form-filter">
|
|
|
161 |
<div class="row">
|
|
|
162 |
<div class="col mt-3">
|
|
|
163 |
<label for="user_id" class="form-label">LABEL_USER</label>
|
|
|
164 |
<select name="user_id" id="user_id" class="form-control">
|
|
|
165 |
<?php foreach($users as $key => $value ) : ?>
|
|
|
166 |
<option value="<?php echo $key ?>"><?php echo $value ?></option>
|
|
|
167 |
<?php endforeach; ?>
|
|
|
168 |
|
|
|
169 |
</select>
|
|
|
170 |
|
|
|
171 |
|
|
|
172 |
|
|
|
173 |
</div>
|
|
|
174 |
</div>
|
|
|
175 |
</form>
|
|
|
176 |
<div class="row">
|
|
|
177 |
<div class="col mt-3">
|
|
|
178 |
<table id="gridTable" class="table table-bordered">
|
|
|
179 |
<thead>
|
|
|
180 |
<tr>
|
|
|
181 |
<th>LABEL_DATE</th>
|
|
|
182 |
<?php foreach($categories as $category_id => $category_name) : ?>
|
|
|
183 |
<th><?php echo $category_name ?></th>
|
|
|
184 |
<?php endforeach; ?>
|
|
|
185 |
<th>LABEL_CONTENT</th>
|
|
|
186 |
</tr>
|
|
|
187 |
</thead>
|
|
|
188 |
<tbody>
|
|
|
189 |
</tbody>
|
|
|
190 |
</table>
|
|
|
191 |
</div>
|
|
|
192 |
</div>
|
|
|
193 |
</div>
|
|
|
194 |
<div class="card-footer text-right">
|
|
|
195 |
<button type="button" style="display: none" class="btn btn-info btn-load-more"><i class="fa fa-sync"></i> LABEL_LOAD_MORE </button>
|
|
|
196 |
</div>
|
|
|
197 |
</div>
|
|
|
198 |
</div>
|
|
|
199 |
|