reduce complexity of user driver license
This commit is contained in:
parent
9c4636f5c4
commit
7b8d191808
|
@ -88,7 +88,7 @@ function user_driver_license_edit_controller() {
|
||||||
$user_driver_license = UserDriverLicense($user_source['UID']);
|
$user_driver_license = UserDriverLicense($user_source['UID']);
|
||||||
if ($user_driver_license == null) {
|
if ($user_driver_license == null) {
|
||||||
$wants_to_drive = false;
|
$wants_to_drive = false;
|
||||||
$user_driver_license = UserDriverLicense_new($user_source);
|
$user_driver_license = UserDriverLicense_new();
|
||||||
} else {
|
} else {
|
||||||
$wants_to_drive = true;
|
$wants_to_drive = true;
|
||||||
}
|
}
|
||||||
|
@ -105,8 +105,8 @@ function user_driver_license_edit_controller() {
|
||||||
$user_driver_license['has_license_forklift'] = isset($_REQUEST['has_license_forklift']);
|
$user_driver_license['has_license_forklift'] = isset($_REQUEST['has_license_forklift']);
|
||||||
|
|
||||||
if (UserDriverLicense_valid($user_driver_license)) {
|
if (UserDriverLicense_valid($user_driver_license)) {
|
||||||
if ($user_driver_license == null) {
|
if ($user_driver_license['user_id'] == null) {
|
||||||
UserDriverLicenses_create($user_driver_license);
|
$user_driver_license = UserDriverLicenses_create($user_driver_license, $user);
|
||||||
} else {
|
} else {
|
||||||
UserDriverLicenses_update($user_driver_license);
|
UserDriverLicenses_update($user_driver_license);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
* Returns a new empty UserDriverLicense
|
* Returns a new empty UserDriverLicense
|
||||||
* FIXME entity object needed
|
* FIXME entity object needed
|
||||||
*/
|
*/
|
||||||
function UserDriverLicense_new($user) {
|
function UserDriverLicense_new() {
|
||||||
return [
|
return [
|
||||||
'user_id' => $user['UID'],
|
'user_id' => null,
|
||||||
'has_car' => false,
|
'has_car' => false,
|
||||||
'has_license_car' => false,
|
'has_license_car' => false,
|
||||||
'has_license_3_5t_transporter' => false,
|
'has_license_3_5t_transporter' => false,
|
||||||
|
@ -51,7 +51,8 @@ function UserDriverLicense($user_id) {
|
||||||
* @param UserDriverLicense $user_driver_license
|
* @param UserDriverLicense $user_driver_license
|
||||||
* The UserDriverLicense to create
|
* The UserDriverLicense to create
|
||||||
*/
|
*/
|
||||||
function UserDriverLicenses_create($user_driver_license) {
|
function UserDriverLicenses_create($user_driver_license, $user) {
|
||||||
|
$user_driver_license['user_id'] = $user['UID'];
|
||||||
$result = sql_query("
|
$result = sql_query("
|
||||||
INSERT INTO `UserDriverLicenses` SET
|
INSERT INTO `UserDriverLicenses` SET
|
||||||
`user_id`=" . sql_escape($user_driver_license['user_id']) . ",
|
`user_id`=" . sql_escape($user_driver_license['user_id']) . ",
|
||||||
|
@ -64,7 +65,7 @@ function UserDriverLicenses_create($user_driver_license) {
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
engelsystem_error('Unable to create user driver license');
|
engelsystem_error('Unable to create user driver license');
|
||||||
}
|
}
|
||||||
return $result;
|
return $user_driver_license;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue