Ver Mensaje Individual
  #1 (permalink)  
Antiguo 28/01/2014, 11:17
nhernandez222
 
Fecha de Ingreso: enero-2014
Mensajes: 12
Antigüedad: 10 años, 3 meses
Puntos: 0
Duda jquery y php

Amigos, estoy trabajando con Hoteles que se le asignan categorias. Necesito eliminar un hotel pero no se puede pues tiene categorias asignadas. Lo que quiero lograr hacer es lo siguiente:

Al poner eliminar le mando el siguiente script :

Código Javascript:
Ver original
  1. <script>
  2. $(function(){
  3.     $('.option_delete').on('click', function (e) {
  4.         modal.confirm('<?=h(__('Do you really want to delete this Hotel?'));?>', function () {
  5.         window.location.href = '<?php echo $this->Html->url(array('controller' => 'hotels',
  6.             'action' => 'delete',
  7.             $hotels['Hotel']['id']));?>';
  8.         });
  9.     });
  10. });
  11. </script>

Aqui se le deberia decir que no se puede eliminar porque tiene asignado X cantidad de categorias y preguntarle si quiere asignar esas categorias a otro Hotel, si el pone que si, mostrarle una especie de lista de los Hoteles que hay disponibles, el seleccionarlo y seguir el procedimiento.

Codigo de eliminar:

Código PHP:
Ver original
  1. public function admin_delete($id = null) {
  2.             $this->Hotel->id = $id;
  3.             if (!$this->Hotel->exists())
  4.                 throw new NotFoundException(__('Invalid Hotel'));
  5.             $resultSelected= $this->Hotel->Category->find('count', array('conditions'=>array('Category.hotel_id' => $id)));
  6.             if ($resultSelected > 0)
  7.  
  8.                 //throw new RuntimeException(__('There are categories bind to this Hotel, unbind and try again.'));
  9.        
  10.             if (!$this->Hotel->delete())
  11.                 throw new RuntimeException(__('The role couldn\'t be deleted. Try again'));
  12.             $this->Session->setSuccess(__('Hotel successfully deleted'));
  13.             $this->redirect(array('action' => 'index'));
  14.     }

Alguna idea de como hacerlo??? Slds.