public function getInitData($req)
 {
     $data = array();
     $employees = new Employee();
     $data['numberOfEmployees'] = $employees->Count("1 = 1");
     $company = new CompanyStructure();
     $data['numberOfCompanyStuctures'] = $company->Count("1 = 1");
     $user = new User();
     $data['numberOfUsers'] = $user->Count("1 = 1");
     $project = new Project();
     $data['numberOfProjects'] = $project->Count("status = 'Active'");
     $attendance = new Attendance();
     $data['numberOfAttendanceLastWeek'] = $attendance->Count("in_time > '" . date("Y-m-d H:i:s", strtotime("-1 week")) . "'");
     if (empty($data['numberOfAttendanceLastWeek'])) {
         $data['numberOfAttendanceLastWeek'] = 0;
     }
     $empLeave = new EmployeeLeave();
     $data['numberOfLeaves'] = $empLeave->Count("date_start > '" . date("Y-m-d") . "'");
     $timeEntry = new EmployeeTimeEntry();
     $data['numberOfAttendanceLastWeek'] = $timeEntry->Count("in_time > '" . date("Y-m-d H:i:s", strtotime("-1 week")) . "'");
     $candidate = new Candidate();
     $data['numberOfCandidates'] = $candidate->Count("1 = 1");
     $job = new Job();
     $data['numberOfJobs'] = $job->Count("status = 'Active'");
     $course = new Course();
     $data['numberOfCourses'] = $course->Count("1 = 1");
     return new IceResponse(IceResponse::SUCCESS, $data);
 }
Пример #2
0
 function save($object = '', $related_field = '')
 {
     if (!$this->exists()) {
         $o = new Candidate();
         $o->select_max('position');
         $o->get();
         if (count($o->all) != 0) {
             $max = $o->position + 1;
             $this->position = $max;
         } else {
             $this->postion = 1;
         }
     }
     return parent::save($object, $related_field);
 }
Пример #3
0
 public function CurrentMemberHasAcceoted()
 {
     $CurrentUserCandidate = Candidate::get()->filter(array('ElectionID' => $this->ID, 'MemberID' => Member::currentUser()->ID))->first();
     if ($CurrentUserCandidate) {
         return $CurrentUserCandidate->HasAcceptedNomination;
     }
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $this->info('Iniciando a requisição para o webservice');
     $this->info('Carregando a lista de estados');
     $estados = $this->makeRequest('estados');
     $this->info('Foram encontrados ' . count($estados) . ' estados');
     $this->info('Carregando a lista de cargos');
     $cargos = CandidateType::all()->lists('id', 'type');
     $this->info('Foram encontrados ' . count($cargos) . ' cargos');
     $this->info('Carregando a lista de partidos');
     $partidos = Party::all()->lists('id', 'abbreviation');
     $this->info('Foram encontrados ' . count($partidos) . ' partidos');
     foreach ($estados as $estado_id => $estado) {
         $this->info("Carregando os candidatos de {$estado->sigla} ({$estado_id}/" . count($estado) . ")");
         foreach ($cargos as $cargo_nome => $cargo_id) {
             $this->info('- Procurando por ' . $cargo_nome);
             $candidatos = $this->makeRequest('candidatos', ['estado' => $estado->sigla, 'cargo' => $cargo_id]);
             foreach ($candidatos as $candidato) {
                 $candidate = Candidate::where('full_name', $candidato->nome)->first();
                 if (!$candidate) {
                     $this->info('-- Processando ' . $candidato->nome . '/' . $candidato->apelido);
                     $picture_hash = Str::random(90) . ".jpg";
                     file_put_contents(app_path() . '/../www/uploads/' . $picture_hash, file_get_contents($candidato->foto));
                     Candidate::create(['party_id' => $partidos[$candidato->partido], 'candidate_type_id' => $cargos[ucfirst(strtolower(str_replace('º', '', (string) $candidato->cargo)))], 'nickname' => $candidato->apelido, 'full_name' => $candidato->nome, 'picture' => $picture_hash]);
                 }
             }
             //$this->info('Foram encontrados ' . count($candidatos) . ' candidatos');
         }
     }
 }
