private function get_referred_jobs() { $criteria = array('columns' => "industries.industry, jobs.id, jobs.title, COUNT(referrals.id) AS num_referrals, \n DATE_FORMAT(jobs.expire_on, '%e %b, %Y') AS formatted_expire_on, \n jobs.description", 'joins' => 'jobs ON jobs.id = referrals.job, industries ON industries.id = jobs.industry', 'match' => "jobs.employer = '" . $this->employer->getId() . "' AND \n need_approval = 'N' AND \n (referrals.referee_acknowledged_on IS NOT NULL AND referrals.referee_acknowledged_on <> '0000-00-00 00:00:00') AND \n (referrals.member_confirmed_on IS NOT NULL AND referrals.member_confirmed_on <> '0000-00-00 00:00:00') AND \n referrals.employer_removed_on IS NULL AND \n (referrals.replacement_authorized_on IS NULL OR referrals.replacement_authorized_on = '0000-00-00 00:00:00')", 'group' => 'referrals.job', 'order' => 'num_referrals DESC'); $referral = new Referral(); $result = $referral->find($criteria); if ($result === false || is_null($result) || empty($result)) { return false; } foreach ($result as $i => $row) { $result[$i]['description'] = htmlspecialchars_decode(desanitize($row['description'])); $result[$i]['new_referrals_count'] = '0'; } $criteria = array('columns' => 'jobs.id, COUNT(referrals.id) AS num_new_referrals', 'joins' => 'jobs ON jobs.id = referrals.job, resumes ON resumes.id = referrals.resume', 'match' => "jobs.employer = '" . $this->employer->getId() . "' AND \n (resumes.deleted = 'N' AND resumes.private = 'N') AND \n (referrals.employer_agreed_terms_on IS NULL OR referrals.employer_agreed_terms_on = '0000-00-00 00:00:00') AND \n (referrals.referee_acknowledged_on IS NOT NULL AND referrals.referee_acknowledged_on <> '0000-00-00 00:00:00') AND \n (referrals.member_confirmed_on IS NOT NULL AND referrals.member_confirmed_on <> '0000-00-00 00:00:00') AND \n (referrals.employed_on IS NULL OR referrals.employed_on = '0000-00-00 00:00:00') AND \n referrals.employer_removed_on IS NULL AND \n (referrals.replacement_authorized_on IS NULL OR referrals.replacement_authorized_on = '0000-00-00 00:00:00')", 'group' => 'referrals.job'); $new_referrals = $referral->find($criteria); if ($new_referrals === false) { return false; } foreach ($new_referrals as $new_referral) { foreach ($result as $i => $row) { if ($row['id'] == $new_referral['id']) { $result[$i]['new_referrals_count'] = $new_referral['num_new_referrals']; break; } } } return $result; }
function get_rewards($_is_paid = false, $_order_by) { $criteria = array('columns' => "invoices.id AS invoice, referrals.id AS referral, referrals.total_reward,\n referrals.job AS job_id, currencies.symbol AS currency, jobs.title, \n referrals.member AS member_id, referrals.employed_on, \n employers.name AS employer, members.phone_num, \n CONCAT(members.lastname, ', ', members.firstname) AS member, \n DATE_FORMAT(referrals.employed_on, '%e %b, %Y') AS formatted_employed_on, \n (SUM(referral_rewards.reward) / 3) AS paid_reward", 'joins' => "invoice_items ON invoice_items.item = referrals.id, \n invoices ON invoices.id = invoice_items.invoice, \n referral_rewards ON referral_rewards.referral = referrals.id, \n jobs ON jobs.id = referrals.job, \n members ON members.email_addr = referrals.member, \n employers ON employers.id = jobs.employer, \n currencies ON currencies.country_code = employers.country", 'match' => "invoices.type = 'R' AND \n (invoices.paid_on IS NOT NULL AND invoices.paid_on <> '0000-00-00 00:00:00') AND \n (referrals.employed_on IS NOT NULL AND referrals.employed_on <> '0000-00-00 00:00:00') AND \n (referrals.employer_removed_on IS NULL OR referrals.employer_removed_on = '0000-00-00 00:00:00') AND \n (referrals.referee_rejected_on IS NULL OR referrals.referee_rejected_on = '0000-00-00 00:00:00') AND \n (referrals.replacement_authorized_on IS NULL OR referrals.replacement_authorized_on = '0000-00-00 00:00:00') AND \n (referrals.guarantee_expire_on <= CURDATE() OR referrals.guarantee_expire_on IS NULL) ", 'group' => "referrals.id", 'order' => $_order_by, 'having' => "(paid_reward < referrals.total_reward OR paid_reward IS NULL)"); if ($_is_paid) { $criteria['columns'] .= ", referral_rewards.gift, DATE_FORMAT(MAX(referral_rewards.paid_on), '%e %b, %Y') AS formatted_paid_on"; $criteria['having'] = "(paid_reward >= referrals.total_reward OR referral_rewards.gift IS NOT NULL)"; } else { $criteria['match'] .= "AND (referral_rewards.gift IS NULL OR referral_rewards.gift = '')"; } $referral = new Referral(); return $referral->find($criteria); }
} } header('Content-type: text/xml'); $response = array('found_employers' => array('found_employer' => $found_employers), 'pagination' => array('total_pages' => $total_pages, 'current_page' => $_POST['page']), 'application' => $result); echo $xml_dom->get_xml_from_array(array('applications' => $response)); exit; } if ($_POST['action'] == 'get_testimony') { $criteria = array('columns' => "testimony", 'match' => "id = " . $_POST['id'], 'limit' => "1"); $referral = new Referral(); $result = $referral->find($criteria); $testimony = htmlspecialchars_decode(str_replace("\n", '<br/>', $result[0]['testimony'])); echo $testimony; exit; } if ($_POST['action'] == 'get_job_desc') { $criteria = array('columns' => "description", 'match' => "id = " . $_POST['id'], 'limit' => "1"); $job = new Job(); $result = $job->find($criteria); $job_desc = htmlspecialchars_decode(str_replace("\n", '<br/>', $result[0]['description'])); echo $job_desc; exit; } if ($_POST['action'] == 'get_employer_remarks') { $criteria = array('columns' => "employer_remarks", 'match' => "id = " . $_POST['id'], 'limit' => "1"); $referral = new Referral(); $result = $referral->find($criteria); $remarks = str_replace("\n", '<br/>', stripslashes($result[0]['employer_remarks'])); echo $remarks; exit; }
private function get_applications() { $criteria = array('columns' => "referrals.id, referrals.member AS referrer, \n jobs.title AS job, jobs.id AS job_id, \n employers.name AS employer, employers.id AS employer_id, \n referrals.resume AS resume_id, resumes.file_name, \n CONCAT(members.lastname, ', ', members.firstname) AS referrer_name, \n DATE_FORMAT(referrals.referred_on, '%e %b, %Y') AS formatted_referred_on, \n DATE_FORMAT(referrals.employer_agreed_terms_on, '%e %b, %Y') AS formatted_employer_agreed_terms_on, \n DATE_FORMAT(referrals.employer_rejected_on, '%e %b, %Y') AS formatted_employer_rejected_on, \n DATE_FORMAT(referrals.employed_on, '%e %b, %Y') AS formatted_employed_on, \n DATE_FORMAT(referrals.employer_removed_on, '%e %b, %Y') AS formatted_employer_removed_on, \n IF(referrals.testimony IS NULL OR referrals.testimony = '', '0', '1') AS has_testimony, \n IF(referrals.employer_remarks IS NULL OR referrals.employer_remarks = '', '0', '1') AS has_employer_remarks", 'joins' => "members ON members.email_addr = referrals.member, \n jobs ON jobs.id = referrals.job, \n employers ON employers.id = jobs.employer, \n resumes ON resumes.id = referrals.resume", 'match' => "referrals.referee = '" . $this->member->getId() . "'", 'order' => "referrals.referred_on DESC"); $referral = new Referral(); return $referral->find($criteria); }
require_once "../private/lib/utilities.php"; function print_array($_array) { echo "<pre>"; print_r($_array); echo "</pre><br><br>"; } $uid = '*****@*****.**'; $rid = '*****@*****.**'; $eid = 'acme123'; $referral = new Referral(); ?> <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";