Ejemplo n.º 1
0
 /**
  * Save referral. 
  */
 function execute()
 {
     $referralDao =& DAORegistry::getDAO('ReferralDAO');
     if (isset($this->referralId)) {
         $referral =& $referralDao->getReferral($this->referralId);
     }
     if (!isset($referral)) {
         $referral = new Referral();
         $referral->setDateAdded(Core::getCurrentDate());
         $referral->setLinkCount(0);
     }
     $referral->setArticleId($this->article->getId());
     $referral->setName($this->getData('name'), null);
     // Localized
     $referral->setUrl($this->getData('url'));
     $referral->setStatus($this->getData('status'));
     // Update or insert referral
     if ($referral->getId() != null) {
         $referralDao->updateReferral($referral);
     } else {
         $referralDao->insertReferral($referral);
     }
 }
Ejemplo n.º 2
0
?>
<p style="font-weight: bold;">Show all referrals... </p><p><?php 
$criteria = array('columns' => '*', 'order' => 'referred_on DESC', 'limit' => '1');
print_array($referral->find($criteria));
?>
</p><p style="font-weight: bold;">Add a referral... </p><p><?php 
$ref_1 = 0;
$ref_2 = 0;
$ref_3 = 0;
$data = array();
$data['member'] = $uid;
$data['referee'] = $rid;
$data['job'] = 159;
$data['referred_on'] = now();
if ($referral->create($data) !== false) {
    $ref_1 = $referral->getId();
    echo "This referral has an ID of <b>" . $ref_1 . "</b><br><br>";
} else {
    echo "failed";
    exit;
}
?>
</p><p style="font-weight: bold;">Add another referral... </p><p><?php 
$data = array();
$data['member'] = $uid;
$data['referee'] = $rid;
$data['job'] = 160;
$data['referred_on'] = now();
if ($referral->create($data) !== false) {
    $ref_2 = $referral->getId();
    echo "This referral has an ID of <b>" . $ref_2 . "</b><br><br>";
Ejemplo n.º 3
0
     $data['paid_through'] = 'CSH';
     $data['paid_id'] = 'FREE_REPLACEMENT';
 }
 $invoice = Invoice::create($data);
 if (!$invoice) {
     echo 'ko';
     exit;
 }
 $referral_desc = 'Reference fee for [' . $job['id'] . '] ' . $job['title'] . ' of ' . $candidate->getFullName();
 if ($is_free_replacement) {
     $referral_desc = 'Free replacement for Invoice: ' . pad($previous_invoice, 11, '0');
 }
 if ($is_replacement && !$is_free_replacement) {
     $referral_desc = 'Replacement fee for Invoice: ' . pad($previous_invoice, 11, '0');
 }
 $item_added = Invoice::addItem($invoice, $subtotal, $referral->getId(), $referral_desc);
 if (!$item_added) {
     echo "ko";
     exit;
 }
 if (!$is_free_replacement) {
     $item_added = Invoice::addItem($invoice, $discount, $referral->getId(), 'Discount');
     if (!$item_added) {
         echo "ko";
         exit;
     }
     $item_added = Invoice::addItem($invoice, $extra_charges, $referral->getId(), 'Extra charges');
     if (!$item_added) {
         echo "ko";
         exit;
     }
Ejemplo n.º 4
0
    // fwrite($handle, $message);
    // fclose($handle);
    exit;
}
if ($_POST['action'] == 'confirm_employed') {
    $work_commence_on = $_POST['work_commence_on'];
    $is_replacement = false;
    $is_free_replacement = false;
    $previous_referral = '0';
    $previous_invoice = '0';
    // 1. Update the referral to employed
    $referral = new Referral($_POST['id']);
    $employer = new Employer($_POST['employer']);
    $candidate = new Member($_POST['candidate_email_addr']);
    // get the referrer
    $criteria = array('columns' => 'member', 'match' => 'id = ' . $referral->getId(), 'limit' => '1');
    $result = $referral->find($criteria);
    $member = new Member($result[0]['member']);
    $job = array('id' => $_POST['job_id'], 'title' => $_POST['job']);
    $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'] = now();
    $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);