diff --git a/Connections/database_functions.php b/Connections/database_functions.php index a1a6952..91e9611 100644 --- a/Connections/database_functions.php +++ b/Connections/database_functions.php @@ -40,7 +40,7 @@ define("TIMEZONE", "America/New_York"); define("NONSHOP",0); // How many transactions do you want shown -define("NUMBER_OF_TRANSACTIONS", 50); +define("NUMBER_OF_TRANSACTIONS", 11); //constants 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 = "") { echo "\n"; diff --git a/include_header.html b/include_header.html index c270ff7..7a8440d 100644 --- a/include_header.html +++ b/include_header.html @@ -34,7 +34,7 @@ function resetTimer() - +
Current Shop | All Shops | Edit Contact Info | Statistics | Transaction Log | PS HomeCurrent Shop | All Shops | Add/Edit Contact | Statistics | Transaction Log | PS Home
diff --git a/js/transaction.js b/js/transaction.js index ddc88f7..0e040a8 100644 --- a/js/transaction.js +++ b/js/transaction.js @@ -4,50 +4,42 @@ $(function() { + $("select[name='transaction_type']").attr("tabindex",1); + $("select[name='transaction_type']").focus(); + $("input[value='Create Transaction']").attr("tabindex",2); + // paid or not? + $(":checked").parent("td").prev().children().hide(); $(".paid").click(function() { 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 } ); } 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 } ); } }); // Deposit Calculator 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 - - $(".paid").each( function() { - - 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) - } - - } - - }); + $(".deposit input").each(function(){ console.log(this.name);}); + + var deposit_length = $(".deposit").length; + if ( deposit_length == 1 ) { // one visible deposit could be 1 or more invisible + 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 if ( $("input[name='shop_id']").length ) { diff --git a/json/transaction.php b/json/transaction.php index b7d5da9..2ea40c2 100644 --- a/json/transaction.php +++ b/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; + + } + + */ + ?> \ No newline at end of file diff --git a/sql/populate.sql b/sql/populate.sql index 7dffa27..ed8f67d 100644 --- a/sql/populate.sql +++ b/sql/populate.sql @@ -40,7 +40,8 @@ INSERT INTO shop_user_roles ( ("Volunteer",0,1,0,0), ("Greeter",0,0,1,0), ("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 @@ -73,7 +74,8 @@ INSERT INTO contacts ( -- Set-up transaction types -- 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:) -- -- 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 -- 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 --- commented out, but never developed to work. --- More than 1 shop with its own accounting? Run a different instance of YBDB. +-- commented out. Not sure what the usefullness of location_add_edit_select.php is yet. +-- With that thought, need more than 1 shop with its own accounting? Run a different instance of YBDB. -- -- USELESS or RESERVED FIELDS -- show_soldto and show_soldby currently do not do anything, diff --git a/transaction_log.php b/transaction_log.php index 62f5356..e1f1805 100644 --- a/transaction_log.php +++ b/transaction_log.php @@ -210,13 +210,13 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) { - + -1 ) { ?> - -
Bike and Sale Log
Bike and Sale Log

Edit Transaction: +

Edit Transaction: @@ -256,7 +256,7 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {

+ @@ -359,8 +359,9 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) { - - @@ -418,9 +420,10 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) { - - + + + @@ -436,10 +439,12 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) { - + - - + + +
  Create New Location | Edit Existing Location"; } else { @@ -369,7 +370,8 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {
  0) list_current_coordinators_select('sold_by', $row_Recordset2['sold_by']); else list_contacts_coordinators('sold_by', $row_Recordset2['sold_by']); + 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_current_coordinators_select('sold_by', $row_Recordset2['sold_by']); ?> @@ -407,7 +409,7 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {

Start New Transaction:
    Select Type: +

Start New Transaction:
    Select Type:

Shop Date Sale Type AmountDescription PatronDescriptionTypeAmount Edit Paid
    edit"; ?>  edit"; ?> @@ -449,7 +454,7 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {
"; + echo "
"; echo 'Change Fund:' . " $$change_fund" . ' | Credit Card: | Check: +