/**
  * Finds the Categorias model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Categorias the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Categorias::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 2
0
/* @var $this yii\web\View */
/* @var $model backend\models\Producto */
$this->title = Yii::t('app', 'Update picture of {modelClass}: ', ['modelClass' => 'product']) . ' ' . $model->Nombre;
$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Products'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->Nombre, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = Yii::t('app', 'Update');
?>
<div class="producto-update">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
	</br>
	<?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['Nombre', ['attribute' => 'idcategoria', 'value' => Categorias::findOne($model->idcategoria)->nombre]]]);
?>

    <div class="producto-form">

	    <?php 
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]);
?>

	    <?php 
echo $form->field($model, 'Nombre')->hiddenInput()->label(false);
?>

	    <?php 
echo $form->field($model, 'idcategoria')->hiddenInput()->label(false);
?>
Ejemplo n.º 3
0
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use backend\models\Categorias;
use yii\helpers\ArrayHelper;
use yii\grid\GridView;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $model backend\models\Comercios */
$this->title = Yii::t('app', 'Add products to ') . $model->nombre;
$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'shop'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
$nombreColumna = function ($data) {
    return Categorias::findOne($data->idcategoria)->nombre;
};
?>
<div class="comercios-view">
    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    </br>
    <?php 
$form = ActiveForm::begin();
?>

   <?php 
echo $form->field($model, 'nombre')->dropDownList($categorias, ['onchange' => '
                        $.post( "' . Url::toRoute('/comercios/getproductos') . '", { id: $(this).val(),idcomercio:' . $model->id . ' } )
                            .done(function( data ) {
Ejemplo n.º 4
0
<?php

use yii\helpers\Html;
use yii\grid\GridView;
use backend\models\Categorias;
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', 'Products');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="producto-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

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

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'Nombre', ['attribute' => 'idcategoria', 'value' => function ($producto) {
    return Categorias::findOne($producto->idcategoria)->nombre;
}], 'Imagen', ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>
Ejemplo n.º 5
0
 public function actionRemove_product()
 {
     $ProductoTiendaModel = new ProductoTienda();
     if ($ProductoTiendaModel->load(Yii::$app->request->post())) {
         $producto = Producto::find()->where(['id' => $ProductoTiendaModel->idproducto])->one();
         $categoria = Categorias::findOne($producto->idcategoria);
         $ProductoTienda = ProductoTienda::find()->where(['idproducto' => $ProductoTiendaModel->idproducto, 'idcomercio' => $ProductoTiendaModel->idcomercio])->one();
         $ProductoTienda->delete();
         $tooltip = Yii::t('app', 'Click to add');
         $message = ['id' => $producto->id, 'nombre' => $producto->Nombre, 'categoria' => $categoria->nombre, 'tooltip' => $tooltip];
         Yii::$app->response->format = 'json';
         return $message;
     }
 }