Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 15389 | Ir a la última revisión | | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
15386 efrain 1
<?php
2
$acl            = $this->viewModel()->getRoot()->getVariable('acl');
3
$currentUser    = $this->currentUserHelper();
4
 
5
$roleName = $currentUser->getUserTypeId();
6
 
7
$allowDownload  = $acl->isAllowed($roleName, 'microlearning/reports/progress-for-student/excel') ? 1 : 0;
8
 
9
 
10
 
11
 
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( $ ) {
50
 
51
 
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
 
64
                if(response['data']['items']) {
65
                    $('#gridTable tbody').empty();
66
                    $('#gridTable tbody').append(
67
                        $( "#progressRowTemplate" ).render( response['data']['items'] )
68
 
69
                    );
70
 
71
                }
72
 
73
                if(response['data']['link_download']) {
74
                    $('button.btn-download').data('href', response['data']['link_download']);
75
                    $('button.btn-download').show();
76
 
77
                } else {
78
                     $('button.btn-download').hide();
79
                }
80
 
81
            } else {
82
                if(jQuery.type(response['data']) == 'string') {
83
                    $.fn.showError(response['data']);
84
                } else  {
85
                    $.each(response['data'], function( fieldname, errors ) {
86
                        $.fn.showFormErrorValidator('#form-filter #' + fieldname, errors);
87
                    });
88
                }
89
            }
90
        }).fail(function( jqXHR, textStatus, errorThrown) {
91
            $.fn.showError(textStatus);
92
        }).always(function() {
93
            NProgress.done();
94
        });
95
        return false;
96
    }
97
 
98
    $('#form-filter #student_uuid').change(function(e) {
99
        e.preventDefault();
100
 
101
        $.fn.changeFilter();
102
    })
103
 
104
 
105
    $('button.btn-download').click(function(e) {
106
        e.preventDefault();
107
        var action   = $(this).data('href');
108
 
109
        NProgress.start();
110
        $.ajax({
111
            'dataType'  : 'json',
112
            'method'    : 'get',
113
            'url'       :  action,
114
        }).done(function(response) {
115
            if(response['success']) {
116
                var anchor = window.document.createElement("a");
117
                anchor.href = 'data:application/octet-stream;charset=utf-8;base64,' + response['data']['content'] ;
118
                anchor.download = response['data']['basename'];
119
                document.body.appendChild(anchor);
120
                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
121
                document.body.removeChild(anchor);
122
            } else {
123
                $.fn.showError(response['data']);
124
            }
125
        }).fail(function( jqXHR, textStatus, errorThrown) {
126
            showError(textStatus);
127
        }).always(function() {
128
            NProgress.done();
129
        });
130
 
131
 
132
    });
133
 
134
 
135
    $('button.btn-refresh').click(function(e) {
136
        e.preventDefault();
137
        $.fn.changeFilter();
138
 
139
 
140
    });
141
 
142
 
143
    $.fn.changeFilter();
144
    $('button.btn-download').hide();
145
 
146
});
147
JS;
148
$this->inlineScript()->captureEnd();
149
?>
150
 
151
<!-- Content Header (Page header) -->
152
<section class="content-header">
153
	<div class="container-fluid">
154
    	<div class="row mb-2">
155
        	<div class="col-sm-12">
156
            	<h1>LABEL_PROGRESS_FOR_STUDENT</h1>
157
			</div>
158
		</div>
159
	</div><!-- /.container-fluid -->
160
</section>
161
 
162
<section class="content">
163
	<div class="container-fluid">
164
    	<div class="row">
165
        	<div class="col-12">
166
				<div class="card">
167
					<div class="card-header">
168
						<?php
169
                        $form = $this->form;
170
            	        $form->setAttributes([
171
                            'name'    => 'form-filter',
172
                            'id'      => 'form-filter',
173
                        ]);
174
 
175
                        $form->prepare();
176
                        echo $this->form()->openTag($form);
177
                        ?>
178
                        <div class="row">
179
                            <div class="col-md-12 col-sm-12">
180
                                <div class="form-group">
181
                                    <?php
182
                                    $element = $form->get('student_uuid');
183
                                    $element->setOptions(['label' => 'LABEL_STUDENT']);
184
 
185
                                    $element->setAttributes(['class' => 'form-control']);
186
                                    echo $this->formLabel($element);
187
                                    echo $this->formSelect($element);
188
                                    ?>
189
                                </div>
190
                            </div>
191
 
192
 
193
                            <div
194
                                class="col-md-12 col-sm-12"
195
                            >
196
                                <div style="float:right;">
197
                                    <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH  </button>
198
                                    <?php if($allowDownload) :  ?>
199
 
200
                					<button type="button" class="btn btn-info btn-download"><i class="fa fa-download"></i> LABEL_DOWNLOAD  </button>
201
                					<?php endif;?>
202
                                </div>
203
                            </div>
204
 
205
                        </div>
206
						<?php echo $this->form()->closeTag($form); ?>
207
					</div>
208
					<div class="card-body">
209
        	    		<table id="gridTable" class="table   table-hover">
210
                      		<thead>
211
        						<tr>
212
									<th style="width: 25%">LABEL_TOPIC</th>
213
									<th style="width: 25%">LABEL_CAPSULE</th>
214
       								<th style="width: 25%">LABEL_DATE</th>
215
                      				<th style="width: 25%">LABEL_REPORTS_PROGRESS</th>
216
                                </tr>
217
                       		</thead>
218
                         	<tbody>
219
                         	</tbody>
220
                    	</table>
221
                   	</div>
222
          		</div>
223
           	</div>
224
        </div>
225
 	</div>
226
</section>
227
 
228
 
229
 
230
 
231
<script id="progressRowTemplate" type="text/x-jsrender">
232
    <tr>
233
        <td style="width: 25%">
234
            {{>topic}}
235
        </td>
236
        <td style="width: 25%">
237
             {{>capsule}}
238
        </td>
239
 
240
 
241
        <td style="width: 25%">
242
            LABEL_REPORTS_FIRST_DATE
243
            <br>
244
            {{>added_on}}
245
            <br><br>
246
            LABEL_REPORTS_LAST_DATE
247
            <br>
248
            {{>updated_on}}
249
        </td>
250
        <td style="width: 25%">
251
 
252
 
253
            <div class="progress progress-xs progress-striped active" style="height: 15px">
254
                <div class="progress-bar {{if completed == '1' }} bg-success {{ else }} bg-primary {{/if}}" style="width: {{>progress}}%">
255
{{>progress}}  %
256
                </div>
257
            </div>
258
        </td>
259
 
260
    </tr>
261
</script>
262
 
263
 
264
 
265
 
266
 
267
 
268