Added some human interaction with Deposit Calculator.

This commit is contained in:
Jonathan Rosenbaum
2015-01-03 11:00:33 +00:00
parent 890b8f1b15
commit 511dc81471
2 changed files with 40 additions and 9 deletions
+32 -3
View File
@@ -11,11 +11,13 @@ $(function() {
// paid or not?
$(":checked").parent("td").prev().children().hide();
$(".paid").click(function() {
$.ajaxSetup({async:false});
if ($(this).prop("checked")) {
$(this).closest("tr").css("background-color","#E6E7E6");
$('[href*="' + this.name + '"]').hide();
console.log(this.name);
$.post("json/transaction.php",{ paid: 1, transaction_id: this.name } );
}
else {
@@ -24,17 +26,44 @@ $(function() {
$('[href*="' + this.name + '"]').show();
$.post("json/transaction.php",{ paid: 0, transaction_id: this.name } );
}
// Deposit Calculator
var deposit = {};
$(".deposit input").each(function(count){
deposit[count] = this.name;
});
$.post("json/transaction.php",{"deposit": deposit}, function(data) {
var obj = $.parseJSON(data);
$.each(obj,function(k,v){
//console.log(k + "= Cash: " + v.cash + " Check: " + v.check + " Credit: " + v.credit + "\n");
$("#" + k + "_cash span").text("$" + v.cash);
$("#" + k + "_check span").text("$" + v.check);
$("#" + k + "_credit span").text("$" + v.credit);
});
});
$.ajaxSetup({async:true});
});
// Deposit Calculator
if ( $(".paid").length ) { // any transactions?
var deposit = {};
$(".deposit input").each(function(count){
deposit[count] = this.name;
});
$.post("json/transaction.php",{"deposit": deposit});
$.post("json/transaction.php",{"deposit": deposit}, function(data) {
var obj = $.parseJSON(data);
$.each(obj,function(k,v){
//console.log(k + "= Cash: " + v.cash + " Check: " + v.check + " Credit: " + v.credit + "\n");
$("#" + k + "_cash span").text("$" + v.cash);
$("#" + k + "_check span").text("$" + v.check);
$("#" + k + "_credit span").text("$" + v.credit);
});
});
}