Merge pull request #19 from PootisPenserHere/creatingNewEmployeeFromView
Creating new employee from view
This commit is contained in:
commit
99a020024e
7
api-payroll/public/css/bootstrap-datepicker.min.css
vendored
Normal file
7
api-payroll/public/css/bootstrap-datepicker.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -54,15 +54,12 @@ body {
|
|||||||
background: #C6E97C;
|
background: #C6E97C;
|
||||||
}
|
}
|
||||||
|
|
||||||
#modal_header_error{
|
.modalHeaderError{
|
||||||
background-color: #d9534f;
|
background-color: #d9534f;
|
||||||
}
|
}
|
||||||
|
|
||||||
#modal_header_respuesa_servidor_error{
|
|
||||||
background-color: #d9534f;
|
|
||||||
}
|
|
||||||
|
|
||||||
#modal_header_respuesa_servidor_success{
|
.modalHeaderSuccess{
|
||||||
background-color: #5bc0de;
|
background-color: #5bc0de;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
<script src="../js/NewEmployee.js"></script>
|
<script src="../js/NewEmployee.js"></script>
|
||||||
|
<script src="../js/getBaseUrl.js"></script>
|
||||||
|
|
||||||
<form class="form-horizontal" id="newEmployeeForm">
|
<form class="form-horizontal" id="newEmployeeForm">
|
||||||
<div class="col-md-12">
|
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<h3 class="panel-title">New employee</h3>
|
<h3 class="panel-title">New employee</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
<div class="col-md-6">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-md-4 control-label" for="newEmployeeFirstName">First name</label>
|
<label class="col-md-4 control-label" for="newEmployeeFirstName">First name</label>
|
||||||
@ -20,17 +21,71 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-md-4 control-label" for="newEmployeeMiddleName">Middle name</label>
|
<label class="col-md-4 control-label" for="newEmployeeMiddleName">Middle name</label>
|
||||||
<div class="col-md-5">
|
<div class="col-md-5">
|
||||||
<input id="newEmployeeMiddleName" name="newEmployeeMiddleName" type="number" class="form-control input-md">
|
<input id="newEmployeeMiddleName" name="newEmployeeMiddleName" type="text" class="form-control input-md">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-12">
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<a href="#" class="btn btn-lg btn-success" onclick="saveNewEmployee();">Save</a>
|
<label class="col-md-4 control-label" for="newEmployeeLastName">Last name</label>
|
||||||
|
<div class="col-md-5">
|
||||||
|
<input id="newEmployeeLastName" name="newEmployeeLastName" type="text" class="form-control input-md">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-md-4 control-label" for="newEmployeeBirthDate">Birth date</label>
|
||||||
|
<div class="col-md-5">
|
||||||
|
<input id="newEmployeeBirthDate" name="newEmployeeBirthDate" type="text" class="form-control input-md datepicker">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-md-4 control-label" for="newEmployeeEmail">Email</label>
|
||||||
|
<div class="col-md-5">
|
||||||
|
<input id="newEmployeeEmail" name="newEmployeeEmail" type="text" class="form-control input-md">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-md-4 control-label" for="newEmployeePhone">Phone</label>
|
||||||
|
<div class="col-md-5">
|
||||||
|
<input id="newEmployeePhone" name="newEmployeePhone" type="text" class="form-control input-md">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-md-4 control-label" for="newEmployeeType">Rol</label>
|
||||||
|
<div class="col-md-5">
|
||||||
|
<select class="form-control input-md" name="newEmployeeType" id="newEmployeeType">
|
||||||
|
<option>Employee type</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-md-4 control-label" for="NewEmpployyContractType">Contract type</label>
|
||||||
|
<div class="col-md-5">
|
||||||
|
<select class="form-control input-md" name="NewEmpployyContractType" id="NewEmpployyContractType">
|
||||||
|
<option>Contract type</option>
|
||||||
|
<option value="INTERNO">interno</option>
|
||||||
|
<option value="EXTERNO">Externo</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row col-md-offset-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<a href="#" class="btn btn-lg btn-success " onclick="saveNewEmployee();">Create</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -64,11 +64,11 @@ if(!isset($_SESSION['userName'])){
|
|||||||
=================================================================================
|
=================================================================================
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<div id="modal_error_internet" class="modal fade" role="dialog">
|
<div id="modalErrorInternetConnection" class="modal fade" role="dialog">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
|
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header" id="modal_header_error">
|
<div class="modal-header modalHeaderError">
|
||||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||||
<h4 class="modal-title">An error has occurred</h4>
|
<h4 class="modal-title">An error has occurred</h4>
|
||||||
</div>
|
</div>
|
||||||
@ -83,11 +83,11 @@ if(!isset($_SESSION['userName'])){
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="modal_error_404" class="modal fade" role="dialog">
|
<div id="modalError404" class="modal fade" role="dialog">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
|
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header" id="modal_header_error">
|
<div class="modal-header modalHeaderError">
|
||||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||||
<h4 class="modal-title">An error has occurred</h4>
|
<h4 class="modal-title">An error has occurred</h4>
|
||||||
</div>
|
</div>
|
||||||
@ -102,11 +102,11 @@ if(!isset($_SESSION['userName'])){
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="modal_error_500" class="modal fade" role="dialog">
|
<div id="modalError500" class="modal fade" role="dialog">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
|
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header" id="modal_header_error">
|
<div class="modal-header modalHeaderError">
|
||||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||||
<h4 class="modal-title">An error has occurred</h4>
|
<h4 class="modal-title">An error has occurred</h4>
|
||||||
</div>
|
</div>
|
||||||
@ -121,11 +121,11 @@ if(!isset($_SESSION['userName'])){
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="modal_error_parsererror" class="modal fade" role="dialog">
|
<div id="modalErrorParsererror" class="modal fade" role="dialog">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
|
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header" id="modal_header_error">
|
<div class="modal-header modalHeaderError">
|
||||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||||
<h4 class="modal-title">An error has occurred</h4>
|
<h4 class="modal-title">An error has occurred</h4>
|
||||||
</div>
|
</div>
|
||||||
@ -140,11 +140,11 @@ if(!isset($_SESSION['userName'])){
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="modal_error_timeout" class="modal fade" role="dialog">
|
<div id="modalErrorTimeout" class="modal fade" role="dialog">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
|
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header" id="modal_header_error">
|
<div class="modal-header modalHeaderError">
|
||||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||||
<h4 class="modal-title">An error has occurred</h4>
|
<h4 class="modal-title">An error has occurred</h4>
|
||||||
</div>
|
</div>
|
||||||
@ -159,11 +159,11 @@ if(!isset($_SESSION['userName'])){
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="modal_error_otro" class="modal fade" role="dialog">
|
<div id="modalErrorOther" class="modal fade" role="dialog">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
|
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header" id="modal_header_error">
|
<div class="modal-header modalHeaderError">
|
||||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||||
<h4 class="modal-title">An error has occurred</h4>
|
<h4 class="modal-title">An error has occurred</h4>
|
||||||
</div>
|
</div>
|
||||||
@ -184,16 +184,16 @@ if(!isset($_SESSION['userName'])){
|
|||||||
=================================================================================
|
=================================================================================
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<div id="modal_server_response_error" class="modal fade" role="dialog">
|
<div id="modalServerResponseError" class="modal fade" role="dialog">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
|
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header" id="modal_header_server_response_error">
|
<div class="modal-header modalHeaderError">
|
||||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||||
<h4 class="modal-title">An error has occurred</h4>
|
<h4 class="modal-title">An error has occurred</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<p id="server_response_error"></p>
|
<p id="modalResponseError"></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
|
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
|
||||||
@ -203,16 +203,16 @@ if(!isset($_SESSION['userName'])){
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="modal_server_response_success" class="modal fade" role="dialog">
|
<div id="modalServerResponseSuccess" class="modal fade" role="dialog">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
|
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header" id="modal_header_server_response_success">
|
<div class="modal-header modalHeaderSuccess" id="modalHeaderServerResponseSuccess">
|
||||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||||
<h4 class="modal-title">Success</h4>
|
<h4 class="modal-title">Success</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<p id="server_response_success"></p>
|
<p id="serverResponseSuccess"></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
|
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
|
||||||
@ -225,4 +225,7 @@ if(!isset($_SESSION['userName'])){
|
|||||||
|
|
||||||
<script src="../js/getBaseUrl.js"></script>
|
<script src="../js/getBaseUrl.js"></script>
|
||||||
<script src="../js/landing.js"></script>
|
<script src="../js/landing.js"></script>
|
||||||
|
<script src="../js/bootstrap-datepicker.min.js"></script>
|
||||||
|
|
||||||
|
<link href="../css/bootstrap-datepicker.min.css" rel="stylesheet">
|
||||||
<link href="../css/landing.css" rel="stylesheet">
|
<link href="../css/landing.css" rel="stylesheet">
|
@ -1,3 +1,94 @@
|
|||||||
function saveNewEmployee(){
|
/**
|
||||||
console.log('saving...');
|
* Bootstrapping the starting actions for the module
|
||||||
|
*/
|
||||||
|
$(document).ready(function(){
|
||||||
|
loadEmployeeTypes();
|
||||||
|
|
||||||
|
$('.datepicker').datepicker({
|
||||||
|
format: "yyyy/mm/dd",
|
||||||
|
autoclose: true
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the the enmployee types into their select option
|
||||||
|
*/
|
||||||
|
function loadEmployeeTypes(){
|
||||||
|
let baseUrl = getbaseUrl();
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: baseUrl + '/api/employee/types',
|
||||||
|
type: 'GET',
|
||||||
|
dataType: 'json',
|
||||||
|
success:function(data){
|
||||||
|
$(data).each(function(i,v){
|
||||||
|
$('#newEmployeeType').append(
|
||||||
|
'<option value="' + v.id + '">'+ v.name + '</option>'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
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');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function saveNewEmployee(){
|
||||||
|
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()
|
||||||
|
};
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: baseUrl + '/api/employee',
|
||||||
|
type: 'POST',
|
||||||
|
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'];
|
||||||
|
},
|
||||||
|
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');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
8
api-payroll/public/js/bootstrap-datepicker.min.js
vendored
Normal file
8
api-payroll/public/js/bootstrap-datepicker.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -14,15 +14,15 @@ function logout() {
|
|||||||
},
|
},
|
||||||
error:function(x,e) {
|
error:function(x,e) {
|
||||||
if (x.status==0) {
|
if (x.status==0) {
|
||||||
$('#modal_error_internet').modal('show');
|
$('#modalErrorInternetConnection').modal('show');
|
||||||
} else if(x.status==404) {
|
} else if(x.status==404) {
|
||||||
$('#modal_error_404').modal('show');
|
$('#modalError404').modal('show');
|
||||||
} else if(x.status==500) {
|
} else if(x.status==500) {
|
||||||
$('#modal_error_500').modal('show');
|
$('#modalError500').modal('show');
|
||||||
} else if(e=='parsererror') {
|
} else if(e=='parsererror') {
|
||||||
$('#modal_error_parsererror').modal('show');
|
$('#modalErrorParsererror').modal('show');
|
||||||
} else if(e=='timeout'){
|
} else if(e=='timeout'){
|
||||||
$('#modal_error_timeout').modal('show');
|
$('#modalErrorTimeout').modal('show');
|
||||||
} else {
|
} else {
|
||||||
$('#modal_error_otro').modal('show');
|
$('#modal_error_otro').modal('show');
|
||||||
}
|
}
|
||||||
@ -60,15 +60,15 @@ function loadView(requestedView){
|
|||||||
},
|
},
|
||||||
error:function(x,e) {
|
error:function(x,e) {
|
||||||
if (x.status==0) {
|
if (x.status==0) {
|
||||||
$('#modal_error_internet').modal('show');
|
$('#modalErrorInternetConnection').modal('show');
|
||||||
} else if(x.status==404) {
|
} else if(x.status==404) {
|
||||||
$('#modal_error_404').modal('show');
|
$('#modalError404').modal('show');
|
||||||
} else if(x.status==500) {
|
} else if(x.status==500) {
|
||||||
$('#modal_error_500').modal('show');
|
$('#modalError500').modal('show');
|
||||||
} else if(e=='parsererror') {
|
} else if(e=='parsererror') {
|
||||||
$('#modal_error_parsererror').modal('show');
|
$('#modalErrorParsererror').modal('show');
|
||||||
} else if(e=='timeout'){
|
} else if(e=='timeout'){
|
||||||
$('#modal_error_timeout').modal('show');
|
$('#modalErrorTimeout').modal('show');
|
||||||
} else {
|
} else {
|
||||||
$('#modal_error_otro').modal('show');
|
$('#modal_error_otro').modal('show');
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,9 @@ $(document).keypress(function(e) {
|
|||||||
* display errors to the user
|
* display errors to the user
|
||||||
*/
|
*/
|
||||||
function processLogin() {
|
function processLogin() {
|
||||||
var baseUrl = getbaseUrl();
|
let baseUrl = getbaseUrl();
|
||||||
|
|
||||||
var parameters = {
|
let parameters = {
|
||||||
"userName":$('#userName').val(),
|
"userName":$('#userName').val(),
|
||||||
"password":$('#password').val()
|
"password":$('#password').val()
|
||||||
};
|
};
|
||||||
@ -29,7 +29,6 @@ function processLogin() {
|
|||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
data: parameters,
|
data: parameters,
|
||||||
success:function(data){
|
success:function(data){
|
||||||
console.log(JSON.stringify(data));
|
|
||||||
if(data["status"] == "success"){
|
if(data["status"] == "success"){
|
||||||
window.location.replace(baseUrl + '/html/landing.php');
|
window.location.replace(baseUrl + '/html/landing.php');
|
||||||
|
|
||||||
|
@ -138,6 +138,7 @@ class EmployeeApplication{
|
|||||||
$email = $requestData['email'];
|
$email = $requestData['email'];
|
||||||
$this->asserts->isNotEmpty($email, "The email can't be empty.");
|
$this->asserts->isNotEmpty($email, "The email can't be empty.");
|
||||||
$this->asserts->betweenLength($email, 1, 100, "The middle name must have a length between 1 and 100 characters.");
|
$this->asserts->betweenLength($email, 1, 100, "The middle name must have a length between 1 and 100 characters.");
|
||||||
|
$this->asserts->isEmail($email, "The email isn't in a correct format");
|
||||||
|
|
||||||
$phone = $requestData['phone'];
|
$phone = $requestData['phone'];
|
||||||
$this->asserts->isNotEmpty($phone, "The phone number can't be empty.");
|
$this->asserts->isNotEmpty($phone, "The phone number can't be empty.");
|
||||||
@ -409,6 +410,7 @@ class EmployeeApplication{
|
|||||||
$email = $requestData['email'];
|
$email = $requestData['email'];
|
||||||
$this->asserts->isNotEmpty($email, "The email can't be empty.");
|
$this->asserts->isNotEmpty($email, "The email can't be empty.");
|
||||||
$this->asserts->betweenLength($email, 1, 100, "The middle name must have a length between 1 and 100 characters.");
|
$this->asserts->betweenLength($email, 1, 100, "The middle name must have a length between 1 and 100 characters.");
|
||||||
|
$this->asserts->isEmail($email, "The email isn't in a correct format");
|
||||||
|
|
||||||
$phone = $requestData['phone'];
|
$phone = $requestData['phone'];
|
||||||
$this->asserts->isNotEmpty($phone, "The phone number can't be empty.");
|
$this->asserts->isNotEmpty($phone, "The phone number can't be empty.");
|
||||||
|
@ -56,5 +56,18 @@ class Asserts{
|
|||||||
throw new Exception($errorMessage);
|
throw new Exception($errorMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compares a string against a regex to determine if it's an email
|
||||||
|
*
|
||||||
|
* @param $string string
|
||||||
|
* @param $errorMessage string
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
function isEmail($string, $errorMessage){
|
||||||
|
if(!filter_var($string, FILTER_VALIDATE_EMAIL)){
|
||||||
|
throw new Exception($errorMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -11,7 +11,7 @@ CREATE TABLE IF NOT EXISTS `persons` (
|
|||||||
`lastName` varbinary(500) comment 'The last name of the person',
|
`lastName` varbinary(500) comment 'The last name of the person',
|
||||||
`birthDate` DATE NOT NULL DEFAULT '1900-01-01' comment 'Date of birth of the person',
|
`birthDate` DATE NOT NULL DEFAULT '1900-01-01' comment 'Date of birth of the person',
|
||||||
`email` varbinary(500) NOT NULL comment 'The email adress of the person',
|
`email` varbinary(500) NOT NULL comment 'The email adress of the person',
|
||||||
`phone` INT(10) UNSIGNED NOT NULL comment 'The phone number of the person should be the mobile one but leaves room for home ones',
|
`phone` BIGINT(10) UNSIGNED NOT NULL comment 'The phone number of the person should be the mobile one but leaves room for home ones',
|
||||||
`status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
|
`status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
|
||||||
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment 'The date on which the registry was created',
|
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment 'The date on which the registry was created',
|
||||||
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment 'The date of the last time the row was modified',
|
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment 'The date of the last time the row was modified',
|
||||||
|
Loading…
Reference in New Issue
Block a user