Пример #5
0
/**
 * Adds the missing instruments based on the visit_label
 *
 * @param Array  $result      containing visit_label info
 * @param String $visit_label The name of the visit
 *
 * @return NULL
 */
function populateVisitLabel($result, $visit_label)
{
    global $argv, $confirm;
    // create a new battery object && new battery
    $battery = new NDB_BVL_Battery();
    // select a specific time point (sessionID) for the battery
    $battery->selectBattery($result['ID']);
    $timePoint = TimePoint::singleton($result['ID']);
    $DB = Database::singleton();
    $candidate = Candidate::singleton($result['CandID']);
    $result_firstVisit = $candidate->getFirstVisit();
    $isFirstVisit = false;
    //adding check for first visit
    if ($result_firstVisit == $visit_label) {
        $isFirstVisit = true;
    }
    //To assign missing instruments to all sessions, sent to DCC or not.
    $defined_battery = $battery->lookupBattery($battery->age, $result['subprojectID'], $timePoint->getCurrentStage(), $visit_label, $timePoint->getCenterID(), $isFirstVisit);
    $actual_battery = $battery->getBattery($timePoint->getCurrentStage(), $result['subprojectID'], $visit_label);
    $diff = array_diff($defined_battery, $actual_battery);
    if (!empty($diff)) {
        echo "\n CandID: " . $timePoint->getCandID() . "  Visit Label:  " . $timePoint->getVisitLabel() . "\nMissing Instruments:\n";
        print_r($diff);
    }
    if ($confirm === true) {
        foreach ($diff as $test_name) {
            $battery->addInstrument($test_name);
        }
    }
    unset($battery);
    unset($timePoint);
}
Пример #6
0
 public function testRetrieveCandidate()
 {
     $candidate = self::createTestCandidate();
     $retrieved_candidate = Candidate::retrieve($candidate->id);
     foreach (self::$test_candidate as $key => $value) {
         $this->assertSame($retrieved_candidate->{$key}, $value);
     }
 }
 public function getInitData($req)
 {
     $data = array();
     $emp = new Employee();
     $data['numberOfEmployees'] = $emp->Count("status = 'Active' and supervisor = ?", array($this->getCurrentProfileId()));
     $data['lastTimeSheetHours'] = $this->getLastTimeSheetHours($req)->getData();
     $data['activeProjects'] = $this->getEmployeeActiveProjects($req)->getData();
     $data['pendingLeaves'] = $this->getPendingLeaves($req)->getData();
     $candidate = new Candidate();
     $data['numberOfCandidates'] = $candidate->Count("1 = 1");
     $job = new Job();
     $data['numberOfJobs'] = $job->Count("status = 'Active'");
     $attendance = new Attendance();
     $data['numberOfAttendanceLastWeek'] = $attendance->Count("in_time > '" . date("Y-m-d H:i:s", strtotime("-1 week")) . "'");
     $course = new Course();
     $data['numberOfCourses'] = $course->Count("1 = 1");
     return new IceResponse(IceResponse::SUCCESS, $data);
 }
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 80) as $index) {
         $fullName = $faker->name;
         $user = User::create(['full_name' => $fullName, 'email' => $faker->email, 'password' => \Hash::make(123456), 'type' => 'candidate']);
         Candidate::create(['id' => $user->id, 'website_url' => $faker->url, 'description' => $faker->text(200), 'job_type' => $faker->randomElement(['full', 'partial', 'freelance']), 'category_id' => $faker->randomElement([1, 2, 3]), 'available' => true, 'slug' => \Str::slug($fullName)]);
     }
 }
 public function delete($candidate_id)
 {
     try {
         $candidate = Candidate::findOrFail($candidate_id);
         $candidate->delete();
         return $this->respondWithArray(['success' => true, 'message' => 'Candidate deleted successfully']);
     } catch (ModelNotFoundException $e) {
         return $this->setStatusCode(404)->respondWithError('Candidate with ID ' . $candidate_id . ' not found', 404);
     }
 }
