Browse Source

Added check number when Check is clicked.

devel
Jonathan Rosenbaum 9 years ago
parent
commit
7658c11d53
  1. 2
      css/transactions.css
  2. 46
      js/transaction.js
  3. 12
      json/transaction.php
  4. 2
      sql/populate.sql
  5. 48
      transaction_log.php

2
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;
}

46
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('&nbsp;&nbsp;<input type="text" id="check_number" size="10" name="check_number" >');
$("#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);

12
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
?>

2
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;

48
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")) {
<td>
<table border="1" cellpadding="1" cellspacing="0" bordercolor="#CCCCCC">
<tr bordercolor="#CCCCCC" bgcolor="#99CC33">
<td colspan="9" bgcolor="#99CC33"><div align="center"><strong>Bike and Sale Log </strong></div></td>
<td colspan="9" bgcolor="#99CC33"><div align="center"><strong>Bike, Sale and Donation Log</strong></div></td>
</tr>
<?php // show delete tranaction confirmation =========================================
if($delete_trans_id <> -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);
?>
<!-- The actual row for edit transactions -->
@ -287,7 +293,7 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {
<td><?php echo $row_Recordset2['transaction_id']; ?><em><?php echo $row_Recordset3['message_transaction_id']; ?></em></em></td>
</tr>
<tr><td>&nbsp;</td>
<td><label>ShopID:</label> </td>
<td><label for="shop_id">ShopID:</label> </td>
<td><input name="shop_id" type="text" id="shop_id" value="<?php echo $row_Recordset2['shop_id']; ?>" size="6" /></td>
</tr>
<?php ?>
@ -297,17 +303,17 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {
<?php //date_startstorage ==============================================================
if($row_Recordset3['show_startdate']){?>
<tr><td>&nbsp;</td>
<td><label>Storage Start Date:</label></td>
<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" />
(yyyy-mm-dd)</td>
</td>
</tr>
<?php } //end if storage | start of date ================================================
?>
<tr><td>&nbsp;</td>
<td><label><?php echo $row_Recordset3['fieldname_date']; ?>:</label></td>
<td><label for="date"><?php echo $row_Recordset3['fieldname_date']; ?>:</label></td>
<td><input name="date" type="text" id="date" value="<?php echo $row_Recordset2['date_day']; ?>" size="10" maxlength="10" />
(yyyy-mm-dd)
<SCRIPT>
function FillDate() {
document.FormEdit.date.value = '<?php echo current_date(); ?>' }
@ -332,10 +338,10 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {
if($row_Recordset3['community_bike']){ //community bike will allow a quantity to be selected for Yellow Bikes and Kids Bikes?>
<tr>
<td>&nbsp;</td>
<td valign="top"><label>Quantity:</label></td>
<td valign="top"><label for="quantity">Quantity:</label></td>
<td><input name="quantity" type="text" id="quantity" value="<?php echo $row_Recordset2['quantity']; ?>" size="3" maxlength="3" /></td>
</tr>
<?php } // end if show quanitiy for community bikes
<?php } // end if show quanitity for community bikes
if($row_Recordset3['show_description']){ ?>
<tr><td>&nbsp;</td>
<td valign="top"><label><?php echo $row_Recordset3['fieldname_description']; ?>:</label></td>
@ -359,11 +365,19 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {
<td><label>Payment Type:</label></td>
<td>
<input type="radio" name="payment_type" value="cash"
<?php if ($row_Recordset2['payment_type'] == "cash") { echo " checked"; } ?> >Cash
<?php if ($row_Recordset2['payment_type'] == "cash") { echo " checked"; } ?> >
<label id="cash" class="payment_type" for="payment_type">Cash</label>
<input type="radio" name="payment_type" value="credit"
<?php if ($row_Recordset2['payment_type'] == "credit") { echo " checked"; } ?> >Credit Card
<?php if ($row_Recordset2['payment_type'] == "credit") { echo " checked"; } ?> >
<label id="credit_card" class="payment_type" for="payment_type">Credit Card</label>
<input type="radio" name="payment_type" value="check"
<?php if ($row_Recordset2['payment_type'] == "check") { echo " checked"; } ?> >Check
<?php if ($row_Recordset2['payment_type'] == "check") { echo " checked"; } ?> >
<label id="check" class="payment_type" for="payment_type">Check</label>
<?php if ($row_Recordset2['payment_type'] == "check") {
echo '&nbsp;<input type="text" id="check_number" size="10" name="check_number" value="' .
$row_Recordset2['check_number'] . '".>';
}
?>
</td>
</tr>
<?php } ?>
@ -498,7 +512,7 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {
<td height="40" valign="bottom"><form id="form1" name="form1" method="post" action="">
<p><br />
Show
<input name="record_count" type="text" value="<?php echo $number_of_transactions; ?>" size="3" maxlength="3" />
<input name="record_count" type="text" value="<?php echo $number_of_transactions; ?>" size="3"
transactions on or before:
<input name="trans_date" type="text" id="trans_date" value="<?php echo current_date(); ?>" size="10" maxlength="10" />
(date format YYYY-MM-DD) Day of week:

Loading…
Cancel
Save