/
bursary_give_rem.php
executable file
·148 lines (123 loc) · 3.33 KB
/
bursary_give_rem.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
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
141
142
143
144
145
146
147
148
<?
require ("settings.php");
if(isset($_POST["key"])){
switch ($_POST["key"]){
case "write":
$OUTPUT = write_details ($_POST);
break;
default:
$OUTPUT = confirm_details ($_POST);
}
}else {
$OUTPUT = confirm_details ($_POST);
}
require ("template.php");
function confirm_details ($_POST)
{
global $_GET;
extract ($_POST);
if(!isset($_GET["id"])){
return "Invalid use of module. Invalid ID.";
}
db_connect ();
$get_burs = "SELECT * FROM active_bursaries WHERE id = '$_GET[id]' LIMIT 1";
$run_burs = db_exec($get_burs) or errDie("Unable to get bursaries information.");
if(pg_numrows($run_burs) < 1){
return "<li class='err'>Invalid Use Of Module. Invalid Bursary Recipient.</li>";
}
$barr = pg_fetch_array($run_burs);
extract ($barr);
$get_bur = "SELECT * FROM bursaries WHERE id = '$bursary' LIMIT 1";
$run_bur = db_exec($get_bur) or errDie("Unable to get bursary information.");
if(pg_numrows($run_bur) < 1){
return "<li class='err'>Invalid Use Of Module. Invalid Bursary.</li>";
}
$burarr = pg_fetch_array($run_bur);
$showburs = $burarr['bursary_name'];
$display = "
<h2>Grant Bursary</h2>
<table ".TMPL_tblDflts.">
<form action='".SELF."' method='POST'>
<input type='hidden' name='key' value='write'>
<input type='hidden' name='id' value='$_GET[id]'>
<input type='hidden' name='bursary' value='$bursary'>
<tr>
<th colspan='2'>Recipient Information</th>
</tr>
<tr class='".bg_class()."'>
<td>Bursary</td>
<td>$showbursary</td>
</tr>
<tr class='".bg_class()."'>
<td>Name</td>
<td>$rec_name</td>
</tr>
<tr class='".bg_class()."'>
<td>Address</td>
<td>$rec_add1</td>
</tr>
<tr class='".bg_class()."'>
<td></td>
<td>$rec_add2</td>
</tr>
<tr class='".bg_class()."'>
<td></td>
<td>$rec_add3</td>
</tr>
<tr class='".bg_class()."'>
<td></td>
<td>$rec_add4</td>
</tr>
<tr class='".bg_class()."'>
<td>ID Number</td>
<td>$rec_idnum</td>
</tr>
<tr class='".bg_class()."'>
<td>Telephone</td>
<td>$rec_telephone</td>
</tr>
<tr class='".bg_class()."'>
<td>Date From</td>
<td>$from_date</td>
</tr>
<tr class='".bg_class()."'>
<td>Date To</td>
<td>$to_date</td>
</tr>
<tr class='".bg_class()."'>
<td>Notes</td>
<td>".nl2br($notes)."</td>
</tr>
<tr><td><br></td></tr>
<tr>
<td colspan='2' align='right'><input type='submit' value='Remove'></td>
</tr>
</form>
</table><br>"
.mkQuickLinks(
ql("bursary_type_add.php", "Add Bursary"),
ql("bursary_type_view.php", "View Bursaries")
);
return $display;
}
function write_details ($_POST)
{
extract ($_POST);
$from_date = "$from_year-$from_month-$from_day";
$to_date = "$to_year-$to_month-$to_day";
db_connect ();
$insert_sql = "DELETE FROM active_bursaries WHERE id = '$id'";
$run_insert = db_exec($insert_sql) or errDie("Unable to save bursary information.");
$update_sql = "UPDATE bursaries SET used = 'no' WHERE id = '$bursary'";
$run_update = db_exec($update_sql) or errDie("Unable to update bursary information.");
return "
<table ".TMPL_tblDflts.">
<tr>
<th>Bursary Information Updated.</th>
</tr>
<tr class='".bg_class()."'>
<td>Bursary Information Removed</td>
</tr>
</table>";
}
?>