diff --git a/css/transactions.css b/css/transactions.css index 92ec5d5..d45f0e1 100644 --- a/css/transactions.css +++ b/css/transactions.css @@ -1,7 +1,7 @@ /* sensible UI defaults for transaction views */ /* right-align labels */ -td > label { +td > label:not(.payment_type) { float: right; padding-right: 5px; } diff --git a/js/transaction.js b/js/transaction.js index 4f7b798..71dea3a 100644 --- a/js/transaction.js +++ b/js/transaction.js @@ -20,7 +20,6 @@ $(function() { $(this).closest("tr").css("background-color","#E6E7E6"); $('[href*="trans_id=' + this.name + '"]').hide(); - $.post("json/transaction.php",{ paid: 1, transaction_id: this.name } ); } else { @@ -32,7 +31,7 @@ $(function() { // Deposit Calculator for clicks deposit_calculator(); - }); + }); // paid or not? // Deposit Calculator on page reload if ( $(".paid").length ) { // any transactions? @@ -88,7 +87,7 @@ $(function() { }); - } + } // Deposit Calculator // editing a transaction @@ -103,30 +102,55 @@ $(function() { $("textarea[name='description']").attr("tabindex",6); $("input[name='amount']").attr("tabindex",7); $("input[name='payment_type']").attr("tabindex",8); - $("select[name='sold_to']").attr("tabindex",9); - $("select[name='sold_by']").attr("tabindex",10); - $("input[value='Save']").attr("tabindex",11); - $("input[value='Close']").attr("tabindex",12); + $("#check_number").attr("tabindex",9); + $("select[name='sold_to']").attr("tabindex",10); + $("select[name='sold_by']").attr("tabindex",11); + $("input[value='Save']").attr("tabindex",12); + $("input[value='Close']").attr("tabindex",13); // require that values be filled in a particular fashion - $("#date").mask("0000-00-00"); - $("#amount").mask("#0.00", {reverse: true}); + $("#date").mask("0000-00-00", {placeholder: "yyyy-mm-dd" }); + $("#amount").mask("#0.00", {reverse: true, placeholder: "000.00"}); + $("#check_number").mask("#0", {reverse: true, placeholder: "check number"}); $transaction_id = $("input[name='transaction_id']").val(); + //var check_number = $("#check_number").on("input"); // what type of payment? cash, credit or check? $("input[name='payment_type']").click(function() { if ($(this).prop("checked")) { $.post("json/transaction.php",{ payment_type: this.value, transaction_id: $transaction_id } ); + + // check number? + if (this.value == "check") { + if ($("#check_number").length == 0) { + $("#check").after('  '); + $("#check_number").attr("tabindex",9); + } else { + $("#check_number").show(); + } + + // return check # + $.post("json/transaction.php",{ check_number: true, transaction_id: $transaction_id }, function(data) { + var obj = $.parseJSON(data); + if (obj.check_number) { + $("#check_number").val(obj.check_number); + } + }); + } else{ + $("#check_number").hide(); + } + } - }); + }); // what type of payment? + /* When the transaction is storage based, only show price and payment_type when a full date (yyyy-mm-dd) is entered. */ if ( $("#date_startstorage").length ) { // require that values be filled in a particular fashion - $("#date_startstorage").mask("0000-00-00"); + $("#date_startstorage").mask("0000-00-00", {placeholder: "yyyy-mm-dd" }); var date_value = $("#date").val(); var date_test = /^\d{4}-((0\d)|(1[012]))-(([012]\d)|3[01])$/.test(date_value); diff --git a/json/transaction.php b/json/transaction.php index 3230839..3852051 100644 --- a/json/transaction.php +++ b/json/transaction.php @@ -29,6 +29,16 @@ mysql_select_db($database_YBDB, $YBDB); } + // If payment_type check is selected - return check number if exists + if (isset($_POST['check_number'])) { + + $query = 'SELECT check_number FROM transaction_log WHERE transaction_id="' . $_POST['transaction_id'] . '";'; + $sql = mysql_query($query, $YBDB) or die(mysql_error()); + $result = mysql_fetch_assoc($sql); + echo json_encode($result); + + } + // Deposit Calculator if (isset($_POST['deposit'])) { @@ -95,6 +105,6 @@ mysql_select_db($database_YBDB, $YBDB); echo json_encode($result_obj); } // end else for invisibles - } + } // End Deposit Calculator ?> \ No newline at end of file diff --git a/sql/populate.sql b/sql/populate.sql index ed8f67d..20bb4cf 100644 --- a/sql/populate.sql +++ b/sql/populate.sql @@ -155,8 +155,10 @@ INSERT INTO transaction_types -- transaction_log - added paid or not -- - added payment_type (cash, check or cc) +-- - added check_number (Check#) -- transaction_id, date_startstorage, date,transaction_type, amount, -- description, sold_to, sold_by, quantity, shop_id, paid ALTER TABLE transaction_log ADD paid tinyint(1) NOT NULL DEFAULT '0'; ALTER TABLE transaction_log ADD payment_type varchar(6) DEFAULT NULL; +ALTER TABLE transaction_log ADD check_number int(10) unsigned DEFAULT NULL; diff --git a/transaction_log.php b/transaction_log.php index f16b45d..f067f28 100644 --- a/transaction_log.php +++ b/transaction_log.php @@ -148,7 +148,7 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "FormNew")) { //Form Edit Record =============================================================================== if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "FormEdit") && ($_POST["EditSubmit"] == "Save")) { - + //Error Correction & good place for jquery $sold_to = (($_POST['sold_to'] == 'no_selection') ? 1268 : $_POST['sold_to'] ); @@ -156,8 +156,13 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "FormEdit") && ($_PO $date_startstorage = date_update_wo_timestamp($_POST['date_startstorage'], $_POST['db_date_startstorage']); $date = date_update_wo_timestamp($_POST['date'], $_POST['db_date']); $description = (($_POST['description'] == "") ? "No Description" : $_POST['description'] ); + $check_number = (($_POST['check_number'] == "") ? "" : $_POST['check_number'] ); - $updateSQL = sprintf("UPDATE transaction_log SET transaction_type=%s, date_startstorage=%s, date=%s, amount=%s, quantity=%s, description=%s, sold_to=%s, sold_by=%s, shop_id=%s WHERE transaction_id=%s", + // keep the order + $updateSQL = sprintf("UPDATE transaction_log SET transaction_type=%s, date_startstorage=%s, + date=%s, amount=%s, quantity=%s, description=%s, + sold_to=%s, sold_by=%s, + shop_id=%s, check_number=%s WHERE transaction_id=%s", GetSQLValueString($_POST['transaction_type'], "text"), GetSQLValueString($date_startstorage, "date"), GetSQLValueString($date, "date"), @@ -167,14 +172,15 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "FormEdit") && ($_PO GetSQLValueString($sold_to, "int"), GetSQLValueString($sold_by, "int"), GetSQLValueString($_POST['shop_id'], "int"), - GetSQLValueString($_POST['transaction_id'], "int")); + GetSQLValueString($check_number, "text"), + GetSQLValueString($_POST['transaction_id'], "int") + ); //"2006-10-12 18:15:00" mysql_select_db($database_YBDB, $YBDB); $Result1 = mysql_query($updateSQL, $YBDB) or die(mysql_error()); - $trans_id = $_POST['transaction_id']; header(sprintf("Location: %s",$editFormAction . "?trans_id={$trans_id}&record_count=$record_count")); //$editFormAction } @@ -223,7 +229,7 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) { - + -1 ) { ?> @@ -262,7 +268,7 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) { $Recordset3 = mysql_query($query_Recordset3, $YBDB) or die(mysql_error()); $row_Recordset3 = mysql_fetch_assoc($Recordset3); $totalRows_Recordset3 = mysql_num_rows($Recordset3); - + ?> @@ -287,7 +293,7 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) { - + @@ -297,17 +303,17 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) { - + + - +
Bike and Sale Log
Bike, Sale and Donation Log
 
  - (yyyy-mm-dd)
  - (yyyy-mm-dd) +