Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16971 | | 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
 
7
 
8
$routeDatatable = $this->url('settings/email-templates');
9
$routeDashboard = $this->url('dashboard');
10
 
11
$allowEdit = $acl->isAllowed($roleName, 'settings/email-templates/edit') ? 1 : 0;
12
 
13
 
16822 efrain 14
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/nprogress/nprogress.css'));
15
$this->inlineScript()->appendFile($this->basePath('assets/vendors/nprogress/nprogress.js'));
1 www 16
 
16822 efrain 17
$this->inlineScript()->appendFile($this->basePath('assets/vendors/ckeditor/ckeditor.js'));
1 www 18
 
19
 
20
 
16929 efrain 21
 
22
 
23
 
16822 efrain 24
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.css'));
25
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.css'));
1 www 26
 
16822 efrain 27
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net/jquery.dataTables.js'));
28
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5/dataTables.bootstrap5.js'));
29
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/dataTables.responsive.min.js'));
30
$this->inlineScript()->appendFile($this->basePath('assets/vendors/datatables.net-bs5-responsive/responsive.bootstrap5.min.js'));
1 www 31
 
32
 
16822 efrain 33
$this->headLink()->appendStylesheet($this->basePath('assets/vendors/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
34
$this->inlineScript()->appendFile($this->basePath('assets/vendors/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
1 www 35
 
36
 
37
 
38
 
16822 efrain 39
 
40
 
1 www 41
$status_active = \LeadersLinked\Model\EmailTemplate::STATUS_ACTIVE;
42
 
43
$this->inlineScript()->captureStart();
44
echo <<<JS
45
    jQuery( document ).ready(function( $ ) {
46
 
47
 
48
 
49
 
50
 
51
        var allowEdit   = $allowEdit;
52
 
53
        var gridTable = $('#gridTable').dataTable( {
54
            'processing': true,
55
            'serverSide': true,
56
            'searching': true,
57
            'order': [[ 0, 'asc' ]],
58
            'ordering':  true,
59
            'ordenable' : true,
60
            'responsive': true,
61
            'select' : false,
62
        	'paging': true,
63
            'pagingType': 'simple_numbers',
64
    		'ajax': {
65
    			'url' : '$routeDatatable',
66
    			'type' : 'get',
67
                'beforeSend': function (request) {
68
                  NProgress.start();
69
                },
70
                'dataFilter': function(response) {
71
                    var response = jQuery.parseJSON( response );
72
 
73
                    var json                = {};
74
                    json.recordsTotal       = 0;
75
                    json.recordsFiltered    = 0;
76
                    json.data               = [];
77
 
78
 
79
                    if(response.success) {
80
                        json.recordsTotal       = response.data.total;
81
                        json.recordsFiltered    = response.data.total;
82
                        json.data               = response.data.items;
83
                    } else {
84
                        $.fn.showError(response.data)
85
                    }
86
 
87
                    return JSON.stringify( json );
88
                }
89
    		},
90
            'language' : {
91
                'sProcessing':     'LABEL_DATATABLE_SPROCESSING',
92
                'sLengthMenu':     'LABEL_DATATABLE_SLENGTHMENU',
93
                'sZeroRecords':    'LABEL_DATATABLE_SZERORECORDS',
94
                'sEmptyTable':     'LABEL_DATATABLE_SEMPTYTABLE',
95
                'sInfo':           'LABEL_DATATABLE_SINFO',
96
                'sInfoEmpty':      'LABEL_DATATABLE_SINFOEMPTY',
97
                'sInfoFiltered':   'LABEL_DATATABLE_SINFOFILTERED',
98
                'sInfoPostFix':    '',
99
                'sSearch':         'LABEL_DATATABLE_SSEARCH',
100
                'sUrl':            '',
101
                'sInfoThousands':  ',',
102
                'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
103
                'oPaginate': {
104
                    'sFirst':    'LABEL_DATATABLE_SFIRST',
105
                    'sLast':     'LABEL_DATATABLE_SLAST',
106
                    'sNext':     'LABEL_DATATABLE_SNEXT',
107
                    'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
108
                },
109
                'oAria': {
110
                    'sSortAscending':  ': LABEL_DATATABLE_SSORTASCENDING',
111
                    'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
112
                },
113
            },
114
            'drawCallback': function( settings ) {
115
                NProgress.done();
116
            },
117
            'aoColumns': [
118
                { 'mDataProp': 'subject' },
119
                { 'mDataProp': 'status' },
120
                { 'mDataProp': 'actions' },
121
    	    ],
122
            'columnDefs': [
123
                {
124
                    'targets':0,
125
                    'className' : 'text-vertical-middle',
126
                },
127
                {
128
                    'targets': -2,
129
                    'orderable': false,
130
                    'className' : 'text-center',
131
                      'render' : function ( data, type, row ) {
132
 
16822 efrain 133
                        checked = data == 'a'  ? 'checked' : '';
134
                        return '<div class="form-check">' +
16971 efrain 135
                            '<input type="checkbox" class="form-check-input" disabled="" ' + checked + '>' +
16822 efrain 136
                            '<label class="form-check-label" for="checkCheckedDisabled"></label></div>' ;
1 www 137
                    }
138
                },
139
                {
140
                    'targets': -1,
141
                    'orderable': false,
142
                    'render' : function ( data, type, row ) {
143
                        s = '';
144
 
145
                        if(allowEdit) {
16906 efrain 146
                            s = s + '<button class="btn btn-primary btn-edit" data-href="' + data['link_edit']+ '" data-toggle="tooltip" title="LABEL_EDIT"><i class="fa fa-pen"></i> LABEL_EDIT </button>&nbsp;';
1 www 147
                        }
148
                        return s;
149
                    }
150
                }
151
              ],
152
        });
153
 
154
 
155
        var validator = $('#form').validate({
156
            debug: true,
157
            onclick: false,
158
            onkeyup: false,
159
            ignore: [],
160
            rules: {
161
                'id': {
162
                    required: true,
163
                    maxlength: 64,
164
                },
165
                'subject': {
166
                    required: true,
167
                    maxlength: 128,
168
                },
169
                'content': {
170
                    updateCkeditor:function() {
171
                        CKEDITOR.instances.content.updateElement();
172
                    },
173
                    required: true,
174
                },
175
                'status': {
176
                    required: false,
177
 
178
                },
179
            },
180
            submitHandler: function(form)
181
            {
182
                $.ajax({
183
                    'dataType'  : 'json',
184
                    'accept'    : 'application/json',
185
                    'method'    : 'post',
186
                    'url'       :  $('#form').attr('action'),
187
                    'data'      :  $('#form').serialize()
188
                }).done(function(response) {
189
                    NProgress.start();
190
                    if(response['success']) {
191
                        $.fn.showSuccess(response['data']);
192
 
193
                        $('#modal').modal('hide');
194
 
195
                         gridTable.api().ajax.reload(null, false);
196
                    } else {
197
                        validator.resetForm();
198
                        if(jQuery.type(response['data']) == 'string') {
199
                            $.fn.showError(response['data']);
200
                        } else  {
201
                            $.each(response['data'], function( fieldname, errors ) {
202
                                $.fn.showFormErrorValidator('#form #' + fieldname, errors);
203
                            });
204
                        }
205
                    }
206
                }).fail(function( jqXHR, textStatus, errorThrown) {
207
                   $.fn.showError(textStatus);
208
                }).always(function() {
209
                    NProgress.done();
210
                });
211
                return false;
212
            },
213
            invalidHandler: function(form, validator) {
214
 
215
            }
216
        });
217
 
218
 
219
        $('body').on('click', 'button.btn-edit', function(e) {
220
            e.preventDefault();
221
            NProgress.start();
222
            var action = $(this).data('href');
223
 
224
            $.ajax({
225
                'dataType'  : 'json',
226
                'accept'    : 'application/json',
227
                'method'    : 'get',
228
                'url'       :  action,
229
            }).done(function(response) {
230
                if(response['success']) {
231
 
16840 efrain 232
 
1 www 233
                    $('#form').attr('action', action);
234
                    $('#form #id').val(response['data']['id']);
235
                    $('#form #subject').val(response['data']['subject']);
236
                    $('#form #status').bootstrapToggle(response['data']['status'] == '$status_active' ? 'on' : 'off')
237
                    CKEDITOR.instances.content.setData(response['data']['content']);
238
 
239
                    validator.resetForm();
240
 
241
                    $('#modal').modal('show');
242
                } else {
243
                    $.fn.showError(response['data']);
244
                }
245
            }).fail(function( jqXHR, textStatus, errorThrown) {
246
                $.fn.showError(textStatus);
247
            }).always(function() {
248
                NProgress.done();
249
            });
250
        });
251
 
252
 
253
 
254
 
255
 
256
        $('body').on('click', 'button.btn-refresh', function(e) {
257
            e.preventDefault();
258
            gridTable.api().ajax.reload(null, false);
259
        });
260
 
261
 
262
        $('body').on('click', 'button.btn-cancel', function(e) {
263
            e.preventDefault();
264
            $('#modal').modal('hide');
265
        });
266
 
267
 
268
        $('#form #status').bootstrapToggle({'on' : 'LABEL_ACTIVE',  'off' : 'LABEL_INACTIVE', 'width' : '160px', 'height' : '40px'});
269
 
270
        CKEDITOR.config.extraPlugins = ['leaderslinked'];
271
        CKEDITOR.replace('content', {
272
            extraPlugins: ['leaderslinked']
273
        })
274
 
275
    });
276
JS;
277
$this->inlineScript()->captureEnd();
278
?>
279
 
280
 
16822 efrain 281
<div class="containe">
1 www 282
    	<div class="row">
16891 efrain 283
        	<div class="col-12 mt-3">
16822 efrain 284
				<div class="card">
285
 
1 www 286
					<div class="card-body">
16822 efrain 287
						<h6 class="card-title">LABEL_EMAIL_TEMPLATES</h6>
16845 efrain 288
        	    		<table id="gridTable" class="table   table-bordered">
1 www 289
                      		<thead>
290
        						<tr>
291
                                	<th>LABEL_SUBJECT</th>
292
                                  	<th>LABEL_ACTIVE</th>
293
                                  	<th>LABEL_ACTIONS</th>
294
                                </tr>
295
                       		</thead>
296
                         	<tbody>
297
                         	</tbody>
298
                    	</table>
299
                   	</div>
300
                   	<div class="card-footer clearfix">
301
                   		<div style="float:right;">
16992 efrain 302
							<button type="button" class="btn btn-info btn-refresh"><i class="fa fa-sync"></i> LABEL_REFRESH  </button>
1 www 303
						</div>
304
                 	</div>
305
          		</div>
306
           	</div>
307
        </div>
16822 efrain 308
</div>
1 www 309
 
16822 efrain 310
 
1 www 311
<!-- The Modal -->
312
<div class="modal" id="modal">
313
	<div class="modal-dialog  modal-xl">
314
    	<div class="modal-content">
315
 
316
            <!-- Modal Header -->
317
      		<div class="modal-header">
16845 efrain 318
        		<h6 class="modal-title">LABEL_EMAIL_TEMPLATES</h6>
16822 efrain 319
        		<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="btn-close"></button>
1 www 320
      		</div>
321
 
322
            <!-- Modal body -->
16822 efrain 323
            			 <?php
1 www 324
                    $form = $this->form;
325
            		$form->setAttributes([
326
                        'method'    => 'post',
327
                        'name'      => 'form',
328
                        'id'        => 'form'
329
                    ]);
330
 
331
                    $form->prepare();
332
                    echo $this->form()->openTag($form);
16822 efrain 333
                    ?>
334
      		<div class="modal-body">
335
 
336
                      	<div class="row">
16841 efrain 337
							<div class="col-12 mt-3 ">
1 www 338
        					<?php
339
        					$element = $form->get('id');
340
        					$element->setOptions(['label' => 'LABEL_ID']);
341
                            $element->setAttributes(['class' => 'form-control', 'readonly' => 'readonly']);
342
 
343
                            echo $this->formLabel($element);
344
                            echo $this->formText($element);
345
                            ?>
16822 efrain 346
                            </div>
1 www 347
						</div>
16822 efrain 348
    					<div class="row">
16841 efrain 349
							<div class="col-12 mt-3 ">
1 www 350
        					<?php
351
        					$element = $form->get('subject');
352
        					$element->setOptions(['label' => 'LABEL_SUBJECT']);
353
                            $element->setAttributes(['class' => 'form-control']);
354
 
355
                            echo $this->formLabel($element);
356
                            echo $this->formText($element);
357
                            ?>
16822 efrain 358
							</div>
359
						</div>
360
						<div class="row">
16841 efrain 361
							<div class="col-12 mt-3 ">
1 www 362
                    	<?php
363
                    	    $element = $form->get('content');
364
                    	    $element->setOptions(['label' => 'LABEL_CONTENT']);
365
                            $element->setAttributes(['class' => 'form-control']);
366
 
367
                            echo $this->formLabel($element);
368
                            echo $this->formTextArea($element);
369
                        ?>
16822 efrain 370
                        	</div>
1 www 371
						</div>
16822 efrain 372
						<div class="row">
16841 efrain 373
							<div class="col-12 mt-3 ">
1 www 374
                      	<?php
375
                            $element = $form->get('status');
376
                            echo $this->formCheckbox($element);
377
                        ?>
16822 efrain 378
                        	</div>
1 www 379
						</div>
16822 efrain 380
 
381
 
1 www 382
      		</div>
383
 
384
            <!-- Modal footer -->
16891 efrain 385
      		<div class="modal-footer text-right">
16822 efrain 386
        		 <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
387
                    		<button type="button" class="btn btn-light btn-cancel">LABEL_CANCEL</button>
1 www 388
      		</div>
16822 efrain 389
      		<?php echo $this->form()->closeTag($form); ?>
1 www 390
 
391
    	</div>
392
	</div>
393
</div>
394
 
395
 
396
 
397
 
398
 
399
 
400
 
401
 
402
 
403
 
404
 
405
 
406