$message = str_replace('%root%', $GLOBALS['root'], $message); $subject = "Welcome To Yellow Elevator!"; $headers = 'From: YellowElevator.com <*****@*****.**>' . "\n"; mail($_POST['email_addr'], $subject, $message, $headers); // $handle = fopen('/tmp/email_to_'. $_POST['email_addr']. '.txt', 'w'); // fwrite($handle, 'Subject: '. $subject. "\n\n"); // fwrite($handle, $message); // fclose($handle); } echo 'ok'; exit; } if ($_POST['action'] == 'copy_fees') { $from_employer = new Employer($_POST['employer']); $to_employer = new Employer($_POST['id']); $fees = $from_employer->getFees(); if ($to_employer->createFees($fees) === false) { echo 'ko'; exit; } $criteria = array('columns' => "working_months, payment_terms_days", 'match' => "id = '" . $from_employer->getId() . "'", 'limit' => "1"); $result = $from_employer->find($criteria); $data = array(); $data['working_months'] = $result[0]['working_months']; $data['payment_terms_days'] = $result[0]['payment_terms_days']; $to_employer->update($data); echo 'ok'; exit; } if ($_POST['action'] == 'delete_fee') { $employer = new Employer();
} else { echo "failed"; exit; } ?> </p><p style="font-weight: bold;">Still logged in after a password change?</p><p><?php if (!$employer->isLoggedIn($hash)) { echo "failed"; exit; } else { echo "Yup!"; } ?> </p><p style="font-weight: bold;">Display the fees I agreed...</p><p><?php echo "<pre>"; print_r($employer->getFees()); echo "</pre><br><br>"; ?> </p><p style="font-weight: bold;">Get all employers...</p><p><?php $criteria = array('columns' => 'id'); $result = $employer->find($criteria); $employers = array(); foreach ($result as $row) { $employers[] = new Employer($row['id']); } $employers_list = array(); $i = 0; foreach ($employers as $emp) { $employers_list[$i]['id'] = $emp->getId(); $employers_list[$i]['name'] = $emp->getName(); $branch = $emp->getAssociatedBranch();
exit; } if ($referral->update($data) === false) { echo 'ko'; exit; } // 2. Generate an Reference Invoice // 2.1 Check whether this job is a replacement for a previous failed referral. $criteria = array('columns' => 'id', 'match' => "job = " . $job['id'] . " 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", 'limit' => '1'); $result = $referral->find($criteria); 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. $fees = $employer->getFees(); $payment_terms_days = $employer->getPaymentTermsInDays(); $subtotal = $discount = $extra_charges = 0.0; foreach ($fees as $fee) { if ($salary >= $fee['salary_start'] && ($salary <= $fee['salary_end'] || $fee['salary_end'] == 0)) { $discount = -($salary * ($fee['discount'] / 100.0)); $subtotal = $salary * ($fee['service_fee'] / 100.0); break; } } $new_total_fee = $subtotal + $discount; // 2.2.1 If this is a replacement, re-calculate accordingly by taking the previously invoiced amount. $credit_amount = 0; if ($is_replacement) { // 2.2.1a If it is a replacement, get the previously invoiced amount. $criteria = array('columns' => 'invoices.id, SUM(invoice_items.amount) AS amount_payable', 'joins' => 'invoice_items ON invoice_items.invoice = invoices.id', 'match' => "invoices.type ='R' AND invoices.is_copy = FALSE AND \n invoice_items.item = " . $previous_referral, 'group' => 'invoices.id');