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]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = StuInfo::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $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_info_id' => $this->stu_info_id, 'stu_dob' => $this->stu_dob, 'stu_admission_date' => $this->stu_admission_date, 'stu_mobile_no' => $this->stu_mobile_no, 'stu_info_stu_master_id' => $this->stu_info_stu_master_id]); $query->andFilterWhere(['like', 'stu_unique_id', $this->stu_unique_id])->andFilterWhere(['like', 'stu_title', $this->stu_title])->andFilterWhere(['like', 'stu_first_name', $this->stu_first_name])->andFilterWhere(['like', 'stu_middle_name', $this->stu_middle_name])->andFilterWhere(['like', 'stu_last_name', $this->stu_last_name])->andFilterWhere(['like', 'stu_gender', $this->stu_gender])->andFilterWhere(['like', 'stu_email_id', $this->stu_email_id])->andFilterWhere(['like', 'stu_bloodgroup', $this->stu_bloodgroup])->andFilterWhere(['like', 'stu_birthplace', $this->stu_birthplace])->andFilterWhere(['like', 'stu_religion', $this->stu_religion])->andFilterWhere(['like', 'stu_photo', $this->stu_photo])->andFilterWhere(['like', 'stu_languages', $this->stu_languages]); return $dataProvider; }
public function actionStudentProfilePdf($sid) { $nationality = $stuAdd = []; $stuMaster = StuMaster::findOne($sid); $stuDocs = StuDocs::find()->where(['stu_docs_stu_master_id' => $sid])->join('join', 'document_category dc', 'dc.doc_category_id = stu_docs_category_id AND dc.is_status <> 2')->all(); $stuInfo = StuInfo::find()->where(['stu_info_stu_master_id' => $sid])->one(); $stuCourse = Courses::findOne($stuMaster->stu_master_course_id); $stuBatch = Batches::findOne($stuMaster->stu_master_batch_id); $stuSection = Section::findOne($stuMaster->stu_master_section_id); $stuGuard = StuGuardians::findAll(['guardia_stu_master_id' => $sid]); $sDocs = new StuDocs(); if ($stuMaster->stu_master_nationality_id !== null) { $nationality = Nationality::findOne($stuMaster->stu_master_nationality_id)->nationality_name; } if ($stuMaster->stu_master_stu_address_id !== null) { $stuAdd = StuAddress::findOne($stuMaster->stu_master_stu_address_id); } $html = $this->renderPartial('/stu-master/stuprofilepdf', ['stuDocs' => $stuDocs, 'stuMaster' => $stuMaster, 'stuInfo' => $stuInfo, 'nationality' => $nationality, 'stuBatch' => $stuBatch, 'stuCourse' => $stuCourse, 'stuSection' => $stuSection, 'stuAdd' => $stuAdd, 'stuGuard' => $stuGuard, 'sDocs' => $sDocs]); $fName = $stuInfo->stu_first_name . "_" . $stuInfo->stu_last_name . "_" . date('Ymd-His'); return Yii::$app->pdf->exportData(Yii::t('report', 'Student Report'), $fName, $html); }
echo $model->isNewRecord ? 'box-success' : 'box-info'; ?> box col-xs-12 col-lg-12 no-padding"> <div class="box-header with-border"> <h3 class="box-title"><i class="fa fa-user"></i><sub><i class="fa fa-info-circle"></i></sub><?php echo Yii::t('fees', 'Student Details'); ?> </h3> </div> <div class="box-body no-padding"> <table class="table"> <col class="col-sm-2"> <col class="col-sm-2"> <col class="col-sm-8"> <?php $imgData = \app\modules\student\models\StuInfo::getStuPhoto($stuData->stuMasterStuInfo->stu_photo); $displayImg = Html::img($imgData, ['alt' => 'No Image', 'class' => 'img-circle edusec-img-disp']); ?> <tr class="visible-xs text-center"> <td colspan="2"><?php echo $displayImg; ?> </td> </tr> <tr> <td rowspan="5" class="hidden-xs"><?php echo $displayImg; ?> </td> <th><?php echo Yii::t('fees', 'Name');
if ($s == 'stu_email_id') { if (StuInfo::findOne($sd['stu_master_stu_info_id'])->{$s} != null) { echo "<td style='text-align:center;width:250px;'>" . StuInfo::findOne($sd['stu_master_stu_info_id'])->{$s} . "</td>"; } else { echo "<td style='text-align:center;'> </td>"; } } else { if ($s == 'stu_admission_date') { $date = StuInfo::findOne($sd['stu_master_stu_info_id'])->{$s}; echo "<td style='text-align:center; width:107px;'>" . date('d-m-Y', strtotime($date)) . "</td>"; } else { if ($s == 'stu_dob') { $dob = StuInfo::findOne($sd['stu_master_stu_info_id'])->{$s}; echo "<td style='text-align:center; width:107px;'>" . date('d-m-Y', strtotime($dob)) . "</td>"; } else { echo "<td style='text-align:center;'>" . StuInfo::findOne($sd['stu_master_stu_info_id'])->{$s} . "</td>"; } } } } } } } } } } $i++; echo "</tr>"; } echo "</table>"; } else {
if ($s == 'stu_email_id') { if (StuInfo::findOne($sd['stu_master_stu_info_id'])->{$s} != null) { echo "<td class='text-center'>" . StuInfo::findOne($sd['stu_master_stu_info_id'])->{$s} . "</td>"; } else { echo "<td class='text-center'> </td>"; } } else { if ($s == 'stu_admission_date') { $date = StuInfo::findOne($sd['stu_master_stu_info_id'])->{$s}; echo "<td class='text-center'>" . date('d-m-Y', strtotime($date)) . "</td>"; } else { if ($s == 'stu_dob') { $dob = StuInfo::findOne($sd['stu_master_stu_info_id'])->{$s}; echo "<td class='text-center'>" . date('d-m-Y', strtotime($dob)) . "</td>"; } else { echo "<td class='text-center'>" . StuInfo::findOne($sd['stu_master_stu_info_id'])->{$s} . "</td>"; } } } } } } } } } } $i++; echo "</tr>"; } echo "</table>"; }
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]; }
public function actionStuPhoto($sid) { $model = $this->findModel($sid); $info = StuInfo::findOne($model->stu_master_stu_info_id); $old_info = StuInfo::findOne($model->stu_master_stu_info_id); $info->scenario = 'photo-upload'; if ($info->load(Yii::$app->request->post())) { $info->attributes = $_POST['StuInfo']; $info->stu_photo = UploadedFile::getInstance($info, 'stu_photo'); $old_photo = $old_info->stu_photo; $model->updated_by = Yii::$app->getid->getId(); $model->updated_at = new \yii\db\Expression('NOW()'); if ($info->stu_photo == NULL) { $old_photo = $old_info->stu_photo; $valid_photo = true; } else { $valid_photo = $info->validate(); } if ($valid_photo) { if ($info->stu_photo != NULL) { $newfname = ''; $ext = substr(strrchr($info->stu_photo, '.'), 1); //following thing done for deleting previously uploaded photo $photo = $old_photo; $dir1 = Yii::getAlias('@webroot') . '/data/stu_images/'; if (file_exists($dir1 . $photo) && $photo != NULL) { unlink($dir1 . $photo); } if ($ext != null) { $newfname = $info->stu_first_name . "_" . $info->stu_unique_id . '.' . $ext; $info->stu_photo->saveAs(Yii::getAlias('@webroot') . '/data/stu_images/' . ($info->stu_photo = $newfname)); } } } if ($info->save(false)) { return $this->redirect(['view', 'id' => $model->stu_master_id]); } else { return $this->renderAjax('photo_form', ['model' => $model, 'info' => $info]); } } else { return $this->renderAjax('photo_form', ['model' => $model, 'info' => $info]); } }
public function getUniqueId() { $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; } } return $uniq_id; }
/** * Finds the StuInfo model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return StuInfo the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = StuInfo::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
if (StuInfo::findOne($sd['stu_master_stu_info_id'])->{$s} != null) { echo "<tr><td class='label'>" . Yii::t('report', 'Email Id') . "</td> <td>" . StuInfo::findOne($sd['stu_master_stu_info_id'])->{$s} . "</td> </tr>"; } else { echo "<tr><td class='label'>" . Yii::t('report', 'Email ID') . "</td> <td > </td></tr>"; } } else { if ($s == 'stu_admission_date') { $date = StuInfo::findOne($sd['stu_master_stu_info_id'])->{$s}; echo "<tr><td class='label'>" . Yii::t('report', 'Admission Date') . "</td><td >" . Yii::$app->formatter->asDate($date) . "</td></tr>"; } else { if ($s == 'stu_dob') { $dob = StuInfo::findOne($sd['stu_master_stu_info_id'])->{$s}; echo "<tr><td class='label'>Birth Date</td><td >" . Yii::$app->formatter->asDate($dob) . "</td></tr>"; } else { echo "<tr><td class='label'>" . Html::ActiveLabel($student_info, $s) . "</td>"; echo "<td>" . StuInfo::findOne($sd['stu_master_stu_info_id'])->{$s} . "</td></tr>"; } } } } } } } } } } echo "</table>"; $i++; } } else { echo "<h1 style=\"color:red;text-align:center;margin-top:10%;margin-right:60%\">" . Yii::t('report', 'No Record To Display') . "</h1>";
/** * @return \yii\db\ActiveQuery */ public function getStuMasterStuInfo() { return $this->hasOne(StuInfo::className(), ['stu_info_id' => 'stu_master_stu_info_id']); }
public function actionUpdatestudloginid($id) { $model = $this->findModel($id); $student_data = StuMaster::find()->where(['stu_master_user_id' => $_REQUEST['id']])->one(); $student_info = StuInfo::findOne($student_data->stu_master_stu_info_id)->stu_first_name; if (isset($_POST['User'])) { $model->attributes = $_POST['User']; $model->user_login_id = $_POST['User']['user_login_id']; \Yii::$app->session->setFlash('resetstudloginid', "<i class='glyphicon glyphicon-info-sign'></i> " . $student_info . "'s Login id is Reset"); if ($model->save()) { \Yii::$app->session->setFlash('resetstudloginid', "<i class='glyphicon glyphicon-info-sign'></i> " . $student_info . "'s Login id is Reset"); return $this->redirect(['resetstudloginid']); } } return $this->render('updatestudloginid', ['model' => $model]); }