public function authenticate_instructor() { $i = Instructor::model()->findByAttributes(array('email' => $this->username)); if ($i === null) { // No user found! $this->errorCode = self::ERROR_USERNAME_INVALID; } else { if ($this->password !== Yii::app()->params['instructor_pass']) { $this->errorCode = self::ERROR_PASSWORD_INVALID; } else { // Okay! $this->errorCode = self::ERROR_NONE; $this->setState('role', 'instructor'); $this->_id = $i->id; $this->username = $i->full_name; } } return !$this->errorCode; }
<?php echo $form->labelEx($model, 'instructor_id'); // This is another odd one, so i'm not using ZHtml here either // I have to constrain based on company here. if (isset($model->instructor_id) && !$model->hasErrors()) { echo CHtml::encode($model->instructor->full_name); echo $form->hiddenField($model, "instructor_id"); } else { $instparams = array(); $constraint = ""; if (isset($model->class_id)) { $instparams = array('condition' => 'company_id = :coid', 'params' => array(':coid' => $model->class->company_id)); $constraint = " (this class is " . $model->class->company->name . ")"; } echo $form->dropDownList($model, 'instructor_id', CHtml::listData(Instructor::model()->findAll($instparams), 'id', 'full_name')); echo $constraint; } echo $form->error($model, 'instructor_id'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'class_id'); if (isset($model->class_id) && !$model->hasErrors()) { echo CHtml::encode($model->class->summary); echo $form->hiddenField($model, "class_id"); } else {
public function getInstructors() { return Instructor::model()->findAllBySql("select instructor.* from instructor \nleft join instructor_assignment\n on instructor.id = instructor_assignment.instructor_id \nleft join class_info on class_info.id = instructor_assignment.class_id\nwhere class_info.session_id = :sid\ngroup by instructor_id\norder by instructor.last_name asc, instructor.first_name asc", array('sid' => $this->id)); }
<div class="row"> <?php echo $form->labelEx($model, 'payee_id'); ?> <?php // This is another odd one, so i'm not using ZHtml here either // I have to constrain based on company here. if (isset($model->payee_id) && !$model->hasErrors()) { echo CHtml::encode($model->payee->full_name); echo $form->hiddenField($model, "payee_id"); } else { $instparams = array('condition' => 'company_id = :coid', 'params' => array(':coid' => Company::OSSPTO_COMPANY)); $constraint = " (expense checks only for OSSPTO)"; echo $form->dropDownList($model, 'payee_id', CHtml::listData(Instructor::model()->findAll($instparams), 'id', 'full_name'), array('ajax' => array('type' => 'POST', 'url' => Yii::app()->controller->createUrl("autocompleteamount"), 'success' => 'function(data){ $("input#CheckExpense_amount").val(jQuery.parseJSON(data));}'))); echo $constraint; } echo $form->error($model, 'payee_id'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'amount'); ?> <?php echo $form->textField($model, 'amount', array('size' => 19, 'maxlength' => 19)); ?> <?php echo $form->error($model, 'amount');
<?php $this->pageTitle = Yii::app()->name; $this->breadcrumbs = array(); // reset $instructor = Instructor::model()->findByPk(Yii::app()->user->id); ?> <h1>After-School Enrichment Program – <?php echo CHtml::encode($this->savedSessionSummary()); ?> </h1> <h3>Instructor Requirements Status for <?php echo CHtml::encode($instructor->full_name); ?> </h3> <?php echo $this->renderPartial('/instructor/_requirement_status', array('model' => $instructor)); ?> <?php echo $this->renderPartial('/instructor/signup_details', array('instructor' => $instructor)); ?>
public function actionAutocompleteAmount() { if (isset($_POST['CheckExpense'])) { $i = Instructor::model()->findByPk($_POST['CheckExpense']['payee_id']); echo CJSON::encode($i->owed); Yii::app()->end(); } //TODO error out, 404? }
/** * 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. */ public function loadModel() { if ($this->_model === null) { if (isset($_GET['id'])) { $this->_model = Instructor::model()->findbyPk($_GET['id']); } if ($this->_model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } } return $this->_model; }