Subversion Repositories Sites.tela-botanica.org

Rev

Rev 540 | Blame | Last modification | View Log | RSS feed

<?
// +--------------------------------------------------------------------------------+
// | liste_inscrit.php                                                              |
// +--------------------------------------------------------------------------------+
// | Copyright (c) 2002                                                             |
// +--------------------------------------------------------------------------------+
// |                                                                                |
// +--------------------------------------------------------------------------------+
// | Auteur : Alexandre Granier <alexandre@tela-botanica.org>                       |
// +--------------------------------------------------------------------------------+
//
// $Id: liste_inscrit.php,v 1.6 2005/03/14 10:10:02 alex Exp $

global $HTTP_USER_AGENT;


$javascript = "function confirmer () 
    {
        if (window.confirm ('Cliquez sur OK pour confirmer.')) {
            window.formmail.submit();
        }
    }
function setCheckboxes(the_form) 
{
    var do_check=document.forms[the_form].elements['selecttotal'].checked;
    var elts            = document.forms[the_form].elements['select[]'];
    var elts_cnt = (typeof(elts.length) != 'undefined')
                        ? elts.length
                        : 0;
    if (elts_cnt) {
        for (var i = 0; i < elts_cnt; i++) {
            elts[i].checked = do_check;
        } // Fin for
    } 
    else {
        elts.checked = do_check;
    } // Fin if... else
    return true;
} // Fin de la fonction 'setCheckboxes()'";

GEN_stockerCodeScript($javascript);

$url = CAR_URL ;

$corps = (isset($_POST['corps'])) ? $_POST['corps'] : '' ;
$titre_mail = (isset($_POST['titre_mail'])) ? $_POST['titre_mail'] : '';

$tabmonde = explode ('*',$monde->historique);

// Premier cas, on vient de cliquer sur un pays qui n'est pas 
// la France, on affiche les adhérents de ce pays

