$totalAlertes = array();
foreach($instances as $instance) {
$historique = $historiquesController->Historique->findById($instance['Instance']['historique']);
- if (!$historique) {
- throw new NotFoundException(__('Historique introuvable'));
- }
- // RÉCUPÉRATION DES ALERTES DE L'HISTORIQUE
- if($historique['Historique']['alertes']) {
- $alertes_id = explode('|', $historique['Historique']['alertes']);
- $alertes = array();
- foreach ($alertes_id as $alerte_id) {
- $alertes[] = $alertesController->Alerte->findById($alerte_id);
+ if ($historique) {
+ // RÉCUPÉRATION DES ALERTES DE L'HISTORIQUE
+ if($historique['Historique']['alertes']) {
+ $alertes_id = explode('|', $historique['Historique']['alertes']);
+ $alertes = array();
+ foreach ($alertes_id as $alerte_id) {
+ $alertes[] = $alertesController->Alerte->findById($alerte_id);
+ }
+ // AJOUT DANS LA LISTE DES ALERTES
+ $totalAlertes[$historique['Historique']['id']] = $alertes;
}
- // AJOUT DANS LA LISTE DES ALERTES
- $totalAlertes[$historique['Historique']['id']] = $alertes;
+ // AJOUT DANS LA LISTE DES HISTORIQUES
+ $historiques[$instance['Instance']['id']] = $historique;
}
- // AJOUT DANS LA LISTE DES HISTORIQUES
- $historiques[$instance['Instance']['id']] = $historique;
-
}
// ENVOI DES DONNÉES À LA VUE
}
public function add() {
- if ($this->request->is('instance')) {
+ if ($this->request->is('POST')) {
$this->Instance->create();
if ($this->Instance->save($this->request->data)) {
$this->Session->setFlash(__("L'instance a été enregistrée."));
if ($this->request->is('get')) {
throw new MethodNotAllowedException();
}
-
+ $instance = $this->Instance->findById($id);
+ if (!$instance) {
+ throw new NotFoundException(__('Instance introuvable'));
+ }
if ($this->Instance->delete($id)) {
$this->Session->setFlash(
- __("L'instance d'id: %s a été supprimée.", h($id))
+ __("L'instance %s a été supprimée.", h($instance['Instance']['reference']))
);
return $this->redirect(array('action' => 'index'));
}