コード例 #1
0
ファイル: CategoriaAction.php プロジェクト: alejandrososa/AB
 /**
  * VISTA CATEGORIA
  * @param $categoria
  * @param null $pp
  * @param null $p
  * @return mixed
  */
 public function run($categoria, $pp = null, $p = null)
 {
     $parametros = Yii::$app->request->post();
     $modelCategoria = new Categorias();
     $modelArticulo = new Articulos();
     $modelProvincia = new Provincias();
     if (!empty(Yii::$app->request->get('ca'))) {
         Yii::$app->request->get('ca');
         $categoria = $modelCategoria->obtenerSlug(Yii::$app->request->get('ca'));
         $provincia = strtolower($modelProvincia->obtenerProvincia(Yii::$app->request->get('ps')));
         $estado = strtolower($modelArticulo->obtenerEstado(Yii::$app->request->get('estado')));
         $estado = MetodosHelper::terminacionEsPlural($categoria) == true ? $estado . 's' : $estado;
         $this->controller->redirect(Yii::$app->urlManager->createUrl(['articulo/categoria-provincia', 'provincia' => $provincia, 'categoria' => $categoria, 'estado' => $estado]));
     }
     $model = Articulos::obtenerArticulosPorCategoria($categoria);
     $datos = new ArticulosBuscador();
     $datos->cs = $categoria;
     $dataProvider = $datos->buscador($parametros, $pp, $p, 'categoria');
     if (!empty($model)) {
         $this->controller->view->params['breadcrumbs'][] = $model[0]->categorias->nombre;
         return $this->controller->render('categoria', ['model' => $model, 'dataProvider' => $dataProvider]);
         echo '<pre>';
         print_r(array('categoria', $categoria, $model[0]->categorias->slug, $model));
     }
     echo '<pre>';
     print_r(array('categoria', $categoria, 'articulo no existe'));
 }
コード例 #2
0
 public function prepareDataProvider()
 {
     $params = \Yii::$app->request->queryParams;
     //print_r($params);die();
     $model = new $this->modelClass();
     // I'm using yii\base\Model::getAttributes() here
     // In a real app I'd rather properly assign
     // $model->scenario then use $model->safeAttributes() instead
     $modelAttr = $model->attributes;
     // this will hold filtering attrs pairs ( 'name' => 'value' )
     $search = [];
     if (!empty($params)) {
         foreach ($params as $key => $value) {
             // In case if you don't want to allow wired requests
             // holding 'objects', 'arrays' or 'resources'
             if (!is_scalar($key) or !is_scalar($value)) {
                 throw new BadRequestHttpException('Bad Request');
             }
             // if the attr name is not a reserved Keyword like 'q' or 'sort' and
             // is matching one of models attributes then we need it to filter results
             if (!in_array(strtolower($key), $this->reservedParams) && ArrayHelper::keyExists($key, $modelAttr, false)) {
                 $search[$key] = $value;
             }
         }
     }
     // you may implement and return your 'ActiveDataProvider' instance here.
     // in my case I prefer using the built in Search Class generated by Gii which is already
     // performing validation and using 'like' whenever the attr is expecting a 'string' value.
     $searchByAttr['ProductSearch'] = $search;
     $lat = isset($params['lat']) ? $params['lat'] : 18.509111;
     $lon = isset($params['lon']) ? $params['lon'] : -69.8468487;
     $model = new Categorias();
     $searchModel = $model->find()->all();
     return $searchModel;
 }
コード例 #3
0
ファイル: MapaSitio.php プロジェクト: alejandrososa/AB
 /**
  * Find profession categories with professions links
  * @param array $config
  */
 public function __construct($config = [])
 {
     $this->categorias = Categorias::find()->with(['articulos' => function ($query) {
         $query->andWhere(['in', 'estado', [Articulos::NUEVO, Articulos::USADO, Articulos::OFERTA, Articulos::RESERVADO]])->orderBy(['idarticulo' => SORT_DESC]);
     }])->activas()->all();
     parent::__construct($config);
 }
