Browse Source

Many goodies for a better user experience.

1. New NONSHOP constant. 0=no function =>1 is function
2. Moved individual_hours_log back to /
3. Added better view/business logic for storage transactions,
   and new documentation.
4. New users logging in can immediately add a project/comments
5. Added more documentation to populate and a new show_payment field.
devel
Jonathan Rosenbaum 10 years ago
parent
commit
2370ccee7b
  1. 6
      Connections/database_functions.php
  2. 7
      individual_hours_log.php
  3. 35
      js/transaction.js
  4. 30
      shop_log.php
  5. 54
      sql/populate.sql
  6. 5
      start_shop.php
  7. 35
      transaction_log.php

6
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");

7
stats/individual_hours_log.php → individual_hours_log.php

@ -1,6 +1,6 @@
<?php
require_once('../Connections/YBDB.php');
require_once('../Connections/database_functions.php');
require_once('Connections/YBDB.php');
require_once('Connections/database_functions.php');
$page_edit_contact = PAGE_EDIT_CONTACT;
@ -38,7 +38,8 @@ if($_GET['record_count']>0){
} 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

35
js/transaction.js

@ -43,6 +43,41 @@ $(function() {
}
});
/* 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
});

30
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 = '<span class="yb_heading3red">Please Select a User</span><br />';
} 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,7 +151,11 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "FormEdit")) {
<td height="35"><strong>Update Hours </strong></td>
<td height="35"><strong>Edit Data </strong></td>
</tr>
<form method="post" name="form_new" action="<?php echo $editFormAction; ?>">
<tr bordercolor="#CCCCCC">
<td height="40" valign="bottom">
<span class="yb_standard_small">&nbsp;&nbsp;Not in the list: Create <a href="<?php echo $page_edit_contact; ?>?contact_id=new_contact&shop_id=<?php echo $shop_id?>">New User</a><br>&nbsp;&nbsp;Hint: Click on dropdown below and type <br />
@ -170,8 +176,28 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "FormEdit")) {
<td valign="bottom"><input name="Submit" type="submit" value="Sign In" /></td>
<td valign="bottom">&nbsp;</td>
</tr>
<!-- testing this -->
<tr bordercolor="#CCCCCC" bgcolor="transparent">
<td colspan="6"><table border="0" cellspacing="0" cellpadding="1">
<tbody><tr>
<td width="125"><div align="right">Project:</div></td>
<td><select name="project">
<option value="" selected="selected"></option>\n<option value="Bike Building">Bike Building</option>\n<option value="Computers">Computers</option>\n<option value="Inventory">Inventory</option>\n<option value="Organization">Organization</option>\n<option value="Website">Website</option>\n</select></td>
</tr>
<tr>
<td><div align="right">Comment:</div></td>
<td><input name="comment" type="text" value="" size="90"></td>
</tr>
<tr>
</tr> </tbody></table> </td>
</tr>
<input type="hidden" name="MM_insert" value="form_new">
</form>
<tr valign="bottom" bordercolor="#CCCCCC" bgcolor="#99CC33">
<td height="25" colspan="6" bgcolor="#99CC33">&nbsp;&nbsp;&nbsp;&nbsp;Existing Shop Users:</td>
</tr>

54
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)

5
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")) {
<td><strong>Stats</strong></td>
<td><strong>Edit</strong></td>
</tr>
<?php if ($nonshop != 0) { ?>
<tr>
<td height="30" colspan="6"><a href="http://www.ybdb.austinyellowbike.org/individual_hours_log.php">Log Non-Shop Hours</a> </td>
<td height="30" colspan="6"><a href="individual_hours_log.php">Log Non-Shop Hours</a> </td>
</tr>
<?php } ?>
<form action="<?php echo $editFormAction; ?>" method="post" name="form_new" id="form_new">
<tr>
<td height="30"><span class="yb_heading3red">Start New Shop:</span></td>

35
transaction_log.php

@ -297,18 +297,23 @@ FROM transaction_log WHERE transaction_id = $trans_id; ";
function FillDate() {
document.FormEdit.date.value = '<?php echo current_date(); ?>' }
</SCRIPT>
<input type="button" name="date_fill" value="Fill Current Date" onclick="FillDate()" />
<input type="button" name="date_fill" id="date_fill" value="Fill Current Date" onclick="FillDate()" />
<br /><?php
if ($row_Recordset3['show_startdate']) { // If there is a start date show storage expiration message.
echo ($row_Recordset2['date_day'] == "0000-00-00") ? $row_Recordset2['storage_days_left'] . " days of storage remaining. Bike must be finished by " . $row_Recordset2['storage_deadline'] . "." : "Bike is marked as complete and should no longer be stored in the shop.";
if ( $row_Recordset2['date_day'] == "0000-00-00" ||
!isset($row_Recordset2['date_day']) ) {
echo $row_Recordset2['storage_days_left'] .
" days of storage remaining. Bike must be finished by " .
$row_Recordset2['storage_deadline'] . ".";
} else {
echo "Bike is marked as complete and should no longer be stored in the shop.";
}
} ?></td>
</tr>
<?php if($row_Recordset3['show_amount']){ ?>
<tr><td>&nbsp;</td>
<td><label>Price:</label></td>
<td><input name="amount" type="text" id="amount" value="<?php echo $row_Recordset2['format_amount']; ?>" size="6" /></td>
</tr>
<?php } // end if show amount
<?php // end if show amount
if($row_Recordset3['community_bike']){ //community bike will allow a quantity to be selected for Yellow Bikes and Kids Bikes?>
<tr>
<td>&nbsp;</td>
@ -321,7 +326,16 @@ FROM transaction_log WHERE transaction_id = $trans_id; ";
<td valign="top"><label><?php echo $row_Recordset3['fieldname_description']; ?>:</label></td>
<td><textarea name="description" cols="45" rows="3"><?php echo $row_Recordset2['description']; ?></textarea></td>
</tr>
<tr>
<?php if($row_Recordset3['show_amount']){ ?>
<tr id="price"><td>&nbsp;</td>
<td><label>Price:</label></td>
<td><input name="amount" type="text" id="amount" value="<?php echo $row_Recordset2['format_amount']; ?>" size="6" /></td>
</tr>
<?php } ?>
<?php if($row_Recordset3['show_payment']) { ?>
<tr id="payment_type">
<td></td>
<td><label>Payment Type:</label></td>
<td>
@ -333,6 +347,7 @@ FROM transaction_log WHERE transaction_id = $trans_id; ";
<?php if ($row_Recordset2['payment_type'] == "check") { echo " checked"; } ?> >Check
</td>
</tr>
<?php } ?>
<?php } // end if show_description
if($row_Recordset3['show_soldto_location']){ // if location show row?>
<tr><td>&nbsp;</td>
@ -370,7 +385,7 @@ FROM transaction_log WHERE transaction_id = $trans_id; ";
<input type="hidden" name="amount" value="<?php echo $row_Recordset2['format_amount']; ?>" />
<!-- <input type="hidden" name="item_number" value="" /> -->
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="return" value="http://fsbomorgantown.com:84/transaction_log.php?error=transactioncomplete" />
<input type="hidden" name="return" value="transaction_log.php?error=transactioncomplete" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="tax" value="0" />

Loading…
Cancel
Save