Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev Autor Línea Nro. Línea
1481 eleazar 1
<?php
2
$acl            = $this->viewModel()->getRoot()->getVariable('acl');
3
$currentUser    = $this->currentUserHelper();
4
$roleName       = $currentUser->getUserTypeId();
5
 
1482 eleazar 6
$routeDatatable = $this->url('recruitment-and-selection/candidates');
1506 eleazar 7
$routeAdd = $this->url('recruitment-and-selection/candidates/add', ['vacancy_uuid' => 'UUID_PLACEHOLDER']);
1481 eleazar 8
 
1482 eleazar 9
$allowAdd = $acl->isAllowed($roleName, 'recruitment-and-selection/candidates/add') ? 1 : 0;
10
$allowDelete = $acl->isAllowed($roleName, 'recruitment-and-selection/candidates/delete') ? 1 : 0;
1613 eleazar 11
$allowEdit = $acl->isAllowed($roleName, 'recruitment-and-selection/candidates/edit') ? 1 : 0;
1481 eleazar 12
 
13
$this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));
14
$this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));
15
 
16
 
17
$this->inlineScript()->appendFile($this->basePath('plugins/bootbox/bootbox.min.js'));
18
 
1490 eleazar 19
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-fileinput/css/fileinput.min.css'));
20
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-fileinput/themes/explorer-fas/theme.css'));
1481 eleazar 21
 
1490 eleazar 22
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/js/plugins/piexif.js'));
23
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/js/plugins/sortable.js'));
24
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/js/fileinput.js'));
25
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/js/locales/es.js'));
26
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/themes/fas/theme.js'));
27
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/themes/explorer-fas/theme.js'));
28
 
29
 
1481 eleazar 30
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/jquery.validate.js'));
31
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/additional-methods.js'));
32
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/localization/messages_es.js'));
33
 
34
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-bs4/css/dataTables.bootstrap4.min.css'));
35
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-responsive/css/responsive.bootstrap4.min.css'));
36
 
37
$this->inlineScript()->appendFile($this->basePath('plugins/datatables/jquery.dataTables.min.js'));
38
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-bs4/js/dataTables.bootstrap4.min.js'));
39
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/dataTables.responsive.min.js'));
40
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/responsive.bootstrap4.min.js'));
41
 
42
 
43
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/jquery.validate.js'));
44
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/additional-methods.js'));
45
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/localization/messages_es.js'));
46
 
47
 
48
 
49
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
50
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
51
 
52
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-confirmation/dist/bootstrap-confirmation.js'));
53
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-checkbox/awesome-bootstrap-checkbox.css'));
54
 
55
 
56
$this->inlineScript()->captureStart();
57
echo <<<JS
58
 
59
 
