public function indexAction()
 {
     $auth = Zend_Auth::getInstance();
     $log = $auth->getIdentity()->NOM_M . " " . $auth->getIdentity()->PRENOM;
     $this->view->log = $log;
     $dba = Zend_Registry::get('dba');
     $evenements = new Application_Model_Evenement($dba);
     $evenements_results = $evenements->fetchAll();
     $genre_table = new Application_Model_Genre($dba);
     $genres = $genre_table->fetchAll()->toArray();
     $genre_playlist = array();
     foreach ($genres as $genre) {
         $playlist_table = new Application_Model_Playlist($dba);
         $where = $dba->quoteInto("ID_GENRE = ?", $genre["ID_GENRE"]);
         $playlists_results = $playlist_table->fetchAll($where)->toArray();
         $playlists = array();
         foreach ($playlists_results as $playlist) {
             $playlists[] = array("PLAY_ID" => $playlist["PLAY_ID"], "NOM_PLAY" => $playlist["NOM_PLAY"]);
         }
         if (count($playlists) > 0) {
             $genre_playlist[] = array("ID_GENRE" => $genre["ID_GENRE"], "GENRE" => $genre["NOM_G"], "PLAYLISTS" => $playlists);
         }
     }
     $result = array();
     foreach ($evenements_results as $evenement) {
         $joue_table = new Application_Model_Joue($dba);
         $select = $joue_table->select()->where("EVENEMENT_ID = ?", $evenement->EVENEMENT_ID);
         $joue_results = $joue_table->fetchAll($select)->toArray();
         $color = "blue";
         if ($evenement->ID_EMISSION != NULL) {
             $color = "red";
         }
         if (count($joue_results) > 0) {
             $color = "orange";
         }
         $item = array("EVENEMENT_ID" => $evenement->EVENEMENT_ID, "D_H_DEBUT" => $evenement->D_H_DEBUT, "D_H_FIN" => $evenement->D_H_FIN, "NOM_EV" => $evenement->NOM_EV, "COLOR" => $color);
         $result[] = $item;
     }
     $emission_table = new Application_Model_Emission($dba);
     $select = $emission_table->select()->where("PATH_E IS NOT NULL");
     $this->view->podcast = $emission_table->fetchAll($select)->toArray();
     $this->view->genre_playlist = $genre_playlist;
     $this->view->evenements = $result;
 }
 function getfatherAction()
 {
     $id = $_GET["id"];
     $dba = Zend_Registry::get('dba');
     $this->_helper->layout->disableLayout(true);
     $this->_helper->viewRenderer->setNoRender(true);
     $genres_table = new Application_Model_Genre($dba);
     $where = $dba->quoteInto("ID_GENRE = ?", $id);
     $genre_tab = $genres_table->fetchAll()->toArray();
     $genres = $genres_table->fetchAll($where)->toArray();
     $res = array();
     foreach ($genre_tab as $gt) {
         if ($gt["ID_GENRE"] == $genres[0]["GEN_ID_GENRE"]) {
             $res[] = $gt;
         }
     }
     $json = json_encode($res);
     // On renvoie le tout sous format JSON
     echo $json;
 }
 public function ajouterAction()
 {
     $dba = Zend_Registry::get('dba');
     $this->_helper->layout->disableLayout(true);
     $this->_helper->viewRenderer->setNoRender(true);
     $id_genre = $_POST["id_genre"];
     $nom_play = $_POST["nom_play"];
     $result = array();
     if ($id_genre != null && $nom_play != null) {
         $datas = array('NOM_PLAY' => $nom_play, 'ID_GENRE' => $id_genre);
         $result["STATUS"] = "OK";
         $result["NOM_PLAY"] = $nom_play;
         $genre_table = new Application_Model_Genre($dba);
         $genre_row = $genre_table->find($id_genre);
         $genre = $genre_row->current();
         $result["GENRE_NAME"] = $genre->NOM_G;
         $dba->beginTransaction();
         try {
             $dba->insert('PLAYLIST', $datas);
             $dba->commit();
         } catch (Exception $e) {
             $dba->rollBack();
             echo $e->getMessage();
         }
         $playlist_table = new Application_Model_Playlist($dba);
         $where = $dba->quoteInto("NOM_PLAY = ?", $nom_play);
         $playlist = $playlist_table->fetchRow($where, "PLAY_ID DESC");
         $result["PLAY_ID"] = $playlist->PLAY_ID;
     } else {
         $result["STATUS"] = "FAIL";
     }
     $json = json_encode($result);
     echo $json;
 }