13,6 → 13,8 |
// $Id: annuaire_moteur_fonction.php,v 1.1 2005/03/24 08:47:31 alex Exp $ |
|
|
include_once 'api/pear/HTML/QuickForm/select.php'; |
|
/** function mkengine () |
* |
* |
25,8 → 27,8 |
global $label_bbota; |
global $nbr_total; |
global $bouton, $HTTP_POST_VARS ; |
$mon_frag = new fragmenteur_session() ; |
|
|
$mes_vars = array ("recherche", "nom", "ville", "mail" ,"dept", "prenom", "cotisant", "pays", "sort", "T_REPONSE", "lettre","statut") ; |
|
// Deux cas , soit on a cliqué sur rechercher, soit on a cliqué sur un lien |
33,7 → 35,7 |
foreach ($mes_vars as $key=>$value) { |
if (!$bouton) { // on a cliqué sur un lien |
if (empty($HTTP_POST_VARS[$value])) { |
$$value = $mon_frag->getVariable($value); |
|
} |
} else { |
// Si on clique sur le bouton rechercher |
44,137 → 46,94 |
} |
} |
} |
|
// Comptage du nombre total de données dans la table (hors CACHER = 1) |
$query = "select count(*) as CPT from ".ANN_ANNUAIRE; |
$result = mysql_query($query) or die("<B>Erreur !</B> $query a échoué..."); |
$result = $GLOBALS['ann_db']->query($query) ; |
if (DB::isError($result)) { |
return $result->getMessage().'<br />'.$result->getDebugInfo(); |
} |
|
if (mysql_num_rows($result) == 1) |
{ |
$tmp_nb = mysql_fetch_object($result); |
$nbr_total = $tmp_nb->CPT; |
if ($nbr_total > 0) $chaine = "parmi $nbr_total données"; |
else die("<B>Erreur</B> lors du comptage des structures ($nbr_total trouvées) : $query"); |
} |
else die("<B>Erreur</B> lors du comptage des structures : $query"); |
if ($result->numRows() == 1) { |
$tmp_nb = $result->fetchRow(DB_FETCHMODE_OBJECT); |
$nbr_total = $tmp_nb->CPT; |
if ($nbr_total > 0) $chaine = "parmi $nbr_total données"; |
else die("<B>Erreur</B> lors du comptage des structures ($nbr_total trouvées) : $query"); |
} else die("<B>Erreur</B> lors du comptage des structures : $query"); |
|
mysql_free_result($result); |
$result->free(); |
// fin comptage |
|
$ret = ""; |
|
$ret = '<h1>'.AM_L_TITRE.'</h1>'."\n"; |
$ret .= '<h2>'.AM_L_TITRE.' '.$chaine.'</h2>'."\n"; |
// construction du moteur de str |
|
$ret .= "<form action=\"".$GLOBALS['ann_url']->getURL()."\" method=\"post\">\n"; |
$ret .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" summary=\"\">\n"; |
$ret .= "<tr class=\"titlePage\"><td colspan=\"2\">".AM_L_TITRE."</td></tr>\n" ; |
$ret .= "<tr class=\"insTitle1\"><td colspan=\"2\">".AM_L_TITRE." $chaine :</td></tr>\n" ; |
$formulaire = new HTML_QuickForm('formulaire_recherche', 'post', str_replace('&', '&', $GLOBALS['ann_url']->getURL())); |
|
$formulaire->addElement('text', 'recherche', AM_L_RECHERCHER); |
|
$requete = 'select GC_ID, GC_NAME from gen_COUNTRY where GC_LOCALE="fr"'; |
$pays = &$GLOBALS['ann_db']->getAssoc ($requete); |
|
$pays = array_merge (array('tous' => 'Tous les pays'), $pays); |
|
if (DB::isError($pays)) { |
return $pays->getMessage().'<br />'.$pays->getDebugInfo(); |
} |
|
// ligne de recherche |
$ret .= "<tr><td colspan=\"2\">\n"; |
$ret .= "<table border=\"0\"><tr>\n" ; |
$ret .= "<td class=\"insLabel\">".AM_L_RECHERCHER." :\n</td>\n<td>"; |
$ret .= form_mk_chaineI(stripslashes($recherche), "recherche")." "; |
$ret .= "</td><td class=\"insLabel\" colspan=\"4\">".AM_L_PAYS." : \n" ; |
$ret .= "" ; |
|
// formulaire contenant les pays, avec par défaut soit le pays en cours |
// soit "tous les pays" |
$select = new HTML_QuickForm_select ('pays', AM_L_PAYS, $pays, array ('class' => 'projet_asso')) ; |
$formulaire->addElement($select) ; |
$formulaire->addElement('text', 'nom', AM_L_NOM); |
$formulaire->addElement('text', 'prenom', AM_L_PRENOM); |
$formulaire->addElement('text', 'ville', AM_L_VILLE); |
|
$departement = & $GLOBALS['ann_db']->getAssoc('select GFD_ID, CONCAT(GFD_ID,\' - \',GFD_NAME) as GFD_NAME from gen_FRENCH_DPT'); |
$departement = array_merge (array ('tous' => 'Tous'), $departement); |
|
$select_dpt = new HTML_QuickForm_select ('departement', AM_L_DEPARTEMENT, $departement, array ('class' => 'projet_asso')) ; |
$formulaire->addElement($select_dpt); |
|
$formulaire->addElement('text', 'mail', AM_L_MAIL); |
|
$cotisant = array (1 => 'Tous', 2 => 'Cotisants', 3 => 'Non cotisants'); |
|
$select_cotisant = new HTML_QuickForm_select ('cotisant', AM_L_COTISANTS, $cotisant, array ('class' => 'projet_asso')) ; |
$formulaire->addElement($select_cotisant); |
|
$requete = 'select distinct(YEAR(IC_DATE)) as annees from annuaire_COTISATION'; |
$resultat_annee_cotisation = &$GLOBALS['ann_db']->query ($requete); |
|
$query_pays = "select GC_ID, GC_NAME from gen_COUNTRY where GC_LOCALE='fr'" ; |
$result_pays = mysql_query($query_pays) or die ("Echec de la requete sur gen_COUNTRY") ; |
$ret .= "<select name=\"pays\" class=\"insInputForm\">\n" ; |
$ret .= "<option value=\"tous\">Tous les pays</option>\n" ; |
while ($row_pays = mysql_fetch_object($result_pays)) { |
$ret .= "<option value=\"$row_pays->GC_ID\"" ; |
if (!empty($pays)) { |
if ($pays == $row_pays->GC_ID) $ret .= " selected" ; |
} |
$ret .= ">$row_pays->GC_NAME</option>\n" ; |
if (DB::isError($resultat_annee_cotisation)) { |
return $resultat_annee_cotisation->getMessage().'<br />'.$resultat_annee_cotisation->getDebugInfo(); |
} |
$tableau_annee_cotisation['Toutes'] = 'Toutes'; |
while ($ligne_annee_cotisation = $resultat_annee_cotisation->fetchRow(DB_FETCHMODE_OBJECT)) { |
$tableau_annee_cotisation[$ligne_annee_cotisation->annees] = $ligne_annee_cotisation->annees; |
} |
$ret .= "</select>\n" ; |
$ret .= "</td>\n" ; |
|
$ret .= "<tr>\n"; |
$ret .= "<td class=\"insLabel\">".AM_L_NOM." :\n</td><td>"; |
$ret .= form_mk_chaineI(stripslashes($nom), "nom")." </td>\n<td class=\"insLabel\">" ; |
$ret .= AM_L_PRENOM." :</td>\n<td>".form_mk_chaineI(stripslashes($prenom), "prenom")." </td>\n<td class=\"insLabel\">" ; |
$ret .= AM_L_VILLE." :</td>\n<td>".form_mk_chaineI(stripslashes($ville), "ville")." </td>" ; |
$ret .= "</tr><tr>\n" ; |
$ret .= "<td class=\"insLabel\">".AM_L_DEPARTEMENT." : </td>\n<td>" ; |
|
// Construction du <select> des départements |
$requete_dpt = "select GFD_ID, GFD_NAME from gen_FRENCH_DPT" ; |
$resultat_dpt = mysql_query($requete_dpt) or die ("Echec de la requete sur gen_FRENCH_DPT<br>".mysql_error()) ; |
$ret .= "<select name=\"dept\" class=\"insInputForm\">\n" ; |
$ret .= "<option value=\"tous\">tous</option>\n" ; |
while ($ligne_dpt = mysql_fetch_object($resultat_dpt)) { |
$ret .= "<option value=\"$ligne_dpt->GFD_ID\"" ; |
if ($dept == $ligne_dpt->GFD_ID) $ret .= " selected" ; |
$ret .= ">$ligne_dpt->GFD_ID - $ligne_dpt->GFD_NAME</option>\n" ; |
} |
$ret .= "</select></td>\n" ; |
|
$ret .= "<td class=\"insLabel\">".AM_L_MAIL." : </td>\n<td>".form_mk_chaineI(stripslashes($mail), "mail")."</td>\n" ; |
$ret .= "<td class=\"insLabel\">".AM_L_COTISANTS." : </td>\n" ; |
$ret .= "<td>".form_mk_select(stripslashes($cotisant), "cotisant")."</td>\n"; |
$ret .= "</tr></table>\n"; |
$ret .= "</td></tr>\n"; |
|
$ret .= "<tr><td><table>\n" ; |
|
|
$ret .= "<tr>\n"; |
|
$select_annee = new HTML_QuickForm_select ('annee_cotisation', 'Année', $tableau_annee_cotisation, array ('class' => 'projet_asso')) ; |
$formulaire->addElement($select_annee); |
|
$grp = array(20 => 20, 50 => 50, 100 => 100) ; |
$select_grp = new HTML_QuickForm_select ('T_REPONSE', '', $grp, array ('class' => 'projet_asso')) ; |
$formulaire->addElement($select_grp); |
$formulaire->addElement('submit', 'bouton', AM_L_RECHERCHER); |
foreach ($mes_vars as $key=>$value) { |
if (isset($_POST[$value])) { |
$default[$value] = $_POST[$value] ; |
} |
} |
$formulaire->setDefaults($_POST); |
|
$ret .= "<td class=\"insLabel\" width=\"60%\">\n"; |
$ret .= AM_L_GRP_RES." : </td>" ; |
$grp = array(20, 50, 100) ; |
$ret .= "<td><select name=\"T_REPONSE\" class=\"insInputForm\">\n" ; |
for ($i = 0; $i < count($grp); $i++) { |
$ret .= "<option value=\"".$grp[$i]."\">".$grp[$i]."</option>\n" ; |
} |
$ret .= "</select></td>" ; |
$ret .= "<td class=\"texte_tb\" align=\"right\" width=\"40%\">\n"; |
$ret .= "<input type=\"submit\" class=\"texte_tb\" value=\"".AM_L_RECHERCHER."\" name =\"bouton\">\n"; |
$ret .= "</td></tr></table>\n</td></tr>\n"; |
$ret .= "</table></form>\n"; |
$ret .= '<br />'.$formulaire->toHTML(); |
return $ret; |
} |
|
/** function form_mk_chaineI () Renvoie une balise de type <input> |
* |
* @param string l'attribut value de la balise |
* @param string l'attibut name de la balise |
* @param string la classe CSS |
* @return string HTML |
*/ |
function form_mk_chaineI($value="", $name, $class="insInputForm") |
{ |
return "<input type=\"text\" size=\"15\" value=\"$value\" name=\"$name\" class=\"$class\">"; |
} |
|
function form_mk_select($value="", $name="", $class="insInputForm") { |
$res = "<select name=\"$name\" class=\"$class\">\n" ; |
$res .= "<option value=\"1\"" ; |
if ($value == 1) $res .= " selected" ; |
$res .= ">Cotisants</option>\n" ; |
$res .= "<option value=\"2\"" ; |
if ($value == 2) $res .= " selected" ; |
$res .= ">Non cotisants</option>\n" ; |
$res .= "<option value=\"3\"" ; |
if ($value == 3 || $value == "") $res .= " selected" ; |
$res .= ">Tous</option>\n" ; |
$res .= "</select>\n" ; |
return $res ; |
} |
|
function mkquery() |
{ |
// définition des variables globales |
global $lettre ; |
global $bouton, $HTTP_POST_VARS ; |
global $bouton ; |
|
$mon_frag = new fragmenteur_session() ; |
|
// Requete sur l'annuaire pour extraire le nom, prénom, ville, nom du département (jointure), |
// l'état de la cotisation (jointure) |
|
182,40 → 141,51 |
$fields_annu = array("nom" => "U_NAME", "prenom" => "U_SURNAME" , "mail" => "U_MAIL" , "ville" => "U_CITY", |
"dept" => "U_FRENCH_DPT", "pays" => "U_COUNTRY" ) ; |
|
$mes_vars = array ("recherche", "nom", "ville", "mail" ,"dept", "prenom", "cotisant", "pays", "sort", "T_REPONSE", "lettre","statut") ; |
$mes_vars = array ("recherche", "nom", "ville", "mail" ,"dept", |
"prenom", "cotisant", "pays", "sort", "T_REPONSE", |
"lettre","statut", "annee_cotisation") ; |
|
foreach ($mes_vars as $key=>$value) { |
if (!$bouton) { |
if (empty($HTTP_POST_VARS[$value])) { |
$$value = $mon_frag->getVariable($value); |
} |
|
} else { |
$lettre = "" ; |
$mon_frag->setVariable("lettre", "") ; |
$mon_frag->fixerLeDebut(0) ; |
if (empty ($HTTP_POST_VARS[$value])) { |
if (empty ($_REQUEST[$value])) { |
$$value = "" ; |
} else { |
$$value = $HTTP_POST_VARS[$value] ; |
$$value = $_REQUEST[$value] ; |
} |
} |
} |
if ($bouton) $sort = $mon_frag->getVariable("sort") ; |
|
|
$queries = "select ".ANN_ANNUAIRE.".*" ; |
$queries = "select U_ID,U_NAME, U_SURNAME, U_COUNTRY,U_MAIL, U_CITY" ; |
$queries .= ", ".ANN_TABLE_PAYS.".GC_NAME "; |
$queries .= "from ".ANN_ANNUAIRE ; |
$queries .= ",".ANN_TABLE_PAYS ; |
|
$queries .= "from "; |
$queries .= ANN_TABLE_PAYS.','.ANN_ANNUAIRE ; |
// On effectue une jointure gauche si l on veut tous les inscrits |
// y compris ce qui ne cotisent pas sinon pas de jointure gauche |
/* |
if (isset($cotisant) && $cotisant != 1) { |
|
} else { |
$queries .= ' left ' ; |
} |
$queries .= ' join annuaire_COTISATION on '. |
ANN_ANNUAIRE.'.U_ID=annuaire_COTISATION.IC_ANNU_ID '; |
|
if (isset($annee_cotisation) && $annee_cotisation != 0) { |
$queries .= ' and year(IC_DATE)='.$annee_cotisation ; |
} else { |
$queries .= 'and year(IC_DATE)='.date('Y') ; |
} |
*/ |
// Construction en fonction des champs saisies |
|
// juste le champs "rechercher", on regarde partout |
$queries .= " where (" ; |
$queries .= " where " ; |
|
if ($lettre == "") { |
if ($recherche != "") { |
$queries .= "(U_NAME like '%$recherche%'" ; // le premier |
if ($_REQUEST['recherche'] != '') { |
$queries .= '(U_NAME like "%'.$_REQUEST['recherche'].'%"' ; // le premier |
foreach($fields_annu as $key=>$value) { |
if ($key == "nom") continue ; |
$queries .= ($key == "pays" ? |
222,7 → 192,7 |
$pays == "tous" ? ")" : |
") and $value = '$pays'" : " or $value like '%$recherche%'") ; // les autres |
} |
|
$queries .= ' and ' ; |
} else { |
|
// si un ou plusieurs autres champs ont été indiqué, on les rajoute ici |
230,9 → 200,8 |
$or_flag = false ; |
foreach($fields_annu as $key=>$valeur) { |
if ($key != "") { |
if ($key == "pays") { |
if ($$key == "tous") $queries .= ") and U_COUNTRY like '%'"; |
else $queries .= ") and $valeur like \"%".$$key."%\"" ; |
if ($key == "pays" && ($$key != 'tous' && $$key != '')) { |
if ($$key != "tous") $queries .= ") and $valeur like \"%".$$key."%\"" ; |
} else { |
if ($key == "dept") { |
if ($$key != "tous" && isset($HTTP_POST_VARS[$key])) { |
241,9 → 210,12 |
} |
|
} else { |
if ($or_flag) $queries .= "$valeur like \"%".$$key."%\"" ; |
else $queries .= "($valeur like \"%".$$key."%\"" ; |
if ($key != "ville") $queries .= " and " ; |
if ($$key != '' && $key != 'pays') { |
if (!$or_flag) $queries .= '(' ; |
$queries .= $valeur.' like "%'.$$key.'%"' ; |
if ($key != "ville") $queries .= " and " ; |
} |
|
} |
} |
$or_flag = true ; |
258,43 → 230,50 |
if ($lettre == "tous") $lettre = "" ; |
$queries .="U_NAME like '$lettre%'" ; |
} |
$queries .= ")" ; |
$queries .= " and ".ANN_ANNUAIRE.".U_COUNTRY=".ANN_TABLE_PAYS.".GC_ID" ; |
if (isset($cotisant) && $cotisant != 3) if ($cotisant == 1) { |
$queries .= " and ".ANN_ANNUAIRE.".U_COT=$cotisant" ; |
} else { |
$queries .= " and ".ANN_ANNUAIRE.".U_COT=0" ; |
} |
$queries .= "" ; |
// jointure entre annuaire et table des pays annuaire_tela et gen_COUNTRY |
$queries .= " ".ANN_ANNUAIRE.".U_COUNTRY=".ANN_TABLE_PAYS.".GC_ID" ; |
|
if (isset($nom) && $nom != "") $queries .= " and U_NAME like \"%$nom%\"" ; |
if (isset($prenom) && $prenom != "") $queries .= " and U_SURNAME like \"%$prenom%\"" ; |
if (isset($ville) && $ville != "") $queries .= " and U_CITY like \"%$ville%\"" ; |
if (isset($mail) && $mail != "") $queries .= " and U_MAIL like \"%$mail%\"" ; |
if (isset($sort) && $sort != "") $queries .= " order by $sort" ; |
if (isset($_REQUEST['sort']) && $_REQUEST['sort'] != '') $queries .= ' order by '.$_REQUEST['sort'] ; |
return $queries; |
} |
|
function mkresu() |
{ |
global $HTTP_HOST, $SCRIPT_URL, $SCRIPT_NAME, $bouton ; |
|
$mon_frag = new fragmenteur_session() ; |
$mon_frag->setURL($GLOBALS['ann_url']->getURL()) ; |
if ($bouton) $mon_frag->fixerLeDebut(0) ; |
function mkresu() { |
|
$requete = mkquery() ; |
|
// Requete sans le limit pour le nombre de resultat |
$resultat_nbr = $GLOBALS['ann_db']->query($requete) ; |
if (DB::isError($resultat_nbr)) { |
return $resultat_nbr->getMessage().'<br />'.$resultat_nbr->getDebugInfo().'<br />'.$requete ; |
} |
$nbr_final = $resultat_nbr->numRows() ; |
$resultat_nbr->free(); |
$_SESSION['requete_mail_tous'] = $requete ; |
|
if (!isset($_REQUEST['T_REPONSE'])) $_REQUEST['T_REPONSE'] = 20 ; |
$debut = $_REQUEST['pageID'] * $_REQUEST['T_REPONSE']; |
$requete .= ' limit '.$debut.','.$_REQUEST['T_REPONSE']; |
// Requetes avec les résultats affichés |
|
// Deux requetes, une avec tous les resultats, l'autre avec les résultats affichés |
$result_total = mysql_query($requete) or print ("Echec de la requete <br>$requete<br>".mysql_error()) ; |
$resultat = $GLOBALS['ann_db']->query($requete) ; |
if (DB::isError($resultat)) { |
return $resultat->getMessage().'<br />'.$resultat->getDebugInfo().'<br />'.$requete ; |
} |
|
// Affichage de la requete |
$ret_req = "<tr class=\"texte_tb\"><td><br><b>La requete : </b><br>$requete". |
" limit ".$mon_frag->lireLeDebut().",".$mon_frag->lireLePas()."</td></tr>\n" ; |
|
$variables_a_supprimer = array ('username', 'password', 'connexion'); |
foreach ($variables_a_supprimer as $var) if (isset($_POST[$var])) unset ($_POST[$var]) ; |
|
|
$variables = array_merge ($_POST, $_GET); |
|
foreach ($variables as $key => $var) if ($variables[$key] != '') $GLOBALS['ann_url']->addQueryString($key, $variables[$key]); |
|
$result_final = mysql_query($requete." limit ".$mon_frag->lireLeDebut().",".$mon_frag->lireLePas()) or print (mysql_error()); |
$nbr_final = mysql_num_rows($result_total) ; |
mysql_free_result($result_total) ; |
// cxt_addVariable(AM_BD_BOTA, AM_BD_LINK, "requete_mail_tous", $requete) ; |
$_SESSION['requete_mail_tous'] = $requete ; |
$ret = "<div><table><tr>" ; |
|
for ($i = 65 ; $i <91 ; $i++) { |
303,73 → 282,144 |
$ret .= chr($i) ; |
$ret .= "</a></td>\n"; |
} |
|
$ret .= "<td> <a href=\"".$GLOBALS['ann_url']->getURL()."&lettre=tous\">".AM_L_TOUS."</a></td>\n" ; |
$GLOBALS['ann_url']->addQueryString('lettre', 'tous'); |
$ret .= '<td> <a href="'.$GLOBALS['ann_url']->getURL().'">'.AM_L_TOUS."</a></td>\n" ; |
$ret .= "<tr></table></div>\n" ; |
$ret .= "<div>".$mon_frag->affNbRes($nbr_final).'</div>' ; |
$ret .= "<div>".$mon_frag->fragmente($nbr_final)."</div>\n" ; |
if ($nbr_final != 0) { |
$ret .= "<div><table>\n"; |
$ret .= "<tr class=\"insTitle1\"><td nowrap><a href=\"".$GLOBALS['ann_url']->getURL()."&sort=U_NAME\">Identité</a></td>\n"; |
$ret .= "<td><a href=\"".$GLOBALS['ann_url']->getURL()."&sort=U_MAIL\">Adresse mail</a></td>\n" ; |
$ret .= "<td><a href=\"".$GLOBALS['ann_url']->getURL()."&sort=U_CITY\">".AM_L_VILLE."</a></td>\n" ; |
$ret .= "<td>Pays ou Dpt (fr)</td>\n" ; |
$ret .= "<td><a href=\"".$GLOBALS['ann_url']->getURL()."&sort=U_COT\">".AM_L_COTISANTS."</a></td></tr>\n" ; |
|
|
$cotisant = array( "non", "oui") ; |
|
$pair = true ; // pour afficher une ligne de résultat coloré, l'autre non |
|
while ($row = mysql_fetch_object($result_final)) |
{ |
$ret .= "<tr class=\"texte_tb2\""; |
if ($pair) { |
$ret .= " bgcolor=\"\"" ; |
$pair = false ; |
} else { |
$pair = true ; |
} |
$ret .= ">" ; |
$ret .= "\n<td nowrap>"; |
$urlPop = $GLOBALS['ann_url']->getURL()."&u_id=$row->U_ID"; |
$ret .= "<a href=\"$urlPop\">" ; |
$ret .= $row->U_NAME." ".$row->U_SURNAME ; |
$ret .= "</a></td>\n "; |
$ret .= "<td><a href=\"mailto:$row->U_MAIL\">$row->U_MAIL</a></td>\n" ; |
$ret .= "<td>$row->U_CITY</td>" ; |
if ($row->U_COUNTRY != 'fr') { |
$ret .= "<td>$row->GC_NAME</td>" ; |
|
include_once 'api/pear/Pager/Pager.php'; |
|
$params = array( |
'mode' => 'Jumping', |
'perPage' => $_REQUEST['T_REPONSE'], |
'delta' => 12, |
'httpMethod' => 'GET', |
'extraVars' => array_merge($_POST, $_GET), |
'altNext' => 'Suivant', |
'altPrev' => 'Précédent', |
'nextImg' => 'Suivant', |
'prevImg' => 'Précedent', |
'totalItems' => $nbr_final |
); |
$pager = & Pager::factory($params); |
$data = $pager->getPageData(); |
$links = $pager->getLinks(); |
$range = $pager->getOffsetByPageId(); |
$ret .= '<h2>'.$range[0].' - '.$range[1].' parmi '.$nbr_final.'</h2>'; |
$ret .= '<br /><br />'; |
$ret .= '<div class="bazar_numero">'.$pager->links.'</div>'."\n"; |
include_once 'api/pear/HTML/Table.php'; |
$table = new HTML_Table(array("class" => "table_cadre")); |
$table->addRow(array("<a href=\"".$GLOBALS['ann_url']->getURL()."&sort=U_NAME\">Identité</a>", |
"<a href=\"".$GLOBALS['ann_url']->getURL()."&sort=U_MAIL\">Adresse mail</a>", |
"<a href=\"".$GLOBALS['ann_url']->getURL()."&sort=U_CITY\">".AM_L_VILLE, "Pays ou Dpt (fr)", |
"<a href=\"".$GLOBALS['ann_url']->getURL()."&sort=U_COT\">Cotisant en ".date(Y)),'', 'TH') ; |
while ($valeur = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) { |
$ligne_tableau = array(); |
$montant = 0; |
// Le nom de l inscrit avec un lien dessus pour voir les details |
$GLOBALS['ann_url']->addQueryString('u_id', $valeur->U_ID); |
array_push ($ligne_tableau, '<a href="'.$GLOBALS['ann_url']->getURL().'">'.$valeur->U_NAME.' '.$valeur->U_SURNAME.'</a>'); |
|
// l email |
array_push ($ligne_tableau, '<a href="mailto:'.$valeur->U_MAIL.'">'.$valeur->U_MAIL.'</a>'); |
// La ville |
array_push ($ligne_tableau, $valeur->U_CITY); |
|
// Le pays ou le departement si francais |
if ($valeur->U_COUNTRY != 'fr') { |
array_push ($ligne_tableau, $valeur->GC_NAME) ; |
} else { |
$req_dpt = "select GFD_NAME from ".ANN_TABLE_DEPARTEMENT.",".ANN_ANNUAIRE." where ".ANN_ANNUAIRE.".U_ID=$row->U_ID" ; |
$req_dpt .= " and ".ANN_ANNUAIRE.".U_FRENCH_DPT=".ANN_TABLE_DEPARTEMENT.".GFD_ID" ; |
$resultat_dpt = mysql_query($req_dpt) or die ("Echec de la requete sur ".ANN_TABLE_DEPARTEMENT."<br>".mysql_error()) ; |
$ligne_dpt = mysql_fetch_object($resultat_dpt) ; |
$ret .= "<td>$ligne_dpt->GFD_NAME</td>" ; |
$req_dpt = 'select GFD_NAME from '.ANN_TABLE_DEPARTEMENT.','.ANN_ANNUAIRE.' where '.ANN_ANNUAIRE.'.U_ID='.$valeur->U_ID ; |
$req_dpt .= " and ".ANN_ANNUAIRE.".U_FRENCH_DPT=".ANN_TABLE_DEPARTEMENT.".GFD_ID" ; |
$resultat_dpt = $GLOBALS['ann_db']->query($req_dpt) ; |
if (DB::isError($resultat_dpt)) { |
return $resultat_dpt->getMessage().'<br />'.$resultat_dpt->getDebugInfo().'<br />'.$req_dpt ; |
} |
$ligne_dpt = $resultat_dpt->fetchRow(DB_FETCHMODE_OBJECT) ; |
array_push ($ligne_tableau, $ligne_dpt->GFD_NAME) ; |
} |
$ret .= "<td>".$cotisant[$row->U_COT]."</td></tr>\n" ; |
} |
|
$ret .= "</table></div>\n" ; |
$ret .= "<div>".$mon_frag->fragmente($nbr_final)."</div>\n" ; |
$ret .= "<div><a href=\"".$GLOBALS['ann_url']->getURL()."&action=".ANN_MAIL_TOUS."\">".AM_L_MAIL_SELECTION."</a></div>\n" ; |
} |
// $ret .= $ret_req ; |
// Si cotisant |
if ($valeur->IC_MONTANT != NULL) $montant = $valeur->IC_MONTANT.' €'; |
array_push ($ligne_tableau, $montant); |
$table->addRow($ligne_tableau); |
} |
$table->altRowAttributes(1, array("class" => "ligne_paire"), array("class" => "ligne_impaire")) ; |
$ret .= $table->toHTML(); |
$GLOBALS['ann_url']->removeQueryString('u_id'); |
|
$ret .= '<div class="bazar_numero">'.$pager->links.'</div>'."\n"; |
$GLOBALS['ann_url']->addQueryString(ANN_VARIABLE_ACTION, ANN_ACTION_MAIL_TOUS); |
$ret .= "<div><a href=\"".$GLOBALS['ann_url']->getURL()."\">".AM_L_MAIL_SELECTION."</a></div>\n" ; |
$ret .= $requete; |
return $ret; |
} |
|
/** function presa_mk_blkline () insere des lignes vides du type <tr><td> </td></tr> |
function resume_cotisation() { |
|
$res = '<h1>Etat des cotisations</h1>'."\n"; |
|
$requete = 'select distinct(YEAR(IC_DATE)) as annees from annuaire_COTISATION'; |
$tableau_annee_cotisation = &$GLOBALS['ann_db']->getCol ($requete); |
if (DB::isError($tableau_annee_cotisation)) { |
return $tableau_annee_cotisation->getMessage().'<br />'.$tableau_annee_cotisation->getDebugInfo(); |
} |
$requete = 'select MC_ID,MC_LABEL from MODE_COTISATION order by MC_ID' ; |
$tableau_mode_cotisation = & $GLOBALS['ann_db']->getAssoc($requete); |
if (DB::isError($tableau_annee_cotisation)) { |
return $tableau_mode_cotisation->getMessage().'<br />'.$tableau_mode_cotisation->getDebugInfo(); |
} |
// Initialisation de la table |
include_once 'api/pear/HTML/Table.php'; |
$table = new HTML_Table(array('class' => 'table_cadre')); |
$table->addRow(array_merge (array('Année'), $tableau_mode_cotisation, |
array('Total', 'Nb cotisant', 'Nb inscrit', 'Ratio')), '', 'TH'); |
|
foreach ($tableau_annee_cotisation as $annee) { |
|
// recherche du nombre d adherent de l annee |
$requete_nb_cotisant = 'select count(*) as nbr from annuaire_tela where U_DATE < "'.$annee.'-12-31" union'. |
' select count(*) as nbr from annuaire_COTISATION where year(IC_DATE)='.$annee; |
// La requete union renvoie une colonne appele nbr avec 2 lignes le nbre inscrit a tela et le nbre de cotisant |
// pour une année donnee |
|
$resultat = $GLOBALS['ann_db']->query($requete_nb_cotisant); |
if (DB::isError($resultat)) { |
return $resultat->getMessage().'<br />'.$rseultat->getDebugInfo(); |
} |
$nb_inscrit_annee = $resultat->fetchRow(DB_FETCHMODE_OBJECT); |
$nb_cotisant_annee = $resultat->fetchRow(DB_FETCHMODE_OBJECT); |
$ratio = $nb_cotisant_annee->nbr / $nb_inscrit_annee->nbr * 100; |
$ligne_table = array(); |
|
// On insere une premiere colone pour les annees |
array_push ($ligne_table, $annee); |
$somme_annee = 0; |
foreach ($tableau_mode_cotisation as $mode_id => $mode_label) { |
$requete = 'select sum(IC_MONTANT) as montant from annuaire_COTISATION where IC_MC_ID='.$mode_id. |
' and year(IC_DATE)='.$annee; |
$montant = $GLOBALS['ann_db']->getOne($requete); |
if (DB::isError($montant)) { |
return $montant->getMessage().'<br />'.$montant->getDebugInfo(); |
} |
array_push ($ligne_table, $montant); |
$somme_annee += $montant; |
} |
|
array_push ($ligne_table, $somme_annee, $nb_cotisant_annee->nbr, $nb_inscrit_annee->nbr,substr((string)$ratio, 0, 5).' %'); |
|
$table->addRow($ligne_table); |
|
} |
$res .= $table->toHTML(); |
$res .= print_r(parse_url($GLOBALS['ann_url']->getURL(), PHP_URL_PATH), true); |
return $res; |
} |
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* |
* @param integer nombre de ligne à insérer |
* @return string HTML |
* $Log:$ |
* * +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
|
function presa_mk_blkline ($nombre) { |
$res = "" ; |
for ($i = 0; $i < $nombre; $i++) { |
$res .= "<tr><td> </td></tr>\n" ; |
} |
return $res ; |
} |
|
?> |
?> |