public function save() { $jobCatId = $this->getValue('jobCategoryId'); if (!empty($jobCatId)) { $jobCat = $this->getJobCategoryService()->getJobCategoryById($jobCatId); } else { $jobCat = new JobCategory(); } $jobCat->setName($this->getValue('name')); $jobCat->save(); }
public function actionIndex($confirm = 0) { $this->layout = '//layouts/column1'; if ($confirm) { $this->render('cvconfirm'); } else { $formModel = new JobForm(); $cvModel = new JobCv(); $job = new Job(); $jobProvider = new CActiveDataProvider('Job', array('criteria' => array('condition' => 'active = 1', 'order' => 'category_id ASC, title ASC'), 'pagination' => false)); $jobCategory = JobCategory::model()->findAll(); foreach ($jobProvider->getData() as $data) { $formModel->{$data['id']} = null; } if (isset($_POST['JobForm'])) { $listJob = '<ul>'; $oneChecked = false; foreach ($_POST['JobForm'] as $key => $item) { if (is_numeric($key) && $item == '1') { $oneChecked = true; $jobChecked = Job::model()->findByPk($key); $listJob .= '<li>' . $jobChecked->title . ' (' . $jobChecked->category->name . ')</li>'; } } $listJob .= '</ul>'; $cvModel->date = date('Y-m-d H:i:s'); $cvModel->cv = $_POST['JobCv']['cv']; if (!$oneChecked) { $cvModel->addError('cv', Yii::t('jobModule.common', 'Vous devez cocher au moins un emploi')); } elseif ($cvModel->save()) { foreach ($_POST['JobForm'] as $attribute => $value) { if (is_numeric($attribute) && $value == '1') { $jobId = (int) $attribute; Yii::app()->db->createCommand('INSERT INTO job_job_cv (job_id, job_cv_id) VALUES (:job_id, :job_cv_id)')->execute(array(':job_id' => $jobId, ':job_cv_id' => $cvModel->id)); } } $subject = 'Postulation pour une offre d’emploi'; $body = ' <p>Bonjour,<br/><br/> Vous avez reçu une candidature pour un ou plusieurs emplois à partir du site Web d`Arianne Phosphate Inc.<br/> ' . $listJob . '<br/> <a href="' . $this->createAbsoluteUrl('admincv/read', array('id' => $cvModel->id)) . '">Voir les détails de la candidature</a><br/><br/> </p> '; $attachment = "./" . $cvModel->cvHandler->dir . "/" . Helper::encodeFileName($cvModel->cv); if (($mailerError = Helper::sendMail($this->module->cvEmail, $subject, $body, $attachment)) !== true) { throw new CHttpException(500, $mailerError); } $this->redirect($this->createUrl('index', array('confirm' => 1))); } } $this->render('index', array('jobProvider' => $jobProvider, 'categories' => $jobCategory, 'formModel' => $formModel, 'cvModel' => $cvModel)); } }
/** * Saving Job Category * @param JobCategory $jobCategory * @returns boolean * @throws DaoException, DataDuplicationException */ public function saveJobCategory(JobCategory $jobCategory) { try { $q = Doctrine_Query::create()->from('JobCategory j')->where('j.eec_desc = ?', $jobCategory->getEecDesc()); if (!empty($jobCategory->eec_code)) { $q->andWhere('j.eec_code <> ?', $jobCategory->eec_code); } if ($q->count() > 0) { throw new DataDuplicationException(); } if ($jobCategory->getEecCode() == '') { $idGenService = new IDGeneratorService(); $idGenService->setEntity($jobCategory); $jobCategory->setEecCode($idGenService->getNextID()); } $jobCategory->save(); return true; } catch (Doctrine_Exception $e) { throw new DaoException($e->getMessage()); } }
public function insertRandomRow() { /* generate the field values */ /* first generate the random values, then add them to query */ $workTypeId = rand(1, WorkType::getRowsNumber()); $districtId = rand(1, District::getRowsNumber()); $jobSubCategoryId = rand(1, JobSubCategory::getRowsNumber()); $salaryLow = rand(20, 200) * 1000; $salaryRange = rand(5, 30) * 1000; $daysOffset = -60 + rand(1, 90); $startDate = strtotime(sprintf("%+d", $daysOffset) . " day"); $endDate = strtotime(sprintf("%+d", $daysOffset + 30) . " day"); /* Processing this information */ $workType = WorkType::getWorkTypeName(WorkType::getWorkType($workTypeId)); $district = District::getDistrict($districtId); $districtName = District::getDistrictName($district); $regionName = Region::getRegionName(Region::getRegion(District::getRegionId($district))); $jobSubCategory = JobSubCategory::getJobSubCategory($jobSubCategoryId); $jobSubCategoryName = JobSubCategory::getJobSubCategoryName($jobSubCategory); $jobCategoryId = JobSubCategory::getJobCategoryId($jobSubCategory); $jobCategoryName = JobCategory::getJobCategoryName(JobCategory::getJobCategory($jobCategoryId)); $salaryHigh = $salaryLow + $salaryRange; $jobTitle = "Job in {$regionName}"; $jobDescription = "{$jobSubCategoryName} " . strtolower($workType) . " job in {$districtName}, {$regionName}, in the domain of {$jobCategoryName}, salary from \${$salaryLow} to \${$salaryHigh}.\n"; $jobDescription .= "Posted on " . date("D, jS \\of F, Y", $startDate) . ", valid until " . date("D, jS \\of F, Y", $endDate); /* Now build the query with the values generated above */ /* job_id */ $values = "NULL"; //AUTO_INCREMENT field /* job_title */ $values .= ", '{$jobTitle}'"; /* job_description */ $values .= ", '{$jobDescription}'"; /* work_type_id */ $values .= ", '{$workTypeId}'"; /* district_id */ $values .= ", '{$districtId}'"; /* subcategory_id */ $values .= ", '{$jobSubCategoryId}'"; /* salary_low */ $values .= ", '{$salaryLow}'"; /* SalaryHihg */ $values .= ", '{$salaryHigh}'"; /* start_ad_date */ /* format: '2013-05-14 00:00:00' */ $values .= ", '" . date("Y-m-d 00:00:00", $startDate) . "'"; /* end_ad_date */ $values .= ", '" . date("Y-m-d 00:00:00", $endDate) . "'"; /* Build the query */ $query = Job::insertRowQuery($values); return $query; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id, $ml = false) { if ($ml && Yii::app()->languageManager->multilang) { $model = JobCategory::model()->multilang()->findByPk($id); } else { $model = JobCategory::model()->findByPk($id); } if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
$session->message('<div class="error">' . format_lang('total_spotlight_post') . '</strong></div>'); redirect_to(BASE_URL . "employer/credits/"); die; } } else { if ($total_post <= 0) { $session->message('<div class="error">' . format_lang('total_jobpost') . '</strong></div>'); redirect_to(BASE_URL . "employer/credits/"); die; } } } //add job to database if ($job->save()) { $new_job_id = $db->insert_id(); $jobcategory = new JobCategory(); ######## GET CAT ID ############### $jobcategory->job_id = (int) $job_id; $cats = $jobcategory->get_cat_by_job_id(); foreach ($cats as $t) { $cat_added = JobCategory::make($t->category_id, $new_job_id); $cat_added->save(); } ################# JOB TYPE ################## $job_type_ns = Job2Type::find_all_type_by_jobid($job_id); foreach ($job_type_ns as $job_type) { $type_added = new Job2Type(); $type_added->fk_job_id = (int) $new_job_id; $type_added->fk_job_type_id = (int) $job_type->fk_job_type_id; $type_added->save(); }
//$type_added = Job2Type::make( $job_id, $value ); $type_added->save(); } } /** deleting job status **/ $job_s = new Job2Status(); $job_s->fk_job_id = $job_id; $job_s->delete_all_on_update(); if (is_array($_POST['txt_job_status']) && !empty($_POST['txt_job_status'])) { foreach ($_POST['txt_job_status'] as $key => $value) { $status_added = Job2Status::make($job_id, $value); $status_added->save(); } } /** deleting job status **/ $job_c = new JobCategory(); $job_c->job_id = $job_id; $job_c->delete_all_on_update(); /**adding cat */ foreach ($_POST['txt_category'] as $key => $value) { $cat_added = JobCategory::make($value, $job_id); $cat_added->save(); } if ($status_added && $cat_added && $type_added) { if (FREE_SITE == "N") { if ($spotlight == "spotlight") { $employer->update_spotlight_job_post(); } else { $employer->update_job_post(); } }
public static function getJobCategory($job) { /* job -> JobSubCategoryId => JobSubCategory row -> JobCategoryId => JobCategory row -> JobCateogryName */ /* -> is array access; => is query access */ return JobCategory::getJobCategoryName(JobCategory::getJobCategory(JobSubCategory::getJobCategoryId(JobSubCategory::getJobSubCategory(self::getJobSubCategoryId($job))))); }
protected function jsJobSubCategoryUpdate() { $output = ""; /* create the jobCategory <-> jobSubCategory connection */ $output .= "var jobSubCategoryNames = new Array();\n"; $output .= "var jobSubCategoryIds = new Array();\n"; $output .= "jobSubCategoryNames[" . static::anyJobCategoryCode . "] = [\"Select job category first\"];\n"; $output .= "jobSubCategoryIds[" . static::anyJobCategoryCode . "] = [\"" . static::anyJobSubCategoryCode . "\"];\n"; $jobCategoryList = JobCategory::getAllRows(); $jobCategoryCount = 0; while (($jobCategory = $jobCategoryList->fetch_row()) != NULL) { $jobCategoryId = JobCategory::getJobCategoryId($jobCategory); $jobSubCategoryList = JobSubCategory::getJobSubCategoryList($jobCategoryId); /* first the jobSubCategory names */ $output .= "jobSubCategoryNames[{$jobCategoryId}] = [\"Any job sub category\""; while (($jobSubCategory = $jobSubCategoryList->fetch_row()) != NULL) { $output .= ", \"" . JobSubCategory::getJobSubCategoryName($jobSubCategory) . "\""; } $output .= "];\n"; /* then the jobSubCategory Ids */ $output .= "jobSubCategoryIds[{$jobCategoryId}] = [\"" . static::anyJobSubCategoryCode . "\""; $jobSubCategoryList->data_seek(0); while (($jobSubCategory = $jobSubCategoryList->fetch_row()) != NULL) { $output .= ", \"" . JobSubCategory::getJobSubCategoryId($jobSubCategory) . "\""; } $output .= "];\n"; } /* print the jobSubCategoryUpdate() function */ /* the below code is JavaScript */ $output .= "\n"; $output .= "jobSubCategoryList = document." . static::formName . "." . static::jobSubCategoryIdFieldName . ";\n"; $output .= "function jobSubCategoryUpdate(selectedJobCategoryId){\n"; $output .= " jobSubCategoryList.options.length = 0;\n"; $output .= " for (i=0; i < jobSubCategoryNames[selectedJobCategoryId].length; i++) {\n"; $output .= " jobSubCategoryList.options[jobSubCategoryList.options.length] = new Option(jobSubCategoryNames[selectedJobCategoryId][i],jobSubCategoryIds[selectedJobCategoryId][i]);\n"; $output .= " }\n"; $output .= "}\n"; return $output; }
if (is_array($_POST['txt_job_type']) && !empty($_POST['txt_job_type'])) { foreach ($_POST['txt_job_type'] as $key => $value) { $type_added = Job2Type::make($job_id, $value); $type_added->save(); } } if (is_array($_POST['txt_job_status']) && !empty($_POST['txt_job_status'])) { foreach ($_POST['txt_job_status'] as $key => $value) { $status_added = Job2Status::make($job_id, $value); $status_added->save(); } } /**adding cat */ if (is_array($_POST['txt_category']) && !empty($_POST['txt_category'])) { foreach ($_POST['txt_category'] as $key => $value) { $cat_added = JobCategory::make($value, $job_id); $cat_added->save(); } } if ($status_added && $cat_added && $type_added) { if (FREE_SITE == "N") { if ($spotlight == "spotlight") { $employer->update_spotlight_job_post(); } else { $employer->update_job_post(); } } unset($_SESSION['add_job']); $message = "<div class='success'>" . format('success', 'job_added') . "</div>"; destroy_my_session(); } else {
protected function fieldJobCategory($jsAction = "") { $output = ""; $allJobCategories = JobCategory::getAllRows(); $output .= "<select name=\"" . static::jobCategoryIdFieldName . "\" {$jsAction}>\n"; /* The following logic will determine the selected option */ /* Chose a do...while() in order to avoid code duplication for the 'selected' option logic */ /* !!! As this is a copy+paste from the previous function, there should be a code optimisation to it */ $jobCategoryId = static::anyJobCategoryCode; $jobCategoryName = "Any job category"; $firstRow = true; do { if (!$firstRow) { $jobCategoryId = JobCategory::getJobCategoryId($row); $jobCategoryName = JobCategory::getJobCategoryName($row); } else { $firstRow = false; } if ($this->searchedJobCategoryId == $jobCategoryId) { $selected = "selected"; } else { $selected = ""; } /* here is the actual option output */ $output .= " <option {$selected} value =\"{$jobCategoryId}\">{$jobCategoryName}</option>\n"; } while (($row = $allJobCategories->fetch_row()) != NULL); $output .= "</select>\n"; return $output; }
public function deleteJobCategory() { $id = Input::get('id'); JobCategory::where('id', '=', $id)->delete(); }
} $i++; } $smarty->assign('cat', $cat); $html_title = SITE_NAME . " - " . format_lang('page_title', 'category'); } $smarty->assign('lang', $lang); $smarty->assign('message', $message); $smarty->assign('rendered_page', $smarty->fetch('category.tpl')); break; case "job_by_category": $cat_id = $category_name = $category_url[1]; $category = Category::find_by_var_name($category_name); if ($category) { $id = $category->id; $jobcategory = new JobCategory(); $num_rows = sizeof($jobcategory->list_job_by_cat_search_total($id)); //$page = !empty($_GET['page']) ? (int)$_GET['page'] : 1; $page_no = !empty($category_url[2]) ? (int) $category_url[2] : 1; $per_page = JOBS_PER_SEARCH <= $num_rows ? JOBS_PER_SEARCH : $num_rows; $per_page = $per_page == 0 ? 1 : $per_page; $total_count = $num_rows; $smarty->assign('total_count', $total_count); $smarty->assign('page', $page_no); $pagination = new Pagination($page_no, $per_page, $total_count); $smarty->assign('previous_page', $pagination->previous_page()); $smarty->assign('has_previous_page', $pagination->has_previous_page()); $smarty->assign('total_pages', $pagination->total_pages()); $smarty->assign('has_next_page', $pagination->has_next_page()); $smarty->assign('next_page', $pagination->next_page()); $offset = $pagination->offset();
public function getDepartment($id) { $sql = "SELECT * FROM departments WHERE id = ?"; $department = DB::select($sql, array($id)); $programs = Course::where('dept_id', '=', $id)->get(); $job_categories = JobCategory::all(); return View::make('admin.department')->with('department', $department)->with('programs', $programs)->with('job_categories', $job_categories); }
/** * Open Job Search * * @param string $catId */ public function anySearch($catId = null) { $categories = array(); if (Input::has("q") && trim(Input::get("q")) != "") { $q = strtolower(Input::get("q")); $foundCategories = JobCategory::whereRaw("LOWER(keywords) LIKE '%{$q}%' OR Lower(name) LIKE '%{$q}%'")->lists("id"); $categories = array_merge($categories, $foundCategories); } else { if (Input::has("catId") && intval(Input::get("catId")) > 0) { $catId = intval(Input::get("catId")); $categories[] = $catId; } } $user = Sentry::getUser(); $student = StudentInfo::findOrFail($user->id); $studentAddress = $student->primaryAddress; if ($studentAddress == null) { $studentAddress = $student->primaryAddress; } // $categories=$student->studentJobPreferences->lists("id"); $orWhereQ = array(); if (count($categories) > 0) { $orWhereQ[] = '`jobs`.`job_category_id` IN (' . implode(",", $categories) . ')'; } if (isset($q)) { $subWhereTitle = array(); $subWhereDescript = array(); if (strpos($q, ' ') > 0) { foreach (explode(' ', $q) as $r) { $subWhereTitle[] = "LOWER(`jobs`.`job_title`) LIKE '%" . $r . "%'"; $subWhereDescript[] = "LOWER(`jobs`.`job_description`) LIKE '%" . $r . "%'"; } $orWhereQ[] = "(" . implode(" AND ", $subWhereTitle) . ")"; $orWhereQ[] = "(" . implode(" AND ", $subWhereDescript) . ")"; } else { $orWhereQ[] = "LOWER(`jobs`.`job_title`) LIKE '%" . $q . "%'"; $orWhereQ[] = "LOWER(`jobs`.`job_description`) LIKE '%" . $q . "%'"; } } if (count($orWhereQ) > 0) { $jobs = Job::whereJobStatusId(JobStatus::$OPEN)->where("jobs.start_date", ">=", date("Y-m-d"))->whereRaw('(' . implode(" OR ", $orWhereQ) . ")")->select("jobs.*", Address::distanceSelectStatement($studentAddress->latitude, $studentAddress->longitude, 'distance', 'jobs'))->orderBy('jobs.start_date', 'asc')->having("distance", "<=", $student->studentProfile->preferred_job_radius)->get(); } else { $jobs = Job::whereJobStatusId(JobStatus::$OPEN)->where("jobs.start_date", ">=", date("Y-m-d"))->select("jobs.*", Address::distanceSelectStatement($studentAddress->latitude, $studentAddress->longitude, 'distance', 'jobs'))->orderBy('jobs.start_date', 'asc')->having("distance", "<=", $student->studentProfile->preferred_job_radius)->get(); } $student->load('userCertifications'); return View::make("jobs.search", compact("jobs", "student")); }
<?php /** cat */ $category_url = return_url(); $current_category = !empty($category_url[1]) ? $category_url[1] : 0; $job_by_cats = JobCategory::top_ten_cat($current_category); if ($job_by_cats) { $categorys = array(); $i = 0; foreach ($job_by_cats as $job_by_cat) { $job_id = $job_by_cat->job_id; $cat_id = $job_by_cat->category_id; $total_jobs = JobCategory::get_total_job_by_cat($cat_id); if (Job::find_active_job_by_id($job_id)) { $cat_name = Category::find_by_id($cat_id); /**check length of text */ $cat_names = strlen($cat_name->cat_name) > 25 ? substr($cat_name->cat_name, 0, 25) . " ... " : $cat_name->cat_name; $categorys[$i]['var_name'] = $cat_name->var_name; $categorys[$i]['category_name'] = $cat_names; $categorys[$i]['f_category_name'] = $cat_name->cat_name; $categorys[$i]['total_num'] = $total_jobs; $i++; } } $smarty->assign('job_by_cats', $categorys); $smarty->assign('job_by_categorys', $smarty->fetch('job_by_top_categorys.tpl')); }
?> <?php echo $form->error($model, 'title' . $suffix); ?> </div> <?php } ?> <div class="row"> <?php echo $form->labelEx($model, 'category_id'); ?> <?php echo $form->dropDownList($model, 'category_id', CHtml::listData(JobCategory::model()->findAll(array('order' => 'name ASC')), 'id', 'name'), array('empty' => '')); ?> <?php echo $form->error($model, 'category_id'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'type'); ?> <?php echo $form->dropDownList($model, 'type', array(1 => Yii::t('jobModule.admin', 'Permanent'), 2 => Yii::t('jobModule.admin', 'Temps partiel'), 3 => Yii::t('jobModule.admin', 'Saisonnier'), 4 => 'Banque de candidatures'), array('empty' => '')); ?> <?php echo $form->error($model, 'type');
/** * Save Job category * @param $request * @return unknown_type */ public function executeSaveJobCategory(sfWebRequest $request) { if ($request->isMethod('post')) { $jobService = new JobService(); $jobCategory = new JobCategory(); $jobCategory->setEecDesc($request->getParameter('txtName')); $jobService->saveJobCategory($jobCategory); $this->setMessage('SUCCESS', array(TopLevelMessages::SAVE_SUCCESS)); $this->redirect('admin/listJobCategory'); } }