/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Ciudades::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, 'estado' => $this->estado]);
     $query->andFilterWhere(['like', 'nombre', $this->nombre]);
     return $dataProvider;
 }
Example #2
0
 /**
  * Transform the \Ciudades entity
  * @param \Ciudades $model
  *
  * @return array
  */
 public function transform(Ciudades $model)
 {
     return ['id' => (int) $model->id_ciudad, 'ciudad' => $model->ciudad, 'zonas' => $model->zonas()->get()];
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCiudad()
 {
     return $this->hasOne(Ciudades::className(), ['id' => 'ciudad_id']);
 }
Example #4
0
<?php

namespace yii\bootstrap;

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use app\models\Ciudades;
/* @var $this yii\web\View */
/* @var $model app\models\Aliados */
/* @var $form yii\widgets\ActiveForm */
$lasCiudades = Ciudades::find()->where(['estado' => 1])->all();
$listData = ArrayHelper::map($lasCiudades, 'id', 'nombre');
?>

<div class="aliados-form">

    <?php 
$form = ActiveForm::begin();
?>
    <div class="row">
        <div class="col-xs-12 col-sm-6 col-md-8">
            <?php 
echo $form->field($model, 'aliado')->textInput(['maxlength' => true, 'class' => 'form-control input-sm']);
?>
        </div>
        <div class="col-xs-6 col-md-4">
            <?php 
echo $form->field($model, 'nit_cc')->textInput(['maxlength' => true, 'class' => 'form-control input-sm']);
?>
        </div>
Example #5
0
<?php

use yii\helpers\Html;
use yii\helpers\ArrayHelper;
use app\models\Aliados;
use app\models\Ciudades;
use yii\widgets\ActiveForm;
use app\models\ArchivoConductor;
/* @var $this yii\web\View */
/* @var $model app\models\Conductor */
/* @var $form yii\widgets\ActiveForm */
$lasCiudades = Ciudades::find()->all();
$listData = ArrayHelper::map($lasCiudades, 'id', 'nombre');
$losAdjuntos = ArchivoConductor::find()->where(['conductor_id' => $model->id])->all();
if (Yii::$app->user->identity->rol_id == 3) {
    $losAliados = Aliados::find()->all();
    $listaAliados = ArrayHelper::map($losAliados, 'id', 'aliado');
} else {
    $losAliados = Aliados::find()->where(['id' => Yii::$app->user->identity->aliado_id])->all();
    $listaAliados = ArrayHelper::map($losAliados, 'id', 'aliado');
}
?>

<div class="conductor-form">

    <?php 
//$form = ActiveForm::begin();
?>
    <?php 
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]);
?>
Example #6
0
/* @var $this yii\web\View */
/* @var $searchModel app\models\CiudadesSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Ciudades';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="ciudades-index">

    <h1><?php 
echo Html::encode($this->title);
?>
 - <?php 
echo Html::a('Crear', ['ciudades/create'], ['class' => 'btn btn-primary']);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
//Html::a('Crear Ciudades', ['create'], ['class' => 'btn btn-success'])
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['attribute' => 'id', 'headerOptions' => ['width' => '80'], 'options' => ['width' => '80']], ['attribute' => 'nombre', 'filter' => ArrayHelper::map(Ciudades::find()->orderBy('id')->asArray()->all(), 'nombre', 'nombre'), 'options' => ['width' => '900']], ['header' => 'Activo', 'filter' => array("1" => "Si", "0" => "No"), 'attribute' => 'estado', 'format' => ['boolean'], 'options' => ['width' => '80']], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{view} - {update}']]]);
?>

</div>
 /**
  * Finds the Ciudades model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Ciudades the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Ciudades::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }