} // 2. Generate an Reference Invoice // 2.1 Check whether this job is a replacement for a previous failed referral. // 2.1.1 Get the job details. $query = "SELECT referrals.job, jobs.title \n FROM referrals \n LEFT JOIN jobs ON jobs.id = referrals.job \n WHERE referrals.id = " . $_POST['id']; $job = $mysqli->query($query); // 2.1.2 Check for replacement. $query = "SELECT id \n FROM referrals \n WHERE job = " . $job[0]['job'] . " AND \n (replacement_authorized_on IS NOT NULL AND replacement_authorized_on <> '0000-00-00 00:00:00') AND \n (replaced_on IS NULL OR replaced_on = '0000-00-00 00:00:00') AND \n replaced_referral IS NULL \n LIMIT 1"; $result = $mysqli->query($query); if (count($result) > 0 && !is_null($result)) { $is_replacement = true; $previous_referral = $result[0]['id']; } // 2.2 Get all the fees, discounts and extras and calculate accordingly. $employer = new Employer($_POST['employer']); $fees = $employer->get_fees(); $extras = $employer->get_extras(); $payment_terms_days = $employer->get_payment_terms_days(); $subtotal = $discount = $extra_charges = 0.0; foreach ($fees as $fee) { if ($_POST['salary'] >= $fee['salary_start'] && ($_POST['salary'] <= $fee['salary_end'] || $fee['salary_end'] == 0)) { $discount = -($_POST['salary'] * ($fee['discount'] / 100.0)); //$subtotal = ($_POST['salary'] * (($fee['service_fee'] + $fee['premier_fee']) / 100.00)); $subtotal = $_POST['salary'] * ($fee['service_fee'] / 100.0); break; } } foreach ($extras as $extra) { $extra_charges = $extra_charges + $extra['charges']; } $new_total_fee = $subtotal + $discount + $extra_charges;
$fees = $employer->get_fees(); $id = $fees[5]['id']; $data = array(); $data['id'] = $id; $data['service_fee'] = 11.5; $data['premier_fee'] = 0.5; if ($employer->update_fee($data)) { print_array($employer->get_fees()); } else { echo "failed"; exit; } ?> </p><p style="font-weight: bold;">Delete employer extras for ken123... </p><p><?php $employer = new Employer('ken123'); if ($employer->delete_extras()) { print_array($employer->get_extras()); } else { echo "failed"; exit; } ?> </p><p style="font-weight: bold;">Delete employer fees for ken123... </p><p><?php if ($employer->delete_fees()) { print_array($employer->get_fees()); } else { echo "failed"; exit; } ?> </p>