'Gestion des sites', 'page callback' => 'application_ags_rederable_page', 'access callback' => TRUE, ); return $items; } /* * hook_theme(). */ function application_ags_theme($existing, $type, $theme, $path) { return array( 'application_ags_template' => array( 'variables' => array('liste_site' => NULL,'nb_ligne' => NULL,'res_site' => NULL), 'template' => 'application_ags_template', ), ); } /* * Call function using renderable array. */ function application_ags_rederable_page() { // nb_ligne du tableau ( donc de site ) $query_nb_ligne = db_query(' select count(*)+1 as nb from ags_site'); $res_nb_ligne = $query_nb_ligne; while($record = $res_nb_ligne -> fetchAssoc() ) { $nb_ligne['nb'] = $record['nb']; } // Select les sites et leurs infos $query_les_sites = db_query(' select site.idSite, site.adresse, site.public, ( site.dateOuverture + interval site.dureeContrat year ) as finContrat, Datediff((site.dateOuverture + interval site.dureeContrat year), DATE(NOW())) as tempsRestant, site.typeHebergement, typeSite.libelleTypeSite, concat(tech.nom, tech.version) as techno , statut.libelleStatut from {ags_site} site, {ags_typeSite} typeSite, {ags_technologie} tech, {ags_statut} statut where site.idTypeS = typeSite.idTypeS and site.idStatut = statut.idStatut and site.idTech = tech.idTech order by (finContrat)'); $res_les_sites = $query_les_sites; $i = 1; while( $record = $res_les_sites -> fetchAssoc() ) { $liste_site[$i]['idSite'] = $record['idSite']; $liste_site[$i]['adresse'] = $record['adresse']; $liste_site[$i]['finContrat'] = $record['finContrat']; $liste_site[$i]['tempsRestant'] = $record['tempsRestant']; $liste_site[$i]['typeHebergement'] = $record['typeHebergement']; $liste_site[$i]['typeSite'] = $record['libelleTypeSite']; $liste_site[$i]['techNom'] = $record['techno']; $liste_site[$i]['statut'] = $record['libelleStatut']; // change le typehebergement en 'UFC' ou 'Autres'. if( $record['typeHebergement'] == 1) { $liste_site[$i]['typeHebergement'] = 'ufc'; } else { $liste_site[$i]['typeHebergement'] = 'autres'; } // change le numérique en 'oui' ou 'non'. if( $record['public'] == 1 ) { $liste_site[$i]['public'] = 'oui'; } else { $liste_site[$i]['public'] = 'non'; } // recupère les informations des responsables du site "$record['idSite']" $query_les_ResSite = db_query(' select res.idR, res.nom, res.prenom, res.tel, res.mail, typeRes.libelleTypeR from ags_gerer gerer, ags_responsable res, ags_typeResponsable typeRes where gerer.idSite ='.$record['idSite'].' and gerer.idR = res.idR and res.idTypeR = typeRes.idTypeR'); $res_les_resSite = $query_les_ResSite; $j=0; // rempli les informations du/des responsable du site "$record['idSite']" while( $rec = $res_les_resSite -> fetchAssoc() ) { $res_site[$record['idSite']] [$j] ['idRes'] = $rec['idR']; $res_site[$record['idSite']] [$j] ['nomRes'] = $rec['nom']; $res_site[$record['idSite']] [$j] ['prenomRes'] = $rec['prenom']; $res_site[$record['idSite']] [$j] ['tel'] = $rec['tel']; $res_site[$record['idSite']] [$j] ['mail'] = $rec['mail']; $res_site[$record['idSite']] [$j] ['fonction'] = $rec['libelleTypeR']; $res_site[$record['idSite']] [$j] ['nb_Res'] = $j+1; $j++; } // incrementation $i++; } // intialisation des valeurs pour le template $output = array( '#theme' => 'application_ags_template', '#type' => 'markup', '#liste_site' => $liste_site, '#nb_ligne' => $nb_ligne, '#res_site' => $res_site, ); return $output; }