Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16845 | Rev 16966 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 www 1
<?php
2
$acl            = $this->viewModel()->getRoot()->getVariable('acl');
3
$currentUser    = $this->currentUserHelper();
4
 
5
$roleName = $currentUser->getUserTypeId();
6
 
16822 efrain 7
 
1 www 8
$routeDatatable = $this->url('followers');
9
 
10
 
16822 efrain 11
$allowDelete    = $acl->isAllowed($roleName, 'followers/delete') ? 1 : 0;
11215 stevensc 12
 
16841 efrain 13
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/nprogress/nprogress.css'));
14
$this->inlineScript()->appendFile($this->basePath('assets/vendors/nprogress/nprogress.js'));
15194 stevensc 15
 
16841 efrain 16
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables-bs4/css/dataTables.bootstrap4.min.css'));
17
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables-responsive/css/responsive.bootstrap4.min.css'));
16822 efrain 18
 
16841 efrain 19
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables/jquery.dataTables.min.js'));
20
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables-bs4/js/dataTables.bootstrap4.min.js'));
21
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables-responsive/js/dataTables.responsive.min.js'));
22
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables-responsive/js/responsive.bootstrap4.min.js'));
16822 efrain 23
 
24
 
25
 
26
 
27
 
28
 
29
 
