public function actionIndex() { $data['state'] = State::find()->indexBy('s_id')->asArray()->all(); $data['Faculty'] = Institution::getCurrentFaculty(); $data['level'] = EducationLevel::find()->indexBy('el_id')->asArray()->all(); $data['course'] = Course::find()->indexBy('course_id')->asArray()->all(); return $this->render('index', $data); }
/** * Displays a single User model. * @param integer $id * @return mixed */ public function actionView($id) { $data['userList'] = User::getAllUsers($id); $data['userEducation'] = User::getUserEducation($id); $data['userWorking'] = User::getUserWorking($id); $data['institution'] = Institution::find()->where(array('inst_status' => 1))->all(); $data['level'] = EducationLevel::find()->indexBy('el_id')->all(); return $this->render('view', $data); /*return $this->render('view', [ 'model' => $this->findModel($id), ]);*/ }
public function actionGetStudent() { $request = Yii::$app->request; $year = $request->post('year'); $poscode = $request->post('zipcode'); $SearchStudent = Institution::getStudent($year, $poscode); /*print_r($SearchStudent); die();*/ Yii::$app->response->format = 'json'; // klu nk convert smue data jdi json echo json_encode($SearchStudent); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Institution::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->andFilterWhere(['inst_id' => $this->inst_id]); $query->andFilterWhere(['like', 'inst_code', $this->inst_code])->andFilterWhere(['like', 'inst_name', $this->inst_name]); return $dataProvider; }
public static function actionGetfaculty() { $request = Yii::$app->request; $uni_ID = $request->post('uni_id'); $data = Institution::find()->where(array('uni_id' => $uni_ID))->asArray()->all(); Yii::$app->response->format = 'json'; //header json echo json_encode($data); }
/** * @return \yii\db\ActiveQuery */ public function getInst() { return $this->hasOne(Institution::className(), ['inst_id' => 'inst_id']); }
public static function actionGetReport() { $request = Yii::$app->request; $type = $request->post('type'); $start = $request->post('start'); $end = $request->post('end'); $data = ""; if ($type == "Negeri") { $data['currentYear'] = State::getStateReport(); $data['rangeYear'] = State::getStateReportRange(); /* print_r($data); die();*/ } else { if ($type == "Faculty") { $faculty = Institution::getFacultyReport($start, $end); $facultyDetailData = array(); foreach ($faculty as $facultyData) { $dataArray = array(); $dataSplit = explode(",", $facultyData['student']); $facultyDetailData[$facultyData['inst_id']]["facultyName"] = $facultyData['inst_name']; $facultyDetailData[$facultyData['inst_id']]["facultyCode"] = $facultyData['inst_code']; for ($i = 0; $i < sizeof($dataSplit); $i++) { $dataSplitDetail = explode("|", $dataSplit[$i]); /*print_r($dataSplitDetail); die();*/ //$facultyDetailData[$facultyData['inst_id']][] = isset($dataSplitDetail[1])?$dataSplitDetail[1]:''; $dataArray[$facultyData['inst_id']][] = isset($dataSplitDetail[1]) ? $dataSplitDetail[1] : ''; } $occurences = array(); foreach ($dataArray as $key) { //print_r($key); $occurences = array_count_values($key); $facultyDetailData[$facultyData['inst_id']]['count'][] = $occurences; //print_r($occurences); } } $data = $facultyDetailData; //inst_id /* print_r($data); die();*/ } else { if ($type == "Course") { $occurences = array(); $factID = $request->post('fact_id'); $course = Course::getCourseReport($factID, $start, $end); /*print_r($course); die();*/ $courseDetailData = array(); $bil2 = 1; $sizecourse = sizeof($course); foreach ($course as $courseData) { $dataCourseArray = array(); $dataCourseSplit = explode(",", $courseData['students']); $courseDetailData[$bil2]["courseName"] = $courseData['course_name']; $courseDetailData[$bil2]["courseCode"] = $courseData['course_code']; $courseDetailData[$bil2]["size"] = $sizecourse; for ($i = 0; $i < sizeof($dataCourseSplit); $i++) { $dataSplitDetail = explode("|", $dataCourseSplit[$i]); // $courseDetailData[$courseData['course_id']][] = $dataCourseSplitDetail[1]; $dataCourseArray[$bil2][] = isset($dataSplitDetail[1]) ? $dataSplitDetail[1] : ''; } $occurences = array(); foreach ($dataCourseArray as $key) { //print_r($key); $occurences = array_count_values($key); $courseDetailData[$bil2]['count'][] = $occurences; //print_r($occurences); } $bil2++; } $courseDetailData[$bil2]['count'][] = $occurences; $data = $courseDetailData; } else { if ($type == "Jantina") { $data = Institution::getUserReport($start); } else { if ($type == "work") { $data = Institution::getWorkingReport($start); } } } } } Yii::$app->response->format = 'json'; //header json echo json_encode($data); }
public static function actionSaverecord() { $request = Yii::$app->request; /* print_r($_POST); die();*/ $sizePost = sizeof($_POST); $lengthData = ($sizePost - 2) / 2; for ($i = 1; $i <= $lengthData; $i++) { $model = new Institution(); $model->inst_name = $request->post('fact_' . $i . ''); $model->inst_code = $request->post('factCode_' . $i . ''); $model->uni_id = $request->post('uni_id'); $model->save(); /*print_r($model->getErrors()); die();*/ } }
public function actionIndex() { $data['report'] = Institution::getReportHome(); return $this->render('index', $data); }