Proyectos de Subversion LeadersLinked - Backend

Rev

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