Ejemplo n.º 1
0
 // 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;
 $credit_amount = 0;
 // 2.2.1 If this is a replacement, re-calculate accordingly by taking the previously invoiced amount.
Ejemplo n.º 2
0
    $result[0]['has_free_postings'] = $employer->has_free_job_postings() === false ? '0' : $employer->has_free_job_postings();
    $result[0]['has_paid_postings'] = $employer->has_paid_job_postings() === false ? '0' : $employer->has_paid_job_postings();
    $response = array('subscription' => $result[0]);
    header('Content-type: text/xml');
    echo $xml_dom->get_xml_from_array($response);
    exit;
}
if ($_POST['action'] == 'buy_subscriptions') {
    $mysqli = Database::connect();
    $employer = new Employer($_POST['id']);
    // 1. generate invoice in the system
    $data = array();
    $data['issued_on'] = today();
    $data['type'] = 'J';
    $data['employer'] = $_POST['id'];
    $data['payable_by'] = sql_date_add($data['issued_on'], $employer->get_payment_terms_days(), 'day');
    $invoice = Invoice::create($data);
    if ($invoice === false) {
        echo 'ko';
        exit;
    }
    $desc = $_POST['period'] . ' month(s) of subscription';
    $item_added = Invoice::add_item($invoice, $_POST['amount'], '1', $desc);
    $items = array();
    $items[0]['itemdesc'] = $desc;
    $items[0]['amount'] = number_format($_POST['price'], '2', '.', ', ');
    $items[1]['itemdesc'] = 'Administration Fee';
    $items[1]['amount'] = number_format($_POST['admin_fee'], '2', '.', ', ');
    // 2. generate the PDF version to be attached to sales.xx and the employer
    $branch_raw = $employer->get_branch();
    $sales = 'sales.' . strtolower($branch_raw[0]['country']) . '@yellowelevator.com';