예제 #1
0
 public function actionIndex()
 {
     $grades = Grade::find()->all();
     $schools = School::find()->all();
     $users = User::find()->all();
     $scholars = Scholar::find()->all();
     $tuitions = Tuition::find()->all();
     return $this->render('index', array('users' => $users, 'scholars' => $scholars, 'schools' => $schools, 'grades' => $grades, 'tuition' => $tuitions));
 }
예제 #2
0
 /**
  * Lists all Compile models.
  * @return mixed
  */
 public function actionIndex()
 {
     $schools = School::find()->all();
     $users = User::find()->all();
     $scholars = Scholar::find()->all();
     $allowances = Allowance::find()->all();
     $grades = Grade::find()->all();
     return $this->render('index', array('users' => $users, 'scholars' => $scholars, 'schools' => $schools, 'allowances' => $allowances, 'grades' => $grades));
 }
예제 #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Grade::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->joinWith('scholarScholar');
     $query->joinWith('subjectSubject');
     $query->joinWith('subjectSubject');
     $query->andFilterWhere(['grade_id' => $this->grade_id, 'subject_subject_id' => $this->subject_subject_id, 'subject_scholar_scholar_id' => $this->subject_scholar_scholar_id, 'subject_scholar_school_school_id' => $this->subject_scholar_school_school_id, 'grade_school_year_start' => $this->grade_school_year_start, 'grade_school_year_end' => $this->grade_school_year_end]);
     $query->andFilterWhere(['like', 'grade_raw_grade', $this->grade_raw_grade])->andFilterWhere(['like', 'grade_approval_status', $this->grade_approval_status])->andFilterWhere(['like', 'grade_approved_by', $this->grade_approved_by])->andFilterWhere(['like', 'scholar.scholar_first_name', $this->firstName])->andFilterWhere(['like', 'scholar.scholar_middle_name', $this->middleName])->andFilterWhere(['like', 'scholar.scholar_last_name', $this->lastName])->andFilterWhere(['like', 'subject.subject_name', $this->subjectName])->andFilterWhere(['like', 'subject.subject_term', $this->subjectTerm])->andFilterWhere(['like', 'subject.subject_units', $this->subjectUnits])->andFilterWhere(['like', 'subject.subject_taken_status', $this->takenStatus]);
     return $dataProvider;
 }
예제 #4
0
use common\models\Grade;
use common\models\GroupGrade;
use common\models\User;
?>

<div class="grade-form">

    <?php 
$form = ActiveForm::begin(['id' => 'dynamic-form']);
?>
	<?php 
$username = Yii::$app->user->identity->username;
$users = User::find()->all();
$scholars = Scholar::find()->all();
$model = new Subject();
$modelCustomer = new Grade();
$modelsAddress = [new Grade()];
foreach ($users as $user) {
    foreach ($scholars as $scholar) {
        if ($user->username == $username && $user->id == $scholar->scholar_user_id) {
            $modelCustomer->subject_scholar_scholar_id = $scholar->scholar_id;
            if ($modelCustomer->load(Yii::$app->request->post())) {
                $modelsAddress = GroupGrade::createMultiple(Grade::classname());
                GroupGrade::loadMultiple($modelsAddress, Yii::$app->request->post());
                // ajax validation
                if (Yii::$app->request->isAjax) {
                    Yii::$app->response->format = Response::FORMAT_JSON;
                    return ArrayHelper::merge(ActiveForm::validateMultiple($modelsAddress), ActiveForm::validate($modelCustomer));
                }
                // validate all models
                $valid = $modelCustomer->validate();
예제 #5
0
 /**
  * Finds the Grade model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $grade_id
  * @param integer $subject_subject_id
  * @param integer $subject_scholar_scholar_id
  * @param integer $subject_scholar_school_school_id
  * @return Grade the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Grade::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getGrades1()
 {
     return $this->hasMany(Grade::className(), ['subject_scholar_school_school_id' => 'scholar_school_school_id']);
 }
예제 #7
0
$form = ActiveForm::begin();
?>
	
    <?php 
echo $form->field($model, 'subject_term')->textInput();
?>

    <?php 
echo $form->field($model, 'subject_name')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'subject_units')->textInput(['maxlength' => true]);
?>
	 <?php 
$modelCustomers = Grade::find()->all();
foreach ($modelCustomers as $modelCustomer) {
    if ($modelCustomer->subject_subject_id == $model->subject_id) {
        $test = $form->field($modelCustomer, 'grade_raw_grade')->textInput(['maxlength' => true]);
    }
}
?>
	 <?php 
echo $test;
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>
예제 #8
0
 /**
  * Updates an existing Subject model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $model2s = Grade::find()->all();
     foreach ($model2s as $model2) {
         if ($model->subject_id == $model2->subject_subject_id) {
             if ($model2->grade_approval_status == 'Not Approved') {
                 if ($model->load(Yii::$app->request->post()) && $model->save()) {
                     if ($model2->load(Yii::$app->request->post()) && $model2->save()) {
                         return $this->redirect(['index', 'id' => $model2->grade_id]);
                     }
                     return $this->redirect(['index', 'id' => $model->subject_id]);
                 } else {
                     return $this->render('update', ['model' => $model]);
                 }
             } else {
                 \Yii::$app->getSession()->setFlash('error', 'The record has already been reviewed by the SM Foundation');
                 return $this->redirect(['index', 'id' => $model->subject_id]);
             }
         }
     }
 }
예제 #9
0
 public function actionGroupcreate()
 {
     $modelCustomer = new Grade();
     $modelsAddress = [new Grade()];
     if ($modelCustomer->load(Yii::$app->request->post())) {
         $modelsAddress = GroupGrade::createMultiple(Grade::classname());
         GroupGrade::loadMultiple($modelsAddress, Yii::$app->request->post());
         // ajax validation
         if (Yii::$app->request->isAjax) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             return ArrayHelper::merge(ActiveForm::validateMultiple($modelsAddress), ActiveForm::validate($modelCustomer));
         }
         // validate all models
         $valid = $modelCustomer->validate();
         $valid = GroupGrade::validateMultiple($modelsAddress) && $valid;
         if ($valid) {
             $transaction = \Yii::$app->db->beginTransaction();
             try {
                 // if($flag = $modelCustomer->save(false)){
                 foreach ($modelsAddress as $modelAddress) {
                     $modelAddress->subject_scholar_scholar_id = $modelCustomer->subject_scholar_scholar_id;
                     $modelAddress->grade_school_year_start = $modelCustomer->grade_school_year_start;
                     $modelAddress->grade_school_year_end = $modelCustomer->grade_school_year_end;
                     $selectSchool = ArrayHelper::map(Scholar::find()->where(['scholar_id' => $modelAddress->subject_scholar_scholar_id])->all(), 'school_school_id', 'school_school_id');
                     $schoolID = array_values($selectSchool)[0];
                     $modelAddress->subject_scholar_school_school_id = $schoolID;
                     if (!($flag = $modelAddress->save(false))) {
                         $transaction->rollBack();
                         break;
                     }
                 }
                 // }
                 if ($flag) {
                     if ($modelCustomer->subject_subject_id == null) {
                         $sql = "DELETE FROM grade WHERE subject_subject_id is null;";
                         Yii::$app->db->createCommand($sql)->execute();
                     }
                     $transaction->commit();
                     return $this->redirect(['index']);
                 }
             } catch (Exception $e) {
                 $transaction->rollBack();
             }
         }
     }
     return $this->render('groupcreate', ['modelCustomer' => $modelCustomer, 'modelsAddress' => empty($modelsAddress) ? [new Grade()] : $modelsAddress]);
 }