Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class DemandantesController extends AppController {
- var $name = 'Demandantes';
- function index() {
- $this->Demandante->recursive = 0;
- $this->set('demandantes', $this->paginate());
- }
- /*function view($id = null) {
- if (!$id) {
- $this->Session->setFlash(sprintf(__('Invalid %s', true), 'demandante'));
- $this->redirect(array('action' => 'index'));
- }
- $this->set('demandante', $this->Demandante->read(null, $id));
- }*/
- function view($cedula = null) {
- $juzgado = $this->loadModel('Juzgado', $this->Demandante->find('first', array('cedula'=>$cedula)));
- $this->set('juzgado', $juzgado);
- if (!$cedula) {
- $this->Session->setFlash(sprintf(__('Invalid %s', true), 'demandante'));
- $this->redirect(array('action' => 'index'));
- }
- //$this->set('demandante', $this->Demandante->read(null, $id));
- $demandante = $this->set('demandante', $this->Demandante->find('first', array('conditions' => array('Demandante.cedula'=>$cedula))));
- var_dump($this->demandante);
- $demandado = $this->loadModel('Demandado', $demandante['Proceso']['demandado_id']);
- $this->set('demandado', $demandado);
- }
- function add() {
- if (!empty($this->data)) {
- $this->Demandante->create();
- $this->loadModel('Usuario');
- $this->Usuario->create();
- if ($this->Demandante->save($this->data) && $this->Usuario->save(array(
- 'id'=>$this->data['Demandante']['cedula'],
- 'username'=>$this->data['Demandante']['cedula'],
- 'password'=>$this->Auth->password($this->data['Demandante']['cedula']),
- 'grupo_id'=>'3'
- )
- )
- ) {
- $this->Session->setFlash(sprintf(__('The %s has been saved', true), 'demandante'));
- $this->redirect(array('action' => 'index'));
- } else {
- $this->Session->setFlash(sprintf(__('The %s could not be saved. Please, try again.', true), 'demandante'));
- }
- }
- }
- function edit($id = null) {
- if (!$id && empty($this->data)) {
- $this->Session->setFlash(sprintf(__('Invalid %s', true), 'demandante'));
- $this->redirect(array('action' => 'index'));
- }
- if (!empty($this->data)) {
- if ($this->Demandante->save($this->data)) {
- $this->Session->setFlash(sprintf(__('The %s has been saved', true), 'demandante'));
- $this->redirect(array('action' => 'index'));
- } else {
- $this->Session->setFlash(sprintf(__('The %s could not be saved. Please, try again.', true), 'demandante'));
- }
- }
- if (empty($this->data)) {
- $this->data = $this->Demandante->read(null, $id);
- }
- }
- function delete($id = null) {
- if (!$id) {
- $this->Session->setFlash(sprintf(__('Invalid id for %s', true), 'demandante'));
- $this->redirect(array('action'=>'index'));
- }
- if ($this->Demandante->delete($id)) {
- $this->Session->setFlash(sprintf(__('%s deleted', true), 'Demandante'));
- $this->redirect(array('action'=>'index'));
- }
- $this->Session->setFlash(sprintf(__('%s was not deleted', true), 'Demandante'));
- $this->redirect(array('action' => 'index'));
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement