Пример #1
0
 public static function getCardsByRecruiter(MongoId $recruiterId)
 {
     // Get cards.
     $customerId = RecruiterModel::getCustomerId($recruiterId);
     if (is_null($customerId)) {
         $cards = [];
     } else {
         $cards = StripeBilling::getCards($customerId);
     }
     return $cards;
 }
Пример #2
0
 public static function login()
 {
     self::ensureAdmin();
     global $params;
     if (!isset($params['login'])) {
         self::render('admin/login');
         return;
     }
     function data(array $data)
     {
         $type = clean($data['type']);
         $email = clean($data['email']);
         return ['type' => $type, 'email' => $email];
     }
     extract($data = data($params));
     session_unset();
     $_SESSION['email'] = $email;
     $_SESSION['pass'] = '';
     $_SESSION['skippass'] = true;
     switch ($data['type']) {
         case 'student':
             $_SESSION['loggedinstudent'] = true;
             $student = StudentModel::get($email);
             $_SESSION['_id'] = $student['_id'];
             $_SESSION['name'] = $student['name'];
             break;
         case 'recruiter':
             $_SESSION['loggedin'] = true;
             $recruiter = RecruiterModel::get($email);
             $_SESSION['_id'] = $recruiter['_id'];
             if (MongoId::isValid($recruiter['company'])) {
                 $_SESSION['company'] = $recruiter['company'];
             }
             break;
     }
     self::redirect($GLOBALS['dirpreFromRoute'] . '../');
 }
 private static function submit(MongoId $jobId, MongoId $studentId, array $questions)
 {
     $answers = array();
     foreach ($questions as $_id => $answer) {
         $answers[] = ['_id' => $_id, 'answer' => $answer];
     }
     $application = ApplicationStudent::save($jobId, $studentId, $answers);
     $applicationId = $application->getId();
     $submitted = ApplicationStudent::submit($applicationId);
     if ($submitted) {
         $job = JobModel::getByIdMinimal($jobId);
         $jobTitle = $job['title'];
         $linkApplicants = "http://sublite.net/employers/viewapplicants/{$jobId}";
         $linkManage = "http://sublite.net/employers/home";
         $recruiterId = $job['recruiter'];
         $recruiter = RecruiterModel::getByIdMinimal($recruiterId);
         $recruiterFirstname = $recruiter['firstname'];
         $recruiterEmail = $recruiter['email'];
         $message = "\n          Hi {$recruiterFirstname},\n          <br /><br />\n          You have received a new applicant for your job: <b>{$jobTitle}</b>!\n          <br /><br />\n          To unlock and view this application, go to\n          <a href='{$linkApplicants}'>View Applicants</a>.\n          <br />\n          To manage your jobs, go to <a href='{$linkManage}'>Manage</a>.\n          <br /><br />\n          View Applicants: <a href='{$linkApplicants}'>{$linkApplicants}</a><br />\n          Manage Jobs: <a href='{$linkManage}'>{$linkManage}</a><br />\n          <br /><br />\n          -------------------<br />\n          Team SubLite\n          <br /><br />\n          Please let us know if you have any questions. We hope you find the\n          right candidate for your job.\n        ";
         sendgmail([$recruiterEmail], "*****@*****.**", "New Applicant for '{$jobTitle}' | SubLite", $message);
         //send an email to the student
         $companyId = $job['company'];
         $company = CompanyModel::getById($companyId);
         $companyName = $company['name'];
         $student = StudentModel::getByIdMinimal($studentId);
         $studentFirstName = $student['name'];
         $studentEmail = $student['email'];
         $linkApplication = "http://sublite.net/jobs/application/{$applicationId}";
         $linkJob = "http://sublite.net/job?id={$jobId}";
         $linkJobSearch = "http://sublite.net/jobs/search";
         $linkJobsByCompany = "http://sublite.net/jobs/search?byrecruiter={$recruiterId}";
         $message = "\n          Hi {$studentFirstName},\n          <br />\n          <br />{$companyName} has successfully received your <a href='{$linkApplication}'>application</a> for <b>{$jobTitle}</b>!<br />\n          <br />View your application: {$linkApplication}\n          <br />View the job you applied to {$linkJob}\n          <br />View more jobs by {$linkJobsByCompany}<br />\n          <br />You are now one step closer to finding your perfect summer experience! Take more steps by applying to more jobs: {$linkJobSearch}<br />\n          -------------------<br />\n          Good luck!\n          <br />\n          Team SubLite\n        ";
         sendgmail([$studentEmail], "*****@*****.**", "Confirmation for Job Application", $message);
         self::redirect("../application/{$applicationId}");
     }
     self::error("You must attach a resume to your profile in order to submit " . "an application.");
 }
 public static function buyPlan()
 {
     RecruiterController::requireLogin();
     global $params;
     $recruiterId = $_SESSION['_id'];
     $customerId = RecruiterModel::getCustomerId($recruiterId);
     $cardId = $params['cardId'];
     $type = $params['type'];
     $term = $params['term'];
     $discount = $params['discount'];
     if ($discount == self::BUYPLAN_DISCOUNT) {
         $discountType = 'discounted';
     } else {
         $discountType = 'normal';
     }
     $costs = ['basic' => ['1' => ['normal' => 39, 'discounted' => 29], '3' => ['normal' => 99, 'discounted' => 79], '6' => ['normal' => 179, 'discounted' => 149], '12' => ['normal' => 299, 'discounted' => 259]], 'premium' => ['1' => ['normal' => 99, 'discounted' => 79], '3' => ['normal' => 249, 'discounted' => 219], '6' => ['normal' => 429, 'discounted' => 379], '12' => ['normal' => 799, 'discounted' => 739]]];
     $amount = $costs[$type][$term][$discountType] * 100;
     $description = ucfirst($type) . " plan for {$term} month(s)";
     // Charge the card.
     $err = StripeBilling::charge($customerId, $cardId, $amount, $description);
     if (!is_null($err)) {
         return self::ajaxError($err);
     }
     $message = "\n        _id: {$recruiterId}<br />\n        type: {$type}<br />\n        term: {$term}<br />\n        discount: {$discount}\n      ";
     sendgmail(['*****@*****.**', '*****@*****.**'], "*****@*****.**", 'Subscription Plan Bought!', $message);
     return self::ajaxSuccess();
 }
 public static function claimApplications()
 {
     RecruiterController::requireLogin();
     global $params;
     $jobId = new MongoId($params['jobId']);
     $count = intval($params['count']);
     $recruiterId = $_SESSION['_id'];
     // Subtract away credits.
     $credits = RecruiterModel::getCredits($recruiterId);
     if ($credits < $count) {
         return;
     }
     RecruiterModel::setCredits($recruiterId, $credits - $count);
     ApplicationModel::claim($jobId, $count);
     return self::ajaxSuccess();
 }
