<?php
#=
/****************************************************************************
Copyright 2002, Daniel Deycard, Jacques Messines, Alain Pomirol
(CATICE Académie de Bordeaux)

This file is part of GiBii/Melia.

GiBii/Melia is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

GiBii/Melia is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GiBii/Melia; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

****************************************************************************/
include ("../include/vars_adm.php");
include("../include/util.inc.php");
include("../include/utiljs.php");
opensession("Admin");

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Bandeau Admin</title>
<script language="JavaScript">
function openwin(mess,mail,datfin) {
msgWindow=window.open("","mafenetre","top=100, left=100, width=380,height=150, resizable='no',scrollbars=yes, menubar='no',toolbar='no', statusbar='no'");
msgWindow.document.write("<HTML><HEAD><TITLE>Informations administratives</TITLE>");
msgWindow.document.write("<link rel='stylesheet' href='<?php echo "../themes/".$etab_theme."/b2i.css" ?>' /></HEAD>");
msgWindow.document.write("<BODY class='arialadmin' >");
msgWindow.document.write("<CENTER><BIG><B>ATTENTION, prenez note de l'information suivante :</B></BIG></CENTER><BR />");
msgWindow.document.write(mess);
msgWindow.document.write("<br><br><font size='1'><i>(Ce message sera affiché jusqu'au : ");
msgWindow.document.write(datfin);
msgWindow.document.write(")</i></font><BR /><BR /><a href='mailto:");
msgWindow.document.write(mail);
msgWindow.document.write("'>Contacter le Super-Administrateur</a> ");
msgWindow.document.write("</BODY></HTML");
return msgWindow;
}

function ouvrirfenetre(adr) { //nouvelle fenêtre
wliste=open(adr,'','dependent,top=100,left=300,height=250,width=450,resizable,scrollbars=no, menubar=no,toolbar=no, statusbar=no');
}

</script>
<link rel="stylesheet" href="<?php echo "../themes/".$etab_theme."/b2i.css" ?>" />

<?php
function boutonsadmin($url) {
   global $etab_id;
       print "<form name='formsa' method=\"post\" target='_top' action='$url'>\n";
       print "<input type='hidden' name='from' value='admin'>\n";
       print "<input type='hidden' name='etab_id' value=$etab_id>\n";
       print "<input class='coul' type='submit' name='bout' value='Retour SuperAdmin' accesskey='S' />";
       print "</form>";
}

//Comparaison de dates à partir de chaînes
function mois($d) {return substr($d,3,2);}
function jour($j) {return substr($j, 0,2);}
function an($a) {return substr($a,6,2);}

print "</head>";

//Fenêtre d'infos administratives uniquement s'il y en a à afficher
$d=date("d/m/y");
//alert($MESSAGE_ADMIN."dates \$d et limite ".$d.$MESSAGE_DATE);

$dd=mktime(0,0,0,mois($d),jour($d),an($d));
if (isset($MESSAGE_DATE)) $mdd=mktime(0,0,0,mois($MESSAGE_DATE),jour($MESSAGE_DATE),an($MESSAGE_DATE));


if ((!empty($MESSAGE_ADMIN)) && ($dd<=$mdd)) {
    $html_mess=str_replace("_n","<br>",str_replace("_r","",str_replace("__"," ",$MESSAGE_ADMIN)));

    $info="onload=\"openwin('$html_mess','$MAIL_ADMIN','$MESSAGE_DATE')\" ";
    }
    else $info="onload=\"\"";

print "<body class=\"admin_header\" $info >";

//définition des variables pour le tableau
//Dénomination EXCEL A1 A2 A3 B1 B2 B3 C1 C2 C3
$A1=date("d/m/Y")."<br><b>".$etab_nom."</b>";
$A2="Admin";

