Пример #1
0
 /**
  * Iniciar Traspaso
  */
 public function actionCreate()
 {
     date_default_timezone_set('America/Caracas');
     $fecha = date('Y-m-d H:i:s');
     $bien = new Bienmueble();
     $user_id = Yii::app()->user->getId();
     $user = Usuario::model()->findbyPk($user_id);
     $dp_id = $user->dependencia_id;
     $emisores = Responsable::model()->findByDp($dp_id, 0);
     $receptores = Responsable::model()->findByDp($dp_id, 1);
     if (!isset(Yii::app()->session['tid'])) {
         $model = new BmTraspaso();
         $model->dependencia_id = $dp_id;
         $model->status_id = 1;
         $model->fecha = $fecha;
         $model->emisor_id = $emisores['id'];
         if ($model->save()) {
             Yii::app()->session['tid'] = $model->id;
             $this->render('create', array('model' => $model, 'bien' => $bien, 'emisores' => $emisores, 'receptores' => $receptores));
         } else {
             // Flujo en caso de error fatal
             $dataProvider = new CActiveDataProvider('BmTraspaso');
             $this->render('index', array('dataProvider' => $dataProvider));
         }
     } else {
         $model = $this->loadModel(Yii::app()->session['tid']);
         if (isset($_POST['BmTraspaso'])) {
             $model->scenario = 'update';
             $model->attributes = $_POST['BmTraspaso'];
             $data = BmTraspaso::model()->getTotal($model->id);
             $model->cantidad_total = $data['cantidad_total'];
             $model->total = $data['total'];
             if ($model->validate() && $model->update()) {
                 $this->redirect(array('enviar', 'id' => $model->id));
             }
         }
         $this->render('create', array('model' => $model, 'bien' => $bien, 'emisores' => $emisores, 'receptores' => $receptores));
     }
 }
Пример #2
0
);

$this->menu=array(
	array('label'=>'Listar Proyecto','url'=>array('index')),
	array('label'=>'Crear Proyecto','url'=>array('create')),
);

$this->widget('bootstrap.widgets.TbGridView',array(
	'id'=>'proyecto-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'columns'=>array(
		'id',
		'nombre',
		'descripcion',
		'fechaInicio_ft',
		'fechaFin_ft',
		array('name'=>'responsable_did',
		        'value'=>'$data->responsable->nombre',
			    'filter'=>CHtml::listData(Responsable::model()->findAll(), 'id', 'nombre'),),
		/*
		array('name'=>'estatus_did',
		        'value'=>'$data->estatus->nombre',
			    'filter'=>CHtml::listData(Estatus::model()->findAll(), 'id', 'nombre'),),
		*/
		array(
			'class'=>'bootstrap.widgets.TbButtonColumn',
		),
	),
)); ?>
Пример #3
0
 public function actionGenerar($formulario)
 {
     $meses = Mes::model()->findAll();
     $user_id = Yii::app()->user->getId();
     $user = Usuario::model()->findbyPk($user_id);
     $dp_id = $user->dependencia_id;
     date_default_timezone_set('America/Caracas');
     $anho_actual = date('Y');
     $i = 0;
     $t_anho = $anho_actual;
     $anhos = array();
     while ($t_anho > 2011) {
         $anhos[$i] = $t_anho;
         $i++;
         $t_anho--;
     }
     switch ($formulario) {
         case 1:
             $model = new Fbm1();
             $model->dependencia_id = $dp_id;
             if (isset($_POST['Fbm1'])) {
                 $fecha = date('Y-m-d H:i:s');
                 $responsable = Responsable::model()->findByAttributes(array('dependencia_id' => $model->dependencia_id, 'status_id' => 1));
                 $model->attributes = $_POST['Fbm1'];
                 if (isset($responsable) && $model->validate()) {
                     $model->anho = $anhos[$model->anho];
                     $data = $model->getData();
                     $mes = Mes::model()->find(array('condition' => 'id=' . $model->mes_id));
                     $info = Dependencia::model()->getInfo($model->dependencia_id);
                     $header = array();
                     if ($model->informativo == 1) {
                         $header['columna'] = 4;
                         $header['formulario'] = 1;
                     } else {
                         $header['columna'] = 5;
                         $header['formulario'] = 2;
                     }
                     $header['dependencia'] = $info['dp'];
                     $header['estado'] = 'BOLIVARIANO DE MIRANDA';
                     $header['municipio'] = 'SUCRE';
                     $header['servicio'] = $info['servicio'];
                     $header['direccion'] = $info['direccion_corta'];
                     $header['fecha'] = $mes->descripcion . '/' . $model->anho;
                     $header['responsable'] = $responsable->persona->pdata->nombre;
                     $header['cargo'] = $responsable->persona->cargo->descripcion;
                     $this->render('pdf', array('header' => $header, 'data' => $data));
                 }
             }
             break;
         case 2:
             $model = new Fbm2();
             $model->dependencia_id = $dp_id;
             if (isset($_POST['Fbm2'])) {
                 $fecha = date('Y-m-d H:i:s');
                 $responsable = Responsable::model()->findByAttributes(array('dependencia_id' => $model->dependencia_id));
                 $model->attributes = $_POST['Fbm2'];
                 if (isset($responsable) && $model->validate()) {
                     $model->anho = $anhos[$model->anho];
                     $data = $model->getData();
                     $mes = Mes::model()->find(array('condition' => 'id=' . $model->mes_id));
                     $info = Dependencia::model()->getInfo($model->dependencia_id);
                     $header = array();
                     $header['columna'] = 6;
                     $header['formulario'] = 3;
                     $header['responsable'] = $responsable->persona->pdata->nombre;
                     $header['cargo'] = $responsable->persona->cargo->descripcion;
                     $header['dependencia'] = $info['dp'];
                     $header['estado'] = 'BOLIVARIANO DE MIRANDA';
                     $header['municipio'] = 'SUCRE';
                     $header['servicio'] = $info['servicio'];
                     $header['direccion'] = $info['direccion_corta'];
                     $header['fecha'] = $mes->descripcion . '/' . $model->anho;
                     $this->render('pdf', array('header' => $header, 'data' => $data));
                 }
             }
             break;
         case 3:
             $this->redirect(array('/fbm3/index'));
             break;
         case 4:
             $model = new Fbm4();
             $model->dependencia_id = $dp_id;
             if (isset($_POST['Fbm4'])) {
                 $fecha = date('Y-m-d H:i:s');
                 $responsable = Responsable::model()->findByAttributes(array('dependencia_id' => $model->dependencia_id));
                 $model->attributes = $_POST['Fbm4'];
                 if (isset($responsable) && $model->validate()) {
                     $model->anho = $anhos[$model->anho];
                     $data = $model->getData();
                     $mes = Mes::model()->find(array('condition' => 'id=' . $model->mes_id));
                     $info = Dependencia::model()->getInfo($model->dependencia_id);
                     $header = array();
                     $header['columna'] = 6;
                     $header['formulario'] = 5;
                     $header['responsable'] = $responsable->persona->pdata->nombre;
                     $header['cargo'] = $responsable->persona->cargo->descripcion;
                     $header['dependencia'] = $info['dp'];
                     $header['estado'] = 'BOLIVARIANO DE MIRANDA';
                     $header['municipio'] = 'SUCRE';
                     $header['servicio'] = $info['servicio'];
                     $header['direccion'] = $info['direccion_corta'];
                     $header['fecha'] = $mes->descripcion . '/' . $model->anho;
                     $header['hoja'] = $mes->id;
                     $this->render('pdf4', array('header' => $header, 'data' => $data));
                 } else {
                     echo 1;
                     exit;
                 }
             }
             break;
     }
     $this->render('generar', array('model' => $model, 'meses' => $meses, 'anhos' => $anhos));
 }
