-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrecord.php
138 lines (137 loc) · 5.1 KB
/
record.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
<?php
require_once('check_cookie.php');
require_once('show_list.php');
require_once('Assign.php');
require_once('Request.php');
require_once('Users.php');
if (check_cookie($_SERVER['PHP_SELF'], 1)) {
if (!empty($_POST)) {
if (!empty($_POST['aid'])) {
$asn = new Assign();
$asn->id = $_POST['aid'];
$asn->find();
$rec = new Record();
$rec->aid = $_POST['aid'];
$rec->uid = $asn->rid;
$rec->date = parse_date($_POST);
$rec->hours = $_POST['hours'];
$rec->materials = $_POST['materials'];
$rec->cost = str_replace('$', '', $_POST['cost']);
$rec->insert();
} else if (!empty($_POST['id'])) {
$rec = new Record();
$date = parse_date($_POST);
$cost = str_replace('$', '', $_POST['cost']);
$query = 'UPDATE record ' .
"SET date='$date', " .
"hours={$_POST['hours']}, " .
"materials='{$_POST['materials']}', " .
"cost=$cost " .
"WHERE id={$_POST['id']}";
$rec->query($query);
}
}
// Initialize values!
$aid = (isset($_GET['aid'])) ? $_GET['aid'] : '';
$id = (isset($_GET['id'])) ? $_GET['id'] : '';
$requestor = '';
$requestor_phone = '';
$deadline = '';
$description = '';
$hours = '';
$materials = '';
$cost = '';
if ($aid) {
$asn = new Assign();
$asn->id = $aid;
$asn->find();
$req = new Request();
$req->id = $asn->rid;
$req->find();
$requestor = $req->name;
$requestor_phone = parse_phone($req->phone);
$deadline = $asn->complete;
$description = $req->description;
} else if ($id) {
$rec = new Record();
$rec->id = $id;
$rec->find();
$asn = new Assign();
$asn->id = $rec->aid;
$asn->find();
$req = new Request();
$req->id = $asn->rid;
$req->find();
$requestor = $req->name;
$requestor_phone = parse_phone($req->phone);
$deadline = $asn->complete;
$description = $req->description;
$hours = $rec->hours;
$materials = $rec->materials;
$cost = '$'.$rec->cost;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Job Approval</title>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="jquery-1.7.min.js"></script>
<script type="text/javascript" src="validator.js"></script>
<script type="text/javascript" src="validate_record.js"></script>
</head>
<body onload="loadEventHandlers();">
<?php include('header.php'); ?>
<a href="logout.php">Logout</a>
<h1>Job Record Form</h1>
<form id="form" method="post" action="record.php">
<div class="form">
<input type="hidden" id="aid" name="aid" value="<?php echo $aid ?>" />
<input type="hidden" id="id" name="id" value="<?php echo $id ?>" />
<table border="0">
<tr>
<td>Requested by:</td>
<td><input type="text" value="<?php echo $requestor ?>" disabled /></td>
</tr>
<tr>
<td>Phone:</td>
<td><input type="text" value="<?php echo $requestor_phone ?>" disabled /></td>
</td>
<tr>
<td>Deadline</td>
<td><input type="text" value="<?php echo $deadline ?>" disabled /></td>
</tr>
<tr>
<td>Description</td>
<td><textarea rows="10" cols="40" disabled><?php echo $description ?></textarea></td>
</tr>
<tr><td>Date:</td><td>
<select id="year" name="year"></select>
<select id="month" name="month">
<option id="month_0" value="January">January</option>
<option id="month_1" value="February">February</option>
<option id="month_2" value="March">March</option>
<option id="month_3" value="April">April</option>
<option id="month_4" value="May">May</option>
<option id="month_5" value="June">June</option>
<option id="month_6" value="July">July</option>
<option id="month_7" value="August">August</option>
<option id="month_8" value="September">September</option>
<option id="month_9" value="October">October</option>
<option id="month_10" value="November">November</option>
<option id="month_11" value="December">December</option>
</select>
<select id="day" name="day"></select></td></tr>
<tr><td>Number of hours:</td><td><input name="hours" id="hours" type="text" value="<?php echo $hours ?>"/></td></tr>
<tr><td>Materials used:</td><td><textarea name="materials" id="materials" rows="10" cols="40"><?php echo $materials ?></textarea></td></tr>
<tr><td>Cost of materials:</td><td><input name="cost" id="cost" type="text" value="<?php echo $cost ?>" /></td></tr>
</table>
<input type="submit" value="Submit" />
</div>
</form>
<?php show_list('assign', $aid); ?>
<?php show_list('record', $id); ?>
</body>
</html>
<?php } ?>