Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 504 → Rev 508

/web/acc/manager/htdocs/group_new.php
1,21 → 1,10
<?php
# Choice of language
$Language = 'en';
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
$Language = strtolower(substr(chop($Langue[0]),0,2)); }
if($Language == 'fr'){
$l_title = "Cr&eacute;ation d'un groupe";
$l_frame_top = "Gestion des groupes";
$l_frame = "Gestion des groupes";
$l_group_create = "Cr&eacute;er un groupe";
}
else {
$l_title = "Create a group";
$l_frame_top = "Groups admin";
$l_frame = "Groups admin";
$l_group_create = "Create a group";
}
 
//Gestion de la langue
$origine='group_new';
if (is_file("../lib/langues.php"))
include("../lib/langues.php");
require('/etc/freeradius-web/config.php');
if ($show == 1){
header("Location: group_admin.php?login=$login");
54,17 → 43,16
 
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $config[general_charset]?>">
<link rel="stylesheet" href="/css/style.css">
<link rel="stylesheet" type="text/css" href="/css/epoch_styles.css" />
<script type="text/javascript" src="/javascript/epoch_classes.js"></script>
<script type="text/javascript" src="/javascript/fonctions.js"></script>
<script language="javascript" type="text/javascript">
function formControl(){
var myregex = /[\S]+/gi; //un ou plusieurs caractères non blanc" (tous les caractères sauf espace, retour chariot, tabulation, saut de ligne, saut de page).
if (myregex.test(document.newgroup.login.value)){
document.newgroup.create.value=1;
return true;
} else {
alert("Nom du groupe invalide.");//non internationnalisé
return false;
}
}
/*Insertion du calendrier*/
var dp_cal;
window.onload = function () {
dp_cal = new Epoch('epoch_popup','popup',document.getElementById('popup_container'));
};
/*Fin calendrier*/
</script>
</head>
<body>
116,7 → 104,7
<?php
echo <<<EOM
<tr>
<td align=right colspan=$colspan bgcolor="#d0ddb0">
<td class="etiquette" colspan=$colspan>
Groupe(s) d&eacute;j&agrave; cr&eacute;&eacute;(s)
</td><td>
EOM;
132,7 → 120,7
</td>
</tr>
<tr>
<td align=right colspan=$colspan bgcolor="#d0ddb0">
<td class="etiquette" colspan=$colspan>
Nom du groupe
</td><td>
<input type=text name="login" value="$login" size=35>
139,7 → 127,7
</td>
</tr>
<tr>
<td align=right colspan=$colspan bgcolor="#d0ddb0">
<td class="etiquette" colspan=$colspan>
Membres du groupe : s&eacute;par&eacute;s par un espace ou un 'retour chariot'.
</td><td>
<textarea name=members cols="15" wrap="PHYSICAL" rows=5></textarea>
153,90 → 141,140
continue;
$oper_name = $name . '_op';
$val = ($item_vals["$key"][0] != "") ? $item_vals["$key"][0] : $default_vals["$key"][0];
print <<<EOM
<tr>
<td align=right bgcolor="#d0ddb0">
$desc
</td>
/*
Gestion d'un mode simple ou d'un mode avancé
Définition du mode avancé les attributs concernant la gestion des octets, de la bande passante
*/
switch ($key)
{
case 'ChilliSpot-Max-Input-Octets' :
case 'ChilliSpot-Max-Output-Octets' :
case 'ChilliSpot-Max-Total-Octets' :
case 'ChilliSpot-Bandwidth-Max-Up' :
case 'ChilliSpot-Bandwidth-Max-Down' :
case 'WISPr-Redirection-URL' :
$advanced=0; //<-- Valeur à mettre à '1' pour avoir toute les fonctionnalités
break;
default:
$advanced=1;
break;
}
if ($advanced){
print <<<EOM
<tr>
<td class="etiquette">
$desc
</td>
EOM;
 
if ($show_ops){
switch ($key)
{
case 'Simultaneous-Use' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
break;
case 'Login-Time' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
break;
case 'Expiration' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
break;
case 'Session-Timeout' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
break;
case 'Max-Daily-Session' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
break;
case 'Max-Weekly-Session' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
break;
case 'Max-Monthly-Session' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
break;
case 'ChilliSpot-Max-Input-Octets' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
break;
case 'ChilliSpot-Max-Output-Octets' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
break;
case 'ChilliSpot-Max-Total-Octets' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
break;
case 'ChilliSpot-Bandwidth-Max-Up' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
break;
case 'ChilliSpot-Bandwidth-Max-Down' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
break;
case 'WISPr-Redirection-URL' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
break;
default :
print <<<EOM
<td>
<select name=$oper_name>
<option $selected[$op_eq] value="=">=
<option $selected[$op_set] value=":=">:=
<option $selected[$op_add] value="+=">+=
<option $selected[$op_eq2] value="==">==
<option $selected[$op_ne] value="!=">!=
<option $selected[$op_gt] value=">">&gt;
<option $selected[$op_ge] value=">=">&gt;=
<option $selected[$op_lt] value="<">&lt;
<option $selected[$op_le] value="<=">&lt;=
<option $selected[$op_regeq] value="=~">=~
<option $selected[$op_regne] value="!~">!~
<option $selected[$op_exst] value="=*">=*
<option $selected[$op_nexst] value="!*">!*
</select>
</td>
}
if ($show_ops && $advanced){
switch ($key)
{
case 'Simultaneous-Use' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
break;
case 'Login-Time' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
break;
case 'Expiration' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
break;
case 'Session-Timeout' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
break;
case 'Max-Daily-Session' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
break;
case 'Max-Weekly-Session' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
break;
case 'Max-Monthly-Session' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
break;
case 'ChilliSpot-Max-Input-Octets' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
break;
case 'ChilliSpot-Max-Output-Octets' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
break;
case 'ChilliSpot-Max-Total-Octets' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
break;
case 'ChilliSpot-Bandwidth-Max-Up' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
break;
case 'ChilliSpot-Bandwidth-Max-Down' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
break;
case 'WISPr-Redirection-URL' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
break;
default :
print <<<EOM
<td>
<select name=$oper_name>
<option $selected[$op_eq] value="=">=
<option $selected[$op_set] value=":=">:=
<option $selected[$op_add] value="+=">+=
<option $selected[$op_eq2] value="==">==
<option $selected[$op_ne] value="!=">!=
<option $selected[$op_gt] value=">">&gt;
<option $selected[$op_ge] value=">=">&gt;=
<option $selected[$op_lt] value="<">&lt;
<option $selected[$op_le] value="<=">&lt;=
<option $selected[$op_regeq] value="=~">=~
<option $selected[$op_regne] value="!~">!~
<option $selected[$op_exst] value="=*">=*
<option $selected[$op_nexst] value="!*">!*
</select>
</td>
EOM;
break;
}
break;
}
}
print <<<EOM
<td>
<input type=text name="$name" value="$val" size=35>
</td>
</tr>
EOM;
/*
Ajout du choix d'unité (pour les durées limites de session, journée et de mois)
et d'un calendrier pour la date d'expiration
Sauf dans le cas de la visualisation
*/
if ($advanced){echo "<td>";}
if ($create==0 ){
switch ($name){
/*
Choix de l'unité heures, minutes ou secondes
pour les durées limites de session,journée et de mois
*/
case 'Session-Timeout' :
case 'Max-Daily-Session' :
case 'Max-Monthly-Session' :
/*valeur d'origine de durée limite */
echo"<input id =\"$name\" type=text name=\"$name\" onfocus=\"this.value=''\" value=\"$val\" size=28>";
/* Choix d'unité*/
echo" <select name=\"$name"."_opt"."\" onchange=\"temps(this,'$name','newgroup')\">
<option value=\"s\" selected>s</option>
<option value=\"m\" >m</option>
<option value=\"H\" >H</option>
</select>";
break;
case 'Expiration' :
/*Ajout du calendrier pour choisir la date*/
echo"<input id=\"popup_container\" type=text name=\"$name\" value=\"$val\" size=35>";
break;
default :
if ($advanced) echo"<input type=text name=\"$name\" value=\"$val\" size=35>";
break;
}
}else{
/*Pas de gestion de remplissage lors de la visualisation*/
if ($advanced) echo"<input type=text name=\"$name\" value=\"$val\" size=35>";
}
/*fin Ajout*/
}
echo "</table><BR>";
if ($create == 1)
echo "<input type=submit class=button value=\"Afficher le groupe\" OnClick=\"this.form.show.value=1\">";
else
echo "<input type=submit class=button value=\"Cr&eacute;er\" OnClick=\"return formControl();\">";
echo "<input type=submit class=button value=\"Cr&eacute;er\" OnClick=\"return formControl('newgroup');\">";
?>
<br><br>
</form>
/web/acc/manager/htdocs/ticket_user.php
0,0 → 1,144
<?php
//--recupération des variables provenant du formulaire
// Etiquettes
$l_login_imp=$_POST["l_login_imp"];
$l_password_imp=$_POST["l_password_imp"];
$l_session_timeout_imp=$_POST["l_session_timeout_imp"];
$l_max_daily_session_imp=$_POST["l_max_daily_session_imp"];
$l_max_monthly_session_imp=$_POST["l_max_monthly_session_imp"];
$l_expiration_imp=$_POST["l_expiration_imp"];
// Valeurs
$log_imp=$_POST["log_imp"];
$passwd_imp=$_POST["passwd_imp"];
$exp_imp = $_POST["exp_imp"];
$sto_imp = $_POST["sto_imp"];
$mds_imp = $_POST["mds_imp"];
$mms_imp = $_POST["mms_imp"];
 
//--initialisation des classes FPDF
require('../../lib/fpdf16/fpdf.php');
 
//création de la classe PDF pour faire l'entête et pieds de page
class PDF extends FPDF
{
//Entête
function Header()
{
$l_title_imp=$_POST["l_title_imp"];
//Logo coordonnées x , y, largeur de l'image ---Attention fpdf ne supporte pas le png avec fond transparent----
$this->Image('../../../images/organisme.jpg',25,5,25);
//Police Arial gras 15
$this->SetFont('Arial','B',18);
//couleur de l'écriture en rouge
$this->SetTextColor(250,1,10);
//Titre largeur cellule x , hauteur y, texte, bordure 0 , Indique où déplace la prochaine position courante 0 droite, centré C
$this->Cell(190,10,$l_title_imp,0,0,'C');
//Saut de ligne
$this->Ln(25);
}
//Pied de page
function Footer()
{
//Positionnement à 1,5 cm du bas
$this->SetY(-15);
//Police Arial italique 8
$this->SetFont('Arial','I',8);
//Produit par est volontairement resté en français
$this->Cell(200,20,'Produit par : ALCASAR',0,0,'C');
}
//fonction rectangle
//Rectangle :
//x, y : coin supérieur gauche du rectangle.w, h : largeur et hauteur. r : rayon des coins arrondis.
//style : comme celui de Rect() : F, D (défaut), FD ou DF.
function RoundedRect($x, $y, $w, $h, $r, $style = '')
{
$k = $this->k;
$hp = $this->h;
if($style=='F')
$op='f';
elseif($style=='FD' or $style=='DF')
$op='B';
else
$op='S';
$MyArc = 4/3 * (sqrt(2) - 1);
$this->_out(sprintf('%.2F %.2F m',($x+$r)*$k,($hp-$y)*$k ));
$xc = $x+$w-$r ;
$yc = $y+$r;
$this->_out(sprintf('%.2F %.2F l', $xc*$k,($hp-$y)*$k ));
 
$this->_Arc($xc + $r*$MyArc, $yc - $r, $xc + $r, $yc - $r*$MyArc, $xc + $r, $yc);
$xc = $x+$w-$r ;
$yc = $y+$h-$r;
$this->_out(sprintf('%.2F %.2F l',($x+$w)*$k,($hp-$yc)*$k));
$this->_Arc($xc + $r, $yc + $r*$MyArc, $xc + $r*$MyArc, $yc + $r, $xc, $yc + $r);
$xc = $x+$r ;
$yc = $y+$h-$r;
$this->_out(sprintf('%.2F %.2F l',$xc*$k,($hp-($y+$h))*$k));
$this->_Arc($xc - $r*$MyArc, $yc + $r, $xc - $r, $yc + $r*$MyArc, $xc - $r, $yc);
$xc = $x+$r ;
$yc = $y+$r;
$this->_out(sprintf('%.2F %.2F l',($x)*$k,($hp-$yc)*$k ));
$this->_Arc($xc - $r, $yc - $r*$MyArc, $xc - $r*$MyArc, $yc - $r, $xc, $yc - $r);
$this->_out($op);
}
//fonction arc de cercle
function _Arc($x1, $y1, $x2, $y2, $x3, $y3)
{
$h = $this->h;
$this->_out(sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $x1*$this->k, ($h-$y1)*$this->k,
$x2*$this->k, ($h-$y2)*$this->k, $x3*$this->k, ($h-$y3)*$this->k));
}
}
 
