Proyectos de Subversion LeadersLinked - Backend

Rev

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