public function detail($id) { $developer = Developer::findOrFail($id); $biodata = Biodata::findOrFail($developer->id); $education = Education::findOrFail($developer->id); return view('developers.detail', compact('developer', 'biodata', 'education')); }
/** * Updates an existing FarmerEducation model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); if ($model->education_id > 0) { $education = Education::findOne($model->education_id); } if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('update', ['model' => $model, 'education' => $education]); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Education::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'type_id' => $this->type_id, 'person_id' => $this->person_id, 'education_type_id' => $this->education_type_id, 'profession_id' => $this->profession_id, 'city_id' => $this->city_id, 'date_start' => $this->date_start, 'date_end' => $this->date_end, 'duration' => $this->duration, 'rec_status_id' => $this->rec_status_id, 'user_id' => $this->user_id, 'dc' => $this->dc]); $query->andFilterWhere(['like', 'firm', $this->firm])->andFilterWhere(['like', 'note', $this->note]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Education::find(); // add conditions that should always apply here $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } // grid filtering conditions $query->andFilterWhere(['id' => $this->id, 'sort' => $this->sort, 'created_at' => $this->created_at, 'created_by' => $this->created_by, 'updated_at' => $this->updated_at, 'updated_by' => $this->updated_by]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
/** * Finds the Education model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Education the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Education::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<h3 class="panel-title"> <span class="glyphicon glyphicon-file" aria-hidden="true"></span> <?php echo Html::encode($this->title); ?> </h3> </div> <div class="panel-body"> <?php echo $this->render('_search', ['model' => $farmerEducationReportSearch]); ?> <?php //$year = $educations = \app\models\Education::find()->all(); $idx_education = 0; ?> <table class="table table-condensed table-striped"> <tr> <th style="width:20px;" class="text-center">No</th> <th style="width:200px;" class="text-center">Level</th> <th style="width:150px;" class="text-center">Jumlah</th> <th style="width:50px;" class="text-center">Satuan</th> <th class="text-center">Keterangan</th> <th style="width:100px;" class="text-center">Data Masuk</th> </tr> <tbody> <?php foreach ($educations as $education) { echo "<tr>";
<?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a(Yii::t('app', '<span class=\'glyphicon glyphicon-plus-sign\'></span> Create Farmer Education'), ['create'], ['class' => 'btn btn-success']); ?> </p> <?php $state_id = Yii::$app->user->identity->state_id; $columns[] = ['class' => 'yii\\grid\\SerialColumn']; $columns[] = ['attribute' => 'education_id', 'format' => 'raw', 'value' => function ($data) { if ($data->education_id > 0) { return \app\models\Education::findOne($data->education_id)->name; } else { return "-"; } }]; if ($state_id > 0) { } else { $columns[] = ['attribute' => 'state_id', 'format' => 'raw', 'value' => function ($data) { if ($data->state_id > 0) { return \app\models\State::findOne($data->state_id)->name; } else { return "-"; } }]; } $columns[] = ['attribute' => 'year', 'headerOptions' => ['style' => 'width:75px;', 'class' => 'text-center'], 'contentOptions' => ['class' => 'text-center']];
public function actionExportExcel() { //$searchModel = new SecuritasSearch(); //$dataProvider = $searchModel->search(Yii::$app->request->queryParams); $session = Yii::$app->session; $renderFarmerEducationReport = $session->get('renderFarmerEducationReport'); $objReader = \PHPExcel_IOFactory::createReader('Excel2007'); $template = Yii::getAlias('@app/views/' . $this->id) . '/_export.xlsx'; $objPHPExcel = $objReader->load($template); $activeSheet = $objPHPExcel->getActiveSheet(); $border_style = ['borders' => ['allborders' => ['style' => \PHPExcel_Style_Border::BORDER_THIN, 'color' => ['argb' => '000000']]]]; $text_center = ['horizontal' => \PHPExcel_Style_Alignment::HORIZONTAL_CENTER]; $font_bold9 = ['font' => ['bold' => true, 'color' => ['rgb' => '000000'], 'size' => 9, 'name' => 'Calibri']]; $font_bold8 = ['font' => ['bold' => true, 'color' => ['rgb' => '000000'], 'size' => 8, 'name' => 'Calibri']]; $bg_gray = ['fill' => ['type' => \PHPExcel_Style_Fill::FILL_SOLID, 'color' => ['rgb' => 'dddddd']]]; $activeSheet->setCellValue('G2', 'print at ' . date('d-M-Y H:i:s')); $years = 'Semua'; if (!empty($renderFarmerEducationReport['years'])) { $years = implode(', ', $renderFarmerEducationReport['years']); } $activeSheet->setCellValue('C3', $years); $quarters = 'Semua'; if (!empty($renderFarmerEducationReport['quarters'])) { $quarters = implode(', ', $renderFarmerEducationReport['quarters']); } $activeSheet->setCellValue('C4', $quarters); $states = 'Semua'; if (!empty($renderFarmerEducationReport['states'])) { $states = implode(', ', $renderFarmerEducationReport['states']); } $activeSheet->setCellValue('C5', $states); $stateCount = $renderFarmerEducationReport['stateCount']; $startRow = 9; //$year = $educations = \app\models\Education::find()->all(); $idx_education = 0; $row = $startRow; $starRowTable = $row; $activeSheet->setCellValue('B' . $row, 'NO'); $activeSheet->setCellValue('C' . $row, 'LEVEL'); $activeSheet->setCellValue('D' . $row, 'JUMLAH'); $activeSheet->setCellValue('E' . $row, 'SATUAN'); $activeSheet->setCellValue('F' . $row, 'KETERANGAN'); $activeSheet->setCellValue('G' . $row, 'DATA MASUK'); $activeSheet->getStyle('B' . $row . ':G' . $row)->applyFromArray($bg_gray); foreach ($educations as $education) { $row++; $activeSheet->setCellValue('B' . $row, ++$idx_education); $activeSheet->setCellValue('C' . $row, $education->name); $where['education_id'] = $education->id; if (!empty($renderFarmerEducationReport['years'])) { $where['year'] = $renderFarmerEducationReport['years']; } if (!empty($renderFarmerEducationReport['quarters'])) { $where['quarter'] = $renderFarmerEducationReport['quarters']; } if (!empty($renderFarmerEducationReport['stateIds'])) { $where['state_id'] = $renderFarmerEducationReport['stateIds']; } $farmerEducation = \app\models\FarmerEducation::find()->select("\n sum(param) as sparam,\n group_concat(note) as gcnote,\n count(state_id) as cstate,\n ")->where($where)->asArray()->one(); $activeSheet->setCellValue('D' . $row, $farmerEducation['sparam']); $activeSheet->setCellValue('E' . $row, $education->unit); $activeSheet->setCellValue('F' . $row, $farmerEducation['gcnote']); $data = number_format($farmerEducation['cstate'] / $stateCount * 100, 2); $activeSheet->setCellValue('G' . $row, $data . '%'); } $activeSheet->getStyle("B" . $starRowTable . ":G" . $row)->applyFromArray($border_style); $activeSheet->getStyle("B" . $starRowTable . ":G" . $row)->getAlignment()->applyFromArray($text_center); $activeSheet->getStyle("F" . ($starRowTable + 1) . ":F" . $row)->getAlignment()->setWrapText(true); header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header('Content-Disposition: attachment;filename="' . $this->id . '_' . date('YmdHis') . '.xlsx"'); header('Cache-Control: max-age=0'); $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, "Excel2007"); $objWriter->save('php://output'); exit; }
/** * @return \yii\db\ActiveQuery */ public function getEducations() { return $this->hasMany(Education::className(), ['person_id' => 'id'])->orderBy('date_start'); }
<?php echo $form->field($model, 'person_id')->widget(\dosamigos\selectize\SelectizeDropDownList::className(), ['items' => ArrayHelper::map(\app\models\Person::find()->active()->all(), 'id', 'fullName'), 'options' => ['multiple' => false, 'class' => 'form-control', 'prompt' => ''], 'clientOptions' => ['selectOnTab' => true, 'openOnFocus' => false, 'persist' => false, 'maxItems' => 1, 'create' => false, 'valueField' => 'id', 'labelField' => 'fullName', 'searchField' => ['fullName']]])->hint(''); ?> <?php //echo $form->field($model, 'education_type_id')->textInput() ?> <?php echo $form->field($model, 'education_type_id')->radioList($model::$list_education_type, ['class' => 'btn-group', 'data-toggle' => 'buttons', 'unselect' => null, 'item' => function ($index, $label, $name, $checked, $value) { return '<label class="btn btn-default' . ($checked ? ' active' : '') . '">' . Html::radio($name, $checked, ['value' => $value, 'class' => 'project-status-btn']) . $label . '</label>'; }]); ?> <?php echo $form->field($model, 'firm')->widget(\dosamigos\selectize\SelectizeDropDownList::className(), ['items' => \yii\helpers\ArrayHelper::map(\app\models\Education::find()->select(['firm'])->active()->distinct()->orderBy('firm asc')->asArray()->all(), 'firm', 'firm'), 'options' => ['multiple' => false, 'class' => 'form-control', 'prompt' => ''], 'clientOptions' => ['selectOnTab' => true, 'openOnFocus' => false, 'persist' => false, 'maxItems' => 1, 'create' => true, 'valueField' => 'firm', 'labelField' => 'firm', 'searchField' => ['firm']]]); ?> <?php //echo $form->field($model, 'profession_id')->textInput() ?> <?php //echo $form->field($model, 'profession_id',['inputOptions' => ['class' => 'form-control']])->dropDownList(ArrayHelper::map(\app\models\Profession::find()->active()->all(), 'id', 'name'), ['prompt' => '']) ?> <?php echo $form->field($model, 'profession_id')->widget(\dosamigos\selectize\SelectizeDropDownList::className(), ['items' => ArrayHelper::map(\app\models\Profession::find()->active()->all(), 'id', 'name'), 'options' => ['multiple' => false, 'class' => 'form-control', 'prompt' => ''], 'clientOptions' => ['openOnFocus' => false, 'persist' => false, 'maxItems' => 1, 'create' => false, 'valueField' => 'id', 'labelField' => 'name', 'searchField' => ['name']]]); ?> <?php //echo= $form->field($model, 'city_id')->textInput() ?>
public function importDBFs($br) { //(Request $request){ $logfile = base_path() . DIRECTORY_SEPARATOR . 'logs' . DIRECTORY_SEPARATOR . 'db-import.txt'; //return Employee::with('childrens')->get(); $import = true; if ($import) { $db = dbase_open('D:\\GI\\' . $br . '\\GC113015\\PAY_MAST.DBF', 0); } else { $db = dbase_open('D:\\GI\\MAR\\GC113015\\PAY_MAST.DBF', 0); } if ($db) { $header = dbase_get_header_info($db); if (!$import) { echo '<table cellpadding="2" cellspacing="0" border="1"><thead>'; } // render table header if (!$import) { echo '<tr>'; foreach ($header as $key => $value) { echo '<th>' . $value['name'] . '</th>'; } echo '</tr>'; } // render table body $children_ctr = 0; $ecperson_ctr = 0; $education_ctr = 0; $work_ctr = 0; $spouse_ctr = 0; $record_numbers = dbase_numrecords($db); for ($i = 1; $i <= $record_numbers; $i++) { $row = dbase_get_record_with_names($db, $i); if ($i == 1) { $brcode = trim($row['BRANCH']); } if ($import) { $e = Employee::where('code', trim($row['MAN_NO']))->first(); if (!is_null($e)) { continue; } } $employee = new Employee(); $employee->code = trim($row['MAN_NO']); $employee->lastname = trim($row['LAST_NAM']); $employee->firstname = trim($row['FIRS_NAM']); $employee->middlename = trim($row['MIDL_NAM']); $employee->companyid = trim($this->getCompanyId($row['CO_NAME'])); $employee->id = $employee->get_uid(); $branch = Branch::where('code', trim($row['BRANCH']))->first(); $employee->branchid = is_null($branch) ? '' : $branch->id; $employee->deptid = $this->getDeptId($row['DEPT']); $employee->positionid = $this->getPositionId(trim($row['POSITION'])); $employee->paytype = 2; $employee->ratetype = 2; $employee->rate = trim($row['RATE_HR']); $employee->ecola = trim($row['RATE_HR']); $employee->allowance1 = trim($row['ALW1_RATE']); $employee->allowance2 = trim($row['ALW2_RATE']); $employee->phicno = trim($row['PHEALTH_NO']); $employee->hdmfno = trim($row['PBIG_NO']); $employee->tin = trim($row['WTAX_NO']); $employee->sssno = trim($row['SSS_NO']); $employee->empstatus = $this->getEmpstatus(trim($row['EMP_STUS'])); $employee->datestart = Carbon::parse(trim($row['STARTED'])); //$employee->datehired = trim($row['ALW2_RATE']); //$employee->datestop = trim($row['ALW2_RATE']); $employee->punching = 1; $employee->processing = 1; $employee->address = trim($row['ADDRESS1']) . ', ' . trim($row['ADDRESS2']) . ', ' . trim($row['ADDRESS3']); $employee->phone = trim($row['TEL']); //$employee->fax = trim($row['TEL']); $employee->mobile = trim($row['CEL']); $employee->email = trim($row['EMAIL']); $employee->gender = trim($row['SEX']) == 'M' ? 1 : 2; $employee->civstatus = trim($row['CIV_STUS']) == 'SINGLE' ? 1 : 2; $employee->height = str_replace("'", '.', trim($row['HEIGHT'])); $employee->weight = trim($row['WEIGHT']); $employee->birthdate = Carbon::parse(trim($row['BIRTHDATE'])); $employee->birthplace = trim($row['BIRTHPLC']); $employee->religionid = trim($this->getReligionId($row['RELIGION'])); $employee->hobby = trim($row['HOBBIES']); $employee->notes = 'UNIFORM:' . trim($row['UNIFORM']) . '; ' . 'SP_NOTES1:' . trim($row['SP_NOTES1']) . '; ' . 'SP_NOTES2:' . trim($row['SP_NOTES2']) . '; '; $childrens = []; if (!empty(trim($row['CHILDREN1'])) && trim($row['CHILDREN1']) != 'N/A') { $c1 = new Children(); $c1->firstname = trim($row['CHILDREN1']); $c1->lastname = $employee->lastname; $c1->id = $c1->get_uid(); array_push($childrens, $c1); $children_ctr++; } if (!empty(trim($row['CHILDREN2'])) && trim($row['CHILDREN2']) != 'N/A') { $c2 = new Children(); $c2->firstname = trim($row['CHILDREN2']); $c2->lastname = $employee->lastname; $c2->id = $c2->get_uid(); array_push($childrens, $c2); $children_ctr++; } if ($import) { $employee->childrens()->saveMany($childrens); } if (!empty(trim($row['EMER_NAM'])) && trim($row['EMER_NAM']) != 'N/A') { $emer = explode(' ', trim($row['EMER_NAM'])); $e = new Ecperson(); $e->firstname = empty($emer[0]) ? '' : $emer[0]; $e->lastname = empty($emer[1]) ? '' : $emer[1]; $e->mobile = trim($row['EMER_NO']); $e->id = $e->get_uid(); $ecperson_ctr++; if ($import) { $employee->ecperson()->save($e); } } if (!empty(trim($row['EDUCATION'])) && trim($row['EDUCATION']) != 'N/A') { $edu = new Education(); $edu->school = trim($row['EDUCATION']); $edu->id = $edu->get_uid(); if ($import) { $employee->educations()->saveMany([$edu]); } $education_ctr++; } $works = []; if (!empty(trim($row['WORKHIST1'])) && trim($row['WORKHIST1']) != 'N/A') { $w1 = new Workexp(); $w1->company = trim($row['WORKHIST1']); $w1->id = $w1->get_uid(); array_push($works, $w1); $work_ctr++; } if (!empty(trim($row['WORKHIST2'])) && trim($row['WORKHIST2']) != 'N/A') { $w2 = new Workexp(); $w2->company = trim($row['WORKHIST2']); $w2->id = $w2->get_uid(); array_push($works, $w2); $work_ctr++; } if (!empty(trim($row['WORKHIST3'])) && trim($row['WORKHIST3']) != 'N/A') { $w3 = new Workexp(); $w3->company = trim($row['WORKHIST3']); $w3->id = $w3->get_uid(); array_push($works, $w3); $work_ctr++; } if (!empty(trim($row['WORKHIST4'])) && trim($row['WORKHIST4']) != 'N/A') { $w4 = new Workexp(); $w4->company = trim($row['WORKHIST2']); $w4->id = $w4->get_uid(); array_push($works, $w4); $work_ctr++; } if ($import) { $employee->workexps()->saveMany($works); } if (!empty(trim($row['SPOUS_NAM'])) && trim($row['SPOUS_NAM']) != 'N/A' && trim($row['SPOUS_NAM']) != 'NA/A') { $sp = preg_split("/\\s+(?=\\S*+\$)/", trim($row['SPOUS_NAM'])); $spou = new Spouse(); $spou->firstname = empty($sp[0]) ? '' : $sp[0]; $spou->lastname = empty($sp[1]) ? '' : $sp[1]; $spou->id = $spou->get_uid(); $spouse_ctr++; if ($import) { $employee->spouse()->save($spou); } } if ($import) { $employee->save(); } if (!$import) { echo '<tr>'; foreach ($header as $key => $value) { //if($value['name']=='CO_NAME') //echo '<td>'.$this->getCompanyId($row[$value['name']]).'</td>'; //else echo '<td>' . $row[$value['name']] . '</td>'; } echo '</tr>'; } } if ($import) { echo $brcode . ' imported! </br>'; $handle = fopen($logfile, 'a'); $content = $brcode . "\n\temployee:\t\t" . $record_numbers . "\n"; $content .= "\tspouse:\t\t\t" . $spouse_ctr . "\n"; $content .= "\tchildren:\t\t" . $children_ctr . "\n"; $content .= "\tecperson:\t\t" . $ecperson_ctr . "\n"; $content .= "\tworkexp:\t\t" . $work_ctr . "\n"; fwrite($handle, $content); fclose($handle); } dbase_close($db); } }
use app\models\State; /* @var $this yii\web\View */ /* @var $model app\models\FarmerEducation */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="farmer-education-form"> <?php $form = ActiveForm::begin(); ?> <div class="row"> <div class="col-md-4"> <?php $data = ArrayHelper::map(Education::find()->select(['id', 'name'])->asArray()->all(), 'id', 'name'); echo $form->field($model, 'education_id')->widget(Select2::classname(), ['data' => $data, 'options' => ['placeholder' => 'Pilih Education ...', 'onchange' => ' location.href = "' . Url::to(['create']) . '"+"?education_id="+$(this).val() ', 'disabled' => !$model->isNewRecord ? true : false], 'pluginOptions' => ['allowClear' => true]]); ?> <?php $data = ArrayHelper::map(State::find()->select(['id', 'name'])->asArray()->all(), 'id', 'name'); echo $form->field($model, 'state_id')->widget(Select2::classname(), ['data' => $data, 'options' => ['placeholder' => 'Pilih State ...', 'disabled' => Yii::$app->user->identity->state_id > 0 ? true : false], 'pluginOptions' => ['allowClear' => true]]); ?> </div> </div> <div class="row"> <div class="col-md-2">
/** * @return \yii\db\ActiveQuery */ public function getEducation() { return $this->hasOne(Education::className(), ['id' => 'education_id']); }
/** * Remove the specified resource from storage. * * @param int $facultyId * @param int $id * @return Response */ public function destroy($facultyId, $id) { $education = Education::find($id); $education->delete(); Flash::success('Faculty education deleted successfully'); return redirect("/admin/faculty/{$facultyId}"); }