[add] Employee updated
This commit is contained in:
parent
b0a19c6daa
commit
a8148bbb93
@ -50,7 +50,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="row" id="hidenEmployeeCode">
|
||||
<div class="form-group">
|
||||
<label class="col-md-4 control-label" for="editEmployeeCode">Code</label>
|
||||
<div class="col-md-5">
|
||||
@ -102,7 +102,7 @@
|
||||
</div>
|
||||
<div class="row col-md-offset-6">
|
||||
<div class="form-group">
|
||||
<a href="#" class="btn btn-lg btn-success " onclick="saveeditEmployee();">Create</a>
|
||||
<a href="#" class="btn btn-lg btn-success " onclick="updateEmployee();">Update</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -6,6 +6,14 @@ $(document).ready(function(){
|
||||
|
||||
loadEmployeeTypes();
|
||||
|
||||
$('.datepicker').datepicker({
|
||||
format: "yyyy/mm/dd",
|
||||
autoclose: true
|
||||
});
|
||||
|
||||
// Not to be edited
|
||||
$("#hidenEmployeeCode").hide();
|
||||
|
||||
// Setting up bloodhound typeahead
|
||||
let employeesList = new Bloodhound({
|
||||
datumTokenizer: Bloodhound.tokenizers.obj.whitespace("name"),
|
||||
@ -130,24 +138,25 @@ function updateEmployee(){
|
||||
let baseUrl = getbaseUrl();
|
||||
|
||||
let parameters = {
|
||||
"firstName":$('#newEmployeeFirstName').val(),
|
||||
"middleName":$('#newEmployeeMiddleName').val(),
|
||||
"lastName":$('#newEmployeeLastName').val(),
|
||||
"birthDate":$('#newEmployeeBirthDate').val(),
|
||||
"email":$('#newEmployeeEmail').val(),
|
||||
"phone":$('#newEmployeePhone').val(),
|
||||
"idEmployeeType":$('#newEmployeeType').val(),
|
||||
"contractType":$('#NewEmpployyContractType').val()
|
||||
"firstName":$('#editEmployeeFirstName').val(),
|
||||
"middleName":$('#editEmployeeMiddleName').val(),
|
||||
"lastName":$('#editEmployeeLastName').val(),
|
||||
"birthDate":$('#editEmployeeBirthDate').val(),
|
||||
"code":$('#editEmployeeCode').val(),
|
||||
"email":$('#editEmployeeEmail').val(),
|
||||
"phone":$('#editEmployeePhone').val(),
|
||||
"idEmployeeType":$('#editEmployeeType').val(),
|
||||
"contractType":$('#editEmployeeContractType').val()
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
url: baseUrl + '/api/employee',
|
||||
type: 'POST',
|
||||
type: 'PUT',
|
||||
dataType: 'json',
|
||||
data: parameters,
|
||||
success:function(data){
|
||||
$('#modalServerResponseSuccess').modal('show');
|
||||
document.getElementById('serverResponseSuccess').innerHTML = 'The employee ' + data['fullName'] + ' has been created with the code ' + data['employeeCode'];
|
||||
document.getElementById('serverResponseSuccess').innerHTML = 'The employee ' + data['fullName'] + ' has been updated.';
|
||||
},
|
||||
error:function(x,e) {
|
||||
let responseText = $.parseJSON(x["responseText"]);
|
||||
|
@ -420,15 +420,12 @@ class EmployeeApplication{
|
||||
*/
|
||||
function updateEmployeeData($requestData){
|
||||
// Getting and validating the data
|
||||
$idEmployee = $requestData['idEmployee'];
|
||||
$this->asserts->higherThanZero($idEmployee, "idEmployee must be higher than 0");
|
||||
|
||||
$idPerson = $this->getIdPersonByIdEmployee($idEmployee);
|
||||
$this->asserts->higherThanZero($idPerson, "idPerson must be higher than 0");
|
||||
|
||||
$code = $requestData['code'];
|
||||
$this->asserts->isNotEmpty($code, "The code can't be empty.");
|
||||
|
||||
$idEmployee = $this->getIdEmployeeByCode($code);
|
||||
$idPerson = $this->getIdPersonByIdEmployee($idEmployee);
|
||||
|
||||
$firstName = $requestData['firstName'];
|
||||
$this->asserts->isNotEmpty($firstName, "The first name can't be empty.");
|
||||
$this->asserts->isString($firstName, "The first name must be a string.");
|
||||
|
Loading…
Reference in New Issue
Block a user