Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Uf::find();
     $pageSize = isset($_GET['per-page']) ? $_GET['per-page'] : \Yii::$app->params['uf.defaultPageSize'];
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => $pageSize], 'sort' => ['defaultOrder' => ['id' => SORT_ASC], 'enableMultiSort' => true]]);
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'loteo' => $this->loteo, 'manzana' => $this->manzana, 'superficie' => $this->superficie, 'created_by' => $this->created_by, 'created_at' => $this->created_at, 'updated_by' => $this->updated_by, 'updated_at' => $this->updated_at, 'estado' => $this->estado]);
     $query->andFilterWhere(['like', 'motivo_baja', $this->motivo_baja]);
     return $dataProvider;
 }
Example #2
0
 /**
  * Finds the Uf model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Uf the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Uf::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUf()
 {
     return $this->hasOne(Uf::className(), ['id' => 'id_uf']);
 }
Example #4
0
$this->title = 'U.F.' . $model->id;
$this->params['breadcrumbs'][] = ['label' => 'Lista de U.F.', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="uf-view">

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

	<?php 
echo '<p>';
if ($model->estado != Uf::ESTADO_BAJA) {
    if (\Yii::$app->user->can('altaModificarUf')) {
        echo Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
    }
    if (\Yii::$app->user->can('borrarUf')) {
        echo ' ' . Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->id], ['class' => 'btn btn-danger']);
    }
}
echo '</p>';
?>
  

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['loteo', 'manzana', 'superficie:decimal', 'userCreatedBy.username', 'created_at:datetime', 'userUpdatedBy.username', 'updated_at:datetime', ['label' => 'Estado', 'value' => Uf::getEstados($model->estado)], 'motivo_baja']]);
?>

</div>
 /**
  * Creates a new UfTitularidad model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($uf)
 {
     $model = new UfTitularidad();
     $model->id_uf = $uf;
     $titPers = new UfTitularidadPersonas();
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate()) {
             $titPers->load(Yii::$app->request->post());
             $sessPersonas = \Yii::$app->session->get('titpersonas');
             if (!$sessPersonas) {
                 \Yii::$app->session->addFlash('danger', 'Debe especificar al menos una persona');
             } else {
                 // Comienza Transaccion
                 $transaction = Yii::$app->db->beginTransaction();
                 try {
                     // busca la UF
                     $UfModel = Uf::findOne($model->id_uf);
                     // guarda el id del ultimo movimiento de titularidad
                     if (!empty($UfModel->ultUfTitularidad->id)) {
                         $idUltTitularidad = $UfModel->ultUfTitularidad->id;
                         // busca el ultimo movimiento de titularidad
                         $ultMovimTit = UfTitularidad::findOne($idUltTitularidad);
                         // actualizar el campo ultima en false para que no sea mas la ultima titularidad
                         $ultMovimTit->ultima = false;
                         $ultMovimTit->save(false);
                     }
                     // ultima en true indica que es el ultimo movimiento de titularidad (el que se esta grabando en este momento)
                     $model->ultima = true;
                     $model->save(false);
                     // elimina todos los autorizantes actuales de la unidad para reemplazarlos con los nuevos
                     Autorizantes::deleteAll(['id_uf' => $model->id_uf]);
                     $aut = new Autorizantes();
                     $aut->id_uf = $model->id_uf;
                     // grabación de personas
                     $titPers->uf_titularidad_id = $model->id;
                     if ($model->tipoMovim->cesion) {
                         $titPers->tipo = UfTitularidadPersonas::TIPO_CES;
                     } else {
                         $titPers->tipo = UfTitularidadPersonas::TIPO_TIT;
                     }
                     foreach ($sessPersonas as $titPers->id_persona) {
                         // graba en UfTitularidadPersonas
                         $titPers->id = null;
                         $titPers->isNewRecord = true;
                         $titPers->save(false);
                         // graba en Autorizantes
                         $aut->id = null;
                         $aut->isNewRecord = true;
                         $aut->id_persona = $titPers->id_persona;
                         $aut->save(false);
                     }
                     // foreach sessPersonas
                     if ($model->tipoMovim->cesion) {
                         // si es una cesion, las personas de $sessPersonas se grabaron como cesionarios,
                         // entonces se debe grabar a los titulares originales como cedentes
                         $ultTitulares = UfTitularidadPersonas::find()->where(['uf_titularidad_id' => $idUltTitularidad])->all();
                         foreach ($ultTitulares as $ut) {
                             $titPers->id = null;
                             $titPers->isNewRecord = true;
                             $titPers->id_persona = $ut->id_persona;
                             $titPers->tipo = UfTitularidadPersonas::TIPO_CED;
                             $titPers->observaciones = $ut->observaciones;
                             $titPers->save(false);
                         }
                     }
                     // Todo bien
                     $transaction->commit();
                     \Yii::$app->session->addFlash('success', 'Movimiento grabado correctamente');
                     // limpia todo
                     \Yii::$app->session->remove('titpersonas');
                     return $this->redirect(['view', 'id' => $model->id]);
                 } catch (\Exception $e) {
                     $transaction->rollBack();
                     Yii::$app->session->addFlash('danger', 'Hubo un error en la grabación');
                     throw $e;
                 }
                 // try..catch
             }
             // else !sessPersonas
         }
         // $model->validate
     }
     // $model->load
     $listas = $this->refreshListas();
     return $this->render('create', ['model' => $model, 'titPers' => $titPers, 'tmpListas' => $listas]);
 }
Example #6
0
  border-top-right-radius: 2px;
}
.table-condensed > thead > tr > th,
.table-condensed > tbody > tr > th,
.table-condensed > tfoot > tr > th,
.table-condensed > thead > tr > td,
.table-condensed > tbody > tr > td,
.table-condensed > tfoot > tr > td {
  padding: 1px;
}
');
?>

<div class="uf-titularidad-form">
    <?php 
$UfModel = Uf::findOne($model->id_uf);
if (!empty($UfModel->ultUfTitularidad->id)) {
    $puedeCambiarTipoMovim = true;
    $query = UfTitularidadPersonas::find()->joinWith('persona')->where(['uf_titularidad_id' => $UfModel->ultUfTitularidad->id]);
    $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['tipo' => SORT_DESC], 'enableMultiSort' => true]]);
    $xDefecto = UfTitularidad::findOne($UfModel->ultUfTitularidad->id);
    $model->exp_telefono = $xDefecto->exp_telefono;
    $model->exp_direccion = $xDefecto->exp_direccion;
    $model->exp_localidad = $xDefecto->exp_localidad;
    $model->exp_email = $xDefecto->exp_email;
    echo GridView::widget(['dataProvider' => $dataProvider, 'condensed' => true, 'layout' => '{items}', 'panel' => ['type' => GridView::TYPE_INFO, 'heading' => 'Titularidad actual sobre U.F.' . $model->id_uf, 'footer' => false, 'before' => false, 'after' => false], 'panelHeadingTemplate' => '{heading}', 'resizableColumns' => false, 'columns' => [['attribute' => 'tipo', 'value' => function ($model) {
        return UfTitularidadPersonas::getTipos($model->tipo);
    }], 'id_persona', 'persona.apellido', 'persona.nombre', 'persona.nombre2', 'persona.tipoDoc.desc_tipo_doc_abr', 'persona.nro_doc', 'observaciones']]);
} else {
    $puedeCambiarTipoMovim = false;
}
Example #7
0
$this->title = 'Expensas';
$this->params['breadcrumbs'][] = $this->title;
use app\assets\ExportSelectorAsset;
ExportSelectorAsset::register($this);
$this->registerCss('
.kv-grid-loading {
    opacity: 0.5;
    background: #ffffff url("../images/loading.gif") top center no-repeat !important;
}
');
?>
<div class="titularidad-vista-index">

    <h3><?php 
global $totSup;
$totSup = Uf::getSuperficieTotal();
echo Html::encode($this->title . ' (' . yii::$app->formatter->asDecimal($totSup, 2) . ' m2)');
?>
</h3>
	
    <?php 
$lbl2 = '';
$pdfHeader = ['L' => ['content' => \Yii::$app->params['lblName']], 'C' => ['content' => $this->title . $lbl2, 'font-style' => 'B'], 'R' => ['content' => '']];
$pdfFooter = ['L' => ['content' => \Yii::$app->params['lblName2']], 'C' => ['content' => 'página {PAGENO} de {nb}'], 'R' => ['content' => 'Fecha:{DATE d/m/Y}']];
$columns = [['attribute' => 'id_uf', 'group' => true], ['attribute' => 'superficie', 'format' => ['decimal', 2], 'hAlign' => 'right', 'group' => true, 'subGroupOf' => 0], ['class' => '\\kartik\\grid\\FormulaColumn', 'value' => function ($model, $key, $index, $widget) {
    if ($model->unidad_estado == 0) {
        return null;
    }
    $p = compact('model', 'key', 'index');
    // Write your formula below
    global $totSup;
Example #8
0
<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use yii\widgets\ActiveForm;
use frontend\models\Uf;
$this->registerJs('$("#uf-motivo_baja").focus();', yii\web\View::POS_READY);
?>
<div class="uf-view">


    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['loteo', 'manzana', 'superficie:decimal', ['label' => 'Estado', 'value' => Uf::getEstados($model->estado)], 'motivo_baja']]);
?>
    
    <?php 
$form = ActiveForm::begin();
?>
	<?php 
echo $form->field($model, 'motivo_baja')->textInput(['maxlength' => true]);
?>

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

	<?php 
ActiveForm::end();
?>
Example #9
0
?>

    <?php 
$lbl2 = '';
$pdfHeader = ['L' => ['content' => \Yii::$app->params['lblName']], 'C' => ['content' => $this->title . $lbl2, 'font-style' => 'B'], 'R' => ['content' => '']];
$pdfFooter = ['L' => ['content' => \Yii::$app->params['lblName2']], 'C' => ['content' => 'página {PAGENO} de {nb}'], 'R' => ['content' => 'Fecha:{DATE d/m/Y}']];
$columns = ['id', 'loteo', 'manzana', ['attribute' => 'superficie', 'format' => ['decimal', 2], 'hAlign' => 'right'], ['class' => '\\kartik\\grid\\FormulaColumn', 'value' => function ($model, $key, $index, $widget) {
    if ($model->estado == 0) {
        return null;
    }
    $p = compact('model', 'key', 'index');
    // Write your formula below
    global $totSup;
    return $totSup == 0 ? 0 : $widget->col(3, $p) / $totSup * 100;
}, 'format' => ['decimal', 3], 'label' => 'Coeficiente', 'hAlign' => 'right'], ['attribute' => 'estado', 'value' => function ($data) {
    return Uf::getEstados($data->estado);
}, 'filter' => $searchModel->estados], ['class' => 'kartik\\grid\\ActionColumn', 'header' => Html::a('<span class="glyphicon glyphicon-plus-sign"></span>', ['create'], ['class' => 'btn-sm btn-primary', 'title' => Yii::t('app', 'Nueva U.F.')]), 'template' => '{view} {comentario} {titularidad}', 'buttons' => ['comentario' => function ($url, $model) {
    $c = Comentarios::getComentariosByModelId($model->className(), $model->id);
    $text = '<span class="glyphicon glyphicon-copyright-mark"';
    if (!empty($c)) {
        $text .= ' style="color:#FF8000"></span>';
        $titl = 'Ingresar nuevo/Ver comentarios';
    } else {
        $text .= '></span>';
        $titl = 'Ingresar nuevo comentario';
    }
    return Html::a($text, $url, ['title' => $titl, 'onclick' => '$.ajax({
							type     :"POST",
							cache    : false,
							url  : $(this).attr("href"),
							success  : function(response) {