-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathstats_employeemetrics.php
277 lines (259 loc) · 10.4 KB
/
stats_employeemetrics.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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
<?php
require_once('Connections/YBDB.php');
require_once('Connections/database_functions.php');
$page_individual_history_log = INDIVIDUAL_HISTORY_LOG;
$page = "stats_employeemetrics.php";
//error
switch ($_GET['error']) {
case 'incorrectcode':
$error_message = '<- Invalid code';
break;
case 'timeexpired':
$error_message = '<- Time expired - Reenter code';
break;
default:
$error_message = '<- Enter Employee Code';
break;
}
//default settings
$currency = 0;
$places = 1;
switch ($_GET['metric']) {
//Main Stats
//case 'NetProductionPerHour': This is the default
// $metric = $_GET['metric'];
// $title = "Net Production Value Per Hour ([Value of Fixed Bikes and Wheels - Pay] / Regular Hours)";
// break;
case 'NetProductionToPayValueRatio':
$metric = $_GET['metric'];
$title = "Value Ratio - (Value of Bikes + Wheels Completed)/Regular Pay";
break;
case 'HoursPerBikeFixed': //this is a sample error message. insert error case here
$metric = $_GET['metric'];
$title = "Hours Per Bike Fixed";
break;
case 'HoursPerBikeSold': //this is a sample error message. insert error case here
$metric = $_GET['metric'];
$title = "Hours Per Bike Sold";
break;
case 'SalesPerHour': //this is a sample error message. insert error case here
$metric = $_GET['metric'];
$title = "Sales Per Hour";
$currency = 1;
$places = 0;
break;
//Hours
case 'Hours_All': //this is a sample error message. insert error case here
$metric = $_GET['metric'];
$title = "Total Hours";
break;
case 'Hours_NoSpec': //this is a sample error message. insert error case here
$metric = $_GET['metric'];
$title = "Regular Hours";
break;
case 'Hours_Spec': //this is a sample error message. insert error case here
$metric = $_GET['metric'];
$title = "Special Hours";
break;
//Production Stats
case 'AverageValueBikesFixed': //this is a sample error message. insert error case here
$metric = $_GET['metric'];
$title = "Average Value of Bikes Fixed";
$currency = 1;
$places = 0;
break;
case 'AverageValueNewPartsOnBikes': //this is a sample error message. insert error case here
$metric = $_GET['metric'];
$title = "Average Value of New Parts on Bikes";
$currency = 1;
$places = 0;
break;
case 'AverageNetValueBikesFixed': //this is a sample error message. insert error case here
$metric = $_GET['metric'];
$title = "Average Net Balue of Bikes Fixed (Bike Price - New Parts)";
$currency = 1;
$places = 0;
break;
case 'NetValueBikesFixedPerHour': //this is a sample error message. insert error case here
$metric = $_GET['metric'];
$title = "Net Value of Bikes Fixed Per Hour";
$currency = 1;
break;
case 'NumBikesFixed': //this is a sample error message. insert error case here
$metric = $_GET['metric'];
$title = "Number of Bikes Fixed";
$places = 0;
break;
case 'AverageValueWheelsFixed': //this is a sample error message. insert error case here
$metric = $_GET['metric'];
$title = "Average Value of Wheels Fixed";
$currency = 1;
$places = 0;
break;
case 'NumWheelsFixed': //this is a sample error message. insert error case here
$metric = $_GET['metric'];
$title = "Total Number of Wheels Fixed";
$places = 0;
break;
//Sales
case 'HoursPerBikeSold': //this is a sample error message. insert error case here
$metric = $_GET['metric'];
$title = "Hours Per Bike Sold";
$places = 0;
break;
case 'NumBikesSold': //this is a sample error message. insert error case here
$metric = $_GET['metric'];
$title = "Number of Bikes Sold";
$places = 0;
break;
default:
$metric = 'NetProductionPerHour';
$title = "Net Production Value Per Hour ([Value of Fixed Bikes and Wheels - Pay] / Regular Hours)";
$currency = 1;
break;
}
switch ($_GET['period']) {
case 'Year':
$period = $_GET['period'];
break;
case 'Quarter':
$period = $_GET['period'];
break;
//case 'Month':
// $period = $_GET['period'];
// break;
//case 'Week': //this is a sample error message. insert error case here
// $period = $_GET['period'];
// break;
default:
$period = 'Quarter';
break;
}
//CheckDetailCode isset($_POST["MM_update"]) =========================================================
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "CheckDetailCode")) {
session_start();
$employeedetail = "_employeedetail";
$error = "";
switch ($_POST['EmployeeDetailCode']) {
case '3267':
$_SESSION['employee'] = "BW";
$_SESSION['ContactID'] = "10019";
break;
case '5478':
$_SESSION['employee'] = "Conti";
$_SESSION['ContactID'] = "4009";
break;
case '4398':
$_SESSION['employee'] = "John";
$_SESSION['ContactID'] = "1755";
break;
case '2145':
$_SESSION['employee'] = "Pete";
$_SESSION['ContactID'] = "107";
break;
case '8745':
$_SESSION['employee'] = "Savanna";
$_SESSION['ContactID'] = "554";
break;
default:
$employeedetail = "";
$_SESSION['employee'] = "None";
$_SESSION['timestamp'] = "None";
$error = "error=incorrectcode";
break;}
$_SESSION['timestamp'] = time();
header("Location: stats_employeemetrics$employeedetail.php?$error"); //$editFormAction
}
mysql_select_db($database_YBDB, $YBDB);
$query_Recordset1 = "select v.Year AS Year,v.$period AS $period,
sum(if((v.ContactID = 10019),v.$metric,0)) AS BW,
sum(if((v.ContactID = 4009),v.$metric,0)) AS Conti,
sum(if((v.ContactID = 107),v.$metric,0)) AS Pete,
sum(if((v.ContactID = 554),v.$metric,0)) AS Savanna,
sum(if((v.ContactID = 1755),v.$metric,0)) AS John
from view_EmployeeMetrics5_by$period" . "_HoursCalc v
group by `v`.`Year` DESC,`v`.`$period` DESC;";
$Recordset1 = mysql_query($query_Recordset1, $YBDB) or die(mysql_error());
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
$row_Recordset1 = mysql_fetch_assoc($Recordset1); //Loads first record so latest date is not visable. Statistics available at close of period.
?>
<?php include("include_header.html"); ?>
<table>
<tr><td><?php echo "Main Stats:
<a href=\"$page?metric=NetProductionPerHour&period=$period\">Net Production Per Hour</a>,
<a href=\"$page?metric=NetProductionToPayValueRatio&period=$period\">Net Production To Pay Ratio</a>,
<a href=\"$page?metric=HoursPerBikeFixed&period=$period\">Hours Per Bike Fixed</a>,
<a href=\"$page?metric=SalesPerHour&period=$period\">Sales Per Hour</a><br>
Hours:
<a href=\"$page?metric=Hours_All&period=$period\">Total Hours</a>,
<a href=\"$page?metric=Hours_NoSpec&period=$period\">Regular Hours</a>,
<a href=\"$page?metric=Hours_Spec&period=$period\">Special Hours</a><br>
Production Figures:
<!--<a href=\"$page?metric=AverageValueBikesFixed&period=$period\">Average Value Bikes Fixed</a>,
<!--<a href=\"$page?metric=AverageValueNewPartsOnBikes&period=$period\">Avg Value New Parts on Bikes</a>,-->
<a href=\"$page?metric=AverageNetValueBikesFixed&period=$period\">Avg Net Value Bikes Fixed</a>,
<a href=\"$page?metric=NetValueBikesFixedPerHour&period=$period\">Net Value of Bikes Fixed Per Hour</a>,
<a href=\"$page?metric=NumBikesFixed&period=$period\">Number of Bikes Fixed</a>,
<a href=\"$page?metric=AverageValueWheelsFixed&period=$period\">Average Value of Wheels Fixed</a>,
<a href=\"$page?metric=NumWheelsFixed&period=$period\">Number of Wheels Fixed</a><br>
Sales Stats:
<a href=\"$page?metric=HoursPerBikeSold&period=$period\">Hours Per Bike Sold</a>,
<a href=\"$page?metric=NumBikesSold&period=$period\">Number of Bikes Sold</a><br><br>
View by:
<a href=\"$page?metric=$metric&period=Year\">Year</a>
<a href=\"$page?metric=$metric&period=Quarter\">Quarter</a>
<!--,<a href=\"$page?metric=$metric&period=Month\">Month</a>
<!--,<a href=\"$page?metric=$metric&period=Week\">Week</a>-->"?>
<form id="form1" name="form1" method="post" action="">
View Employee Details:
<input name="EmployeeDetailCode" type="text" value="" size="20" maxlength="20" autocomplete="off">
<input type="submit" name="Submit" value="Load">
<input type="hidden" name="MM_insert" value="CheckDetailCode">
<span class = "yb_standardred"><?php echo $error_message;?></span>
</form>
</td></tr>
<tr valign="top"><td><span class="yb_heading3red"><?php echo $title; ?></span></td></tr>
<tr>
<td>
<table id="metrics" border="1" cellpadding="1" cellspacing="0">
<tr valign="top" bgcolor="#99CC33" class="yb_standardCENTER">
<td width="100" height="35">Year</td>
<td width="100"><?php echo $period?></td>
<td width="100">BW<br />
<td width="100">Conti<br />
<td width="100">John<br />
<td width="100">Pete<br />
<td width="100">Savanna<br />
</tr>
<form method="post" name="FormUpdate_<?php echo $row_Recordset1['shop_id']; ?>" action="<?php echo $editFormAction; ?>">
<?php while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)) { //do {
if(1 == 2) {?>
<tr valign="bottom" bgcolor="#CCCC33">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<input type="hidden" name="MM_insert" value="FormEdit">
<input type="hidden" name="shop_id" value="<?php echo $row_Recordset1['shop_id']; ?>">
</form>
<?php } else { // end if EDIT RECORD ?>
<tr class=yb_standardRIGHT>
<td><?php echo $row_Recordset1['Year']; ?></td>
<td><?php echo $row_Recordset1["$period"]; ?></td>
<td><?php echo formatnum($row_Recordset1['BW'],$currency,$places); ?></td>
<td><?php echo formatnum($row_Recordset1['Conti'],$currency,$places); ?></td>
<td><?php echo formatnum($row_Recordset1['John'],$currency,$places); ?></td>
<td><?php echo formatnum($row_Recordset1['Pete'],$currency,$places); ?></td>
<td><?php echo formatnum($row_Recordset1['Savanna'],$currency,$places); ?></td>
</tr>
<?php
} // end if EDIT RECORD
} // end WHILE count of recordset ?>
</table> </td>
</tr>
</table>
<?php include("include_footer.html"); ?>
<?php
mysql_free_result($Recordset1);
?>