/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = StuCategory::find()->where(['is_status' => 0]);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['stu_category_id' => SORT_DESC]]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['stu_category_id' => $this->stu_category_id, 'created_at' => $this->created_at, 'created_by' => $this->created_by, 'updated_at' => $this->updated_at, 'updated_by' => $this->updated_by, 'is_status' => $this->is_status]);
     $query->andFilterWhere(['like', 'stu_category_name', $this->stu_category_name]);
     unset($_SESSION['exportData']);
     $_SESSION['exportData'] = $dataProvider;
     return $dataProvider;
 }
 public function actionIndex()
 {
     $fYearWiseAdm = [];
     /**
      * @Start Display Category Wise Student Details Graph
      */
     $stuCateDataTmp = StuCategory::find()->where(['is_status' => 0])->asArray()->all();
     foreach ($stuCateDataTmp as $cv) {
         $stuCatWiseDisp[] = $cv['stu_category_name'];
         $maleCount = (new \yii\db\Query())->from('stu_master sm')->join('JOIN', 'stu_info si', 'si.stu_info_stu_master_id = sm.stu_master_id')->where(['sm.is_status' => '0', 'si.stu_gender' => 'Male', 'sm.stu_master_category_id' => $cv['stu_category_id']])->count();
         $femaleCount = (new \yii\db\Query())->from('stu_master sm')->join('JOIN', 'stu_info si', 'si.stu_info_stu_master_id = sm.stu_master_id')->where(['sm.is_status' => '0', 'si.stu_gender' => 'Female', 'sm.stu_master_category_id' => $cv['stu_category_id']])->count();
         $stuCatWiseDataMale[] = $maleCount;
         $stuCatWiseDataFemale[] = $femaleCount;
     }
     $stuCatWiseDisp[] = 'Not Set';
     $stuCatWiseDataMale[] = (new \yii\db\Query())->from('stu_master sm')->join('JOIN', 'stu_info si', 'si.stu_info_stu_master_id = sm.stu_master_id')->where(['sm.is_status' => 0, 'sm.stu_master_category_id' => NULL, 'si.stu_gender' => 'Male'])->count();
     $stuCatWiseDataFemale[] = (new \yii\db\Query())->from('stu_master sm')->join('JOIN', 'stu_info si', 'si.stu_info_stu_master_id = sm.stu_master_id')->where(['sm.is_status' => 0, 'sm.stu_master_category_id' => NULL, 'si.stu_gender' => 'Female'])->count();
     /**
      * @Start Display Student Status Wise Details in combine graph
      */
     $dataRegTmp = $courseData = [];
     $stuRegStat = StuMaster::find()->where(['is_status' => 0, 'stu_master_stu_status_id' => 0])->count();
     $stuStatusWise[] = ['name' => "Default ({$stuRegStat})", 'y' => $stuRegStat, 'color' => '#77C730'];
     $courseDataTmp = Courses::find()->where(['is_status' => 0])->asArray()->limit(10)->orderBy('course_id DESC')->all();
     $stuStatusDataTmp = StuStatus::find()->where(['is_status' => 0])->orderBy('stu_status_id')->asArray()->all();
     foreach ($courseDataTmp as $v) {
         $stuCourseRegStat = StuMaster::find()->where(['is_status' => 0, 'stu_master_stu_status_id' => 0, 'stu_master_course_id' => $v['course_id']])->count();
         $dataRegTmp[] = $stuCourseRegStat;
         $courseData[] = $v['course_name'];
     }
     $stuStatusData[] = ['name' => "Default ({$stuRegStat})", 'type' => 'column', 'data' => $dataRegTmp, 'color' => '#77C730'];
     //print_r($stuStatusData); exit;
     foreach ($stuStatusDataTmp as $k => $sv) {
         $dataTmp = [];
         foreach ($courseDataTmp as $v) {
             $stuCourseStat = StuMaster::find()->where(['is_status' => 0, 'stu_master_course_id' => $v['course_id'], 'stu_master_stu_status_id' => $sv['stu_status_id']])->count();
             $dataTmp[] = $stuCourseStat;
         }
         $stuStatusWiseCount = StuMaster::find()->where(['is_status' => 0, 'stu_master_stu_status_id' => $sv['stu_status_id']])->count();
         $stuStatusData[] = ['name' => $sv['stu_status_name'] . "({$stuStatusWiseCount})", 'type' => 'column', 'data' => $dataTmp];
         $stuStatusWise[] = ['name' => $sv['stu_status_name'] . ' (' . $stuStatusWiseCount . ')', 'y' => $stuStatusWiseCount, 'color' => new JsExpression('Highcharts.getOptions().colors[' . $k . ']')];
     }
     /**
      * @Start Gender Wise Data Display For Student
      */
     $stuGenWise = (new \yii\db\Query())->select(["CONCAT(IFNULL(si.stu_gender, 'Not Set'), ' (', COUNT( stu_master_id ), ')') AS '0'", 'COUNT(stu_master_id) AS "1"'])->from('stu_master sm')->join('JOIN', 'stu_info si', 'si.stu_info_stu_master_id = sm.stu_master_id')->where(['sm.is_status' => '0'])->groupBy('si.stu_gender')->orderBy('si.stu_gender ASC')->all();
     if ($stuGenWise) {
         $stuGenWise[0][0] = "Not Set" . $stuGenWise[0][0];
     }
     /**
      * @Start Gender Wise Data Display For Employee
      */
     $empGenWise = (new \yii\db\Query())->select(["CONCAT(IFNULL(ei.emp_gender, 'Not Set'), ' (', COUNT( emp_master_id ), ')') AS '0'", 'COUNT(emp_master_id) AS "1"'])->from('emp_master em')->join('JOIN', 'emp_info ei', 'ei.emp_info_emp_master_id = em.emp_master_id')->where(['em.is_status' => '0'])->groupBy('ei.emp_gender')->orderBy('ei.emp_gender ASC')->all();
     if ($empGenWise) {
         $empGenWise[0][0] = "Not Set" . $empGenWise[0][0];
     }
     /**
      * @Start Year wise employee joining
      */
     $empYearWiseJoin = $depDisp = [];
     $empYearJoin = (new \yii\db\Query())->select(["CONCAT(DATE_FORMAT(ei.emp_joining_date, '%Y'), ' (', COUNT(em.emp_master_id), ')') AS 'yearDisp'", 'DATE_FORMAT(ei.emp_joining_date, "%Y") as "year"'])->from('emp_master em')->join('JOIN', 'emp_info ei', 'ei.emp_info_emp_master_id = em.emp_master_id')->where(['em.is_status' => '0'])->groupBy(['DATE_FORMAT(ei.emp_joining_date, "%Y")'])->orderBy('YEAR(ei.emp_joining_date) DESC')->limit('3')->all();
     foreach ($empYearJoin as $k => $v) {
         $yearResults = $deptCount = $depDisp = [];
         $deptData = \app\modules\employee\models\EmpDepartment::find()->where(['is_status' => 0])->limit(10)->orderBy('emp_department_id DESC')->asArray()->all();
         foreach ($deptData as $k => $dv) {
             $deptCountTmp = (new \yii\db\Query())->from('emp_master em')->join('JOIN', 'emp_info ei', 'ei.emp_info_emp_master_id = em.emp_master_id')->where(['YEAR(ei.emp_joining_date)' => $v['year'], 'emp_master_department_id' => $dv['emp_department_id'], 'is_status' => 0])->count();
             $deptCount[] = $deptCountTmp;
             $depDisp[] = $dv['emp_department_alias'];
         }
         $yearResults = ['name' => !empty($v['yearDisp']) ? $v['yearDisp'] : "Not Set", 'data' => $deptCount];
         $empYearWiseJoin[] = $yearResults;
     }
     return $this->render('index', ['stuCatWiseDataMale' => $stuCatWiseDataMale, 'stuCatWiseDataFemale' => $stuCatWiseDataFemale, 'stuCatWiseDisp' => $stuCatWiseDisp, 'stuStatusWise' => $stuStatusWise, 'stuGenWise' => $stuGenWise, 'empYearWiseJoin' => $empYearWiseJoin, 'depDisp' => $depDisp, 'courseData' => $courseData, 'stuStatusData' => $stuStatusData, 'empGenWise' => $empGenWise]);
 }
 public function importStuData($model)
 {
     $dispResults = [];
     $totalSuccess = 0;
     $objPHPExcel = PHPExcel_IOFactory::load($model->importFilePath . $model->importFile);
     $sheetData = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true);
     //print_r($sheetData); exit;
     unset($sheetData[1]);
     //start import student row by row
     foreach ($sheetData as $k => $line) {
         //print_r($line); exit;
         if (!array_filter($line)) {
             continue;
         }
         $line = array_map('trim', $line);
         $line = array_map(function ($value) {
             return empty($value) ? NULL : $value;
         }, $line);
         $stuMaster = new StuMaster();
         $stuInfo = new StuInfo();
         $stuInfo->scenario = 'import-stu';
         $stuAddress = new StuAddress();
         $user = new User();
         $auth_assign = new AuthAssignment();
         //set student info attributes
         $stuInfo->stu_unique_id = $stuInfo->getUniqueId();
         // Student Unique Id
         $stuInfo->stu_title = $this->valueReplace($line['A'], $stuInfo->getTitleOptions());
         //Title Name
         $stuInfo->stu_first_name = $line['B'];
         //First Name
         $stuInfo->stu_last_name = $line['C'];
         //Last Name
         $stuInfo->stu_dob = Yii::$app->dateformatter->getDateFormat($line['D']);
         //Date of Birth
         $stuInfo->stu_admission_date = Yii::$app->dateformatter->getDateFormat($line['H']);
         //Student Admission Date
         $stuInfo->stu_gender = $this->valueReplace($line['I'], $stuInfo->getGenderOptions());
         // Gender
         $stuInfo->stu_email_id = $line['J'];
         // Email ID
         $stuInfo->stu_mobile_no = $line['K'];
         // Mobile No
         //set student master attribute
         $stuMaster->stu_master_course_id = $this->valueReplace($line['E'], Courses::getStuCourse());
         // Course
         $stuMaster->stu_master_batch_id = $this->valueReplace($line['F'], Batches::getStuBatches());
         // Batch
         $stuMaster->stu_master_section_id = $this->valueReplace($line['G'], Section::getStuSection());
         // Section
         $stuMaster->stu_master_category_id = $this->valueReplace($line['L'], StuCategory::getStuCategoryId());
         //Admission Category
         $stuMaster->stu_master_nationality_id = $this->valueReplace($line['M'], Nationality::getNationality());
         //Nationality
         //set student address attribute
         $stuAddress->stu_cadd = $line['N'];
         //Current Address
         $stuAddress->stu_cadd_city = $this->valueReplace($line['O'], City::getAllCity());
         //City
         $stuAddress->stu_cadd_state = $this->valueReplace($line['P'], State::getAllState());
         //State
         $stuAddress->stu_cadd_country = $this->valueReplace($line['Q'], Country::getAllCountry());
         //Country
         $stuAddress->stu_cadd_pincode = $line['R'];
         //Pincode
         $stuAddress->stu_cadd_house_no = $line['S'];
         //House No
         $stuAddress->stu_cadd_phone_no = $line['T'];
         //Phone No
         //set user login info attributes
         $uniq_id = $stuInfo->getUniqueId();
         $login_id = \app\models\Organization::find()->one()->org_stu_prefix . $uniq_id;
         $user->user_login_id = $login_id;
         //user login id
         $user->user_password = md5($user->user_login_id . $user->user_login_id);
         //user password
         $user->user_type = "S";
         //user type
         $user->created_by = Yii::$app->getid->getId();
         //created by
         $user->created_at = new \yii\db\Expression('NOW()');
         //created at
         if ($user->validate() && $stuInfo->validate() && $stuAddress->validate()) {
             $transaction = Yii::$app->db->beginTransaction();
             try {
                 if ($stuInfo->save() && $user->save() && $stuAddress->save()) {
                     $stuMaster->stu_master_stu_info_id = $stuInfo->stu_info_id;
                     $stuMaster->stu_master_user_id = $user->user_id;
                     $stuMaster->stu_master_stu_address_id = $stuAddress->stu_address_id;
                     $stuMaster->created_by = Yii::$app->getid->getId();
                     $stuMaster->created_at = new \yii\db\Expression('NOW()');
                     if ($stuMaster->save()) {
                         $stuInfo->stu_info_stu_master_id = $stuMaster->stu_master_id;
                         if ($stuInfo->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);
                             $transaction->commit();
                             $totalSuccess += 1;
                             $dispResults[] = array_merge($line, ['type' => 'S', 'stuMasterId' => $stuMaster->stu_master_id, 'message' => 'Success']);
                         }
                     } else {
                         $dispResults[] = array_merge($line, ['type' => 'E', 'message' => Html::errorSummary($stuMaster)]);
                     }
                 }
                 // end stuInfo, user, StuAddress
                 $transaction->rollback();
             } catch (\Exception $e) {
                 $transaction->rollBack();
                 $dispResults[] = array_merge($line, ['type' => 'E', 'message' => $e->getMessage()]);
             }
         } else {
             $dispResults[] = array_merge($line, ['type' => 'E', 'message' => Html::errorSummary([$user, $stuInfo, $stuMaster, $stuAddress])]);
         }
         //end validated if
     }
     //end foreach
     return ['dispResults' => $dispResults, 'totalSuccess' => $totalSuccess];
 }
Exemple #4
0
 /**
  * @return student category
  */
 public function getStuCategoryId()
 {
     $dataTmp = StuCategory::find()->where(['is_status' => 0])->orderBy('stu_category_name')->all();
     $result = yii\helpers\ArrayHelper::map($dataTmp, 'stu_category_id', 'stu_category_name');
     return $result;
 }
Exemple #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getStuMasterCategory()
 {
     return $this->hasOne(StuCategory::className(), ['stu_category_id' => 'stu_master_category_id']);
 }
 /**
  * Finds the StuCategory model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return StuCategory the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = StuCategory::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }