Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 1495 | Rev 1503 | 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');
1496 eleazar 7
$routeAdd = $this->url('recruitment-and-selection/candidates/add');
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;
1481 eleazar 11
 
12
$this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));
13
$this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));
14
 
15
 
16
$this->inlineScript()->appendFile($this->basePath('plugins/bootbox/bootbox.min.js'));
17
 
1490 eleazar 18
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-fileinput/css/fileinput.min.css'));
19
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-fileinput/themes/explorer-fas/theme.css'));
1481 eleazar 20
 
1490 eleazar 21
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/js/plugins/piexif.js'));
22
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/js/plugins/sortable.js'));
23
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/js/fileinput.js'));
24
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/js/locales/es.js'));
25
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/themes/fas/theme.js'));
26
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/themes/explorer-fas/theme.js'));
27
 
28
 
1481 eleazar 29
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/jquery.validate.js'));
30
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/additional-methods.js'));
31
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/localization/messages_es.js'));
32
 
33
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-bs4/css/dataTables.bootstrap4.min.css'));
34
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-responsive/css/responsive.bootstrap4.min.css'));
35
 
36
$this->inlineScript()->appendFile($this->basePath('plugins/datatables/jquery.dataTables.min.js'));
37
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-bs4/js/dataTables.bootstrap4.min.js'));
38
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/dataTables.responsive.min.js'));
39
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/responsive.bootstrap4.min.js'));
40
 
41
 
42
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/jquery.validate.js'));
43
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/additional-methods.js'));
44
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/localization/messages_es.js'));
45
 
46
 
47
 
48
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
49
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
50
 
51
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-confirmation/dist/bootstrap-confirmation.js'));
52
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-checkbox/awesome-bootstrap-checkbox.css'));
53
 
54
 
55
$this->inlineScript()->captureStart();
56
echo <<<JS
57
 
58
 
