Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
58ee48d
commit bbb72df
Showing
12 changed files
with
700 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<div class="itemBox"> | ||
<input type="text" class="span3" name="partnerName[]" placeholder="Ad"> | ||
|
||
<div class="input-append"> | ||
<input type="text" class="span3 partnerPriceInput" name="partnerPrice[]" placeholder="Toplam Ücret"> | ||
<span class="add-on">TL</span> | ||
</div> | ||
|
||
|
||
<a class="btn deleteItemBox" href="javascript:void(0);"><i class="icon-remove"></i></a> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<?php | ||
$isAllValueValid = true; | ||
|
||
foreach ($_POST['partnerPrice'] as $row) | ||
{ | ||
if (empty($row)) | ||
{ | ||
// eğer değerlerden biri boş ise artık diğerlerini kontrol etmez. | ||
// döngüden çıkar. | ||
$isAllValueValid = false; | ||
break; | ||
} | ||
} | ||
|
||
// eğer price lar geçerli ise sıra isimleri kontrol etmeye gelir. | ||
if ($isAllValueValid) | ||
{ | ||
foreach ($_POST['partnerName'] as $row) | ||
{ | ||
if (empty($row)) | ||
{ | ||
$isAllValueValid = false; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
// kontrollerin sonucunda işleme başlanır yada uyarı verilir. | ||
if ($isAllValueValid) | ||
{ | ||
// kişilerin ödeyeceği toplam ücret öğreniliyor. | ||
$totalPrice = 0; | ||
|
||
foreach ($_POST['partnerPrice'] as $row) | ||
{ | ||
$totalPrice += $row; | ||
} | ||
|
||
|
||
// toplam ücrete joker indirimi uygulanır. | ||
// 70 => 45 | ||
if ($totalPrice >= 70) | ||
{ | ||
$newTotalPrice = $totalPrice - 25; | ||
$discountName = '70 yerine 45 tl öde'; | ||
} | ||
// 40 => 25 | ||
elseif ($totalPrice >= 40) | ||
{ | ||
$newTotalPrice = $totalPrice - 15; | ||
$discountName = '40 yerine 25 tl öde'; | ||
} | ||
// 30 => 20 | ||
elseif ($totalPrice >= 30) | ||
{ | ||
$newTotalPrice = $totalPrice - 10; | ||
$discountName = '30 yerine 20 tl öde'; | ||
} | ||
|
||
|
||
// eğer ücrete joker indirimi uygulanmış ise işleme devam edilir. | ||
if (isset($newTotalPrice)) | ||
{ | ||
// her bir kişi toplam ücretin "yüzde" olarak ne kadarını karşılıyor öğreniyoruz. | ||
foreach ($_POST['partnerPrice'] as $row) | ||
{ | ||
$partnerPricePercent[] = round(($row * 100) / $totalPrice); | ||
} | ||
|
||
|
||
// ardından mevcut yüzdeleri joker indirimli yeni fiyat üzerinden yeniden hesaplarız. | ||
// böylece herkesin ödemesi gereken tutar ortaya çıkar. | ||
$newRoundedTotalPrice = 0; | ||
|
||
foreach ($partnerPricePercent as $percentVal) | ||
{ | ||
$price = ($newTotalPrice * $percentVal) / 100; | ||
|
||
// normal ücret | ||
$newPartnerPrice[] = $price; | ||
|
||
// yuvarlanmış ücret | ||
$newRoundedPartnerPrice[] = round($price); | ||
|
||
// yuvarlanmış ücretlerin tamamı toplanır. | ||
$newRoundedTotalPrice += round($price); | ||
} | ||
|
||
|
||
require 'calcDesign.php'; | ||
} | ||
else | ||
{ | ||
echo 'Toplam sipariş tutarı joker indirimi uygulanmayacak kadar düşük.'; | ||
} | ||
} | ||
else | ||
{ | ||
echo 'Bütün alanlar dolu olmalı.'; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
|
||
<ul> | ||
<li>Toplam tutar: <strong><?php echo $totalPrice; ?></strong></li> | ||
<li>Uygulanan joker indirimi: <strong><?php echo $discountName; ?></strong></li> | ||
<li>Joker uygulanmış toplam tutar: <strong><?php echo $newTotalPrice; ?></strong></li> | ||
<li>Joker uygulanmış ve yuvarlanmış toplam tutar: <strong><?php echo $newRoundedTotalPrice; ?></strong></li> | ||
</ul> | ||
|
||
|
||
|
||
|
||
<table class="table table-bordered table-hover"> | ||
<thead> | ||
<tr> | ||
<th>İsim</th> | ||
<th>Yeni ücret</th> | ||
<th>Yeni ücret - yuvarlanmış</th> | ||
<th>Joker olmadan</th> | ||
<th>Kazanç</th> | ||
<th>Yüzde</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<?php | ||
foreach ($_POST['partnerName'] as $k => $name) { | ||
|
||
$showNewPartnerPrice = $newPartnerPrice[$k]; | ||
$showNewRoundedPartnerPrice = $newRoundedPartnerPrice[$k]; | ||
$showPartnerPrice = $_POST['partnerPrice'][$k]; | ||
$showPartnerDiscountPrice = $showPartnerPrice - $showNewPartnerPrice; | ||
$showPartnerPricePercent = $partnerPricePercent[$k]; | ||
?> | ||
<tr> | ||
<td><?php echo $name; ?></td> | ||
<td><?php echo $showNewPartnerPrice; ?></td> | ||
<td><?php echo $showNewRoundedPartnerPrice; ?></td> | ||
<td><?php echo $showPartnerPrice; ?></td> | ||
<td><?php echo $showPartnerDiscountPrice; ?></td> | ||
<td>% <?php echo $showPartnerPricePercent; ?></td> | ||
</tr> | ||
<?php } // end foreach ?> | ||
</tbody> | ||
</table> | ||
|
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/** | ||
* Created with JetBrains WebStorm. | ||
* User: Güven | ||
* Date: 07.03.2013 | ||
* Time: 20:27 | ||
* To change this template use File | Settings | File Templates. | ||
*/ | ||
|
||
|
||
|
||
$(function(){ | ||
|
||
|
||
addItemBox(); | ||
addItemBox(); | ||
|
||
|
||
|
||
$('a.deleteItemBox').live('click', function() | ||
{ | ||
var itemBoxCount = $('div.itemBox').length; | ||
|
||
if (itemBoxCount > 2) | ||
{ | ||
$(this).parent().remove(); | ||
} | ||
else | ||
{ | ||
alert('Sipariş veren en az 2 kişi olmalı.'); | ||
} | ||
}); | ||
|
||
|
||
|
||
// ücret girişi yapılan numeric(float) input kontrolü | ||
$('.partnerPriceInput').live('focus', function(){ | ||
$(this).numeric(); | ||
}); | ||
|
||
|
||
}); | ||
|
||
|
||
|
||
function addItemBox() | ||
{ | ||
$.ajax({ | ||
type : 'GET', | ||
url : 'add-item-box.html', | ||
dataType : 'html', | ||
success : function(data) | ||
{ | ||
$('form#calcForm').append(data); | ||
} | ||
}); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
// hesapla butonuna basıldığında çalışır. | ||
function calc() | ||
{ | ||
$.ajax({ | ||
type : 'POST', | ||
url : 'calc.php', | ||
data : $('form#calcForm').serialize(), | ||
dataType : 'html', | ||
success : function(data) | ||
{ | ||
$('div#myModal div#modalContent').html(data); | ||
$('div#myModal').modal('show'); | ||
} | ||
}); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Oops, something went wrong.