/** * Store a newly created resource in storage. * * @return Response */ public function store(SchoolYearRequest $request) { $data = $request->all(); $schoolYear = new SchoolYear(); $schoolYear->fromArray($data); $schoolYear->save(); flash()->success("ADDED"); session(['attribute' => \Lang::get('general.SCHOOL_YEAR')]); return redirect($this->main_page); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = SchoolYear::find(); // add conditions that should always apply here $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; } // grid filtering conditions $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'sy', $this->sy]); return $dataProvider; }
/** * Clears the current object, sets all attributes to their default values and removes * outgoing references as well as back-references (from other objects to this one. Results probably in a database * change of those foreign objects when you call `save` there). */ public function clear() { if (null !== $this->aPeriod) { $this->aPeriod->removeApplication($this); } if (null !== $this->aSubject) { $this->aSubject->removeApplication($this); } if (null !== $this->aStudent) { $this->aStudent->removeApplication($this); } if (null !== $this->aSchoolYear) { $this->aSchoolYear->removeApplication($this); } $this->id = null; $this->student_id = null; $this->subject_id = null; $this->period_id = null; $this->school_year_id = null; $this->application_date = null; $this->exam_date = null; $this->exam_time = null; $this->exam_score = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); $this->setNew(true); $this->setDeleted(false); }
/** * Clears the current object, sets all attributes to their default values and removes * outgoing references as well as back-references (from other objects to this one. Results probably in a database * change of those foreign objects when you call `save` there). */ public function clear() { if (null !== $this->aCourse) { $this->aCourse->removeStudent($this); } if (null !== $this->aSchoolYear) { $this->aSchoolYear->removeStudent($this); } $this->id = null; $this->identification_number = null; $this->school_year_id = null; $this->course_id = null; $this->first_name = null; $this->last_name = null; $this->birth_place = null; $this->birthday = null; $this->phone_number = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); $this->setDeleted(false); }
protected function findLatestSy() { $school_year = SchoolYear::find()->orderBy(['id' => SORT_DESC])->all(); return $school_year[0]->sy; }
use yii\helpers\Html; use yii\helpers\HtmlPurifier; use kartik\select2\Select2; use app\models\ApplicantForm; use app\models\ActiveRecord; use app\models\StudentForm; use yii\helpers\ArrayHelper; use yii\bootstrap\ActiveForm; use app\models\GradeLevel; use app\models\Section; use app\models\SchoolYear; use app\models\Card; use app\models\DataHelper; $card_url = json_encode(Yii::$app->request->baseUrl . '/site/card?data='); $current_date = date('Y'); $school_year = SchoolYear::find()->orderBy(['id' => SORT_DESC])->all(); $section = Section::find()->all(); $grade_level = GradeLevel::find()->where(['!=', 'id', 0])->all(); $status = [['id' => 1, 'status' => 'Pending'], ['id' => 0, 'status' => 'Enrolled']]; $listData = ArrayHelper::map($grade_level, 'id', 'name'); $listData2 = ArrayHelper::map($school_year, 'id', 'sy'); $listData3 = ArrayHelper::map($section, 'id', 'section_name'); $listData4 = ArrayHelper::map($status, 'id', 'status'); $state = false; $avatar = Yii::$app->request->baseUrl . Yii::$app->params['avatar']; !$model->isNewRecord ? !empty($model->student->students_profile_image) ? $img = Yii::$app->request->baseUrl . '/uploads/students/' . $model->student->students_profile_image : ($img = $avatar) : ''; !$model->isNewRecord ? !empty(trim($model->student->middle_name)) ? $middle = ucfirst(substr($model->student->middle_name, 0, 1)) . '.' : ($middle = '') : ''; !$model->isNewRecord ? $this->title = implode(' ', [$model->student->first_name, $middle, $model->student->last_name]) : 'New'; $model->isNewRecord ? $this->title = 'New' : ($this->title = implode(' ', [$model->student->first_name, $middle, $model->student->last_name])); $form = ActiveForm::begin(); ?>
public function countCurrentEnrolled() { $latest = (int) SchoolYear::find()->orderBy(['id' => SORT_DESC])->all()[0]['id']; $count = count(EnrolledForm::find()->where(['sy_id' => $latest])->where(['enrollment_status' => 0])->all()); return $count; }
/** * @return \yii\db\ActiveQuery */ public function getSy() { return $this->hasOne(SchoolYear::className(), ['id' => 'sy_id']); }
/** * Filter the query by a related \App\Models\SchoolYear object * * @param \App\Models\SchoolYear|ObjectCollection $schoolYear The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @throws \Propel\Runtime\Exception\PropelException * * @return ChildEngagementQuery The current query, for fluid interface */ public function filterBySchoolYear($schoolYear, $comparison = null) { if ($schoolYear instanceof \App\Models\SchoolYear) { return $this->addUsingAlias(EngagementTableMap::COL_SCHOOL_YEAR_ID, $schoolYear->getId(), $comparison); } elseif ($schoolYear instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this->addUsingAlias(EngagementTableMap::COL_SCHOOL_YEAR_ID, $schoolYear->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterBySchoolYear() only accepts arguments of type \\App\\Models\\SchoolYear or Collection'); } }
<div class="ui three column stackable grid"> <div class="four wide rounded column"> <?php echo Card::render($options = ['imageContent' => !$model->isNewRecord ? !empty($model->teacher->profile_image) ? ['/file', 'id' => $model->teacher->profile_image] : Yii::$app->params['avatar'] : Yii::$app->request->baseUrl . Yii::$app->params['avatar'], 'labelContent' => !$model->isNewRecord ? implode(' ', ['ID#', '<strong>', $model->teacher->id, '</strong>']) : ' ', 'labelFor' => 'Teacher ID', 'labelOptions' => '', 'headerContent' => !$model->isNewRecord ? DataHelper::name($model->teacher->first_name, $model->teacher->middle_name, $model->teacher->last_name) : ' ', 'headerOptions' => '', 'metaContent' => !$model->isNewRecord ? implode('', ['\'', $model->teacher->username, '\'']) : ' ', 'metaOptions' => '', 'leftFloatedContent' => !$model->isNewRecord ? implode('', [DataHelper::gradeLevel($model->grade_level_id), '<p style="color: rgba(0,0,0,.4);"><span style="font-size: 11px;">', DataHelper::schoolYear($model->sy_id), '</span><br/>Adviser', '</p>']) : ' ', 'leftFloatedFor' => '', 'leftFloatedOptions' => '', 'rightFloatedContent' => '', 'rightFloatedOptions' => 'hidden']); ?> </div> <div class="nine wide rounded column"> <div class="ui segment"> <?php echo !$model->isNewRecord ? Html::tag('label', implode('', [implode('-', array_map('ucfirst', explode('-', Yii::$app->controller->id))), '# ', $model->id]), ['class' => 'ui fluid big label']) : ''; ?> <br><br> <div class="row"> <div class="col-lg-4 col-md-4 col-sm-12"> <?php echo $form->field($model, 'sy_id', ['inputTemplate' => '<label>School Year</label>{input}'])->dropDownList(ArrayHelper::map(SchoolYear::find()->orderBy(['id' => SORT_DESC])->all(), 'id', 'sy'), ['class' => 'form-control pva-form-control'])->label(false); ?> </div> </div> <div class="row"> <div class="col-lg-6 col-md-6 col-sm-12"> <?php echo $form->field($model, 'teacher_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(app\models\User::find()->joinWith('role')->where(['item_name' => 'teacher'])->orderBy(['first_name' => SORT_ASC])->all(), 'id', function ($model) { if ($model->first_name === '') { return $model->username; } else { return implode(' ', [$model->first_name, $model->middle_name, $model->last_name]); } }), 'language' => 'en', 'options' => ['id' => 'auto-suggest', 'placeholder' => 'Select Teacher'], 'pluginOptions' => ['allowClear' => true], 'pluginEvents' => ['change' => "\n function(){\n if(\$('#auto-suggest').val() === ''){\n console.log('empty');\n \$('.tiny.image').attr('src', '/proverbs/uploads/ui/user-blue.svg');\n \$('#header-label').html(' ');\n \$('#header-content').html(' ');\n \$('#meta-content').html(' ');\n \$('#left-content').html(' ');\n \$('#right-content').addClass('hidden');\n }else {\n \$.ajax({\n type: 'POST',\n url: {$card_url} + JSON.stringify({uid:\$('#auto-suggest').val(),}),\n contentType: 'application/json; charset=utf-8',\n dataType: 'json',\n success: function(data){\n \$('#header-label').html('<em>' + data.email + '</em>');\n \$('#header-content').html(data.name);\n \$('#meta-content').html(data.username);\n\n if(data.img !== 'empty'){\n \$('.tiny.image').attr('src', data.img);\n }else {\n \$('.tiny.image').attr('src', '/proverbs/uploads/ui/user-blue.svg');\n }\n }\n });\n }\n }\n "]])->label(false); ?> </div>
/** * Clears the current object, sets all attributes to their default values and removes * outgoing references as well as back-references (from other objects to this one. Results probably in a database * change of those foreign objects when you call `save` there). */ public function clear() { if (null !== $this->aPeriod) { $this->aPeriod->removePeriodSchoolYear($this); } if (null !== $this->aSchoolYear) { $this->aSchoolYear->removePeriodSchoolYear($this); } $this->period_id = null; $this->school_year_id = null; $this->date_start = null; $this->date_end = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); $this->setDeleted(false); }
public function getSyList() { $school_year = SchoolYear::find()->orderBy(['id' => SORT_DESC])->all(); $array = [null => null]; for ($i = 0; $i < count($school_year); $i++) { $array[$school_year[$i]->sy] = $school_year[$i]->sy; } return $array; }
public static function schoolYear($data) { $data = SchoolYear::find()->where(['id' => $data])->one(); return $data->sy; }
/** * Exclude object from result * * @param ChildSchoolYear $schoolYear Object to remove from the list of results * * @return $this|ChildSchoolYearQuery The current query, for fluid interface */ public function prune($schoolYear = null) { if ($schoolYear) { $this->addUsingAlias(SchoolYearTableMap::COL_ID, $schoolYear->getId(), Criteria::NOT_EQUAL); } return $this; }
/** * Clears the current object, sets all attributes to their default values and removes * outgoing references as well as back-references (from other objects to this one. Results probably in a database * change of those foreign objects when you call `save` there). */ public function clear() { if (null !== $this->aCourse) { $this->aCourse->removeEngagement($this); } if (null !== $this->aProfessor) { $this->aProfessor->removeEngagement($this); } if (null !== $this->aSubject) { $this->aSubject->removeEngagement($this); } if (null !== $this->aSchoolYear) { $this->aSchoolYear->removeEngagement($this); } $this->professor_id = null; $this->subject_id = null; $this->course_id = null; $this->school_year_id = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); $this->setDeleted(false); }
/** * Finds the SchoolYear model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return SchoolYear the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = SchoolYear::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }