add shift update model
This commit is contained in:
parent
fa0e38ebff
commit
d26f8aa12c
|
@ -1,7 +1,35 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update a shift.
|
||||||
|
*/
|
||||||
|
function Shift_update($shift) {
|
||||||
|
return sql_query("UPDATE `Shifts` SET
|
||||||
|
`start`=" . sql_escape($shift['start']) . ",
|
||||||
|
`end`=" . sql_escape($shift['end']) . ",
|
||||||
|
`RID`=" . sql_escape($shift['RID']) . ",
|
||||||
|
`name`=" . sql_null($shift['name']) . ",
|
||||||
|
`URL`=" . sql_null($shift['URL']) . ",
|
||||||
|
`PSID`=" . sql_null($shift['PSID']) . "
|
||||||
|
WHERE `SID`=" . sql_escape($shift['SID']));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update a shift by its external id.
|
||||||
|
*/
|
||||||
|
function Shift_update_by_psid($shift) {
|
||||||
|
return sql_query("UPDATE `Shifts` SET
|
||||||
|
`start`=" . sql_escape($shift['start']) . ",
|
||||||
|
`end`=" . sql_escape($shift['end']) . ",
|
||||||
|
`RID`=" . sql_escape($shift['RID']) . ",
|
||||||
|
`name`=" . sql_null($shift['name']) . ",
|
||||||
|
`URL`=" . sql_null($shift['URL']) . "
|
||||||
|
WHERE `PSID`=" . sql_escape($shift['PSID']));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new shift.
|
* Create a new shift.
|
||||||
|
*
|
||||||
* @return new shift id or false
|
* @return new shift id or false
|
||||||
*/
|
*/
|
||||||
function Shift_create($shift) {
|
function Shift_create($shift) {
|
||||||
|
|
|
@ -123,8 +123,11 @@ function admin_import() {
|
||||||
engelsystem_error('Unable to create shift.');
|
engelsystem_error('Unable to create shift.');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($events_updated as $event)
|
foreach ($events_updated as $event) {
|
||||||
sql_query("UPDATE `Shifts` SET `name`='" . sql_escape($event['name']) . "', `start`=" . sql_escape($event['start']) . ", `end`=" . sql_escape($event['end']) . ", `RID`=" . sql_escape($event['RID']) . ", `PSID`=" . sql_escape($event['PSID']) . ", `URL`='" . sql_escape($event['URL']) . "' WHERE `PSID`=" . sql_escape($event['PSID']) . " LIMIT 1");
|
$result = Shift_update_by_psid($event);
|
||||||
|
if ($result === false)
|
||||||
|
engelsystem_error('Unable to update shift.');
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($events_deleted as $event)
|
foreach ($events_deleted as $event)
|
||||||
sql_query("DELETE FROM `Shifts` WHERE `PSID`=" . sql_escape($event['PSID']) . " LIMIT 1");
|
sql_query("DELETE FROM `Shifts` WHERE `PSID`=" . sql_escape($event['PSID']) . " LIMIT 1");
|
||||||
|
|
|
@ -125,7 +125,13 @@ function user_shifts() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($ok) {
|
if ($ok) {
|
||||||
sql_query("UPDATE `Shifts` SET `start`=" . sql_escape($start) . ", `end`=" . sql_escape($end) . ", `RID`=" . sql_escape($rid) . ", `name`='" . sql_escape($name) . "' WHERE `SID`=" . sql_escape($shift_id) . " LIMIT 1");
|
$shift['name'] = $name;
|
||||||
|
$shift['RID'] = $rid;
|
||||||
|
$shift['start'] = $start;
|
||||||
|
$shift['end'] = $end;
|
||||||
|
$result = Shift_update($shift);
|
||||||
|
if ($result === false)
|
||||||
|
engelsystem_error('Unable to update shift.');
|
||||||
sql_query("DELETE FROM `NeededAngelTypes` WHERE `shift_id`=" . sql_escape($shift_id));
|
sql_query("DELETE FROM `NeededAngelTypes` WHERE `shift_id`=" . sql_escape($shift_id));
|
||||||
$needed_angel_types_info = array();
|
$needed_angel_types_info = array();
|
||||||
foreach ($needed_angel_types as $type_id => $count) {
|
foreach ($needed_angel_types as $type_id => $count) {
|
||||||
|
|
Loading…
Reference in New Issue