Пример #10
0
 public function doRestList()
 {
     $criteria = new CDbCriteria(array('condition' => 't.user_id = ' . $this->plainFilter['user_id']));
     if (!empty($this->plainFilter['name'])) {
         $criteria->mergeWith(array('condition' => 'election.name LIKE :electionName', 'params' => array(':electionName' => '%' . $this->plainFilter['name'] . '%')));
     }
     if (!empty($this->plainFilter['status'])) {
         $criteria->mergeWith(Candidate::getCriteriaWithStatusOnly($this->plainFilter['status']));
     }
     $results = $this->getModel()->with($this->nestedRelations)->limit($this->restLimit)->offset($this->restOffset)->findAll($criteria);
     $this->outputHelper('Records Retrieved Successfully', $results, $this->getModel()->with($this->nestedRelations)->count($criteria));
 }
Пример #11
0
 public static function sendReset($candidate_id)
 {
     // Generate activation code
     $code = str_random(25);
     $c = Candidate::find($candidate_id);
     $c->password_reset_code = $code;
     $c->save();
     $data = [];
     $data['candidate'] = $c;
     // Send activation email - Just in case they missed it when registering
     Mail::send('emails.candidate.reset', $data, function ($message) use($c) {
         $message->to($c->email, $c->name . ' ' . $c->surname)->subject('KDC - Reset your password');
     });
 }
 public function getVoterVoteNext($postid)
 {
     $post = Post::where('id', '>', $postid)->where('Active', '=', TRUE);
     if ($post->count()) {
         $post = $post->first();
         View::share('post', $post);
         //get the candidates vieing fot the post
         $candidates = Candidate::where('Posts_Id', '=', $post->id)->get();
         View::share('candidates', $candidates);
         return View::make('voter.voter-vote-next');
     } else {
         return Redirect::route('voter-home-get')->with('globalsuccess', 'Thanks for Voting');
     }
 }
Пример #13
0
 public function filterCheckExists($filterChain)
 {
     $data = $this->data();
     $candidate = Candidate::model()->with($this->nestedModels)->findByAttributes(array('user_id' => (int) $data['user_id'], 'election_id' => (int) $data['election_id']));
     if ($candidate) {
         if ($candidate->user_id == Yii::app()->user->id) {
             switch ($candidate->status) {
                 case Candidate::STATUS_REGISTERED:
                     $message = 'You have been already registered as candidate';
                     break;
                 case Candidate::STATUS_INVITED:
                     $message = 'Election administrator has already invited you ' . 'to become candidate. Please confirm your intention at ' . '<a href="' . Yii::app()->createAbsoluteUrl('userPage/nominations', array('id' => Yii::app()->user->id)) . '">nominations</a> page.';
                     break;
                 default:
                     $message = 'You have already applied to become candidate';
             }
         } else {
             $message = 'Candidate has been already created';
         }
         $this->renderJson(array('success' => true, 'status' => 'exists', 'message' => Yii::t('aes', $message), 'data' => array('totalCount' => 1, 'models' => $this->allToArray(array($candidate)))));
         return true;
     }
     $filterChain->run();
 }
Пример #14
0
 function listAll($offset = 0, $limit = 30)
 {
     $candidates = new Candidate();
     $candidates->order_by('position', 'desc');
     $searchKey = "";
     if ($_SERVER['METHOD_REQUEST'] == 'GET') {
     } else {
         $searchKey = $this->input->post("search_name");
         $candidates->distinct();
         $candidates->group_start();
         $candidates->like('lastname', $searchKey);
         $candidates->group_end();
     }
     $candidates->get_paged($offset, $limit, TRUE);
     setPagination($this->admin . 'candidates/listAll/', $candidates->paged->total_rows, $limit, 4);
     $dis['base_url'] = base_url();
     $dis['view'] = 'candidate/list';
     $dis['candidates'] = $candidates;
     $dis['searchKey'] = $searchKey;
     $dis['menu_active'] = "Ứng viên";
     $dis['title_table'] = "Trang hiện tại:" . $candidates->paged->current_page . '/' . $candidates->paged->total_pages;
     $dis['title'] = "Danh sách 'Ứng viên'";
     $this->viewadmin($dis);
 }