Пример #4
0
 /**
  * Updates a particular model
  * @param integer $id the ID of the model to be updated
  * @redirected to'view' page.
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     if (isset($_POST['Fbm3'])) {
         $model->attributes = $_POST['Fbm3'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $responsables = Responsable::model()->findAll();
     $profesiones = Profesion::model()->findAll();
     $dps = Dependencia::model()->findAll();
     $generos = Sexo::model()->findAll();
     $this->render('update', array('model' => $model, 'responsables' => $responsables, 'profesiones' => $profesiones, 'dps' => $dps, 'generos' => $generos));
 }
Пример #5
0

	<div class="clearfix">
		<?php echo $form->label($model,'fechaFin_ft'); ?>
		<div class="input">
			
			<?php echo $form->textField($model,'fechaFin_ft'); ?>
		</div>
	</div>


	<div class="clearfix">
		<?php echo $form->label($model,'responsable_did'); ?>
		<div class="input">
			
			<?php echo $form->dropDownList($model,"responsable_did",CHtml::listData(Responsable::model()->findAll(), 'id', 'nombre')); ?>		</div>
	</div>


	<div class="clearfix">
		<?php echo $form->label($model,'estatus_did'); ?>
		<div class="input">
			
			<?php echo $form->dropDownList($model,"estatus_did",CHtml::listData(Estatus::model()->findAll(), 'id', 'nombre')); ?>		</div>
	</div>

	<div class="form-actions">
		<?php $this->widget('bootstrap.widgets.TbButton', array(
			'buttonType'=>'submit',
			'type'=>'primary',
			'label'=>'Search',
Пример #6
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Responsable::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Пример #7
0
 /**
  * Deletes a particular model.
  * If deletion is successful, the browser will be redirected to the 'admin' page.
  * @param integer $id the ID of the model to be deleted
  */
 public function actionEliminar($id)
 {
     $eliminadas = 0;
     $fallos = 0;
     $model = PersonaData::model()->findByPk($id);
     $personas = Persona::model()->findAll(array('condition' => 'pdata_id=' . $model->id));
     foreach ($personas as $persona) {
         $existeR = Responsable::model()->exists('persona_id=' . $persona->id);
         $existeT = BmTraspaso::model()->exists('emisor_id=' . $persona->id . ' OR receptor_id=' . $persona->id);
         $existeF = FBm3::model()->exists('observador_id=' . $persona->id);
         if (!$existeR && !$existeT && !$existeF) {
             $persona->delete();
             $eliminadas++;
         } else {
             $fallos++;
         }
     }
     if ($fallos == 0) {
         $model->delete();
         $this->redirect(array('index'));
     } else {
         Yii::app()->user->setFlash('error', 'No puede efectuarse la operación. Existen registros que utilizan este dato.');
         $this->redirect(array('view', 'pid' => $model->id));
     }
 }