public function search($params) { /*[5.1] JOIN TABLE */ $query = Dept::find(); $dataProvider_Dept = new ActiveDataProvider(['query' => $query]); /*[5.3] LOAD VALIDATION PARAMS */ /*LOAD FARM VER 1*/ $this->load($params); if (!$this->validate()) { return $dataProvider_Dept; } /*[5.4] FILTER WHERE LIKE (string/integer)*/ /* FILTER COLUMN Author -ptr.nov-*/ $query->andFilterWhere(['like', 'DEP_ID', $this->DEP_ID])->andFilterWhere(['like', 'DEP_NM', $this->DEP_NM]); return $dataProvider_Dept; }
<?php use yii\helpers\Html; use app\models\hrd\Corp; use app\models\hrd\Dept; use app\models\hrd\Jabatan; use app\models\hrd\Status; use app\models\hrd\Employe; use kartik\widgets\ActiveForm; use kartik\builder\Form; use kartik\builder\FormGrid; use kartik\widgets\FileInput; use yii\helpers\ArrayHelper; $form = ActiveForm::begin(['type' => ActiveForm::TYPE_HORIZONTAL]); //$form = ActiveForm::begin(['type'=>ActiveForm::TYPE_VERTICAL]); $nlDigit = Employe::find()->count() + 1; $nl = 'LG' . $nlDigit; echo FormGrid::widget(['model' => $model, 'form' => $form, 'autoGenerateColumns' => true, 'rows' => [['contentBefore' => '<legend class="text-info"><small>EMPLOYE IDENTITY</small></legend>', 'columns' => 1, 'autoGenerateColumns' => false, 'attributes' => ['employe_identity' => ['label' => 'Employee.ID', 'columns' => 5, 'attributes' => ['EMP_ID' => ['type' => Form::INPUT_TEXT, 'Form::SIZE_LARGE', 'options' => ['value' => $nl], 'columnOptions' => ['colspan' => 3]], 'EMP_NM' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Enter First Name...'], 'columnOptions' => ['colspan' => 4]], 'EMP_NM_BLK' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Enter Last Name...'], 'columnOptions' => ['colspan' => 4]]]]]], ['contentBefore' => '<legend class="text-info"><small>CORPORATE IDENTITY</small></legend>', 'columns' => 2, 'autoGenerateColumns' => false, 'attributes' => ['employe_identity' => ['label' => 'Company', 'columns' => 2, 'attributes' => ['EMP_CORP_ID' => ['type' => Form::INPUT_DROPDOWN_LIST, 'items' => ArrayHelper::map(Corp::find()->orderBy('SORT')->asArray()->all(), 'CORP_ID', 'CORP_NM'), 'columnOptions' => ['colspan' => 1]], 'DEP_ID' => ['type' => Form::INPUT_DROPDOWN_LIST, 'items' => ArrayHelper::map(Dept::find()->orderBy('SORT')->asArray()->all(), 'DEP_ID', 'DEP_NM'), 'hint' => 'Select Department', 'columnOptions' => ['colspan' => 1]], 'JAB_ID' => ['type' => Form::INPUT_DROPDOWN_LIST, 'items' => ArrayHelper::map(Jabatan::find()->orderBy('SORT')->asArray()->all(), 'JAB_ID', 'JAB_NM'), 'hint' => 'Select Position ', 'columnOptions' => ['colspan' => 1]], 'EMP_STS' => ['type' => Form::INPUT_DROPDOWN_LIST, 'items' => ArrayHelper::map(Status::find()->orderBy('SORT')->asArray()->all(), 'STS_ID', 'STS_NM'), 'hint' => 'Select Employee Status', 'columnOptions' => ['colspan' => 1]], 'EMP_JOIN_DATE' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => '\\kartik\\widgets\\DatePicker', 'options' => ['pluginOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd', 'todayHighlight' => true]], 'hint' => 'Enter Join Date (yyyy-mm-dd)', 'columnOptions' => ['colspan' => 1]], 'EMP_RESIGN_DATE' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => '\\kartik\\widgets\\DatePicker', 'options' => ['pluginOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd', 'todayHighlight' => true]], 'hint' => 'Enter Resign Date (yyyy-mm-dd)', 'columnOptions' => ['colspan' => 1]]]]]], ['contentBefore' => '<legend class="text-info"><small>EMPLOYEE PROFILE</small></legend>', 'columns' => 3, 'autoGenerateColumns' => false, 'attributes' => ['address_detail' => ['label' => 'Address', 'columns' => 6, 'attributes' => ['EMP_KTP' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Enter NO KTP...'], 'columnOptions' => ['colspan' => 2]], 'EMP_ALAMAT' => ['type' => Form::INPUT_TEXTAREA, 'options' => ['placeholder' => 'Enter address...'], 'columnOptions' => ['colspan' => 6]], 'EMP_ZIP' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Zip...'], 'columnOptions' => ['colspan' => 1]], 'EMP_HP' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Phone...'], 'columnOptions' => ['colspan' => 2]], 'EMP_GENDER' => ['type' => Form::INPUT_RADIO_LIST, 'items' => ['Male' => 'Male', 'Female' => 'Female'], 'options' => ['inline' => 'Male'], 'columnOptions' => ['colspan' => 4]], 'EMP_TGL_LAHIR' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => '\\kartik\\widgets\\DatePicker', 'options' => ['pluginOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd', 'todayHighlight' => true]], 'hint' => 'Enter birthday (yyyy-mm-dd)', 'columnOptions' => ['colspan' => 3]], 'EMP_EMAIL' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'acount@domain.com...', 'addon' => ['prepend' => ['content' => '@']]], 'columnOptions' => ['colspan' => 3]]]]]], ['columns' => 3, 'attributes' => ['address_detail' => ['label' => 'Picture', 'columns' => 6, 'attributes' => ['EMP_IMG' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => '\\kartik\\widgets\\FileInput', 'columnOptions' => ['colspan' => 2]]]]]], ['attributes' => ['actions' => ['type' => Form::INPUT_RAW, 'value' => '<div style="text-align: right; margin-top: 20px">' . Html::resetButton('Reset', ['class' => 'btn btn-default']) . ' ' . Html::submitButton('Submit', ['class' => 'btn btn-primary']) . '</div>']]]]]); ActiveForm::end();
<?php use yii\helpers\Html; use app\models\hrd\Dept; use kartik\widgets\ActiveForm; use kartik\builder\Form; use kartik\builder\FormGrid; use kartik\widgets\FileInput; use yii\helpers\ArrayHelper; $this->mddPage = 'hrd'; $form = ActiveForm::begin(['type' => ActiveForm::TYPE_VERTICAL]); $nlDigit = Dept::find()->count() + 1; $nl = 'LG' . $nlDigit; echo FormGrid::widget(['model' => $model, 'form' => $form, 'autoGenerateColumns' => true, 'rows' => [['contentBefore' => '<legend class="text-info"><small>DEPARTMENT IDENTITY</small></legend>', 'columns' => 1, 'autoGenerateColumns' => false, 'attributes' => ['employe_identity' => ['label' => 'Dept.ID', 'columns' => 5, 'attributes' => ['DEP_ID' => ['type' => Form::INPUT_TEXT, 'Form::SIZE_LARGE', 'options' => [], 'columnOptions' => ['colspan' => 3]], 'DEP_NM' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Department Name...'], 'columnOptions' => ['colspan' => 4]], 'DEP_DCRP' => ['type' => Form::INPUT_TEXTAREA, 'options' => ['placeholder' => 'Department Description ...'], 'columnOptions' => ['colspan' => 4]], 'SORT' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'SORT...'], 'columnOptions' => ['colspan' => 4]]]]]], ['attributes' => ['actions' => ['type' => Form::INPUT_RAW, 'value' => '<div style="text-align: right; margin-top: 20px">' . Html::resetButton('Reset', ['class' => 'btn btn-default']) . ' ' . Html::submitButton('Submit', ['class' => 'btn btn-primary']) . '</div>']]]]]); ActiveForm::end();
<?php use yii\helpers\Html; use yii\helpers\ArrayHelper; use app\models\hrd\Dept; use kartik\detail\DetailView; use yii\bootstrap\Modal; use kartik\widgets\ActiveField; use kartik\widgets\ActiveForm; use kartik\builder\Form; use kartik\icons\Icon; use kartik\widgets\Growl; $this->mddPage = 'hrd'; //$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Maxiprodaks'), 'url' => ['prodak']]; //$this->params['breadcrumbs'][] = $this->title; ?> <?php $Dept_MDL = Dept::find()->where(['DEP_ID' => $model->DEP_ID])->orderBy('SORT')->one(); $Val_Jabatan = $Dept_MDL->DEP_NM; $attribute = [['attribute' => 'DEP_ID'], ['attribute' => 'DEP_NM'], ['attribute' => 'DEP_DCRP', 'format' => 'raw', 'type' => DetailView::INPUT_TEXTAREA, 'widgetOptions' => ['data' => 'DEP_DCRP', 'options' => ['placeholder' => 'Position Description ...'], 'pluginOptions' => ['allowClear' => true]]], ['attribute' => 'SORT']]; echo DetailView::widget(['model' => $model, 'condensed' => true, 'hover' => true, 'mode' => DetailView::MODE_VIEW, 'panel' => ['heading' => $model->DEP_ID . '| ' . $model->DEP_NM, 'type' => DetailView::TYPE_INFO], 'attributes' => $attribute]); ?>
/** * CLASS TABLE FIND PrimaryKey * Example: Employe::find() */ protected function findModel($id) { if (($model = Dept::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function getDeptOne() { return $this->hasOne(Dept::className(), ['DEP_ID' => 'DEP_ID']); }