if (count($tabmonde) == 3) {
    $argument = $tabmonde[2];
    
    $requete = "select * from carto_PAYS where CP_ID_pays='$argument'";
    $resultat = $GLOBALS['car_db']->query($requete);
    if (DB::isError($resultat)) {
        die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
    }
    $ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ;
    
    $pays = $ligne->CP_Intitule_pays;
    $monde->nom = $monde->nom.'*'.$pays;
    
    $tabonglet = explode ('*', $monde->historique);
    $tabnom = explode ('*', $monde->nom);
    foreach ($tabonglet as $key => $value) {
        $res .= '<a class="chemin_carto"' ;
        if ($key == 0) {
            $chemin = $value;
            $value = 'monde';
            $res .= " href=\"".$monde->url."&amp;historique_cartes=$chemin\">&nbsp;&gt;&nbsp;".$tabnom[$key] ;
        }
        else if ($key == (count($tabonglet)-1)) {
            $res .= ">&nbsp;&gt;&nbsp;$pays";
        }
        else {
            $chemin .= '*'.$value;
            $res .= " href=\"".$monde->url."&amp;historique_cartes=$chemin\">&nbsp;&gt;&nbsp;".$tabnom[$key] ;
        }
        $res .= '</a>' ;
    }

    $capitale = $ligne->CP_Intitule_capitale;
    
    $requete_2 = " SELECT count(".CAR_CHAMPS_ID.") as nbr".
            " from ".CAR_ANNUAIRE.
            " where ".CAR_CHAMPS_CE_PAYS."='$argument'";
    
    $resultat_2 = $GLOBALS['car_db']->query($requete_2);
    if (DB::isError($resultat_2)) {
        die ($resultat_2->getMessage().'<br />'.$resultat_2->getDebugInfo()) ;
    }
    $ligne_2 = $resultat_2->fetchRow(DB_FETCHMODE_OBJECT) ;
    $res .= '<h1 class="titre1_cartographie">'.$pays.' ('.$capitale.') : ' ;
    if ($ligne_2->nbr == 0) {
        $res .= 'aucun inscrit '.CAR_LABEL_PROJET."</h1>\n";
        if (!$GLOBALS['car_auth']->getAuth()) {
            $res .= AUTH_formulaire_login();
        } else {
            $res .= '<div class="message_pas_dinscrit">'.CAR_PAS_D_INSCRIT.'</div>'."\n" ;
        }
        return $res ;
    } else if ($ligne_2->nbr == 1) {
        $res .= $ligne_2->nbr." inscrit " ;
    } else {
        $res .= $ligne_2->nbr." inscrits " ;
    }
    $res .= CAR_LABEL_PROJET."</h1>\n";
    
    if (!$GLOBALS['car_auth']->getAuth()) {
        $res .= AUTH_formulaire_login();
    } else {
    $res .= '<form action="'.$url.'?mailer=1&amp;fin=true" method="post" name="formmail">'.
            '   <div id="div_inscrit">'.
            '           <table id="table_inscrits">'.
            '                   <colgroup>'.
                        '                               <col />'.
                        '                               <col />'.
                        '                               <col />'.
                        '                               <col />'.
                        '                               <col />'.
                        '                               <col />'.
                        '                       </colgroup>'.
                        '                       <thead>'.
                        '                               <tr>'.
                        '                                       <th>&nbsp;</th>'.
                        '                                       <th>'.CAR_NOM.'</th>'.
                        '                                       <th>'.CAR_PRENOM.'</th>'.
                        '                                       <th>'.CAR_DATE_INS.'</th>'.
                        '                                       <th>'.CAR_REGION.'</th>'.
                        '                                       <th>'.CAR_VILLE.'</th>'.
                        '                               </tr>'.
                        '                       </thead>'.
                        '                       <tbody>';
        
        $requete = "select * from ".CAR_ANNUAIRE.
                " where ".CAR_CHAMPS_CE_PAYS."='$argument'".
                " order by ".CAR_CHAMPS_NOM.", ".CAR_CHAMPS_PRENOM;
        $resultat= $GLOBALS['car_db']->query($requete);
        if (DB::isError($resultat)) {
                die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
        }
        $indic=0;
        $i=1;
        while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
            if ($indic==0) {
                $res.="<tr class=\"ligne_impaire\">\n";
                $indic=1;
            }
            else {
                $res.="<tr class=\"ligne_paire\">\n";
                $indic=0;
            }
            $res.="<td><input type=\"checkbox\" name=\"select[]\" value=\"".$ligne[CAR_CHAMPS_MAIL]."\" /></td>
                            <td>".strtoupper($ligne[CAR_CHAMPS_NOM])."&nbsp;</td>\n
                                <td>".str_replace(' - ', '-', ucwords(strtolower(str_replace('-', ' - ', $ligne[CAR_CHAMPS_PRENOM]))))."&nbsp;</td>\n
                            <td>".date("d m Y", strtotime($ligne[CAR_CHAMPS_DATE_INS]))."&nbsp;</td>
                            <td>".str_replace(' - ', '-', ucwords(strtolower(str_replace('-', ' - ', $ligne[CAR_CHAMPS_REGION]))))."&nbsp;</td>
                            <td>".strtoupper($ligne[CAR_CHAMPS_VILLE])."&nbsp;</td>\n";
            $res .= "</tr>\n";
        }
        $res .= "</tbody></table></div>\n";
        
        if ($mailer==1) {
            if (!is_array($select)) {
                $res .= '<p class="attention">'.CAR_NO_DESTINATAIRE.'<p>';
            } else {
                $res .= envoie_mail_modere($GLOBALS['car_db']) ;
            }
        } else {
            $res .= carto_texte_cocher() ;
        }
        
        $res .= carto_formulaire($titre_mail, stripslashes($corps)) ;
    }

