Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16992 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1320 efrain 1
<?php
2
$acl            = $this->viewModel()->getRoot()->getVariable('acl');
3
$currentUser    = $this->currentUserHelper();
4
 
5
$roleName = $currentUser->getUserTypeId();
6
 
15386 efrain 7
$allowDownload  = $acl->isAllowed($roleName, 'microlearning/reports/progress-for-capsule/excel') ? 1 : 0;
1320 efrain 8
 
16822 efrain 9
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/select2/css/select2.min.css'));
16918 efrain 10
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/select2-bootstrap5-theme/select2-bootstrap-5-theme.css'));
16822 efrain 11
$this->inlineScript()->appendFile($this->basePath('assets/vendors/select2/js/select2.min.js'));
15386 efrain 12
 
13
 
14
 
15389 efrain 15
 
16822 efrain 16
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/nprogress/nprogress.css'));
17
$this->inlineScript()->appendFile($this->basePath('assets/vendors/nprogress/nprogress.js'));
18
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jsrender/jsrender.js'));
1320 efrain 19
 
20
$this->headStyle()->captureStart();
21
echo <<<CSS
22
 
23
 
15390 efrain 24
#gridTable {
1320 efrain 25
    display: flex;
26
    flex-flow: column;
27
    width: 100%;
28
}
29
 
15390 efrain 30
#gridTable thead {
1320 efrain 31
    flex: 0 0 auto;
32
}
33
 
15390 efrain 34
#gridTable tbody {
1320 efrain 35
    flex: 1 1 auto;
36
    display: block;
37
    overflow-y: auto;
38
    overflow-x: hidden;
39
}
40
 
15390 efrain 41
#gridTable tr {
1320 efrain 42
    width: 100%;
43
    display: table;
44
    table-layout: fixed;
45
}
46
CSS;
47
$this->headStyle()->captureEnd();
48
 
49
 
50
 
