Merhaba Arkadaşlar
PHP kredi hesaplama verilerini post ettiğim modal bölümüne yazdıramıyorum, bu konuda yardım edebilirmisiniz, kod bloklarım aşağıdaki gibi
kredi.php
<div class="modal fade" id="empModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">User Info</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div class="widget">
<h3 class="sidebar-title">Başlık</h3>
<form class="mortgage-calc">
<div class="calc-input">
<input type="text" class="form-control" name="kredi" placeholder="Kredi Tutarı" required />
<label class="fa fa-try"></label>
</div>
<div class="calc-input">
<select class="form-control" name="vade" required>
<option value="12">12 Ay</option>
<option value="24">24 Ay</option>
<option value="36">36 Ay</option>
<option value="48">48 Ay</option>
</select>
<label class="lni-calendar"></label>
</div>
<div class="calc-input">
<input type="text" class="form-control" name="faiz" placeholder="Faiz Oranı" required />
<label>%</label>
</div>
<div class="calc-input">
<input type="text" class="form-control" name="bsmv" value="0.05" placeholder="BSMV" />
<label>BSMV</label>
</div>
<div class="calc-input">
<input type="text" class="form-control" name="kkdf" value="0.15" placeholder="KKDF" />
<label>KKDF</label>
</div>
<button type="submit" class="btn btn-common">Hesapla</button>
</form>
</div>
<script type='text/javascript'>
$(document).ready(function(){
$('.userinfo').click(function(){
var userid = $(this).data('id');
// AJAX request
$.ajax({
url: 'kredihesapla.php',
type: 'post',
data: {userid: userid},
success: function(response){
// Add response in Modal body
$('.modal-body').html(response);
// Display Modal
$('#empModal').modal('show');
}
});
});
});
</script>
---------------------
kredihesapla.php
<?php
$bul = array(' ',',','.');
$degistir = array('','','');
$kredi = str_replace($bul, $degistir, $_POST['kredi']);
$vade = $_POST['vade']; // Kaç taksit olacak
$bul = array(',',' ');
$degistir = array('.','');
$faiz = str_replace($bul, $degistir, $_POST['faiz']);
$bul = array(',',' ');
$degistir = array('.','');
$bsmv = str_replace($bul, $degistir, $_POST['bsmv']);
$kkdf = str_replace($bul, $degistir, $_POST['kkdf']);
$vergi_faiz = ($faiz / 100) * (1 + $bsmv + $kkdf);
$deger1 = $vergi_faiz * pow((1+$vergi_faiz),$vade);
$deger2 = pow((1+$vergi_faiz),$vade) - 1;
$taksit = $kredi * $deger1/$deger2;
?>
<div class="col-12">
<table class="table table-bordered">
<tr>
<th>Kredi Tutarı</th>
<th>Kredi Vadesi</th>
<th>Kredi Faizi</th>
<th>BSMV</th>
<th>KKDF</th>
<th>Taksit Tutarı</th>
</tr>
<tr>
<td><?=number_format($kredi, 2, ',', '.')?></td>
<td><?=$vade?></td>
<td><?=$faiz?></td>
<td><?=$bsmv?></td>
<td><?=$kkdf?></td>
<td><?=number_format($taksit, 2, ',', '.')?></td>
</tr>
</table>
<table class="table table-bordered table-striped">
<tr>
<th>Dönem</th>
<th>Taksit Tutarı</th>
<th>Anapara</th>
<th>Faiz</th>
<th>KKDF</th>
<th>BSMV</th>
<th>Kalan Anapara</th>
</tr>
<?php
for ($row = '1'; $row <= $vade; $row++) {
if ($row == '1') {
// Birinci Satır
$_faiz = $kredi * ($faiz / 100);
$_kkdf = $_faiz * $kkdf;
$_bsmv = $_faiz * $bsmv;
$_anapara = $taksit - ($_faiz + $_kkdf + $_bsmv);
$_kalananapara = $kredi - $_anapara;
echo '<tr>';
echo '<td>'.$row.'</td>';
echo '<td>'.number_format($taksit, 2, ',', '.').' TL</td>';
echo '<td>'.number_format($_anapara, 2, ',', '.').'</td>';
echo '<td>'.number_format($_faiz, 2, ',', '.').'</td>';
echo '<td>'.$_kkdf.'</td>';
echo '<td>'.$_bsmv.'</td>';
echo '<td>'.number_format($_kalananapara, 2, ',', '.').'</td>';
echo '</tr>';
}else{
// Diğer Satırlar
$_faiz = $_kalananapara * ($faiz / 100);
$_kkdf = $_faiz * $kkdf;
$_bsmv = $_faiz * $bsmv;
$_anapara = $taksit - ($_faiz + $_kkdf + $_bsmv);
$_kalananapara = $_kalananapara - $_anapara;
echo '<tr>';
echo '<td>'.$row.'</td>';
echo '<td>'.number_format($taksit, 2, ',', '.').' TL</td>';
echo '<td>'.number_format($_anapara, 2, ',', '.').'</td>';
echo '<td>'.number_format($_faiz, 2, ',', '.').'</td>';
echo '<td>'.number_format($_kkdf, 2, ',', '.').'</td>';
echo '<td>'.number_format($_bsmv, 2, ',', '.').'</td>';
echo '<td>'.number_format($_kalananapara, 2, ',', '.').'</td>';
echo '</tr>';
}
}
?>
</table>
</div>