Proyectos de Subversion LeadersLinked - Backend

Rev

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