/app/controllers/atenciones_integrales_controller.php
PHP | 107 lines | 93 code | 9 blank | 5 comment | 19 complexity | c6ad411d96575ad784569952f11f07ff MD5 | raw file
- <?php
- class AtencionesIntegralesController extends AppController {
-
- var $name = 'AtencionesIntegrales';
- var $uses = array('UsersEquiposOperativo', 'Zona','AtencionesIntegrale');
- var $helpers = array('AtencionesIntegrale');
-
- function index() {
- $usuario_activo = $this->Access->getMy('username');
- //Verificacion de sesion del sistema
- if(!$usuario_activo){
- $this->Session->setFlash(__('Por favor inicie sesion', true));
- $this->redirect(array('controller'=>'users','action' => 'login'));
- }
- $this->AtencionesIntegrale->recursive = 0;
-
- $group_id= $this->Access->getMy('group_id');
- $user_id= $this->Access->getMy('id');
- $eo= $this->UsersEquiposOperativo->find('first',array('conditions'=>array('UsersEquiposOperativo.user_id'=>$user_id)));
- $zona_id=$this->Zona->find('all',array('conditions'=>array('Zona.id'=>$eo['EquiposOperativo']['zona_id'])));
- if($group_id=="1"){ //Si es administrador
- $zona_id = $this->Zona->find('all');
- }
- $this->set(compact('zona_id'));
-
- $this->set('atencionesIntegrales', $this->paginate());
- }
-
- function view($id = null) {
- $usuario_activo = $this->Access->getMy('username');
- //Verificacion de sesion del sistema
- if(!$usuario_activo){
- $this->Session->setFlash(__('Por favor inicie sesion', true));
- $this->redirect(array('controller'=>'users','action' => 'login'));
- }
- if (!$id) {
- $this->Session->setFlash(__('Invalid atenciones integrale', true));
- $this->redirect(array('action' => 'index'));
- }
- $this->set('atencionesIntegrale', $this->AtencionesIntegrale->read(null, $id));
- }
-
- function add($bimestre=null, $year=null, $zona=null) {
- $usuario_activo = $this->Access->getMy('username');
- //Verificacion de sesion del sistema
- if(!$usuario_activo){
- $this->Session->setFlash(__('Por favor inicie sesion', true));
- $this->redirect(array('controller'=>'users','action' => 'login'));
- }
- if (!empty($this->data)) {
- $this->AtencionesIntegrale->create();
- if ($this->AtencionesIntegrale->save($this->data)) {
- $this->Session->setFlash(__('The atenciones integrale has been saved', true));
- $this->redirect(array('action' => 'index'));
- } else {
- $this->Session->setFlash(__('The atenciones integrale could not be saved. Please, try again.', true));
- }
- }
- $bimestre=$year."-".$bimestre;
- $this->set(compact('zona', 'bimestre'));
- }
-
- function edit($bimestre=null, $year=null, $zona=null){
- $usuario_activo = $this->Access->getMy('username');
- //Verificacion de sesion del sistema
- if(!$usuario_activo){
- $this->Session->setFlash(__('Por favor inicie sesion', true));
- $this->redirect(array('controller'=>'users','action' => 'login'));
- }
- if (!$bimestre && !$year && !$zona && empty($this->data)) {
- $this->Session->setFlash(__('Invalid atenciones integrale', true));
- $this->redirect(array('action' => 'index'));
- }
- if (!empty($this->data)) {
- if ($this->AtencionesIntegrale->save($this->data)) {
- $this->Session->setFlash(__('The atenciones integrale has been saved', true));
- $this->redirect(array('action' => 'index'));
- } else {
- $this->Session->setFlash(__('The atenciones integrale could not be saved. Please, try again.', true));
- }
- }
-
- $datos = $this->AtencionesIntegrale->find('first', array('conditions'=>array('AtencionesIntegrale.zona_id'=>$zona,
- 'AND'=>array('AtencionesIntegrale.bimestre'=>$year."-".$bimestre))));
- $this->set(compact('datos'));
- }
-
- function delete($id = null) {
- $usuario_activo = $this->Access->getMy('username');
- //Verificacion de sesion del sistema
- if(!$usuario_activo){
- $this->Session->setFlash(__('Por favor inicie sesion', true));
- $this->redirect(array('controller'=>'users','action' => 'login'));
- }
- if (!$id) {
- $this->Session->setFlash(__('Invalid id for atenciones integrale', true));
- $this->redirect(array('action'=>'index'));
- }
- if ($this->AtencionesIntegrale->delete($id)) {
- $this->Session->setFlash(__('Atenciones integrale deleted', true));
- $this->redirect(array('action'=>'index'));
- }
- $this->Session->setFlash(__('Atenciones integrale was not deleted', true));
- $this->redirect(array('action' => 'index'));
- }
- }
- ?>