Your IP : 216.73.216.65


Current Path : /home/ataenra/www/ATA/INTRANET/Formulaires/CLIENT/
Upload File :
Current File : /home/ataenra/www/ATA/INTRANET/Formulaires/CLIENT/Simulprime.php

<?php
require "../../Outils/co.php"; 

$PR = $dbco->prepare("SELECT * FROM primerenov"); //user='$AF' AND
$PR->execute();
$RPR = $PR->fetchall();

if(isset($_POST['Simulprime'])&&$_POST['Simulprime']=="Valider"){

$client = $dbco->prepare("SELECT * FROM client WHERE IDc = '".$_SESSION['IDclient']."'"); //user='$AF' AND
$client->execute();
$CLI = $client->fetch(PDO::FETCH_OBJ);

//CODES DES PRIMES
if($_POST['revenu']=="L1"){$CouleurPrimeRenov = "BLEU"; $ProfilCee = "Tres Modeste";
}elseif($_POST['revenu']=="L2"){$CouleurPrimeRenov = "JAUNE"; $ProfilCee = "Modeste";
}else if($_POST['revenu']=="L3"){$CouleurPrimeRenov = "VIOLET"; $ProfilCee = "Classiques";    
}else if($_POST['revenu']=="L4"){$CouleurPrimeRenov = "ROSE"; $ProfilCee = "Classiques";}

if(isset($_SESSION['IDsimulA'])){$SIMUL = $_SESSION['ID_simulA'];}

//ENREGISTRER LA SIMULATION 
$UP2 = $dbco->prepare("UPDATE cli_simulprime set ID_simulprime = :ID_simulprime, PrimeATA = :PrimeATA, prop =:prop, proptype = :proptype, hab = :hab, ancienprime = :ancienprime, CouleurPrimeRenov = :CouleurPrimeRenov, ProfilCee = :ProfilCee, NBPERS = :NBPERS, revenu = :revenu, revenus = :revenus
where ID_simulprime = :ID_simulprime");
$UP2->bindParam('ID_simulprime',$_SESSION['ID_simulA']);
$UP2->bindValue('PrimeATA','PR');
$UP2->bindParam('prop',$_POST['Prop']);
$UP2->bindParam('proptype',$_POST['PropType']);
$UP2->bindParam('hab',$_POST['hab']);
$UP2->bindParam('ancienprime',$_POST['ancienprime']);
$UP2->bindParam(':CouleurPrimeRenov',$CouleurPrimeRenov);
$UP2->bindParam(':ProfilCee',$ProfilCee);
$UP2->bindParam(':NBPERS',$_POST['NBPERS']);
$UP2->bindParam(':revenu',$_POST['revenu']);
$UP2->bindParam(':revenus',$_POST['revenus']);
$UP2->execute();

$_SESSION['ID_simul'] = $_SESSION['ID_simulA'];
$_SESSION['NewSimul'] = 0;
header("location:NouveauProjet.php");

}
?>
<?php if($_SESSION['Adresse']=='log'){
   $client = $dbco->prepare("SELECT * FROM cli_simulprime WHERE ID_sp_client = '".$_SESSION['IDclient']."' AND ID_simulprime = '".$_SESSION['ID_simulA']."'"); //user='$AF' AND
   $client->execute();
   $CLI = $client->fetch(PDO::FETCH_OBJ); 
    
    ?>
    <form method="post">
    
	<div class="row">
            

    		<div class="col-md-6">
              
                <input type="hidden" name="PropType" value="<?php echo $CLI->proptype; ?>">
                <input type="hidden" name="Prop" value="<?php echo $CLI->prop; ?>">
                <input type="hidden" name="hab" value="<?php echo $CLI->hab; ?>">

					<p> Avez-vous déja perçu des aides de l'état ? <select class="form-control" name="ancienprime"></p>
					<option selected>Non</option>
					<option>Moins de 5 ans</option>
					<option>Plus de 5 ans</option>
					<option>Demande en cours</option></select>

                    <p> Nombre de parts : <select class="form-control" name="NBPERS" onchange="updateList3(this.value)" ></p>
              		<option>Nombre ?</option><option>1</option><option>2</option><option>3</option><option>4</option><option>5</option><option>6</option><option>7</option><option>8</option><option>9</option></select>

			</div>

			<div class="col-md-6">
                   
					
					<p> Tranche de revenu : <select name="revenu" class="form-control" id="revenu" ><option value="">-- Selectionner --</option></select></p>
					<P> Revenu imposable : <input type="text" name="revenus" class="form-control" placeholder="Valeur nette" minlength="4" maxlength="6" pattern="[0-9]{4,6}"/></p><br>
					
			</div>
           
    </div>
    <div class="row">  
            <br><br>
            <div class="col-md-8"></div>
            <div class="col-md-4">
                <input type="submit" name="Simulprime" class="btn-l btn-primary" value="Valider" />
            </div>
    </div>
                
		
</form>	

<?php } ?>

<?php if($_SESSION['Adresse']=='dif'){?>

<h2>NOUVELLE SIMULATION AIDES</h2>
<form method="post">
    
	<div class="row">
            

    		<div class="col-md-6">
                    <p> Le logement est ?<select class="form-control" name="PropType"></p>
					<option selected>Une maison</option>
					<option>Un appartement</option>
					</select>

					<p> Je suis le ?<select class="form-control" name="Prop"></p>
					<option selected>Proprietaire residence principale</option>
					<option>Proprietaire residence secondaire</option>
					<option>Proprietaire bailleur</option>
					<option>Locataire avec bail</option>
					<option>Locataire a titre gratuit</option></select>

					<p> Le logement a ?<select class="form-control" name="hab"></p>
					<option selected>Moins de 2 ans</option>
					<option>Entre 2 et 15 ans</option>
					<option>Plus de 15 ans</option></select>

					<p> Avez-vous déja perçu des aides de l'état ? <select class="form-control" name="ancienprime"></p>
					<option selected>Non</option>
					<option>Moins de 5 ans</option>
					<option>Plus de 5 ans</option>
					<option>Demande en cours</option></select>
			</div>

			<div class="col-md-6">
                   
					<p> Nombre de parts : <select class="form-control" name="NBPERS" onchange="updateList3(this.value)" ></p>
              		<option>Nombre ?</option><option>1</option><option>2</option><option>3</option><option>4</option><option>5</option><option>6</option><option>7</option><option>8</option><option>9</option></select>
					<p> Tranche de revenu : <select name="revenu" class="form-control" id="revenu" ><option value="">-- Selectionner --</option></select></p>
					<P> Revenu imposable : <input type="text" name="revenus" class="form-control" placeholder="Valeur nette" minlength="4" maxlength="6" pattern="[0-9]{4,6}"/></p><br>
					
			</div>
           
    </div>
    <div class="row">  
            <br><br>
            <div class="col-md-8"></div>
            <div class="col-md-4">
                <input type="submit" name="Simulprime" class="btn-l btn-primary" value="Valider" />
            </div>
    </div>
                
		
</form>	
<?php } ?>



<script type="text/javascript">
document.getElementById("champ_cache").style.display = "none";
document.getElementById("champ_cache1").style.display = "none";
document.getElementById("champ_cache2").style.display = "none";
function afficher(){
document.getElementById("champ_cache").style.display = "block";
document.getElementById("champ_cache1").style.display = "block";
document.getElementById("champ_cache2").style.display = "block";
}
function cacher(){
document.getElementById("champ_cache").style.display = "none";
document.getElementById("champ_cache1").style.display = "none";
document.getElementById("champ_cache2").style.display = "none";
}
</script>

<script>
  
            function updateList3(C) {
            var revenu = document.getElementById("revenu");
            revenu.options.length = 0;
            if (C === "1") {
            revenu.options[0] = new Option("Moins de <?php echo $RPR[0][1];?> euros", "L1");
            revenu.options[1] = new Option("Entre <?php echo $RPR[0][1];?> et <?php echo $RPR[1][1];?> euros", "L2");
            revenu.options[2] = new Option("Entre <?php echo $RPR[1][1];?> et <?php echo $RPR[2][1];?> euros", "L3");
            revenu.options[3] = new Option("Supérieur à <?php echo $RPR[2][1];?> euros", "L4");
            } else if (C === "2") {
            revenu.options[0] = new Option("Moins de <?php echo $RPR[0][2];?> euros", "L1");
            revenu.options[1] = new Option("Entre <?php echo $RPR[0][2];?> et <?php echo $RPR[1][2];?> euros", "L2");
            revenu.options[2] = new Option("Entre <?php echo $RPR[1][2];?> et <?php echo $RPR[2][2];?> euros", "L3");
            revenu.options[3] = new Option("Supérieur à <?php echo $RPR[2][2];?> euros", "L4");
            } else if (C === "3") {
            revenu.options[0] = new Option("Moins de <?php echo $RPR[0][3];?> euros", "L1");
            revenu.options[1] = new Option("Entre <?php echo $RPR[0][3];?> et <?php echo $RPR[1][3];?> euros", "L2");
            revenu.options[2] = new Option("Entre <?php echo $RPR[1][3];?> et <?php echo $RPR[2][3];?> euros", "L3");
            revenu.options[3] = new Option("Supérieur à <?php echo $RPR[2][3];?> euros", "L4");
            } else if (C === "4") {
            revenu.options[0] = new Option("Moins de <?php echo $RPR[0][4];?> euros", "L1");
            revenu.options[1] = new Option("Entre <?php echo $RPR[0][4];?> et <?php echo $RPR[1][4];?> euros", "L2");
            revenu.options[2] = new Option("Entre <?php echo $RPR[1][4];?> et <?php echo $RPR[2][4];?> euros", "L3");
            revenu.options[3] = new Option("Supérieur à <?php echo $RPR[2][4];?> euros", "L4");	
            } else if (C === "5") {
            revenu.options[0] = new Option("Moins de <?php echo $RPR[0][5];?> euros", "L1");
            revenu.options[1] = new Option("Entre <?php echo $RPR[0][5];?> et <?php echo $RPR[1][5];?> euros", "L2");
            revenu.options[2] = new Option("Entre <?php echo $RPR[1][5];?> et <?php echo $RPR[2][5];?> euros", "L3");
            revenu.options[3] = new Option("Supérieur à <?php echo $RPR[2][5];?> euros", "L4");	
            } else if (C > "5") { 
            var D=C-5;
            revenu.options[0] = new Option("Moins de "+(38168+D*4813)+" euros","L1");
            revenu.options[1] = new Option("Entre "+(38168+D*4813)+" et "+(48930+D*6165)+" euros", "L2");
            revenu.options[2] = new Option("Entre "+(48930+D*5797)+" et "+(69081+D*8744)+" euros", "L3");
            revenu.options[3] = new Option("Supérieur à "+(69081+D*8744)+" euros", "L4");	
        
        }
    }
</script>