I got a raise yesterday and when i adjusted the percentages, i had a major brain fart. The script worked as it should, but… the problem is that i didn’t account for raises when i wrote the script, so now the previous year and this year are showing the wrong values. Below is what i have now.
[php]
<?php require 'config.php'; ?>
My Shares
Month |
Base Pay |
20% |
Share |
<?php
$query = mysql_query("SELECT aid FROM venzo_admin_pay") or die(mysql_error());
while($aids = mysql_fetch_array($query)) {
$ads = $aids['aid'];
$aid = explode(',', $ads);
foreach ($aid AS $val) {
if($val == $_SESSION['adminid'] || $_COOKIE['adminid']) {
if(empty($_SESSION['adminid'])) {
$a_id = $_COOKIE['adminid'];
} else {
$a_id = $_SESSION['adminid'];
}
}
}
}
$querys = mysql_query("SELECT * FROM venzo_admin_pay WHERE aid LIKE '%$a_id%' ORDER BY sales_month") or die(mysql_error());
while($s = mysql_fetch_array($querys)) {
switch($s['sales_month']) {
case 1:
$month = "January";
break;
case 2:
$month = "February";
break;
case 3:
$month = "March";
break;
case 4:
$month = "April";
break;
case 5:
$month = "May";
break;
case 6:
$month = "June";
break;
case 7:
$month = "July";
break;
case 8:
$month = "August";
break;
case 9:
$month = "September";
break;
case 10:
$month = "October";
break;
case 11:
$month = "November";
break;
case 12:
$month = "December";
break;
}
$empl = mysql_query("SELECT * FROM venzo_admin WHERE id = $a_id");
$emp = mysql_fetch_array($empl);
$perc = $emp['percentage'];
$base = $s['sales_amount'];
$pay_a = $base * 0.20;
$pay_b = $pay_a * $perc;
if($prev_year != $s['year']) {
?>
<tr>
<td colspan="4" style="color: #6F0; font-size: 12pt; text-align: center; background-color: #03C; line-height: 25px;"><?= $s['year'] ?></td>
</tr>
<?php $prev_year = $s['year'];
} // below is the last bit of code lol ?>
<tr>
<td style="text-align: left;"><?=$month?></td>
<td style="text-align: right;">$<?=number_format($base, 2)?></td>
<td style="text-align: right;">$<?=number_format($pay_a, 2)?></td>
<td style="text-align: right;">$<?=number_format($pay_b, 2)?></td>
</tr>
<?php } ?>
</table>
[/php]
To explain it a bit, the last bit of code is where it does the display, $base is the total sales, $pay_a is our cut of the sales and $pay_b is the employee share. The old values run from april of 2011 to march 2012. The raise takes affect in april. I can’t think of a simple way of fixing it. If i change the db table, then i have to change a few pages, to much of a hassle.
Also, if there’s a way to get rid of that switch, i’d really like to do that.
So, what i need are ideas of how to seperate out or show the old and new values.