Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 14614 | Rev 15389 | Ir a la última revisión | | 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
 
15386 efrain 9
 
10
 
11
 
1320 efrain 12
$this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));
13
$this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));
14
$this->inlineScript()->appendFile($this->basePath('plugins/jsrender/jsrender.js'));
15
 
16
$this->headStyle()->captureStart();
17
echo <<<CSS
18
 
19
 
20
#tableStudents {
21
    display: flex;
22
    flex-flow: column;
23
    width: 100%;
24
}
25
 
26
#tableStudents thead {
27
    flex: 0 0 auto;
28
}
29
 
30
#tableStudents tbody {
31
    flex: 1 1 auto;
32
    display: block;
33
    overflow-y: auto;
34
    overflow-x: hidden;
35
}
36
 
37
#tableStudents tr {
38
    width: 100%;
39
    display: table;
40
    table-layout: fixed;
41
}
42
CSS;
43
$this->headStyle()->captureEnd();
44
 
45
 
46
 
47
$this->inlineScript()->captureStart();
48
echo <<<JS
49
jQuery( document ).ready(function( $ ) {
15386 efrain 50
 
51
 
1320 efrain 52
    $.fn.changeFilter = function() {
53
        NProgress.start();
54
        $.ajax({
55
            'dataType'  : 'json',
56
            'accept'    : 'application/json',
57
            'method'    : 'get',
58
            'url'       :  $('#form-filter').attr('action'),
59
            'data'      :  $('#form-filter').serialize(),
60
        }).done(function(response) {
61
            if(response['success']) {
62
 
63
 
14614 efrain 64
                if(response['data']['capsules']) {
65
 
66
                    $('#form-filter #capsule_uuid').empty();
67
 
68
                    $.each(response['data']['capsules'], function( value, label ) {
69
                      $('#form-filter #capsule_uuid').append(new Option(label, value));
70
                    });
15386 efrain 71
 
72
                    $('#form-filter #capsule_uuid').val(response['data']['capsule_selected']);
14614 efrain 73
                }
74
 
75
                if(response['data']['items']) {
76
                    $('#gridTable tbody').empty();
77
                    $('#gridTable tbody').append(
78
                        $( "#progressRowTemplate" ).render( response['data']['items'] )
1320 efrain 79
 
14614 efrain 80
                    );
81
 
82
                }
1320 efrain 83
 
15386 efrain 84
                if(response['data']['link_download']) {
85
                    $('button.btn-download').data('href', response['data']['link_download']);
86
                    $('button.btn-download').show();
87
 
88
                } else {
89
                     $('button.btn-download').hide();
90
                }
91
 
1320 efrain 92
            } else {
93
                if(jQuery.type(response['data']) == 'string') {
94
                    $.fn.showError(response['data']);
95
                } else  {
96
                    $.each(response['data'], function( fieldname, errors ) {
14614 efrain 97
                        $.fn.showFormErrorValidator('#form-filter #' + fieldname, errors);
1320 efrain 98
                    });
99
                }
100
            }
101
        }).fail(function( jqXHR, textStatus, errorThrown) {
102
            $.fn.showError(textStatus);
103
        }).always(function() {
104
            NProgress.done();
105
        });
106
        return false;
107
    }
108
 
109
    $('#form-filter #topic_uuid').change(function(e) {
110
        e.preventDefault();
111
 
112
        $('#form-filter #capsule_uuid').empty();
113
        $.fn.changeFilter();
114
    })
115
 
116
 
117
    $('#form-filter #capsule_uuid').change(function(e) {
118
        e.preventDefault();
119
 
120
        $.fn.changeFilter();
121
    })
122
 
15386 efrain 123
    $('button.btn-download').click(function(e) {
124
        e.preventDefault();
125
        var action   = $(this).data('href');
1320 efrain 126
 
15386 efrain 127
        NProgress.start();
128
        $.ajax({
129
            'dataType'  : 'json',
130
            'method'    : 'get',
131
            'url'       :  action,
132
        }).done(function(response) {
133
            if(response['success']) {
134
                var anchor = window.document.createElement("a");
135
                anchor.href = 'data:application/octet-stream;charset=utf-8;base64,' + response['data']['content'] ;
136
                anchor.download = response['data']['basename'];
137
                document.body.appendChild(anchor);
138
                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
139
                document.body.removeChild(anchor);
140
            } else {
141
                $.fn.showError(response['data']);
142
            }
143
        }).fail(function( jqXHR, textStatus, errorThrown) {
144
            showError(textStatus);
145
        }).always(function() {
146
            NProgress.done();
147
        });
148
 
149
 
150
    });
151
 
152
 
153
    $('button.btn-refresh').click(function(e) {
154
        e.preventDefault();
155
        $.fn.changeFilter();
156
 
157
 
158
    });
159
 
160
 
161
 
1320 efrain 162
    $.fn.changeFilter();
15386 efrain 163
    $('button.btn-download').hide();
1320 efrain 164
 
165
});
166
JS;
167
$this->inlineScript()->captureEnd();
168
?>
169
 