59
jQuery( document ).ready(function( $ ) {
60
 
61
    var allowAdd = $allowAdd;
62
    var allowDelete = $allowDelete
63
 
64
        var gridTable = $('#gridTable').dataTable( {
65
            'processing': true,
66
            'serverSide': true,
67
            'searching': true,
68
            'order': [[ 1, 'asc' ]],
69
            'ordering':  true,
70
            'ordenable' : true,
71
            'responsive': true,
72
            'select' : false,
73
        	'paging': true,
74
            'pagingType': 'simple_numbers',
75
            'lengthMenu': [ [10, 25, 50, -1], [10, 25, 50, 'All'] ],
76
 
77
    		'ajax': {
78
    			'url' : '$routeDatatable',
79
    			'type' : 'get',
80
                'data': function ( d ) {
81
                    d.vacancy_uuid = $('#form-filter #form_uuid').val();
82
 
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');
1484 eleazar 178
                     validatorAdd.resetForm();
179
 
180
                     $('#add-job-box').modal('show');
181
                     return false;
1485 eleazar 182
                    });
1484 eleazar 183
 
1491 eleazar 184
                    $(".close-box, .btn-add-cancel").on("click", function(e){
1485 eleazar 185
                         e.preventDefault();
186
                         $('#add-job-box').modal('hide');
187
                         return false;
188
                    });
189
 
1486 eleazar 190
    var validatorAdd = $('#form-add').validate({
191
        debug: true,
192
        onclick: false,
193
        onkeyup: false,
194
        onfocusout: false,
195
        ignore: [],
196
        rules: {
1489 eleazar 197
            'first_name': {
1486 eleazar 198
                required: true,
199
                maxlength: 128,
1481 eleazar 200
            },
1486 eleazar 201
            'file': {
202
                required: true,
203
                extension: 'pdf|docx',
1495 eleazar 204
                accept: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/msword,application/pdf'
1486 eleazar 205
            },
206
            'last_name': {
207
                required: true,
208
            },
209
            'email' :  {
210
                required: true,
211
            }
212
        },
213
        submitHandler: function(form)
214
        {
215
            var formdata = false;
216
            if (window.FormData){
217
                formdata = new FormData(form); //form[0]);
218
            }
219
 
220
            $('input[type="submit"]').prop('disabled', true);
221
 
222
            $.ajax({
223
                'dataType'  : 'json',
224
                'accept'    : 'application/json',
225
                'method'    : 'post',
1494 eleazar 226
                'url'       :  $('#form-add').attr('action'),
1486 eleazar 227
                'data'      :  formdata,
228
                'processData': false,
229
                'contentType': false,
230
            }).done(function(response) {
231
                if(response['success']) {
232
                    $.fn.showSuccess(response['data']);
233
 
234
                    $('#add-job-box').modal('hide');
235
                    gridTable.api().ajax.reload(null, false);
236
                } else {
237
                    validatorAdd.resetForm();
238
                    if(jQuery.type(response['data']) == 'string') {
239
                        $.fn.showError(response['data']);
240
                    } else  {
241
                        $.each(response['data'], function( fieldname, errors ) {
1494 eleazar 242
                            $.fn.showFormErrorValidator('#form-add #' + fieldname, errors);
1486 eleazar 243
                        });
244
                    }
245
                }
246
            }).fail(function( jqXHR, textStatus, errorThrown) {
247
                $.fn.showError(textStatus);
248
            }).always(function() {
249
                NProgress.done();
250
            });
251
            return false;
252
        },
253
        invalidHandler: function(form, validator) {
254
 
255
        }
256
    });
257
 
258
            },
1481 eleazar 259
            'aoColumns': [
260
                { 'mDataProp': 'first_name' },
261
                { 'mDataProp': 'last_name' },
262
                { 'mDataProp': 'email' },
263
                { 'mDataProp': 'actions' },
264
    	    ],
265
            'columnDefs': [
266
 
267
 
268
                {
269
                    'targets': -1,
270
                    'orderable': false,
271
                    'render' : function ( data, type, row ) {
272
                        s = '';
273
 
274
                        if(allowDelete && data['link_delete']  ) {
275
                            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;';
276
                        }
277
 
278
                        if(allowAdd && data['link_add']  ) {
279
                            s = s + '<button class="btn btn-primary btn-sm btn-add" data-href="' + data['link_add']+ '" data-toggle="tooltip" title="LABEL_ADD"><i class="fa fa-plus"></i> LABEL_ADD </button>&nbsp;';
280
                        }
281
 
282
                        return s;
283
                    }
284
                }
285
              ],
286
        });
287
 
288
    $('#form-filter #form_uuid').change(function(e) {
289
        e.preventDefault();
290
 
291
        gridTable.api().ajax.reload(null, false);
292
    })
293
 
294
 
295
    $('body').on('click', 'button.btn-refresh', function(e) {
296
        e.preventDefault();
297
        gridTable.api().ajax.reload(null, false);
298
    });
299
});
300
JS;
301
$this->inlineScript()->captureEnd();
302
?>
303
 
304
 
305
<!-- Content Header (Page header) -->
306
<section class="content-header">
307
	<div class="container-fluid">
308
    	<div class="row mb-2">
309
        	<div class="col-sm-12">
310
            	<h1>LABEL_CANDIDATES</h1>
311
			</div>
312
		</div>
313
	</div><!-- /.container-fluid -->
314
</section>
315
 
316
<section class="content">
317
	<div class="container-fluid">
318
    	<div class="row">
319
        	<div class="col-12">
320
				<div class="card">
321
					<div class="card-header">
322
						<?php
1486 eleazar 323
                        // $form = $this->form;
1481 eleazar 324
            	        $form->setAttributes([
325
                            'name'    => 'form-filter',
326
                            'id'      => 'form-filter',
327
                        ]);
328
 
329
                        $form->prepare();
330
                        echo $this->form()->openTag($form);
331
                        ?>
332
                        <div class="row">
333
                            <div class="col-md-6 col-sm-12">
334
                                <div class="form-group">
335
                                    <?php
336
                                    $element = $form->get('form_uuid');
337
 
1484 eleazar 338
                                    $element->setOptions(['label' => 'LABEL_VACANCIES']);
1481 eleazar 339
 
340
                                    $element->setAttributes(['class' => 'form-control']);
