diff --git a/Connections/database_functions.php b/Connections/database_functions.php index a41c86e..cbcbcd9 100644 --- a/Connections/database_functions.php +++ b/Connections/database_functions.php @@ -9,6 +9,7 @@ define("DEFAULT_SHOP_USER", "Volunteer"); // How many hours should the shop be open from the time a person logins? Hours display in pulldown in shop_log.php // No overtime for volunteers. :) +// shop will be current shop for the 24hr day yyyy-mm-dd (currently no check for hrs, only date) define("SHOP_HOURS_LENGTH", 10); /* @@ -26,6 +27,11 @@ define("SHOP_HOURS_LENGTH", 10); */ define("TIMEZONE", "America/New_York"); +/* If you elect to keep records for non-shop hours, decide which shop should be used for that purpose. + The first shop created, 1, makes sense. A link will show in start_shop.php. + If you do not want this functionality at all, choose 0. +*/ +define("NONSHOP",0); //constants define("PAGE_START_SHOP", "/start_shop.php"); diff --git a/stats/individual_hours_log.php b/individual_hours_log.php similarity index 98% rename from stats/individual_hours_log.php rename to individual_hours_log.php index 888ad98..631d7d6 100644 --- a/stats/individual_hours_log.php +++ b/individual_hours_log.php @@ -1,6 +1,6 @@ 0){ $record_count = $_GET['record_count']; } else { $record_count = 10;} - -$individual_shop_id = 90; + +// A special shop devoted to this, better to start with 1. :) +$individual_shop_id = NONSHOP; $query_Recordset1 = "SELECT shop_hours.shop_visit_id, shop_hours.contact_id, shop_hours.shop_user_role, shop_hours.project_id, DATE(shop_hours.time_in) AS date, shop_hours.time_in, shop_hours.time_out, TIME_FORMAT(TIMEDIFF(time_out, time_in),'%k:%i') as et, shop_hours.comment, CONCAT(contacts.last_name, ', ', contacts.first_name, ' ',contacts.middle_initial) AS full_name, contacts.first_name FROM shop_hours LEFT JOIN shop_user_roles ON shop_hours.shop_user_role=shop_user_roles.shop_user_role_id diff --git a/js/transaction.js b/js/transaction.js index 4b7badc..8f809f4 100644 --- a/js/transaction.js +++ b/js/transaction.js @@ -42,6 +42,41 @@ $(function() { $.post("json/transaction.php",{ payment_type: this.value, transaction_id: $transaction_id } ); } }); + + /* 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 ) { + + var date_value = $("#date").val(); + var date_test = /^\d{4}-((0\d)|(1[012]))-(([012]\d)|3[01])$/.test(date_value); + + if ( date_test && date_value != "0000-00-00" ) { + $("#price").show(); + $("#payment_type").show(); + } else { + $("#price").hide(); + $("#payment_type").hide(); + } + + $("#date_fill").click(function(){ + $("#price").show(); + $("#payment_type").show(); + }) + + $("#date").on("input", function(){ + + date_test = /^\d{4}-((0\d)|(1[012]))-(([012]\d)|3[01])$/.test(this.value); + if ( date_test && this.value != "0000-00-00" ) { + $("#price").show(); + $("#payment_type").show(); + } else { + $("#price").hide(); + $("#payment_type").hide(); + } + }); + + } // end testing for storage presentation + } // editing a transaction diff --git a/shop_log.php b/shop_log.php index 13863d8..dc23c1c 100644 --- a/shop_log.php +++ b/shop_log.php @@ -78,11 +78,13 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form_new") && ($_PO //if no contact is selected $error_message = 'Please Select a User
'; } elseif ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form_new")) { - $insertSQL = sprintf("INSERT INTO shop_hours (contact_id, shop_id, shop_user_role, time_in) VALUES (%s, %s, %s, %s)", + $insertSQL = sprintf("INSERT INTO shop_hours (contact_id, shop_id, shop_user_role, time_in, comment, project_id) VALUES (%s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['contact_id'], "int"), GetSQLValueString($shop_id, "int"), GetSQLValueString($_POST['user_role'], "text"), - GetSQLValueString($_POST['time_in'], "date")); + GetSQLValueString($_POST['time_in'], "date"), + GetSQLValueString($_POST['comment'], "text"), + GetSQLValueString($_POST['project'], "text")); mysql_select_db($database_YBDB, $YBDB); $Result1 = mysql_query($insertSQL, $YBDB) or die(mysql_error()); @@ -149,8 +151,12 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "FormEdit")) { Update Hours Edit Data + +
- + + +   Not in the list: Create New User
  Hint: Click on dropdown below and type
    last name quickly
