-
Notifications
You must be signed in to change notification settings - Fork 0
/
call.inc.original.php
237 lines (181 loc) · 9.82 KB
/
call.inc.original.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<?php /* *************** call.inc.php **************** */
session_start();
include("../../checklist/includes/db.inc.php");
if($_POST['action'] == "secretBuilding"){
$id = $_POST['id'];
// $list = "<h3>The Building ID is ".$id."</h3>";
$room_list = grabRooms($id);
$list .= "<form name='RoomsForm' method='post' action=''>";
$list .= "<select id='room' name='room' onChange=\"document.getElementById('equipment_checkboxes').style.display=''; log_roomid=(this.value); getOldIssues(this.value);\">"; //THIS SHOULD BE OPENDIV SO ITS ALL FANCY BUT I CANT MAKE IT WORK YET ???
$list .= "<option value=''>Select Room</option>";
while($row = mysql_fetch_assoc($room_list)){
$list.= "<option value='$row[field]'>".$row['room']."</option>";
}
$list .="</select>";
$list .="</form>";
echo $list;
}
/*
else if($_POST && $_POST['action'] != "logNewCall"){$list="<h2>balls</h2>";
echo $list;
}
*/
else if($_POST['action'] == "queryOldIssues"){
$id = $_POST['id'];
$list_of_issues = grabIssues($id);
//$common_problems = grabChecklist();
$list = "";
while($row = mysql_fetch_assoc($list_of_issues)){
if (strlen($row['status'])>47){ // *********************************** THIS REALLLLLLLY NEEDS TO BE CHANGED - TOTALLY DUMB WAY OF DOING IT - BUT IM TIRED AND CANT MAKE IT WORK THE WAY I WANTED TO I.E. COMPARE THE 'CHECKLIST' LIST (VGA CABLE IS NOT INVENTORIED..... VCR DOES NOT WORK.... THE CANNED RESPONSES!) AGAINST THE ACTUAL 'NOTES' SUBMISSIONS, AND ONLY SHOW TH NOTES
$list .= "<b>".$row['d']."</b>: ".$row['status']."<br />";
}
}
$list .= "</div>";
echo $list;
}
//** ********************************************************* **//
function grabIssues($room){
$db = CreateConnection();
$sql="SELECT status, DATE_FORMAT(datecreated, '%Y %M %D') as d from report_details WHERE room = '".$room."' order by datecreated DESC;";
$result = mysql_query($sql,$db) or print "Error with grabIssues " . mysql_error();
CloseConnection($db);
return $result;
}
//** ************************************* the next couple functions are borrowed from classroom.inc.php ********* **//
function grabChecklist(){
$db = CreateConnection();
$sql = "select * from lu_checklist";
$result = mysql_query($sql,$db) or print "Error with grabChecklist " . mysql_error();
CloseConnection($db);
return $result;
}
function grabBuildings(){
$db = CreateConnection();
$sql = "select * from lu_buildings where active = 'Y' ";
$result = mysql_query($sql,$db) or print "Error with grabBuildings: " . mysql_error();
CloseConnection($db);
return $result;
}
function grabRooms($building){
$db = CreateConnection();
$sql = "select * from lu_rooms r where building = ". $building;
$result = mysql_query($sql,$db) or print "error with grabrooms: " . mysql_error();
Closeconnection($db);
return $result;
}
//** ******************************** FOR SUBMITTING THE NEW CALL INFO ************************************* **//
if($_POST['action'] == "logNewCall"){
$summary ="";
$summary .= "<h2>Call Logged</h2>";
$summary .="Call taken by: ".$_SESSION['user'];
$summary .= "<br />Was Classroom Support: ".$_POST['support'];
if($_POST['support']=='yes'){ // ****************************************** CLASSROOM SUPPORT CALLS
if ($_POST['buildings']=='10000'){$_POST['buildings']='unknown';};
if ($_POST['room']=='10000'){$_POST['room']='unknown';};
$summary .="<br />Building ID: ".$_POST['buildings'];
$summary .="<br />Room ID: ".$_POST['room'];
// $summary .="<br />Reason: ".$_POST['reason']; REASON IS IRRELEVANT TO CLASSROOM CALLS, ONLY MATTERS FOR NON CS CALLS
$summary .="<br />Resolved: ".$_POST['radio_resolved'];
$db = CreateConnection();
$sql = "INSERT INTO report_building (reportedby, building_id, phone_code) VALUES ('$_SESSION[user]', '$_POST[buildings]', '10000');"; // SAME INNITIAL INSERT AS FOR NON-CLASSROOM CALLS BELOW, ONLY THE ACTUAL BUILDING CODE IS ALSO INSERTED INSTEAD OF JUST A ZERO
mysql_query($sql,$db) or print "Error insertin data to report_building ".mysql_error();
$reportid = mysql_insert_id($db); // SET $REPORTID TO VALUE OF THE ID JUST AUTO-INSERTED IN THE REPORT_BUILDING TABLE
// SECOND INSERT
$sql_two = "INSERT INTO report_rooms (reportedby, room, report_id, status, noted) VALUES ('$_SESSION[user]','$_POST[room]','$reportid','$_POST[radio_resolved]','no');";
mysql_query($sql_two,$db) or print "Error with second insert, insserting into report_rooms " . mysql_error();
$roomreportid = mysql_insert_id($db); // SET $ROOMREPORTID TO VALUE OF THE ID JUST AUTO-INSERTED IN THE REPORT_ROOMS TABLE
// THIRD INSERT
$sql_three = "INSERT INTO report_details (report_id, status, room, room_id, typed) VALUES ('$reportid','$_POST[notes]','$_POST[room]','$roomreportid','1');";
mysql_query($sql_three,$db) or print "Error with third insert, into report_details " . mysql_error();
// ADDITIONAL INSERTS *IF* THEY CLICKED ANY OF THE CHECKBOXES FOR SPECIFIC PROBLEMS
foreach($_POST as $key => $value){
if(preg_match("/cl_/", $key)){
$sql_more = "INSERT INTO report_details (report_id, status, room, room_id, typed) VALUES ('$reportid','$value','$_POST[room]','$roomreportid','0');";
mysql_query($sql_more,$db) or print "Error with additional inserts " . mysql_error();
}
}
CloseConnection($db);
}
else { // ***************************************************************** OTHER CALLS - NOT CLASSROOM SUPPORT
if ($_POST['otherCalls']=='10000'){$_POST['otherCalls']='unknown';}; // this should probaly be removed - it will never be 10000 now that i'm subbmitting it through the form before confirmation
$summary .="<br />Reason for Call: ".$_POST['otherCalls'];
$db = CreateConnection();
$sql = "INSERT INTO report_building (reportedby, building_id, phone_code) VALUES ('$_SESSION[user]', '0', '$_POST[otherCalls]')"; // VALUE OF ZERO FOR BUILDING_ID B/C THERE IS NO BUILDING, ITS NON-CLASSROOM SUP.
mysql_query($sql,$db) or print "Error inserting data ".mysql_error();
$reportid = mysql_insert_id($db); // SETS $REPORTID TO THE VALUE OF THE ID JUST AUTO-INSERTED INTO THE REPORT_BUILDING TABLE
$new_sql = "INSERT INTO call_details (report_id, notes, reason) VALUES ('$reportid','$_POST[notes]','$_POST[otherCalls]')";
mysql_query($new_sql,$db) or print "Error with second insert ".mysql_error();
CloseConnection($db);
}
$summary .= "<br />NOTES: ".$_POST['notes'];
echo $summary;
}
//** **************************** GET LIST OF POSSIBLE REASONS FOR NON-CLASSROOM SUPPORT CALLS *************** **//
function getReasons(){
$callReasons = array();
$db = CreateConnection();
$sql = "SELECT * FROM lu_calls WHERE id > 100;";
$result = mysql_query($sql,$db) or print "Error with getting call reasons list!! " . mysql_error();
while ($row = mysql_fetch_assoc($result)){
array_push($callReasons,$row);
}
CloseConnection($db);
return $callReasons;
}
//** ************************** reporting functions ******************************** **//
// FOR NOW THESE ARE BEING USED IN THE TESTFORCALLS.PHP FILE
function getClassroomCalls($thisDay){
$allCalls = array();
$db = CreateConnection();
//$thisDay = date("Ymd"); // THIS GETS ALL THE INFO FOR THE CALLS THAT ******* WERE CLASSROOM SUPPORT *********
$sql = "SELECT * from report_details JOIN report_building ON report_details.report_id=report_building.id WHERE DATE_FORMAT(report_details.datecreated, '%Y%m%d') = '".$thisDay."' AND phone_code != '0'; ";
//$sql = "SELECT * from call_details JOIN report_building ON call_details.report_id=report_building.id;";
$result = mysql_query($sql,$db) or print "Error with showCalls: ". mysql_error();
while ($row = mysql_fetch_assoc($result)){
array_push($allCalls,$row);
}
CloseConnection($db);
return $allCalls;
}
function getOtherCalls($thisDay){
$allCalls = array();
$db = CreateConnection();
//$thisDay = date("Ymd"); // THIS GETS ALL THE INFO FOR THE CALLS THAT WERE ******* NOT CLASSROOM SUPPORT *********
$sql = "SELECT * from call_details JOIN report_building ON call_details.report_id=report_building.id WHERE DATE_FORMAT(call_details.datecreated, '%Y%m%d') = '".$thisDay."';";
//$sql = "SELECT * from call_details JOIN report_building ON call_details.report_id=report_building.id;";
$result = mysql_query($sql,$db) or print "Error with showCalls: ". mysql_error();
while ($row = mysql_fetch_assoc($result)){
array_push($allCalls,$row);
}
CloseConnection($db);
return $allCalls;
}
function listCalls(){
if (!$_GET) {
$report_day = date("Ymd");
} else {
$report_day = $_GET['go'];
}
$call_list = getOtherCalls($report_day);
$another_call_list = getClassroomCalls($report_day);
$list = "<h3>Classroom-Support Calls:</h3>";
$list .= "<table border='1' width='100%'><tr><th width='15%'>Date</th><th width='15%'>Reported By</th><th width='15%'>Room</th><th width='55%'>Notes</th></tr>";
foreach($another_call_list as $row){
$list .= "<tr><td>" . $row['datecreated'] . "</td><td>" . $row['reportedby'] . "</td><td> " . $row['room'] . "</td><td>" . $row['status'] . "</td></tr>";
}
$list .= "</table>";
$list .= "<h3>Other Calls:</h3>";
$list .= "<table border='1' width='100%'><tr><th width='15%'>Date</th><th width='15%'>Reported By</th><th width='15%'>Reason for Call</th><th width='55%'>Notes</th></tr>";
foreach($call_list as $row){
$list .= "<tr><td>" . $row['datecreated'] . "</td><td>" . $row['reportedby'] . "</td><td> " . $row['phone_code'] . "</td><td>" . $row['notes'] . "</td></tr>";
}
$list .= "</table>";
$yest = $report_day-1;
$tomo = $report_day+1;
$display_day = substr($report_day,4,2)." - ".substr($report_day, 6, 2)." - ".substr($report_day,0,4);
echo "<div id='report_date' style='width:200px; margin-left:auto; margin-right:auto;'>".
"<a href='?go=".$yest."' title='previous day' style='text-decoration:none;'> << </a> ".$display_day." <a href='?go=".$tomo."' title='next day' style='text-decoration:none;'> >> </a>".
"</div>";
echo $list;
}
?>