public function getType($name) { $model = Acctype::find()->where(['name' => $name])->one(); //print_r($this); return $model->id; }
/** * Manages all models. */ public function actionAdmin($id = 0) { $types = Acctype::find()->All(); $list = array(); $searchModel = new \app\models\AccountsSearch(); $searchModel->type = $id; $dataProvider = $searchModel->search(Yii::$app->request->queryParams); if (Yii::$app->request->get('AccountsSearch')) { $searchModel->search(Yii::$app->request->get()); return $this->renderPartial('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); } foreach ($types as $type1) { $searchModel = new \app\models\AccountsSearch(); $searchModel->type = $type1->id; $dataProvider = $searchModel->search(Yii::$app->request->queryParams); $array = ['linkOptions' => ['data-id' => $type1->id], 'content' => $this->renderPartial('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]), 'label' => Yii::t('app', $type1->desc)]; if ($id == $type1->id) { $array['active'] = true; } $list[] = $array; } return $this->render('admin', ['list' => $list, 'type' => $id]); /* return $this->render('admin', array( 'model' => $model, 'type' => $type )); */ }
echo \yii\helpers\Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => 'btn btn-success']); ?> </div> <?php kartik\form\ActiveForm::end(); $this->registerJs("\$('#mailtemplate-entity_type').change(function(){\r\n change();\r\n });", \yii\web\View::POS_READY); ?> <script type="text/javascript"> function change(){ var accList=<?php echo \yii\helpers\JSON::encode(\yii\helpers\ArrayHelper::map(Acctype::find()->All(), 'id', 'name')); ?> ; var docList=<?php echo \yii\helpers\JSON::encode(\yii\helpers\ArrayHelper::map(Doctype::find()->All(), 'id', 'name')); ?> ; //console.log(docList.length); if($("#mailtemplate-entity_type").val()=='app\\models\\Accounts'){ loadList(accList); }else{ loadList(docList); } }
<?php /*********************************************************************************** * The contents of this file are subject to the GNU AFFERO GENERAL PUBLIC LICENSE Version 3 * ("License"); You may not use this file except in compliance with the GNU AFFERO GENERAL PUBLIC LICENSE Version 3 * The Original Code is: Linet 3.0 Open Source * The Initial Developer of the Original Code is Adam Ben Hur. * All portions are Copyright (C) Adam Ben Hur. * All Rights Reserved. ************************************************************************************/ $this->params["breadcrumbs"] = array(Yii::t('app', 'Account Categories') => array('index'), Yii::t('app', 'Manage')); $this->params["menu"] = array(array('label' => Yii::t('app', 'Create Account Category'), 'url' => array('create'))); app\widgets\MiniForm::begin(array('header' => Yii::t('app', "Manage Account Categories"))); ?> <?php echo app\widgets\GridView::widget(array('id' => 'bank-name-grid', 'dataProvider' => $model->search([]), 'filterModel' => $model, 'columns' => array('name', ['attribute' => 'type_id', 'filter' => \yii\helpers\ArrayHelper::map(\app\models\Acctype::find()->All(), 'id', 'name'), 'value' => function ($data) { return $data->TypeName(); }], array('class' => 'yii\\grid\\ActionColumn')))); app\widgets\MiniForm::end();
echo $form->field($model, 'to_date')->widget(kartik\datecontrol\DateControl::classname(), ['type' => 'date']); ?> <?php echo $form->field($model, 'acc'); ?> <?php echo Yii::t('app', 'Examples'); ?> : <br/> 1-200<br/> 1,3,5<br/> 1-10,15-20,25-30<br/> <?php $temp = \yii\helpers\ArrayHelper::map(Acctype::find()->All(), 'id', 'name'); $temp[""] = Yii::t('app', 'Choose Type'); echo $form->field($model, 'type')->widget(kartik\select2\Select2::className(), ['data' => $temp]); ?> <div class="form-actions"> <?php echo \yii\helpers\Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-success']); ?> </div> </div> </div>