mirror of
https://github.com/fspc/Yellow-Bike-Database.git
synced 2025-02-22 08:53:23 -05:00
Improves user input and output for Deposit Calculator.
This commit is contained in:
parent
d40dfca931
commit
a94d62c78b
@ -41,6 +41,15 @@ $(function() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// null or real number
|
||||||
|
function payment_result(result) {
|
||||||
|
if (result == null) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return Number(result).toFixed(2);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Deposit Calculator function
|
// Deposit Calculator function
|
||||||
function deposit_calculator() {
|
function deposit_calculator() {
|
||||||
|
|
||||||
@ -52,12 +61,29 @@ $(function() {
|
|||||||
$.post("json/transaction.php",{"deposit": deposit}, function(data) {
|
$.post("json/transaction.php",{"deposit": deposit}, function(data) {
|
||||||
var obj = $.parseJSON(data);
|
var obj = $.parseJSON(data);
|
||||||
$.each(obj,function(k,v){
|
$.each(obj,function(k,v){
|
||||||
//console.log(k + "= Cash: " + v.cash + " Check: " + v.check + " Credit: " + v.credit + "\n");
|
|
||||||
$("#" + k + "_cash span").text("$" + v.cash);
|
// Cash / Check / Credit
|
||||||
$("#" + k + "_check span").text("$" + v.check);
|
$("#" + k + "_cash span").text("$" + payment_result(v.cash));
|
||||||
$("#" + k + "_credit span").text("$" + v.credit);
|
$("#" + k + "_check span").text("$" + payment_result(v.check));
|
||||||
|
$("#" + k + "_credit span").text("$" + payment_result(v.credit));
|
||||||
|
|
||||||
|
// Sum
|
||||||
var sum = Number(v.check) + Number(v.cash);
|
var sum = Number(v.check) + Number(v.cash);
|
||||||
$("#" + k + "_sum span").text("$" + sum);
|
$("#" + k + "_sum span").text("$" + sum.toFixed(2));
|
||||||
|
|
||||||
|
// Difference
|
||||||
|
var deposit_amount = $('input[name="' + k + '"]').parent().prev().prev().text().replace(/\$(\d*\.\d*)\s+/, "$1" );
|
||||||
|
if (deposit_amount != 0) {
|
||||||
|
var diff = deposit_amount - sum;
|
||||||
|
$("#" + k + "_difference span").text("$"+ diff.toFixed(2));
|
||||||
|
if ( diff == 0 ) {
|
||||||
|
$("#" + k + "_difference").css("color","green");
|
||||||
|
} else {
|
||||||
|
$("#" + k + "_difference").css("color","red");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$("#" + k + "_difference span").text("n/a");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -84,6 +110,7 @@ $(function() {
|
|||||||
|
|
||||||
// require that values be filled in a particular fashion
|
// require that values be filled in a particular fashion
|
||||||
$("#date").mask("0000-00-00");
|
$("#date").mask("0000-00-00");
|
||||||
|
$("#amount").mask("#0.00", {reverse: true});
|
||||||
|
|
||||||
$transaction_id = $("input[name='transaction_id']").val();
|
$transaction_id = $("input[name='transaction_id']").val();
|
||||||
|
|
||||||
|
@ -60,6 +60,7 @@ if($_GET['trans_type']=='all_types'){
|
|||||||
$trans_type = '';
|
$trans_type = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//record_count
|
//record_count
|
||||||
if($_GET['record_count']>0){
|
if($_GET['record_count']>0){
|
||||||
$record_count = $_GET['record_count'];
|
$record_count = $_GET['record_count'];
|
||||||
@ -67,6 +68,7 @@ if($_GET['record_count']>0){
|
|||||||
$record_count = $number_of_transactions;
|
$record_count = $number_of_transactions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// This is the recordset for the list of logged transactions
|
// This is the recordset for the list of logged transactions
|
||||||
|
|
||||||
|
|
||||||
@ -86,7 +88,14 @@ $Recordset1 = mysql_query($query_Recordset1, $YBDB) or die(mysql_error());
|
|||||||
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
|
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
|
||||||
|
|
||||||
//Action on form update
|
//Action on form update
|
||||||
$editFormAction = $_SERVER['PHP_SELF'];
|
|
||||||
|
if (isset($_GET[record_count])) {
|
||||||
|
$editFormAction = $_SERVER['PHP_SELF'];
|
||||||
|
} else {
|
||||||
|
$editFormAction = $_SERVER['PHP_SELF'];
|
||||||
|
}
|
||||||
|
|
||||||
|
//$editFormAction = $_SERVER['PHP_SELF'];
|
||||||
|
|
||||||
//Form Submit New Transaction===================================================================
|
//Form Submit New Transaction===================================================================
|
||||||
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "FormNew")) {
|
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "FormNew")) {
|
||||||
@ -167,7 +176,7 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "FormEdit") && ($_PO
|
|||||||
|
|
||||||
|
|
||||||
$trans_id = $_POST['transaction_id'];
|
$trans_id = $_POST['transaction_id'];
|
||||||
header(sprintf("Location: %s",$editFormAction . "?trans_id={$trans_id}" )); //$editFormAction
|
header(sprintf("Location: %s",$editFormAction . "?trans_id={$trans_id}&record_count=$record_count")); //$editFormAction
|
||||||
}
|
}
|
||||||
|
|
||||||
//Form Edit Record Delete ===============================================================================
|
//Form Edit Record Delete ===============================================================================
|
||||||
@ -203,7 +212,7 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {
|
|||||||
|
|
||||||
<?php include("include_header.html"); ?>
|
<?php include("include_header.html"); ?>
|
||||||
|
|
||||||
<input type="hidden" name="cancel_return" value="http://positivespin.org/ybdb/transaction_log.php?error=transactioncanceled" />
|
<input type="hidden" name="cancel_return" value="transaction_log.php?error=transactioncanceled" />
|
||||||
<table border="0" cellpadding="1" cellspacing="0">
|
<table border="0" cellpadding="1" cellspacing="0">
|
||||||
<tr>
|
<tr>
|
||||||
<td align="left" valign="bottom"><?php echo $error_message ?> </td>
|
<td align="left" valign="bottom"><?php echo $error_message ?> </td>
|
||||||
@ -279,7 +288,7 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr><td> </td>
|
<tr><td> </td>
|
||||||
<td><label>ShopID:</label> </td>
|
<td><label>ShopID:</label> </td>
|
||||||
<td><input name="shop_id" type="text" id="amount" value="<?php echo $row_Recordset2['shop_id']; ?>" size="6" /></td>
|
<td><input name="shop_id" type="text" id="shop_id" value="<?php echo $row_Recordset2['shop_id']; ?>" size="6" /></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php ?>
|
<?php ?>
|
||||||
<tr><td> </td><td><label>Select Type:</label></td>
|
<tr><td> </td><td><label>Select Type:</label></td>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user