private function findModel($id)
 {
     $listaComercioProductos = ComercioProductosRelacionados::find()->where(['id_comercio' => $id])->all();
     $listaProductos = [];
     foreach ($listaComercioProductos as $comercioProductos) {
         $producto = Producto::find()->where(['id' => $comercioProductos->id_producto])->one();
         $listaProductos[] = $producto;
     }
     return $listaProductos;
 }
示例#2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Producto::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(['id' => $this->id, 'categoria_producto_id' => $this->categoria_producto_id]);
     $query->andFilterWhere(['like', 'codigo_producto', $this->codigo_producto])->andFilterWhere(['like', 'nombre', $this->nombre])->andFilterWhere(['like', 'descripcion', $this->descripcion])->andFilterWhere(['like', 'estado', $this->estado]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Producto::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(['id' => $this->id, 'id_categoria' => $this->id_categoria, 'precio' => $this->precio]);
     if (strtolower($this->esActivo) == strtolower(Yii::t('core', 'Yes'))) {
         $query->andFilterWhere(['esActivo' => $this->esActivo == 0]);
     } else {
         if (strtolower($this->esActivo) == strtolower(Yii::t('core', 'No'))) {
             $query->andFilterWhere(['esActivo' => $this->esActivo == 1]);
         }
     }
     $query->andFilterWhere(['like', 'nombre', $this->nombre])->andFilterWhere(['like', 'imagen', $this->imagen]);
     return $dataProvider;
 }
示例#4
0
 /**
  * Lists all Producto models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Producto::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
echo $form->field($model, 'fecha')->textInput(['label' => Yii::t('core', 'Date')]);
?>

    <?php 
echo $form->field($model, 'vendidos')->textInput(['label' => Yii::t('core', 'Sold')]);
?>

    <?php 
$comercio = array(Comercio::find()->all());
$listData = ArrayHelper::map(Comercio::find()->all(), 'id', 'nombre');
echo $form->field($model, 'id_comercio')->dropDownList($listData, ['prompt' => Yii::t('core', 'Select...')]);
?>

    <?php 
//$comercio=array(Comercio::find()->all());
$listData = ArrayHelper::map(Producto::find()->all(), 'id', 'nombre');
echo $form->field($model, 'id_producto')->dropDownList($listData, ['prompt' => Yii::t('core', 'Select...')]);
?>

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

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

</div>
示例#6
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;
     }
 }