-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschedule_briefing.php
More file actions
140 lines (129 loc) · 5.07 KB
/
schedule_briefing.php
File metadata and controls
140 lines (129 loc) · 5.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
/**
* Created by PhpStorm.
* User: Dale
* Date: 2015-03-06
* Time: 3:25 PM
*/
session_start();
require_once("require/basic.php");
require_once("require/secure.php");
require_once("require/rbriefing.php");
Secure(true);
$time = time();
$briefing = array("id" => 0,
"release_time" => implode("T", explode(" ", date("Y-m-d H:i:s", $time))),
"expire_time" => implode("T", explode(" ", date("Y-m-d H:i:s", $time + 3600))),
"human_title" => "",
"human_body" => "",
"zombie_title" => "",
"zombie_body" => "");
$editing = false;
if( isset( $_REQUEST["action"] ) )
{
$action = $_REQUEST["action"];
if( $action == "Submit" )
{
$release = $_REQUEST["release_time"];
$expire = $_REQUEST["expire_time"];
$human_title = $_REQUEST["human_title"];
$human_body = $_REQUEST["human_body"];
$zombie_title = $_REQUEST["zombie_title"];
$zombie_body = $_REQUEST["zombie_body"];
if (check_briefing_conflict($release, $expire))
{
set_alert("ERROR", "&This briefing conflicts with a scheduled briefing");
}
else
{
schedule_briefing($release, $expire, $human_title, $human_body, $zombie_title, $zombie_body);
set_alert("SUCCESS", "Briefing has been scheduled.");
}
}
elseif( $action == "Update" )
{
$id = $_REQUEST["id"];
$release = $_REQUEST["release_time"];
$expire = $_REQUEST["expire_time"];
$human_title = $_REQUEST["human_title"];
$human_body = $_REQUEST["human_body"];
$zombie_title = $_REQUEST["zombie_title"];
$zombie_body = $_REQUEST["zombie_body"];
update_briefing($id, $release, $expire, $human_title, $human_body, $zombie_title, $zombie_body);
set_alert("SUCCESS", "Briefing has been updated");
}
elseif( $action == "Delete")
{
$id = $_REQUEST["id"];
$result = delete_briefing($id);
if ($result)
{
set_alert("SUCCESS", "Briefing deleted successfully");
}
else
{
set_alert("ERROR", "Failed to delete briefing");
}
}
elseif( $action == "Edit" )
{
$id = $_REQUEST["id"];
$briefing = get_briefing($id);
$briefing["release_time"] = implode("T", explode(" ", $briefing["release_time"]));
$briefing["expire_time"] = implode("T", explode(" ", $briefing["expire_time"]));
$editing = true;
}
else
{
}
}
page_head();
?>
<div class="row">
<div class="col-md-12">
<h2>Manage Mission Briefings</h2>
</div>
</div>
<div class="row">
<div class="col-md-6">
<form action="" method="post">
<label>Release Time</label><input class="form-control" name="release_time" type="datetime-local" value="<?php echo $briefing['release_time'];?>"/><br/>
<label>Expire Time</label><input class="form-control" name="expire_time" type="datetime-local" value="<?php echo $briefing['expire_time'];?>"/><br/>
<label>Human Title</label><input class="form-control" name="human_title" type="text" value="<?php echo $briefing['human_title'];?>"/><br/>
<label>Human Briefing</label><br/>
<textarea class="form-control" name="human_body" cols="100" rows="10" style="resize: vertical"><?php echo $briefing['human_body'];?></textarea><br/>
<label>Zombie Title</label><input class="form-control" name="zombie_title" type="text" value="<?php echo $briefing['zombie_title'];?>"/><br/>
<label>Zombie Briefing</label><br/>
<textarea class="form-control" name="zombie_body" cols="100" rows="10" style="resize: vertical"><?php echo $briefing['zombie_body'];?></textarea><br/>
<?php
if ($editing)
{
echo "<input type='hidden' value='$briefing[id]' name='id'/>";
echo "<input class='btn btn-default' type='submit' value='Update' name='action'/>";
}
else
{
echo "<input class='btn btn-default' type='submit' value='Submit' name='action'/>";
}
?>
<input class='btn btn-default' type="submit" value="Clear" name="action"/>
</form>
</div>
<div id="table" class="col-md-6">
<label>Right click to edit/delete</label>
<?php gen_briefing_table(); ?>
</div>
</div>
<script type="text/javascript">
LoadTableData( <?php echo json_encode(get_briefings()); ?>);
var actions = { "Edit" : { "type" : "post" },
"Delete" : { "type" : "post",
"confirm":true,
"message" : "Are you sure you would like to delete ",
"columns" : ["title"] } };
var briefingTable = new Table( <?php echo json_encode($briefingProperties); ?>, { }, actions );
briefingTable.take( $("#table"), false );
</script>
<?php
page_foot();
?>