Пример #6
0
 function search()
 {
     // $this->requireLogin();
     global $params;
     $params = $_REQUEST;
     global $MJob, $MStudent, $MCompany, $MRecruiter;
     // Function for processing results and showing them
     function process($res)
     {
         global $MCompany;
         // Processing results
         $jobs = array();
         foreach ($res as $job) {
             $company = $MCompany->get($job['company']);
             $job['company'] = $company['name'];
             $job['desc'] = strmax($job['desc'], 300);
             $job['logophoto'] = $company['logophoto'];
             array_push($jobs, $job);
         }
         return $jobs;
     }
     // Predefined searches
     $showSearch = true;
     $showCompany = null;
     if (isset($_GET['byrecruiter'])) {
         $params = $this->dataSearchEmpty();
         $params['recruiter'] = $_GET['byrecruiter'];
         $showSearch = false;
     }
     if (isset($_GET['bycompany'])) {
         $params = $this->dataSearchEmpty();
         $params['company'] = $_GET['bycompany'];
         $showCompany = $MCompany->getByName($_GET['bycompany']);
         $showSearch = false;
     }
     if ($showSearch and !isset($params['search'])) {
         // If not searching for anything, then return last 6 entries
         $showMore = isset($_GET['showMore']);
         if ($showMore) {
             if (isset($_SESSION['showMoreJobs'])) {
                 $_SESSION['showMoreJobs'] += 6;
             } else {
                 $_SESSION['showMoreJobs'] = 12;
             }
             $showMore = $_SESSION['showMoreJobs'];
         } else {
             $_SESSION['showMoreJobs'] = 6;
         }
         $res = $MJob->last($_SESSION['showMoreJobs']);
         $jobs = process($res);
         $recent = count($jobs) < JobModel::getSize();
         self::render('jobs/search/form', $this->dataSearchSetup());
         self::render('jobs/search/results', array('jobs' => $jobs, 'recent' => $recent, 'search' => 'jobs', 'showMore' => $showMore));
         return;
     }
     // Params to vars
     extract($data = $this->dataSearch($params));
     // Validations
     $this->startValidations();
     $this->validate(!MongoId::isValid($recruiter) or !is_null(RecruiterModel::getById(new MongoId($recruiter))), $err, 'unknown recruiter');
     // Code
     if ($this->isValid()) {
         // Searching for companies
         $companyquery = array();
         if (strlen($company) > 0) {
             $companyquery['name'] = array('$regex' => keywords2mregex($company));
         }
         if (strlen($industry) > 0) {
             $companyquery['industry'] = array('$regex' => keywords2mregex($industry));
         }
         if (strlen($city) > 0) {
             $companyquery['location'] = array('$regex' => keywords2mregex($city));
         }
         $cs = $MCompany->find($companyquery);
         // Search query building
         $query = array();
         if (strlen($recruiter) > 0) {
             $query['recruiter'] = new MongoId($recruiter);
         }
         if (strlen($title) > 0) {
             $query['title'] = array('$regex' => keywords2mregex($title));
         }
         $companies = array();
         foreach ($cs as $c) {
             array_push($companies, $c['_id']);
         }
         $query['company'] = array('$in' => $companies);
         // Performing search
         $res = $MJob->find($query);
         $jobs = process($res);
         if ($showSearch) {
             self::render('jobs/search/form', $data);
         }
         self::render('jobs/search/results', array('jobs' => $jobs, 'showCompany' => $showCompany, 'search' => 'jobs'));
         // Send email notification of search to us
         // $this->sendrequestreport("Search for jobs:", $jobs);
         // Save search to db
         global $MApp;
         $MApp->recordSearch('jobs');
         return;
     }
     $this->error($err);
     self::render('jobs/search/form', array_merge($data, array('search' => 'jobs')));
 }
