public static function actionGetCourse() { $request = Yii::$app->request; $factID = $request->post('fact_id'); $data = Course::getCourseName($factID); Yii::$app->response->format = 'json'; //header json echo json_encode($data); /*print_r($data['coursename']); die();*/ }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Course::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(['course_id' => $this->course_id]); $query->andFilterWhere(['like', 'course_code', $this->course_code])->andFilterWhere(['like', 'course_name', $this->course_name]); return $dataProvider; }
public static function actionSavecourse() { $request = Yii::$app->request; $sizePost = sizeof($_POST); $lengthData = ($sizePost - 2) / 2; /*print_r($_POST); die();*/ //fact_id for ($i = 1; $i <= $lengthData; $i++) { $model = new Course(); $model->course_name = $request->post('course_' . $i . ''); $model->course_code = $request->post('courseCode_' . $i . ''); $model->course_status = 1; $model->save(); if ($model->save() == 1) { $modelie = new InstitutionCourse(); $modelie->inst_id = $request->post('fact_id'); $modelie->course_id = $model->course_id; $modelie->save(); } /* print_r($model->getErrors()); die();*/ } }
/** * @return \yii\db\ActiveQuery */ public function getCourse() { return $this->hasOne(Course::className(), ['course_id' => 'course_id']); }
public function getCourse() { return $this->hasMany(Course::className(), ['dept_id' => 'dept_id']); }
/** * @return \yii\db\ActiveQuery * join table jauuuh */ public function getCourse() { return $this->hasOne(Course::className(), ['course_id' => 'course_id'])->via('educationInformation'); }
public static function actionGetcourse() { $request = Yii::$app->request; $factID = $request->post('factID'); $data = Course::getCourseByFaculty($factID); Yii::$app->response->format = 'json'; //header json echo json_encode($data); }
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); }