-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcashBox.php
More file actions
107 lines (90 loc) · 2.8 KB
/
cashBox.php
File metadata and controls
107 lines (90 loc) · 2.8 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
<?
include('Controls/header.php');
include_once('BusinessLogic/cashBoxLogic.php');
include_once('Controls/DataGrid.php');
// handle action buttons
if (isset($_POST['action']) && $_POST['action'] == "Add")
{
CashboxLogLogic::AddCashboxLog(
$_POST['cashboxCount'],
$_POST['cashboxNote']);
}
else if (isset($_POST['action']) && $_POST['action'] == "Delete")
{
CashboxLogLogic::DeleteCashboxLog($_POST['deleteID']);
}
else if (isset($_POST['action']) && $_POST['action'] == "Save")
{
CashboxLogLogic::UpdateCashboxLog(
$_POST['editID'],
$_POST['cashboxCount'],
$_POST['cashboxNote']);
}
?>
<script>
function validate(cashboxCount)
{
if (cashboxCount == "")
{
alert("Please enter count.");
return false;
}
if (isNaN(cashboxCount))
{
alert("Please enter a valid number for cashbox count.");
return false;
}
return true;
}
function validateForm()
{
var cashboxCount = $("#cashboxCount").val();
return validate(cashboxCount);
}
function validateEdit(row)
{
var cashboxCount = $(row).find("input[name=CashboxCount]").val();
return validate(cashboxCount);
}
function storeEdit(row)
{
// store values in the form
$("#cashboxCount").val( $(row).find("input[name=CashboxCount]").val() );
$("#cashboxNote").val( $(row).find("input[name=CashboxNote]").val() );
}
</script>
<form id="cashboxLogForm" method="post">
<input type="hidden" id="deleteID" name="deleteID" />
<input type="hidden" id="editID" name="editID" />
<input type="hidden" id="action" name="action" />
<fieldset>
<legend>Add New Cashbox Count</legend>
<table>
<tr>
<td><input id="cashboxCount" name="cashboxCount" type="number" /><br /><label for="cashboxCount">Count</label></td>
<td><input id="cashboxNote" name="cashboxNote" type="text" /><br /><label for="cashboxNote">Note</label></td>
<td><input type="button" onclick="setAdd('cashboxLogForm',validateForm);" value="Add"></td>
</tr>
</table>
</fieldset>
</form>
<?
// setup datagrid
$cashboxLogGrid = new DataGrid();
$cashboxLogGrid->DataSource = CashboxLogLogic::GetAllCashboxLogs();
$cashboxLogGrid->DataSourceClassName = "CashboxLog";
$cashboxLogGrid->IDPropertyName = "CashboxLogID";
$cashboxLogGrid->FormID = "cashboxLogForm";
$cashboxLogGrid->ValidateEditCallback = "validateEdit";
$cashboxLogGrid->StoreEditCallback = "storeEdit";
// setup data columns
$idCol = $cashboxLogGrid->AddColumn("CashboxLogID", DataColumnType::NumberColumn, "CashboxLogID");
$idCol->ReadOnly = true;
$cashboxLogGrid->AddColumn("Count", DataColumnType::NumberColumn, "CashboxCount");
$cashboxLogGrid->AddColumn("Note", DataColumnType::StringColumn, "CashboxNote");
$dateCol = $cashboxLogGrid->AddColumn("Date", DataColumnType::StringColumn, "Date");
$dateCol->ReadOnly = true;
// draw!
$cashboxLogGrid->Render();
include('Controls/footer.php');
?>