60
jQuery( document ).ready(function( $ ) {
61
 
62
    var allowAdd = $allowAdd;
1613 eleazar 63
    var allowDelete = $allowDelete;
64
    var allowEdit = $allowEdit;
1481 eleazar 65
 
66
        var gridTable = $('#gridTable').dataTable( {
67
            'processing': true,
68
            'serverSide': true,
69
            'searching': true,
70
            'order': [[ 1, 'asc' ]],
71
            'ordering':  true,
72
            'ordenable' : true,
73
            'responsive': true,
74
            'select' : false,
75
        	'paging': true,
76
            'pagingType': 'simple_numbers',
77
            'lengthMenu': [ [10, 25, 50, -1], [10, 25, 50, 'All'] ],
78
 
79
    		'ajax': {
80
    			'url' : '$routeDatatable',
81
    			'type' : 'get',
82
                'data': function ( d ) {
83
                },
84
                'beforeSend': function (request) {
85
                  NProgress.start();
86
                },
87
                'dataFilter': function(response) {
88
                    var response = jQuery.parseJSON( response );
89
 
90
                    var json                = {};
91
                    json.recordsTotal       = 0;
92
                    json.recordsFiltered    = 0;
93
                    json.data               = [];
94
 
95
                    if(response.success) {
96
                                               json.recordsTotal       = response.data.total;
97
                        json.recordsFiltered    = response.data.total;
98
                        json.data               = response.data.items;
99
                    } else {
100
                        $.fn.showError(response.data)
101
                    }
102
 
103
                    return JSON.stringify( json );
104
                }
105
    		},
106
            'language' : {
107
                'sProcessing':     'LABEL_DATATABLE_SPROCESSING',
108
                'sLengthMenu':     'LABEL_DATATABLE_SLENGTHMENU',
109
                'sZeroRecords':    'LABEL_DATATABLE_SZERORECORDS',
110
                'sEmptyTable':     'LABEL_DATATABLE_SEMPTYTABLE',
111
                'sInfo':           'LABEL_DATATABLE_SINFO',
112
                'sInfoEmpty':      'LABEL_DATATABLE_SINFOEMPTY',
113
                'sInfoFiltered':   'LABEL_DATATABLE_SINFOFILTERED',
114
                'sInfoPostFix':    '',
115
                'sSearch':         'LABEL_DATATABLE_SSEARCH',
116
                'sUrl':            '',
117
                'sInfoThousands':  ',',
118
                'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
119
                'oPaginate': {
120
                    'sFirst':    'LABEL_DATATABLE_SFIRST',
121
                    'sLast':     'LABEL_DATATABLE_SLAST',
122
                    'sNext':     'LABEL_DATATABLE_SNEXT',
123
                    'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
124
                },
125
                'oAria': {
126
                    'sSortAscending':  ': LABEL_DATATABLE_SSORTASCENDING',
127
                    'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
128
                },
129
            },
130
            'drawCallback': function( settings ) {
131
                NProgress.done();
132
                $('button.btn-delete').confirmation({
133
                    rootSelector: 'button.btn-delete',
134
                    title : 'LABEL_ARE_YOU_SURE',
135
                    singleton : true,
136
                    btnOkLabel: 'LABEL_YES',
137
                    btnCancelLabel: 'LABEL_NO',
138
                    onConfirm: function(value) {
139
                        action = $(this).data('href');
140
                        NProgress.start();
141
                        $.ajax({
142
                            'dataType'  : 'json',
143
                            'accept'    : 'application/json',
144
                            'method'    : 'post',
145
                            'url'       :  action,
146
                        }).done(function(response) {
147
                            if(response['success']) {
148
                                $.fn.showSuccess(response['data']);
149
                                gridTable.api().ajax.reload(null, false);
150
                            } else {
151
                                $.fn.showError(response['data']);
152
                            }
153
                        }).fail(function( jqXHR, textStatus, errorThrown) {
154
                            $.fn.showError(textStatus);
155
                        }).always(function() {
156
                            NProgress.done();
157
                        });
158
                    },
159
                });
160
 
1492 eleazar 161
                $('#form-add #file').fileinput({
1484 eleazar 162
                    theme: 'fas',
163
                    language: 'es',
164
                    showUpload: false,
165
                    dropZoneEnabled: false,
166
                    maxFileCount: 1,
167
                    allowedFileExtensions: ['pdf', 'docx'],
1481 eleazar 168
                });
169
 
1484 eleazar 170
                $('body').on('click', 'button.btn-add', function(e) {
171
                     e.preventDefault();
172
 
173
 
1492 eleazar 174
                     $('#form-add #first_name').val('');
175
                     $('#form-add #last_name').val('');
176
                     $('#form-add #email').val('');
177
                     $('#form-add #file').fileinput('reset');
1583 eleazar 178
                     $('#form-add #file').val('');
1484 eleazar 179
                     validatorAdd.resetForm();
180
 
181
                     $('#add-job-box').modal('show');
182
                     return false;
1485 eleazar 183
                    });
1484 eleazar 184
 
1491 eleazar 185
                    $(".close-box, .btn-add-cancel").on("click", function(e){
1485 eleazar 186
                         e.preventDefault();
187
                         $('#add-job-box').modal('hide');
188
                         return false;
189
                    });
190
 
1486 eleazar 191
    var validatorAdd = $('#form-add').validate({
192
        debug: true,
193
        onclick: false,
194
        onkeyup: false,
195
        onfocusout: false,
196
        ignore: [],
197
        rules: {
1489 eleazar 198
            'first_name': {
1486 eleazar 199
                required: true,
200
                maxlength: 128,
1481 eleazar 201
            },
1486 eleazar 202
            'file': {
203
                required: true,
204
                extension: 'pdf|docx',
1495 eleazar 205
                accept: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/msword,application/pdf'
1486 eleazar 206
            },
207
            'last_name': {
208
                required: true,
209
            },
210
            'email' :  {
211
                required: true,
212
            }
213
        },
214
        submitHandler: function(form)
215
        {
216
            var formdata = false;
217
            if (window.FormData){
218
                formdata = new FormData(form); //form[0]);
219
            }
220
 
221
            $('input[type="submit"]').prop('disabled', true);
222
 
223
            $.ajax({
224
                'dataType'  : 'json',
225
                'accept'    : 'application/json',
226
                'method'    : 'post',
1494 eleazar 227
                'url'       :  $('#form-add').attr('action'),
1486 eleazar 228
                'data'      :  formdata,
229
                'processData': false,
230
                'contentType': false,
231
            }).done(function(response) {
232
                if(response['success']) {
233
                    $.fn.showSuccess(response['data']);
234
 
235
                    $('#add-job-box').modal('hide');
236
                    gridTable.api().ajax.reload(null, false);
237
                } else {
238
                    validatorAdd.resetForm();
239
                    if(jQuery.type(response['data']) == 'string') {
240
                        $.fn.showError(response['data']);
241
                    } else  {
242
                        $.each(response['data'], function( fieldname, errors ) {
1494 eleazar 243
                            $.fn.showFormErrorValidator('#form-add #' + fieldname, errors);
1486 eleazar 244
                        });
245
                    }
246
                }
247
            }).fail(function( jqXHR, textStatus, errorThrown) {
248
                $.fn.showError(textStatus);
249
            }).always(function() {
250
                NProgress.done();
251
            });
252
            return false;
253
        },
254
        invalidHandler: function(form, validator) {
255
 
256
        }
257
    });
258
 
259
            },
1481 eleazar 260
            'aoColumns': [
261
                { 'mDataProp': 'first_name' },
262
                { 'mDataProp': 'last_name' },
263
                { 'mDataProp': 'email' },
264
                { 'mDataProp': 'actions' },
265
    	    ],
266
            'columnDefs': [
267
 
268
 
269
                {
270
                    'targets': -1,
271
                    'orderable': false,
272
                    'render' : function ( data, type, row ) {
273
                        s = '';
274
 
275
                        if(allowDelete && data['link_delete']  ) {
276
                            s = s + '<button class="btn btn-danger btn-sm btn-delete" data-href="' + data['link_delete']+ '" data-toggle="tooltip" title="LABEL_DELETE"><i class="fa fa-times"></i> LABEL_DELETE </button>&nbsp;';
277
                        }
278
 
1612 eleazar 279
                        if (allowEdit) {
280
                        s = s + '<button class="btn btn-primary btn-edit-form" data-href="' + data['link_edit'] + '" data-toggle="tooltip" title="LABEL_EDIT"><i class="fa fa-pencil"></i> LABEL_EDIT </button>&nbsp;';
281
                    }
1481 eleazar 282
 
283
                        return s;
284
                    }
285
                }
286
              ],
287
        });
288
 
289
    $('#form-filter #form_uuid').change(function(e) {
290
        e.preventDefault();
291
 
1503 eleazar 292
        var uuid = e.target.value;
293
 
1507 eleazar 294
        $('#form-add').attr('action', String("$routeAdd").replaceAll('UUID_PLACEHOLDER', uuid));
1503 eleazar 295
 
1599 eleazar 296
        gridTable.api().ajax.url("$routeDatatable" + "/" + uuid);
1481 eleazar 297
        gridTable.api().ajax.reload(null, false);
298
    })
299
 
300
 
301
    $('body').on('click', 'button.btn-refresh', function(e) {
302
        e.preventDefault();
303
        gridTable.api().ajax.reload(null, false);
304
    });
1507 eleazar 305
 
306
    $('#form-filter #form_uuid').change();
1481 eleazar 307
});
308
JS;
309
$this->inlineScript()->captureEnd();
310
?>
311
 
