public function postReportExcel(Request $request) { $id = $request->input('report_id'); $report = \App\Models\Report::find($id); $organization = \App\Models\Organization::find($report->organization_id); $filename = $organization->inn . "_" . $report->quarter . "_квартал_" . $report->year . "_года"; $file = Excel::create($filename, function ($excel) use($report, $organization) { $excel->sheet(' Сводные данные по отчету', function ($sheet) use($report, $organization) { $sheet->mergeCells('A1:E1'); $sheet->mergeCells('A2:E2'); $sheet->mergeCells('A6:E6'); $sheet->mergeCells('A11:E11'); $sheet->mergeCells('A15:E15'); $sheet->cells('A1:E1', function ($cells) { $cells->setAlignment('center'); $cells->setValignment('middle'); }); $sheet->fromArray(array(array($organization->inn . " " . $organization->short_name . " " . $report->quarter . " квартал " . $report->year . " года"), array('Итоговые суммы по отчету'), array('Балансовая стоимость', 'Начисленный износ', 'Сумма списания', 'Остаточная стоимость'), array($report->report_total_carrying_amount, $report->report_wearout_value, $report->decommission_carrying_amount, $report->report_total_residual_value), array(''), array('Сводные данные по приобретению'), array('', 'Итого', ' Движимое имущество', 'Особо ценное движимое имущество', ' Здания и сооружения', 'Земельные участки', 'Автомобили'), array('Балансовая стоимость', $report->report_carrying_amount, $report->report_movables_carrying_amount, $report->report_value_movables_carrying_amount, $report->report_buildings_carrying_amount, $report->report_parcels_carrying_amount, $report->report_cars_carrying_amount), array('Остаточная стоимость', $report->report_residual_value, $report->report_movables_residual_value, $report->report_value_movables_residual_value, $report->report_buildings_residual_value, $report->report_parcels_residual_value, $report->report_cars_residual_value), array(''), array('Сводные данные по начислению износа'), array('Балансовая стоимость', 'Начисление износа', 'Остаточная стоимость'), array($report->report_wearout_carrying_amount, $report->report_wearout_value, $report->report_wearout_residual_value), array(''), array('Сводные данные по списанию основных средств'), array('Балансовая стоимость', 'Сумма списания'), array($report->decommission_carrying_amount, $report->decommission_sum)), null, 'A1', false, false); }); $excel->sheet('Приобретение', function ($sheet) use($report, $organization) { $sheet->mergeCells('A1:E1'); $sheet->cells('A1:E1', function ($cells) { $cells->setAlignment('center'); $cells->setValignment('middle'); }); $items = $report->items; $sheet->fromArray(array(array($organization->inn . " " . $organization->short_name . " " . $report->quarter . " квартал " . $report->year . " года"), array('Инвертарный номер', 'Наименование', 'Балансовая стоимость', 'Код ОКОФ', 'Остаточная стоимость')), null, 'A1', false, false); $row = 3; foreach ($items as $item) { $sheet->row($row, [$item->number, $item->name, $item->carrying_amount, $item->okof != 0 ? $item->okof : 'Земельный участок', isset($item->variable->residual_value) ? $item->variable->residual_value : 0]); $row++; } }); $excel->sheet('Начисление износа', function ($sheet) use($report, $organization) { $sheet->mergeCells('A1:E1'); $sheet->cells('A1:E1', function ($cells) { $cells->setAlignment('center'); $cells->setValignment('middle'); }); $depreciations = $report->depreciations()->get(['number', 'name', 'carrying_amount', 'sum', 'residual_value']); $sheet->fromArray(array(array($organization->inn . " " . $organization->short_name . " " . $report->quarter . " квартал " . $report->year . " года"), array('Инвертарный номер', 'Наименование', 'Балансовая стоимость', 'Начисленный износ', 'Остаточная стоимость')), null, 'A1', false, false); $sheet->fromModel($depreciations, null, 'A1', false, false); }); $excel->sheet('Списание', function ($sheet) use($report, $organization) { $sheet->mergeCells('A1:E1'); $sheet->cells('A1:E1', function ($cells) { $cells->setAlignment('center'); $cells->setValignment('middle'); }); $decommissions = $report->decommissions()->get(['number', 'name', 'carrying_amount', 'sum', 'date', 'type']); $sheet->fromArray(array(array($organization->inn . " " . $organization->short_name . " " . $report->quarter . " квартал " . $report->year . " года"), array('Инвертарный номер', 'Наименование', 'Балансовая стоимость', 'Сумма списания', 'Дата списания', 'Вид списания')), null, 'A1', false, false); $sheet->fromModel($decommissions, null, 'A1', false, false); }); })->store('xlsx', storage_path('excel/exports'), true); return Response::download($file['full']); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Organization::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(['org_id' => $this->org_id, 'created_at' => $this->created_at, 'created_by' => $this->created_by, 'updated_at' => $this->updated_at, 'updated_by' => $this->updated_by]); $query->andFilterWhere(['like', 'org_name', $this->org_name])->andFilterWhere(['like', 'org_alias', $this->org_alias])->andFilterWhere(['like', 'org_address_line1', $this->org_address_line1])->andFilterWhere(['like', 'org_address_line2', $this->org_address_line2])->andFilterWhere(['like', 'org_phone', $this->org_phone])->andFilterWhere(['like', 'org_email', $this->org_email])->andFilterWhere(['like', 'org_website', $this->org_website])->andFilterWhere(['like', 'org_logo', $this->org_logo])->andFilterWhere(['like', 'org_logo_type', $this->org_logo_type]); return $dataProvider; }
/** * Lists all Organization models. * @return mixed */ public function actionIndex() { $model = new Organization(); // This is used to search/filter organizations $dataProvider = null; if (isset($_GET['user_id'])) { $user_id = $_GET['user_id']; if ($user_id !== null) { $query = new Query(); $query->from(Organization::tableName()); $query->where(['user_id' => $user_id]); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 5]]); } } else { if (isset($_GET['search_keyword']) && $_GET['search_keyword'] !== null && strlen($_GET['search_keyword']) > 0 || isset($_GET['search_location']) && $_GET['search_location'] !== null && strlen($_GET['search_location']) > 0) { $search_keyword = $_GET['search_keyword']; if ($search_keyword !== null) { $query = new Query(); $query->from(Organization::tableName()); $query->where(['name' => $search_keyword]); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 5]]); } } else { $dataProvider = new ActiveDataProvider(['query' => Organization::find(), 'pagination' => ['pageSize' => 5]]); } } if ($model->load(Yii::$app->request->post())) { $query = new Query(); $query->from(Organization::tableName()); if (!is_null($model->org_type) && is_array($model->org_type)) { $query->where(['org_type' => array_map('intval', $model->org_type)]); } if (!is_null($model->work_domain) && is_array($model->work_domain)) { $query->andWhere(['work_domain' => array_map('intval', $model->work_domain)]); } if (isset($_GET['user_id'])) { $query->andWhere(['user_id' => $_GET['user_id']]); } if (isset($_GET['search_keyword']) && $_GET['search_keyword'] !== null && strlen($_GET['search_keyword']) > 0 || isset($_GET['search_location']) && $_GET['search_location'] !== null && strlen($_GET['search_location']) > 0) { $query->andWhere(['name' => $_GET['search_keyword']]); } $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 5]]); } return $this->render('index', ['model' => $model, 'dataProvider' => $dataProvider]); }
public function exportData($title = '', $filename = 'Edusec Pdf', $html = NULL) { $mpdf = new mPDF('utf-8', 'A4', 0, '', 15, 15, 25, 16, 4, 9, 'P'); $org = Organization::find()->asArray()->one(); $src = Yii::$app->urlManager->createAbsoluteUrl('site/loadimage'); $org_image = Html::img($src, ['alt' => 'No Image', 'width' => 90, 'height' => 70]); $org_name = $org['org_name']; $org_add = $org['org_address_line1'] . "<br/>" . $org['org_address_line2']; $mpdf->SetHTMLHeader('<table style="border-bottom:1.6px solid #999998;border-top:hidden;border-left:hidden;border-right:hidden;width:100%;"><tr style="border:hidden"><td vertical-align="center" style="width:35px;border:hidden" align="left">' . $org_image . '</td><td style="border:hidden;text-align:left;color:#555555;"><b style="font-size:22px;">' . $org_name . '</b><br/><span style="font-size:10.2px">' . $org_add . '</td></tr></table>'); $stylesheet = file_get_contents('css/pdf.css'); // external css $mpdf->WriteHTML($stylesheet, 0); $mpdf->WriteHTML('<watermarkimage src=' . $src . ' alpha="0.33" size="50,30"/>'); $mpdf->showWatermarkImage = true; $arr = ['odd' => ['L' => ['content' => $title, 'font-size' => 10, 'font-style' => 'B', 'font-family' => 'serif', 'color' => '#27292b'], 'C' => ['content' => 'Page - {PAGENO}/{nbpg}', 'font-size' => 10, 'font-style' => 'B', 'font-family' => 'serif', 'color' => '#27292b'], 'R' => ['content' => 'Printed @ {DATE j-m-Y}', 'font-size' => 10, 'font-style' => 'B', 'font-family' => 'serif', 'color' => '#27292b'], 'line' => 1], 'even' => []]; $mpdf->SetFooter($arr); $mpdf->WriteHTML('<sethtmlpageheader name="main" page="ALL" value="on" show-this-page="1">'); $mpdf->WriteHTML($html); $mpdf->Output($filename . '.pdf', "I"); }
public function store($id) { $organization = \App\Models\Organization::find($id); $reports = $organization->reports; if ($reports->count()) { $maxYear = \App\Models\Report::where('organization_id', '=', $id)->max('year'); $maxQuarter = \App\Models\Report::where('organization_id', '=', $id)->where('year', '=', $maxYear)->max('quarter'); if ($maxQuarter == 4) { $year = ++$maxYear; $report = new \App\Models\Report(); $report->year = $year; $report->quarter = 1; $report->organization_id = $id; $report->state = 'not_accepted'; $report->save(); return Redirect::action('AdminController@organization', [$id]); } else { $quarter = $maxQuarter + 1; $report = new \App\Models\Report(); $report->year = $maxYear; $report->quarter = $quarter; $report->organization_id = $id; $report->state = 'not_accepted'; $report->save(); return Redirect::action('AdminController@organization', [$id]); } } else { $report = new \App\Models\Report(); $report->year = 2015; $report->quarter = 1; $report->organization_id = $id; $report->state = 'not_accepted'; $report->save(); return Redirect::action('AdminController@organization', [$id]); } }
<h4 class="box-title"><i class="fa fa-info-circle"></i> <?php echo Yii::t('emp', 'Personal Details'); ?> </h4> </div> <div class="box-body"> <div class="col-xs-12 col-lg-12 col-sm-12"> <div class = "col-sm-4 col-xs-9"> <?php echo $form->field($info, 'emp_unique_id', ['inputOptions' => ['class' => 'form-control', 'placeholder' => 'Unique Id']])->textInput(['value' => $empno]); ?> </div> <div class="col-xs-3 col-sm-8 edusecArLangPopover" style="padding-top: 25px;"> <?php $emp_login_prefix = \app\models\Organization::find()->one()->org_emp_prefix; ?> <button type="button" class="btn btn-danger" data-html=true data-toggle="popover" title="<?php echo Yii::t('emp', 'Employee Login Note'); ?> " data-trigger="focus" data-content="<?php echo Yii::t('stu', 'Unique Id is used as login username with'); ?> <b><?php echo $emp_login_prefix; ?> </b><?php echo Yii::t('stu', 'prefix.'); ?> </br> <?php echo Yii::t('stu', 'Example: If Unique id : 123 so, Username :');
/** * Creates a new EmpMaster model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new EmpMaster(); $info = new EmpInfo(); $user = new User(); $address = new EmpAddress(); $auth_assign = new AuthAssignment(); $empUniqueId = EmpInfo::find()->max('emp_unique_id'); $empno = null; if (empty($empUniqueId)) { $empno = $info->emp_unique_id = 1; } else { $chkId = EmpInfo::find()->where(['emp_unique_id' => $empUniqueId])->exists(); if ($chkId) { $empno = $empUniqueId + 1; } else { $empno = $empUniqueId; } } 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::validate($info); } if (Yii::$app->request->isAjax) { \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; return ActiveForm::validate($model); } $model->attributes = $_POST['EmpMaster']; $info->attributes = $_POST['EmpInfo']; $info->emp_dob = Yii::$app->dateformatter->getDateFormat($_POST['EmpInfo']['emp_dob']); $info->emp_joining_date = Yii::$app->dateformatter->getDateFormat($_POST['EmpInfo']['emp_joining_date']); $info->emp_unique_id = $empno; if (empty($_POST['EmpInfo']['emp_email_id'])) { $info->emp_email_id = NULL; } else { $info->emp_email_id = strtolower($info->emp_email_id); } $user->user_login_id = \app\models\Organization::find()->one()->org_emp_prefix . $info->emp_unique_id; $user->user_password = md5($user->user_login_id . $user->user_login_id); $user->user_type = "E"; $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->emp_master_emp_address_id = $address->emp_address_id; $model->emp_master_emp_info_id = $info->emp_info_id; $model->emp_master_user_id = $user->user_id; $model->created_by = Yii::$app->getid->getId(); $model->created_at = new \yii\db\Expression('NOW()'); $model->save(false); $emp_info = EmpInfo::findOne($model->emp_master_emp_info_id); $emp_info->emp_info_emp_master_id = $model->emp_master_id; $emp_info->save(false); $auth_assign->item_name = 'Employee'; $auth_assign->user_id = $user->user_id; $auth_assign->created_at = date_format(date_create(), 'U'); $auth_assign->save(false); if ($model->save(false)) { return $this->redirect(['view', 'id' => $model->emp_master_id]); } else { return $this->render('create', ['model' => $model, 'info' => $info, 'user' => $user, 'empno' => $empno]); } } else { return $this->render('create', ['model' => $model, 'info' => $info, 'user' => $user, 'empno' => $empno]); } }
<p class="note">Fields with <span class="required"> <b style=color:red;>*</b></span> are required.</p> <?php $form = ActiveForm::begin(['id' => 'stu-master-form', 'enableAjaxValidation' => true, 'fieldConfig' => ['template' => "{label}{input}{error}"]]); ?> <div class="box box-solid box-info col-xs-12 col-lg-12 no-padding"> <div class="box-header with-border"> <h4 class="box-title"><i class="fa fa-info-circle"></i> Personal Details</h4> </div> <div class="box-body"> <div class="col-xs-12 col-sm-12 col-lg-12 no-padding"> <div class="col-xs-9 col-sm-4"> <?php $stu_login_prefix = \app\models\Organization::find()->one()->org_stu_prefix; ?> <?php echo $form->field($info, 'stu_unique_id', ['template' => '{label}{input}{error}'])->textInput(['value' => $uniq_id]); ?> </div> <div class="col-xs-3 col-sm-8" style="padding-top: 25px;"> <button type="button" class="btn btn-danger" data-html=true data-toggle="popover" title="Student Login Note" data-trigger="focus" data-content="Unique Id is used as login username with <b><?php echo $stu_login_prefix; ?> </b>prefix. </br> Example: If Unique id : 123 so, Username : <?php echo $stu_login_prefix; ?> 123"><i class="fa fa-info-circle"></i></button> </div> </div>
public function postCalcSumsFirstEnter($id) { $sum_org_movables_carrying_amount = 0; $sum_org_value_movables_carrying_amount = 0; $sum_org_buildings_carrying_amount = 0; $sum_org_parcels_carrying_amount = 0; $sum_org_movables_residual_value = 0; $sum_org_value_movables_residual_value = 0; $sum_org_buildings_residual_value = 0; $sum_org_cars_carrying_amount = 0; $sum_org_cars_residual_value = 0; $user = \App\Models\Organization::find($id)->user; $documents = \App\Models\User::find($user->id)->documents; $documents = $documents->where('document_type', 'residues_entering'); foreach ($documents as $document) { $type = $document->os_type; if ($type == 'movables') { $sum_org_movables_carrying_amount = $sum_org_movables_carrying_amount + $document->doc_carrying_amount; $sum_org_movables_residual_value = $sum_org_movables_residual_value + $document->doc_residual_value; } if ($type == 'value_movables') { $sum_org_value_movables_carrying_amount = $sum_org_value_movables_carrying_amount + $document->doc_carrying_amount; $sum_org_value_movables_residual_value = $sum_org_value_movables_residual_value + $document->doc_residual_value; } if ($type == 'car') { $sum_org_cars_carrying_amount = $sum_org_cars_carrying_amount + $document->doc_carrying_amount; $sum_org_cars_residual_value = $sum_org_cars_residual_value + $document->doc_residual_value; } if ($type == 'buildings') { $sum_org_buildings_carrying_amount = $sum_org_buildings_carrying_amount + $document->doc_carrying_amount; $sum_org_buildings_residual_value = $sum_org_buildings_residual_value + $document->doc_residual_value; } if ($type == 'parcels') { $sum_org_parcels_carrying_amount = $sum_org_parcels_carrying_amount + $document->doc_carrying_amount; } } $organization_id = $user->organization_id; $organization = \App\Models\Organization::find($organization_id); $organization->org_movables_carrying_amount = $sum_org_movables_carrying_amount; $organization->org_value_movables_carrying_amount = $sum_org_value_movables_carrying_amount + $sum_org_cars_carrying_amount; $organization->org_cars_carrying_amount = $sum_org_cars_carrying_amount; $organization->org_buildings_carrying_amount = $sum_org_buildings_carrying_amount; $organization->org_parcels_carrying_amount = $sum_org_parcels_carrying_amount; $organization->org_movables_residual_value = $sum_org_movables_residual_value; $organization->org_value_movables_residual_value = $sum_org_value_movables_residual_value + $sum_org_cars_residual_value; $organization->org_buildings_residual_value = $sum_org_buildings_residual_value; $organization->org_cars_residual_value = $sum_org_cars_residual_value; $organization->org_carrying_amount = $organization->org_movables_carrying_amount + $organization->org_value_movables_carrying_amount + $organization->org_buildings_carrying_amount + $organization->org_parcels_carrying_amount; $organization->org_residual_value = $organization->org_movables_residual_value + $organization->org_value_movables_residual_value + $organization->org_buildings_residual_value; $organization->save(); return redirect()->back(); }
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]; }
/** * 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]); } }
/** * Lists all Organization models. * @return mixed */ public function actionIndex() { $orgs = Organization::find()->all(); // $file = Yii::$app->basePath."/data.xlsx"; // $PHPExcel = \PHPExcel_IOFactory::load($file); // $sheet = $PHPExcel->getSheet(0); // 读取第一個工作表(编号从 0 开始) // $highestRow = $sheet->getHighestRow(); // 取得总行数 // $highestColumm = $sheet->getHighestColumn(); // 取得总列数 // $country_arr = array(); // $row = 8; // // for($row = 9;$row <= $highestRow;$row++){ // // $model = new CountryOrgRel(); // $org = array(); // for ($column = 9; $column <= 213; $column++) {//列数是以A列开始 // $column_name = \PHPExcel_Cell::stringFromColumnIndex($column); // $row_country_name = 8; // $val = (string)$sheet->getCell($column_name.$row_country_name)->getValue(); // $country_model = Country::findOne([ // 'name_english' => $val, // ]); // // echo isset($country_model->name)?"":$column_name.$row.":".$val; // // echo "</br>"; // if(isset($country_model->id)){ // for($row = 9; $row<=$highestRow;$row++){ // $val = (string)$sheet->getCell($column_name.$row)->getValue(); // $org_id = $row - 8 ; // $type = null; // if($val == "1"){ // $type = '1'; // // echo $country_model->name_english."___is".$row."_1<br/>"; // }else if(strtolower($val) == "o"){ // $type = "o"; // // echo $country_model->name_english."___o".$row."<br/>"; // }else if(strtolower($val) == "p"){ // $type = "p"; // // echo $country_model->name_english."___p".$row."<br/>"; // }else if(strtolower($val) == "m+"){ // $type = "m+"; // // echo $country_model->name_english."___m+".$row."_1<br/>"; // }else if(strtolower($val) == "o/m+"){ // $type = "o/m+"; // // echo $country_model->name_english."___o/m+".$row."_1<br/>"; // } // if($type){ // $model = new CountryOrgRel; // $model->org_id = $org_id; // $model->country_id = $country_model->id; // $model->type = $type; // $model->save(); // } // } // } // $country_arr[] = trim($val); // // echo $column_name.$row.":".$sheet->getCell($column_name.$row)->getValue()."<br />"; // } // // var_dump($country_arr); // // $model->name = $org['name']; // // $model->slug = $org['slug']; // // $model->founding_year = $org['founding_year']; // // $model->initiating_country = $org['initiating_country']; // // $model->funding_model = $org['funding_model']; // // $model->top_funding_country = $org['top_funding_country']; // // $model->responsible_person = $org['responsible_person']; // // $model->save(); // // } return $this->render('index', ['orgs' => $orgs]); }
/** * Creates a new Organization model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $chkOrg = Organization::find()->all(); if (!empty($chkOrg)) { throw new NotFoundHttpException('The requested page does not exist.'); } $model = new Organization(); if (isset($_POST['Organization']) && $model->load(Yii::$app->request->post())) { $model->attributes = $_POST['Organization']; $model->org_email = strtolower($_POST['Organization']['org_email']); $model->created_by = 1; $model->created_at = new \yii\db\Expression('NOW()'); ob_start(); if (!empty($_FILES['Organization']['tmp_name']['org_logo'])) { $file = UploadedFile::getInstance($model, 'org_logo'); $model->org_logo_type = $file->type; $fp = fopen($file->tempName, 'r'); $content = fread($fp, filesize($file->tempName)); fclose($fp); if ($model->org_logo_type == "image/png") { $src_img = imagecreatefrompng($file->tempName); $dst_img = imagecreatetruecolor(90, 70); imagealphablending($dst_img, false); imagesavealpha($dst_img, true); $transparent = imagecolorallocatealpha($dst_img, 255, 255, 255, 127); imagefilledrectangle($dst_img, 0, 0, 90, 70, $transparent); imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, 90, 70, imagesx($src_img), imagesy($src_img)); imagepng($dst_img); ob_start(); imagepng($dst_img); $image_string = ob_get_contents(); ob_end_flush(); } if ($model->org_logo_type == "image/jpg" || $model->org_logo_type == "image/jpeg") { $src_img = imagecreatefromjpeg($file->tempName); $dst_img = imagecreatetruecolor(90, 70); imagealphablending($dst_img, false); imagesavealpha($dst_img, true); $transparent = imagecolorallocatealpha($dst_img, 255, 255, 255, 127); imagefilledrectangle($dst_img, 0, 0, 90, 70, $transparent); imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, 90, 70, imagesx($src_img), imagesy($src_img)); imagejpeg($dst_img); ob_start(); imagepng($dst_img); $image_string = ob_get_contents(); ob_end_flush(); } if ($model->org_logo_type == "image/gif") { $src_img = imagecreatefromgif($file->tempName); $dst_img = imagecreatetruecolor(90, 70); imagealphablending($dst_img, false); imagesavealpha($dst_img, true); $transparent = imagecolorallocatealpha($dst_img, 255, 255, 255, 127); imagefilledrectangle($dst_img, 0, 0, 90, 70, $transparent); imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, 90, 70, imagesx($src_img), imagesy($src_img)); imagepng($dst_img); ob_start(); imagecreatefromgif($dst_img); $image_string = ob_get_contents(); ob_end_flush(); } $model->org_logo = $image_string; } if ($model->save()) { return $this->redirect(['view', 'id' => $model->org_id]); } } return $this->render('create', ['model' => $model]); }
public function residueStore($id) { $organization = \App\Models\Organization::find($id); $residue = $organization->residue; if (isset($residue)) { } else { $residue = new \App\Models\Residue(); $residue->organization_id = $id; $residue->state = 'not_accepted'; $residue->save(); } return redirect()->back(); }
/** * Ruturn institute-setup page if application is no-institute found. * @return mixed */ public function actionInstituteSetup() { $chkInstituteTbl = \app\models\Organization::find()->exists(); if ($chkInstituteTbl) { return $this->redirect(['user-setup']); } $model = new \app\models\Organization(); $model->scenario = 'insert'; if (isset($_POST['Organization']) && $model->load(Yii::$app->request->post())) { $image_string = null; $model->attributes = $_POST['Organization']; $model->org_email = strtolower($_POST['Organization']['org_email']); $model->created_at = new \yii\db\Expression('NOW()'); ob_start(); if (!empty($_FILES['Organization']['tmp_name']['org_logo'])) { $file = UploadedFile::getInstance($model, 'org_logo'); $model->org_logo_type = $file->type; $fp = fopen($file->tempName, 'r'); $content = fread($fp, filesize($file->tempName)); fclose($fp); if ($model->org_logo_type == "image/png") { $src_img = imagecreatefrompng($file->tempName); $dst_img = imagecreatetruecolor(90, 70); imagealphablending($dst_img, false); imagesavealpha($dst_img, true); $transparent = imagecolorallocatealpha($dst_img, 255, 255, 255, 127); imagefilledrectangle($dst_img, 0, 0, 90, 70, $transparent); imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, 90, 70, imagesx($src_img), imagesy($src_img)); imagepng($dst_img); ob_start(); imagepng($dst_img); $image_string = ob_get_contents(); ob_end_flush(); } if ($model->org_logo_type == "image/jpg" || $model->org_logo_type == "image/jpeg") { $src_img = imagecreatefromjpeg($file->tempName); $dst_img = imagecreatetruecolor(90, 70); imagealphablending($dst_img, false); imagesavealpha($dst_img, true); $transparent = imagecolorallocatealpha($dst_img, 255, 255, 255, 127); imagefilledrectangle($dst_img, 0, 0, 90, 70, $transparent); imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, 90, 70, imagesx($src_img), imagesy($src_img)); imagejpeg($dst_img); ob_start(); imagepng($dst_img); $image_string = ob_get_contents(); ob_end_flush(); } if ($model->org_logo_type == "image/gif") { $src_img = imagecreatefromgif($file->tempName); $dst_img = imagecreatetruecolor(90, 70); imagealphablending($dst_img, false); imagesavealpha($dst_img, true); $transparent = imagecolorallocatealpha($dst_img, 255, 255, 255, 127); imagefilledrectangle($dst_img, 0, 0, 90, 70, $transparent); imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, 90, 70, imagesx($src_img), imagesy($src_img)); imagepng($dst_img); ob_start(); imagecreatefromgif($dst_img); $image_string = ob_get_contents(); ob_end_flush(); } $model->org_logo = $image_string; } if ($model->save()) { return $this->redirect(['user-setup']); } } return $this->render('institute-setup', ['model' => $model]); }
public function actionLoadimage() { $model = \app\models\Organization::find()->asArray()->all(); header('Pragma: public'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Content-Transfer-Encoding: binary'); header('Content-type: ' . $model[0]['org_logo_type']); echo $model[0]['org_logo']; }
<html> <head> <title><?php echo $title; ?> </title> <link rel="stylesheet" type="text/css" href="<?php echo Yii::$app->request->baseUrl; ?> /css/print-receipt.css" media="screen, print, projection" /> </head> <body> <div id="pcr"> <?php $orgData = \app\models\Organization::find()->asArray()->one(); ?> <table class="table table-bordered table-main"> <tr> <td colspan=3 class="text-left padding-left padding-right" style="border-bottom:1px solid #000;height:80px"> <table> <tr> <td rowspan=2><?php echo Html::img(Yii::$app->urlManager->createUrl('/site/loadimage'), ['style' => 'width:70px; height:50px']); ?> </td> <td class="text-left org-title"><?php echo $orgData['org_name']; ?> </td>