Browse Source

Transaction history is now stored.

1).  Next step, view history in the transaction when more than 1 transaction.
devel
Jonathan Rosenbaum 10 years ago
parent
commit
e47498a00a
  1. 38
      js/transaction.js
  2. 19
      json/transaction.php

38
js/transaction.js

@ -456,7 +456,7 @@ $(function() {
// On save (or close) check for errors // On save (or close) check for errors
function save_or_close(button_choice) { function save_or_close(button_choice, type_of_button) {
//function error_handler(input,error_span,error,error_text,event) //function error_handler(input,error_span,error,error_text,event)
var err1 = 0, err2 = 0, err3 = 0, err4 = 0, err5 = 0, err6 = 0, err7 = 0, err8 = 0; var err1 = 0, err2 = 0, err3 = 0, err4 = 0, err5 = 0, err6 = 0, err7 = 0, err8 = 0;
@ -526,7 +526,11 @@ $(function() {
if ( !transaction_error.is(":visible") ) { if ( !transaction_error.is(":visible") ) {
transaction_error.show(); transaction_error.show();
} }
transaction_error.text("Correct errors below"); if (type_of_button === "Save") {
transaction_error.text("Correct errors below");
} else {
transaction_error.text("Correct errors below, and save before closing.");
}
} else { } else {
transaction_error.hide(); transaction_error.hide();
} }
@ -586,13 +590,16 @@ $(function() {
var check_number_error = $("#check_number_error"); var check_number_error = $("#check_number_error");
//var check_number = $("#check_number").on("input"); //var check_number = $("#check_number").on("input");
var result = save_or_close($("#save_transaction")); var result = save_or_close($("#save_transaction"), "Save");
save_or_close($("#close_transaction")); // kind of a trick // note: it is possible to close with all error conditions being satisfied,
// however, it is no biggy.
save_or_close($("#close_transaction"), "Close");
// Save history // Save history
if (result === "Success") { if (result === "Success") {
transaction_id = $("input[name='transaction_id']").val(); transaction_id = $("input[name='transaction_id']").val();
// store the transaction's history // store the transaction's history
var transaction_history = []; var transaction_history = [];
var current_transaction = var current_transaction =
@ -610,10 +617,25 @@ $(function() {
check_number: $("#check_number").val(), check_number: $("#check_number").val(),
anonymous: $("#anonymous").val() anonymous: $("#anonymous").val()
}; };
//transaction_history[transaction_id].push(current_transaction);
console.dir(current_transaction);
} // check for prior transactions
$.post("json/transaction.php",{ history_select: 1, transaction_id: transaction_id }, function(data) {
if (data === "First Transaction") {
console.log(data);
transaction_history.push(current_transaction);
} else {
transaction_history = $.parseJSON(data);
transaction_history.push(current_transaction);
//var obj = $.parseJSON(data);
}
} );
$.post("json/transaction.php",{ history_update: 1, transaction_id: transaction_id, history: transaction_history });
} // End Save History

19
json/transaction.php

@ -89,6 +89,25 @@ $change_fund = CHANGE_FUND;
} }
} }
if(isset($_POST['history_select'])) {
$query = 'SELECT history FROM transaction_log WHERE transaction_id="' . $_POST['transaction_id'] . '";';
$sql = mysql_query($query, $YBDB) or die(mysql_error());
$result = mysql_fetch_assoc($sql);
if ($result['history'] == "") {
echo "First Transaction";
} else {
echo $result['history'];
}
}
if(isset($_POST['history_update'])) {
$json = json_encode($_POST['history']);
$query = "UPDATE transaction_log SET history='$json'" .
' WHERE transaction_id="' . $_POST['transaction_id'] . '";';
$result = mysql_query($query, $YBDB) or die(mysql_error());
//echo ;
}
// check if start storage date has been changed since original shop date // check if start storage date has been changed since original shop date
if(isset($_POST['date_startstorage'])) { if(isset($_POST['date_startstorage'])) {
$query = 'SELECT shops.date FROM transaction_log, shops WHERE transaction_id=' . $_POST['transaction_id'] . $query = 'SELECT shops.date FROM transaction_log, shops WHERE transaction_id=' . $_POST['transaction_id'] .

Loading…
Cancel
Save