Beispiel #1
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);
     if (isset($_POST['Usuario'])) {
         $model->attributes = $_POST['Usuario'];
         $model->password = $model->hashPassword($model->password, $model->salt);
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $model->password = NULL;
     $roles = Rol::model()->findAll(array('condition' => 'id<>1'));
     $dps = Dependencia::model()->findAll(array('condition' => 'sede_id=1'));
     $this->render('update', array('model' => $model, 'roles' => $roles, 'dps' => $dps));
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $user = Usuario::model()->findbyPk(Yii::app()->user->getId());
     $acceso = Usuario::privilegiado($user->rol_id);
     date_default_timezone_set('America/Caracas');
     $fecha = date('Y-m-d H:i:s');
     $model = new Responsable();
     $model->dependencia_id = $user->dependencia_id;
     $model->fecha = $fecha;
     if (isset($_POST['Responsable'])) {
         $model->attributes = $_POST['Responsable'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $dps = Dependencia::model()->findAll(array('condition' => 'sede_id=1', 'order' => 'descripcion ASC'));
     $status = BmStatus::model()->findAll();
     $personas = Persona::model()->listAll();
     $this->render('create', array('model' => $model, 'dps' => $dps, 'status' => $status, 'personas' => $personas, 'acceso' => $acceso));
 }
Beispiel #3
0
echo $form->labelEx($model, 'Cargo_idCargo');
?>
		<?php 
echo $form->dropDownList($model, 'Cargo_idCargo', CHtml::listData(Cargo::model()->findAll(), 'idCargo', 'Nombre'), array('empty' => 'Seleccione un cargo'));
?>
		<?php 
echo $form->error($model, 'Cargo_idCargo');
?>
	</div>

	<div class="row">
		<?php 
echo $form->labelEx($model, 'Dependencia_idDependencia');
?>
		<?php 
echo $form->dropDownList($model, 'Dependencia_idDependencia', CHtml::listData(Dependencia::model()->findAll(), 'idDependencia', 'Nombre'), array('empty' => 'Seleccione una dependencia'));
?>
		<?php 
echo $form->error($model, 'Dependencia_idDependencia');
?>
	</div>

	<div class="row">
		<?php 
echo $form->labelEx($model, 'Sueldo');
?>
		<?php 
echo $form->textField($model, 'Sueldo', array('size' => 45, 'maxlength' => 45));
?>
		<?php 
echo $form->error($model, 'Sueldo');
Beispiel #4
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));
 }
Beispiel #5
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));
 }
Beispiel #6
0
			<h1> Trabajadores </h1>			
			<div class="contenido">
			
			<div class="busqueda">
			<div class="opcion">
			<br/>
			<div class="new-button">
			<?php 
$this->widget('zii.widgets.jui.CJuiButton', array('buttonType' => 'link', 'name' => 'new-worker', 'caption' => 'Nuevo trabajador', 'htmlOptions' => array('class' => 'new-button'), 'url' => array('/persona/create')));
?>
 </div>	
			<div class="update-button">
			<?php 
$this->widget('zii.widgets.jui.CJuiButton', array('buttonType' => 'link', 'name' => 'update-worker', 'caption' => 'Actualizar trabajador', 'url' => array('/trabajador/index')));
?>
 </div>	
			</div>
			<br/>
		
			</div>
			<br/>

<?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'trabajador-grid', 'cssFile' => Yii::app()->baseUrl . '/css/gridview/styles.css', 'summaryText' => 'Mostrando resultados {start} al {end} de {count} en total', 'dataProvider' => $model->search(), 'emptyText' => 'No se encontraron resultados', 'filter' => $model, 'columns' => array('idTrabajador', array('name' => 'Nacionalidad', 'filter' => array('V' => 'Venezolano', 'E' => 'Extranjero')), array('name' => 'Sexo', 'filter' => array('M' => 'Masculino', 'F' => 'Femenino')), array('name' => 'persona_nombre', 'value' => 'Persona::model()->find(" idPersona = ".$data->Persona_idPersona)->Nombre'), array('name' => 'persona_apellido', 'value' => 'Persona::model()->find(" idPersona = ".$data->Persona_idPersona)->Apellido; '), array('name' => 'persona_cedula', 'value' => 'Persona::model()->find(" idPersona = ".$data->Persona_idPersona)->Cedula; '), array('name' => 'Dependencia_idDependencia', 'filter' => CHtml::listData(Dependencia::model()->findAll(), 'idDependencia', 'Nombre'), 'value' => 'Dependencia::model()->find(" idDependencia = ".$data->Dependencia_idDependencia)->Nombre;'), array('class' => 'CButtonColumn'))));
?>
  
			</div>
 /**
  * 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 = Dependencia::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 /**
  * Lists all models.
  */
 public function actionIndex()
 {
     $this->pageTitle = 'Listar Bienes';
     $filtro = new BmFiltro();
     $user = Usuario::model()->findbyPk(Yii::app()->user->getId());
     $acceso = Usuario::privilegiado($user->rol_id);
     if (isset($_GET['BmFiltro'])) {
         $filtro->attributes = $_GET['BmFiltro'];
     }
     $vars = array();
     $vars['dps'] = Dependencia::model()->findAll(array('condition' => 'sede_id=1', 'order' => 'descripcion ASC'));
     $vars['clases'] = BmClasificacion::model()->listAll();
     $vars['tipos'] = BmTipo::model()->findAll(array('order' => 'descripcion'));
     $vars['conceptos'] = Concepto::model()->findAll();
     $vars['status'] = BmStatus::model()->findAll();
     $vars['anhos'] = array('1' => "2012", '2' => "2011");
     $dataProvider = $filtro->search();
     $this->render('index', array('dataProvider' => $dataProvider, 'filtro' => $filtro, 'vars' => $vars, 'acceso' => $acceso));
 }
Beispiel #9
0
 /**
  * Asociar Cargo
  */
 public function actionAdd($persona_id)
 {
     $persona = PersonaData::model()->findByPk($persona_id);
     if (isset($persona)) {
         $model = new Persona();
         $model->pdata_id = $persona->id;
         $model->status_id = 1;
         if (isset($_POST['Persona'])) {
             $model->attributes = $_POST['Persona'];
             date_default_timezone_set('America/Caracas');
             $fecha = date('Y-m-d H:i:s');
             $model->fecha = $fecha;
             if ($model->save()) {
                 $this->redirect(array('view', 'pid' => $model->pdata_id));
                 //else print_r($model->getErrors()); exit;
             }
             //else print_r($persona->getErrors()); exit;
         }
         if ($persona->sexo_id == 1) {
             $cargos = Cargo::model()->findAll(array('order' => 'descripcion ASC'));
         } else {
             $cargos = Cargo::model()->findAll(array('select' => 'id, desc_f as descripcion', 'order' => 'descripcion ASC'));
         }
         $dps = Dependencia::model()->findAll(array('condition' => 'sede_id=1', 'order' => 'descripcion ASC'));
         $this->render('add', array('persona_id' => $persona->id, 'model' => $model, 'cargos' => $cargos, 'dps' => $dps));
     } else {
         $this->redirect(array('create'));
     }
 }