if (@$etab_pas_aide_admin==0) {
  if (isset($etab_URL_aide_admin) AND ($etab_URL_aide_admin!="")) 
	 $A3="<a href=\"".$etab_URL_aide_admin."\" target=\"_blank\"><img src=\"../themes/".$etab_theme."/aide.gif\" Title=\"aide\" alt=\"aide\" border =\"0\"></a>";
  elseif (isset($URL_AIDE_ADMIN) AND ($URL_AIDE_ADMIN!=""))
	$A3="<a href=\"".$URL_AIDE_ADMIN."\" target=\"_blank\"><img src=\"../themes/".$etab_theme."/aide.gif\" Title=\"aide\" alt=\"aide\" border =\"0\"></a>";
  else  $A3="<img src=\"../themes/".$etab_theme."/aide.gif\"  border =\"0\">";
}

$sep='&nbsp;';
// chgt de theme sauf aux adjoints
if ($etab_chgt_theme==1){
        if ((isset($sess_statut_prof) && ($sess_statut_prof & 2)) or (isset($sess_statut_prof) && ($sess_statut_prof & 4))){
        $A3.="";
        }
        else $A3.=$sep."<a href=\"javascript:ouvrirfenetre('../outils/choisir_theme.php?statut=Admin')\"><img src=\"../themes/".$etab_theme."/chgt_theme.gif\" Title=\"Changer le thème\" Alt=\"Changer le thème\"></a>";

}

/*************** Partie modifiée par Béa *****************************/

if (isset($sess_statut_prof) && ($sess_statut_prof & 2) ) { // admin-adjoint
    $c = base64_encode(serialize(array('d' => 0, 's' =>1)));
    $A3.="$sep<a href=\"../prof/muer.php?c=$c\" target=\"_top\"  class=\"muer\"><img src=\"../themes/".$etab_theme."/vers_prof.gif\" Title=\"Mode Prof (".$sess_login.")\" alt=\"Mode Prof\" border =\"0\"></a>";
    $A2.="-adjoint";
    }

if (isset($sess_statut_prof) && ($sess_statut_prof & 4) ) { // gestionnaire-adjoint
    $c = base64_encode(serialize(array('d' => 2, 's' =>1)));
    $A3.=$sep."<a href=\"../prof/muer.php?c=$c\" target=\"_top\"  class=\"muer\"><img src=\"../themes/".$etab_theme."/vers_gestion.gif\" Title=\"Mode Gestionnaire-adjoint\" alt=\"Gest-adjoint\" border =\"0\"></a>";

}

/**********************************************************************/


$B1="../themes/".$etab_theme."/b2i_admin.gif";
$C1=oldsession();
$C2="";
$C3="";
?>

<table border="0" width="100%" align="center">
<!--   ligne 1  -->
   <tr class="titre_prof" valign="top" height="70">
        <td width='25%'>
            <span class="titre_prof_header"><?php echo $A1; ?></span>
        </td>
        <td rowspan="3" valign="top">
            <p style="text-align:center;"><a href="admin_ut.php" target="_top" title="Retour accueil admin" accesskey="M"><img src="<?php echo $B1; ?>" border="0" alt="Retour accueil admin"/></a></p>
        </td>
        <td >
            <?php print $C1; ?>
        </td>
    </tr>
<!--    ligne 2   -->
    <tr class="titre_prof" valign="top" height="35">
        <td >
          <strong><?php  print $A2?></strong>
        </td>
        <td style="text-align:right;">
            <?php if ($sess_statut=="Sadmin") boutonsadmin("../sadmin/sadmin_ut.php");
                  elseif (($etab_typauth_id==3) and ($entree_SSO==1)) boutonlogin("$CAS_RETOUR");
                  else boutonlogin("../login/login.php");  ?>
        </td>
    </tr>
<!--   ligne 3  -->
    <tr class="titre_prof" height="45" valign="top">
        <td >
            <?php if ($sess_statut!="Sadmin") print $A3; ?>
        </td>
        <td >
            <p >&nbsp;</p>
        </td>
    </tr>
</table>
</body>
</html>