Пример #7
0
 function add()
 {
     function formData($data)
     {
         return array_merge($data, array('headline' => 'Create', 'submitname' => 'add', 'submitvalue' => 'Add Company'));
     }
     global $CRecruiter;
     $CRecruiter->requireLogin();
     global $params, $MCompany, $MRecruiter;
     $me = $MRecruiter->me();
     if (!isset($_POST['add'])) {
         self::render('companies/form', formData(array('name' => $me['company'])));
         return;
     }
     // Params to vars
     $params['name'] = $me['company'];
     extract($data = $this->data($params));
     // Validations
     $this->startValidations();
     $this->validate(!$this->exists(), $err, 'company exists');
     $this->validateData($data, $err);
     // Code
     if ($this->isValid()) {
         $id = $MCompany->save($data);
         $me = $MRecruiter->me();
         $me['company'] = new MongoID($id);
         $MRecruiter->save($me);
         $_SESSION['company'] = $id;
         // Add credit for making company profile.
         $recruiterId = $_SESSION['_id'];
         RecruiterModel::addCreditsForNewCompanyProfile($recruiterId);
         $this->redirect('home');
         return;
     }
     self::error($err);
     self::render('companies/form', formData($data));
 }
Пример #8
0
<?php

// Add initial credits to each recruiter.
$recruiters = RecruiterModel::getAll();
foreach ($recruiters as $recruiter) {
    if (!isset($recruiter['credits'])) {
        $recruiterId = $recruiter['_id'];
        RecruiterModel::setCredits($recruiterId, 0);
    }
}