mirror of
https://github.com/fspc/Yellow-Bike-Database.git
synced 2025-02-22 00:53:22 -05:00
Added some human interaction with Deposit Calculator.
This commit is contained in:
parent
890b8f1b15
commit
511dc81471
@ -11,11 +11,13 @@ $(function() {
|
|||||||
// paid or not?
|
// paid or not?
|
||||||
$(":checked").parent("td").prev().children().hide();
|
$(":checked").parent("td").prev().children().hide();
|
||||||
$(".paid").click(function() {
|
$(".paid").click(function() {
|
||||||
|
|
||||||
|
$.ajaxSetup({async:false});
|
||||||
|
|
||||||
if ($(this).prop("checked")) {
|
if ($(this).prop("checked")) {
|
||||||
|
|
||||||
$(this).closest("tr").css("background-color","#E6E7E6");
|
$(this).closest("tr").css("background-color","#E6E7E6");
|
||||||
$('[href*="' + this.name + '"]').hide();
|
$('[href*="' + this.name + '"]').hide();
|
||||||
console.log(this.name);
|
|
||||||
$.post("json/transaction.php",{ paid: 1, transaction_id: this.name } );
|
$.post("json/transaction.php",{ paid: 1, transaction_id: this.name } );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -24,17 +26,44 @@ $(function() {
|
|||||||
$('[href*="' + this.name + '"]').show();
|
$('[href*="' + this.name + '"]').show();
|
||||||
$.post("json/transaction.php",{ paid: 0, transaction_id: this.name } );
|
$.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
|
// Deposit Calculator
|
||||||
if ( $(".paid").length ) { // any transactions?
|
if ( $(".paid").length ) { // any transactions?
|
||||||
|
|
||||||
var deposit = {};
|
var deposit = {};
|
||||||
$(".deposit input").each(function(count){
|
$(".deposit input").each(function(count){
|
||||||
deposit[count] = this.name;
|
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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@ mysql_select_db($database_YBDB, $YBDB);
|
|||||||
. $deposit[$key + 1] . ';';
|
. $deposit[$key + 1] . ';';
|
||||||
$sql = mysql_query($query, $YBDB) or die(mysql_error());
|
$sql = mysql_query($query, $YBDB) or die(mysql_error());
|
||||||
$result = mysql_fetch_assoc($sql);
|
$result = mysql_fetch_assoc($sql);
|
||||||
|
$result_obj[$deposit[$key]] = $result;
|
||||||
} else {
|
} else {
|
||||||
$query = 'SELECT SUM(IF(payment_type="check", amount, 0)) AS "check",
|
$query = 'SELECT SUM(IF(payment_type="check", amount, 0)) AS "check",
|
||||||
SUM(IF(payment_type="credit", amount, 0)) AS "credit",
|
SUM(IF(payment_type="credit", amount, 0)) AS "credit",
|
||||||
@ -59,12 +60,12 @@ mysql_select_db($database_YBDB, $YBDB);
|
|||||||
FROM transaction_log WHERE paid=1 AND transaction_id <' . $deposit[$key] . ';';
|
FROM transaction_log WHERE paid=1 AND transaction_id <' . $deposit[$key] . ';';
|
||||||
$sql = mysql_query($query, $YBDB) or die(mysql_error());
|
$sql = mysql_query($query, $YBDB) or die(mysql_error());
|
||||||
$result = mysql_fetch_assoc($sql);
|
$result = mysql_fetch_assoc($sql);
|
||||||
|
$result_obj[$deposit[$key]] = $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo json_encode($result);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
echo json_encode($result_obj);
|
||||||
|
|
||||||
} else { // more deposits than visible
|
} else { // more deposits than visible
|
||||||
|
|
||||||
$limit = $visible_count + 1;
|
$limit = $visible_count + 1;
|
||||||
@ -86,10 +87,11 @@ mysql_select_db($database_YBDB, $YBDB);
|
|||||||
. $transaction_id[$key + 1] . ';';
|
. $transaction_id[$key + 1] . ';';
|
||||||
$sql = mysql_query($query, $YBDB) or die(mysql_error());
|
$sql = mysql_query($query, $YBDB) or die(mysql_error());
|
||||||
$result = mysql_fetch_assoc($sql);
|
$result = mysql_fetch_assoc($sql);
|
||||||
echo json_encode($result);
|
$result_obj[$transaction_id[$key]] = $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // foreach
|
} // foreach
|
||||||
|
echo json_encode($result_obj);
|
||||||
} // end else for invisibles
|
} // end else for invisibles
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user