Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Impuesto::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(['idImpuesto' => $this->idImpuesto, 'valor' => $this->valor]);
     $query->andFilterWhere(['like', 'nombre', $this->nombre]);
     return $dataProvider;
 }
Example #2
0
echo $form->field($model, 'codigo')->textInput();
?>

    <?php 
echo $form->field($model, 'producto')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'precio')->widget(MaskMoney::classname(), ['pluginOptions' => ['prefix' => '$ ', 'suffix' => '', 'thousands' => '.', 'decimal' => ',', 'allowNegative' => false]]);
?>

    <?php 
echo $form->field($model, 'embalaje_idEmbalaje')->widget(Select2::classname(), ['data' => ArrayHelper::map(Embalaje::find()->all(), 'idEmbalaje', 'nombre'), 'options' => ['placeholder' => 'Seleccione une opción'], 'pluginOptions' => ['allowClear' => true]]);
?>

    <?php 
echo $form->field($model, 'impuestos_idImpuesto')->widget(Select2::classname(), ['data' => ArrayHelper::map(Impuesto::find()->all(), 'idImpuesto', 'nombre'), 'options' => ['placeholder' => 'Seleccione une opción'], 'pluginOptions' => ['allowClear' => true]]);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>
Example #3
0
/* @var $searchModel app\models\ProductoSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', 'Productos');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="producto-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a(Yii::t('app', 'Create {0}', Yii::t('app', 'Producto')), ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'codigo', 'producto', 'precio:currency', ['attribute' => 'embalaje_idEmbalaje', 'filter' => Html::activeDropDownList($searchModel, 'embalaje_idEmbalaje', ArrayHelper::map(Embalaje::find()->asArray()->all(), 'idEmbalaje', 'nombre'), ['class' => 'form-control', 'prompt' => '']), 'value' => function ($model, $index, $dataColumn) {
    return $model->embalajeIdEmbalaje->nombre;
}], ['attribute' => 'impuestos_idImpuesto', 'filter' => Html::activeDropDownList($searchModel, 'impuestos_idImpuesto', ArrayHelper::map(Impuesto::find()->asArray()->all(), 'idImpuesto', 'nombre'), ['class' => 'form-control', 'prompt' => '']), 'value' => function ($model, $index, $dataColumn) {
    return $model->impuestosIdImpuesto->nombre;
}], ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>
Example #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getImpuestosIdImpuesto()
 {
     return $this->hasOne(Impuesto::className(), ['idImpuesto' => 'impuestos_idImpuesto']);
 }
Example #5
0
 /**
  * Finds the Impuesto model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Impuesto the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Impuesto::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }