Exemplo n.º 1
0
 public function actionIndex()
 {
     $model = new StuMaster();
     $model->scenario = 'import-student';
     $importResults = [];
     if ($model->load(Yii::$app->request->post())) {
         $model->importFile = UploadedFile::getInstance($model, 'importFile');
         if ($model->saveImportFile()) {
             $importResults = $this->importStuData($model);
             //print_r($importResults); exit;
         }
     }
     return $this->render('index', ['model' => $model, 'importResults' => $importResults]);
 }
Exemplo n.º 2
0
 public function actionStuinforeport()
 {
     $student_data = $selected_list = [];
     $model = new StuMaster();
     $info = new StuInfo();
     if ($model->load(Yii::$app->request->post()) && $info->load(Yii::$app->request->post())) {
         if (Yii::$app->request->isAjax) {
             \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
             return ActiveForm::validateMultiple([$model, $info]);
         }
         $selected_list = $_POST['s_info'];
         $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(['stu.is_status' => 0])->andFilterWhere(['stu.stu_master_course_id' => $model->stu_master_course_id])->andFilterWhere(['stu.stu_master_batch_id' => $model->report_batch_id])->andFilterWhere(['stu.stu_master_section_id' => $model->report_section_id])->andFilterWhere(['add.stu_cadd_city' => $model->report_city])->andFilterWhere(['s_info.stu_gender' => $info->stu_gender]);
         $command = $query1->createCommand();
         $student_data = $command->queryAll();
         Yii::$app->session->set('data["stuData"]', $student_data);
         Yii::$app->session->set('data["selection"]', $selected_list);
         if (empty($student_data)) {
             \Yii::$app->getSession()->setFlash('studerror', "<i class='fa fa-exclamation-triangle'></i> <b> " . Yii::t('report', 'No Record Found For This Criteria.') . "</b>");
             return $this->redirect(['stuinforeport']);
         }
         return $this->render('stu_info_report', ['student_data' => $student_data, 'selected_list' => $selected_list]);
     } else {
         if (Yii::$app->request->get('exportExcel')) {
             $file = $this->renderPartial('stu_info_report_excel', array('student_data' => Yii::$app->session->get('data["stuData"]'), 'selected_list' => Yii::$app->session->get('data["selection"]')));
             $fileName = "Employee_info_report" . date('YmdHis') . '.xls';
             $options = ['mimeType' => 'application/vnd.ms-excel'];
             return Yii::$app->excel->exportExcel($file, $fileName, $options);
         } else {
             if (Yii::$app->request->get('exportPDF')) {
                 $html = $this->renderPartial('stu_info_report_pdf', array('student_data' => Yii::$app->session->get('data["stuData"]'), 'selected_list' => Yii::$app->session->get('data["selection"]')));
                 ob_clean();
                 return Yii::$app->pdf->exportData('Employee Info Report', 'Employee_info_report', $html);
             }
         }
     }
     return $this->render('stu_report_view', ['model' => $model, 'info' => $info, 'selected_list' => $selected_list]);
 }
Exemplo n.º 3
0
 /**
  * Creates a new StuMaster model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new StuMaster();
     $info = new StuInfo();
     $address = new StuAddress();
     $user = new User();
     $auth_assign = new AuthAssignment();
     if (Yii::$app->request->isAjax) {
         if ($info->load(Yii::$app->request->post())) {
             \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
             return ActiveForm::validate($info);
         }
         if ($model->load(Yii::$app->request->post())) {
             \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
             return ActiveForm::validate($model);
         }
     }
     $stud_uniq_no = \app\modules\student\models\StuInfo::find()->max('stu_unique_id');
     $uniq_id = NULL;
     if (empty($stud_uniq_no)) {
         $uniq_id = $info->stu_unique_id = 1;
     } else {
         $chk_id = StuInfo::find()->where(['stu_unique_id' => $stud_uniq_no])->exists();
         if ($chk_id) {
             $uniq_id = $stud_uniq_no + 1;
         } else {
             $uniq_id = $stud_uniq_no;
         }
     }
     if ($model->load(Yii::$app->request->post()) || $info->load(Yii::$app->request->post())) {
         $login_id = \app\models\Organization::find()->one()->org_stu_prefix . $uniq_id;
         $model->attributes = $_POST['StuMaster'];
         $info->attributes = $_POST['StuInfo'];
         $info->stu_dob = Yii::$app->dateformatter->getDateFormat($_POST['StuInfo']['stu_dob']);
         $info->stu_admission_date = Yii::$app->dateformatter->getDateFormat($_POST['StuInfo']['stu_admission_date']);
         if (empty($_POST['StuInfo']['stu_email_id'])) {
             $info->stu_email_id = NULL;
         } else {
             $info->stu_email_id = strtolower($_POST['StuInfo']['stu_email_id']);
         }
         $user->user_login_id = $login_id;
         $user->user_password = md5($user->user_login_id . $user->user_login_id);
         $user->user_type = "S";
         $user->created_by = Yii::$app->getid->getId();
         $user->created_at = new \yii\db\Expression('NOW()');
         if ($info->save(false)) {
             $user->save(false);
             $address->save(false);
         }
         $model->stu_master_stu_address_id = $address->stu_address_id;
         $model->stu_master_stu_info_id = $info->stu_info_id;
         $model->stu_master_user_id = $user->user_id;
         $model->created_by = Yii::$app->getid->getId();
         $model->created_at = new \yii\db\Expression('NOW()');
         $model->save(false);
         $s_info = StuInfo::findOne($model->stu_master_stu_info_id);
         $s_info->stu_info_stu_master_id = $model->stu_master_id;
         $s_info->save(false);
         $auth_assign->item_name = 'Student';
         $auth_assign->user_id = $user->user_id;
         $auth_assign->created_at = date_format(date_create(), 'U');
         $auth_assign->save(false);
         if ($model->save()) {
             return $this->redirect(['view', 'id' => $model->stu_master_id]);
         } else {
             return $this->render('create', ['model' => $model, 'info' => $info, 'uniq_id' => $uniq_id]);
         }
     } else {
         return $this->render('create', ['model' => $model, 'info' => $info, 'uniq_id' => $uniq_id]);
     }
 }