Beispiel #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Departamento::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(['codigo' => $this->codigo]);
     $query->andFilterWhere(['like', 'nombre', $this->nombre]);
     return $dataProvider;
 }
Beispiel #2
0
?>
      </span>
    </div>

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

    <div class="cflex">
      <span style="order: 1; flex-grow: 1; margin-right:10px;">
        <div class="form-group">
          <?php 
echo Html::label('Departamento de Origen', 'deptomo');
?>
          <?php 
echo Html::dropDownList('departamento', null, ArrayHelper::map(Departamento::find()->all(), 'codigo', 'nombre'), ['id' => 'deptomo', 'class' => 'form-control', 'onchange' => '
          $.post( "' . Yii::$app->urlManager->createUrl('general/municipios?id=') . '"+$(this).val(), function( data ) {
            $("select#munico").html(data);
            $("#munico").val(' . $model->cod_mun_origen . ');
          });
          ']);
?>
        </div>
      </span>
      <span style="order: 2; flex-grow: 1; margin-right:10px;">
        <?php 
if (!$model->isNewRecord) {
    $objMunicipio = Municipio::find()->where('codigo = :valor', [':valor' => $model->cod_mun_origen])->one();
    $this->registerJs('$("#deptomo").val(' . $objMunicipio->codDepartamento->codigo . ').change();', View::POS_READY);
}
?>
Beispiel #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCodDepartamento()
 {
     return $this->hasOne(Departamento::className(), ['codigo' => 'cod_departamento']);
 }
 /**
  * Finds the Departamento model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Departamento the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Departamento::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }