Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16822 | Rev 16910 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
15390 efrain 1
<?php
2
$acl            = $this->viewModel()->getRoot()->getVariable('acl');
3
$currentUser    = $this->currentUserHelper();
4
 
5
$routeReports = $this->url('microlearning/reports/devices-and-access');
6
 
7
$roleName = $currentUser->getUserTypeId();
8
$allowDownload  = $acl->isAllowed($roleName, 'microlearning/reports/devices-and-access/excel') ? 1 : 0;
9
 
10
 
11
 
16822 efrain 12
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/select2/css/select2.min.css'));
13
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/select2-bootstrap4-theme/select2-bootstrap4.min.css'));
14
$this->inlineScript()->appendFile($this->basePath('assets/vendors/select2/js/select2.min.js'));
15390 efrain 15
 
16
 
17
 
18
 
16822 efrain 19
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/nprogress/nprogress.css'));
20
$this->inlineScript()->appendFile($this->basePath('assets/vendors/nprogress/nprogress.js'));
21
$this->inlineScript()->appendFile($this->basePath('assets/vendors/jsrender/jsrender.js'));
15390 efrain 22
 
23
$this->headStyle()->captureStart();
24
echo <<<CSS
25
 
26
 
27
#tableDevices {
28
    display: flex;
29
    flex-flow: column;
30
    width: 100%;
31
}
32
 
33
#tableDevices thead {
34
    flex: 0 0 auto;
35
}
36
 
37
#tableDevices tbody {
38
    flex: 1 1 auto;
39
    display: block;
40
    overflow-y: auto;
41
    overflow-x: hidden;
42
}
43
 
44
#tableDevices tr {
45
    width: 100%;
46
    display: table;
47
    table-layout: fixed;
48
}
49
CSS;
50
$this->headStyle()->captureEnd();
51
 
52
 
53
 
54
$this->inlineScript()->captureStart();
55
echo <<<JS
56
jQuery( document ).ready(function( $ ) {
57
 
58
    $.fn.changeFilter = function() {
59
        NProgress.start();
60
        $.ajax({
61
            'dataType'  : 'json',
62
            'accept'    : 'application/json',
63
            'method'    : 'get',
64
            'url'       :  $('#form-filter').attr('action'),
65
            'data'      :  $('#form-filter').serialize(),
66
        }).done(function(response) {
67
            if(response['success']) {
68
 
69
                $('#tableDevices tbody').empty();
70
                $('#tableDevices tbody').append(
71
                     $( "#deviceRowTemplate" ).render( response['data']['items'] )
72
 
73
                );
74
 
75
                if(response['data']['link_download']) {
76
                    $('button.btn-download').data('href', response['data']['link_download']);
77
                    $('button.btn-download').show();
78
 
79
                } else {
80
                     $('button.btn-download').hide();
81
                }
82
 
83
 
84
            } else {
85
                if(jQuery.type(response['data']) == 'string') {
86
                    $.fn.showError(response['data']);
87
                } else  {
88
                    $.each(response['data'], function( fieldname, errors ) {
89
                        $.fn.showFormErrorValidator('#form-slide-video-edit #' + fieldname, errors);
90
                    });
91
                }
92
            }
93
        }).fail(function( jqXHR, textStatus, errorThrown) {
94
            $.fn.showError(textStatus);
95
        }).always(function() {
96
            NProgress.done();
97
        });
98
        return false;
99
    }
100
 
101
 
102
    $('#form-filter select').change(function(e) {
103
        e.preventDefault();
104
        $.fn.changeFilter();
105
 
106
    });
107
 
108
 
109
    $('#form-filter select').select2({
110
        theme: 'bootstrap4',
111
        width: '100%',
112
    });
113
 
114
 
115
 
116
 
117
 
118
    $('#form-filter #student_type_id').change(function(e) {
119
        e.preventDefault();
120
        $.fn.changeFilter();
121
 
122
    });
123
 
124
    $('button.btn-refresh').click(function(e) {
125
        e.preventDefault();
126
        $.fn.changeFilter();
127
 
128
 
129
    });
130
 
131
    $('button.btn-download').click(function(e) {
132
        e.preventDefault();
133
        var action   = $(this).data('href');
134
 
135
        NProgress.start();
136
        $.ajax({
137
            'dataType'  : 'json',
138
            'method'    : 'get',
139
            'url'       :  action,
140
        }).done(function(response) {
141
            if(response['success']) {
142
                var anchor = window.document.createElement("a");
143
                anchor.href = 'data:application/octet-stream;charset=utf-8;base64,' + response['data']['content'] ;
144
                anchor.download = response['data']['basename'];
145
                document.body.appendChild(anchor);
146
                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
147
                document.body.removeChild(anchor);
148
            } else {
149
                $.fn.showError(response['data']);
150
            }
151
        }).fail(function( jqXHR, textStatus, errorThrown) {
152
            showError(textStatus);
153
        }).always(function() {
154
            NProgress.done();
155
        });
156
 
157
 
158
    });
159
 
160
    $.fn.changeFilter();
161
 
162
});
163
JS;
164
$this->inlineScript()->captureEnd();
165
?>
166
 
167
<!-- Content Header (Page header) -->
168
<section class="content-header">
169
	<div class="container-fluid">
170
    	<div class="row mb-2">
171
        	<div class="col-sm-12">
172
            	<h1>LABEL_DEVICES_AND_ACCESS</h1>
173
			</div>
174
		</div>
175
	</div><!-- /.container-fluid -->
176
</section>
177
 
178
<section class="content">
179
	<div class="container-fluid">
180
		<div class="row">
16891 efrain 181
			<div class="col-12 mt-3">
15390 efrain 182
				<div class="card card-primary collapsed-card">
183
              		<div class="card-header">
184
                		<h3 class="card-title"><button type="button" data-card-widget="collapse"><i class="fa fa-filter"></i>  LABEL_FILTERS</button></h3>
185
 
186
                        <!-- /.card-tools -->
187
              		</div>
188
                    <!-- /.card-header -->
189
              		<div class="card-body">
190
                		<form name="form-filter" id="form-filter" action="<?php echo $routeReports ?>">
191
                		<?php
192
                    $fields = [
193
                        [
194
                            'label' => 'LABEL_COMPANIES',
195
                            'name' => 'company_id',
196
                        ],
197
                        [
198
                            'label' => 'LABEL_FUNCTIONS',
199
                            'name' => 'function_id',
200
                        ],
201
                        [
202
                            'label' => 'LABEL_GROUPS',
203
                            'name' => 'group_id',
204
                        ],
205
                        [
206
                            'label' => 'LABEL_INSTITUTIONS',
207
                            'name' => 'institution_id',
208
                        ],
209
                        [
210
                            'label' => 'LABEL_PROGRAMS',
211
                            'name' => 'program_id',
212
                        ],
213
                        [
214
                            'label' => 'LABEL_PARTNERS',
215
                            'name' => 'partner_id',
216
                        ],
217
                        [
218
                            'label' => 'LABEL_SECTORS',
219
                            'name' => 'sector_id',
220
                        ],
221
                        [
222
                            'label' => 'LABEL_STUDENT_TYPES',
223
                            'name' => 'student_type_id',
224
                        ],
225
                    ];
226
 
227
                    $column = 0;
228
                    foreach($fields as $field) :
229
                        if($column == 0) {
230
                            echo '<div class="row">';
231
 
232
                        }
233
                        $column++;
234
 
235
                    ?>
236
 
237
 
238
                             <div class="col-md-6 col-sm-12">
239
    					<div class="form-group">
240
        					<?php
241
                            $element = $form->get( $field['name'] );
242
                            $element->setOptions(['label' => $field['label'] ]);
243
                            $element->setAttributes(['class' => 'form-control']);
244
 
245
                            echo $this->formLabel($element);
246
                            echo $this->formSelect($element);
247
                            ?>
248
						</div>
249
						</div>
250
						<?php
251
						if($column == 2) {
252
						    $column = 0;
253
						    echo '</div>';
254
						}
255
						?>
256
					<?php endforeach; ?>
257
						<?php if($column) {
258
						    echo '</div>';
259
						}
260
						?>
261
                		</form>
262
              		</div>
263
                <!-- /.card-body -->
264
            	</div>
265
			</div>
266
		</div>
267
 
268
    	<div class="row">
16891 efrain 269
        	<div class="col-12 mt-3">
15390 efrain 270
 
271
				<div class="card">
272
					<div class="card-header">
273
 
274
 
275
                            <div
276
                                class="col-md-12 col-sm-12"
277
                            >
278
                                <div style="float:right;">
279
                                    <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH  </button>
280
                                    <?php if($allowDownload) :  ?>
281
 
282
                					<button type="button" class="btn btn-info btn-download"><i class="fa fa-download"></i> LABEL_DOWNLOAD  </button>
283
                					<?php endif;?>
284
                                </div>
285
                            </div>
286
 
287
					</div>
288
              		<div class="card-body p-0">
289
                		<table class="table table-responsive" id="tableDevices" >
290
                  			<thead>
291
                    			<tr>
292
 
293
                      				<th>LABEL_FIRST_NAME</th>
294
                      				<th>LABEL_LAST_NAME</th>
295
                      				<th>LABEL_EMAIL</th>
296
 
297
 
298
                    			</tr>
299
                  			</thead>
300
                  			<tbody>
301
 
302
                 			</tbody>
303
                		</table>
304
              		</div>
305
             		 <!-- /.card-body -->
306
            	</div>
307
 
308
 
309
           	</div>
310
        </div>
311
 	</div>
312
</section>
313
 
314
 
315
<script id="deviceRowTemplate" type="text/x-jsrender">
316
    <tr>
317
        <td> {{>first_name}} </td>
318
        <td> {{>last_name}} </td>
319
        <td> {{>email}} </td>
320
    </tr>
321
 
322
 
323
        <tr>
324
            <td colspan="3">
325
                <table class="table table-bordered">
326
                    <thead>
327
                        <tr>
328
                            <td>Marca</td>
329
                            <td>Fabricante</td>
330
                            <td>Modelo</td>
331
                            <td>Plataforma</td>
332
 
333
                            <td>Versión</td>
334
                             <td>Push</td>
335
                            <td>Ult.uso</td>
336
                        </tr>
337
                    </thead>
338
                    <tbody>
339
 
340
                            <tr>
341
                                <td>{{>brand}}</td>
342
                                <td>{{>manufacturer}}</td>
343
                                <td>{{>model}}</td>
344
                                <td>{{>platform}}</td>
345
                                <td>{{>version}}</td>
346
                                <td>{{>token}}</td>
347
                                <td>{{>updated_on}}</td>
348
                            </tr>
349
                     <tbody>
350
                </table>
351
            </td>
352
        </tr>
353
 
354
 
355
 
356
</script>
357
 
358
 
359
 
360
 
361
 
362