コード例 #4
0
 public function crear()
 {
     $model = new Categorias();
     $image = $this->cargarImagen();
     if ($this->validate()) {
         $model->nombre = ucfirst($this->nombre);
         $model->estado = $this->estado;
         $model->descripcion = ucfirst($this->descripcion);
         $model->icono = $this->icono;
         if ($model->save()) {
             if (!empty($image)) {
                 // the path to save file, you can set an uploadPath
                 $path = Yii::getAlias('@libreria') . '/imagenes/categorias/' . $this->icono;
                 $image->saveAs($path);
                 Yii::$app->session->setFlash('error', ['Error 1', 'Error 2']);
             }
             return true;
         } else {
             return false;
         }
     }
     return false;
 }
コード例 #5
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Categorias::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(['idcategoria' => $this->idcategoria, 'padre' => $this->padre]);
     $query->andFilterWhere(['like', 'nombre', $this->nombre]);
     return $dataProvider;
 }
コード例 #6
0
 /**
  * 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.');
     }
 }
コード例 #7
0
ファイル: Buscador.php プロジェクト: alejandrososa/AB
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCategoria0()
 {
     return $this->hasOne(Categorias::className(), ['idcategoria' => 'categoria']);
 }
コード例 #8
0
ファイル: Articulos.php プロジェクト: alejandrososa/AB
 /**
  * Listado de los tipos de articulo
  * @return array
  */
 public function listadoCategorias()
 {
     $model = new Categorias();
     return $model->listadoCategorias();
 }
コード例 #9
0
 /**
  * Finds the Usuarios 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($slug)
 {
     if (($model = Categorias::find()->where(['slug' => $slug])->one()) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #10
0
ファイル: Contenido.php プロジェクト: alejandrososa/AB
 /**
  * Menu Categorias populares Articulos
  * @return array
  */
 public static function listadoCategoriasPopularesArticulos()
 {
     $model = new Categorias();
     return $model->listadoCategoriasPopulares();
 }
コード例 #11
0
ファイル: Paginas.php プロジェクト: alejandrososa/portalJA
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIdCategorias()
 {
     return $this->hasMany(Categorias::className(), ['id_categoria' => 'id_categoria'])->viaTable('paginas_categoria', ['id_pag' => 'id_pag']);
 }
コード例 #12
0
<?php

/**
 * Created by PhpStorm.
 * User: alejandro.sosa
 * Date: 27/03/2016
 * Time: 21:01
 */
/* @var $this yii\web\View */
/* @var $model common\models\Articulos */
use common\models\Usuarios;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\models\Categorias;
$articulo = new \common\models\Articulos();
$categorias = new Categorias();
$inputCheckBoxListOpciones = ['style' => 'margin-top: 10px;', 'tag' => 'div', 'class' => 'control-group', 'item' => function ($index, $label, $name, $checked, $value) {
    $seleccion = $checked == true ? 'checked' : '';
    $html = '<div class="checkbox controls"><input id="' . $index . '_' . $name . '" type="checkbox" name="' . $name . '" class="filled-in" value="' . $value . '" ' . $seleccion . '>
                 <label for="' . $index . '_' . $name . '">' . $label . '</label></div>';
    return $html;
}, 'itemOptions' => ['labelOptions' => ['class' => 'radio-inline radio-styled']]];
$inputRadioBoxListOpciones = ['style' => 'margin-top: 10px;', 'tag' => 'div', 'class' => 'control-group', 'item' => function ($index, $label, $name, $checked, $value) {
    $html = '<div class="checkbox controls"><input id="' . $index . '_' . $name . '" type="radio" name="' . $name . '" class="with-gap" value="' . $value . '">
                 <label for="' . $index . '_' . $name . '">' . $label . '</label></div>';
    return $html;
}, 'itemOptions' => ['labelOptions' => ['class' => 'radio-inline radio-styled']]];
?>

<div class="col-sm-3 col-lg-3 col-md-3">
    <div class="left-sidebar">