Proyectos de Subversion LeadersLinked - Backend

Rev

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