I've made a calculator to calculate the overtime owed to an employee and send it to them by email. You can view and test the calculator here.
The email sends, but it only has zeros in the calculations? I have no idea what could be wrong.
<?
$to = "$email" . ", " ;
$to .= "webmaster@californiawagelawyer.com" . ", ";
$subject = "Calculations from" . "californiawagelawyer";
$server_name = "californiawagelawyer";
if (!empty($POST['send']) || !empty($GET['send']))
{
$action = (!empty($POST['send'])) ? $POST['send'] : $_GET['send'];
}
else
{
$action = '';
}
if($action != "")
{
$build_message = true;
$form_complete= true;
$hourly_rate = trim($POST['hourly_rate']);
$uncompensated_hours = trim($POST['uncompensated_hours']);
$meals_missed = trim($POST['meals_missed']);
$look_back_period = trim($POST['look_back_period']);
$email = trim($_POST['email']);
$time = time();
$date = date("F j, Y", time());
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=UTF-8\r\n";
$headers .= "From: $server_name\r\n";
$headers .= "X-mailer: " . $server_name . " Server\r\n";
}
if (isset($_REQUEST['form_complete'])) {
$hourly_rate = $_REQUEST['hourly_rate'];
$uncompensated_hours = $_REQUEST['uncompensated_hours'];
$meals_missed = $_REQUEST['meals_missed'];
$look_back_period = $_REQUEST['look_back_period'];
$form_complete = $_REQUEST['form_complete'];
if ($form_complete) {
$hourly_rate = ereg_replace( "[^0-9.]", "", $hourly_rate);
$uncompensated_hours = eregi_replace("[^0-9.]", "", $uncompensated_hours);
$meals_missed = eregi_replace("[^0-9.]", "", $meals_missed);
$look_back_period = eregi_replace("[^0-9.]", "", $look_back_period);
}
if ($form_complete) {
$total_overtime_hours = $uncompensated_hours * $look_back_period;
$overtime_hourly_rate = $hourly_rate * 1.5;
$overtime_owed = $total_overtime_hours * $overtime_owed;
$meals_owed = $look_back_period * $meals_missed * $hourly_rate;
$subtotal_owed = $meals_owed + overtime_owed;
$estimated_owed_interest = .1283 * $overtime_owed;
$equation = $hourly_rate * 160;
$calc = $overtime_hourly_rate * 15;
$penalties = 1.5 * ($equation * $calc);
$grand_total = $subtotal + $estimated_owed_interest + $penalties;
}
else
{
$result = "Sorry: An error occured, please try again.";
}
if($build_message)
{
$message = "Your overtime rate per hour is $total_overtime_hours dollars. The overtime hours owed to you is $overtime_hourly_rate dollars. Your employer owes you for impared overtime is $overtime_owed. Your employer owes you $meals_owed dollars for missed meal periods.</p>
<p>Your owed subtotal is $subtotal_owed dollars. </p>
<p>Estimated interest owed is $estimated_owed_interest dollars. Employer penalties added are $penalties dollars. </p>
<p>Your employer may owe you $grand_total dollars.</p>";
if(mail($to, $subject, $message, $headers))
{
$result = "<b>Thank you</b>.<br />Your calculations have been sent to the provided e-mail address.<br />";
}
else
{
$result = "Sorry: An error occured, please try again.";
}
}
print $result;
?>