~julian-lam/maccms/trunk

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
149
<?php 

	session_start();
	
	# Variables
	$prefix = "..";				# Prefix for relative links
	$title = "Add New Instrument";		# Title of the page
	
	# Including includes
	include "$prefix/config/config.php";	# General configuration file for all pages
	include "$prefix/includes/db.inc";	# DB access
	include "$prefix/includes/other.inc";	# Other scripts (secure access, etc)
	include "$prefix/includes/header.inc";	# Including HTML headers, etc
	
	secure_page(admin);
	
	# Process Records (if applicable)
	if ($_POST['action'] == "add") {
		db_connect();
		$instrument = mysql_real_escape_string($_POST['instrument']);
		$make = mysql_real_escape_string($_POST['make']);
		$model = mysql_real_escape_string($_POST['model']);
		$serial = mysql_real_escape_string($_POST['serial']);
		$comment = mysql_real_escape_string($_POST['comment']);
		if ($_POST['last_cleaned'] != "") $last_cleaned = strtotime(mysql_real_escape_string($_POST['last_cleaned']));
		else $last_cleaned = '0';
		if ($_POST['last_repaired'] != "") $last_repaired = strtotime(mysql_real_escape_string($_POST['last_repaired']));
		else $last_repaired = '0';
		$status = mysql_real_escape_string($_POST['status']);
		
		$result = mysql_query("INSERT INTO inventory VALUES (DEFAULT,'$instrument','$make','$model','$serial','$comment','$last_cleaned','$last_repaired','$status')");
		db_close();
	}

?>

					<div class="buttons">
						<a href="./inventory.php">
							<img src="<?=$imagepath?>/inventory.png" title="" />
							Back to Inventory
						</a>
					</div>
					<hr />
					<?php
						if ($_POST['action'] == "add" && $result == 1) messagebox(notice,add,'"' . $instrument . '" added to inventory.',false);
						elseif ($_POST['action'] == "add" && $result != 1) echo messagebox(error,error,'Instrument not added to inventory!',false);
					?>
				</td>
			</tr>
			<tr>
				<td>
					<form id="addinstrument" method="post" action="inventory.php" name="addinstrument">
						<div class="inventory_add_container">
							<div class="inventory_add_row">
								<div class="inventory_add_cell">
									Instrument:
								</div>
								<div class="inventory_add_cell">
									<input type="text" name="instrument" />
								</div>
							</div>
							<div class="inventory_add_row">
								<div class="inventory_add_cell">
									Make:
								</div>
								<div class="inventory_add_cell">
									<input type="text" name="make" />
								</div>
							</div>
							<div class="inventory_add_row">
								<div class="inventory_add_cell">
									Model Number:
								</div>
								<div class="inventory_add_cell">
									<input type="text" name="model" />
								</div>
							</div>
							<div class="inventory_add_row">
								<div class="inventory_add_cell">
									Serial Number:
								</div>
								<div class="inventory_add_cell">
									<input type="text" name="serial" />
								</div>
							</div>
							<div class="inventory_add_row">
								<div class="inventory_add_cell">
									Comment:
								</div>
								<div class="inventory_add_cell">
									<textarea name="comment" cols="50"></textarea>
								</div>
							</div>
							<div class="inventory_add_row">
								<div class="inventory_add_cell">
									Date Last Cleaned:
								</div>
								<div class="inventory_add_cell">
									<input type="text" name="last_cleaned" />
								</div>
							</div>
							<div class="inventory_add_row">
								<div class="inventory_add_cell">
									Date Last Repaired:
								</div>
								<div class="inventory_add_cell">
									<input type="text" name="last_repaired" />
								</div>
							</div>
							<div class="inventory_add_row">
								<div class="inventory_add_cell">
									Status:
								</div>
								<div class="inventory_add_cell">
									<select name="status">
										<option value="in">Checked in</option>
										<option value="out">Withdrawn</option>
										<option value="repair">Out for Repair</option>
										<option value="reserve">Reserved Indefinitely</option>
										<option value="missing">Instrument Missing</option>
									</select>
								</div>
							</div>
						</div>
						<div class="buttons">
							<button type="submit" name="action" value="add">
								<img src="<?=$imagepath?>/add.png" title="" />
								Add Instrument
							</button>
							<button type="submit" name="action" value="add" onClick="javascript: addinstrument.action='addinstrument.php'">
								<img src="<?=$imagepath?>/add.png" title="" />
								Add Instrument & Add Another
							</button>
						</div>
					</form>
				</td>
			</tr>
		</table>
		
		<script type="text/javascript">
			document.addinstrument.instrument.focus();
		</script>

<?php

	# Including includes
	include "$prefix/includes/footer.inc";

?>