//création du constructeur pdf avec fpdf : portrait P sinon paysage L, unite mm, page A4
$pdf = new PDF('L','mm','A5');
$pdf->AliasNbPages();
//creation de la page
$pdf->Addpage();
//Couleur du texte en noir
$pdf->SetTextColor(0);
 
//création du cadre arrondi qui entoure le ticket d'impression
//x, y : coin supérieur gauche du rectangle.w, h : largeur et hauteur. r : rayon des coins arrondis.
//style : comme celui de Rect() : F, D (défaut), FD ou DF.
$pdf->RoundedRect(40, 32, 130, 80, 3.5, 'D');
//création utilisateur et mot de passe coordonnées x , y hauteur et largeur , texte
$pdf->Ln(5);
$pdf->SetFont('Arial','',12);
$pdf->cell(50);
$pdf->Cell(45,10,$l_login_imp,0,0,'R');
$pdf->SetFont('Arial','B',12);
$pdf->Cell(45,10,$log_imp,0,1,'L');
$pdf->cell(50);
$pdf->SetFont('Arial','',12);
$pdf->Cell(45,10,$l_password_imp,0,0,'R');
$pdf->SetFont('Arial','B',12);
$pdf->Cell(45,10,$passwd_imp,0,1,'L');
//saut de ligne
$pdf->Ln(7);
//création des attributs utilisateurs coordonnées x , y hauteur et largeur , texte
$pdf->SetFont('Arial','',12);
$pdf->cell(50);
$pdf->Cell(45,10,$l_session_timeout_imp,0,0,'R');
$pdf->SetFont('Arial','B',12);
$pdf->Cell(45,10,$sto_imp,0,1,'L');
$pdf->cell(50);
$pdf->SetFont('Arial','',12);
$pdf->Cell(45,10,$l_max_daily_session_imp,0,0,'R');
$pdf->SetFont('Arial','B',12);
$pdf->Cell(45,10,$mds_imp,0,1,'L');
$pdf->SetFont('Arial','',12);
$pdf->cell(50);
$pdf->Cell(45,10,$l_max_monthly_session_imp,0,0,'R');
$pdf->SetFont('Arial','B',12);
$pdf->Cell(45,10,$mms_imp,0,1,'L');
$pdf->cell(50);
$pdf->SetFont('Arial','',12);
$pdf->Cell(45,10,$l_expiration_imp,0,0,'R');
$pdf->SetFont('Arial','B',12);
$pdf->Cell(45,10,$exp_imp,0,1,'L');
 
//renvoie au navigateur du document
$pdf->Output();
 
