/** * find duplicate applicants in the same cycle * * @param Applicant $applicant * @return array */ public function findDuplicates(Applicant $applicant) { $query = $this->_em->createQuery('SELECT a FROM Jazzee\\Entity\\Applicant a WHERE a != :applicantId AND a.email = :email AND a.application IN (SELECT app FROM Jazzee\\Entity\\Application app WHERE app.cycle = :cycleId) AND a.deactivated=false'); $query->setParameter('applicantId', $applicant->getId()); $query->setParameter('cycleId', $applicant->getApplication()->getCycle()->getId()); $query->setParameter('email', $applicant->getEmail()); return $query->getResult(); }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = new Certificate(); $applicant = Applicant::model()->findByPk($id); // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model, $applicant); //$model=$this->loadModel($id); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Certificate'], $_POST['Applicant'])) { $model->attributes = $_POST['Certificate']; //$applicant->attributes=$_POST['Applicant']; //conhverting some of date into strtotime of type integer $applicant->dateofbirth = strtotime($applicant->dateofbirth); $model->residentcertdateissued = strtotime($model->residentcertdateissued); $valid = $model->validate(); //$valid = $applicant->validate() && $valid; //autogenerate the certificate here //also assign the station in certificate-> station if ($valid) { // if($applicant->save()){ $model->applicant_id = $applicant->id; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } //} } } $applicant->dateofbirth = date("Y-m-d", $applicant->dateofbirth); $model->residentcertdateissued = date("Y-m-d", $model->residentcertdateissued); $this->render('update', array('model' => $model, 'applicant' => $applicant)); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate($app_id) { if (Yii::app()->user->checkAccess($this->id . '.' . $this->action->id)) { $model = new PaymentDetail(); $applicant = Applicant::model()->findByPk($app_id); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); $allotments = $applicant->getAllotments(); if ($applicant !== null && !empty($allotments)) { $model->allotment_id = $allotments->data[0]->id; $model->applicant_id = $app_id; } else { throw new CHttpException('Please make allotment first. ' . CHtml::link('Click here to go Back', Yii::app()->user->returnUrl)); exit; } $paymentTypeOptions = PaymentType::getPaymentTypes($allotments->data[0]->category_id); if (isset($_POST['PaymentDetail'])) { $model->attributes = $_POST['PaymentDetail']; if ($model->save()) { $this->redirect(Yii::app()->user->returnUrl); } } $this->render('create', array('model' => $model, 'applicant' => $applicant, 'paymentTypeOptions' => $paymentTypeOptions)); } else { $this->accessDenied(); } }
public static function get_user_logged_in() { if (isset($_SESSION['user'])) { $user_id = $_SESSION['user']; $user = Applicant::find($user_id); return $user; } return null; }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate($app_id) { if (Yii::app()->user->checkAccess($this->id . '.' . $this->action->id)) { $model = new Allotment(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Allotment'])) { $model->attributes = $_POST['Allotment']; $model->applicant_id = $app_id; if ($model->save()) { $this->redirect(Yii::app()->user->returnUrl); } } $this->render('create', array('model' => $model, 'applicant' => Applicant::model()->findByPk($app_id))); } else { $this->accessDenied(); } }
public static function handle_login() { $params = $_POST; $user = Applicant::authenticate($params['email'], $params['password']); if (!$user) { $admin = Admin::authenticate($params['email'], $params['password']); if (!$admin) { View::make('login.html', array('error' => 'Oops! Username or password is wrong.', 'email' => $params['email'])); } else { $_SESSION['user'] = $admin->id; $_SESSION['admin'] = true; Redirect::to('/home'); } } else { $_SESSION['user'] = $user->id; $_SESSION['admin'] = false; Redirect::to('/mydegrees'); } }
public static function getApplicantOptions() { $result = array(); //lists all applicants $_applicants = Applicant::model()->findAll(); foreach ($_applicants as $applicant) { $result = $result + array($applicant['id'] => $applicant['name'] . ' S/D/o ' . $applicant['fname']); } return $result; }
<?php //Imports require_once 'db/db_conn.php'; require_once 'db/DELETE.php'; require_once 'classes/Applicant.php'; if (!isset($_POST['id']) || !is_numeric($_POST['id'])) { header('Location: ../applicants?e=i'); exit; } $con = connect_db(); $ADK_APPLICANT = new Applicant(); $ADK_APPLICANT->id = intval($_POST['id']); $ADK_APPLICANT->delete($con); $con->close(); header('Location: ../applicants');
/** * 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) { $model = Applicant::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<?php //Imports require_once 'db/db_conn.php'; require_once 'db/SELECT.php'; require_once 'db/UPDATE.php'; require_once 'classes/Applicant.php'; require_once 'classes/User.php'; require_once 'classes/Peak.php'; $con = connect_db(); $old_ADK_APPLICANT = new Applicant(); $old_ADK_APPLICANT->id = intval($_POST['id']); $old_ADK_APPLICANT->get($con); $ADK_APPLICANT = new Applicant(); $ADK_APPLICANT->populateFromUpdate(); if (!$ADK_APPLICANT->isValid()) { $con->close(); header('Location: ../editApplicant?_=' . $ADK_APPLICANT->id . '&e=' . $ADK_APPLICANT->err); exit; } if (!User::isUniqueUsername($con, $ADK_APPLICANT->username, $old_ADK_APPLICANT->username)) { $con->close(); header('Location: ../editApplicant?_=' . $ADK_APPLICANT->id . '&e=q'); exit; } $ADK_APPLICANT->sanitize(); $ADK_APPLICANT->update($con); $con->close(); header('Location: ../applicant?_=' . $ADK_APPLICANT->id);
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id, $app_id) { $model = $this->loadModel($id); if (Yii::app()->user->checkAccess($this->id . '.' . $this->action->id, array('owner' => $model->create_user))) { $applicant = Applicant::model()->findByPk($app_id); $allotment = $applicant->getAllotments(); $paymentTypes = $allotment->data[0]->category->payment_types; $paymentTypesOption = array(); foreach ($paymentTypes as $paymentType) { $paymentTypesOption = $paymentTypesOption + array($paymentType->id => $paymentType->payment_type); } // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['DueDate'])) { $model->attributes = $_POST['DueDate']; if ($model->save()) { $this->redirect(Yii::app()->user->returnUrl); } } $this->render('update', array('model' => $model, 'paymentTypesOption' => $paymentTypesOption)); } else { $this->accessDenied(); } }
$allData = $dp->getData(); if (empty($allData)) { $user = Yii::app()->getComponent('user'); $user->setFlash('error', "<strong>Not Found!</strong> <a href=\"reminders\"> Click here to go back </a>"); } $this->widget('booster.widgets.TbAlert', array('fade' => true, 'closeText' => '×', 'events' => array(), 'htmlOptions' => array(), 'userComponentId' => 'user', 'alerts' => array('success' => array('closeText' => '×'), 'info', 'warning' => array('closeText' => false), 'error' => array('closeText' => false)))); // $this->widget('ext.mPrint.mPrint', array( // 'title' => 'title', //the title of the document. Defaults to the HTML title // 'tooltip' => 'Print', //tooltip message of the print icon. Defaults to 'print' // 'text' => 'Print', //text which will appear beside the print icon. Defaults to NULL // 'element' => '.print_container', //the element to be printed. // 'exceptions' => array( //the element/s which will be ignored // '.summary', // '.search-form' // ), // 'publishCss' => false, //publish the CSS for the whole page? // //'visible' => Yii::app()->user->checkAccess('print'), //should this be visible to the current user? // 'alt' => 'print', //text which will appear if image can't be loaded // 'debug' => false, //enable the debugger to see what you will get // 'id' => 'print-div', //id of the print lin // 'htmlOptions'=>array( // 'class'=>'btn btn-primary', // ) // )); foreach ($allData as $data) { echo '<div class="print_container visible-print-block" >'; $applicant = Applicant::model()->findByPk($data['aid']); $this->renderPartial('_reminder', array('data' => $data, 'allotment' => $applicant->getAllotment(), 'reminder' => $reminder)); echo '</div>'; }
require_once 'classes/Message.php'; require_once 'classes/Peak.php'; require_once 'classes/User.php'; if (!isset($_POST['id']) || !is_numeric($_POST['id'])) { header('Location: ../applicants?_e=i'); exit; } if (!isset($_POST['corrid']) || !is_numeric($_POST['corrid'])) { header('Location: ../applicant?_=' . $_POST['id'] . '&e=c'); exit; } $ADK_APPLICANT_ID = intval($_POST['id']); $ADK_CORRESPONDENT_ID = intval($_POST['corrid']); $randomPW = randomPW(8); $con = connect_db(); $ADK_APPLICANT = new Applicant(); $ADK_APPLICANT->id = $ADK_APPLICANT_ID; $ADK_APPLICANT->get($con); $ADK_APPLICANT->delete($con); $ADK_USER = new User(); $ADK_USER->populateFromApplicant($randomPW, $ADK_APPLICANT); $ADK_USER->save($con); $ADK_HIKER = new Hiker(); $ADK_HIKER->populateFromApplicant($ADK_USER->id, $ADK_CORRESPONDENT_ID, $ADK_APPLICANT); $ADK_HIKER->save($con); foreach ($ADK_APPLICANT->peaks as $ADK_PEAK) { $ADK_HIKE = new Hike(); $ADK_HIKE->userid = $ADK_USER->id; $ADK_HIKE->save($con); $ADK_HIKE->addPeak($con, $ADK_PEAK); }
/** * @depends testCreateWithQuestionAndInterviewName */ public function testCreateWithCallback() { $param = ["mail" => "*****@*****.**", "alert" => false, "questions" => [["content" => "question 1", "readingTime" => 60, "answerTime" => 60, "number" => 1]], "lang" => "en", "deadline" => intval((microtime(true) + ApplicantTest::$oneMonth) * 1000), "callback" => "http://mycustomeurl.com/done"]; $res = Applicant::create($param); $this->assertEquals("*****@*****.**", $res->mail); $this->assertFalse($res->deleted); $this->assertCount(1, $res->questions); $this->assertEquals("http://mycustomeurl.com/done", $res->callback); Interview::delete($res->interview, array("withApplicant" => true)); $app = Applicant::findOne($res->id); $this->assertTrue($app->deleted); }
<?php //Imports require_once 'variables_site.php'; require_once 'db/db_conn.php'; require_once 'db/SELECT.php'; require_once 'db/INSERT.php'; require_once 'email.php'; require_once 'pm.php'; require_once 'classes/Applicant.php'; require_once 'classes/Message.php'; require_once 'classes/Peak.php'; require_once 'classes/User.php'; $con = connect_db(); $ADK_APPLICANT = new Applicant(); $ADK_APPLICANT->populateFromSignUp(); if (!$ADK_APPLICANT->isValid()) { $con->close(); header('Location: ../signup?e=' . $this->err); exit; } if (!User::isUniqueUsername($con, $ADK_APPLICANT->username, '')) { $con->close(); header('Location: ../signup?e=q'); exit; } $ADK_APPLICANT->sanitize(); $ADK_APPLICANT->save($con); foreach ($ADK_APPLICANT->peaks as $ADK_PEAK) { $ADK_APPLICANT->addPeak($con, $ADK_PEAK); }
<?php //Imports require_once 'includes/db/db_conn.php'; require_once 'includes/db/SELECT.php'; require_once 'includes/classes/Applicant.php'; require_once 'includes/classes/Correspondent.php'; require_once 'includes/classes/Peak.php'; if (!isset($_GET['_']) || !is_numeric($_GET['_'])) { header("Location: ./"); } $con = connect_db(); $ADK_APPLICANT = new Applicant(); $ADK_APPLICANT->id = intval($_GET['_']); $ADK_APPLICANT->get($con); if ($ADK_APPLICANT->name == '') { header("Location: ./"); } $ADK_CORRESPONDENTS = new Correspondents(); $ADK_CORRESPONDENTS->get($con); $ADK_PEAKS = new Peaks(); $ADK_PEAKS->get($con); $con->close();
$form = $this->beginWidget('booster.widgets.TbActiveForm', array('id' => 'transfer-form', 'enableAjaxValidation' => false, 'type' => 'horizontal')); ?> <p class="help-block">Fields with <span class="required">*</span> are required.</p> <?php echo $form->errorSummary($model); ?> <?php echo $form->datePickerGroup($model, 'transfer_date', array('widgetOptions' => array('options' => array('format' => Yii::app()->user->getDateFormat(true), 'autoclose' => true), 'htmlOptions' => array('class' => 'span5')), 'prepend' => '<i class="glyphicon glyphicon-calendar"></i>', 'append' => 'Click on Month/Year to select a different Month/Year.')); ?> <?php echo $form->dropDownListGroup($model, 'applicant_id', array('widgetOptions' => array('htmlOptions' => array('class' => 'span5', 'maxlength' => 10), 'data' => Applicant::getApplicantOptions()))); ?> <?php echo $form->textFieldGroup($model, 'deed_no', array('widgetOptions' => array('htmlOptions' => array('class' => 'span5', 'maxlength' => 255)))); ?> <div class="form-actions text-center"> <?php $this->widget('booster.widgets.TbButton', array('buttonType' => 'submit', 'context' => 'primary', 'label' => $model->isNewRecord ? 'Create' : 'Save')); echo " | " . CHtml::link('Cancel', Yii::app()->user->getReturnUrl()); ?> </div> <?php
/** * @return \yii\db\ActiveQuery */ public function getAppilcant() { return $this->hasOne(Applicant::className(), ['id' => 'appilcant_id']); }