@@ -170,8 +176,28 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "FormEdit")) {   + + + + + + + + + + + + + + +
Project:
Comment:
+ +
+ +     Existing Shop Users: diff --git a/sql/populate.sql b/sql/populate.sql index 0503c0c..68a9657 100644 --- a/sql/populate.sql +++ b/sql/populate.sql @@ -72,8 +72,6 @@ INSERT INTO contacts ( -- Set-up transaction types -- This is object orienteed like :) -- --- Storage period may be defined in Connections/database_functions.php --- -- SILLY TEXT FIELDS (some presentation logic that is in the business logic, rather than kept cleanly separated from it) -- NOTE - (:colon is appended by default:) -- @@ -107,37 +105,47 @@ INSERT INTO contacts ( -- Note: good news, default select value for transaction types may be set in Connections/database_functions.php -- -- Sales Tax Report - Hardwired Caveat: The same value used for accounting_group --- needs to be defined in Connections/database_functions.php --- +-- needs to be defined in Connections/database_functions.php - ACCOUNTING_GROUP +-- +-- STORAGE TRANSACTION +-- show_startdate - is used by transactions where an item (usually a bicycle) is stored for +-- a defined period before it is purchased. If this is set, +-- the behavior is to hide price (show_amount) and payment types (show_payment) +-- until a date (label defined by fieldname_date) is entered. + +-- Storage period may be defined in Connections/database_functions.php - STORAGE_PERIOD + +ALTER TABLE transaction_types ADD show_payment tinyint(1) NOT NULL DEFAULT '1'; INSERT INTO transaction_types (transaction_type_id, rank, active, community_bike, show_transaction_id, show_type, show_startdate, show_amount, show_description, show_soldto, show_soldby, fieldname_date, fieldname_soldby, message_transaction_id, fieldname_soldto, show_soldto_location, fieldname_description, - accounting_group + accounting_group, show_payment) ) VALUES - ("Build Your Own Bike", 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales"), - ("Bicycles", 2, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales"), - ("Non-inventory Parts", 3, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales"), - ("Trade-ups/Ins", 4, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales"), - ("Helmets", 5, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales"), - ("Donations", 6, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales"), - ("Memberships", 7, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales"), - ("Inventory Parts", 8, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales"), - ("Cargo Related", 9, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales"), - ("Car Racks", 10, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales"), - ("DIY Repairs", 11, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales"), - ("Accounts Receivable Invoice", 12, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales"), - ("Accounts Receivable Payment", 13, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales"), - ("Deposit", 14, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales"), - ("Metrics - Completed Mechanic Operation Bike", 15, 1, 0, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales"), - ("Metrics - Completed Mechanic Operation Wheel", 16, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales"), + ("Build Your Own Bike", 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales", 1), + ("Bicycles", 2, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales", 1), + ("Non-inventory Parts", 3, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales", 1), + ("Trade-ups/Ins", 4, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales", 1), + ("Helmets", 5, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales", 1), + ("Donations", 6, 1, 0, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales", 1), + ("Memberships", 7, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales", 1), + ("Inventory Parts", 8, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales", 1), + ("Cargo Related", 9, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales", 1), + ("Car Racks", 10, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales", 1), + ("DIY Repairs", 11, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales", 1), + ("Accounts Receivable Invoice", 12, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales", 0), + ("Accounts Receivable Payment", 13, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales", 1), + ("Deposit", 14, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales", 0), + ("Metrics - Completed Mechanic Operation Bike", 15, 1, 0, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales", 1), + ("Metrics - Completed Mechanic Operation Wheel", 16, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales", 1), ("Metrics - New Parts on a Completed Bike", 17, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales"), - ("Sale - Used Parts", 18, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales"), - ("Sale - New Parts", 19, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales"), - ("Sale - Complete Bike", 20, 1, 0, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales"); + ("Sale - Used Parts", 18, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales", 1), + ("Sale - New Parts", 19, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales", 1), + ("Sale - Complete Bike", 20, 1, 0, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales", 1), + ("Giveaway", 21, 1, 0, 1, 1, 0, 0, 1, 1, 1, "Sale Date", "Given By"," ", "Given To", 1, "Description", "Sales", 0); -- transaction_log - added paid or not -- - added payment_type (cash, check or cc) diff --git a/start_shop.php b/start_shop.php index 0868c68..fc80f5e 100644 --- a/start_shop.php +++ b/start_shop.php @@ -3,6 +3,7 @@ require_once('Connections/YBDB.php'); require_once('Connections/database_functions.php'); $page_shop_log = PAGE_SHOP_LOG; +$nonshop = NONSHOP; //?shop_id=2 if($_GET['shop_id']>0){ @@ -126,9 +127,11 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) { Stats Edit + - Log Non-Shop Hours + Log Non-Shop Hours +
Start New Shop: diff --git a/transaction_log.php b/transaction_log.php index 28d71f7..35b7730 100644 --- a/transaction_log.php +++ b/transaction_log.php @@ -230,12 +230,12 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) { // Gets data for the transaction being edited mysql_select_db($database_YBDB, $YBDB); $query_Recordset2 = "SELECT *, -DATE_FORMAT(date_startstorage,'%Y-%m-%d') as date_startstorage_day, -DATE_FORMAT(date,'%Y-%m-%d') as date_day, -DATE_FORMAT(DATE_ADD(date_startstorage,INTERVAL $storage_period DAY),'%W, %M %D') as storage_deadline, -DATEDIFF(DATE_ADD(date_startstorage,INTERVAL $storage_period DAY),CURRENT_DATE()) as storage_days_left, -FORMAT(amount,2) as format_amount -FROM transaction_log WHERE transaction_id = $trans_id; "; + DATE_FORMAT(date_startstorage,'%Y-%m-%d') as date_startstorage_day, + DATE_FORMAT(date,'%Y-%m-%d') as date_day, + DATE_FORMAT(DATE_ADD(date_startstorage,INTERVAL $storage_period DAY),'%W, %M %D') as storage_deadline, + DATEDIFF(DATE_ADD(date_startstorage,INTERVAL $storage_period DAY),CURRENT_DATE()) as storage_days_left, + FORMAT(amount,2) as format_amount + FROM transaction_log WHERE transaction_id = $trans_id; "; $Recordset2 = mysql_query($query_Recordset2, $YBDB) or die(mysql_error()); $row_Recordset2 = mysql_fetch_assoc($Recordset2); $totalRows_Recordset2 = mysql_num_rows($Recordset2); @@ -297,18 +297,23 @@ FROM transaction_log WHERE transaction_id = $trans_id; "; function FillDate() { document.FormEdit.date.value = '' } - +
- -   - - - -   @@ -321,7 +326,16 @@ FROM transaction_log WHERE transaction_id = $trans_id; "; - + + +   + + + + + + + @@ -333,6 +347,7 @@ FROM transaction_log WHERE transaction_id = $trans_id; "; >Check +   @@ -370,7 +385,7 @@ FROM transaction_log WHERE transaction_id = $trans_id; "; - +