예제 #1
0
 $employee = new Employee($_POST['employee_id']);
 $employee_email = $employee->getEmailAddress();
 if (is_null($employee_email) || empty($employee_email) || $employee_email === false) {
     $employee_email = '';
 }
 // 1. Update the referral to employed
 $referral = new Referral($_POST['id']);
 $criteria = array('columns' => "jobs.id AS job_id, jobs.title, jobs.employer, \n                      referrals.member, referrals.referee", 'joins' => "jobs ON jobs.id = referrals.job", 'match' => "referrals.id = " . $_POST['id'], 'limit' => "1");
 $result = $referral->find($criteria);
 $employer = new Employer($result[0]['employer']);
 $candidate = new Member($result[0]['referee']);
 $member = new Member($result[0]['member']);
 $job = array('id' => $result[0]['job_id'], 'title' => htmlspecialchars_decode(stripslashes($result[0]['title'])));
 $salary = $_POST['salary'];
 $irc_id = $member->isIRC() ? $member->getId() : NULL;
 $total_reward = $referral->calculateRewardFrom($salary, $irc_id);
 $total_token_reward = $total_reward * 0.3;
 $total_reward_to_referrer = $total_reward - $total_token_reward;
 $data = array();
 $data['employed_on'] = $_POST['employed_on'];
 $data['work_commence_on'] = $work_commence_on;
 $data['salary_per_annum'] = $salary;
 $data['total_reward'] = $total_reward_to_referrer;
 $data['total_token_reward'] = $total_token_reward;
 $data['guarantee_expire_on'] = $referral->getGuaranteeExpiryDateWith($salary, $work_commence_on);
 // 1.1 Check whether the reward is 0.00 or NULL. If it is, then the employer account is not ready.
 if ($data['total_reward'] <= 0.0 || $data['guarantee_expire_on'] == '0000-00-00 00:00:00' || is_null($data['guarantee_expire_on'])) {
     echo '-1';
     exit;
 }
 if ($referral->update($data) === false) {
예제 #2
0
파일: referral.php 프로젝트: pamalite/yel
$data = array();
$data['employer_agreed_terms_on'] = now();
// This should be done before the shortlisting.
$data['shortlisted_on'] = now();
if ($referral->update($data) !== false) {
    print_array($referral->get());
} else {
    echo "failed";
    exit;
}
?>
</p><p style="font-weight: bold;">Employer decides to employ referral 3... </p><p><?php 
$data = array();
$data['employed_on'] = now();
$data['work_commence_on'] = today();
$data['salary_per_annum'] = 36000.0;
$data['total_reward'] = $referral->calculateRewardFrom($data['salary_per_annum']);
if ($referral->update($data)) {
    print_array($referral->get());
} else {
    echo "failed";
    exit;
}
?>
</p><p style="font-weight: bold;">Remove the test referrals... </p><p><?php 
$query = "DELETE FROM referrals WHERE id IN (" . $ref_1 . ", " . $ref_2 . ", " . $ref_3 . ")";
echo $query;
$mysqli = Database::connect();
print_r($mysqli->execute($query));
?>
</p>