?
Path : /home/admin/public_html/old/promice/components/com_jsjobs/models/ |
Current File : /home/admin/public_html/old/promice/components/com_jsjobs/models/jsjobs.php |
<?php /** + Created by: Ahmad Bilal * Company: Al-Barr Technologies + Contact: www.al-barr.com , info@al-barr.com * Created on: Jan 11, 2009 ^ + Project: Job Posting and Employment Application * File Name: models/jsjobs.php ^ * Description: Model class for application data ^ * History: NONE ^ */ defined('_JEXEC') or die('Restricted access'); jimport('joomla.application.component.model'); jimport('joomla.html.html'); $option = JRequest :: getVar('option', 'com_jsjobs'); class JSJobsModelJsjobs extends JModel { var $_id = null; var $_uid = null; var $_application = null; var $_applications = array(); var $_options = null; var $_empoptions = null; var $_searchoptions = null; var $_config = null; function __construct() { parent :: __construct(); $user =& JFactory::getUser(); } function &getJobSearch($title,$jobcategory,$jobtype,$jobstatus,$jobsalaryrange,$education ,$company,$country,$state,$county,$city,$zipcode,$sortby,$limit,$limitstart) { $result = array(); $db = &$this->getDBO(); // here AlexeyR patch to more flexible SQL request for Title,Company,City fields $wherequery = ''; if ($title != '') $wherequery .= " AND job.title LIKE '%".str_replace("'","",$db->Quote($title))."%'"; if ($jobcategory != '') $wherequery .= " AND job.jobcategory = ".$db->Quote($jobcategory); if ($jobtype != '') $wherequery .= " AND job.jobtype = ".$db->Quote($jobtype); if ($jobstatus != '') $wherequery .= " AND job.jobstatus = ".$db->Quote($jobstatus); if ($jobsalaryrange != '') $wherequery .= " AND job.jobsalaryrange = ".$db->Quote($jobsalaryrange); if ($education != '') $wherequery .= " AND job.heighestfinisheducation = ".$db->Quote($education); if ($company != '') $wherequery .= " AND job.company LIKE '%".str_replace("'","",$db->Quote($company))."%'"; if ($country != '') $wherequery .= " AND country.name LIKE ".$db->Quote($country); if ($state != '') $wherequery .= " AND state.name LIKE ".$db->Quote($state); if ($county != '') $wherequery .= " AND county.name LIKE ".$db->Quote($county); if ($city != '') $wherequery .= " AND city.name LIKE '%".str_replace("'","",$db->Quote($city))."%'"; if ($zipcode != '') $wherequery .= " AND job.zipcode = ".$db->Quote($zipcode); $query = "SELECT count(job.id) FROM ".$db->nameQuote('#__js_job_jobs')." AS job, ".$db->nameQuote('#__js_job_categories')." AS cat WHERE job.jobcategory = cat.id AND job.status = 1 AND (job.jobstatus BETWEEN 1 AND 5)"; $query .= $wherequery; //echo '<br> SQL '.$query; $db->setQuery($query); $total = $db->loadResult(); $limit = $limit ? $limit : 5; if ( $total <= $limit ) { $limitstart = 0; } $query = "SELECT job.*, cat.cat_title , salary.rangestart, salary.rangeend, country.name AS countryname FROM ".$db->nameQuote('#__js_job_jobs')." AS job LEFT JOIN ".$db->nameQuote('#__js_job_salaryrange')." AS salary ON job.jobsalaryrange = salary.id LEFT JOIN ".$db->nameQuote('#__js_job_countries')." AS country ON job.country = country.code , ".$db->nameQuote('#__js_job_categories')." AS cat "; if ($country != '') $query .= " , ".$db->nameQuote('#__js_job_countries')." AS country "; if ($state != '') $query .= " , ".$db->nameQuote('#__js_job_states')." AS state "; if ($county != '') $query .= " , ".$db->nameQuote('#__js_job_counties')." AS county "; if ($city != '') $query .= " , ".$db->nameQuote('#__js_job_cities')." AS city "; $query .= "WHERE job.jobcategory = cat.id AND job.status = 1 AND (job.jobstatus BETWEEN 1 AND 5) "; $query .= $wherequery; $query .= " ORDER BY ".$sortby; //echo '<br> SQL '.$query; $db->setQuery($query); //$db->setQuery($query, $limitstart, $limit); $this->_applications = $db->loadObjectList(); $result[0] = $this->_applications; $result[1] = $total; return $result; } function &getMyJobs($u_id,$sortby,$limit,$limitstart) { $result = array(); $db = &$this->getDBO(); $query = "SELECT count(job.id) FROM ".$db->nameQuote('#__js_job_jobs')." AS job WHERE job.uid = ".$db->Quote($u_id); //echo '<br> SQL '.$query; $db->setQuery($query); $total = $db->loadResult(); $limit = $limit ? $limit : 5; if ( $total <= $limit ) { $limitstart = 0; } $query = "SELECT job.*, cat.cat_title , salary.rangestart, salary.rangeend, country.name AS countryname FROM ".$db->nameQuote('#__js_job_jobs')." AS job LEFT JOIN ".$db->nameQuote('#__js_job_salaryrange')." AS salary ON job.jobsalaryrange = salary.id LEFT JOIN ".$db->nameQuote('#__js_job_countries')." AS country ON job.country = country.code , ".$db->nameQuote('#__js_job_categories')." AS cat WHERE job.jobcategory = cat.id AND job.uid = ".$db->Quote($u_id)." ORDER BY ".$sortby; //echo '<br> SQL '.$query; $db->setQuery($query, $limitstart, $limit); $this->_applications = $db->loadObjectList(); $result[0] = $this->_applications; $result[1] = $total; return $result; } function &getjob($job_id) // <<<--- this isn't used { $db = &$this->getDBO(); $query = "SELECT job.*, cat.cat_title, city.name AS cityname, county.name AS countyname , state.name AS statename, country.name AS countryname , salary.rangestart, salary.rangeend FROM ".$db->nameQuote('#__js_job_jobs')." AS job JOIN ".$db->nameQuote('#__js_job_categories')." AS cat ON job.jobcategory = cat.id LEFT JOIN ".$db->nameQuote('#__js_job_salaryrange')." AS salary ON job.jobsalaryrange = salary.id LEFT JOIN ".$db->nameQuote('#__js_job_cities')." AS city ON job.city = city.code LEFT JOIN ".$db->nameQuote('#__js_job_counties')." AS county ON job.county = county.code LEFT JOIN ".$db->nameQuote('#__js_job_states')." AS state ON job.state = state.code LEFT JOIN ".$db->nameQuote('#__js_job_countries')." AS country ON job.country = country.code WHERE job.id = ".$db->Quote($job_id); //echo $query; $db->setQuery($query); $this->_application = $db->loadObject(); return $this->_application; } function &getJobcat() { $db = &$this->getDBO(); $query = "SELECT DISTINCT cat.id, cat.cat_title, "; $query .= " (SELECT COUNT(job.id) from ".$db->nameQuote('#__js_job_jobs')." AS job WHERE cat.id = job.jobcategory AND job.status = 1 AND job.jobstatus BETWEEN 1 AND 5) as catinjobs"; $query .= " FROM ".$db->nameQuote('#__js_job_categories')." AS cat left JOIN ".$db->nameQuote('#__js_job_jobs')." AS job "; $query .= " ON cat.id = job.jobcategory "; $query .= " WHERE cat.isactive = 1 "; $query .= " ORDER BY 'id' "; //echo '<br> SQL '.$query; $db->setQuery($query); $this->_application = $db->loadObjectList(); return $this->_application; } function &getJobsbyCategory($cat_id,$sortby,$limit,$limitstart) { $db = &$this->getDBO(); $result = array(); $query = "SELECT COUNT(job.id) FROM ".$db->nameQuote('#__js_job_jobs')." AS job, ".$db->nameQuote('#__js_job_categories')." AS cat WHERE job.jobcategory = cat.id AND job.status = 1 AND (job.jobstatus BETWEEN 1 AND 5) AND cat.id = ".$db->Quote($cat_id); //echo '<br> SQL '.$query; $db->setQuery($query); $total = $db->loadResult(); $limit = $limit ? $limit : 5; if ( $total <= $limit ) { $limitstart = 0; } $query = "SELECT job.*, cat.cat_title, salary.rangestart, salary.rangeend, country.name AS countryname FROM ".$db->nameQuote('#__js_job_jobs')." AS job LEFT JOIN ".$db->nameQuote('#__js_job_salaryrange')." AS salary ON job.jobsalaryrange = salary.id LEFT JOIN ".$db->nameQuote('#__js_job_countries')." AS country ON job.country = country.code , ".$db->nameQuote('#__js_job_categories')." AS cat WHERE job.jobcategory = cat.id AND job.status = 1 AND (job.jobstatus BETWEEN 1 AND 5) AND cat.id = ".$db->Quote($cat_id)." ORDER BY ".$sortby; //echo '<br> SQL '.$query; $db->setQuery($query, $limitstart, $limit); $this->_applications = $db->loadObjectList(); $result[0] = $this->_applications; $result[1] = $total; return $result; } function &getJobbyId($job_id) { $db = &$this->getDBO(); $query = "SELECT job.*, cat.cat_title FROM ".$db->nameQuote('#__js_job_jobs')." AS job, ".$db->nameQuote('#__js_job_categories')." AS cat WHERE job.jobcategory = cat.id AND job.id = ".$db->Quote($job_id); //echo '<br> SQL '.$query; $db->setQuery($query); $this->_application = $db->loadObject(); return $this->_application; } function &getMyApplication($u_id) { $db = &$this->getDBO(); $query = "SELECT id, application_title, create_date, status FROM ".$db->nameQuote('#__js_job_resume')." WHERE uid = ".$db->Quote($u_id); //echo '<br> SQL '.$query; $db->setQuery($query); $this->_application = $db->loadObject(); return $this->_application; } function &getMyAppliedJobs($u_id,$sortby,$limit,$limitstart) { $db = &$this->getDBO(); $result = array(); $query = "SELECT COUNT(job.id) FROM ".$db->nameQuote('#__js_job_jobs')." AS job, ".$db->nameQuote('#__js_job_jobapply')." AS apply WHERE apply.jobid = job.id AND apply.uid = ".$db->Quote($u_id); //echo '<br> SQL '.$query; $db->setQuery($query); $total = $db->loadResult(); $limit = $limit ? $limit : 5; if ( $total <= $limit ) { $limitstart = 0; } $query = "SELECT job.*, cat.cat_title, apply.apply_date , salary.rangestart, salary.rangeend, country.name AS countryname FROM ".$db->nameQuote('#__js_job_jobs')." AS job LEFT JOIN ".$db->nameQuote('#__js_job_salaryrange')." AS salary ON job.jobsalaryrange = salary.id LEFT JOIN ".$db->nameQuote('#__js_job_countries')." AS country ON job.country = country.code , ".$db->nameQuote('#__js_job_categories')." AS cat , ".$db->nameQuote('#__js_job_jobapply')." AS apply WHERE job.jobcategory = cat.id AND apply.jobid = job.id AND apply.uid = ".$db->Quote($u_id)." ORDER BY ".$sortby; //echo '<br> SQL '.$query; $db->setQuery($query, $limitstart, $limit); $this->_applications = $db->loadObjectList(); $result[0] = $this->_applications; $result[1] = $total; return $result; } function &getJobsAppliedApplications($u_id,$sortby,$limit,$limitstart) { $db = &$this->getDBO(); $result = array(); $query = "SELECT COUNT(job.id) FROM ".$db->nameQuote('#__js_job_jobs')." AS job, ".$db->nameQuote('#__js_job_categories')." AS cat WHERE job.jobcategory = cat.id AND job.uid= ".$db->Quote($u_id); //echo '<br> SQL '.$query; $db->setQuery($query); $total = $db->loadResult(); $limit = $limit ? $limit : 5; if ( $total <= $limit ) { $limitstart = 0; } $query = "SELECT DISTINCT job.*, cat.cat_title , (SELECT COUNT(apply.id) FROM ".$db->nameQuote('#__js_job_jobapply')." AS apply WHERE apply.jobid = job.id ) as appinjob FROM ".$db->nameQuote('#__js_job_jobs')." AS job, ".$db->nameQuote('#__js_job_categories')." AS cat WHERE job.jobcategory = cat.id AND job.uid= ".$db->Quote($u_id)." ORDER BY ".$sortby; //echo '<br> SQL '.$query; $db->setQuery($query, $limitstart, $limit); $this->_applications = $db->loadObjectList(); $result[0] = $this->_applications; $result[1] = $total; return $result; } function &getJobAppliedApplications($u_id,$jobid,$sortby,$limit,$limitstart) { $db = &$this->getDBO(); $result = array(); $query = "SELECT COUNT(job.id) FROM ".$db->nameQuote('#__js_job_jobs')." AS job , ".$db->nameQuote('#__js_job_jobapply')." AS apply , ".$db->nameQuote('#__js_job_resume')." AS app WHERE apply.jobid = job.id AND apply.cvid = app.id AND apply.jobid = ".$db->Quote($jobid); //echo '<br> SQL '.$query; $db->setQuery($query); $total = $db->loadResult(); $limit = $limit ? $limit : 5; if ( $total <= $limit ) { $limitstart = 0; } $query = "SELECT job.id, cat.cat_title ,apply.apply_date, app.id AS appid, app.first_name, app.last_name, app.email_address, app.jobtype, app.jobsalaryrange, salary.rangestart, salary.rangeend FROM ".$db->nameQuote('#__js_job_jobs')." AS job, ".$db->nameQuote('#__js_job_categories')." AS cat , ".$db->nameQuote('#__js_job_jobapply')." AS apply , ".$db->nameQuote('#__js_job_resume')." AS app LEFT OUTER JOIN ".$db->nameQuote('#__js_job_salaryrange')." AS salary ON app.jobsalaryrange=salary.id WHERE job.jobcategory = cat.id AND apply.jobid = job.id AND apply.cvid = app.id AND apply.jobid = ".$db->Quote($jobid)." ORDER BY ".$sortby; //echo '<br> SQL '.$query; $db->setQuery($query, $limitstart, $limit); $this->_applications = $db->loadObjectList(); $result[0] = $this->_applications; $result[1] = $total; return $result; } function &getCurUserAllow($u_id) { $db = &$this->getDBO(); $query = "SELECT * FROM ".$db->nameQuote('#__js_job_userallow') ." WHERE uid= ".$db->Quote($u_id); //echo '<br> SQL '.$query; $db->setQuery($query); $this->_application = $db->loadObject(); return $this->_application; } function &getConfig() { if ( !$this->_config ){ $db = &$this->getDBO(); $query = "SELECT * FROM ".$db->nameQuote('#__js_job_config'); //echo '<br> SQL '.$query; $db->setQuery($query); $this->_config = $db->loadObjectList(); } return $this->_config; } function storejob() //store job { $row = &$this->getTable('jobposting'); $data = JRequest :: get('post'); if ( !$this->_config ) $this->getConfig(); foreach ($this->_config as $conf){ if ($conf->configname == 'jobautoapprove') $data['status'] = $conf->configvalue; } //++++++++++++++++++++++++++++++++++++++++ if ($data['applyinfo'] == '') $data['applyinfo'] = "0"; //++++++++++++++++++++++++++++++++++++++++ if (!$row->bind($data)) { $this->setError($this->_db->getErrorMsg()); return false; } if (!$row->check()) { $this->setError($this->_db->getErrorMsg()); return 2; } if (!$row->store()) { $this->setError($this->_db->getErrorMsg()); return false; } return true; } function jobapply() { $row = &$this->getTable('jobapply'); $data = JRequest :: get('post'); if (!$row->bind($data)) { $this->setError($this->_db->getErrorMsg()); return false; } if (!$row->check()) { $this->setError($this->_db->getErrorMsg()); return false; } if ($data['id'] == ''){ // only for new $result=$this->jobApplyValidation($data['uid'],$data['jobid']); if ($result == true) { return 3; } } if (!$row->store()) { $this->setError($this->_db->getErrorMsg()); return false; } $emailrerurn=$this->sendMail($data['jobid'], $data['uid']); return true; } function storeUserAllow($u_id) { $row = & $this->getTable('userallow'); $data['uid'] = $u_id; if ( !$this->_config ) $this->getConfig(); foreach ($this->_config as $conf){ if ($conf->configname == 'defaultempallow') $data['empallow'] = $conf->configvalue; if ($conf->configname == 'defaultjoballow') $data['joballow'] = $conf->configvalue; } if (!$row->bind($data)) { $this->setError($this->_db->getErrorMsg()); return false; } if (!$row->check()) { $this->setError($this->_db->getErrorMsg()); return 2; } if (!$row->store()) { $this->setError($this->_db->getErrorMsg()); return false; } return true; } function jobApplyValidation($u_id, $jobid) { $db =& JFactory::getDBO(); $query = "SELECT COUNT(id) FROM #__js_job_jobapply WHERE uid = ".$db->Quote($u_id) ." AND jobid = ".$db->Quote($jobid); echo '<br>sql '.$query; $db->setQuery( $query ); $result = $db->loadResult(); //echo '<br>r'.$result; if ($result == 0) return false; else return true; } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //send mail function &sendMail($jobid, $uid) { $db =& JFactory::getDBO(); $jobquery = "SELECT users.name, users.email, job.title, job.applyinfo FROM ".$db->nameQuote('#__users') ."AS users, ".$db->nameQuote('#__js_job_jobs') ." AS job WHERE users.id = job.uid AND job.id = ".$db->Quote($jobid); //echo '<br>sql '.$jobquery; $db->setQuery( $jobquery ); $jobuser = $db->loadObject(); if ($jobuser->applyinfo == '1'){ $userquery = "SELECT name, email FROM ".$db->nameQuote('#__users') ." WHERE id = ".$db->Quote($uid); //echo '<br>sql '.$userquery; $db->setQuery( $userquery ); $user = $db->loadObject(); $ApplicantName=$user->name; $EmployerEmail=$jobuser->email; $EmployerName=$jobuser->name; $JobTitle=$jobuser->title; if ( !$this->_config ) $this->getConfig(); foreach ($this->_config as $conf){ if ($conf->configname == 'mailfromname') $senderName = $conf->configvalue; if ($conf->configname == 'mailfromaddress') $senderEmail = $conf->configvalue; } $message =& JFactory::getMailer(); $message->addRecipient($EmployerEmail); //to email $message->setSubject("JS Jobs : $ApplicantName apply for $JobTitle"); $siteAddress = JURI::base(); $msgBody="Hello $EmployerName , \n\n Mr/Mrs $ApplicantName apply for $JobTitle.\n Login and view detail at $siteAddress \n\nPlease do not respond to this message. It is automatically generated and is for information purposes only."; $message->setBody($msgBody); $sender = array( $senderEmail, $senderName ); $message->setSender($sender); $sent = $message->send(); return $sent; //if ($sent != 1) echo 'Error sending email'; } } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //Employement Application // get application for the set id function &getEmpApplicationbyid($id) // <<<--- this isn't used { $db = &$this->getDBO(); $query = "SELECT app.* , cat.cat_title AS job_category, salary.rangestart, salary.rangeend , address_city.name AS address_city , address_county.name AS address_county , address_state.name AS address_state , address_country.name AS address_country , institute_city.name AS institute_city , institute_county.name AS institute_county , institute_state.name AS institute_state , institute_country.name AS institute_country , employer_city.name AS employer_city , employer_county.name AS employer_county , employer_state.name AS employer_state , employer_country.name AS employer_country FROM ".$db->nameQuote('#__js_job_resume')." AS app JOIN ".$db->nameQuote('#__js_job_categories')." AS cat ON app.job_category = cat.id LEFT JOIN ".$db->nameQuote('#__js_job_salaryrange')." AS salary ON app.jobsalaryrange = salary.id LEFT JOIN ".$db->nameQuote('#__js_job_cities')." AS address_city ON app.address_city = address_city.code LEFT JOIN ".$db->nameQuote('#__js_job_counties')." AS address_county ON app.address_county = address_county.code LEFT JOIN ".$db->nameQuote('#__js_job_states')." AS address_state ON app.address_state = address_state.code LEFT JOIN ".$db->nameQuote('#__js_job_countries')." AS address_country ON app.address_country = address_country.code LEFT JOIN ".$db->nameQuote('#__js_job_cities')." AS institute_city ON app.institute_city = institute_city.code LEFT JOIN ".$db->nameQuote('#__js_job_counties')." AS institute_county ON app.institute_county = institute_county.code LEFT JOIN ".$db->nameQuote('#__js_job_states')." AS institute_state ON app.institute_state = institute_state.code LEFT JOIN ".$db->nameQuote('#__js_job_countries')." AS institute_country ON app.institute_country = institute_country.code LEFT JOIN ".$db->nameQuote('#__js_job_cities')." AS employer_city ON app.employer_city = employer_city.code LEFT JOIN ".$db->nameQuote('#__js_job_counties')." AS employer_county ON app.employer_county = employer_county.code LEFT JOIN ".$db->nameQuote('#__js_job_states')." AS employer_state ON app.employer_state = employer_state.code LEFT JOIN ".$db->nameQuote('#__js_job_countries')." AS employer_country ON app.employer_country = employer_country.code WHERE app.id = ".$db->Quote($id); //echo '<br> sql '.$query; $db->setQuery($query); $this->_application = $db->loadObject(); return $this->_application; } function &getEmpApplicationbyuserid($u_id) { $db = &$this->getDBO(); $query = "SELECT app.* , cat.cat_title AS job_category, salary.rangestart, salary.rangeend , address_city.name AS address_city , address_county.name AS address_county , address_state.name AS address_state , address_country.name AS address_country , institute_city.name AS institute_city , institute_county.name AS institute_county , institute_state.name AS institute_state , institute_country.name AS institute_country , employer_city.name AS employer_city , employer_county.name AS employer_county , employer_state.name AS employer_state , employer_country.name AS employer_country FROM ".$db->nameQuote('#__js_job_resume')." AS app JOIN ".$db->nameQuote('#__js_job_categories')." AS cat ON app.job_category = cat.id LEFT JOIN ".$db->nameQuote('#__js_job_salaryrange')." AS salary ON app.jobsalaryrange = salary.id LEFT JOIN ".$db->nameQuote('#__js_job_cities')." AS address_city ON app.address_city = address_city.code LEFT JOIN ".$db->nameQuote('#__js_job_counties')." AS address_county ON app.address_county = address_county.code LEFT JOIN ".$db->nameQuote('#__js_job_states')." AS address_state ON app.address_state = address_state.code LEFT JOIN ".$db->nameQuote('#__js_job_countries')." AS address_country ON app.address_country = address_country.code LEFT JOIN ".$db->nameQuote('#__js_job_cities')." AS institute_city ON app.institute_city = institute_city.code LEFT JOIN ".$db->nameQuote('#__js_job_counties')." AS institute_county ON app.institute_county = institute_county.code LEFT JOIN ".$db->nameQuote('#__js_job_states')." AS institute_state ON app.institute_state = institute_state.code LEFT JOIN ".$db->nameQuote('#__js_job_countries')." AS institute_country ON app.institute_country = institute_country.code LEFT JOIN ".$db->nameQuote('#__js_job_cities')." AS employer_city ON app.employer_city = employer_city.code LEFT JOIN ".$db->nameQuote('#__js_job_counties')." AS employer_county ON app.employer_county = employer_county.code LEFT JOIN ".$db->nameQuote('#__js_job_states')." AS employer_state ON app.employer_state = employer_state.code LEFT JOIN ".$db->nameQuote('#__js_job_countries')." AS employer_country ON app.employer_country = employer_country.code WHERE app.uid = ".$db->Quote($u_id); //echo '<br> sql '.$query; $db->setQuery($query); $this->_application = $db->loadObject(); return $this->_application; } function &getEmpApplicationbyuid($u_id) { $db = &$this->getDBO(); $query = "SELECT * FROM ".$db->nameQuote('#__js_job_resume')." WHERE ".$db->nameQuote('uid')." = ".$db->Quote($u_id); //echo '<br> sql '.$query; $db->setQuery($query); $this->_application = $db->loadObject(); return $this->_application; } function storeEmpApp() { global $resumedata; $row = &$this->getTable('empapp'); $resumedata = JRequest :: get('post'); if ( !$resumedata['id'] ){ if ( !$this->_config ) $this->getConfig(); foreach ($this->_config as $conf){ if ($conf->configname == 'empautoapprove') $resumedata['status'] = $conf->configvalue; } } $resumedata['resume'] = JRequest::getVar('resume', '', 'post', 'string', JREQUEST_ALLOWRAW); $returnvalue = $this->uploadResume($resumedata['uid']); if ($returnvalue != 1) return $returnvalue; if (!$row->bind($resumedata)) { $this->setError($this->_db->getErrorMsg()); return false; } if (!$row->check()) { $this->setError($this->_db->getErrorMsg()); return 2; } if (!$row->store()) { $this->setError($this->_db->getErrorMsg()); return false; } return true; } function uploadResume($u_id) { global $resumedata ; $db =& JFactory::getDBO(); $resumequery = "SELECT * FROM ".$db->nameQuote('#__js_job_resume') ." WHERE uid = ".$db->Quote($u_id); //echo '<br>sql '.$resumequery; if($_FILES['resumefile']['size'] > 0){ $file_name = $_FILES['resumefile']['name']; // file name $file_tmp = $_FILES['resumefile']['tmp_name']; // actual location $file_size = $_FILES['resumefile']['size']; // file size $file_type = $_FILES['resumefile']['type']; // mime type of file determined by php $file_error = $_FILES['resumefile']['error']; // any error!. get reason here if( !empty($file_tmp)){ // only MS office and text file is accepted. if( !(($file_type=="application/msword") || ($file_type=="text/plain")) ) { return 6; //file type mistmathc } } $path =JPATH_BASE.'/components/com_jsjobs/resume'; if (!file_exists($path)){ // creating resume directory mkdir($path, 0777); } $userpath= $path . '/'.$u_id; if (!file_exists($userpath)){ // create user directory mkdir($userpath, 0777); } $files = glob($userpath.'/*.*'); array_map('unlink', $files); //delete all file in user directory move_uploaded_file($file_tmp, $userpath.'/' . $file_name); //unlink($file_tmp); $resumedata['filename'] = $file_name; $resumedata['filecontent'] = ''; return 1; }else { if ($resumedata['deleteresumefile'] == 1){ $path =JPATH_BASE.'/components/com_jsjobs/resume'; $userpath= $path . '/'.$u_id; $files = glob($userpath.'/*.*'); array_map('unlink', $files); $resumedata['filename'] = ''; $resumedata['filecontent'] = ''; }else{ $db->setQuery( $resumequery ); $resume = $db->loadObject(); if ( isset($resume) ){ // if already file upload then pick the path $resumedata['filename'] = $resume->filename; $resumedata['filecontent'] = ''; } } return 1; } } function &listAddressData($data,$val) { $db = &$this->getDBO(); if ($data=='country') { // country $query = "SELECT code, name FROM ".$db->nameQuote('#__js_job_countries')." ORDER BY name ASC"; $db->setQuery($query); $result = $db->loadObjectList(); if (empty($result)) { $return_value = "<input class='inputbox' type='text' name='country' size='40' maxlength='100' />"; }else { $return_value = "<select name='country' onChange=\"dochange('state', this.value)\">\n"; $return_value .= "<option value='0'>". JText::_('JP_CHOOSE_COUNTRY') ."</option>\n"; foreach($result as $row){ $return_value .= "<option value=\"$row->code\" >$row->name</option> \n" ; } $return_value .= "</select>\n"; } }else if ($data=='state') { // states $query = "SELECT code, name from ".$db->nameQuote('#__js_job_states')." WHERE countrycode= '$val' ORDER BY name ASC"; $db->setQuery($query); $result = $db->loadObjectList(); if (empty($result)) { $return_value = "<input class='inputbox' type='text' name='state' size='40' maxlength='100' />"; }else { $return_value = "<select name='state' class='inputbox' onChange=\"dochange('county', this.value)\">\n"; $return_value .= "<option value='0'>". JText::_('JP_CHOOSE_STATE') ."</option>\n"; foreach($result as $row){ $return_value .= "<option value=\"$row->code\" >$row->name</option> \n" ; } $return_value .= "</select>\n"; } }else if ($data=='county') { // county $query = "SELECT code, name from ".$db->nameQuote('#__js_job_counties')." WHERE statecode= '$val' ORDER BY name ASC"; $db->setQuery($query); $result = $db->loadObjectList(); if (empty($result)) { $return_value = "<input class='inputbox' type='text' name='county' size='40' maxlength='100' />"; }else { $return_value = "<select name='county' class='inputbox' onChange=\"dochange('city', this.value)\">\n"; $return_value .= "<option value='0'>". JText::_('JP_CHOOSE_COUNTY') ."</option>\n"; foreach($result as $row){ $return_value .= "<option value=\"$row->code\" >$row->name</option> \n" ; } $return_value .= "</select>\n"; } } else if ($data=='city') { // city $query = "SELECT code, name from ".$db->nameQuote('#__js_job_cities')." WHERE countycode= '$val' ORDER BY 'name'"; $db->setQuery($query); $result = $db->loadObjectList(); //if (mysql_num_rows($result)== 0) if (empty($result)) { $return_value = "<input class='inputbox' type='text' name='city' size='40' maxlength='100' />"; }else { $return_value = "<select name='city' class='inputbox' onChange=\"dochange('zipcode', this.value)\">\n"; $return_value .= "<option value='0'>". JText::_('JP_CHOOSE_CITY') ."</option>\n"; foreach($result as $row){ $return_value .= "<option value=\"$row->code\" >$row->name</option> \n" ; } $return_value .= "</select>\n"; } } return $return_value; } function &listSearchAddressData($data,$val) { $db = &$this->getDBO(); if ($data=='country') { // country $query = "SELECT code, name FROM ".$db->nameQuote('#__js_job_countries')." ORDER BY name ASC"; $db->setQuery($query); $result = $db->loadObjectList(); if (empty($result)) { $return_value = "<input class='inputbox' type='text' name='country' size='40' maxlength='100' />"; }else { $return_value = "<select name='country' onChange=\"dochange('state', this.value)\">\n"; $return_value .= "<option value=''>".JText::_('JP_SEARCH_ALL')."</option>\n"; foreach($result as $row){ $return_value .= "<option value=\"$row->code\" >$row->name</option> \n" ; } $return_value .= "</select>\n"; } }else if ($data=='state') { // states $query = "SELECT code, name from ".$db->nameQuote('#__js_job_states')." WHERE countrycode= '$val' ORDER BY name ASC"; $db->setQuery($query); $result = $db->loadObjectList(); if (empty($result)) { $return_value = "<input class='inputbox' type='text' name='state' size='40' maxlength='100' />"; }else { $return_value = "<select name='state' class='inputbox' onChange=\"dochange('county', this.value)\">\n"; $return_value .= "<option value=''>".JText::_('JP_SEARCH_ALL')."</option>\n"; foreach($result as $row){ $return_value .= "<option value=\"$row->code\" >$row->name</option> \n" ; } $return_value .= "</select>\n"; } }else if ($data=='county') { // county $query = "SELECT code, name from ".$db->nameQuote('#__js_job_counties')." WHERE statecode= '$val' ORDER BY name ASC"; $db->setQuery($query); $result = $db->loadObjectList(); if (empty($result)) { $return_value = "<input class='inputbox' type='text' name='county' size='40' maxlength='100' />"; }else { $return_value = "<select name='county' class='inputbox' onChange=\"dochange('city', this.value)\">\n"; $return_value .= "<option value=''>".JText::_('JP_SEARCH_ALL')."</option>\n"; foreach($result as $row){ $return_value .= "<option value=\"$row->code\" >$row->name</option> \n" ; } $return_value .= "</select>\n"; } } else if ($data=='city') { // city $query = "SELECT code, name from ".$db->nameQuote('#__js_job_cities')." WHERE countycode= '$val' ORDER BY 'name'"; $db->setQuery($query); $result = $db->loadObjectList(); //if (mysql_num_rows($result)== 0) if (empty($result)) { $return_value = "<input class='inputbox' type='text' name='city' size='40' maxlength='100' />"; }else { $return_value = "<select name='city' class='inputbox' onChange=\"dochange('zipcode', this.value)\">\n"; $return_value .= "<option value=''>".JText::_('JP_SEARCH_ALL')."</option>\n"; foreach($result as $row){ $return_value .= "<option value=\"$row->code\" >$row->name</option> \n" ; } $return_value .= "</select>\n"; } } return $return_value; } function &listEmpAddressData($name, $myname, $nextname, $data, $val) { $db = &$this->getDBO(); if ($data=='country') { // country $query = "SELECT code, name FROM ".$db->nameQuote('#__js_job_countries')." ORDER BY name ASC"; $db->setQuery($query); $result = $db->loadObjectList(); if (empty($result)) { $return_value = "<input class='inputbox' type='text' name='$name' size='40' maxlength='100' />"; }else { $return_value = "<select name='$name' onChange=\"dochange(\"$myname\",'state', this.value)\">\n"; $return_value .= "<option value='0'>". JText::_('JP_CHOOSE_COUNTRY') ."</option>\n"; foreach($result as $row){ $return_value .= "<option value=\"$row->code\" >$row->name</option> \n" ; } $return_value .= "</select>\n"; } }else if ($data=='state') { // states $query = "SELECT code, name from ".$db->nameQuote('#__js_job_states')." WHERE countrycode= '$val' ORDER BY name ASC"; $db->setQuery($query); $result = $db->loadObjectList(); if (empty($result)) { $return_value = "<input class='inputbox' type='text' name='$name' size='40' maxlength='100' />"; }else { $return_value = "<select name='$name' class='inputbox' onChange=\"dochange('$myname','$nextname','','county', this.value)\">\n"; $return_value .= "<option value='0'>". JText::_('JP_CHOOSE_STATE') ."</option>\n"; foreach($result as $row){ $return_value .= "<option value=\"$row->code\" >$row->name</option> \n" ; } $return_value .= "</select>\n"; } }else if ($data=='county') { // county $query = "SELECT code, name from ".$db->nameQuote('#__js_job_counties')." WHERE statecode= '$val' ORDER BY name ASC"; $db->setQuery($query); $result = $db->loadObjectList(); if (empty($result)) { $return_value = "<input class='inputbox' type='text' name='$name' size='40' maxlength='100' />"; }else { $return_value = "<select name='$name' class='inputbox' onChange=\"dochange('$myname','','','city', this.value)\">\n"; $return_value .= "<option value='0'>". JText::_('JP_CHOOSE_COUNTY') ."</option>\n"; foreach($result as $row){ $return_value .= "<option value=\"$row->code\" >$row->name</option> \n" ; } $return_value .= "</select>\n"; } } else if ($data=='city') { // second dropdown $query = "SELECT code, name from ".$db->nameQuote('#__js_job_cities')." WHERE countycode= '$val' ORDER BY 'name'"; $db->setQuery($query); $result = $db->loadObjectList(); if (empty($result)) { $return_value = "<input class='inputbox' type='text' name='$name' size='40' maxlength='100' />"; }else { $return_value = "<select name='$name' class='inputbox' onChange=\"dochange('zipcode', this.value)\">\n"; $return_value .= "<option value='0'>". JText::_('JP_CHOOSE_CITY') ."</option>\n"; foreach($result as $row){ $return_value .= "<option value=\"$row->code\" >$row->name</option> \n" ; } $return_value .= "</select>\n"; } } return $return_value; } function &getEmpOptions() { if ( !$this->_empoptions ) { $this->_empoptions = array(); $job_type = array( '0' => array('value' => JText::_(1), 'text' => JText::_('JP_JOBTYPE_FULLTIME')), '1' => array('value' => JText::_(2), 'text' => JText::_('JP_JOBTYPE_PARTTIME')), '3' => array('value' => JText::_(3), 'text' => JText::_('JP_JOBTYPE_INTERNSHIP')),); $heighesteducation = array( '0' => array('value' => JText::_(1), 'text' => JText::_('JP_JOBEDUCATION_UNIVERSITY')), '1' => array('value' => JText::_(2), 'text' => JText::_('JP_JOBEDUCATION_COLLEGE')), '2' => array('value' => JText::_(2), 'text' => JText::_('JP_JOBEDUCATION_HIGH_SCHOOL')), '3' => array('value' => JText::_(3), 'text' => JText::_('JP_JOBEDUCATION_NO_SCHOOL')),); $job_categories = $this->getCategories(); $job_salaryrange = $this->getJobSalaryRange(); $countries = $this->getCountries(); if(isset($this->_application))$address_states = $this->getStates($this->_application->address_country); if(isset($this->_application))$address_counties = $this->getCounties($this->_application->address_state); if(isset($this->_application))$address_cities = $this->getCities($this->_application->address_county); if(isset($this->_application))$institute_states = $this->getStates($this->_application->institute_country); if(isset($this->_application))$institute_counties = $this->getCounties($this->_application->institute_state); if(isset($this->_application))$institute_cities = $this->getCities($this->_application->institute_county); if(isset($this->_application))$employer_states = $this->getStates($this->_application->employer_country); if(isset($this->_application))$employer_counties = $this->getCounties($this->_application->employer_state); if(isset($this->_application))$employer_cities = $this->getCities($this->_application->employer_county); if ( isset($this->_application) ) { $this->_empoptions['job_category'] = JHTML::_('select.genericList', $job_categories, 'job_category', 'class="inputbox" '. '', 'value', 'text', $this->_application->job_category); $this->_empoptions['address_country'] = JHTML::_('select.genericList', $countries, 'address_country','class="inputbox" '.'onChange="dochange(\'address_state\', \'address_county\',\'address_city\', \'state\', this.value)"', 'value', 'text', $this->_application->address_country); if ($address_states[1] != '')$this->_empoptions['address_state'] = JHTML::_('select.genericList', $address_states, 'address_state', 'class="inputbox" '. 'onChange="dochange(\'address_county\, \'address_city\', , this.value)"', 'value', 'text', $this->_application->address_state); if ($address_counties[1] != '')$this->_empoptions['address_county'] = JHTML::_('select.genericList', $address_counties, 'address_county', 'class="inputbox" '. 'onChange="dochange(\'address_city\, , , this.value)"', 'value', 'text', $this->_application->address_county); if ($address_cities[1] != '')$this->_empoptions['address_city'] = JHTML::_('select.genericList', $address_cities, 'address_city', 'class="inputbox" '. '', 'value', 'text', $this->_application->address_city); $this->_empoptions['institute_country'] = JHTML::_('select.genericList', $countries, 'institute_country','class="inputbox" '.'onChange="dochange(\'institute_state\', \'institute_county\',\'institute_city\', \'state\', this.value)"', 'value', 'text', $this->_application->institute_country); if ($institute_states[1] != '')$this->_empoptions['institute_state'] = JHTML::_('select.genericList', $institute_states, 'institute_state', 'class="inputbox" '. 'onChange="dochange(\'institute_county\, \'institute_city\', , this.value)"', 'value', 'text', $this->_application->institute_state); if ($institute_counties[1] != '')$this->_empoptions['institute_county'] = JHTML::_('select.genericList', $institute_counties, 'institute_county', 'class="inputbox" '. 'onChange="dochange(\'institute_city\, , , this.value)"', 'value', 'text', $this->_application->institute_county); if ($institute_cities[1] != '')$this->_empoptions['institute_city'] = JHTML::_('select.genericList', $institute_cities, 'institute_city', 'class="inputbox" '. '', 'value', 'text', $this->_application->institute_city); $this->_empoptions['employer_country'] = JHTML::_('select.genericList', $countries, 'employer_country','class="inputbox" '.'onChange="dochange(\'employer_state\', \'employer_county\',\'employer_city\',\'state\', this.value)"', 'value', 'text', $this->_application->employer_country); if ($employer_states[1] != '')$this->_empoptions['employer_state'] = JHTML::_('select.genericList', $employer_states, 'employer_state', 'class="inputbox" '. 'onChange="dochange(\'employer_county\, \'employer_city\', , this.value)"', 'value', 'text', $this->_application->employer_state); if ($employer_counties[1] != '')$this->_empoptions['employer_county'] = JHTML::_('select.genericList', $employer_counties, 'employer_county', 'class="inputbox" '. 'onChange="dochange(\'employer_city\, , , this.value)"', 'value', 'text', $this->_application->employer_county); if ($employer_cities[1] != '')$this->_empoptions['employer_city'] = JHTML::_('select.genericList', $employer_cities, 'employer_city', 'class="inputbox" '. '', 'value', 'text', $this->_application->employer_city); $this->_empoptions['jobtype'] = JHTML::_('select.genericList', $job_type, 'jobtype', 'class="inputbox" '. '', 'value', 'text', $this->_application->jobtype); $this->_empoptions['heighestfinisheducation'] = JHTML::_('select.genericList', $heighesteducation, 'heighestfinisheducation', 'class="inputbox" '. '', 'value', 'text', $this->_application->heighestfinisheducation); $this->_empoptions['jobsalaryrange'] = JHTML::_('select.genericList', $job_salaryrange, 'jobsalaryrange', 'class="inputbox" '. '', 'value', 'text', $this->_application->jobsalaryrange); } else { $this->_empoptions['job_category'] = JHTML::_('select.genericList', $job_categories, 'job_category', 'class="inputbox" '. '', 'value', 'text', ''); $this->_empoptions['address_country'] = JHTML::_('select.genericList', $countries, 'address_country','class="inputbox" '.'onChange="dochange(\'address_state\', \'address_county\',\'address_city\', \'state\', this.value)"', 'value', 'text', ''); //echo '<br> st '.$address_states[1]; if ( isset($address_states[1]) )if ($address_states[1] != '')$this->_empoptions['address_state'] = JHTML::_('select.genericList', $address_states, 'address_state', 'class="inputbox" '. 'onChange="dochange(\'address_county\, \'address_city\', , this.value)"', 'value', 'text', ''); if ( isset($address_counties[1]) )if ($address_counties[1] != '')$this->_empoptions['address_county'] = JHTML::_('select.genericList', $address_counties, 'address_county', 'class="inputbox" '. 'onChange="dochange(\'address_city\, , , this.value)"', 'value', 'text', ''); if ( isset($address_cities[1]) )if ($address_cities[1] != '')$this->_empoptions['address_city'] = JHTML::_('select.genericList', $address_cities, 'address_city', 'class="inputbox" '. '', 'value', 'text', ''); $this->_empoptions['institute_country'] = JHTML::_('select.genericList', $countries, 'institute_country','class="inputbox" '.'onChange="dochange(\'institute_state\', \'institute_county\',\'institute_city\', \'state\', this.value)"', 'value', 'text', ''); if ( isset($institute_states[1]) )if ($institute_states[1] != '')$this->_empoptions['institute_state'] = JHTML::_('select.genericList', $institute_states, 'institute_state', 'class="inputbox" '. 'onChange="dochange(\'institute_county\, \'institute_city\', , this.value)"', 'value', 'text', ''); if ( isset($institute_counties[1]) )if ($institute_counties[1] != '')$this->_empoptions['institute_county'] = JHTML::_('select.genericList', $institute_counties, 'institute_county', 'class="inputbox" '. 'onChange="dochange(\'institute_city\, , , this.value)"', 'value', 'text', ''); if ( isset($institute_cities[1]) )if ($institute_cities[1] != '')$this->_empoptions['institute_city'] = JHTML::_('select.genericList', $institute_cities, 'institute_city', 'class="inputbox" '. '', 'value', 'text', $this->_application->institute_city); $this->_empoptions['employer_country'] = JHTML::_('select.genericList', $countries, 'employer_country','class="inputbox" '.'onChange="dochange(\'employer_state\', \'employer_county\',\'employer_city\',\'state\', this.value)"', 'value', 'text', ''); if ( isset($employer_states[1]) )if ($employer_states[1] != '')$this->_empoptions['employer_state'] = JHTML::_('select.genericList', $employer_states, 'employer_state', 'class="inputbox" '. 'onChange="dochange(\'employer_county\, \'employer_city\', , this.value)"', 'value', 'text', ''); if ( isset($employer_counties[1]) )if ($employer_counties[1] != '')$this->_empoptions['employer_county'] = JHTML::_('select.genericList', $employer_counties, 'employer_county', 'class="inputbox" '. 'onChange="dochange(\'employer_city\, , , this.value)"', 'value', 'text', ''); if ( isset($employer_cities[1]) )if ($employer_cities[1] != '')$this->_empoptions['employer_city'] = JHTML::_('select.genericList', $employer_cities, 'employer_city', 'class="inputbox" '. '', 'value', 'text', ''); $this->_empoptions['jobtype'] = JHTML::_('select.genericList', $job_type, 'jobtype', 'class="inputbox" '. '', 'value', 'text', ''); $this->_empoptions['heighestfinisheducation'] = JHTML::_('select.genericList', $heighesteducation, 'heighestfinisheducation', 'class="inputbox" '. '', 'value', 'text', ''); $this->_empoptions['jobsalaryrange'] = JHTML::_('select.genericList', $job_salaryrange, 'jobsalaryrange', 'class="inputbox" '. '', 'value', 'text', ''); } } return $this->_empoptions; } function &getSearchOptions() { //echo '<br> search options'; if ( !$this->_searchoptions ) { $this->_searchoptions = array(); $jobtype = array( '0' => array('value' => JText::_(''), 'text' => JText::_('JP_SEARCH_ALL')), '1' => array('value' => JText::_(1), 'text' => JText::_('JP_JOBTYPE_FULLTIME')), '2' => array('value' => JText::_(2), 'text' => JText::_('JP_JOBTYPE_PARTTIME')), '3' => array('value' => JText::_(3), 'text' => JText::_('JP_JOBTYPE_INTERNSHIP')),); $jobstatus = array( '0' => array('value' => JText::_(''), 'text' => JText::_('JP_SEARCH_ALL')), '1' => array('value' => JText::_(1), 'text' => JText::_('JP_JOBSTATUS_SOURCING')), '2' => array('value' => JText::_(2), 'text' => JText::_('JP_JOBSTATUS_INTERVIEWING')), '3' => array('value' => JText::_(3), 'text' => JText::_('JP_JOBSTATUS_CLOSED')), '4' => array('value' => JText::_(4), 'text' => JText::_('JP_JOBSTATUS_FINALISTS')), '5' => array('value' => JText::_(5), 'text' => JText::_('JP_JOBSTATUS_PENDING')), '6' => array('value' => JText::_(6), 'text' => JText::_('JP_JOBSTATUS_HOLD')),); $heighesteducation = array( '0' => array('value' => JText::_(''), 'text' => JText::_('JP_SEARCH_ALL')), '1' => array('value' => JText::_(1), 'text' => JText::_('JP_JOBEDUCATION_UNIVERSITY')), '2' => array('value' => JText::_(2), 'text' => JText::_('JP_JOBEDUCATION_COLLEGE')), '3' => array('value' => JText::_(2), 'text' => JText::_('JP_JOBEDUCATION_HIGH_SCHOOL')), '4' => array('value' => JText::_(3), 'text' => JText::_('JP_JOBEDUCATION_NO_SCHOOL')),); $job_categories = $this->getSearchCategories(); $job_salaryrange = $this->getSearchJobSalaryRange(); //$countries = $this->getSearchCountries(); $this->_searchoptions['jobcategory'] = JHTML::_('select.genericList', $job_categories, 'jobcategory', 'class="inputbox" '. '', 'value', 'text', ''); $this->_searchoptions['jobsalaryrange'] = JHTML::_('select.genericList', $job_salaryrange, 'jobsalaryrange', 'class="inputbox" '. '', 'value', 'text', ''); //$this->_searchoptions['country'] = JHTML::_('select.genericList', $countries, 'country', 'class="inputbox" '. '','javascript=onchange()', 'value', 'text', ''); $this->_searchoptions['jobstatus'] = JHTML::_('select.genericList', $jobstatus, 'jobstatus', 'class="inputbox" '. '', 'value', 'text', ''); $this->_searchoptions['jobtype'] = JHTML::_('select.genericList', $jobtype, 'jobtype', 'class="inputbox" '. '', 'value', 'text', ''); $this->_searchoptions['heighestfinisheducation'] = JHTML::_('select.genericList', $heighesteducation, 'heighestfinisheducation', 'class="inputbox" '. '', 'value', 'text', ''); } return $this->_searchoptions; } function getSearchCategories( ) { $db =& JFactory::getDBO(); $query = "SELECT * FROM ".$db->nameQuote('#__js_job_categories')." WHERE isactive = 1 ORDER BY 'id' "; //echo '<br>sql '.$query; $db->setQuery( $query ); $rows = $db->loadObjectList(); if ($db->getErrorNum()) { echo $db->stderr(); return false; } $jobcategories = array(); $jobcategories[] = array('value' => JText::_(''), 'text' => JText::_('JP_SEARCH_ALL')); foreach($rows as $row) { $jobcategories[] = array('value' => JText::_($row->id), 'text' => JText::_($row->cat_title)); } return $jobcategories; } function getSearchJobSalaryRange( ) { $db =& JFactory::getDBO(); $query = "SELECT * FROM ".$db->nameQuote('#__js_job_salaryrange')." ORDER BY 'id' "; //echo '<br>sql '.$query; $db->setQuery( $query ); $rows = $db->loadObjectList(); if ($db->getErrorNum()) { echo $db->stderr(); return false; } $jobsalaryrange = array(); $jobsalaryrange[] = array('value' => JText::_(''), 'text' => JText::_('JP_SEARCH_ALL')); if ( !$this->_config ) $this->getConfig(); foreach ($this->_config as $conf){ if ($conf->configname == 'currency') $currency = $conf->configvalue; } foreach($rows as $row) { $salrange = $currency . $row->rangestart.' - '.$currency . $row->rangeend; $jobsalaryrange[] = array('value' => JText::_($row->id), 'text' => JText::_($salrange)); } return $jobsalaryrange; } // we're just setting our option type values for the html output function &getOptions() { if ( !$this->_options ) { $this->_options = array(); $jobtype = array( '0' => array('value' => JText::_(1), 'text' => JText::_('JP_JOBTYPE_FULLTIME')), '1' => array('value' => JText::_(2), 'text' => JText::_('JP_JOBTYPE_PARTTIME')), '2' => array('value' => JText::_(3), 'text' => JText::_('JP_JOBTYPE_INTERNSHIP')),); $jobstatus = array( '0' => array('value' => JText::_(1), 'text' => JText::_('JP_JOBSTATUS_SOURCING')), '1' => array('value' => JText::_(2), 'text' => JText::_('JP_JOBSTATUS_INTERVIEWING')), '2' => array('value' => JText::_(3), 'text' => JText::_('JP_JOBSTATUS_CLOSED')), '3' => array('value' => JText::_(4), 'text' => JText::_('JP_JOBSTATUS_FINALISTS')), '4' => array('value' => JText::_(5), 'text' => JText::_('JP_JOBSTATUS_PENDING')), '5' => array('value' => JText::_(6), 'text' => JText::_('JP_JOBSTATUS_HOLD')),); $heighesteducation = array( '0' => array('value' => JText::_(1), 'text' => JText::_('JP_JOBEDUCATION_UNIVERSITY')), '1' => array('value' => JText::_(2), 'text' => JText::_('JP_JOBEDUCATION_COLLEGE')), '2' => array('value' => JText::_(2), 'text' => JText::_('JP_JOBEDUCATION_HIGH_SCHOOL')), '3' => array('value' => JText::_(3), 'text' => JText::_('JP_JOBEDUCATION_NO_SCHOOL')),); $job_categories = $this->getCategories(); $job_salaryrange = $this->getJobSalaryRange(); $countries = $this->getCountries(); if ( isset($this->_application) ){ $states = $this->getStates($this->_application->country); $counties = $this->getCounties($this->_application->state); $cities = $this->getCities($this->_application->county); } if ( isset($this->_application) ) { $this->_options['jobcategory'] = JHTML::_('select.genericList', $job_categories, 'jobcategory', 'class="inputbox" '. '', 'value', 'text', $this->_application->jobcategory); $this->_options['jobsalaryrange'] = JHTML::_('select.genericList', $job_salaryrange, 'jobsalaryrange', 'class="inputbox" '. '', 'value', 'text', $this->_application->jobsalaryrange); $this->_options['country'] = JHTML::_('select.genericList', $countries, 'country','class="inputbox required" '.'onChange="dochange(\'state\', this.value)"', 'value', 'text', $this->_application->country); if ( isset($states[1]) ) if ($states[1] != '')$this->_options['state'] = JHTML::_('select.genericList', $states, 'state', 'class="inputbox" '. 'onChange="dochange(\'county\', this.value)"', 'value', 'text', $this->_application->state); if ( isset($counties[1]) ) if ($counties[1] != '')$this->_options['county'] = JHTML::_('select.genericList', $counties, 'county', 'class="inputbox" '. 'onChange="dochange(\'city\', this.value)"', 'value', 'text', $this->_application->county); if ( isset($cities[1]) ) if ($cities[1] != '')$this->_options['city'] = JHTML::_('select.genericList', $cities, 'city', 'class="inputbox" '. '', 'value', 'text', $this->_application->city); $this->_options['jobstatus'] = JHTML::_('select.genericList', $jobstatus, 'jobstatus', 'class="inputbox" '. '', 'value', 'text', $this->_application->jobstatus); $this->_options['jobtype'] = JHTML::_('select.genericList', $jobtype, 'jobtype', 'class="inputbox" '. '', 'value', 'text', $this->_application->jobtype); $this->_options['heighestfinisheducation'] = JHTML::_('select.genericList', $heighesteducation, 'heighestfinisheducation', 'class="inputbox" '. '', 'value', 'text', $this->_application->heighestfinisheducation); } else { $this->_options['jobcategory'] = JHTML::_('select.genericList', $job_categories, 'jobcategory', 'class="inputbox" '. '', 'value', 'text', ''); $this->_options['jobsalaryrange'] = JHTML::_('select.genericList', $job_salaryrange, 'jobsalaryrange', 'class="inputbox" '. '', 'value', 'text', ''); $this->_options['country'] = JHTML::_('select.genericList', $countries, 'country','class="inputbox required" '.'onChange="dochange(\'state\', this.value)"', 'value', 'text', ''); if ( isset($states[1]) ) if ($states[1] != '')$this->_options['state'] = JHTML::_('select.genericList', $states, 'state', 'class="inputbox" '. 'onChange="dochange(\'county\', this.value)"', 'value', 'text', ''); if ( isset($counties[1]) ) if ($counties[1] != '')$this->_options['county'] = JHTML::_('select.genericList', $counties, 'county', 'class="inputbox" '. 'onChange="dochange(\'city\', this.value)"', 'value', 'text', ''); if ( isset($cities[1]) ) if ($cities[1] != '')$this->_options['city'] = JHTML::_('select.genericList', $cities, 'city', 'class="inputbox" '. '', 'value', 'text', ''); $this->_options['jobstatus'] = JHTML::_('select.genericList', $jobstatus, 'jobstatus', 'class="inputbox" '. '', 'value', 'text', ''); $this->_options['jobtype'] = JHTML::_('select.genericList', $jobtype, 'jobtype', 'class="inputbox" '. '', 'value', 'text', ''); $this->_options['heighestfinisheducation'] = JHTML::_('select.genericList', $heighesteducation, 'heighestfinisheducation', 'class="inputbox" '. '', 'value', 'text', ''); } } return $this->_options; } function getCategories( ) { $db =& JFactory::getDBO(); $query = "SELECT * FROM ".$db->nameQuote('#__js_job_categories')." WHERE isactive = 1 ORDER BY 'id' "; //echo '<br>sql '.$query; $db->setQuery( $query ); $rows = $db->loadObjectList(); if ($db->getErrorNum()) { echo $db->stderr(); return false; } $jobcategories = array(); foreach($rows as $row) { $jobcategories[] = array('value' => JText::_($row->id), 'text' => JText::_($row->cat_title)); } return $jobcategories; } function getJobSalaryRange( ) { $db =& JFactory::getDBO(); $query = "SELECT * FROM ".$db->nameQuote('#__js_job_salaryrange')." ORDER BY 'id' "; //echo '<br>sql '.$query; $db->setQuery( $query ); $rows = $db->loadObjectList(); if ($db->getErrorNum()) { echo $db->stderr(); return false; } if ( !$this->_config ) $this->getConfig(); foreach ($this->_config as $conf){ if ($conf->configname == 'currency') $currency = $conf->configvalue; } $jobsalaryrange = array(); foreach($rows as $row) { $salrange = $currency . $row->rangestart.' - '.$currency . $row->rangeend; $jobsalaryrange[] = array('value' => JText::_($row->id), 'text' => JText::_($salrange)); } return $jobsalaryrange; } function getCountries( ) { $db =& JFactory::getDBO(); $query = "SELECT * FROM ".$db->nameQuote('#__js_job_countries')." ORDER BY name ASC "; //echo '<br>sql '.$query; $db->setQuery( $query ); $rows = $db->loadObjectList(); if ($db->getErrorNum()) { echo $db->stderr(); return false; } $countries = array(); $countries[] = array('value' => JText::_(''), 'text' => JText::_('JP_CHOOSE_COUNTRY')); foreach($rows as $row) { $countries[] = array('value' => JText::_($row->code), 'text' => JText::_($row->name)); } return $countries; } function getStates( $countrycode ) { // if ($this->_application->country != ''){ $db =& JFactory::getDBO(); $query = "SELECT * FROM ".$db->nameQuote('#__js_job_states')." WHERE countrycode = '". $countrycode ."' ORDER BY name ASC "; $db->setQuery( $query ); $rows = $db->loadObjectList(); if ($db->getErrorNum()) { echo $db->stderr(); return false; } $states = array(); $states[] = array('value' => JText::_(''), 'text' => JText::_('JP_CHOOSE_STATE')); foreach($rows as $row) { $states[] = array('value' => JText::_($row->code), 'text' => JText::_($row->name)); } // } return $states; } function getCounties( $statecode ) { // if ($this->_application->state != ''){ $db =& JFactory::getDBO(); $query = "SELECT * FROM ".$db->nameQuote('#__js_job_counties')." WHERE statecode = '". $statecode ."' ORDER BY name ASC "; $db->setQuery( $query ); $rows = $db->loadObjectList(); if ($db->getErrorNum()) { echo $db->stderr(); return false; } $counties = array(); $counties[] = array('value' => JText::_(''), 'text' => JText::_('JP_CHOOSE_COUNTY')); foreach($rows as $row) { $counties[] = array('value' => JText::_($row->code), 'text' => JText::_($row->name)); } // } return $counties; } function getCities( $countycode ) { // if ($this->_application->county != ''){ $db =& JFactory::getDBO(); $query = "SELECT * FROM ".$db->nameQuote('#__js_job_cities')." WHERE countycode = '". $countycode ."' ORDER BY name ASC "; $db->setQuery( $query ); $rows = $db->loadObjectList(); if ($db->getErrorNum()) { echo $db->stderr(); return false; } $cities = array(); $cities[] = array('value' => JText::_(''), 'text' => JText::_('JP_CHOOSE_CITY')); foreach($rows as $row) { $cities[] = array('value' => JText::_($row->code), 'text' => JText::_($row->name)); } // } return $cities; } } ?>