312
 
313
<!-- Content Header (Page header) -->
314
<section class="content-header">
315
	<div class="container-fluid">
316
    	<div class="row mb-2">
317
        	<div class="col-sm-12">
318
            	<h1>LABEL_CANDIDATES</h1>
319
			</div>
320
		</div>
321
	</div><!-- /.container-fluid -->
322
</section>
323
 
324
<section class="content">
325
	<div class="container-fluid">
326
    	<div class="row">
327
        	<div class="col-12">
328
				<div class="card">
329
					<div class="card-header">
330
						<?php
1486 eleazar 331
                        // $form = $this->form;
1481 eleazar 332
            	        $form->setAttributes([
333
                            'name'    => 'form-filter',
334
                            'id'      => 'form-filter',
335
                        ]);
336
 
337
                        $form->prepare();
338
                        echo $this->form()->openTag($form);
339
                        ?>
340
                        <div class="row">
341
                            <div class="col-md-6 col-sm-12">
342
                                <div class="form-group">
343
                                    <?php
344
                                    $element = $form->get('form_uuid');
345
 
1484 eleazar 346
                                    $element->setOptions(['label' => 'LABEL_VACANCIES']);
1481 eleazar 347
 
348
                                    $element->setAttributes(['class' => 'form-control']);
349
                                    echo $this->formLabel($element);
