|
|
|
@ -1,4 +1,67 @@
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Delete a shift by its external id.
|
|
|
|
|
*/
|
|
|
|
|
function Shift_delete_by_psid($shift_psid) {
|
|
|
|
|
return sql_query("DELETE FROM `Shifts` WHERE `PSID`=" . sql_escape($shift_psid));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Delete a shift.
|
|
|
|
|
*/
|
|
|
|
|
function Shift_delete($shift_id) {
|
|
|
|
|
return sql_query("DELETE FROM `Shifts` WHERE `SID`=" . sql_escape($shift_id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
|
|
|
|
* @return new shift id or false
|
|
|
|
|
*/
|
|
|
|
|
function Shift_create($shift) {
|
|
|
|
|
$result = sql_query("INSERT INTO `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']));
|
|
|
|
|
if ($result === false)
|
|
|
|
|
return false;
|
|
|
|
|
return sql_id();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return users shifts.
|
|
|
|
|
*/
|
|
|
|
|
function Shifts_by_user($user) {
|
|
|
|
|
return sql_select("
|
|
|
|
|
SELECT *
|
|
|
|
|