Add shift deletion
This commit is contained in:
parent
05a0266a5d
commit
0a2ced319a
15
action.php
15
action.php
@ -120,6 +120,19 @@ switch ($VARS['action']) {
|
||||
} else {
|
||||
returnToSender("no_permission");
|
||||
}
|
||||
case "deleteshift":
|
||||
if (!$database->has('shifts', ['shiftid' => $VARS['shiftid']])) {
|
||||
returnToSender("invalid_shiftid");
|
||||
}
|
||||
if (account_has_permission($_SESSION['username'], "QWIKCLOCK_ADMIN")) {
|
||||
if ($database->has('assigned_shifts', ['shiftid' => $VARS['shiftid']])) {
|
||||
returnToSender('shift_has_users');
|
||||
}
|
||||
$database->delete('shifts', ['shiftid' => $VARS['shiftid']]);
|
||||
returnToSender("shift_deleted");
|
||||
} else {
|
||||
returnToSender("no_permission");
|
||||
}
|
||||
case "assignshift":
|
||||
if (!account_has_permission($_SESSION['username'], "QWIKCLOCK_MANAGE")) {
|
||||
returnToSender("no_permission");
|
||||
@ -178,7 +191,7 @@ switch ($VARS['action']) {
|
||||
|
||||
$resp = json_decode($response->getBody(), TRUE);
|
||||
if ($resp['status'] == "OK") {
|
||||
if (!account_has_permission($_SESSION['username'], "ADMIN")) {
|
||||
if (!account_has_permission($_SESSION['username'], "QWIKCLOCK_ADMIN")) {
|
||||
require_once __DIR__ . "/lib/userinfo.php";
|
||||
$managed = getManagedUIDs($_SESSION['uid']);
|
||||
$result = $resp['result'];
|
||||
|
@ -66,6 +66,8 @@ define("STRINGS", [
|
||||
"edit shift" => "Edit Shift",
|
||||
"shift added" => "Shift added.",
|
||||
"shift saved" => "Shift saved.",
|
||||
"shift deleted" => "Shift deleted.",
|
||||
"shift has users" => "Please un-assign all users before deleting the shift.",
|
||||
"invalid time format" => "Invalid time format. Please use HH:MM or HH:MM AM.",
|
||||
"shift name used" => "The shift name you gave is already in use. Use a different name or edit the existing shift.",
|
||||
"invalid shiftid" => "Invalid shift ID.",
|
||||
|
@ -45,6 +45,14 @@ define("MESSAGES", [
|
||||
"string" => "shift saved",
|
||||
"type" => "success"
|
||||
],
|
||||
"shift_deleted" => [
|
||||
"string" => "shift deleted",
|
||||
"type" => "success"
|
||||
],
|
||||
"shift_has_users" => [
|
||||
"string" => "shift has users",
|
||||
"type" => "danger"
|
||||
],
|
||||
"shift_name_used" => [
|
||||
"string" => "shift name used",
|
||||
"type" => "danger"
|
||||
|
@ -111,6 +111,13 @@ if (isset($VARS['id']) && $database->has('shifts', ['shiftid' => $VARS['id']]))
|
||||
|
||||
<div class="panel-footer">
|
||||
<button type="submit" class="btn btn-success"><i class="fa fa-floppy-o"></i> <?php lang("save"); ?></button>
|
||||
<?php
|
||||
if ($editing && account_has_permission($_SESSION['username'], "QWIKCLOCK_ADMIN")) {
|
||||
?>
|
||||
<a href="action.php?action=deleteshift&source=shifts&shiftid=<?php echo $data['shiftid']; ?>" class="btn btn-danger btn-xs pull-right mgn-top-8px"><i class="fa fa-times"></i> <?php lang('delete'); ?></a>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
Loading…
x
Reference in New Issue
Block a user