示例#1
0
        togglePropDep();
    });
    
    
    function contains(array,x){
        for(i=0;i<array.length;i++){
            if(array[i]==x){
                return true;
            }
        }
        return false;
    }
    
    var saved_departamentos = Array();
    <?php 
$egresos_deptos = EgresoDepartamento::model()->findAllByAttributes(array('egreso_id' => $model->id));
$l = 0;
foreach ($egresos_deptos as $egDep) {
    $depto_id = $egDep->departamento_id;
    echo "saved_departamentos[{$l}]={$depto_id};";
    $l++;
}
?>
		

    $(".select-on-check").each(function(e){
        if(contains(saved_departamentos,$(this).val())){
            $(this).attr('checked',true);
        }
    });
});
示例#2
0
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $model->fecha = Tools::backFecha($model->fecha);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Egreso'])) {
         $model->attributes = $_POST['Egreso'];
         $model->fecha = Tools::fixFecha($model->fecha);
         $propiedad = null;
         if ($model->centroCosto != null) {
             $ok = $model->validate();
             if ($model->centroCosto->carga_a == '1') {
                 $propiedad = Propiedad::model()->findByPk($model->propiedad_id);
                 if ($propiedad == null) {
                     $model->addError("propiedad_id", "Propiedad no puede ser nulo.");
                     $ok = false;
                 }
             }
             if ($ok) {
                 if ($model->save()) {
                     EgresoPropiedad::model()->deleteAllByAttributes(array('egreso_id' => $model->id));
                     if ($model->centroCosto->carga_a == '1') {
                         $egPro = new EgresoPropiedad();
                         $egPro->egreso_id = $model->id;
                         $egPro->propiedad_id = $model->propiedad_id;
                         $egPro->save();
                     }
                     if ($model->centroCosto->carga_a == '2') {
                         if (isset($_POST['chbDepartamentoId'])) {
                             $cant_deptos = count($_POST['chbDepartamentoId']);
                             if ($cant_deptos > 0) {
                                 EgresoDepartamento::model()->deleteAllByAttributes(array('egreso_id' => $model->id));
                                 foreach ($_POST['chbDepartamentoId'] as $i => $departamento) {
                                     $egDpto = new EgresoDepartamento();
                                     $egDpto->departamento_id = $departamento;
                                     $egDpto->egreso_id = $model->id;
                                     if ($egDpto->validate()) {
                                         $egDpto->save();
                                     }
                                 }
                             }
                         }
                     }
                     $this->redirect(array('admin'));
                 } else {
                     Yii::app()->user->setFlash('error', CHtml::errorSummary($model));
                 }
             } else {
                 Yii::app()->user->setFlash('error', CHtml::errorSummary($model));
             }
         } else {
             Yii::app()->user->setFlash('error', 'ERROR: Centro de costo no puede ser nulo.');
         }
         $model->fecha = Tools::backFecha($model->fecha);
     }
     $conceptos = ConceptoPredefinido::model()->findAll();
     $cptos = array();
     foreach ($conceptos as $concepto) {
         $cptos[] = $concepto->nombre;
     }
     $deptos = new Departamento('search');
     $deptos->unsetAttributes();
     if (isset($_GET['Departamento'])) {
         $deptos->attributes = $_GET['Departamento'];
     }
     $this->render('update', array('model' => $model, 'conceptos' => $cptos, 'departamentos' => $deptos));
 }
示例#3
0
<?php

/* @var $this EgresoController */
/* @var $model Egreso */
$this->breadcrumbs = array('Egresos' => array('admin'), 'Egreso #' . $model->id);
$this->menu = array(array('label' => 'Listar Egresos', 'url' => array('admin')), array('label' => 'Crear Egreso', 'url' => array('create')), array('label' => 'Actualizar Egreso', 'url' => array('update', 'id' => $model->id)), array('label' => 'Eliminar Egreso', 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => 'Are you sure you want to delete this item?')));
?>

<?php 
$egPro = EgresoPropiedad::model()->findByAttributes(array('egreso_id' => $model->id));
$propiedad = null;
if ($egPro != null) {
    $propiedad = $egPro->propiedad;
}
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array(array('name' => 'fecha', 'value' => Tools::backFecha($model->fecha)), 'monto', 'concepto', array('name' => 'respaldo', 'value' => $model->respaldo == '1' ? 'SÍ' : 'NO'), 'cta_contable', 'nro_cheque', 'centro_costo_id', 'proveedor', 'nro_documento', array('name' => 'propiedad_id', 'value' => $propiedad != null ? $propiedad->nombre : '', 'visible' => $propiedad != null))));
?>
<fieldset style="display:<?php 
echo count(EgresoDepartamento::model()->findAllByAttributes(array('egreso_id' => $model->id))) == 0 ? 'none' : 'block';
?>
">
    <legend>Departamentos a los que se aplica el egreso</legend>
    <?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'departamentos-grid', 'dataProvider' => $departamentos, 'columns' => array(array('name' => 'propiedad_nombre', 'value' => '$data->propiedad->nombre'), 'numero', 'mt2', 'dormitorios', 'estacionamientos', 'renta')));
?>
</fieldset>
<br/>