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 {
|
} else {
|
||||||
returnToSender("no_permission");
|
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":
|
case "assignshift":
|
||||||
if (!account_has_permission($_SESSION['username'], "QWIKCLOCK_MANAGE")) {
|
if (!account_has_permission($_SESSION['username'], "QWIKCLOCK_MANAGE")) {
|
||||||
returnToSender("no_permission");
|
returnToSender("no_permission");
|
||||||
@ -178,7 +191,7 @@ switch ($VARS['action']) {
|
|||||||
|
|
||||||
$resp = json_decode($response->getBody(), TRUE);
|
$resp = json_decode($response->getBody(), TRUE);
|
||||||
if ($resp['status'] == "OK") {
|
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";
|
require_once __DIR__ . "/lib/userinfo.php";
|
||||||
$managed = getManagedUIDs($_SESSION['uid']);
|
$managed = getManagedUIDs($_SESSION['uid']);
|
||||||
$result = $resp['result'];
|
$result = $resp['result'];
|
||||||
|
@ -66,6 +66,8 @@ define("STRINGS", [
|
|||||||
"edit shift" => "Edit Shift",
|
"edit shift" => "Edit Shift",
|
||||||
"shift added" => "Shift added.",
|
"shift added" => "Shift added.",
|
||||||
"shift saved" => "Shift saved.",
|
"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.",
|
"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.",
|
"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.",
|
"invalid shiftid" => "Invalid shift ID.",
|
||||||
|
@ -45,6 +45,14 @@ define("MESSAGES", [
|
|||||||
"string" => "shift saved",
|
"string" => "shift saved",
|
||||||
"type" => "success"
|
"type" => "success"
|
||||||
],
|
],
|
||||||
|
"shift_deleted" => [
|
||||||
|
"string" => "shift deleted",
|
||||||
|
"type" => "success"
|
||||||
|
],
|
||||||
|
"shift_has_users" => [
|
||||||
|
"string" => "shift has users",
|
||||||
|
"type" => "danger"
|
||||||
|
],
|
||||||
"shift_name_used" => [
|
"shift_name_used" => [
|
||||||
"string" => "shift name used",
|
"string" => "shift name used",
|
||||||
"type" => "danger"
|
"type" => "danger"
|
||||||
|
@ -111,6 +111,13 @@ if (isset($VARS['id']) && $database->has('shifts', ['shiftid' => $VARS['id']]))
|
|||||||
|
|
||||||
<div class="panel-footer">
|
<div class="panel-footer">
|
||||||
<button type="submit" class="btn btn-success"><i class="fa fa-floppy-o"></i> <?php lang("save"); ?></button>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
Loading…
x
Reference in New Issue
Block a user