341
                                    echo $this->formLabel($element);
342
                                    echo $this->formSelect($element);
343
                                    ?>
344
                                </div>
345
                            </div>
346
 
347
                        </div>
348
						<?php echo $this->form()->closeTag($form); ?>
349
					</div>
350
					<div class="card-body">
351
        	    		<table id="gridTable" class="table   table-hover">
352
                      		<thead>
353
        						<tr>
354
                                	<th>LABEL_FIRST_NAME</th>
355
                                	<th>LABEL_LAST_NAME</th>
356
                                	<th>LABEL_EMAIL</th>
357
                                  	<th>LABEL_ACTIONS</th>
358
                                </tr>
359
                       		</thead>
360
                         	<tbody>
361
                         	</tbody>
362
                    	</table>
363
                   	</div>
1483 eleazar 364
                       <div class="card-footer clearfix">
365
                       		<div style="float:right;">
366
    							<button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
367
    							<?php if($allowAdd) : ?>
368
    							<button type="button" class="btn btn-primary btn-add"><i class="fa fa-plus"></i> LABEL_ADD </button>
369
    							<?php endif; ?>
370
    						</div>
371
                     	</div>
1481 eleazar 372
          		</div>
373
           	</div>
374
        </div>
375
 	</div>
376
</section>
1485 eleazar 377
<div class="modal" tabindex="-1" role="dialog" id="add-job-box">
378
	<div class="modal-dialog" role="document">
379
		<?php
1487 eleazar 380
	    //$form = $this->formA;
1485 eleazar 381
	    $form->setAttributes([
382
	       'method'    => 'post',
383
	        'name'      => 'form-add',
1496 eleazar 384
            'action'    => $routeAdd,
1485 eleazar 385
	        'id'        => 'form-add'
386
	    ]);
387
	    $form->prepare();
388
	    echo $this->form()->openTag($form);
389
 
390
	    ?>
391
    	<div class="modal-content">
392
      		<div class="modal-header">
393
        		<h3 class="modal-title">LABEL_NEW_CANDIDATE</h3>
394
      		</div>
395
      		<div class="modal-body">
396
      			<div class="form-group">
397
    				<?php
398
                        $element = $form->get('first_name');
399
                        $element->setOptions(['label' => 'LABEL_FIRST_NAME']);
400
                        $element->setAttributes(['class' => 'form-control']);
401
                        echo $this->formLabel($element);
402
                        echo $this->formText($element);
403
                    ?>
404
				</div>
405
				<div class="form-group">
406
    				<?php
407
                        $element = $form->get('last_name');
408
                        $element->setOptions(['label' => 'LABEL_LAST_NAME']);
409
                        $element->setAttributes(['class' => 'form-control']);
410
                        echo $this->formLabel($element);
411
                        echo $this->formText($element);
412
                    ?>
413
				</div>
414
      			<div class="form-group">
415
    				<?php
416
                        $element = $form->get('email');
417
                        $element->setOptions(['label' => 'LABEL_EMAIL']);
418
                        $element->setAttributes(['class' => 'form-control']);
419
                        echo $this->formLabel($element);
420
                        echo $this->formText($element);
421
                    ?>
422
				</div>
423
 
424
				<div class="form-group">
425
    				<?php
426
                    $element = $form->get('file');
427
 
428
                    $element->setAttributes(['class' => 'form-control',  'accept' => 'pdf/docx']);
429
                    $element->setOptions(['label' => 'LABEL_CURRICULUM']);
430
                    echo $this->formLabel($element);
431
                    ?>
432
                    <div class="file-loading">
433
                    	<?php echo $this->formFile($element); ?>
1493 eleazar 434
                    </div>
1485 eleazar 435
				</div>
436
          	</div>
437
         	<div class="modal-footer">
438
    			<button type="submit" class="btn btn-primary">LABEL_SAVE</button>
439
    			<button type="button" class="btn btn-default btn-add-cancel">LABEL_CANCEL</button>
440
          	</div>
441
      	<?php echo $this->form()->closeTag($form); ?>
442
    	</div>
443
	</div>
444
</div>