/** * Удаляет вакансию из БД, если нет соискателей по такой вакансии * * @return void */ public function _delete() { $Applicants = new Applicants(); $res = $Applicants->getApplicants($this->id); if ($res != false) { throw new Zend_Exception('[LS_VACANCY_HAS_APPLICANTS]'); } }
/** * Тестирование * @return void */ public function testingAction() { $objForm = new Form_Test_Testing(); $link = $this->getRequest()->getParam('link'); $objApplicantTests = new ApplicantTests(); $applicantTest = $objApplicantTests->getTest($link); if (empty($applicantTest)) { exit; } $applicantId = $applicantTest->applicant_id; $testId = $applicantTest->test_id; $applicantTestId = $applicantTest->id; $applicantScore = $applicantTest->score; $applicantPercent = $applicantTest->percent; $objTests = new Tests(); $test = $objTests->find($testId)->current()->toArray(); $testName = $test['t_name']; $testTime = $test['time']; $objApplicants = new Applicants(); $applicantName = $objApplicants->getName($applicantId); $objQuestion = new Questions(); $questions = $objQuestion->getQuestions($testId); $questions = $this->convertArr($questions, 'tq_id'); $countQuestions = count($questions); $objTestAnswers = new Answers(); $answers = $objTestAnswers->getAnswers(array_keys($questions)); $answers = $this->convertArr($answers, 'tq_id', true); // ключем $answers будет id вопроса $objForm->addElementsForm($questions, $answers); if ($this->getRequest()->isPost()) { //получаем ответы на вопросы и сохраняем if ($objForm->isValid($_POST)) { $objApplicantAnswers = new ApplicantAnswers(); $newAnswers = $this->keyReplace($objForm->getValues(), 'answer_'); foreach ($newAnswers as $answerId => $val) { if ($val) { $newAnswer = $objApplicantAnswers->createRow(array('applicant_tests_id' => $applicantTestId, 'answer_id' => $answerId)); $newAnswer->save(); } else { unset($newAnswers[$answerId]); } } $result = $this->calcTestScore($questions, $answers, $newAnswers); $applicantTest->score = $result['score']; $applicantTest->percent = $result['percent']; $applicantTest->save(); $this->view->sendTest = true; return; } } else { $this->view->testName = $testName; $this->view->applicantName = $applicantName; $this->view->time = $testTime; $this->view->score = $applicantScore; $this->view->percent = $applicantPercent; if (is_null($applicantTest->date)) { // выводим тест // $this->view->objForm = $objForm; $applicantTest->date = new Zend_Db_Expr('NOW()'); $applicantTest->save(); } else { if ($this->_authorize('test', 'view')) { // выводим результаты теста // $objApplicantAnswers = new ApplicantAnswers(); $applicantAnswers = $objApplicantAnswers->getAnswers($applicantTestId); $applicantAnswers = $this->convertArr($applicantAnswers, 'answer_id'); $questions = $this->makeQAArray($questions, $answers, $applicantAnswers); unset($answers); unset($applicantAnswers); $questionCategories = $objTests->getQuestionCategoriesListByTestId($testId); if ($questionCategories) { $questionCategories = $this->calcCategoriesScore($questions, $questionCategories); } $this->view->countQuestions = $countQuestions; $this->view->countQuestionFail = $this->countWrongAnswers($questions); $this->view->questionsAndAnswers = $questions; $this->view->questionCategories = $questionCategories; } } } }
<?php //Imports require_once 'includes/db/db_conn.php'; require_once 'includes/db/SELECT.php'; require_once 'includes/classes/Applicant.php'; $con = connect_db(); $ADK_APPLICANTS = new Applicants(); $ADK_APPLICANTS->get($con); $con->close();
/** * Изменение статуса соискателя * @return void */ public function statusAction() { if ($this->_authorize('applicants', 'status')) { $applicantId = $this->getRequest()->getParam('applicantId'); $form = new Form_Applicant_Status(); $objApplicants = new Applicants(); if ($this->getRequest()->isPost()) { if ($form->isValid($_POST)) { $objApplicant = $objApplicants->getObjectById($form->applicantId->getValue()); if ($objApplicant && $form->Status->getValue() != $objApplicant->status) { $status = $objApplicant->status; $objApplicant->status = $form->Status->getValue(); $objApplicant->save(); $comments = new Comments(); $comment = $comments->createRow(); $comment->user_id = Auth::getInstance()->getIdentity(); $comment->applicant_id = $objApplicant->id; $comment->comment = 'Applicant status changed from "' . $this->view->translate('[LS_STATUS_' . strtoupper($status) . ']') . '" to "' . $this->view->translate('[LS_STATUS_' . strtoupper($form->Status->getValue()) . ']') . '"<br>' . $form->Comment->getValue(); $comment->save(); $this->_helper->redirector('index', 'applicant'); } } } else { // выбираем из базы данные о соискателе $objApplicant = $objApplicants->getObjectById($applicantId); if ($objApplicant) { $form->populate(array('Status' => $objApplicant->status, 'applicantId' => $objApplicant->id)); } } $this->view->form = $form; } }