File "parametrages.php"

Full Path: /home/analogde/www/Massage_prod_avant/parametrages.php
File size: 4.72 KB
MIME-type: text/x-php
Charset: utf-8

<?php

	session_start ();
	
	include('database.php');
	DB_connexion();
 	header( 'content-type: text/html; charset=utf-8' );
	
	if (!isset($_SESSION['nom']) && !isset($_SESSION['password']))
	{  
			header("Location: login.php");   
	}
/*	
CREATE TABLE IF NOT EXISTS configuration (
  id int(11) NOT NULL AUTO_INCREMENT,
  tarifCE varchar(30) NOT NULL,
  tarifnormal varchar(30) NOT NULL,
  seuilcreneau varchar(30) NOT NULL,
  PRIMARY KEY (id)
)*/
	
	if(isset($_POST['submit']))
	{
			if(isset($_POST['verrou']) && $_POST['verrou'] == "ok")
			{
				$tarifCE = $_POST['tarifCE'];		
				$tarifnormal = $_POST['tarifnormal'];	
				$nb_creneau = $_POST['nb_creneau'];	
				
				// rafraichir 
				$_SESSION['tarifCE'] = $tarifCE;	
				$_SESSION['tarifnormal'] = $tarifnormal; 
				$_SESSION['nb_creneau'] = $nb_creneau; 
				
				$id = 1;
				$sql = "UPDATE configuration  SET tarifCE = '$tarifCE',  tarifnormal ='$tarifnormal' , nb_creneau = '$nb_creneau' WHERE id = '$id' ";
				//echo $sql;
				$result = mysqli_query($connexion, $sql );	
				if(!$result)
				{
					die('Impossible d\'exécuter la requête :' . mysql_error());
				}		
				
				echo "Paramétres pris en compte";
				echo '<br><br>';
			}	
	}
	 
	$sql = 'SELECT * FROM configuration';
	mysqli_query($connexion, "SET NAMES 'utf8'");
	$result = mysqli_query($connexion, $sql );
	$data = mysqli_fetch_assoc($result);
	$tarifCE = $data['tarifCE'];		
	$tarifnormal = $data['tarifnormal'];	
	$nb_creneau = $data['nb_creneau'];	
	
/*	
	CREATE TABLE IF NOT EXISTS configuration (
  id int(11) NOT NULL AUTO_INCREMENT,
  tarifCE varchar(30) NOT NULL,
  tarifnormal varchar(30) NOT NULL,
  PRIMARY KEY (id)
)
	 */
	 
?>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Tarification</title>
</head>		

<link rel="stylesheet" href="menu_style.css" type="text/css">

<body>

<script type="text/javascript">

function valide_champs()
{	
	var champ1 = document.getElementById('tarifCE').value;
	var champ2 = document.getElementById('tarifnormal').value;
	
	var verif = true;
	var msg_erreur = new Array;
	
	if(isNaN(champ1) == true ||  isNaN(champ2) == true )
	{
			msg_erreur[0] = "Uniquement des chiffres !";
			verif = false;
	}
	
	if(champ1 == '' ||  champ2 == '' )
	{
			msg_erreur[0] = "Pas de champs vide !";
			verif = false;
	}
	
	if(verif == true)
 	{ document.getElementById('verrou').value="ok";
 	}
 	
	if(verif == false)
 	{ 	var affiche = msg_erreur.join("\n");
		alert(affiche);
		document.getElementById('verrou').value="erreur";
 	}	
	
} 

</script>

	<link rel="stylesheet" href="menu_style.css" type="text/css">

	<div id='cssmenu'>
	<ul>
		<li><a href='home.php'><span>Home</span></a></li>
		<li><a href='selection_planning_mois.php'><span>Planning</span></a></li>
		<li><a href='selection_gestion_mois.php'><span>Gestion</span></a></li>
		<li><a href='selection_statistique_mois.php'><span>Statistiques</span></a></li>
<?php
		if($_SESSION['nom'] == "admin")
		{ 	
			echo '<li><a href="deplacer_un_rendezvous_admin.php"><span>Déplacer</span></a></li>';
			echo '<li><a href="configuration.php"><span>Configuration</span></a></li>';
		}
		else
		{
			echo '<li><a href="deplacer_un_rendezvous_user.php"><span>Déplacer</span></a></li>';
		}
?>
		<li><a href='change_password.php'><span>Changer password</span></a></li>
		<li><a href='logout.php'><span>Déconnexion</span></a></li>
		<li><a href='#'><span><?php echo $_SESSION['nom'] .' ' .$_SESSION['prenom'] .' connecté' ?></span></a></li>
	</ul>
	</div>
	<br>
	<br>
	
	
	<form action="" method="post" id="editer_tarif" name="editer_tarif" >
	<input type="hidden" name="verrou" id="verrou" value="">

	<table align="left" cellspacing="1" cellpadding="5" border="0" bgcolor="#D5D5D5" width="600">
	<tr bgcolor="#F1F3F5">
	<td colspan="2">Paramétres : </td>
	</tr>
	</tr>
		
	</td>
	</tr>
		
	<tr bgcolor="#FFFFFF">
	<td align="left" valign="top">Tarif CE (subvention) :</td>
	<td><input type="text" id="tarifCE" = name="tarifCE" size="5" maxlength="5"  value="<?php echo $tarifCE; ?>" id="annee" >&nbsp;</td>
	</tr>

	<tr bgcolor="#FFFFFF">
	<td align="left" valign="top">Tarif normal :</td>
	<td><input type="text" id="tarifnormal" name="tarifnormal" size="5" maxlength="5"  value="<?php echo $tarifnormal; ?>" id="date" >&nbsp;</td>
	</tr>
	
	<tr bgcolor="#FFFFFF">
	<td align="left" valign="top">Nombre de créneaux par semaine (sans supplément):</td>
	<td><input type="text" id="nb_creneau" name="nb_creneau" size="5" maxlength="5"  value="<?php echo $nb_creneau; ?>" id="date" >&nbsp;</td>
	</tr>	
				
	<tr bgcolor="#F1F3F5">
	<td colspan="2" align="center">
	
    <input type="submit" name="submit" value="Enregister" onclick="valide_champs()"/>
	</td>
	</tr>
		
	</table>
	</div>
	</div>
		
	</form>
	
	</body>
	</html>