30
$this->inlineScript()->captureStart();
31
echo <<<JS
32
    jQuery( document ).ready(function( $ ) {
33
 
34
        var allowDelete = $allowDelete;
35
 
36
 
37
        var gridTable = $('#gridTable').dataTable( {
38
            'processing': true,
39
            'serverSide': true,
40
            'searching': true,
41
            'order': [[ 1, 'asc' ]],
42
            'ordering':  true,
43
            'ordenable' : true,
44
            'responsive': true,
45
            'select' : false,
46
        	'paging': true,
47
            'pagingType': 'simple_numbers',
48
    		'ajax': {
49
    			'url' : '$routeDatatable',
50
    			'type' : 'get',
51
                'beforeSend': function (request) {
52
                  NProgress.start();
53
                },
54
                'dataFilter': function(response) {
55
                    var response = jQuery.parseJSON( response );
56
 
57
                    var json                = {};
58
                    json.recordsTotal       = 0;
59
                    json.recordsFiltered    = 0;
60
                    json.data               = [];
61
 
62
 
63
                    if(response.success) {
64
                        json.recordsTotal       = response.data.total;
65
                        json.recordsFiltered    = response.data.total;
66
                        json.data               = response.data.items;
67
                    } else {
68
                        $.fn.showError(response.data)
69
                    }
70
 
71
                    return JSON.stringify( json );
72
                }
73
    		},
74
            'language' : {
75
                'sProcessing':     'LABEL_DATATABLE_SPROCESSING',
76
                'sLengthMenu':     'LABEL_DATATABLE_SLENGTHMENU',
77
                'sZeroRecords':    'LABEL_DATATABLE_SZERORECORDS',
78
                'sEmptyTable':     'LABEL_DATATABLE_SEMPTYTABLE',
79
                'sInfo':           'LABEL_DATATABLE_SINFO',
80
                'sInfoEmpty':      'LABEL_DATATABLE_SINFOEMPTY',
81
                'sInfoFiltered':   'LABEL_DATATABLE_SINFOFILTERED',
82
                'sInfoPostFix':    '',
83
                'sSearch':         'LABEL_DATATABLE_SSEARCH',
84
                'sUrl':            '',
85
                'sInfoThousands':  ',',
86
                'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
87
                'oPaginate': {
88
                    'sFirst':    'LABEL_DATATABLE_SFIRST',
89
                    'sLast':     'LABEL_DATATABLE_SLAST',
90
                    'sNext':     'LABEL_DATATABLE_SNEXT',
91
                    'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
92
                },
93
                'oAria': {
94
                    'sSortAscending':  ': LABEL_DATATABLE_SSORTASCENDING',
95
                    'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
96
                },
97
            },
98
            'drawCallback': function( settings ) {
99
                NProgress.done();
100
 
101
            },
102
            'aoColumns': [
103
                { 'mDataProp': 'first_name' },
104
                { 'mDataProp': 'last_name' },
105
                { 'mDataProp': 'email' },
106
                { 'mDataProp': 'actions' },
107
    	    ],
108
            'columnDefs': [
109
                {
110
                    'targets': 0,
111
                    'className' : 'text-vertical-middle',
112
                },
113
                {
114
                    'targets': 1,
115
                    'className' : 'text-vertical-middle',
116
                },
117
                {
118
                    'targets': 2,
119
                    'className' : 'text-vertical-middle',
120
                },
121
                {
122
                    'targets': -1,
123
                    'orderable': false,
124
                    'render' : function ( data, type, row ) {
125
                        s = '&nbsp;';
126
 
127
                        if(allowDelete && data['link_delete']) {
128
                            s = s + '<button class="btn btn-danger btn-delete" data-href="' + data['link_delete']+ '" data-toggle="tooltip" title="LABEL_DELETE"><i class="fa fa-times"></i> LABEL_DELETE </button>&nbsp;';
129
                        }
130
 
131
                        return s;
132
                    }
133
                }
134
 
135
            ],
136
        });
137
 
138
        $('body').on('click', 'button.btn-refresh', function(e) {
139
            e.preventDefault();
140
            gridTable.api().ajax.reload(null, false);
141
        });
142
 
143
    $('body').on('click', 'button.btn-delete', function(e) {
144
        e.preventDefault();
145
        var action = $(this).data('href');
146
 
147
 
148
          swal.fire({
149
            title: 'LABEL_ARE_YOU_SURE',
150
            icon: 'question',
151
            cancelButtonText: 'LABEL_NO',
152
            showCancelButton: true,
153
            confirmButtonText: 'LABEL_YES'
154
          }).then((result) => {
155
            if (result.isConfirmed) {
156
 
157
                    NProgress.start();
158
                    $.ajax({
159
                        'dataType'  : 'json',
160
                        'accept'    : 'application/json',
161
                        'method'    : 'post',
162
                        'url'       :  action,
163
                    }).done(function(response) {
164
                        if(response['success']) {
165
                            $.fn.showSuccess(response['data']);
166
                            gridTable.api().ajax.reload(null, false);
167
                        } else {
168
                            $.fn.showError(response['data']);
169
                        }
170
                    }).fail(function( jqXHR, textStatus, errorThrown) {
171
                        $.fn.showError(textStatus);
172
                    }).always(function() {
173
                        NProgress.done();
174
                    });
175
                }
176
          });
177
 
178
 
179
        });
180
 
181
    });
182
JS;
183
$this->inlineScript()->captureEnd();
7545 stevensc 184
?>
7707 stevensc 185
 
16822 efrain 186
 
187
<div class="container">
188
    	<div class="row">
16891 efrain 189
        	<div class="col-12 mt-3">
16822 efrain 190
				<div class="card">
191
					<h6 class="card-title">LABEL_FOLLOWERS</h6>
192
					<div class="card-body">
16845 efrain 193
        	    		<table id="gridTable" class="table   table-bordered">
16822 efrain 194
                      		<thead>
195
        						<tr>
196
                                	<th>LABEL_FIRST_NAME</th>
197
                                	<th>LABEL_LAST_NAME</th>
198
                                	<th>LABEL_EMAIL</th>
199
                                  	<th>LABEL_ACTIONS</th>
200
                                </tr>
201
                       		</thead>
202
                         	<tbody>
203
                         	</tbody>
204
                    	</table>
205
                   	</div>
206
                   	<div class="card-footer clearfix">
207
                   		<div style="float:right;">
208
							<button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH  </button>
209
						</div>
210
                 	</div>
211
          		</div>
212
           	</div>
213
        </div>
214
</div>