Proyectos de Subversion LeadersLinked - Backend

Rev

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