add shift entry create model
This commit is contained in:
parent
09e65d1a84
commit
9176261762
|
@ -7,8 +7,24 @@ function ShiftEntries_freeleaded_count() {
|
|||
return sql_select_single_cell("SELECT COUNT(*) FROM `ShiftEntry` WHERE `freeloaded` = 1");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new shift entry.
|
||||
*
|
||||
* @param ShiftEntry $shift_entry
|
||||
*/
|
||||
function ShiftEntry_create($shift_entry) {
|
||||
return sql_query("INSERT INTO `ShiftEntry` SET
|
||||
`SID`=" . sql_escape($shift_entry['SID']) . ",
|
||||
`TID`=" . sql_escape($shift_entry['TID']) . ",
|
||||
`UID`=" . sql_escape($shift_entry['UID']) . ",
|
||||
`Comment`='" . sql_escape($shift_entry['Comment']) . "',
|
||||
`freeload_comment`='" . sql_escape($shift_entry['freeload_comment']) . "',
|
||||
`freeloaded`=" . sql_escape($shift_entry['freeloaded'] ? 'TRUE' : 'FALSE'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns next (or current) shifts of given user.
|
||||
*
|
||||
* @param User $user
|
||||
*/
|
||||
function ShiftEntries_upcoming_for_user($user) {
|
||||
|
|
|
@ -246,13 +246,17 @@ function user_shifts() {
|
|||
}
|
||||
|
||||
$comment = strip_request_item_nl('comment');
|
||||
sql_query("INSERT INTO `ShiftEntry` SET
|
||||
`Comment`='" . sql_escape($comment) . "',
|
||||
`freeloaded`=" . sql_escape($freeloaded ? 1 : 0) . ",
|
||||
`freeload_comment`='" . sql_escape($freeload_comment) . "',
|
||||
`UID`=" . sql_escape($user_id) . ",
|
||||
`TID`=" . sql_escape($selected_type_id) . ",
|
||||
`SID`=" . sql_escape($shift_id));
|
||||
$result = ShiftEntry_create(array(
|
||||
'SID' => $shift_id,
|
||||
'TID' => $selected_type_id,
|
||||
'UID' => $user_id,
|
||||
'Comment' => $comment,
|
||||
'freeloaded' => $freeloaded,
|
||||
'freeload_comment' => $freeload_comment
|
||||
));
|
||||
if ($result === false)
|
||||
engelsystem_error('Unable to create shift entry.');
|
||||
|
||||
if ($type['restricted'] == 0 && sql_num_query("SELECT * FROM `UserAngelTypes` INNER JOIN `AngelTypes` ON `AngelTypes`.`id` = `UserAngelTypes`.`angeltype_id` WHERE `angeltype_id` = '" . sql_escape($selected_type_id) . "' AND `user_id` = '" . sql_escape($user_id) . "' ") == 0)
|
||||
sql_query("INSERT INTO `UserAngelTypes` (`user_id`, `angeltype_id`) VALUES ('" . sql_escape($user_id) . "', '" . sql_escape($selected_type_id) . "')");
|
||||
|
||||
|
|
Loading…
Reference in New Issue