51
$this->inlineScript()->captureStart();
52
echo <<<JS
53
jQuery( document ).ready(function( $ ) {
15386 efrain 54
 
55
 
1320 efrain 56
    $.fn.changeFilter = function() {
17349 stevensc 57
        // Validar que haya un tópico y una cápsula seleccionados
58
        var topicValue = $('#form-filter #topic_uuid').val();
59
        var capsuleValue = $('#form-filter #capsule_uuid').val();
60
 
61
        if (!topicValue || topicValue === '' || !capsuleValue || capsuleValue === '') {
62
            // Si no hay tópico o cápsula seleccionados, limpiar la tabla y ocultar el botón de descarga
63
            $('#gridTable tbody').empty();
64
            $('button.btn-download').hide();
65
            return false;
66
        }
67
 
1320 efrain 68
        NProgress.start();
69
        $.ajax({
70
            'dataType'  : 'json',
71
            'accept'    : 'application/json',
72
            'method'    : 'get',
73
            'url'       :  $('#form-filter').attr('action'),
74
            'data'      :  $('#form-filter').serialize(),
75
        }).done(function(response) {
76
            if(response['success']) {
77
 
15389 efrain 78
 
1320 efrain 79
 
15389 efrain 80
 
14614 efrain 81
                if(response['data']['capsules']) {
82
 
15389 efrain 83
                  $('#form-filter #capsule_uuid').empty();
14614 efrain 84
 
15389 efrain 85
                  $.each(response['data']['capsules'], function( value, label ) {
86
                        $('#form-filter #capsule_uuid').append($('<option>', {
87
                            value: value,
88
                            text: label
89
                        }));
90
                     });
15386 efrain 91
 
15389 efrain 92
 
93
                  $('#form-filter #capsule_uuid').val(response['data']['capsule_selected']).trigger('change');
14614 efrain 94
                }
95
 
96
                if(response['data']['items']) {
97
                    $('#gridTable tbody').empty();
98
                    $('#gridTable tbody').append(
99
                        $( "#progressRowTemplate" ).render( response['data']['items'] )
1320 efrain 100
 
14614 efrain 101
                    );
102
 
103
                }
1320 efrain 104
 
15386 efrain 105
                if(response['data']['link_download']) {
106
                    $('button.btn-download').data('href', response['data']['link_download']);
107
                    $('button.btn-download').show();
108
 
109
                } else {
110
                     $('button.btn-download').hide();
111
                }
112
 
1320 efrain 113
            } else {
114
                if(jQuery.type(response['data']) == 'string') {
115
                    $.fn.showError(response['data']);
116
                } else  {
117
                    $.each(response['data'], function( fieldname, errors ) {
14614 efrain 118
                        $.fn.showFormErrorValidator('#form-filter #' + fieldname, errors);
1320 efrain 119
                    });
120
                }
121
            }
122
        }).fail(function( jqXHR, textStatus, errorThrown) {
123
            $.fn.showError(textStatus);
124
        }).always(function() {
125
            NProgress.done();
126
        });
127
        return false;
128
    }
129
 
130
    $('#form-filter #topic_uuid').change(function(e) {
131
        e.preventDefault();
132
 
133
        $('#form-filter #capsule_uuid').empty();
17349 stevensc 134
        // Limpiar la tabla cuando se cambia el tópico y no hay cápsula seleccionada
135
        $('#gridTable tbody').empty();
136
        $('button.btn-download').hide();
1320 efrain 137
        $.fn.changeFilter();
138
    })
139
 
140
 
141
    $('#form-filter #capsule_uuid').change(function(e) {
142
        e.preventDefault();
143
 
144
        $.fn.changeFilter();
145
    })
146
 
15386 efrain 147
    $('button.btn-download').click(function(e) {
148
        e.preventDefault();
149
        var action   = $(this).data('href');
1320 efrain 150
 
15386 efrain 151
        NProgress.start();
152
        $.ajax({
153
            'dataType'  : 'json',
154
            'method'    : 'get',
155
            'url'       :  action,
156
        }).done(function(response) {
157
            if(response['success']) {
158
                var anchor = window.document.createElement("a");
159
                anchor.href = 'data:application/octet-stream;charset=utf-8;base64,' + response['data']['content'] ;
160
                anchor.download = response['data']['basename'];
161
                document.body.appendChild(anchor);
162
                anchor.click();  // IE: "Access is denied"; see: https://connect.microsoft.com/IE/feedback/details/797361/ie-10-treats-blob-url-as-cross-origin-and-denies-access
163
                document.body.removeChild(anchor);
164
            } else {
165
                $.fn.showError(response['data']);
166
            }
167
        }).fail(function( jqXHR, textStatus, errorThrown) {
168
            showError(textStatus);
169
        }).always(function() {
170
            NProgress.done();
171
        });
172
 
173
 
174
    });
175
 
176
 
177
    $('button.btn-refresh').click(function(e) {
178
        e.preventDefault();
179
        $.fn.changeFilter();
180
 
181
 
182
    });
183
 
15389 efrain 184
    $('#topic_uuid').select2({
16918 efrain 185
        theme: 'bootstrap-5',
15389 efrain 186
        width: '100%',
187
    });
15386 efrain 188
 
189
 
15389 efrain 190
 
191
    $('#capsule_uuid').select2({
16918 efrain 192
        theme: 'bootstrap-5',
15389 efrain 193
        width: '100%',
194
    });
195
 
196
 
197
 
198
 
199
 
200
 
17349 stevensc 201
    // No llamar changeFilter automáticamente al cargar la página
202
    // Solo se ejecutará cuando haya un tópico y cápsula seleccionados
15386 efrain 203
    $('button.btn-download').hide();
1320 efrain 204
 
205
});
206
JS;
207
$this->inlineScript()->captureEnd();
208
?>
209
 
16910 efrain 210
<div class="container">
211
	<div class="card" id="">
212
	 	<div class="card-header">
213
	 		<h6 class="card-title">LABEL_PROGRESS_FOR_CAPSULE</h6>
214
	 	</div>
215
	 	<div class="card-body">
216
 
217
	 	<?php
1320 efrain 218
                        $form = $this->form;
219
            	        $form->setAttributes([
220
                            'name'    => 'form-filter',
221
                            'id'      => 'form-filter',
222
                        ]);
223
 
224
                        $form->prepare();
225
                        echo $this->form()->openTag($form);
226
                        ?>
227
                        <div class="row">
16910 efrain 228
                            <div class="col-6 mt-3">
16929 efrain 229
                              	<?php
14614 efrain 230
                                    $element = $form->get('topic_uuid');
231
                                    $element->setOptions(['label' => 'LABEL_TOPIC']);
1320 efrain 232
 
14614 efrain 233
                                    $element->setAttributes(['class' => 'form-control']);
234
                                    echo $this->formLabel($element);
235
                                    echo $this->formSelect($element);
1320 efrain 236
                                    ?>
16929 efrain 237
 
1320 efrain 238
                            </div>
16910 efrain 239
                            <div class="col-6 mt-3">
240
 
1320 efrain 241
                                    <?php
14614 efrain 242
                                    $element = $form->get('capsule_uuid');
243
                                    $element->setOptions(['label' => 'LABEL_CAPSULE']);
244
                                    $element->setAttributes(['class' => 'form-control']);
245
                                    echo $this->formLabel($element);
246
                                    echo $this->formSelect($element);
1320 efrain 247
                                    ?>
16910 efrain 248
 
1320 efrain 249
                            </div>
16910 efrain 250
 
15386 efrain 251
 
1320 efrain 252
                        </div>
253
						<?php echo $this->form()->closeTag($form); ?>
16910 efrain 254
 
255
 
256
	 		<div class="row">
257
	 	         <div class="col-12 mt-3">
258
 
259
	 	             		<table id="gridTable" class="table   table-bordered">
1320 efrain 260
                      		<thead>
261
        						<tr>
15390 efrain 262
									<th >LABEL_FIRST_NAME</th>
263
									<th>LABEL_LAST_NAME</th>
264
									<th>LABEL_EMAIL</th>
265
                      				<th >LABEL_REPORTS_PROGRESS</th>
14614 efrain 266
 
1320 efrain 267
                                </tr>
268
                       		</thead>
269
                         	<tbody>
270
                         	</tbody>
271
                    	</table>
16910 efrain 272
 
273
	 	         </div>
274
	 	     </div>
275
	 	</div>
276
	 	<div class="card-footer text-right">
16992 efrain 277
	 	                    <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-sync"></i> LABEL_REFRESH  </button>
16910 efrain 278
                                    <?php if($allowDownload) :  ?>
279
 
280
                					<button type="button" class="btn btn-info btn-download"><i class="fa fa-download"></i> LABEL_DOWNLOAD  </button>
281
                					<?php endif;?>
282
	 	</div>
283
	</div>
284
</div>
1320 efrain 285
 
286
 
287
 
288
<script id="progressRowTemplate" type="text/x-jsrender">
289
    <tr>
15390 efrain 290
        <td>
1320 efrain 291
            {{>first_name}}
292
        </td>
15390 efrain 293
        <td>
1320 efrain 294
             {{>last_name}}
295
        </td>
15390 efrain 296
        <td>
1320 efrain 297
            {{>email}}
298
        </td>
299
 
15390 efrain 300
        <td>
14614 efrain 301
 
302
 
303
            <div class="progress progress-xs progress-striped active" style="height: 15px">
304
                <div class="progress-bar {{if completed == '1' }} bg-success {{ else }} bg-primary {{/if}}" style="width: {{>progress}}%">
305
{{>progress}}  %
306
                </div>
1320 efrain 307
            </div>
308
        </td>
14614 efrain 309
 
1320 efrain 310
    </tr>
15390 efrain 311
    <tr>
312
 
313
                    <td class="text-right">LABEL_REPORTS_TOTAL_SLIDES</td>
314
                    <td class="text-right">LABEL_REPORTS_VIEW_SLIDES</td>
315
                    <td>LABEL_REPORTS_FIRST_DATE</td>
316
                    <td>LABEL_REPORTS_LAST_DATE</td>
317
                </tr>
318
 
319
 
320
                <tr>
321
                    <td class="text-right">{{>total_slides}}</td>
322
                    <td class="text-right">{{>view_slides}}</td>
323
                    <td>{{>added_on}}</td>
324
                    <td>{{>updated_on}}</td>
325
                </tr>
326
 
327
 
328
 
329
 
330
     </tr>
1320 efrain 331
</script>
332
 
333
 
334
 
335
 
336
 
337
 
338