Al poner eliminar le mando el siguiente script :
Código Javascript:
Ver original
<script> $(function(){ $('.option_delete').on('click', function (e) { modal.confirm('<?=h(__('Do you really want to delete this Hotel?'));?>', function () { window.location.href = '<?php echo $this->Html->url(array('controller' => 'hotels', 'action' => 'delete', $hotels['Hotel']['id']));?>'; }); }); }); </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
public function admin_delete($id = null) { $this->Hotel->id = $id; if (!$this->Hotel->exists()) throw new NotFoundException(__('Invalid Hotel')); if ($resultSelected > 0) //throw new RuntimeException(__('There are categories bind to this Hotel, unbind and try again.')); if (!$this->Hotel->delete()) throw new RuntimeException(__('The role couldn\'t be deleted. Try again')); $this->Session->setSuccess(__('Hotel successfully deleted')); }
Alguna idea de como hacerlo??? Slds.