Пример #15
0
 function login()
 {
     $username = $this->input->post('username');
     $password = md5($this->input->post('password'));
     $o = new Candidate();
     $o->where(array('username' => $username, 'password' => $password));
     $o->get_iterated();
     if ($o->result_count() == 0) {
     } else {
     }
 }
Пример #16
0
        }
    }
    // Used for CSS for a specific instrument.
    if (file_exists($paths['base'] . "project/instruments/{$TestName}.css")) {
        if (strpos($_SERVER['REQUEST_URI'], "main.php") === false) {
            $tpl_data['test_name_css'] = "css/instruments/{$TestName}.css";
        } else {
            $tpl_data['test_name_css'] = "GetCSS.php?Instrument={$TestName}";
        }
    }
}
//--------------------------------------------------
// get candidate data
if (!empty($_REQUEST['candID'])) {
    try {
        $candidate =& Candidate::singleton($_REQUEST['candID']);
        $tpl_data['candidate'] = $candidate->getData();
    } catch (Exception $e) {
        $tpl_data['error_message'][] = $e->getMessage();
    }
}
// get time point data
if (!empty($_REQUEST['sessionID'])) {
    try {
        $timePoint =& TimePoint::singleton($_REQUEST['sessionID']);
        if ($config->getSetting("SupplementalSessionStatus")) {
            $tpl_data['SupplementalSessionStatuses'] = true;
        }
        $tpl_data['timePoint'] = $timePoint->getData();
    } catch (Exception $e) {
        $tpl_data['error_message'][] = "TimePoint Error (" . $_REQUEST['sessionID'] . "): " . $e->getMessage();
function fixDate($candID, $dateType, $newDate, $sessionID = null)
{
    // check the user $_ENV['USER']
    $user =& User::singleton(getenv('USER'));
    if ($user->getUsername() == null) {
        return PEAR::raiseError("Error: Database user named " . getenv('USER') . " does not exist. Please create and then retry script\n");
    }
    if (PEAR::isError($user)) {
        return "Error, failed to create User object for (" . getenv('USER') . "):" . $user->getMessage() . " \n";
    }
    $db =& Database::singleton();
    if (PEAR::isError($db)) {
        return PEAR::raiseError("Failed to create database object:\n" . $db->getMessage());
    }
    // check the args
    if (empty($dateType) || !in_array($dateType, array('dob', 'edc', 'screening', 'visit')) || empty($newDate) || in_array($dateType, array('screening', 'visit')) && empty($sessionID)) {
        return PEAR::raiseError("Please pass a valid set of arguments\n");
    }
    // check the date format (redundant)
    $dateArray = explode('-', $newDate);
    if (!is_array($dateArray) || !checkdate($dateArray[1], $dateArray[2], $dateArray[0])) {
        return PEAR::raiseError("Invalid Date! Please use the following format: YYYY-MM-DD \n");
    }
    unset($dateArray);
    // candidate object - needed to get the dob/edc
    $candidate =& Candidate::singleton($candID);
    if (PEAR::isError($candidate)) {
        return PEAR::raiseError("Error, failed to create candidate object:\n" . $candidate->getMessage());
    }
    // fixing DOB or EDC
    if (in_array($dateType, array('dob', 'edc'))) {
        // set and where arrays
        $setArray = array($dateType => $newDate);
        $whereArray = array('CandID' => $candID);
        // update candidate table record
        $success = $db->update('candidate', $setArray, $whereArray);
        if (PEAR::isError($success)) {
            return PEAR::raiseError("Failed to update the {$dateType}: " . $success->getMessage());
        }
        /*
         * add Feedback
         */
        // feedback object
        $feedback =& NDB_BVL_Feedback::singleton($user->getUsername(), $candID);
        if (PEAR::isError($feedback)) {
            return PEAR::raiseError("Failed to create feedback object: " . $feedback->getMessage());
        }
        // add the new thread
        $success = $feedback->createThread('profile', '5', "The date of {$dateType} has been changed to {$newDate}.", 'N');
        if (PEAR::isError($success)) {
            return PEAR::raiseError("Failed to create feedback: " . $success->getMessage());
        }
        // log the change
        fwrite(STDERR, "Updated {$dateType} to: {$newDate}, for candidate {$candID}. Check the record in the DB! \n");
    } else {
        // fixing Date_screening or Date_visit
        // create timepoint object
        $timePoint =& TimePoint::singleton($sessionID);
        if (PEAR::isError($timePoint)) {
            return PEAR::raiseError("Failed to create timepoint object: " . $timePoint->getMessage());
        }
        // check if the timepoint is started before attempting to make changes to it
        if ($timePoint->getCurrentStage() == 'Not Started') {
            return PEAR::raiseError("Error: Cannot perform screening/visit date fixes on the non-started timepoints!");
        }
        // get the stage statuses
        $screeningStage = $timePoint->getScreeningStatus();
        $visitStage = $timePoint->getVisitStatus();
        // make sure that the stage to fix is started
        if ($dateType == 'visit' && empty($visitStage) || $dateType == 'screening' && empty($screeningStage)) {
            return PEAR::raiseError("Error: failed to retrieve the date of {$dateType} (sessionID: {$sessionID}) b/c that stage was not started!");
        }
        // set and where arrays for the update
        $setArray = array("Date_" . $dateType => $newDate);
        $whereArray = array("ID" => $sessionID);
        // update session table record
        $success = $db->update('session', $setArray, $whereArray);
        if (PEAR::isError($success)) {
            return PEAR::raiseError("Failed to update the {$dateType} stage date to {$newDate}: " . $success->getMessage());
        }
        /*
         * add Feedback
         */
        // feedback object
        $feedback =& NDB_BVL_Feedback::singleton($user->getUsername(), null, $sessionID);
        if (PEAR::isError($feedback)) {
            return PEAR::raiseError("Failed to create feedback object: " . $feedback->getMessage());
        }
        // add the new thread
        $success = $feedback->createThread('session', '5', "The date of {$dateType} has been changed to {$newDate}.", 'N');
        if (PEAR::isError($success)) {
            return PEAR::raiseError("Failed to create feedback: " . $success->getMessage());
        }
        // log the change
        fwrite(STDERR, "Updated date of {$dateType} to {$newDate}, for candidate {$candID}, timepoint {$sessionID}. Check the DB record!\n");
    }
    // end if
    return;
}
Пример #18
0
 public function getUsersMandates($userId)
 {
     $candidates = Candidate::model()->findAllByAttributes(array('user_id' => (int) $userId));
     $cand_ids = array();
     foreach ($candidates as $candidate) {
         $cand_ids[] = $candidate->id;
     }
     return $this->findAllByAttributes(array('candidate_id' => $cand_ids));
 }
Пример #19
0
 /**
  * @return ICandidate|null
  */
 public function getCurrentCandidate()
 {
     $res = null;
     $election = ElectionSystem::get()->first();
     if ($election && $election->CurrentElectionID != 0) {
         $current_election = $election->CurrentElection();
         if (!is_null($current_election)) {
             $candidate = Candidate::get()->filter(array('MemberID' => $this->getIdentifier(), 'ElectionID' => $current_election->ID))->first();
             $res = $candidate;
             if (!is_null($candidate)) {
                 UnitOfWork::getInstance()->setToCache($candidate);
                 UnitOfWork::getInstance()->scheduleForUpdate($candidate);
             }
         }
     }
     return $res;
 }
Пример #20
0
<?php

header('refresh: 3; url = ../index.php');
//header('Location: ../index.php');
session_start();
require_once "../libraries/classes/config.php";
require_once "../libraries/classes/clsSchoolYear.php";
require_once "../libraries/classes/clsCandidate.php";
require_once "../libraries/classes/clsPosition.php";
require_once "../libraries/classes/clsVoter.php";
$studentID = $_SESSION["studentID"];
$programID = $_SESSION["programID"];
$voter = new Voter();
$schoolYear = new SchoolYear();
$currentSY = $schoolYear->getCurrentSchoolYear();
$candidate = new Candidate();
$ssgCandidate = $candidate->getSSGCandidates();
$programCandidate = $candidate->getProgramCandidates($programID);
$position = new Position();
$ssgPosition = $position->getPosition(1);
$programPosition = $position->getPosition(2);
$ctr = 0;
/*This line displays list of voted candidates from the SSG executive positions*/
//echo "-----------------------------------------------SSG Executive-----------------------------------------------<br>";
for ($pos_y = 0; $pos_y < count($position->getPosition(1)); $pos_y++) {
    if (isset($_POST[$ssgPosition[$pos_y]["posID"]])) {
        for ($cand_x = 0; $cand_x < count($candidate->getSSGCandidates()); $cand_x++) {
            if ($_POST[$ssgPosition[$pos_y]["posID"]] == $ssgCandidate[$cand_x]["candID"]) {
                /*
                echo $ssgPosition[$pos_y]["posName"].": ";
                echo $ssgCandidate[$cand_x]["lname"].", ".$ssgCandidate[$cand_x]["fname"];
Пример #21
0
 public function clean($vote_id)
 {
     Candidate::where('vote_id', '=', $vote_id)->delete();
     $arr = ['status' => 'success', 'msg' => '完成事項已刪除!'];
     return Response::json($arr);
 }
Пример #22
0
 public function actionCandidates($id)
 {
     $model = $this->getModel($id);
     $this->layout = '//layouts/election';
     $this->election = $model;
     $candidate = false;
     if (Yii::app()->user->id) {
         $candidate = Candidate::model()->findByAttributes(array('user_id' => Yii::app()->user->id, 'election_id' => $model->id));
     }
     $this->render('candidates', array('model' => $model, 'candidate' => $candidate));
 }
				<td><br>投票已完成...<br><a href="{{ url('/vote_result_show', array($vote->id), false) }}"><strong>{{$vote->vote_title}}<br>now:{{$time_now}}<br>start:{{$vote->start_at}}end:{{$vote->end_at}}</strong></a><br>
				</td>
			@elseif ( $time_now > $vote->start_at)
				<td ><br>投票進行中...
					<a href="{{ url('/account_data_show', array($vote->id), false) }}"><strong>籤票內容</strong></a>

					<br><a href="{{ url('/vote_result_show', array($vote->id), false) }}"><strong>{{$vote->vote_title}}<br>now:{{$time_now}}<br>start:{{$vote->start_at}}end:{{$vote->end_at}}</strong></a><br>
					<br><strong>{{$vote->vote_title}}<br>now:{{$time_now}}<br>start:{{$vote->start_at}}end:{{$vote->end_at}}</strong><br>
				</td>


			@else
				<td ><br>尚未投票...<br><strong>{{$vote->vote_title}}<br>now:{{$time_now}}<br>start:{{$vote->start_at}}end:{{$vote->end_at}}</strong>

<?php 
$candidates = Candidate::where('vote_id', '=', $vote->id)->get();
$can_id = null;
if (count($candidates) != 0) {
    $can_id = $candidates[0]->id;
}
?>
			<li class="list-group-item">
				<table>
				<tr>
				<td >
				@if ($ary[1][$vote->id]<>'沒有資料')

				<!-- {{$ary[1][$vote->id]}} -->
				<a href="{{ url('/candidate_data_show', array($vote->id), false) }}"><strong>瀏覽選項內容</strong></a>
				
				
Пример #24
0
    // $account->vote_id;
    // $account->finish_at;
    $vote = Vote::find(49);
    $account = new Account();
    $account->username = '******';
    $account->vote_id = 49;
    $account->finish_at = "0000-00-00 00:00:00";
    $account->vote()->associate($vote);
    $account->save();
    $account2 = new Account();
    $account2->username = '******';
    $account2->vote_id = 2;
    $account2->finish_at = "0000-00-00 00:00:00";
    $account2->vote()->associate($vote);
    $account2->save();
    $candidate = new Candidate();
    $candidate->cname = 'Naruto Uzumaki';
    $candidate->job_title = 'yy';
    $candidate->sex = '男';
    $candidate->vote_id = 49;
    $candidate->total_count = 2;
    $candidate->save();
    $candidate->accounts()->save($account);
    $candidate->accounts()->save($account2);
    // $account = Account::find(1);
    // $candidate = Candidate::find(10);
    // $candidate->accounts()->detach();
    // // return $candidate->accounts;
    // return Candidate::with('accounts')->find($candidate->id);
});
Route::get('/test2', function () {
 public function identifyDetails($text, $lastCandidateID, $cv, $connect, $s, $sessionID)
 {
     $patternEmail = '/[A-Za-z0-9!#$%&\'\\=*+\\/\\?^_`{|}\\.~-]+@[A-Za-z0-9!#$%&\'\\=*+\\/\\?^_`{|}\\.~-]+\\.(?:[A-Za-z]{4}|lk|com|org|net|edu|biz|info|asia)/';
     $patternNIC = '/[0-9]{9}+(V|v)/';
     $patternDateOfBirth1 = '/([1|2][0-9\\.\\/-]{4}[0|1][0-9][\\.\\/-][0|1|2|3][0-9])/';
     $patternDateOfBirth2 = '/([0|1|2|3][0-9][\\.\\/-][0|1|2|3][0-9][\\.\\/-][1|2][0-9]{3})/';
     $patternContactNo1 = '/[0][0-9]{9}/';
     $patternContactNo2 = '/[0][0-9]{2}[-" "][0-9]{7}/';
     $patternContactNo3 = '/[+|0][0-9]{11}/';
     preg_match_all($patternNIC, $text, $nicList);
     preg_match_all($patternEmail, $text, $emailList);
     preg_match_all($patternDateOfBirth1, $text, $dobList1);
     preg_match_all($patternDateOfBirth2, $text, $dobList2);
     preg_match_all($patternContactNo1, $text, $contactList1);
     /*** new Candidate Object is created***/
     /*and putting extracted details to that object's attributes*/
     if ($lastCandidateID == null) {
         $newCandidate = new Candidate("C001");
     } else {
         ++$lastCandidateID;
         $newCandidate = new Candidate("{$lastCandidateID}");
     }
     if ($nicList[0] != null) {
         $newCandidate->setNIC($nicList[0][0]);
     } else {
         /*If NIC is not extracted,cand status would be marked to unchecked*/
         $newCandidate->setCandStatus("CS003");
     }
     if ($emailList[0] != null) {
         $newCandidate->setEmail($emailList[0][0]);
     }
     $minYear = 3000;
     $minDOB = "";
     if ($dobList1[0] != null) {
         for ($i = 0; $i < sizeof($dobList1[0]); $i++) {
             $year = $dobList1[0][0][0] . $dobList1[0][0][1] . $dobList1[0][0][2] . $dobList1[0][0][3];
             if ($year <= $minYear) {
                 $minYear = $year;
                 $minDOB = $dobList1[0][$i];
             }
         }
     }
     if ($dobList2[0] != null) {
         for ($i = 0; $i < sizeof($dobList2[0]); $i++) {
             $date = $this->changeDateFormat($dobList2[0][$i]);
             if (strlen($date) == 10) {
                 $year = $date[0] . $date[1] . $date[2] . $date[3];
                 if ($year <= $minYear) {
                     $minYear = $year;
                     $minDOB = $date;
                 }
             }
         }
     }
     if (date("Y") - $minYear <= 15) {
         $minDOB = "";
     }
     $newCandidate->setDateOfBirth($minDOB);
     if ($contactList1[0] != null) {
         $newCandidate->setContactNo($contactList1[0][0]);
     } else {
         preg_match_all($patternContactNo2, $text, $contactList2);
         if ($contactList2[0] != null) {
             $contact = $this->changeContactNoFormat($contactList2[0][0]);
             $newCandidate->setContactNo($contact);
         } else {
             preg_match_all($patternContactNo3, $text, $contactList3);
             if ($contactList3[0] != null) {
                 $contact = $this->changeContactNoFormat($contactList3[0][0]);
                 $newCandidate->setContactNo($contact);
             }
         }
     }
     if ($nicList[0] != null) {
         if (sizeof($nicList[0]) == 1) {
             $s->checkInDB($nicList[0][0], $cv, $newCandidate, $connect, $sessionID);
         }
     } else {
         $matchToFlag = $s->needToFlag($cv, $newCandidate, $connect, $sessionID);
     }
     return $newCandidate;
 }
Пример #26
0
 /**
  * Testable wrapper for Candidate::createNew
  *
  * @param string $DoB    Date of birth of the candidate
  * @param string $edc    EDC of the candidate
  * @param string $gender Gender of the candidate to be created
  * @param string $PSCID  PSCID of the candidate to be created
  *
  * @return none
  */
 public function createNew($DoB, $edc, $gender, $PSCID)
 {
     $user = \User::singleton();
     \Candidate::createNew($user->getCenterID(), $DoB, $edc, $gender, $PSCID);
 }
Пример #27
0
 function profile()
 {
     // Grab member ID from the URL
     $MemberID = Convert::raw2sql($this->request->param("ID"));
     // Check to see if the ID is numeric
     if (is_numeric($MemberID)) {
         // Check to make sure there's a member with the current id
         if ($Profile = $this->findMember($MemberID)) {
             $CurrentElection = $this->CurrentElection();
             if ($CurrentElection) {
                 $Candidate = Candidate::get()->filter(array('MemberID' => $MemberID, 'ElectionID' => $CurrentElection->ID))->first();
                 $data["Candidate"] = $Candidate;
                 $data["CurrentElection"] = $CurrentElection;
             }
             $data["Profile"] = $Profile;
             // A member is looking at own profile
             if (Member::currentUserID() == $MemberID) {
                 $data["OwnProfile"] = true;
             }
             //return our $Data to use on the page
             return $this->Customise($data);
         }
     }
     return $this->httpError(404, 'Sorry that member could not be found');
 }
Пример #28
0
 public function getPaginateCandidatesAttribute()
 {
     return Candidate::where('category_id', $this->id)->paginate();
 }
Пример #29
0
 public function testRevokeVoteFailsWithMessageBecauseOfTimeout()
 {
     $this->login("*****@*****.**", "qwerty");
     $this->open('election/candidates/1');
     $this->waitForPageToLoad("30000");
     $voteBox = "css=div.checkbox.vote";
     $this->waitForElementPresent($voteBox);
     //first vote
     $this->click($voteBox);
     $this->waitForElementContainsText($voteBox . ' span.value', '✓');
     //Simulating that timer is expired
     $candidate = Candidate::model()->findByAttributes(array('electoral_list_pos' => 1, 'election_id' => 1));
     $vote = Vote::model()->findByAttributes(array('candidate_id' => $candidate->id, 'user_id' => 1));
     $voted = new DateTime($vote->date);
     $voted->sub(new DateInterval('PT' . (Election::model()->findByPk(1)->remove_vote_time - 1) . 'M' . '54S'));
     $voted = $voted->format('Y-m-d H:i:s');
     Yii::app()->db->createCommand()->update('vote', array('date' => $voted), 'id = ' . $vote->id);
     $this->open('election/candidates/1');
     $this->sleep(7000);
     $this->click($voteBox);
     $this->assertElementPresent($errorBox = 'css=div.flash-messages div.alert-error');
     $this->assertElementContainsText($errorBox, 'Action is unavailable because of timeout');
     //check all candidates are inactive for voting
     $this->waitForCssCount($voteBox . '.inactive', 3);
 }
 public function jobAlertsPost()
 {
     // dd(Input::all());
     if (!is_null(Session::get('candidate'))) {
         $candidate = Candidate::find(Session::get('candidate')->id);
         $input = Input::all();
         // Check if there is an alert already
         $jobAlert = JobAlerts::where('candidate_id', $candidate->id)->first();
         if (is_null($jobAlert)) {
             $alert = new JobAlerts();
         } else {
             $alert = $jobAlert;
         }
         if (isset($input['active'])) {
             $active = 1;
         } else {
             $active = 0;
         }
         $alert->candidate_id = $candidate->id;
         $alert->job_type = $input['job_type_id'];
         $alert->sector_id = $input['sector_id'];
         $alert->location_id = $input['location_id'];
         $alert->salary_expectations = $input['salary'];
         $alert->keywords = $input['job_keywords'];
         $alert->skill_keywords = $input['skill_keywords'];
         $alert->active = $active;
         $alert->save();
         return Redirect::back()->withInfo('Your alert settings have been saved');
     } else {
         return Redirect::to('become-a-candidate')->with('info', 'Please login / register to view this page');
     }
 }