/
deposit_refund.php
executable file
·93 lines (77 loc) · 1.76 KB
/
deposit_refund.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
<?php
require ("settings.php");
// Navigation logic
if (isset($_REQUEST["key"])) {
switch ($_REQUEST["key"]) {
case "select_customer":
$OUTPUT = select_customer();
break;
case "input_amount":
$OUTPUT = input_amount;
break;
}
} else {
$OUTPUT = select_customer();
}
require ("template.php");
function select_customer()
{
extract($_REQUEST);
$fields = array();
$fields["cusnum"] = 0;
$fields["search"] = "[_BLANK_]";
extract($fields, EXTR_SKIP);
$sql = "
SELECT cusnum, surname FROM cubit.customers
WHERE surname ILIKE '$search%' ORDER BY surname ASC";
$cust_rslt = db_exec($sql) or errDie("Unable to retrieve customers.");
$cust_out = "";
$i = 0;
while (list($cusnum, $surname) = pg_fetch_array($cust_rslt)) {
if ($i == 5) {
$cust_out .= "</tr>";
$i = 0;
}
if ($i == 0) {
$cust_out .= "<tr class='".bg_class()."'>";
}
$i++;
$cust_out .= "
<td>
<a href='".SELF."?key=input_amounts&cusnum=$cusnum'>
$i $surname
</a>
</td>";
}
if ($search == "[_BLANK_]") {
$search = "";
$cust_out = "
<tr class='".bg_class()."'>
<td>
<li>Please enter the first letters of the customer name.</li>
</td>
</tr>";
} elseif (empty($cust_out)) {
$cust_out = "
<tr class='".bg_class()."'>
<td><li>No results found. Please redefine your search.</li></td>
</tr>";
}
$OUTPUT = "
<h3>Deposit Refund</h3>
<form method='post' action='".SELF."'>
<input type='hidden' name='key' value='select_customer' />
<table ".TMPL_tblDflts.">
<tr>
<th colspan='2'>Select Customer</th>
</tr>
<tr class='".bg_class()."'>
<td><input type='text' name='search' value='$search' /></td>
<td><input type='submit' value='Search' /></td>
</tr>
</table>
<table ".TMPL_tblDflts.">
$cust_out
</table>";
return $OUTPUT;
}