/** * Finds the Unidadmedida model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Unidadmedida the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Unidadmedida::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Unidadmedida::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', 'unidad', $this->unidad])->andFilterWhere(['like', 'descripcion', $this->descripcion])->andFilterWhere(['like', 'tipo_unidad', $this->tipo_unidad]); return $dataProvider; }
if (Yii::$app->session->getFlash('crear')) { echo growl\Growl::widget(['type' => growl\Growl::TYPE_SUCCESS, 'title' => 'Registro Creado', 'icon' => 'glyphicon glyphicon-ok-sign', 'body' => 'Se agrego correctamente ' . Yii::$app->session->getFlash('crear'), 'showSeparator' => true, 'delay' => 0, 'pluginOptions' => ['placement' => ['from' => 'top', 'align' => 'right']]]); } } ?> <?php $gridColumns = [['width' => '25px', 'class' => 'kartik\\grid\\SerialColumn'], ['class' => 'kartik\\grid\\ActionColumn', 'template' => '{delete}', 'width' => '25px'], ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'unidad', 'editableOptions' => function () { return ['asPopover' => false, 'options' => ['style' => 'width:100px']]; }, 'value' => function ($model) { return $model->unidad; }], ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'descripcion', 'editableOptions' => function () { return ['asPopover' => false, 'options' => ['style' => 'width:200px']]; }, 'value' => function ($model) { return $model->descripcion; }], ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'tipo_unidad', 'width' => '12em', 'value' => function ($model) { return $model->tipo_unidad; }, 'filterType' => GridView::FILTER_SELECT2, 'filter' => \backend\modules\mrp\models\Unidadmedida::arreglotipounidad(), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => 'Unidad'], 'editableOptions' => function () { return ['size' => 'md', 'inputType' => \kartik\editable\Editable::INPUT_SELECT2, 'options' => ['data' => \backend\modules\mrp\models\Unidadmedida::arreglotipounidad()]]; }]]; echo \kartik\grid\GridView::widget(['export' => false, 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => $gridColumns]); ?> <div class="unidadmedida-create"> <?php echo $this->render('_form', ['modelunidad' => $modelunidad]); ?> </div> </div>
?> <div class="col-sm-2"> <?php echo $form->field($modelunidad, 'unidad', ['showLabels' => false])->textInput(['placeholder' => 'Unidad']); ?> </div> <div class="col-sm-4"> <?php echo $form->field($modelunidad, 'descripcion', ['showLabels' => false])->textInput(['placeholder' => 'Descripción']); ?> </div> <div class="col-sm-2"> <?php echo $form->field($modelunidad, 'tipo_unidad', ['showLabels' => false])->dropDownList(\backend\modules\mrp\models\Unidadmedida::arreglotipounidad(), ['prompt' => 'Tipo Unidad']); ?> </div> <div class="col-sm-2"> <?php echo Html::submitButton($modelunidad->isNewRecord ? 'Nueva' : 'Actualizar', ['class' => $modelunidad->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> </div> <?php ActiveForm::end();
<div class="col-xs-9"> <?php $lista = \yii\helpers\ArrayHelper::map(\backend\modules\mrp\models\Unidadmedida::find()->asArray()->all(), 'id', 'descripcion'); echo $form->field($modelPresentacion, "[{$i}]presentacionunidad_id")->dropDownList($lista)->label('Unitaria '); ?> </div> </div> <div class="col-xs-6"> <div class="col-xs-3"> <?php echo $form->field($modelPresentacion, "[{$i}]equivalencia")->textInput(['maxlength' => true]); ?> </div> <div class="col-xs-9"> <?php $lista = \yii\helpers\ArrayHelper::map(\backend\modules\mrp\models\Unidadmedida::find()->asArray()->all(), 'id', 'descripcion'); echo $form->field($modelPresentacion, "[{$i}]equivalenciasunidad_id")->dropDownList($lista)->label('Con unidad mínima'); ?> </div> </div> </div> </div> </div> <?php } ?> </div> <?php DynamicFormWidget::end(); ?>