Пример #1
0
 public function indexAction()
 {
     $smarty = Zend_Registry::get('view');
     $model = $this->_getModel();
     $modelLanJeux = $this->_getModelLanJeux();
     $modelConfig = $this->_getModelConfig();
     $request = $this->getRequest();
     $mode = $request->getParam('m', '');
     $lan_ouverte_date = $model->fetchEntryOuverteDateField(array('idLan'));
     $lan_ouverte = $model->fetchEntryOuverteField(array('idLan'));
     $map = null;
     $map_google = 0;
     if ($lan_ouverte_date == -1 || $mode == "histo") {
         //pointe vers l'affichage de l'ensemble des lans
         $lans = $model->fetchEntriesorderByDateField(array('idLan', 'nom', 'datedeb', 'datefin', 'adresse', 'cp', 'ville', 'extra', 'description', 'prix', 'prix_prepaiement_paypal', 'prix_prepaiement', 'telethon'));
         $chiffre = array();
         $jeux = array();
         foreach ($lans as $lan) {
             $chiffre[$lan['idLan']]['insc'] = $model->fetchEntriesCountValide($lan['idLan']);
             $chiffre[$lan['idLan']]['present'] = $model->fetchEntriesCountPresent($lan['idLan']);
             if ($lan['idLan'] == $lan_ouverte['idLan']) {
                 $chiffre[$lan['idLan']]['pre_inscrit'] = $model->fetchEntriesCountPreInscrits($lan['idLan']);
             }
             $jeux[$lan['idLan']] = $modelLanJeux->fetchEntriesByLanField($lan['idLan'], array(''), array(''), array('nom'));
         }
         $smarty->assign('lan_ouverte', $lan_ouverte);
         $smarty->assign('lans', $lans);
         $smarty->assign('chiffre', $chiffre);
         $smarty->assign('jeux', $jeux);
         $smarty->assign('titre', 'Lans');
         $smarty->assign('base_url', $request->getBaseUrl());
         $smarty->display('lan/index.tpl');
     } else {
         //poite vers la prochaine et unique lan
         $lan = $model->fetchEntry($lan_ouverte_date);
         $jeux[$lan['idLan']] = $modelLanJeux->fetchEntriesByLanField($lan['idLan'], array(''), array(''), array('nom'));
         $chiffre['insc'] = $model->fetchEntriesCountValide($lan['idLan']);
         $chiffre['present'] = $model->fetchEntriesCountPresent($lan['idLan']);
         if ($lan['idLan'] == $lan_ouverte['idLan']) {
             $chiffre['pre_inscrit'] = $model->fetchEntriesCountPreInscrits($lan['idLan']);
         }
         if ($lan['datedeb'] < date('YYYY-MM-DD')) {
             try {
                 // API Google Map v3
                 require APPLICATION_PATH . '/../library/My/GoogleMapAPI.class.php';
                 $map = new GoogleMapAPI();
                 $map->setMapType('ROADMAP');
                 $map->setDivId('googlemap');
                 // fixe les dimensions de la carte
                 $map->setSize('400px', '350px');
                 // definition du zoom automatique
                 $map->setZoom(8);
                 $map->setCenter($lan['ville']);
                 // ajout du marqueur lan sur la carte
                 $map->addMarkerByAddress($lan['adresse'] . '-' . $lan['ville'] . '-' . $lan['cp'], $lan['nom'], "<span class='rouge'><strong>{$lan['nom']}</strong></span><br/>{$lan['adresse']}<br/>{$lan['ville']} ({$lan['cp']})", $lan['nom'], $request->getBaseUrl() . '/images/admin/computer_gmap.png');
                 $map->generate();
                 $smarty->assign('map', $map);
                 $map_google = 1;
             } catch (Exception $e) {
                 $map_google = 2;
                 $map_error = "Probleme Map Google";
                 $smarty->assign('map_error', $map_error);
             }
         }
         $smarty->assign('lan_ouverte', $lan_ouverte);
         $smarty->assign('lan', $lan);
         $smarty->assign('chiffre', $chiffre);
         $smarty->assign('jeux', $jeux);
         $smarty->assign('map_google', $map_google);
         $smarty->assign('titre', 'Lans');
         $smarty->assign('base_url', $request->getBaseUrl());
         $smarty->display('lan/index_ouverte.tpl');
     }
 }