Browse Source

Show start storage original date if it has changed.

1).  Some css improvments.
2).  The beginnings of transaction history.
3).  Trying to find out why the window reloads twice on transactions without errors.
devel
Jonathan Rosenbaum 9 years ago
parent
commit
be43ea3245
  1. 4
      css/transactions.css
  2. 2
      include_header.html
  3. 65
      js/transaction.js
  4. 10
      json/transaction.php
  5. 3
      transaction_log.php

4
css/transactions.css

@ -68,11 +68,11 @@ input[value=Save]:focus, input[value=Close]:focus {
}
/* errors */
#current_shop, #date_error,
#current_shop > a, #date_error,
#transaction_start_error,
#sold_by_error, #sold_to_error,
#description_error, #check_number_error,
#payment_error, #payment_type_error,
#quantity_error, #anonymous_error {
color: red;
color: red;
}

2
include_header.html

@ -22,10 +22,10 @@ function resetTimer()
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>YBDB</title>
<link href="css/transactions.css" rel="stylesheet" type="text/css" />
<link href="css/css_yb_standard.css" rel="stylesheet" type="text/css" />
<link href="css/jquery.nouislider.css" rel="stylesheet" type="text/css" />
<link href="css/chosen.css" rel="stylesheet" type="text/css" />
<link href="css/transactions.css" rel="stylesheet" type="text/css" />
<script src="js/jquery-2.1.1.js"></script>
<script src="js/transaction.js"></script>

65
js/transaction.js

@ -4,10 +4,10 @@
$(function() {
$.ajaxSetup({async:false}); // best to do this in $.ajax,
// but all ajax needs to be synchronous in this program because of the use of mysql
$("#transaction_type").attr("tabindex",1);
$("#transaction_type").focus();
$("input[value='Create Transaction']").attr("tabindex",2);
@ -17,7 +17,7 @@ $(function() {
// use .paid parent and hover & classes
// If page has not been reloaded after a shop period ends, prevent edit from working.
// Note: create transaction covered via a mysql_error()), but with a reload.
// Note: create transaction covered via a mysql_error()), but with a reload - header("Refresh:0;")
$('[href*="trans_id="]').click(function(e){
var remember_me;
$.post("json/transaction.php", {shop_exist: 1}, function(data) {
@ -50,11 +50,11 @@ $(function() {
}
});
if (remember_me == "unbind") {
$('#save_transaction').on('click');
}
else {
$('#save_transaction').on('click');
}
else {
e.preventDefault();
}
}
} );
// Does a current shop exist?
@ -448,7 +448,6 @@ $(function() {
$("select[name='sold_by']").attr("tabindex",11);
$("input[value='Save']").attr("tabindex",12);
$("input[value='Close']").attr("tabindex",13);
// common ids
var transaction_id = $("input[name='transaction_id']").val();
@ -551,6 +550,26 @@ $(function() {
} else {
transaction_error.hide();
}
// store the transaction's history
var transaction_history = {
transaction_id: $("input[name='transaction_id']").val(),
date_startstorage: $("#date_startstorage").val(),
date: $("#date").val(),
transaction_type: $("#transaction_type").val(),
amount: $("#amount").val(),
description: $("#description").val(),
sold_to: $("#sold_to").val(),
sold_by: $("[name='sold_by']").val(),
quantity: $("#quantity").val(),
shop_id: $("#shop_id").val(),
payment_type: $("#payment_type").val(),
check_number: $("#check_number").val(),
anonymous: $("#anonymous").val()
};
console.dir(transaction_history);
});
// error handler for edited transactions
@ -568,9 +587,11 @@ $(function() {
}
if (trans_error) {
event.preventDefault();
event.preventDefault();
}
return trans_error;
return trans_error;
}
@ -581,7 +602,7 @@ $(function() {
if (obj.sold_to) {
var obj = $.parseJSON(data);
sold_to.replaceWith("<span name='sold_to'>" + obj.full_name +
"</span><input value='" + obj.sold_to + "' type='hidden' name='sold_to'>");
"</span><input value='" + obj.sold_to + "' type='hidden' id='sold_to' name='sold_to'>");
}
} );
}
@ -635,6 +656,16 @@ $(function() {
when a full date (yyyy-mm-dd) is entered. */
if ( $("#date_startstorage").length ) {
var date_startstorage = $("#date_startstorage").val();
// If storage start date has changed since original shop trans, show the original shop day.
$.post("json/transaction.php",{date_startstorage: date_startstorage,
transaction_id: $("input[name='transaction_id']").val() }, function(data) {
if (data) {
$("#original_shop_date").html("(transaction date: " + data + ")");
}
});
// require that values be filled in a particular fashion
$("#date_startstorage").mask("0000-00-00", {placeholder: "yyyy-mm-dd" });
@ -690,20 +721,12 @@ $(function() {
// If storage date is NULL, update to 0000-00-00 on save
$("#save_transaction").click(function(e) {
/*
var span_or_select = $("[name='sold_to']").is("span"), err0;
if(span_or_select) {
err0 = error_handler(span_or_select, date_error, true, "*Patron must be signed in to complete this transaction.",e);
}
*/
if ( !$("#date").val().length ) {
//if (err0 != 1) {
$("#date").val("0000-00-00");
//}
$("#date").val("0000-00-00");
}
});
} // end testing for storage presentation

10
json/transaction.php

@ -89,6 +89,16 @@ $change_fund = CHANGE_FUND;
}
}
// check if start storage date has been changed since original shop date
if(isset($_POST['date_startstorage'])) {
$query = 'SELECT shops.date FROM transaction_log, shops WHERE transaction_id=' . $_POST['transaction_id'] .
' AND transaction_log.shop_id = shops.shop_id;';
$sql = mysql_query($query, $YBDB) or die(mysql_error());
$result = mysql_fetch_assoc($sql);
if ($result['date'] != $_POST['date_startstorage']) {
echo $result['date'];
}
}
// reset payment_type && amount for storage transaction
if(isset($_POST['storage_payment_reset'])) {

3
transaction_log.php

@ -286,6 +286,7 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "FormEdit") && ($_PO
$trans_id = $transaction_id;
header(sprintf("Location: %s",$editFormAction . "?trans_id={$trans_id}&" . $search_state)); //$editFormAction
}
//Form Edit Record Delete ===============================================================================
@ -441,7 +442,7 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {
<td for="date_startstorage"><label>Storage Start Date:</label></td>
<td><input name="date_startstorage" type="text" id="date_startstorage" value="<?php
echo $row_Recordset2['date_startstorage_day']; ?>" size="10" maxlength="10" />
</td>
<span id="original_shop_date"></span></td>
</tr>
<?php } //end if storage | start of date ================================================
?>

Loading…
Cancel
Save