From facc32f13331498999ee07d467ea4ef420ebf190 Mon Sep 17 00:00:00 2001 From: Philip Häusler Date: Sat, 19 Dec 2015 23:31:08 +0100 Subject: #198 add basic driver license information --- includes/model/UserDriverLicenses_model.php | 69 +++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 includes/model/UserDriverLicenses_model.php (limited to 'includes/model') diff --git a/includes/model/UserDriverLicenses_model.php b/includes/model/UserDriverLicenses_model.php new file mode 100644 index 00000000..b99c8b1b --- /dev/null +++ b/includes/model/UserDriverLicenses_model.php @@ -0,0 +1,69 @@ + 0) + return $user_driver_license[0]; + return null; +} + +/** + * Create a user's driver license entry + * + * @param bool $user_id + * @param bool $has_car + * @param bool $has_license_car + * @param bool $has_license_3_5t_transporter + * @param bool $has_license_7_5t_truck + * @param bool $has_license_12_5t_truck + * @param bool $has_license_forklift + */ +function UserDriverLicenses_create($user_id, $has_car, $has_license_car, $has_license_3_5t_transporter, $has_license_7_5t_truck, $has_license_12_5t_truck, $has_license_forklift) { + return sql_query(" + INSERT INTO `UserDriverLicenses` SET + `user_id`=" . sql_escape($user_id) . ", + `has_car`=" . sql_bool($has_car) . ", + `has_license_car`=" . sql_bool($has_license_car) . ", + `has_license_3_5t_transporter`=" . sql_bool($has_license_3_5t_transporter) . ", + `has_license_7_5t_truck`=" . sql_bool($has_license_7_5t_truck) . ", + `has_license_12_5t_truck`=" . sql_bool($has_license_12_5t_truck) . ", + `has_license_forklift`=" . sql_bool($has_license_forklift)); +} + +/** + * Update a user's driver license entry + * + * @param bool $user_id + * @param bool $has_car + * @param bool $has_license_car + * @param bool $has_license_3_5t_transporter + * @param bool $has_license_7_5t_truck + * @param bool $has_license_12_5t_truck + * @param bool $has_license_forklift + */ +function UserDriverLicenses_update($user_id, $has_car, $has_license_car, $has_license_3_5t_transporter, $has_license_7_5t_truck, $has_license_12_5t_truck, $has_license_forklift) { + return sql_query("UPDATE `UserDriverLicenses` SET + `has_car`=" . sql_bool($has_car) . ", + `has_license_car`=" . sql_bool($has_license_car) . ", + `has_license_3_5t_transporter`=" . sql_bool($has_license_3_5t_transporter) . ", + `has_license_7_5t_truck`=" . sql_bool($has_license_7_5t_truck) . ", + `has_license_12_5t_truck`=" . sql_bool($has_license_12_5t_truck) . ", + `has_license_forklift`=" . sql_bool($has_license_forklift) . " + WHERE `user_id`='" . sql_escape($user_id) . "'"); +} + +/** + * Delete a user's driver license entry + * + * @param int $user_id + */ +function UserDriverLicenses_delete($user_id) { + return sql_query("DELETE FROM `UserDriverLicenses` WHERE `user_id`=" . sql_escape($user_id)); +} +?> \ No newline at end of file -- cgit v1.2.3-70-g09d2