Browse Source

Several improvements:

1.  Now uses better function, CurrentShopUser for signed-in users so that people need to be signed in to make purchases.
2.  Improved header text for Contacts.
3.  Removed edit link when paid checked.
4.  Fixed populate.sql
5.  Added payment type column in transaction_log.php
devel
Jonathan Rosenbaum 10 years ago
parent
commit
f6d392b0b5
  1. 4
      Connections/database_functions.php
  2. 2
      include_header.html
  3. 44
      js/transaction.js
  4. 41
      json/transaction.php
  5. 12
      sql/populate.sql
  6. 31
      transaction_log.php

4
Connections/database_functions.php

@ -40,7 +40,7 @@ define("TIMEZONE", "America/New_York");
define("NONSHOP",0); define("NONSHOP",0);
// How many transactions do you want shown // How many transactions do you want shown
define("NUMBER_OF_TRANSACTIONS", 50); define("NUMBER_OF_TRANSACTIONS", 11);
//constants //constants
define("PAGE_START_SHOP", "/start_shop.php"); define("PAGE_START_SHOP", "/start_shop.php");
@ -375,7 +375,7 @@ function list_contacts_select_user($form_name = "contact_id", $default_value = "
function list_CurrentShopUsers_select($form_name = "contact_id", $default_value = "") function list_CurrentShopUsers_select($form_name = "contact_id", $default_value = "")
{ {
echo "<select name={$form_name} class='yb_standard'>\n"; echo "<select name={$form_name} class='yb_standard'>\n";
echo "<option value='no_selection'>Select User</option>\n"; echo "<option value='no_selection'>Select Patron</option>\n";
echo "<option value='no_selection'>--------------</option>"; echo "<option value='no_selection'>--------------</option>";
list_CurrentShopUsers("none",$default_value); list_CurrentShopUsers("none",$default_value);
echo "</select>\n"; echo "</select>\n";

2
include_header.html

@ -34,7 +34,7 @@ function resetTimer()
<body class="yb_standard"> <body class="yb_standard">
<table align="center" width="1000" border="0" cellpadding="1" cellspacing="0"> <table align="center" width="1000" border="0" cellpadding="1" cellspacing="0">
<tr valign="top"> <tr valign="top">
<td height="40" align="right"><a href="/shop_log.php">Current Shop</a> | <a href="/start_shop.php"> All Shops</a> | <a href="/contact_add_edit_select.php">Edit Contact Info</a> | <a href="/stats.php">Statistics</a> | <a href="/transaction_log.php">Transaction Log</a> | <a href="http://www.positivespin.org/home2/" target="_blank">PS Home</a></td> <td height="40" align="right"><a href="/shop_log.php">Current Shop</a> | <a href="/start_shop.php"> All Shops</a> | <a href="/contact_add_edit_select.php">Add/Edit Contact</a> | <a href="/stats.php">Statistics</a> | <a href="/transaction_log.php">Transaction Log</a> | <a href="http://www.positivespin.org/home2/" target="_blank">PS Home</a></td>
</tr> </tr>
<tr> <tr>
<td> <td>

44
js/transaction.js

@ -4,50 +4,42 @@
$(function() { $(function() {
$("select[name='transaction_type']").attr("tabindex",1);
$("select[name='transaction_type']").focus();
$("input[value='Create Transaction']").attr("tabindex",2);
// paid or not? // paid or not?
$(":checked").parent("td").prev().children().hide();
$(".paid").click(function() { $(".paid").click(function() {
if ($(this).prop("checked")) { if ($(this).prop("checked")) {
$(this).closest("tr").css("background-color","#E6E7E6"); $(this).closest("tr").css("background-color","#E6E7E6");
$('[href$="' + this.name + '"]').hide();
console.log(this.name);
$.post("json/transaction.php",{ paid: 1, transaction_id: this.name } ); $.post("json/transaction.php",{ paid: 1, transaction_id: this.name } );
} }
else { else {
$(this).closest("tr").css("background-color","transparent"); $(this).closest("tr").css("background-color","transparent");
$('[href$="' + this.name + '"]').show();
$.post("json/transaction.php",{ paid: 0, transaction_id: this.name } ); $.post("json/transaction.php",{ paid: 0, transaction_id: this.name } );
} }
}); });
// Deposit Calculator // Deposit Calculator
if ( $(".paid").length ) { // any transactions? if ( $(".paid").length ) { // any transactions?
var deposit_length = $(".deposit").length;
if ( deposit_length && deposit_length == 1 ) { // one transaction - maybe can do 1 or more with a sort $(".deposit input").each(function(){ console.log(this.name);});
$(".paid").each( function() { var deposit_length = $(".deposit").length;
if ( deposit_length == 1 ) { // one visible deposit could be 1 or more invisible
if (this.value == 1) { /* Calculate using only the transactions that have been checked
as paid before the deposit
*/
var deposit_number = $(".deposit input").attr("name");
if ( this.name < deposit_number ) { // use database at this point
// find out the Payment Type
console.log(this.name)
}
}
});
var deposit_number = $(".deposit input").attr("name");
//console.log(deposit_number);
} }
else if ( deposit_length && deposit_length > 1) { /* more than one transaction
use a range of deposits closest to visible transactions
*/
//console.log("greater than one deposit");
}
} }
// editing a transaction // editing a transaction
if ( $("input[name='shop_id']").length ) { if ( $("input[name='shop_id']").length ) {

41
json/transaction.php

@ -29,4 +29,45 @@ mysql_select_db($database_YBDB, $YBDB);
} }
/*
transaction_id, date_startstorage, date,transaction_type, amount, description, sold_to, sold_by, quantity, shop_id, paid
Always do transactions from the first visible Deposit to the next Deposit.
Variations:
Based on the results of ..
SELECT COUNT(transaction_type) FROM transaction_log WHERE transaction_type="Deposit";
However, if there are no invisible deposits go to the end from the last visible deposit, so do a comparison with
visible deposits, to find out if there is 1 unique non-visible deposit.
COUNT == 1
1. Just beginning to use YBDB: Calculation for 1 visible Deposit all the way to the first existing transaction
SELECT SUM(IF(payment_type="check", amount, 0.00)) AS "Check",
SUM(IF(payment_type="credit", amount, 0.00)) AS "Credit",
SUM(IF(payment_type="cash", amount, 0.00)) AS "Cash"
FROM transaction_log WHERE paid=1 AND transaction_id < 74;
(return sum)
COUNT > 1
2. Calculation for 1 or more visible Deposits to next non-visible Deposit or no non-visible Deposit
If no hidden, loop for visible deposits (#2)) ($v) with last one to end (#1 logic, except use $v variable); else;
loop for visible deposits to the next hidden deposit (#2).
foreach ( my $v in @visible_deposits ) {
SELECT SUM(IF(payment_type="check", amount, 0.00)) AS "Check",
SUM(IF(payment_type="credit", amount, 0.00)) AS "Credit",
SUM(IF(payment_type="cash", amount, 0.00)) AS "Cash"
FROM transaction_log WHERE paid=1 AND transaction_id < $v AND transaction_id >
(SELECT transaction_id FROM transaction_log WHERE transaction_type="Deposit" ORDER BY transaction_id LIMIT 1);
push @sum, answer;
}
*/
?> ?>

12
sql/populate.sql

@ -40,7 +40,8 @@ INSERT INTO shop_user_roles (
("Volunteer",0,1,0,0), ("Volunteer",0,1,0,0),
("Greeter",0,0,1,0), ("Greeter",0,0,1,0),
("Staff",0,0,1,1), ("Staff",0,0,1,1),
("Student Volunteer",0,0,0,0); ("Student Volunteer",0,0,0,0),
("Shopping",0,0,0,0);
-- Add some projects to projects -- Add some projects to projects
@ -73,7 +74,8 @@ INSERT INTO contacts (
-- Set-up transaction types -- Set-up transaction types
-- This is object orienteed like :) -- This is object orienteed like :)
-- --
-- SILLY TEXT FIELDS (some presentation logic that is in the business logic, rather than kept cleanly separated from it) -- TEXT FIELDS (some presentation logic that is in the business logic, rather than kept cleanly separated from it)
-- Although, there are some advantages to this approach.
-- NOTE - (:colon is appended by default:) -- NOTE - (:colon is appended by default:)
-- --
-- fieldname_date: text field for the day the transaction transpires, e.g. "Sale Date" -- fieldname_date: text field for the day the transaction transpires, e.g. "Sale Date"
@ -85,10 +87,10 @@ INSERT INTO contacts (
-- --
-- DISCUSSION ABOUT LOCATIONS in transaction_log.php -- DISCUSSION ABOUT LOCATIONS in transaction_log.php
-- show_soldto_location is now used to show patrons. The history of this name is -- show_soldto_location is now used to show patrons. The history of this name is
-- that YBP was using it to keep track of donations and locations. However, there is an -- that YBP was using it to keep track of donation locations. However, there is an
-- option in transaction_log.php that would show current shop users that was -- option in transaction_log.php that would show current shop users that was
-- commented out, but never developed to work. -- commented out. Not sure what the usefullness of location_add_edit_select.php is yet.
-- More than 1 shop with its own accounting? Run a different instance of YBDB. -- With that thought, need more than 1 shop with its own accounting? Run a different instance of YBDB.
-- --
-- USELESS or RESERVED FIELDS -- USELESS or RESERVED FIELDS
-- show_soldto and show_soldby currently do not do anything, -- show_soldto and show_soldby currently do not do anything,

31
transaction_log.php

@ -210,13 +210,13 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {
<td> <td>
<table border="1" cellpadding="1" cellspacing="0" bordercolor="#CCCCCC"> <table border="1" cellpadding="1" cellspacing="0" bordercolor="#CCCCCC">
<tr bordercolor="#CCCCCC" bgcolor="#99CC33"> <tr bordercolor="#CCCCCC" bgcolor="#99CC33">
<td colspan="8" bgcolor="#99CC33"><div align="center"><strong>Bike and Sale Log </strong></div></td> <td colspan="9" bgcolor="#99CC33"><div align="center"><strong>Bike and Sale Log </strong></div></td>
</tr> </tr>
<?php // show delete tranaction confirmation ========================================= <?php // show delete tranaction confirmation =========================================
if($delete_trans_id <> -1 ) { ?> if($delete_trans_id <> -1 ) { ?>
<form method="post" name="FormConfirmDelete" action="<?php echo $editFormAction; ?>"> <form method="post" name="FormConfirmDelete" action="<?php echo $editFormAction; ?>">
<tr bordercolor="#CCCCCC" bgcolor="#CCCC33"> <tr bordercolor="#CCCCCC" bgcolor="#CCCC33">
<td colspan="8"><p><strong>Edit Transaction: <td colspan="9"><p><strong>Edit Transaction:
<input type="submit" name="DeleteConfirm" value="Confirm Delete" /> <input type="submit" name="DeleteConfirm" value="Confirm Delete" />
<input type="submit" name="DeleteConfirm" value="Cancel" /> <input type="submit" name="DeleteConfirm" value="Cancel" />
<input type="hidden" name="delete_trans_id" value="<?php echo $delete_trans_id; ?>"> <input type="hidden" name="delete_trans_id" value="<?php echo $delete_trans_id; ?>">
@ -256,7 +256,7 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {
<tr bgcolor="#CCCC33"> <tr bgcolor="#CCCC33">
<!-- the column for the edit transactions form --> <!-- the column for the edit transactions form -->
<td colspan="7"> <td colspan="8">
<form method="post" name="FormEdit" action="<?php echo $editFormAction; ?>"> <form method="post" name="FormEdit" action="<?php echo $editFormAction; ?>">
<table border="0" cellspacing="0" cellpadding="1"> <table border="0" cellspacing="0" cellpadding="1">
@ -359,8 +359,9 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {
<tr><td>&nbsp;</td> <tr><td>&nbsp;</td>
<td><label><?php echo $row_Recordset3['fieldname_soldto']; ?>:</label></td> <td><label><?php echo $row_Recordset3['fieldname_soldto']; ?>:</label></td>
<td><?php <td><?php
if($row_Recordset3['show_soldto_location']){ if($row_Recordset3['show_soldto_location']){
list_donation_locations_withheader('sold_to', $row_Recordset2['sold_to']); // list_donation_locations_withheader('sold_to', $row_Recordset2['sold_to']);
list_CurrentShopUsers_select('sold_to', $row_Recordset2['sold_to']);
$record_trans_id = $row_Recordset2['transaction_id']; $record_trans_id = $row_Recordset2['transaction_id'];
// echo " <a href=\"location_add_edit.php?trans_id={$record_trans_id}&contact_id=new_contact\">Create New Location</a> | <a href=\"location_add_edit_select.php?trans_id={$record_trans_id}&contact_id=new_contact\">Edit Existing Location</a>"; // echo " <a href=\"location_add_edit.php?trans_id={$record_trans_id}&contact_id=new_contact\">Create New Location</a> | <a href=\"location_add_edit_select.php?trans_id={$record_trans_id}&contact_id=new_contact\">Edit Existing Location</a>";
} else { } else {
@ -369,7 +370,8 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {
</tr> <?php } //end if show location row ?> </tr> <?php } //end if show location row ?>
<tr><td>&nbsp;</td> <tr><td>&nbsp;</td>
<td><label><?php echo $row_Recordset3['fieldname_soldby']; ?>:</label></td> <td><label><?php echo $row_Recordset3['fieldname_soldby']; ?>:</label></td>
<td><?php if(current_shop_by_ip()>0) list_current_coordinators_select('sold_by', $row_Recordset2['sold_by']); else list_contacts_coordinators('sold_by', $row_Recordset2['sold_by']); <td><?php if(current_shop_by_ip()>0) list_current_coordinators_select('sold_by', $row_Recordset2['sold_by']);
else list_contacts_coordinators('sold_by//,', $row_Recordset2['sold_by']);
//list_contacts_coordinators('sold_by', $row_Recordset2['sold_by']); //list_contacts_coordinators('sold_by', $row_Recordset2['sold_by']);
//list_current_coordinators_select('sold_by', $row_Recordset2['sold_by']); //list_current_coordinators_select('sold_by', $row_Recordset2['sold_by']);
?> ?>
@ -407,7 +409,7 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {
<form method="post" name="FormNew" action="<?php echo $editFormAction; ?>"> <form method="post" name="FormNew" action="<?php echo $editFormAction; ?>">
<tr bordercolor="#CCCCCC" bgcolor="#CCCC33"> <tr bordercolor="#CCCCCC" bgcolor="#CCCC33">
<td colspan="8"><p><strong>Start New Transaction:</strong><br />&nbsp;&nbsp;&nbsp;&nbsp;Select Type: <?php list_transaction_types('transaction_type',$default_transaction_type); ?> <td colspan="9"><p><strong>Start New Transaction:</strong><br />&nbsp;&nbsp;&nbsp;&nbsp;Select Type: <?php list_transaction_types('transaction_type',$default_transaction_type); ?>
<input type="submit" name="Submit43" value="Create Transaction" /> <input type="submit" name="Submit43" value="Create Transaction" />
</p> </td> </p> </td>
</tr> </tr>
@ -418,9 +420,10 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {
<td width="50"><strong>Shop</strong></td> <td width="50"><strong>Shop</strong></td>
<td width="100"><strong>Date</strong></td> <td width="100"><strong>Date</strong></td>
<td width="200" bgcolor="#99CC33"><strong>Sale Type </strong></td> <td width="200" bgcolor="#99CC33"><strong>Sale Type </strong></td>
<td width="70"><strong>Amount</strong></td>
<td width="300"><strong>Description</strong></td>
<td><strong>Patron</strong></td> <td><strong>Patron</strong></td>
<td width="300"><strong>Description</strong></td>
<td><strong>Type</strong></td>
<td width="70"><strong>Amount</strong></td>
<td width="50"><strong>Edit </strong></td> <td width="50"><strong>Edit </strong></td>
<td><strong>Paid</strong></td> <td><strong>Paid</strong></td>
</tr> </tr>
@ -436,10 +439,12 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {
<td><?php echo $row_Recordset1['shop_id']; ?></td> <td><?php echo $row_Recordset1['shop_id']; ?></td>
<td><?php echo $row_Recordset1['date_wday']; ?></td> <td><?php echo $row_Recordset1['date_wday']; ?></td>
<td><?php echo $row_Recordset1['transaction_type']; ?></td> <td><?php echo $row_Recordset1['transaction_type']; ?></td>
<td><?php echo $row_Recordset1['format_amount']; ?>&nbsp;</td> <td><?php echo $row_Recordset1['full_name']; ?>&nbsp;</td>
<td><?php echo $row_Recordset1['description_with_locations']; ?>&nbsp;</td> <td><?php echo $row_Recordset1['description_with_locations']; ?>&nbsp;</td>
<td><?php echo $row_Recordset1['full_name']; ?></td> <td><?php echo $row_Recordset1['payment_type']; ?>&nbsp;</td>
<td><?php $record_trans_id = $row_Recordset1['transaction_id']; echo "<a href=\"{$_SERVER['PHP_SELF']}?trans_id={$record_trans_id}\">edit</a>"; ?></td> <td><?php echo $row_Recordset1['format_amount']; ?>&nbsp;</td>
<td><?php $record_trans_id = $row_Recordset1['transaction_id'];
echo "<a href=\"{$_SERVER['PHP_SELF']}?trans_id={$record_trans_id}\">edit</a>"; ?></td>
<td><input class="paid" type="checkbox" name="<?php $ti = $row_Recordset1['transaction_id']; echo $ti; ?>" <td><input class="paid" type="checkbox" name="<?php $ti = $row_Recordset1['transaction_id']; echo $ti; ?>"
value="<?php echo $row_Recordset1['paid'];?>" value="<?php echo $row_Recordset1['paid'];?>"
<?php if ($row_Recordset1['paid'] == 1) { echo " checked"; } ?> <?php if ($row_Recordset1['paid'] == 1) { echo " checked"; } ?>
@ -449,7 +454,7 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {
</tr> </tr>
<?php <?php
if ($row_Recordset1['transaction_type'] == "Deposit") { if ($row_Recordset1['transaction_type'] == "Deposit") {
echo "<tr class='deposit_calculator'><td colspan='8'><div style='text-align:right;'>"; echo "<tr class='deposit_calculator'><td colspan='9'><div style='text-align:right;'>";
echo '<span style="padding-left:10px; padding-right:10px;" id="' . $ti . '_change">Change Fund:' . " $$change_fund" . ' <span></span></span>| echo '<span style="padding-left:10px; padding-right:10px;" id="' . $ti . '_change">Change Fund:' . " $$change_fund" . ' <span></span></span>|
<span style="padding-left:10px; padding-right:10px;" id="' . $ti . '_credit">Credit Card: <span></span></span>| <span style="padding-left:10px; padding-right:10px;" id="' . $ti . '_credit">Credit Card: <span></span></span>|
<span style="padding-left:10px; padding-right:10px;" id="' . $ti . '_check">Check: <span></span></span>+ <span style="padding-left:10px; padding-right:10px;" id="' . $ti . '_check">Check: <span></span></span>+

Loading…
Cancel
Save