public static function getJobsBySkill($skill_name, $comp_name) { // print "<pre>"; print_r($comp_id->attributes);print "</pre>";return; $jobMap = null; $skill_id = null; $comp_posts = null; // Query dabase by skill name and retrieve the skill_id $skill = Skillset::model()->findByAttributes(array('name' => $skill_name)); if ($skill != null) { $skill_id = $skill->id; // Get all jobs that have the skill_id $jobMap = JobSkillMap::model()->findAllByAttributes(array('skillid' => $skill_id)); } // Query the database by Company name and get All job posts for that company $comp_id = CompanyInfo::model()->findByAttributes(array('name' => $comp_name)); if ($comp_id != null) { $comp_posts = Job::model()->findAllByAttributes(array('FK_poster' => $comp_id->FK_userid)); } // Array of jobs $jobs = array(); if ($jobMap != null) { foreach ($jobMap as $aJobMap) { $jobid = $aJobMap->jobid; if ($skill_id != null && $comp_posts != null) { // search for Company and Skill $jobs[] = Job::model()->findByAttributes(array('id' => $jobid, 'FK_poster' => $comp_id->FK_userid)); } elseif ($comp_id == null) { $jobs[] = Job::model()->findByAttributes(array('id' => $jobid)); } // search for skill only } } else { if ($comp_posts != null) { foreach ($comp_posts as $aPost) { $tmp = $aPost->id; $jobs[] = Job::model()->findByAttributes(array('id' => $tmp)); // search for Company only } } } return $jobs; }
public function cascade_delete() { $id = $this->id; // delete basic info mappings $basic_info = BasicInfo::model()->findByAttributes(array('userid' => $id)); if (isset($basic_info)) { $basic_info->delete(); } // delete company info mapping $comp_info = CompanyInfo::model()->findByAttributes(array('FK_userid' => $id)); if (isset($comp_info)) { $comp_info->delete(); } // delete sms mappings $sms_mappings = SMS::model()->findAll("sender_id=:id OR receiver_id=:id ", array(':id' => $id)); foreach ($sms_mappings as $sms_mapping) { $sms_mapping->delete(); } // delete education mapping $edu_mappings = Education::model()->findAllByAttributes(array('FK_user_id' => $id)); foreach ($edu_mappings as $edu_mapping) { $edu_mapping->delete(); } // delete skills mappings $skills_mappings = StudentSkillMap::model()->findAllByAttributes(array('userid' => $id)); foreach ($skills_mappings as $skills_mapping) { $skills_mapping->delete(); } // delete application mappings $app_mappings = Application::model()->findAllByAttributes(array('userid' => $id)); foreach ($app_mappings as $app_mapping) { $app_mapping->delete(); } // delete jobs mappings $job_mappings = Job::model()->findAllByAttributes(array('FK_poster' => $id)); foreach ($job_mappings as $job_mapping) { $job_mapping->cascade_delete(); } $this->delete(); }
if ($i < $sizeJobs) { ?> <!-- CareerPath --> <tr> <td><a href="/JobFair/index.php/job/view/jobid/<?php echo $jobs[$i]->id; ?> "><?php echo $jobs[$i]->title; ?> </a></td> <td><a href="/JobFair/index.php/profile/employer/user/<?php echo User::model()->findByAttributes(array('id' => $jobs[$i]->FK_poster))->username; ?> "><?php echo CompanyInfo::model()->findByAttributes(array('FK_userid' => $jobs[$i]->FK_poster))->name; ?> </a></td> <td><?php echo $jobs[$i]->type; ?> </td> <td><?php echo Yii::app()->dateFormatter->format('MM/dd/yyyy', $jobs[$i]->post_date); ?> </td> <!-- <td>--><?php //echo Yii::app()->dateFormatter->format('MM/dd/yyyy', $jobs[$i]->deadline); ?> <!--</td>--> <td><?php
public static function getCompanyNamesUser($fKPoster) { $names = CompanyInfo::model()->findBySql("SELECT company_info.name FROM company_info WHERE FK_userid=:FK_poster", array(":FK_poster" => $fKPoster)); return $names->name; }
$("#aboutmeleft").text(aboutmelimit + " characters left"); $("#companydescleft").text(companydesclimit + " characters left"); }); </script> <h2>Employer Register</h2> <div class="form"> <?php $form = $this->beginWidget('CActiveForm', array('id' => 'user-EmployerRegister-form', 'enableAjaxValidation' => false)); ?> <?php $model->companyInfo = CompanyInfo::model(); $model->basicInfo = BasicInfo::model(); ?> <p class="note">Fields with <span class="required">*</span> are required.</p> <p style="color:red" id="errors"></p> <h4>Personal Info.</h4> <div id="regbox"> <?php echo $form->labelEx($model, 'username'); ?> <?php echo $form->textField($model, 'username'); ?>
public function actionSearch() { $flag = 1; $keyword = $_POST['keyword']; // Get words to search $pieces = trim($keyword); $pieces = explode(" ", $pieces); // split words to search $count = sizeof($pieces); // get number of word to search $query = ''; for ($i = 0; $i < $count; $i++) { if ($i == $count - 1) { $query = $query . 'name like \'%' . $pieces[$i] . '%\''; } else { $query = $query . 'name like \'%' . $pieces[$i] . '%\' OR '; } } $criteria = new CDbCriteria(); $criteria->condition = $query; $results = array(); if ($keyword != null) { $skillsArray = Skillset::model()->findAll($criteria); foreach ($skillsArray as $sk) { if ($sk != null) { $jobIds = JobSkillMap::model()->findAllByAttributes(array('skillid' => $sk->id)); // get all jobs with that skill if ($jobIds != null) { foreach ($jobIds as $ji) { if ($ji != null) { $jobid = $ji->jobid; $duplicate = 0; if (sizeof($results) > 0) { foreach ($results as $t) { if ($t != null) { if (strcmp($t->id, $jobid) == 0) { $duplicate = 1; } } } } if ($duplicate == 0) { $results[] = Job::model()->findByAttributes(array('id' => $jobid, 'active' => '1')); // search for skill only } } } } } } $compsArray = CompanyInfo::model()->findAll($criteria); foreach ($compsArray as $co) { if ($co != null) { $comp_posts = Job::model()->findAllByAttributes(array('FK_poster' => $co->FK_userid)); if ($comp_posts != null) { foreach ($comp_posts as $cp) { $duplicate = 0; if (sizeof($results) > 1) { if ($cp != null) { foreach ($results as $t) { if ($t != null) { if ($t->id == $cp->id) { $duplicate = 1; } } } } } if ($duplicate == 0) { $results[] = Job::model()->findByAttributes(array('id' => $cp->id, 'active' => '1')); } } } } } } if (isset($_GET['user'])) { $username = $_GET['user']; } else { $username = Yii::app()->user->name; } $user = User::model()->find("username=:username", array(':username' => $username)); // pass user $skills = Skillset::getNames(); // pass skills $companies = CompanyInfo::getNames(); // pass companies $this->render('home', array('flag' => $flag, 'results' => $results, 'user' => $user, 'companies' => $companies, 'skills' => $skills)); //$this->render('studentSearchResults',array('results'=>$results,'user'=>$user,'companies'=>$companies,'skills'=>$skills,)); }