Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev Autor Línea Nro. Línea
15387 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, 'reports/users-blocked/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.loadData = 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
 
65
               $('#gridTable tbody').empty();
66
                if(response['data']['items']) {
67
 
68
                    $('#gridTable tbody').append(
69
                        $( "#itemRowTemplate" ).render( response['data']['items'] )
70
 
71
                    );
72
 
73
                } else {
74
                    $('#gridTable tbody').append(
75
                        $( "#itemEmptyRowTemplate" ).render([])
76
                    );
77
 
78
                }
79
 
80
                if(response['data']['link_download']) {
81
                    $('button.btn-download').data('href', response['data']['link_download']);
82
                    $('button.btn-download').show();
83
 
84
                } else {
85
                     $('button.btn-download').hide();
86
                }
87
 
88
            } else {
89
                if(jQuery.type(response['data']) == 'string') {
90
                    $.fn.showError(response['data']);
91
                } else  {
92
                    $.each(response['data'], function( fieldname, errors ) {
93
                        $.fn.showFormErrorValidator('#form-filter #' + fieldname, errors);
94
                    });
95
                }
96
            }
97
        }).fail(function( jqXHR, textStatus, errorThrown) {
98
            $.fn.showError(textStatus);
99
        }).always(function() {
100
            NProgress.done();
101
        });
102
        return false;
103
    }
104
 
105
 
106
    $('button.btn-download').click(function(e) {
107
        e.preventDefault();
108
        var action   = $(this).data('href');
109
 
110
        NProgress.start();
111
        $.ajax({
112
            'dataType'  : 'json',
113
            'method'    : 'get',
114
            'url'       :  action,
115
        }).done(function(response) {
116
            if(response['success']) {
117
                var anchor = window.document.createElement("a");
118
                anchor.href = 'data:application/octet-stream;charset=utf-8;base64,' + response['data']['content'] ;
119
                anchor.download = response['data']['basename'];
120
                document.body.appendChild(anchor);
121
                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
122
                document.body.removeChild(anchor);
123
            } else {
124
                $.fn.showError(response['data']);
125
            }
126
        }).fail(function( jqXHR, textStatus, errorThrown) {
127
            showError(textStatus);
128
        }).always(function() {
129
            NProgress.done();
130
        });
131
 
132
 
133
    });
134
 
135
 
136
    $('button.btn-refresh').click(function(e) {
137
        e.preventDefault();
138
        $.fn.loadData();
139
 
140
 
141
    });
142
 
143
 
144
 
145
    $.fn.loadData();
146
    $('button.btn-download').hide();
147
 
148
});
149
JS;
150
$this->inlineScript()->captureEnd();
151
?>
152
 
153
<!-- Content Header (Page header) -->
154
<section class="content-header">
155
	<div class="container-fluid">
156
    	<div class="row mb-2">
157
        	<div class="col-sm-12">
158
            	<h1>LABEL_REPORTS_USERS_BLOCKED</h1>
159
			</div>
160
		</div>
161
	</div><!-- /.container-fluid -->
162
</section>
163
 
164
<section class="content">
165
	<div class="container-fluid">
166
    	<div class="row">
167
        	<div class="col-12">
168
				<div class="card">
169
					<div class="card-header">
170
						<div class="col-md-12 col-sm-12">
171
                                <div style="float:right;">
172
                                    <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH  </button>
173
                                    <?php if($allowDownload) :  ?>
174
 
175
                					<button type="button" class="btn btn-info btn-download"><i class="fa fa-download"></i> LABEL_DOWNLOAD  </button>
176
                					<?php endif;?>
177
                                </div>
178
                     	</div>
179
					</div>
180
					<div class="card-body">
181
        	    		<table id="gridTable" class="table   table-hover">
182
                      		<thead>
183
        						<tr>
184
									<th style="width: 25%">LABEL_FIRST_NAME</th>
185
									<th style="width: 25%">LABEL_LAST_NAME</th>
186
									<th style="width: 30%">LABEL_EMAIL</th>
187
       								<th style="width: 20%">LABEL_REPORTS_LAST_ACTIVITY</th>
188
 
189
 
190
                                </tr>
191
                       		</thead>
192
                         	<tbody>
193
                         	</tbody>
194
                    	</table>
195
                   	</div>
196
          		</div>
197
           	</div>
198
        </div>
199
 	</div>
200
</section>
201
 
202
 
203
 
204
 
205
<script id="itemRowTemplate" type="text/x-jsrender">
206
    <tr>
207
        <td style="width: 25%">
208
            {{>first_name}}
209
        </td>
210
        <td style="width: 25%">
211
             {{>last_name}}
212
        </td>
213
        <td style="width: 30%">
214
            {{>email}}
215
        </td>
216
        <td style="width: 30%">
217
            {{>last_activity_on}}
218
        </td>
219
 
220
 
221
 
222
    </tr>
223
</script>
224
 
225
 
226
<script id="itemEmptyRowTemplate" type="text/x-jsrender">
227
    <tr>
228
        <td colspan="4">
229
            LABEL_NOT_RECORDS_FOUND
230
        </td>
231
    </tr>
232
</script>
233
 
234
 
235
 
236
 
237
 
238