/** * Finds the Clavepresupuestal model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Clavepresupuestal the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Clavepresupuestal::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('La página solicitada no existe.'); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Clavepresupuestal::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]); $query->andFilterWhere(['like', 'clavepresupuestal', $this->clavepresupuestal])->andFilterWhere(['like', 'descripcion', $this->descripcion]); return $dataProvider; }
/* @var $model backend\modules\mrp\models\Insumo */ /* @var $modelsPresentacion \backend\modules\mrp\models\Presentacion */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="insumo-form"> <?php $form = ActiveForm::begin(['id' => 'dynamic-form']); ?> <div class="row"> <div class="col-xs-3"> <?php $lista = \yii\helpers\ArrayHelper::map(\backend\modules\mrp\models\Clavepresupuestal::find()->asArray()->all(), 'id', 'clavepresupuestal'); echo $form->field($model, 'clavepresupuestal_id')->dropDownList($lista); ?> </div> <div class="col-xs-4"> <?php echo $form->field($model, 'insumo_generico')->textInput(['maxlength' => true]); ?> </div> <div class="col-xs-4"> <?php $lista = \yii\helpers\ArrayHelper::map(\backend\modules\mrp\models\Unidadmedida::find()->asArray()->all(), 'id', 'descripcion'); echo $form->field($model, 'unidad_id')->dropDownList($lista);
echo Html::a('Nuevo Insumo', ['create'], ['class' => 'btn btn-success']); ?> </p> <?php $gridColumns = [['class' => 'kartik\\grid\\SerialColumn', 'width' => '25px'], ['class' => 'kartik\\grid\\ActionColumn', 'template' => '{update} {delete}', 'width' => '25px'], ['class' => 'kartik\\grid\\ExpandRowColumn', 'value' => function () { return GridView::ROW_COLLAPSED; }, 'expandOneOnly' => true, 'detail' => function ($modelo) { $searchModel = new \backend\modules\mrp\models\search\PresentacionSearch(); $searchModel->insumo_id = $modelo->id; $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return Yii::$app->controller->renderPartial('_presentacion-details', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); }], ['attribute' => 'clavepresupuestal_id', 'width' => '140px', 'value' => function ($model) { return $model->clavepresupuestal->clavepresupuestal; }, 'filterType' => GridView::FILTER_SELECT2, 'filter' => \yii\helpers\ArrayHelper::map(\backend\modules\mrp\models\Clavepresupuestal::find()->asArray()->orderBy('clavepresupuestal')->all(), 'id', 'clavepresupuestal'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => 'Clave Presupuestal']], ['attribute' => 'insumo_generico', 'label' => 'Insumo Genérico', 'width' => '140px'], ['attribute' => 'unidad_id', 'width' => '140px', 'value' => function ($model) { return $model->unidad->descripcion; }]]; ?> <?php echo GridView::widget(['export' => false, 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'showPageSummary' => true, 'columns' => $gridColumns, 'responsive' => true, 'pjax' => true, 'pjaxSettings' => ['neverTimeout' => true], 'hover' => true]); ?> <?php /* <p> <?= Html::a('Create Insumo', ['create'], ['class' => 'btn btn-success']) ?> </p> <?= GridView::widget([ 'dataProvider' => $dataProvider,