-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlink_rescue_docs.php
executable file
·90 lines (74 loc) · 2.58 KB
/
link_rescue_docs.php
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
<?php
// Start the page
require("template/header.php");
echo "<div class='newsbox'>";
echo "<div class='newstitle'>Link Documents to Rescues</div>";
echo "<div class='newscontent'>";
// If its a non-logged in user, display public text
if (!$theSentry->login())
{
echo "You need to be logged in to view this page";
}
else
{
if ($theSentry->hasPermission(3))
{
if (isset($_POST['doc_id']) && isset($_POST['rescue_id']))
{
$res = $theDB->doQuery("replace into rescue_docs (rescue_id,doc_id) values (".$_POST['rescue_id'].",".$_POST['doc_id'].");");
if ($res)
{
$theLogger->log("Doc_id ".$_POST['doc_id']." linked sucessfully to rescue_id ".$_POST['rescue_id']);
echo "Document linked sucessfully to Rescue<br/>";
}
else
{
echo "Document linking failed - ".$theDB->lasterror()."<br/>";
}
}
else
{
echo "<form action='link_rescue_docs.php' method='post'>";
echo "Select a Document:<br/><br/>";
$res = $theDB->fetchQuery("select doc_id,title,name from documents;");
if (!$res)
{
echo "No documents found!";
die();
}
else
{
echo "<select name=doc_id>";
for ($i=0; $i<count($res); $i++)
{
echo "<option value='".$res[$i]['doc_id']."'>".$res[$i]['title']."</option>";
}
echo "</select>";
}
echo "<br/><br/>";
echo "Select a Rescue:<br/><br/>";
$res = $theDB->fetchQuery("select r.date,r.rescue_id,c.name,c.county from rescues r, caves c where r.cave_id = c.cave_id order by date desc;");
if (!$res)
{
echo "No rescues found!";
die();
}
else
{
echo "<select name=rescue_id>";
for ($i=0; $i<count($res); $i++)
{
echo "<option value='".$res[$i]['rescue_id']."'>".$res[$i]['date']." - ".$res[$i]['name']."</option>";
}
echo "</select>";
}
echo "<br/><br/>";
echo "<INPUT TYPE='submit' value='Link Doc to Rescue'/>";
echo "</form>";
}
}
}
// End the page
echo "<div id='clear_both' style='clear:both;'></div></div>";
require("template/footer.html");
?>