?>
/web/acc/manager/htdocs/user_new.php
1,37 → 1,9
<?php
# Choice of language
$Language = 'en';
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
$Language = strtolower(substr(chop($Langue[0]),0,2)); }
if($Language == 'fr'){
$l_title = "Cr&eacute;ation d'un usager";
$l_frame_top = "Gestion des usagers";
$l_frame = "Cr&eacute;ation d'un usager";
$l_user_exist = "existe d&eacute;j&agrave;";
$l_login = "Identifiant";
$l_password = "Mot de passe";
$l_passwd_gen = "g&eacute;n&eacute;rer";
$l_group = "Groupe";
$l_group_empty = "La liste des groupes est vide";
$l_name = "Nom et pr&eacute;nom";
$l_email = "Adresse de couriel";
}
else {
$l_title = "Create a user";
$l_frame_top = "Users admin";
$l_frame = "Create a user";
$l_user_exist = "already exist";
$l_login = "Login";
$l_password = "Password";
$l_passwd_gen = "generate";
$l_group = "Group";
$l_group_empty = "The group list is empty";
$l_name = "Surname and name";
$l_email = "Email Address";
}
//gestion de la langue
$origine='user_new';
if (is_file("../lib/langues.php"))
include("../lib/langues.php");
 
 
require('/etc/freeradius-web/config.php');
if ($show == 1){
header("Location: user_admin.php?login=$login");
52,28 → 24,18
 
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $config[general_charset]?>">
<link rel="stylesheet" href="/css/style.css">
<link rel="stylesheet" type="text/css" href="/css/epoch_styles.css" />
<script type="text/javascript" src="/javascript/epoch_classes.js"></script>
<script type="text/javascript" src="/javascript/fonctions.js"></script>
<script language="javascript" type="text/javascript">
var chars='0123456789abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ'
function password(size)
{
var pass=''
while(pass.length < size)
{
pass+=chars.charAt(Math.round(Math.random() * (chars.length)))
}
document.newuser.passwd.value=pass
document.newuser.pwdgene.value=pass
}
function formControl(){
var myregex = /[\S]+/gi; //un ou plusieurs caract�res non blanc" (tous les caract�res sauf espace, retour chariot, tabulation, saut de ligne, saut de page).
if (myregex.test(document.newuser.login.value)){
document.newuser.create.value=1;
return true;
} else {
alert("Votre identifiant est invalide.");//non internationnalis�
return false;
}
}
 
/*Insertion du calendrier*/
var dp_cal;
window.onload = function () {
dp_cal = new Epoch('epoch_popup','popup',document.getElementById('popup_container'));
};
/*Fin calendrier*/
 
</script>
</head>
<body>
80,6 → 42,7
 
<?php
include("password_generator.jsc");
 
echo "<TABLE width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
echo "<tr><th>$l_frame_top</th></tr>";
?>
103,9 → 66,22
</td></tr>
<tr bgcolor="black" valign=top><td colspan=2>
<table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top>
<tr><td>
<tr><td>
<?php
function sec_imp($time)
/*Formatage des secondes avant l'impression*/
{
$heure=0;$minute=0;$seconde=0;
$heure = floor($time/3600);
$reste = $time%3600;
if ($heure!=0) $result = $heure.' H ';
$minute = floor($reste/60);
if ($minute!=0) $result = $result.$minute.' min ';
$seconde = $reste%60;
if ($seconde!=0) $result = $result.$seconde.' s ';
return $result;
}
 
if ($create == 1){
if (is_file("../lib/$config[general_lib_type]/user_info.php"))
include("../lib/$config[general_lib_type]/user_info.php");
117,6 → 93,54
else{
if (is_file("../lib/$config[general_lib_type]/create_user.php"))
include("../lib/$config[general_lib_type]/create_user.php");
/* Petit traitement pré-impression
pour la lisibilité */
/*Gestion des cas sans limitation*/
if ($sto_imp=='' && $mds_imp=='' && $mms_imp==''){
/*Recherche de l'existence d'un groupe et récupération des attributs le cas échéant*/
if ($group!=''){
$saved_login = $login;
$login = $group;
if (is_file("../lib/sql/group_info.php"))
include("../lib/sql/group_info.php");
$login = $saved_login;
/* formatage des secondes sous le format H min s*/
$sto_imp=sec_imp($sto_imp);
$mds_imp=sec_imp($mds_imp);
$mds_imp=sec_imp($mds_imp);
} else {
/*Si les valeurs de durée sont vide remplissage avec la valeur 'Illimitée'*/
$sto_imp=$v_illimit;
$mds_imp=$v_illimit;
$mms_imp=$v_illimit;
}
}else{
/* formatage des secondes sous le format H min s*/
$sto_imp=sec_imp($sto_imp);
$mds_imp=sec_imp($mds_imp);
$mms_imp=sec_imp($mms_imp);
}
/*Formatage de la date afin d'être lisible dans toute les langues 'jj mm yyyy'*/
$Expiration=date("d - m - Y",strtotime($Expiration));
//Appel du ticket d'impression , passage en paramètres des étiquettes et des valeurs à afficher
echo' <form name="impression" method="post" action="ticket_user.php" target=_blank>
<input type="hidden" name="l_title_imp" value="'.$l_title_imp.'">
<input type="hidden" name="l_login_imp" value="'.$l_login_imp.'">
<input type="hidden" name="l_password_imp" value="'.$l_password_imp.'">
<input type="hidden" name="l_session_timeout_imp" value="'.$l_session_timeout_imp.'">
<input type="hidden" name="l_max_daily_session_imp" value="'.$l_max_daily_session_imp.'">
<input type="hidden" name="l_max_monthly_session_imp" value="'.$l_max_monthly_session_imp.'">
<input type="hidden" name="l_expiration_imp" value="'.$l_expiration_imp.'">
<input type="hidden" name="log_imp" value="'.$login.'">
<input type="hidden" name="passwd_imp" value="'.$passwd_imp.'">
<input type="hidden" name="sto_imp" value="'.$sto_imp.'">
<input type="hidden" name="mds_imp" value="'.$mds_imp.'">
<input type="hidden" name="mms_imp" value="'.$mms_imp.'">
<input type="hidden" name="exp_imp" value="'.$Expiration.'">
</form>';
echo' <script type="text/javascript"> document.forms["impression"].submit();</script>';
//fin ticket impression
require("../lib/defaults.php");
if (is_file("../lib/$config[general_lib_type]/user_info.php"))
include("../lib/$config[general_lib_type]/user_info.php");
126,11 → 150,12
<form name="newuser" method=post>
<input type=hidden name=create value="0">
<input type=hidden name=show value="0">
<input type=hidden name=langue_imp value='fr'>
<table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
<?php
echo <<<EOM
<tr>
<td align=right colspan=$colspan bgcolor="#d0ddb0">
<td class="etiquette" colspan=$colspan>
$l_login
</td><td>
<input type=text name="login" value="$login" size=35>
137,11 → 162,11
</td>
</tr>
<tr>
<td align=right colspan=$colspan bgcolor="#d0ddb0">
<td class="etiquette" colspan=$colspan>
$l_password
</td><td>
<input type=password name="passwd" size=35>
<br /><input type="button" value="$l_passwd_gen" onclick="password(8)">
<br /><input type="button" value="$l_passwd_gen" onclick="password(8,'newuser')">
<input type="text" value="" name="pwdgene" size=20 readonly>
</td>
</tr>
151,7 → 176,7
$selected[$member_groups[0]] = 'selected';
echo <<<EOM
<tr>
<td align=right colspan=$colspan bgcolor="#d0ddb0">
<td class="etiquette" colspan=$colspan>
$l_group
</td><td>
EOM;
170,7 → 195,7
($config[general_lib_type] == 'sql' && $config[sql_use_user_info_table] == 'true')){
echo <<<EOM
<tr>
<td align=right colspan=$colspan bgcolor="#d0ddb0">
<td class="etiquette" colspan=$colspan>
$l_name
</td><td>
<input type=text name="Fcn" value="$cn" size=35>
177,14 → 202,16
</td>
</tr>
<tr>
<td align=right colspan=$colspan bgcolor="#d0ddb0">
<td class="etiquette" colspan=$colspan>
$l_email
</td><td>
<input type=text name="Fmail" value="$mail" size=35>
</td>
</tr>
<!-- Mettre en commentaire les champs qui ne sont pas nécessaire, chaque champ est entre les balises <tr> et </tr> -->
<!--
<tr>
<td align=right colspan=$colspan bgcolor="#d0ddb0">
<td class="etiquette" colspan=$colspan>
Service
</td><td>
<input type=text name="Fou" value="$ou" size=35>
191,7 → 218,7
</td>
</tr>
<tr>
<td align=right colspan=$colspan bgcolor="#d0ddb0">
<td class="etiquette" colspan=$colspan>
Nro TPH personnel
</td><td>
<input type=text name="Fhomephone" value="$homephone" size=35>
198,7 → 225,7
</td>
</tr>
<tr>
<td align=right colspan=$colspan bgcolor="#d0ddb0">
<td class="etiquette" colspan=$colspan>
Nro TPH bureau
</td><td>
<input type=text name="Ftelephonenumber" value="$telephonenumber" size=35>
205,12 → 232,13
</td>
</tr>
<tr>
<td align=right colspan=$colspan bgcolor="#d0ddb0">
<td class="etiquette" colspan=$colspan>
Nro TPH mobile
</td><td>
<input type=text name="Fmobile" value="$mobile" size=35>
</td>
</tr>
</tr>
-->
EOM;
}
foreach($show_attrs as $key => $desc){
219,93 → 247,170
continue;
$oper_name = $name . '_op';
$val = ($item_vals["$key"][0] != "") ? $item_vals["$key"][0] : $default_vals["$key"][0];
/*
Gestion d'un mode simple ou d'un mode avancé
Définition du mode avancé: les attributs concernant la gestion des octets, de la bande passante
*/
switch ($key)
{
case 'ChilliSpot-Max-Input-Octets' :
case 'ChilliSpot-Max-Output-Octets' :
case 'ChilliSpot-Max-Total-Octets' :
case 'ChilliSpot-Bandwidth-Max-Up' :
case 'ChilliSpot-Bandwidth-Max-Down' :
case 'WISPr-Redirection-URL' :
$advanced=0; //<-- Valeur à mettre à '1' pour avoir toutes les fonctionnalités
break;
default:
$advanced=1;
break;
}
if ($advanced){
print <<<EOM
<tr>
<td align=right bgcolor="#d0ddb0">
$desc
</td>
<tr>
<td class="etiquette">
$desc
</td>
EOM;
 
if ($show_ops){
switch ($key)
{
case 'Simultaneous-Use' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
break;
case 'Login-Time' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
break;
case 'Expiration' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
break;
case 'Session-Timeout' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
break;
case 'Max-Daily-Session' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
break;
case 'Max-Weekly-Session' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
break;
case 'Max-Monthly-Session' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
break;
case 'ChilliSpot-Max-Input-Octets' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
break;
case 'ChilliSpot-Max-Output-Octets' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
break;
case 'ChilliSpot-Max-Total-Octets' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
break;
case 'ChilliSpot-Bandwidth-Max-Up' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
break;
case 'ChilliSpot-Bandwidth-Max-Down' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
break;
case 'WISPr-Redirection-URL' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
break;
default :
print <<<EOM
<td>
<select name=$oper_name>
<option $selected[$op_eq] value="=">=
<option $selected[$op_set] value=":=">:=
<option $selected[$op_add] value="+=">+=
<option $selected[$op_eq2] value="==">==
<option $selected[$op_ne] value="!=">!=
<option $selected[$op_gt] value=">">&gt;
<option $selected[$op_ge] value=">=">&gt;=
<option $selected[$op_lt] value="<">&lt;
<option $selected[$op_le] value="<=">&lt;=
<option $selected[$op_regeq] value="=~">=~
<option $selected[$op_regne] value="!~">!~
<option $selected[$op_exst] value="=*">=*
<option $selected[$op_nexst] value="!*">!*
</select>
</td>
}
if ($show_ops && $advanced){
switch ($key){
case 'Simultaneous-Use' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
break;
case 'Login-Time' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
break;
case 'Expiration' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
break;
case 'Session-Timeout' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
break;
case 'Max-Daily-Session' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
break;
case 'Max-Weekly-Session' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
break;
case 'Max-Monthly-Session' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\":=\">:=";
break;
case 'ChilliSpot-Max-Input-Octets' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
break;
case 'ChilliSpot-Max-Output-Octets' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
break;
case 'ChilliSpot-Max-Total-Octets' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
break;
case 'ChilliSpot-Bandwidth-Max-Up' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
break;
case 'ChilliSpot-Bandwidth-Max-Down' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
break;
case 'WISPr-Redirection-URL' :
echo "<td><select name=$oper_name><option $selected[$op_eq] value=\"=\">=";
break;
default :
print <<<EOM
<td>
<select name=$oper_name>
<option $selected[$op_eq] value="=">=
<option $selected[$op_set] value=":=">:=
<option $selected[$op_add] value="+=">+=
<option $selected[$op_eq2] value="==">==
<option $selected[$op_ne] value="!=">!=
<option $selected[$op_gt] value=">">&gt;
<option $selected[$op_ge] value=">=">&gt;=
<option $selected[$op_lt] value="<">&lt;
<option $selected[$op_le] value="<=">&lt;=
<option $selected[$op_regeq] value="=~">=~
<option $selected[$op_regne] value="!~">!~
<option $selected[$op_exst] value="=*">=*
<option $selected[$op_nexst] value="!*">!*
</select>
</td>
EOM;
break;
}
break;
}
}
print <<<EOM
<td>
<input type=text name="$name" value="$val" size=35>
</td>
</tr>
/*
Ajout du pré-remplissage de cellule
du choix d'unité (pour les durées limites de session,journée et de mois)
et d'un calendrier pour la date d'expiration
Sauf dans le cas de la visualisation
*/
if ($advanced){echo "<td>";}
if ($create==0 ){
switch ($name){
case 'Simultaneous-Use' :
/*Pré-remplissage avec la valeur '1' pour empécher plusieurs connexions silmutanées*/
$val=1;//<--cette valeur correspond au nombre de session simultanée en commentant cette ligne la valeur n'est plus pré-remplie
echo"<input type=text name=\"$name\" value=\"$val\" size=35>";
break;
/*
Choix de l'unité heures, minutes ou secondes
pour les durées limites de session,journée et de mois
*/
case 'Session-Timeout' :
case 'Max-Daily-Session' :
case 'Max-Monthly-Session' :
/*valeur d'origine de durée limite */
echo"<input type=text name=\"$name\" onfocus=\"this.value=''\" value=\"$val\" size=28>";
/* Choix d'unité*/
echo" <select name=\"$name"."_opt"."\" onchange=\"temps(this,'$name','newuser')\">
<option value=\"s\" selected>s</option>
<option value=\"m\" >m</option>
<option value=\"H\" >H</option>
</select>";
break;
case 'Expiration' :
/*Pré-remplissage avec la date du lendemain*/
$val=date("d F Y",strtotime("+1 day"));//<--en commentant cette ligne la valeur n'est plus pré-remplie
/*Ajout du calendrier pour choisir la date*/
echo"<input id=\"popup_container\" type=text name=\"$name\" value=\"$val\" size=35>";
break;
default :
if ($advanced) echo"<input type=text name=\"$name\" value=\"$val\" size=35>";
break;
}
}else{
/*Pas de gestion de remplissage lors de la visualisation*/
if ($advanced) echo"<input type=text name=\"$name\" value=\"$val\" size=35>";
/*fin Ajout*/
}
}
if (create==0){
print <<<EOM
<tr>
<td class="etiquette" colspan=$colspan>
$l_lang_ticket
</td>
<td width=35>
EOM;
/*Choix de la langue du ticket d'impression*/
echo" <select name=\"$langue_imp\" onchange=\"lang_imp(this,'newuser')\">
<option value=\"fr\" selected>Fran&ccedil;ais</option>
<option value=\"en\" >English</option>
<option value=\"nl\" >Nederlandse</option>
<option value=\"de\" >Deutsch</option>
<option value=\"es\" >Espa&ntilde;ol</option>
<option value=\"it\" >Italiano</option>
</select></td></tr>";
}
echo "</table><BR>";
if ($create == 1)
echo "<input type=submit class=button value=\"Afficher le profil de l'utilisateur\" OnClick=\"this.form.show.value=1\">";
else{
//echo "<input type=submit class=button value=\"Cr&eacute;er\" OnClick=\"this.form.create.value=1\">";}
echo "<input type=submit class=button value=\"Cr&eacute;er\" OnClick=\"return formControl();\">";}
echo "<input type=submit class=button value=\"Cr&eacute;er\" OnClick=\"return formControl('newuser');\">";
}
?>
</form>
 
</td></tr>
</table>
</tr>
/web/acc/manager/lib/sql/create_user.php
17,6 → 17,9
if ($link){
if (is_file("../lib/crypt/$config[general_encryption_method].php")){
include("../lib/crypt/$config[general_encryption_method].php");
/*Ajout en vue de l'impression des données*/
$passwd_imp = $passwd;
/*Fin Ajout*/
$passwd = da_encrypt($passwd);
$passwd = da_sql_escape_string($passwd);
$res = @da_sql_query($link,$config,
90,6 → 93,11
$type = 2;
}
$val = $$attrmap["$key"];
/*Ajout en vue de l'impression des données*/
if($key == "Session-Timeout") $sto_imp = $val;
if($key == "Max-Daily-Session") $mds_imp = $val;
if($key == "Max-Monthly-Session") $mms_imp = $val;
/*Fin Ajout*/
$val = da_sql_escape_string($val);
$op_name = $attrmap["$key"] . '_op';
$op_val = $$op_name;
97,7 → 105,7
$op_val = da_sql_escape_string($op_val);
if (check_operator($op_val,$type) == -1){
echo "<b>Invalid operator ($op_val) for attribute $key</b><br>\n";
coninue;
continue;
}
$op_val2 = ",'$op_val'";
}
/web/acc/manager/lib/langues.php
0,0 → 1,135
<?php
/*
Fichier de gestion des langues
Pour l'utilisation de ce fichier mettre une variable
$origine égal au nom du fichier php contenant l'include sans l'extension
avant l'include du fichier langues.php
*/
// Choix de la langue
$Language = 'en';
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
$Language = strtolower(substr(chop($Langue[0]),0,2)); }
//-------------------
// En fonction de la langue et de la page d'appel remplissage des variables
switch ($Language){
case 'fr':
//Français
switch ($origine){
//Administration
case 'user_new':
$l_title = "Cr&eacute;ation d'un usager";
$l_frame_top = "Gestion des usagers";
$l_frame = "Cr&eacute;ation d'un usager";
$l_user_exist = "existe d&eacute;j&agrave;";
$l_login = "Identifiant";
$l_password = "Mot de passe";
$l_passwd_gen = "g&eacute;n&eacute;rer";
$l_group = "Groupe";
$l_group_empty = "La liste des groupes est vide";
$l_name = "Nom et pr&eacute;nom";
$l_email = "Adresse de couriel";
$l_lang_ticket = "Langue du ticket";
break;
case 'group_new':
$l_title = "Cr&eacute;ation d'un groupe";
$l_frame_top = "Gestion des groupes";
$l_frame = "Gestion des groupes";
$l_group_create = "Cr&eacute;er un groupe";
break;
}
break;
default :
//English
switch ($origine){
//Administration
case 'user_new':
$l_title = "Create a user";
$l_frame_top = "Users admin";
$l_frame = "Create a user";
$l_user_exist = "already exist";
$l_login = "Login";
$l_password = "Password";
$l_passwd_gen = "generate";
$l_group = "Group";
$l_group_empty = "The group list is empty";
$l_name = "Surname and name";
$l_email = "Email Address";
$l_lang_ticket = "Voucher language";
break;
case 'group_new':
$l_title = "Create a group";
$l_frame_top = "Groups admin";
$l_frame = "Groups admin";
$l_group_create = "Create a group";
break;
}
break;
}
//Langue du Ticket d'impression en fonction de la liste déroulante
$langue_imp=$_POST["langue_imp"];
if($origine=='user_new'){
switch ($langue_imp){
case 'fr':
$l_title_imp = "TICKET ACC&Egrave;S INTERNET";
$l_login_imp = "Utilisateur :";
$l_password_imp = "Mot de passe :";
$l_session_timeout_imp="Dur&eacute;e d'une session :";
$l_max_daily_session_imp="Dur&eacute;e journali&egrave;re :";
$l_max_monthly_session_imp ="Dur&eacute;e mensuelle :";
$l_expiration_imp="Date d'expiration :";
$v_illimit="Illimit&eacute;e";
break;
case 'de':
$l_title_imp = "GUTSCHEIN SPRACHE";
$l_login_imp = "Login :";
$l_password_imp = "Passwort :";
$l_session_timeout_imp="Dauer der Sitzung :";
$l_max_daily_session_imp="Stunden t&auml;glich :";
$l_max_monthly_session_imp ="monatlich Dauer :";
$l_expiration_imp="Verfallsdatum :";
$v_illimit="Unbegrenzt";
break;
case 'nl':
$l_title_imp = "ONTVANGST INTERNET";
$l_login_imp = "Gebruikers :";
$l_password_imp = "Wachtwoord :";
$l_session_timeout_imp="Sessieduur :";
$l_max_daily_session_imp="Dagelijkse uren :";
$l_max_monthly_session_imp ="Maandelijkse duur :";
$l_expiration_imp="Vervaldatum :";
$v_illimit="Onbeperkte";
break;
case 'es':
$l_title_imp = "BONO INTERNET";
$l_login_imp = "Usuario :";
$l_password_imp = "Contraseña :";
$l_session_timeout_imp="Duraci&oacute;n de Sesi&oacute;n :";
$l_max_daily_session_imp="Horas diarias :";
$l_max_monthly_session_imp ="Duraci&oacute;n mensual :";
$l_expiration_imp="Fecha de caducidad :";
$v_illimit="Ilimitado";
break;
case 'it':
$l_title_imp = "RICEVIMENTO INTERNET";
$l_login_imp = "Utenti :";
$l_password_imp = "Password :";
$l_session_timeout_imp="Durata della sessione :";
$l_max_daily_session_imp="Ore giornaliere :";
$l_max_monthly_session_imp ="Durata mensile :";
$l_expiration_imp="Data di scadenza :";
$v_illimit="Illimitato";
break;
default:
$l_title_imp = "INTERNET VOUCHER";
$l_login_imp = "Login :";
$l_password_imp = "Password :";
$l_session_timeout_imp="Session timeout :";
$l_max_daily_session_imp="Max daily session :";
$l_max_monthly_session_imp ="Max monthly session :";
$l_expiration_imp="Expiration date :";
$v_illimit="Unlimited";
break;
}
}
?>
/web/css/style.css
41,3 → 41,15
color: #666666;
background-color: #EFEFEF;
}
/*style des étiquettes*/
.etiquette {
font-family:"DejaVu Sans";
font-size: small;
text-align: right;
color: #666666;
background-color: #d0ddb0;
}
/web/css/epoch_styles.css
0,0 → 1,88
table.calendar {
font-family: Helvetica, Arial, sans-serif;
font-size: 0.8em;
border-collapse: collapse;
background-color: white;
border: solid #999999 1px;
background-color: white;
width: 200px;
text-align: center;
/*prevent user from selecting text in Mozilla & Safari - check calendar constructor for IE code)*/
-moz-user-select: none;
/*-khtml-user-select: none;*/
}
table.calendar input, table.calendar select {
font-size: 10px;
}
table.calendar td {
border: 0;
font-size: 10px;
text-align: center;
}
div.mainheading {
margin: 2px;
}
table.caldayheading {
border-collapse: collapse;
cursor: pointer;
empty-cells: show;
margin: 0 6px 0 6px;
}
table.caldayheading td {
border: solid #CCCCCC 1px;
text-align: left;
color: #0054E3;
font-weight: bold;
width: 22px; /*should match calendar cell's width*/
}
table.caldayheading td.wkhead {
border-right: double #CCCCCC 3px;
}
table.calcells {
border-collapse: collapse;
cursor: pointer;
margin: 0 6px 0 6px;
}
table.calcells td {
border: solid #CCCCCC 1px;
vertical-align: top;
text-align: left;
font-weight: bold;
width: 22px;
height: 20px; /*IE doesn't like ems*/
}
table.calcells td div {
padding: 1px;
margin: 0;
}
table.calcells td.wkhead {
background-color: white;
text-align: center;
border-right: double #CCCCCC 3px;
color: #0054E3;
}
table.calcells td.wkday {
background-color: #DDDDDD;
}
table.calcells td.wkend {
background-color: #A9A9A9;
}
table.calcells td.curdate {
 
}
table.calcells td.cell_selected {
background-color: #99CCFF;
color: black;
}
table.calcells td.notmnth {
background-color: #FFFFFF;
color: #CCCCCC;
}
table.calcells td.notallowed {
background-color: white;
color: #EEEEEE;
font-style: italic;
}
table.calcells td.hover {
background-color: #999999;
}
/web/js/epoch_classes.js
0,0 → 1,877
/*****************************************************************************
Copyright (C) 2006 Nick Baicoianu
 
This program 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.
 
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*****************************************************************************/
//constructor for the main Epoch class (ENGLISH VERSION)
function Epoch(name,mode,targetelement,multiselect)
{
this.state = 0;
this.name = name;
this.curDate = new Date();
this.mode = mode;
this.selectMultiple = (multiselect == true); //'false' is not true or not set at all
//the various calendar variables
//this.selectedDate = this.curDate;
this.selectedDates = new Array();
this.calendar;
this.calHeading;
this.calCells;
this.rows;
this.cols;
this.cells = new Array();
//The controls
this.monthSelect;
this.yearSelect;
//standard initializations
this.mousein = false;
this.calConfig();
this.setDays();
this.displayYear = this.displayYearInitial;
this.displayMonth = this.displayMonthInitial;
this.createCalendar(); //create the calendar DOM element and its children, and their related objects
if(this.mode == 'popup' && targetelement && targetelement.type == 'text') //if the target element has been set to be an input text box
{
this.tgt = targetelement;
this.calendar.style.position = 'absolute';
this.topOffset = this.tgt.offsetHeight; // the vertical distance (in pixels) to display the calendar from the Top of its input element
this.leftOffset = 0; // the horizontal distance (in pixels) to display the calendar from the Left of its input element
this.calendar.style.top = this.getTop(targetelement) + this.topOffset + 'px';
this.calendar.style.left = this.getLeft(targetelement) + this.leftOffset + 'px';
document.body.appendChild(this.calendar);
this.tgt.calendar = this;
this.tgt.onfocus = function () {this.calendar.show();}; //the calendar will popup when the input element is focused
this.tgt.onblur = function () {if(!this.calendar.mousein){this.calendar.hide();}}; //the calendar will popup when the input element is focused
}
else
{
this.container = targetelement;
this.container.appendChild(this.calendar);
}
this.state = 2; //0: initializing, 1: redrawing, 2: finished!
this.visible ? this.show() : this.hide();
}
//-----------------------------------------------------------------------------
Epoch.prototype.calConfig = function () //PRIVATE: initialize calendar variables
{
/*
------------------------------------------------------------------
la majorité des modifications d'affichage du calendrier se font ici
modifications de configuration faites:
1-Début du calendrier en 2011 à modifier au fur et à mesure
2-Fin en 2037 c'est déjà pas mal
3-jour de début de semaine "Lundi"
4-Affichage du numéro de semaine "non"
------------Commentaire ajouté par Geoffroy MUSITELLI-------------
*/
//this.mode = 'flat'; //can be 'flat' or 'popup'
this.displayYearInitial = this.curDate.getFullYear(); //the initial year to display on load
this.displayMonthInitial = this.curDate.getMonth(); //the initial month to display on load (0-11)
this.rangeYearLower = 2011;
this.rangeYearUpper = 2037;
this.minDate = new Date(2011,0,1);
this.maxDate = new Date(2037,0,1);
this.startDay = 1; // the day the week will 'start' on: 0(Sun) to 6(Sat)
this.showWeeks = false; //whether the week numbers will be shown
this.selCurMonthOnly = false; //allow user to only select dates in the currently displayed month
this.clearSelectedOnChange = true; //whether to clear all selected dates when changing months
//flat mode-only settings:
//this.selectMultiple = true; //whether the user can select multiple dates (flat mode only)
 
switch(this.mode) //set the variables based on the calendar mode
{
case 'popup': //popup options
this.visible = false;
break;
case 'flat':
this.visible = true;
break;
}
this.setLang();
};
//-----------------------------------------------------------------------------
Epoch.prototype.setLang = function() //all language settings for Epoch are made here. Check Date.dateFormat() for the Date object's language settings
{
this.daylist = new Array('Su','Mo','Tu','We','Th','Fr','Sa','Su','Mo','Tu','We','Th','Fr','Sa'); /*<lang:en>*/
this.months_sh = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
this.monthup_title = 'Go to the next month';
this.monthdn_title = 'Go to the previous month';
this.clearbtn_caption = 'Clear';
this.clearbtn_title = 'Clears any dates selected on the calendar';
this.maxrange_caption = 'This is the maximum range';
};
//-----------------------------------------------------------------------------
Epoch.prototype.getTop = function (element) //PRIVATE: returns the absolute Top value of element, in pixels
{
var oNode = element;
var iTop = 0;
while(oNode.tagName != 'BODY') {
iTop += oNode.offsetTop;
oNode = oNode.offsetParent;
}
return iTop;
};
//-----------------------------------------------------------------------------
Epoch.prototype.getLeft = function (element) //PRIVATE: returns the absolute Left value of element, in pixels
{
var oNode = element;
var iLeft = 0;
while(oNode.tagName != 'BODY') {
iLeft += oNode.offsetLeft;
oNode = oNode.offsetParent;
}
return iLeft;
};
//-----------------------------------------------------------------------------
Epoch.prototype.show = function () //PUBLIC: displays the calendar
{
this.calendar.style.display = 'block';
this.visible = true;
};
//-----------------------------------------------------------------------------
Epoch.prototype.hide = function () //PUBLIC: Hides the calendar
{
this.calendar.style.display = 'none';
this.visible = false;
};
//-----------------------------------------------------------------------------
Epoch.prototype.toggle = function () //PUBLIC: Toggles (shows/hides) the calendar depending on its current state
{
if(this.visible) {
this.hide();
}
else {
this.show();
}
};
//-----------------------------------------------------------------------------
Epoch.prototype.setDays = function () //PRIVATE: initializes the standard Gregorian Calendar parameters
{
this.daynames = new Array();
var j=0;
for(var i=this.startDay; i< this.startDay + 7;i++) {
this.daynames[j++] = this.daylist[i];
}
this.monthDayCount = new Array(31,((this.curDate.getFullYear() - 2000) % 4 ? 28 : 29),31,30,31,30,31,31,30,31,30,31);
};
//-----------------------------------------------------------------------------
Epoch.prototype.setClass = function (element,className) //PRIVATE: sets the CSS class of the element, W3C & IE
{
element.setAttribute('class',className);
element.setAttribute('className',className); //<iehack>
};
//-----------------------------------------------------------------------------
Epoch.prototype.createCalendar = function () //PRIVATE: creates the full DOM implementation of the calendar
{
var tbody, tr, td;
this.calendar = document.createElement('table');
this.calendar.setAttribute('id',this.name+'_calendar');
this.setClass(this.calendar,'calendar');
//to prevent IE from selecting text when clicking on the calendar
this.calendar.onselectstart = function() {return false;};
this.calendar.ondrag = function() {return false;};
tbody = document.createElement('tbody');
//create the Main Calendar Heading
tr = document.createElement('tr');
td = document.createElement('td');
td.appendChild(this.createMainHeading());
tr.appendChild(td);
tbody.appendChild(tr);
//create the calendar Day Heading
tr = document.createElement('tr');
td = document.createElement('td');
td.appendChild(this.createDayHeading());
tr.appendChild(td);
tbody.appendChild(tr);
 
//create the calendar Day Cells
tr = document.createElement('tr');
td = document.createElement('td');
td.setAttribute('id',this.name+'_cell_td');
this.calCellContainer = td; //used as a handle for manipulating the calendar cells as a whole
td.appendChild(this.createCalCells());
tr.appendChild(td);
tbody.appendChild(tr);
//create the calendar footer
tr = document.createElement('tr');
td = document.createElement('td');
td.appendChild(this.createFooter());
tr.appendChild(td);
tbody.appendChild(tr);
//add the tbody element to the main calendar table
this.calendar.appendChild(tbody);
 
//and add the onmouseover events to the calendar table
this.calendar.owner = this;
this.calendar.onmouseover = function() {this.owner.mousein = true;};
this.calendar.onmouseout = function() {this.owner.mousein = false;};
};
//-----------------------------------------------------------------------------
Epoch.prototype.createMainHeading = function () //PRIVATE: Creates the primary calendar heading, with months & years
{
//create the containing <div> element
var container = document.createElement('div');
container.setAttribute('id',this.name+'_mainheading');
this.setClass(container,'mainheading');
//create the child elements and other variables
this.monthSelect = document.createElement('select');
this.yearSelect = document.createElement('select');
var monthDn = document.createElement('input'), monthUp = document.createElement('input');
var opt, i;
//fill the month select box
for(i=0;i<12;i++)
{
opt = document.createElement('option');
opt.setAttribute('value',i);
if(this.state == 0 && this.displayMonth == i) {
opt.setAttribute('selected','selected');
}
opt.appendChild(document.createTextNode(this.months_sh[i]));
this.monthSelect.appendChild(opt);
}
//and fill the year select box
for(i=this.rangeYearLower;i<=this.rangeYearUpper;i++)
{
opt = document.createElement('option');
opt.setAttribute('value',i);
if(this.state == 0 && this.displayYear == i) {
opt.setAttribute('selected','selected');
}
opt.appendChild(document.createTextNode(i));
this.yearSelect.appendChild(opt);
}
//add the appropriate children for the month buttons
monthUp.setAttribute('type','button');
monthUp.setAttribute('value','>');
monthUp.setAttribute('title',this.monthup_title);
monthDn.setAttribute('type','button');
monthDn.setAttribute('value','<');
monthDn.setAttribute('title',this.monthdn_title);
this.monthSelect.owner = this.yearSelect.owner = monthUp.owner = monthDn.owner = this; //hack to allow us to access this calendar in the events (<fix>??)
//assign the event handlers for the controls
monthUp.onmouseup = function () {this.owner.nextMonth();};
monthDn.onmouseup = function () {this.owner.prevMonth();};
this.monthSelect.onchange = function() {
this.owner.displayMonth = this.value;
this.owner.displayYear = this.owner.yearSelect.value;
this.owner.goToMonth(this.owner.displayYear,this.owner.displayMonth);
};
this.yearSelect.onchange = function() {
this.owner.displayMonth = this.owner.monthSelect.value;
this.owner.displayYear = this.value;
this.owner.goToMonth(this.owner.displayYear,this.owner.displayMonth);
};
//and finally add the elements to the containing div
container.appendChild(monthDn);
container.appendChild(this.monthSelect);
container.appendChild(this.yearSelect);
container.appendChild(monthUp);
return container;
};
//-----------------------------------------------------------------------------
Epoch.prototype.createFooter = function () //PRIVATE: creates the footer of the calendar - goes under the calendar cells
{
var container = document.createElement('div');
var clearSelected = document.createElement('input');
clearSelected.setAttribute('type','button');
clearSelected.setAttribute('value',this.clearbtn_caption);
clearSelected.setAttribute('title',this.clearbtn_title);
clearSelected.owner = this;
clearSelected.onclick = function() { this.owner.resetSelections(false);};
container.appendChild(clearSelected);
return container;
};
//-----------------------------------------------------------------------------
Epoch.prototype.resetSelections = function (returnToDefaultMonth) //PRIVATE: reset the calendar's selection variables to defaults
{
this.selectedDates = new Array();
this.rows = new Array(false,false,false,false,false,false,false);
this.cols = new Array(false,false,false,false,false,false,false);
if(this.tgt) //if there is a target element, clear it too
{
this.tgt.value = '';
if(this.mode == 'popup') {//hide the calendar if in popup mode
this.hide();
}
}
if(returnToDefaultMonth == true) {
this.goToMonth(this.displayYearInitial,this.displayMonthInitial);
}
else {
this.reDraw();
}
};
//-----------------------------------------------------------------------------
Epoch.prototype.createDayHeading = function () //PRIVATE: creates the heading containing the day names
{
//create the table element
this.calHeading = document.createElement('table');
this.calHeading.setAttribute('id',this.name+'_caldayheading');
this.setClass(this.calHeading,'caldayheading');
var tbody,tr,td;
tbody = document.createElement('tbody');
tr = document.createElement('tr');
this.cols = new Array(false,false,false,false,false,false,false);
//if we're showing the week headings, create an empty <td> for filler
if(this.showWeeks)
{
td = document.createElement('td');
td.setAttribute('class','wkhead');
td.setAttribute('className','wkhead'); //<iehack>
tr.appendChild(td);
}
//populate the day titles
for(var dow=0;dow<7;dow++)
{
td = document.createElement('td');
td.appendChild(document.createTextNode(this.daynames[dow]));
if(this.selectMultiple) { //if selectMultiple is true, assign the cell a CalHeading Object to handle all events
td.headObj = new CalHeading(this,td,(dow + this.startDay < 7 ? dow + this.startDay : dow + this.startDay - 7));
}
tr.appendChild(td);
}
tbody.appendChild(tr);
this.calHeading.appendChild(tbody);
return this.calHeading;
};
//-----------------------------------------------------------------------------
Epoch.prototype.createCalCells = function () //PRIVATE: creates the table containing the calendar day cells
{
this.rows = new Array(false,false,false,false,false,false);
this.cells = new Array();
var row = -1, totalCells = (this.showWeeks ? 48 : 42);
var beginDate = new Date(this.displayYear,this.displayMonth,1);
var endDate = new Date(this.displayYear,this.displayMonth,this.monthDayCount[this.displayMonth]);
var sdt = new Date(beginDate);
sdt.setDate(sdt.getDate() + (this.startDay - beginDate.getDay()) - (this.startDay - beginDate.getDay() > 0 ? 7 : 0) );
//create the table element
this.calCells = document.createElement('table');
this.calCells.setAttribute('id',this.name+'_calcells');
this.setClass(this.calCells,'calcells');
var tbody,tr,td;
tbody = document.createElement('tbody');
for(var i=0;i<totalCells;i++)
{
if(this.showWeeks) //if we are showing the week headings
{
if(i % 8 == 0)
{
row++;
tr = document.createElement('tr');
td = document.createElement('td');
if(this.selectMultiple) { //if selectMultiple is enabled, create the associated weekObj objects
td.weekObj = new WeekHeading(this,td,sdt.getWeek(),row)
}
else //otherwise just set the class of the td for consistent look
{
td.setAttribute('class','wkhead');
td.setAttribute('className','wkhead'); //<iehack>
}
td.appendChild(document.createTextNode(sdt.getWeek()));
tr.appendChild(td);
i++;
}
}
else if(i % 7 == 0) //otherwise, new row every 7 cells
{
row++;
tr = document.createElement('tr');
}
//create the day cells
td = document.createElement('td');
td.appendChild(document.createTextNode(sdt.getDate()));// +' ' +sdt.getUeDay()));
var cell = new CalCell(this,td,sdt,row);
this.cells.push(cell);
td.cellObj = cell;
sdt.setDate(sdt.getDate() + 1); //increment the date
tr.appendChild(td);
tbody.appendChild(tr);
}
this.calCells.appendChild(tbody);
this.reDraw();
return this.calCells;
};
//-----------------------------------------------------------------------------
Epoch.prototype.reDraw = function () //PRIVATE: reapplies all the CSS classes for the calendar cells, usually called after chaning their state
{
this.state = 1;
var i,j;
for(i=0;i<this.cells.length;i++) {
this.cells[i].selected = false;
}
for(i=0;i<this.cells.length;i++)
{
for(j=0;j<this.selectedDates.length;j++) { //if the cell's date is in the selectedDates array, set its selected property to true
if(this.cells[i].date.getUeDay() == this.selectedDates[j].getUeDay() ) {
this.cells[i].selected = true;
}
}
 
this.cells[i].setClass();
}
//alert(this.selectedDates);
this.state = 2;
};
//-----------------------------------------------------------------------------
Epoch.prototype.deleteCells = function () //PRIVATE: removes the calendar cells from the DOM (does not delete the cell objects associated with them
{
this.calCellContainer.removeChild(this.calCellContainer.firstChild); //get a handle on the cell table (optional - for less indirection)
this.cells = new Array(); //reset the cells array
};
//-----------------------------------------------------------------------------
Epoch.prototype.goToMonth = function (year,month) //PUBLIC: sets the calendar to display the requested month/year
{
this.monthSelect.value = this.displayMonth = month;
this.yearSelect.value = this.displayYear = year;
this.deleteCells();
this.calCellContainer.appendChild(this.createCalCells());
};
//-----------------------------------------------------------------------------
Epoch.prototype.nextMonth = function () //PUBLIC: go to the next month. if the month is december, go to january of the next year
{
//increment the month/year values, provided they're within the min/max ranges
if(this.monthSelect.value < 11) {
this.monthSelect.value++;
}
else
{
if(this.yearSelect.value < this.rangeYearUpper)
{
this.monthSelect.value = 0;
this.yearSelect.value++;
}
else {
alert(this.maxrange_caption);
}
}
//assign the currently displaying month/year values
this.displayMonth = this.monthSelect.value;
this.displayYear = this.yearSelect.value;
//and refresh the calendar for the new month/year
this.deleteCells();
this.calCellContainer.appendChild(this.createCalCells());
};
//-----------------------------------------------------------------------------
Epoch.prototype.prevMonth = function () //PUBLIC: go to the previous month. if the month is january, go to december of the previous year
{
//increment the month/year values, provided they're within the min/max ranges
if(this.monthSelect.value > 0)
this.monthSelect.value--;
else
{
if(this.yearSelect.value > this.rangeYearLower)
{
this.monthSelect.value = 11;
this.yearSelect.value--;
}
else {
alert(this.maxrange_caption);
}
}
//assign the currently displaying month/year values
this.displayMonth = this.monthSelect.value;
this.displayYear = this.yearSelect.value;
//and refresh the calendar for the new month/year
this.deleteCells();
this.calCellContainer.appendChild(this.createCalCells());
};
//-----------------------------------------------------------------------------
Epoch.prototype.addZero = function (vNumber) //PRIVATE: pads a 2 digit number with a leading zero
{
return ((vNumber < 10) ? '0' : '') + vNumber;
};
//-----------------------------------------------------------------------------
Epoch.prototype.addDates = function (dates,redraw) //PUBLIC: adds the array "dates" to the calendars selectedDates array (no duplicate dates) and redraws the calendar
{
var j,in_sd;
for(var i=0;i<dates.length;i++)
{
in_sd = false;
for(j=0;j<this.selectedDates.length;j++)
{
if(dates[i].getUeDay() == this.selectedDates[j].getUeDay())
{
in_sd = true;
break;
}
}
if(!in_sd) { //if the date isn't already in the array, add it!
this.selectedDates.push(dates[i]);
}
}
if(redraw != false) {//redraw the calendar if "redraw" is false or undefined
this.reDraw();
}
};
//-----------------------------------------------------------------------------
Epoch.prototype.removeDates = function (dates,redraw) //PUBLIC: adds the dates to the calendars selectedDates array and redraws the calendar
{
var j;
for(var i=0;i<dates.length;i++)
{
for(j=0;j<this.selectedDates.length;j++)
{
if(dates[i].getUeDay() == this.selectedDates[j].getUeDay()) { //search for the dates in the selectedDates array, removing them if the dates match
this.selectedDates.splice(j,1);
}
}
}
if(redraw != false) { //redraw the calendar if "redraw" is false or undefined
this.reDraw();
}
};
//-----------------------------------------------------------------------------
Epoch.prototype.outputDate = function (vDate, vFormat) //PUBLIC: outputs a date in the appropriate format (DEPRECATED)
{
var vDay = this.addZero(vDate.getDate());
var vMonth = this.addZero(vDate.getMonth() + 1);
var vYearLong = this.addZero(vDate.getFullYear());
var vYearShort = this.addZero(vDate.getFullYear().toString().substring(3,4));
var vYear = (vFormat.indexOf('yyyy') > -1 ? vYearLong : vYearShort);
var vHour = this.addZero(vDate.getHours());
var vMinute = this.addZero(vDate.getMinutes());
var vSecond = this.addZero(vDate.getSeconds());
return vFormat.replace(/dd/g, vDay).replace(/mm/g, vMonth).replace(/y{1,4}/g, vYear).replace(/hh/g, vHour).replace(/nn/g, vMinute).replace(/ss/g, vSecond);
};
//-----------------------------------------------------------------------------
Epoch.prototype.updatePos = function (target) //PUBLIC: moves the calendar's position to target's location (popup mode only)
{
this.calendar.style.top = this.getTop(target) + this.topOffset + 'px'
this.calendar.style.left = this.getLeft(target) + this.leftOffset + 'px'
}
//-----------------------------------------------------------------------------
 
/*****************************************************************************/
function CalHeading(owner,tableCell,dow)
{
this.owner = owner;
this.tableCell = tableCell;
this.dayOfWeek = dow;
//the event handlers
this.tableCell.onclick = this.onclick;
}
//-----------------------------------------------------------------------------
CalHeading.prototype.onclick = function ()
{
//reduce indirection:
var owner = this.headObj.owner;
var sdates = owner.selectedDates;
var cells = owner.cells;
owner.cols[this.headObj.dayOfWeek] = !owner.cols[this.headObj.dayOfWeek];
for(var i=0;i<cells.length;i++) //cycle through all the cells in the calendar, selecting all cells with the same dayOfWeek as this heading
{
if(cells[i].dayOfWeek == this.headObj.dayOfWeek && (!owner.selCurMonthOnly || cells[i].date.getMonth() == owner.displayMonth && cells[i].date.getFullYear() == owner.displayYear)) //if the cell's DoW matches, with other conditions
{
if(owner.cols[this.headObj.dayOfWeek]) //if selecting, add the cell's date to the selectedDates array
{
if(owner.selectedDates.arrayIndex(cells[i].date) == -1) { //if the date isn't already in the array
sdates.push(cells[i].date);
}
}
else //otherwise, remove it
{
for(var j=0;j<sdates.length;j++)
{
if(cells[i].dayOfWeek == sdates[j].getDay())
{
sdates.splice(j,1); //remove dates that are within the displaying month/year that have the same day of week as the day cell
break;
}
}
}
cells[i].selected = owner.cols[this.headObj.dayOfWeek];
}
}
owner.reDraw();
};
/*****************************************************************************/
function WeekHeading(owner,tableCell,week,row)
{
this.owner = owner;
this.tableCell = tableCell;
this.week = week;
this.tableRow = row;
this.tableCell.setAttribute('class','wkhead');
this.tableCell.setAttribute('className','wkhead'); //<iehack>
//the event handlers
this.tableCell.onclick = this.onclick;
}
//-----------------------------------------------------------------------------
WeekHeading.prototype.onclick = function ()
{
//reduce indirection:
var owner = this.weekObj.owner;
var cells = owner.cells;
var sdates = owner.selectedDates;
var i,j;
owner.rows[this.weekObj.tableRow] = !owner.rows[this.weekObj.tableRow];
for(i=0;i<cells.length;i++)
{
if(cells[i].tableRow == this.weekObj.tableRow)
{
if(owner.rows[this.weekObj.tableRow] && (!owner.selCurMonthOnly || cells[i].date.getMonth() == owner.displayMonth && cells[i].date.getFullYear() == owner.displayYear)) //match all cells in the current row, with option to restrict to current month only
{
if(owner.selectedDates.arrayIndex(cells[i].date) == -1) {//if the date isn't already in the array
sdates.push(cells[i].date);
}
}
else //otherwise, remove it
{
for(j=0;j<sdates.length;j++)
{
if(sdates[j].getTime() == cells[i].date.getTime()) //this.weekObj.tableRow && sdates[j].getMonth() == owner.displayMonth && sdates[j].getFullYear() == owner.displayYear)
{
sdates.splice(j,1); //remove dates that are within the displaying month/year that have the same day of week as the day cell
break;
}
}
}
}
}
owner.reDraw();
};
/*****************************************************************************/
//-----------------------------------------------------------------------------
function CalCell(owner,tableCell,dateObj,row)
{
this.owner = owner; //used primarily for event handling
this.tableCell = tableCell; //the link to this cell object's table cell in the DOM
this.cellClass; //the CSS class of the cell
this.selected = false; //whether the cell is selected (and is therefore stored in the owner's selectedDates array)
this.date = new Date(dateObj);
this.dayOfWeek = this.date.getDay();
this.week = this.date.getWeek();
this.tableRow = row;
//assign the event handlers for the table cell element
this.tableCell.onclick = this.onclick;
this.tableCell.onmouseover = this.onmouseover;
this.tableCell.onmouseout = this.onmouseout;
//and set the CSS class of the table cell
this.setClass();
}
//-----------------------------------------------------------------------------
CalCell.prototype.onmouseover = function () //replicate CSS :hover effect for non-supporting browsers <iehack>
{
this.setAttribute('class',this.cellClass + ' hover');
this.setAttribute('className',this.cellClass + ' hover');
};
//-----------------------------------------------------------------------------
CalCell.prototype.onmouseout = function () //replicate CSS :hover effect for non-supporting browsers <iehack>
{
this.cellObj.setClass();
};
//-----------------------------------------------------------------------------
CalCell.prototype.onclick = function ()
{
//reduce indirection:
var cell = this.cellObj;
var owner = cell.owner;
if(!owner.selCurMonthOnly || cell.date.getMonth() == owner.displayMonth && cell.date.getFullYear() == owner.displayYear)
{
if(owner.selectMultiple == true) //if we can select multiple cells simultaneously, add the currently selected cell's date to the selectedDates array
{
if(!cell.selected) //if this cell has been selected
{
if(owner.selectedDates.arrayIndex(cell.date) == -1) {
owner.selectedDates.push(cell.date);
}
}
else
{
var tmp = owner.selectedDates; // to reduce indirection
//if the cell has been deselected, remove it from the owner calendar's selectedDates array
for(var i=0;i<tmp.length;i++)
{
if(tmp[i].getUeDay() == cell.date.getUeDay()) {
tmp.splice(i,1);
}
}
}
}
else //if we can only select one cell at a time
{
owner.selectedDates = new Array(cell.date);
if(owner.tgt) //if there is a target element to place the value in, do so
{
owner.tgt.value = owner.selectedDates[0].dateFormat();
if(owner.mode == 'popup') {
owner.hide();
}
}
}
owner.reDraw(); //redraw the calendar cell styles to reflect the changes
}
};
//-----------------------------------------------------------------------------
CalCell.prototype.setClass = function () //private: sets the CSS class of the cell based on the specified criteria
{
if(this.selected) {
this.cellClass = 'cell_selected';
}
else if(this.owner.displayMonth != this.date.getMonth() ) {
this.cellClass = 'notmnth';
}
else if(this.date.getDay() > 0 && this.date.getDay() < 6) {
this.cellClass = 'wkday';
}
else {
this.cellClass = 'wkend';
}
if(this.date.getFullYear() == this.owner.curDate.getFullYear() && this.date.getMonth() == this.owner.curDate.getMonth() && this.date.getDate() == this.owner.curDate.getDate()) {
this.cellClass = this.cellClass + ' curdate';
}
 
this.tableCell.setAttribute('class',this.cellClass);
this.tableCell.setAttribute('className',this.cellClass); //<iehack>
};
/*****************************************************************************/
Date.prototype.getDayOfYear = function () //returns the day of the year for this date
{
return parseInt((this.getTime() - new Date(this.getFullYear(),0,1).getTime())/86400000 + 1);
};
//-----------------------------------------------------------------------------
Date.prototype.getWeek = function () //returns the day of the year for this date
{
return parseInt((this.getTime() - new Date(this.getFullYear(),0,1).getTime())/604800000 + 1);
};
/*function getISOWeek()
{
var newYear = new Date(this.getFullYear(),0,1);
var modDay = newYear.getDay();
if (modDay == 0) modDay=6; else modDay--;
var daynum = ((Date.UTC(this.getFullYear(),this.getMonth(),this.getDate(),0,0,0) - Date.UTC(this.getFullYear()),0,1,0,0,0)) /1000/60/60/24) + 1;
if (modDay < 4 ) {
var weeknum = Math.floor((daynum+modDay-1)/7)+1;
}
else {
var weeknum = Math.floor((daynum+modDay-1)/7);
if (weeknum == 0) {
year--;
var prevNewYear = new Date(this.getFullYear(),0,1);
var prevmodDay = prevNewYear.getDay();
if (prevmodDay == 0) prevmodDay = 6; else prevmodDay--;
if (prevmodDay < 4) weeknum = 53; else weeknum = 52;
}
}
return + weeknum;
}*/
//-----------------------------------------------------------------------------
Date.prototype.getUeDay = function () //returns the number of DAYS since the UNIX Epoch - good for comparing the date portion
{
return parseInt(Math.floor((this.getTime() - this.getTimezoneOffset() * 60000)/86400000)); //must take into account the local timezone
};
//-----------------------------------------------------------------------------
Date.prototype.dateFormat = function(format)
{
if(!format) { // the default date format to use - can be customized to the current locale
format = 'd F Y'; //Changé pour avoir la date au format jour mois_long année_sur_4digits
}
LZ = function(x) {return(x < 0 || x > 9 ? '' : '0') + x};
var MONTH_NAMES = new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var DAY_NAMES = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
format = format + "";
var result="";
var i_format=0;
var c="";
var token="";
var y=this.getFullYear().toString();
var M=this.getMonth()+1;
var d=this.getDate();
var E=this.getDay();
var H=this.getHours();
var m=this.getMinutes();
var s=this.getSeconds();
var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
// Convert real this parts into formatted versions
var value = new Object();
//if (y.length < 4) {y=''+(y-0+1900);}
value['Y'] = y.toString();
value['y'] = y.substring(2);
value['n'] = M;
value['m'] = LZ(M);
value['F'] = MONTH_NAMES[M-1];
value['M'] = MONTH_NAMES[M+11];
value['j'] = d;
value['d'] = LZ(d);
value['D'] = DAY_NAMES[E+7];
value['l'] = DAY_NAMES[E];
value['G'] = H;
value['H'] = LZ(H);
if (H==0) {value['g']=12;}
else if (H>12){value['g']=H-12;}
else {value['g']=H;}
value['h']=LZ(value['g']);
if (H > 11) {value['a']='pm'; value['A'] = 'PM';}
else { value['a']='am'; value['A'] = 'AM';}
value['i']=LZ(m);
value['s']=LZ(s);
//construct the result string
while (i_format < format.length) {
c=format.charAt(i_format);
token="";
while ((format.charAt(i_format)==c) && (i_format < format.length)) {
token += format.charAt(i_format++);
}
if (value[token] != null) { result=result + value[token]; }
else { result=result + token; }
}
return result;
};
/*****************************************************************************/
Array.prototype.arrayIndex = function(searchVal,startIndex) //similar to array.indexOf() - created to fix IE deficiencies
{
startIndex = (startIndex != null ? startIndex : 0); //default startIndex to 0, if not set
for(var i=startIndex;i<this.length;i++)
{
if(searchVal == this[i]) {
return i;
}
}
return -1;
};
/*****************************************************************************/
/web/js/fonctions.js
0,0 → 1,59
 
/* Fonctions JavaScript*/
 
 
function password(size,formulaire)
/*Fonction création de mot de passe*/
{
var chars='0123456789abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ'
var pass=''
while(pass.length < size)
{
pass+=chars.charAt(Math.round(Math.random() * (chars.length)))
}
document.forms[formulaire].passwd.value=pass
document.forms[formulaire].pwdgene.value=pass
}
 
function formControl(formulaire){
/*Fonction contrôle du formulaire*/
var myregex = /[\S]+/gi; //un ou plusieurs caractères non blanc" (tous les caractères sauf espace, retour chariot, tabulation, saut de ligne, saut de page).
if (myregex.test(document.forms[formulaire].login.value)){
document.forms[formulaire].create.value=1;
return true;
} else {
alert("Votre identifiant est invalide.");//non internationnalisé
return false;
}
}
 
function temps(selectbox,origine,formulaire) {
/*
Fonction qui effectue la conversion en seconde en fonction de l'unité choisi
La valeur en seconde est écrite à la place de la valeur d'origine et la liste déroulante est replacée sur 's'
*/
i = selectbox.options.selectedIndex;
/*unité correspond à 's' m' ou 'H' */
unite = selectbox.options[i].value;
/*multiple est le coéfficient multiplicateur pour obtenir la valeur en secondes*/
multiple=1;
if (unite == "m") {
multiple=60;
}
else {
if (unite=="H") {
multiple=3600;
}
}
/*valeur est la valeur en seconde d'origine petite condition pour traiter la valeur vide*/
valeur = document.forms[formulaire].elements[origine].value;
if (valeur!='') valeur = valeur * multiple;
document.forms[formulaire].elements[origine].value = valeur;
selectbox.options.selectedIndex=0;
}
 
function lang_imp(selectbox,formulaire) {
/*Fonction permettant de remplir la valeur de langue d'impression*/
i = selectbox.options.selectedIndex;
document.forms[formulaire].langue_imp.value = selectbox.options[i].value;
}