diff --git a/api-payroll/public/html/registerWorkDays.php b/api-payroll/public/html/registerWorkDays.php index 6551418..b036ef5 100644 --- a/api-payroll/public/html/registerWorkDays.php +++ b/api-payroll/public/html/registerWorkDays.php @@ -17,6 +17,80 @@ + +
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+ +
+ + +
+
+ +
+ +
+
+
Update diff --git a/api-payroll/public/js/editEmployee.js b/api-payroll/public/js/editEmployee.js index c51e545..2416684 100644 --- a/api-payroll/public/js/editEmployee.js +++ b/api-payroll/public/js/editEmployee.js @@ -52,7 +52,7 @@ $(document).ready(function(){ }); /** - * Loads the the enmployee types into their select option + * Loads the the employee types into their select option */ function loadEmployeeTypes(){ let baseUrl = getbaseUrl(); diff --git a/api-payroll/public/js/registerWorkDays.js b/api-payroll/public/js/registerWorkDays.js index e69de29..5ebbf45 100644 --- a/api-payroll/public/js/registerWorkDays.js +++ b/api-payroll/public/js/registerWorkDays.js @@ -0,0 +1,96 @@ +/** + * Bootstrapping the starting actions for the module + */ +$(document).ready(function(){ + let baseUrl = getbaseUrl(); + + loadEmployeeTypesForWorkDays(); + + $('.datepicker').datepicker({ + format: "yyyy/mm/dd", + autoclose: true + }); + + // Not to be edited + $("#hidenEmployeeCodeForWorkDays").hide(); + + // Setting up bloodhound typeahead + let employeesList = new Bloodhound({ + datumTokenizer: Bloodhound.tokenizers.obj.whitespace("name"), + queryTokenizer: Bloodhound.tokenizers.whitespace, + remote: { + 'cache': false, + url: baseUrl + '/api/employee/find', + + replace: function(url, uriEncodedQuery) { + + return url + '/' + uriEncodedQuery + + }, + wildcard: '%QUERY', + filter: function (data) { + return data; + } + } + }); + + employeesList.initialize(); + + $("#workDaysSearchEmployee").typeahead({ + hint: true, + highlight: true, + minLength: 3 + }, + { + name: "result", + displayKey: "fullName", + source: employeesList.ttAdapter() + }).bind("typeahead:selected", function(obj, datum, name) { + $(this).data("id", datum.code); + console.log(datum.code); + $('#hidenEmployeeCodeForWorkDaysCode').val(datum.code); // For future reference + }); +}); + + +/** + * Loads the the employee types into their select option + */ +function loadEmployeeTypesForWorkDays(){ + let baseUrl = getbaseUrl(); + + $.ajax({ + url: baseUrl + '/api/employee/types', + type: 'GET', + dataType: 'json', + success:function(data){ + $(data).each(function(i,v){ + $('#workDaysEmployeeRol').append( + '' + ); + + $('#workDaysEmployeePerformedRol').append( + '' + ); + }); + }, + error:function(x,e) { + let responseText = $.parseJSON(x["responseText"]); + + if (x.status==0) { + $('#modalErrorInternetConnection').modal('show'); + } else if(x.status==404) { + $('#modalError404').modal('show'); + } else if(x.status==500) { + $('#modalServerResponseError').modal('show'); + document.getElementById('modalResponseError').innerHTML = responseText['message']; + } else if(e=='parsererror') { + $('#modalErrorParsererror').modal('show'); + } else if(e=='timeout'){ + $('#modalErrorTimeout').modal('show'); + } else { + $('#modalErrorOther').modal('show'); + } + }, + }); +} \ No newline at end of file