// 2 ème cas, on vient de cliquer sur un département français

} else if (count($tabmonde) == 4) {
    $argument = $tabmonde[3];
    
    $requete = "select * from gen_FRENCH_DPT where GFD_ID='$argument'";
    $resultat = $GLOBALS['car_db']->query($requete);
    if (DB::isError($resultat)) {
        die ($resultat->getMessage() .'<br />'.$resultat->getDebugInfo());
    }
    $ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT);
    $nom = $ligne->GFD_NAME;
    
    $tabonglet=explode ('*', $monde->historique);
    $tabnom=explode ('*', $monde->nom);
    $res.="<div>\n";
    foreach ($tabonglet as $key=>$value) {
        if ($key==0) {
            $chemin=$value;
            $value='monde';
            $res.= "<a class=\"chemin_carto\" href=\"".$monde->url."&amp;historique_cartes=$chemin\">&nbsp;&gt;&nbsp;".$tabnom[$key]."</a>";
        }
        else if ($key==(count($tabonglet)-1)) {
            $res.="<a class=\"chemin_carto\">&nbsp;&gt;&nbsp;$nom</a>";
        }
        else {
            $chemin.='*'.$value;
            $res.= "<a class=\"chemin_carto\" href=\"".$monde->url."&amp;historique_cartes=$chemin\">&nbsp;&gt;&nbsp;".$tabnom[$key]."</a>";
        }
    }
    $res .= "</div>\n";
    
    $requete_2 = " SELECT count(".CAR_CHAMPS_ID.") as nbr".
            " FROM ".CAR_ANNUAIRE.
            " WHERE ".CAR_CHAMPS_DPT." = '$argument'".
            " AND ".CAR_CHAMPS_CE_PAYS."='fr'";
    
    $resultat_2 = $GLOBALS['car_db']->query($requete_2);
    if (DB::isError($resultat_2)) {
        die ($resultat_2->getMessage().'<br />'.$resultat_2->getDebugInfo()) ;
    }
    
    $ligne_2 = $resultat_2->fetchRow(DB_FETCHMODE_OBJECT);

    $res .= '<h1 class="titre1_cartographie">'.$nom.' : ' ;
    if ($ligne_2->nbr == 0) {
        $res .= 'aucun inscrit '.CAR_LABEL_PROJET."</h1>\n";
        if (!$GLOBALS['car_auth']->getAuth()) {
            $res .= AUTH_formulaire_login();
        } else {
            $res .= '<p class="attention">'.CAR_PAS_D_INSCRIT.'<p>';
        }
        return $res ;
    } else if ($ligne_2->nbr == 1) {
        $res .= $ligne_2->nbr." inscrit " ;
    } else {
        $res .= $ligne_2->nbr." inscrits " ;
    }
    $res .= CAR_LABEL_PROJET."</h1>\n";
    
    if (!$GLOBALS['car_auth']->getAuth()) {
        $res .= AUTH_formulaire_login();
    } else {
        $res.= "<form action=\"$url?argument=$argument&amp;fin=true&amp;mailer=1\" 
                method=\"post\" name=\"formmail\">
                    <div id=\"div_inscrit\"><table id=\"table_inscrits\">
                        <colgroup>
                            <col />
                            <col />
                            <col />
                            <col />
                            <col />
                            <col />
                        </colgroup>
                        <thead>
                        <tr>
                            <th>&nbsp;</th>
                            <th>".CAR_NOM."</th>
                            <th>".CAR_PRENOM."</th>
                            <th>".CAR_DATE_INS."</th>
                            <th>".CAR_CP."</th>
                            <th>".CAR_VILLE."</th>
                        </tr></thead><tbody>\n";
        
        $requete = "SELECT * FROM ".CAR_ANNUAIRE.
                " WHERE ".CAR_CHAMPS_DPT." = '$argument'".
                " AND ".CAR_CHAMPS_CE_PAYS."='fr'".
                " ORDER BY ".CAR_CHAMPS_NOM.", ".CAR_CHAMPS_PRENOM;
        $resultat = $GLOBALS['car_db']->query($requete);
        if (DB::isError($resultat)) {
            die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
        }
        
        $indic=0;
        $i=1;
        while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
            if ($indic==0) {
                $res.="<tr class=\"ligne_impaire\">\n";
                $indic=1;
            } else {
                $res.="<tr class=\"ligne_paire\">\n";
                $indic=0;
            }
            $res.="<td><input type=\"checkbox\" name=\"select[]\" value=\"".$ligne[CAR_CHAMPS_MAIL]."\" /></td>
                                    <td>".strtoupper($ligne[CAR_CHAMPS_NOM])."&nbsp;</td>
                                    <td>".str_replace(' - ', '-', ucwords(strtolower(str_replace('-', ' - ', $ligne[CAR_CHAMPS_PRENOM]))))."&nbsp;</td>
                                    <td>".date("d m Y", strtotime($ligne[CAR_CHAMPS_DATE_INS]))."</td>
                                    <td>".$ligne[CAR_CHAMPS_CODE_POSTAL]."&nbsp;</td>
                                    <td>".strtoupper($ligne[CAR_CHAMPS_VILLE])."&nbsp;</td>
                                    </tr>\n";
        }
        $res.="</tbody></table></div>\n";
        if ($mailer==1) {
            if (!is_array($select)) {
                $res.= '<p class="attention">'.CAR_NO_DESTINATAIRE.'<p>';
            } else {
                $res .= envoie_mail_modere($GLOBALS['car_db']) ;
            }
        } else {
            $res .=carto_texte_cocher() ;
        }
        $res .= carto_formulaire($titre_mail,stripslashes($corps)) ;
    }
}
?>