350
                                    echo $this->formSelect($element);
351
                                    ?>
352
                                </div>
353
                            </div>
354
 
355
                        </div>
356
						<?php echo $this->form()->closeTag($form); ?>
357
					</div>
358
					<div class="card-body">
359
        	    		<table id="gridTable" class="table   table-hover">
360
                      		<thead>
361
        						<tr>
362
                                	<th>LABEL_FIRST_NAME</th>
363
                                	<th>LABEL_LAST_NAME</th>
364
                                	<th>LABEL_EMAIL</th>
365
                                  	<th>LABEL_ACTIONS</th>
366
                                </tr>
367
                       		</thead>
368
                         	<tbody>
369
                         	</tbody>
370
                    	</table>
371
                   	</div>
1483 eleazar 372
                       <div class="card-footer clearfix">
373
                       		<div style="float:right;">
374
    							<button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
375
    							<?php if($allowAdd) : ?>
376
    							<button type="button" class="btn btn-primary btn-add"><i class="fa fa-plus"></i> LABEL_ADD </button>
377
    							<?php endif; ?>
378
    						</div>
379
                     	</div>
1481 eleazar 380
          		</div>
381
           	</div>
382
        </div>
383
 	</div>
384
</section>
1485 eleazar 385
<div class="modal" tabindex="-1" role="dialog" id="add-job-box">
386
	<div class="modal-dialog" role="document">
387
		<?php
1487 eleazar 388
	    //$form = $this->formA;
1485 eleazar 389
	    $form->setAttributes([
390
	       'method'    => 'post',
391
	        'name'      => 'form-add',
1496 eleazar 392
            'action'    => $routeAdd,
1485 eleazar 393
	        'id'        => 'form-add'
394
	    ]);
395
	    $form->prepare();
396
	    echo $this->form()->openTag($form);
397
 
398
	    ?>
399
    	<div class="modal-content">
400
      		<div class="modal-header">
401
        		<h3 class="modal-title">LABEL_NEW_CANDIDATE</h3>
402
      		</div>
403
      		<div class="modal-body">
404
      			<div class="form-group">
405
    				<?php
406
                        $element = $form->get('first_name');
407
                        $element->setOptions(['label' => 'LABEL_FIRST_NAME']);
408
                        $element->setAttributes(['class' => 'form-control']);
409
                        echo $this->formLabel($element);
410
                        echo $this->formText($element);
411
                    ?>
412
				</div>
413
				<div class="form-group">
414
    				<?php
415
                        $element = $form->get('last_name');
416
                        $element->setOptions(['label' => 'LABEL_LAST_NAME']);
417
                        $element->setAttributes(['class' => 'form-control']);
418
                        echo $this->formLabel($element);
419
                        echo $this->formText($element);
420
                    ?>
421
				</div>
422
      			<div class="form-group">
423
    				<?php
424
                        $element = $form->get('email');
425
                        $element->setOptions(['label' => 'LABEL_EMAIL']);
426
                        $element->setAttributes(['class' => 'form-control']);
427
                        echo $this->formLabel($element);
428
                        echo $this->formText($element);
429
                    ?>
430
				</div>
431
 
432
				<div class="form-group">
433
    				<?php
434
                    $element = $form->get('file');
435
 
436
                    $element->setAttributes(['class' => 'form-control',  'accept' => 'pdf/docx']);
437
                    $element->setOptions(['label' => 'LABEL_CURRICULUM']);
438
                    echo $this->formLabel($element);
439
                    ?>
440
                    <div class="file-loading">
441
                    	<?php echo $this->formFile($element); ?>
1493 eleazar 442
                    </div>
1485 eleazar 443
				</div>
444
          	</div>
445
         	<div class="modal-footer">
446
    			<button type="submit" class="btn btn-primary">LABEL_SAVE</button>
447
    			<button type="button" class="btn btn-default btn-add-cancel">LABEL_CANCEL</button>
448
          	</div>
449
      	<?php echo $this->form()->closeTag($form); ?>
450
    	</div>
451
	</div>
452
</div>