/** * 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; }
<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>";
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; }
<?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() ?>
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">
/** * 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}"); }