170
<!-- Content Header (Page header) -->
171
<section class="content-header">
172
	<div class="container-fluid">
173
    	<div class="row mb-2">
174
        	<div class="col-sm-12">
175
            	<h1>LABEL_PROGRESS_FOR_CAPSULE</h1>
176
			</div>
177
		</div>
178
	</div><!-- /.container-fluid -->
179
</section>
180
 
181
<section class="content">
182
	<div class="container-fluid">
183
    	<div class="row">
184
        	<div class="col-12">
185
				<div class="card">
186
					<div class="card-header">
187
						<?php
188
                        $form = $this->form;
189
            	        $form->setAttributes([
190
                            'name'    => 'form-filter',
191
                            'id'      => 'form-filter',
192
                        ]);
193
 
194
                        $form->prepare();
195
                        echo $this->form()->openTag($form);
196
                        ?>
197
                        <div class="row">
198
                            <div class="col-md-6 col-sm-12">
199
                                <div class="form-group">
200
                                    <?php
14614 efrain 201
                                    $element = $form->get('topic_uuid');
202
                                    $element->setOptions(['label' => 'LABEL_TOPIC']);
1320 efrain 203
 
14614 efrain 204
                                    $element->setAttributes(['class' => 'form-control']);
205
                                    echo $this->formLabel($element);
206
                                    echo $this->formSelect($element);
1320 efrain 207
                                    ?>
208
                                </div>
209
                            </div>
210
                            <div class="col-md-6 col-sm-12">
211
                                <div class="form-group">
212
                                    <?php
14614 efrain 213
                                    $element = $form->get('capsule_uuid');
214
                                    $element->setOptions(['label' => 'LABEL_CAPSULE']);
215
                                    $element->setAttributes(['class' => 'form-control']);
216
                                    echo $this->formLabel($element);
217
                                    echo $this->formSelect($element);
1320 efrain 218
                                    ?>
219
                                </div>
220
                            </div>
15386 efrain 221
 
1320 efrain 222
                            <div
223
                                class="col-md-12 col-sm-12"
224
                            >
225
                                <div style="float:right;">
226
                                    <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH  </button>
15386 efrain 227
                                    <?php if($allowDownload) :  ?>
228
 
229
                					<button type="button" class="btn btn-info btn-download"><i class="fa fa-download"></i> LABEL_DOWNLOAD  </button>
230
                					<?php endif;?>
1320 efrain 231
                                </div>
232
                            </div>
15386 efrain 233
 
1320 efrain 234
                        </div>
235
						<?php echo $this->form()->closeTag($form); ?>
236
					</div>
237
					<div class="card-body">
238
        	    		<table id="gridTable" class="table   table-hover">
239
                      		<thead>
240
        						<tr>
241
									<th style="width: 12%">LABEL_FIRST_NAME</th>
242
									<th style="width: 12%">LABEL_LAST_NAME</th>
14614 efrain 243
									<th style="width: 16%">LABEL_EMAIL</th>
1320 efrain 244
       								<th style="width: 20%">LABEL_DATE</th>
14614 efrain 245
                      				<th style="width: 20%">LABEL_REPORTS_PROGRESS</th>
246
 
1320 efrain 247
                                </tr>
248
                       		</thead>
249
                         	<tbody>
250
                         	</tbody>
251
                    	</table>
252
                   	</div>
253
          		</div>
254
           	</div>
255
        </div>
256
 	</div>
257
</section>
258
 
259
 
260
 
261
 
262
<script id="progressRowTemplate" type="text/x-jsrender">
263
    <tr>
264
        <td style="width: 12%">
265
            {{>first_name}}
266
        </td>
267
        <td style="width: 12%">
268
             {{>last_name}}
269
        </td>
270
        <td style="width: 16%">
271
            {{>email}}
272
        </td>
273
 
274
        <td style="width: 20%">
275
            LABEL_REPORTS_FIRST_DATE
276
            <br>
14614 efrain 277
            {{>added_on}}
278
            <br><br>
1320 efrain 279
            LABEL_REPORTS_LAST_DATE
280
            <br>
14614 efrain 281
            {{>updated_on}}
1320 efrain 282
        </td>
14614 efrain 283
        <td style="width: 20%">
284
 
285
 
286
            <div class="progress progress-xs progress-striped active" style="height: 15px">
287
                <div class="progress-bar {{if completed == '1' }} bg-success {{ else }} bg-primary {{/if}}" style="width: {{>progress}}%">
288
{{>progress}}  %
289
                </div>
1320 efrain 290
            </div>
291
        </td>
14614 efrain 292
 
1320 efrain 293
    </tr>
294
</script>
295
 
296
 
297
 
298
 
299
 
300
 
301