Repository navigation
Expand file tree
/
Copy pathfine_reduction.php
More file actions
93 lines (71 loc) · 2.39 KB
/
Copy pathfine_reduction.php
File metadata and controls
93 lines (71 loc) · 2.39 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
<?php
session_start();
require_once("config/config.inc.php");
require_once("includes/Database.php");
require_once("load.php");
require_once("includes/verify_access.php");
restrict_access($db,array("admin"));
$fine_id = $_GET['fine_id'];
$fines = load_fines(array('id'=>$fine_id));
if(count($fines) == 0)
{
display_error("Fine could not be found.",array("fine_id"=>$fine_id));
exit();
}
else if(count($fines) > 1)
{
display_error("Multiple fines with the same id found.",$fines);
exit();
}
else
{
foreach($fines as $fine)
break;
if(isset($_GET['submitted']))
{
if(isset($_GET['reduction_amount']) && strcmp(trim($_GET['reduction_amount']),''))
{
$reduction_amount = $_GET['reduction_amount'];
$reduction_reason = $_GET['reduction_reason'];
$table = "fines_reductions";
$fields = array('fine_id','amount','description','date_added','added_by');
$values = array($fine->id,$reduction_amount,$reduction_reason,date('Y-m-d H:i:s'),$_SESSION['LibRooms']['UserID']);
//pr($values);
$insert_id = $db->insert($table,$fields,$values);
}
// reload fine
$fines = load_fines(array('id'=>$fine_id));
foreach($fines as $fine)
break;
}
print("<h3>Fine</h3>\n");
print("Amount: ".format2dollars($fine->amount)."<br>\n");
print("Description: $fine->description<br>\n");
if(is_array($fine->reductions))
{
print("<b>Reductions:</b><br>\n");
foreach($fine->reductions as $reduction)
{
print("<div style='color:red'>".date('m/d/Y',strtotime($reduction->date_added))." -".format2dollars($reduction->amount)." $reduction->description</div>\n");
}
}
}
if(isset($_GET['remove_reduction']))
{
$remove_reduction = $_GET['remove_reduction'];
$db->update('fines_reductions','active','0',"id like '$remove_reduction'");
// reload fine
$fines = load_fines(array('id'=>$fine_id));
// TODO: actually check the result to make sure the db change worked
print("<font color='green'>Reduction successfully removed.</font><br>\n");
}
print("<hr>\n");
print("<form>\n");
print("<input type='hidden' name='submitted' value='1'>\n");
print("<input type='hidden' name='fine_id' value='$fine_id'>\n");
print("<h2>Reduce Fine</h2>\n");
print("Reduce Fine Amount By: <input type='text' size='10' name='reduction_amount'><br>\n");
print("Reason: <input type='text' size='60' name='reduction_reason'><br>\n");
print("<input type='submit' value='Reduce Fine'>\n");
print("</form>\n");
?>