Ejemplo n.º 1
0
 public function actionStuinforeport()
 {
     $selected_list = $query = NULL;
     $student_data = array();
     $model = new StuMaster();
     $info = new StuInfo();
     $course = $batch = $section = null;
     if (!empty($_POST['s_info']) && !empty($_POST['StuMaster']['stu_master_course_id']) || (!empty($_POST['StuMaster']['report_batch_id']) || !empty($_POST['StuMaster']['report_section_id']) || !empty($_POST['StuMaster']['report_city']) || !empty($_POST['StuInfo']['stu_gender']))) {
         if (Yii::$app->request->isAjax) {
             \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
             return ActiveForm::validateMultiple([$model, $info]);
         }
         if (!empty($_POST['StuMaster']['stu_master_course_id'])) {
             $query .= "stu.stu_master_course_id=" . $_POST['StuMaster']['stu_master_course_id'] . " AND ";
         }
         if (!empty($_POST['StuMaster']['report_batch_id'])) {
             $query .= "stu.stu_master_batch_id=" . $_POST['StuMaster']['report_batch_id'] . " AND ";
         }
         if (!empty($_POST['StuMaster']['report_section_id'])) {
             $query .= "stu.stu_master_section_id=" . $_POST['StuMaster']['report_section_id'] . " AND ";
         }
         if (!empty($_POST['StuMaster']['report_city'])) {
             $query .= "add.stu_cadd_city=" . $_POST['StuMaster']['report_city'] . " AND ";
         }
         if (!empty($_POST['StuInfo']['stu_gender'])) {
             $query .= "s_info.stu_gender='" . $_POST['StuInfo']['stu_gender'] . "' AND ";
         }
         if (!empty($_POST['s_info'])) {
             $selected_list = $_POST['s_info'];
         }
         echo $model->validate();
         $query1 = new \yii\db\Query();
         $query1->select('*')->from('stu_master stu')->join('join', 'stu_info s_info', 's_info.stu_info_id = stu.stu_master_stu_info_id')->join('join', 'stu_address add', 'add.stu_address_id = stu.stu_master_stu_address_id')->where($query . 'stu.is_status = 0');
         $command = $query1->createCommand();
         $student_data = $command->queryAll();
         if (empty($student_data)) {
             \Yii::$app->getSession()->setFlash('studerror', "<i class='fa fa-exclamation-triangle'></i> <b> No Record For This Criteria.</b>");
             return $this->redirect(['stuinforeport']);
         }
         return $this->render('stu_info_report', ['student_data' => $student_data, 'selected_list' => $selected_list, 'query' => $query]);
         break;
     }
     return $this->render('stu_report_view', ['model' => $model, 'info' => $info, 'query' => $query, 'selected_list' => $selected_list]);
 }