function nojobs() { global $MRecruiter, $MJob, $MCompany; $r = $MRecruiter->find(); $j = $MJob->find(); $rids = array(); foreach ($j as $job) { $rids[] = $job['recruiter']->{'$id'}; } $emails = array(); $emailswc = array(); $emailswj = array(); foreach ($r as $recruiter) { $id = $recruiter['_id']->{'$id'}; $rdoc = $MRecruiter->getById($id); if (!in_array($id, $rids)) { $emails[] = $rdoc['email']; if (MongoID::isValid($recruiter['company'])) { $emailswc[] = $rdoc['email']; } } else { $emailswj[] = $rdoc; } } echo 'Recruiters who have posted jobs:<br /> <textarea style="width:800px; height: 400px;">'; foreach ($emailswj as $r) { $email = $r['email']; $firstname = $r['firstname']; $lastname = $r['lastname']; $company = $r['company']; if (MongoId::isValid($company)) { $company = $MCompany->getName($company); } echo "\"{$email}\",\"{$firstname}\",\"{$lastname}\",\"{$company}\"\n"; } echo '</textarea>'; echo '<br />Recruiters who have not posted jobs:<br /> <textarea style="width:800px; height: 400px;">'; foreach ($emails as $email) { echo "{$email}\n"; } echo '</textarea>'; echo '<br />Recruiters who have not posted jobs but have made a company profile:<br /> <textarea style="width:800px; height: 400px;">'; foreach ($emailswc as $email) { echo "{$email}\n"; } echo '</textarea>'; }
function recruiters() { global $MRecruiter, $MJob, $MCompany, $MApp; $recruiterArray = []; $recruiterColumns = ["email", "firstname", "lastname", "company", "datejoined", "postedjob", "madecompany", "approved"]; $jobColumns = ["jobname", "jobviews", "jobclicks", "applicants"]; $recruiterArray[] = implode(',', $recruiterColumns) . ',' . implode(',', $jobColumns); $r = $MRecruiter->find(); $j = $MJob->find(); $rids = array(); // an array of recruiters ids that have posted jobs foreach ($j as $job) { $rids[] = $job['recruiter']->{'$id'}; } foreach ($r as $recruiter) { $info = []; $id = $recruiter['_id']; $rdoc = $MRecruiter->getById($id); if (isset($recruiter['email'])) { $info['email'] = $recruiter['email']; } else { $info['email'] = 'no email'; } if (isset($recruiter['firstname'])) { $info['firstname'] = $recruiter['firstname']; } else { $info['firstname'] = 'no firstname'; } if (isset($recruiter['lastname'])) { $info['lastname'] = $recruiter['lastname']; } else { $info['lastname'] = 'no lastname'; } if (isset($recruiter['company'])) { if (MongoID::isValid($recruiter['company'])) { // if the company is a MongoID $info['company'] = $MCompany->getName($recruiter['company']); } else { $info['company'] = $recruiter['company']; } } else { $info['company'] = 'no company'; } $info['dateJoined'] = fdate($recruiter['_id']->getTimestamp()); if (in_array($id, $rids)) { // recruiters who have posted at least one job and have a company profile $info['postedJob'] = 'YES'; $info['madeCompany'] = 'YES'; $info['approved'] = 'YES'; } else { // recruiters who have not posted a job $info['postedJob'] = 'NO'; if (MongoID::isValid($recruiter['company'])) { // recruiters who have a company profile $info['madeCompany'] = 'YES'; $info['approved'] = 'YES'; } else { // recruiters who don't have a company profile $info['madeCompany'] = 'NO'; if ($recruiter['approved'] == 'approved') { // recruiters who are approved $info['approved'] = 'YES'; } else { // recruiters who are not approved $info['approved'] = 'NO'; } } } $recruiterArray[] = implode(',', self::quoteStringsInArray($info)); $jobs = $MJob->getByRecruiter($id); // get jobs for recruiter foreach ($jobs as $job) { //make rows under each recruiter for their listed jobs $jobInfo = []; if (isset($job['title'])) { $jobInfo['title'] = $job['title']; } else { 'No Job Title'; } $jobInfo['views'] = $job['stats']['views']; $jobInfo['clicks'] = $job['stats']['clicks']; $jobInfo['applicants'] = ApplicationModel::countByJob($job['_id']); $recruiterArray[] = str_repeat(',', count($recruiterColumns)) . implode(',', self::quoteStringsInArray($jobInfo)); } } return ["recruiterArray" => $recruiterArray]; }