1
0
mirror of https://github.com/fspc/Yellow-Bike-Database.git synced 2025-04-04 09:33:24 -04:00

Compare commits

..

No commits in common. "devel" and "2.0" have entirely different histories.
devel ... 2.0

26 changed files with 254 additions and 762 deletions

View File

@ -1,7 +1,6 @@
<?php
require_once('YBDB.php');
// DO NOT EDIT - USE Connections/local_configurations.php instead with definitions between
// <?php (no space between ? and >) ? >
@ -18,21 +17,8 @@ require_once('YBDB.php');
Hawaii no DST ..... Pacific/Honolulu
*/
if( !defined( 'TIMEZONE' ) ) define("TIMEZONE", "America/New_York");
define("TIMEZONE", "America/New_York");
/***
DHCP
****/
// The public IP address of the device which has opened a shop determines the ownership of that shop.
// In that way, more than one shop can run without conflicting with each other from different locations.
// However, in some cases the IP changes frequently due to DHCP during a 24hr shop.
// Definitions:
// default (use full IP address assigned)
// or
// Enter the numbers that defines a Class (A|B|C) Network, eg. 73.79;
// 73.79 would match a Class B network with an IP range of 73.79.*.*
// For additional info, read https://www.webopedia.com/DidYouKnow/Internet/IPaddressing.asp
if( !defined( 'IP' ) ) define("IP", "default");
/*********
MEMBERSHIP
@ -48,29 +34,32 @@ Memberships include unlimited access to an available work stand during open shop
// Needs to volunteer at least this amount of defined hours before being considered a member
// Note: used only as a metric for reports
if( !defined( 'MEMBERSHIP_HOURS' ) ) define("MEMBERSHIP_HOURS",8);
define("MEMBERSHIP_HOURS",8);
// Needs to volunteer at least this number of days before being considered a member
// Note: used only as a metric for reports
if( !defined( 'MEMBERSHIP_DAYS' ) ) define("MEMBERSHIP_DAYS",2);
define("MEMBERSHIP_DAYS",2);
// Define how long a patron remains a member if they purchase a membership.
if( !defined( 'PURCHASED_MEMBERSHIP_DAYS' ) ) define("PURCHASED_MEMBERSHIP_DAYS",365);
define("PURCHASED_MEMBERSHIP_DAYS",365);
// Define discount for paid members (applies when volunteer benefits do not)
if( !defined( 'MEMBERSHIP_DISCOUNT' ) ) define("MEMBERSHIP_DISCOUNT",10); // PERCENTAGE
define("MEMBERSHIP_DISCOUNT",10); // PERCENTAGE
/*********
STAND TIME
**********/
// Determines the hourly cost for Stand Time (transaction_type_id)
if( !defined( 'STAND_TIME_HOURLY_RATE' ) ) define("STAND_TIME_HOURLY_RATE",10); // IN DOLLARS
// Determines the behaviour of Stand Time (transaction_type_id)
define("STAND_TIME_HOURLY_RATE",10); // IN DOLLARS
// Define how much time over 1hr is allowed before charging for the next hour.
if( !defined( 'STAND_TIME_GRACE_PERIOD' ) ) define("STAND_TIME_GRACE_PERIOD",15); // IN MINUTES 1 - 59
define("STAND_TIME_GRACE_PERIOD",15); // IN MINUTES 1 - 59
// Define hourly cost for stand time
define("STAND_TIME_VALUE",10); // IN DOLLARS
// Define how many free days of stand time are allotted after purchase of a bike
if( !defined( 'FREE_STAND_TIME_PERIOD' ) ) define("FREE_STAND_TIME_PERIOD",30); // IN DAYS
define("FREE_STAND_TIME_PERIOD",30); // IN DAYS
/********************************
SWEAT EQUITY / VOLUNTEER BENEFITS
@ -91,17 +80,22 @@ donated more than 100 hours of their time in the past 365 days, this match can b
(Sweat Equity / Volunteer Benefits can't be combined with Membership Benefits.)
*/
if( !defined( 'SWEAT_EQUITY_LIMIT' ) ) define("SWEAT_EQUITY_LIMIT",100); // IN DOLLARS
if( !defined( 'MAX_BIKE_EARNED' ) ) define("MAX_BIKE_EARNED",1); // AMOUNT OF BIKES
if( !defined( 'VOLUNTEER_HOUR_VALUE' ) ) define("VOLUNTEER_HOUR_VALUE",8); // IN DOLLARS
if( !defined( 'VOLUNTEER_DISCOUNT' ) ) define("VOLUNTEER_DISCOUNT",25); // PERCENTAGE
if( !defined( 'SPECIAL_VOLUNTEER_HOURS_QUALIFICATION' ) ) define("SPECIAL_VOLUNTEER_HOURS_QUALIFICATION",100); // IN HOURS
if( !defined( 'SPECIAL_VOLUNTEER_DISCOUNT' ) ) define("SPECIAL_VOLUNTEER_DISCOUNT",50); // PERCENTAGE
define("SWEAT_EQUITY_LIMIT",100); // IN DOLLARS
define("MAX_BIKE_EARNED",1); // AMOUNT OF BIKES
define("VOLUNTEER_HOUR_VALUE",8); // IN DOLLARS
define("VOLUNTEER_DISCOUNT",25); // PERCENTAGE
define("SPECIAL_VOLUNTEER_HOURS_QUALIFICATION",100); // IN HOURS
define("SPECIAL_VOLUNTEER_DISCOUNT",50); // PERCENTAGE
// Customized sweat equity limit per contact_id
// e.g. for sweat equity limit of $200 for contact_id 500: array(500 => 200)
$custom_sweat_equity_limit = array();
// Determines the behaviour of Bicycles (transaction_type_id) for volunteer to earn-a-bike purchases.
// Keeping things equitable, if a patron decides to purchase a bike, rather than earning it,
// that counts to the EAB limit for the year.
define("EARN_A_BIKE_LIMIT",1);
// Determine if stand time behaviour will be based on the SWEAT_EQUITY_LIMIT with discounts applied,
// or 1 to 1 (1hr of volunteering === 1hr of free stand time) regardless of the SWEAT_EQUITY_LIMIT
define("REDEEM_ONE_TO_ONE", true);
@ -128,16 +122,6 @@ BANNED IDS
// Ban those pesky individuals who continually refuse to follow policies and safer space agreements by contact_id
$banned_individuals = array();
/************
PROBATION IDS
************/
// Put individuals under probation by contact_id. Probation could be used for a variety of scenarios,
// an individual who may potentially become banned, or who has been deemed as worthy of coming out of a ban,
// or someone who IOU's volunteer time for a bike they earned (generally, people should not be allowed to do
// this in the first place), etc.
$probation_individuals = array();
/*******
CONTACTS
@ -145,12 +129,12 @@ CONTACTS
// Allow waiver (recommended) in Add/Edit Contacts; 1 = yes, 0 = no
// Waiver text may be modified in Connections/waiver.txt
if( !defined( 'WAIVER' ) ) define("WAIVER", 1);
define("WAIVER", 1);
if( !defined( 'WAIVER_LABEL' ) ) define("WAIVER_LABEL","Waiver of Liability and Safer Spaces Agreement:");
define("WAIVER_LABEL","Waiver of Liability and Safer Spaces Agreement:");
// Allow email_list option in Add/Edit Contacts; 1 = yes, 0 = no
if( !defined( 'EMAIL_LIST' ) ) define("EMAIL_LIST", 1);
define("EMAIL_LIST", 1);
// Define a url for an email connector that will connect to an email list.
// The url can be a server:port, program, etc.
@ -159,20 +143,20 @@ if( !defined( 'EMAIL_LIST' ) ) define("EMAIL_LIST", 1);
// The purpose of email connectors is to provide autonomy in the choice
// of email services and programs. E.g. mailman, googlegroups
// See ./examples for an example mailman connector
if( !defined( 'EMAIL_LIST_CONNECTOR' ) ) define("EMAIL_LIST_CONNECTOR","https://wvcompletestreets.org:9987");
define("EMAIL_LIST_CONNECTOR","https://wvcompletestreets.org:9987");
// Define the password that is unique to the connector.
if( !defined( 'EMAIL_LIST_CONNECTOR_PASSWORD' ) ) define("EMAIL_LIST_CONNECTOR_PASSWORD","bikebike");
define("EMAIL_LIST_CONNECTOR_PASSWORD","bikebike");
// If a self-signed ssl certificate that is associated with the email connector is being provided,
// designate an absolute path, if not, change to false.
if( !defined( 'SSL_CERTIFICATE' ) ) define("SSL_CERTIFICATE", "/var/www/html/examples/cert.pem");
define("SSL_CERTIFICATE", "/var/www/html/examples/cert.pem");
//// "Volunteer Interest" form ////
if( !defined( 'VOLUNTEER_INTEREST_FORM' ) ) define("VOLUNTEER_INTEREST_FORM", true);
define("VOLUNTEER_INTEREST_FORM", true);
// Form name
if( !defined( 'VOLUNTEER_INTEREST_FORM_NAME' ) ) define("VOLUNTEER_INTEREST_FORM_NAME","Volunteer Interests");
define("VOLUNTEER_INTEREST_FORM_NAME","Volunteer Interests");
// NOTE: Introductory text can be modified in Connections/volunteer_interest_form_introduction.txt
@ -194,7 +178,7 @@ $volunteer_interests = array(
);
// Provide a comment box - true of false
if( !defined( 'VOLUNTEER_INTEREST_COMMENTS' ) ) define("VOLUNTEER_INTEREST_COMMENTS", true);
define("VOLUNTEER_INTEREST_COMMENTS", true);
// NOTE: The 2 variables ($volunteer_interest_changename & $volunteer_interests_deletename)
// below allow you to change or delete an interest.
@ -227,40 +211,40 @@ TRANSACTIONS
************/
// User defined constants - read sql/populate.sql for an explanation
if( !defined( 'STORAGE_PERIOD' ) ) define("STORAGE_PERIOD", 14);
if( !defined( 'ACCOUNTING_GROUP' ) ) define("ACCOUNTING_GROUP", "Sales");
if( !defined( 'DEFAULT_TRANSACTION_TYPE' ) ) define("DEFAULT_TRANSACTION_TYPE", "Sale - Used Parts");
define("STORAGE_PERIOD", 14);
define("ACCOUNTING_GROUP", "Sales");
define("DEFAULT_TRANSACTION_TYPE", "Sale - Used Parts");
// shop_user_role
if( !defined( 'DEFAULT_SHOP_USER' ) ) define("DEFAULT_SHOP_USER", "Stand Time");
define("DEFAULT_SHOP_USER", "Stand Time");
/* Change Fund - A specific amount of money for the purpose of making change.
The amount on hand should remain the same at all times;
therefore a change funds does not require replenishment.
*/
if( !defined( 'CHANGE_FUND' ) ) define("CHANGE_FUND", 20);
define("CHANGE_FUND", 20);
// 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)
if( !defined( 'SHOP_HOURS_LENGTH' ) ) define("SHOP_HOURS_LENGTH", 10);
define("SHOP_HOURS_LENGTH", 10);
// What minute interval should be displayed for list_time()? In other words, the time_in and time_out pulldown lists.
// choose an interval that is divisible by 60 minutes, 1, 5, 15, 30 etc.
if( !defined( 'LIST_MINUTE_INTERVAL' ) ) define("LIST_MINUTE_INTERVAL", 1);
define("LIST_MINUTE_INTERVAL", 1);
/* 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.
*/
if( !defined( 'NONSHOP' ) ) define("NONSHOP", 0);
define("NONSHOP", 0);
// How many transactions do you want shown by default
if( !defined( 'NUMBER_OF_TRANSACTIONS' ) ) define("NUMBER_OF_TRANSACTIONS", 11);
define("NUMBER_OF_TRANSACTIONS", 11);
// Define csv directory (see directions below for creating it)
if( !defined( 'CSV_DIRECTORY' ) ) define("CSV_DIRECTORY","csv");
define("CSV_DIRECTORY","csv");
// Make a directory to store csv accounting files. Currently used for GnuCash format.
// Assuming the root of the website, and directory is called csv, and a Debian-based distribution:
@ -294,15 +278,14 @@ $gnucash_accounts = array( "Assets:Current Assets:Checking Account" => "checking
// Note: Remote shops function independently via their IP identification.
//
// Normally, you will want this set at 0.
if( !defined( 'SHOW_SHOP_ID' ) ) define('SHOW_SHOP_ID',0);
define('SHOW_SHOP_ID',0);
/*************
ETHERPAD LITE
**************/
// Allow comments/feedback/notes to be added per individual_history_log in reports,
// and globally in shop_log. An etherpad host has to be defined for this to work.
// See wiki for instructions on how to setup an etherpad docker instance or just go to
// https://github.com/fspc/etherpad-and-draw-node-alpine
// See wiki for instructions on how to setup an etherpad docker instance.
//
// prefix allows you to set a prefix to the name of the autogenerated padId:
// etherpad = prefix + "pad_contact_id_" + contact_id;
@ -332,38 +315,16 @@ if(file_exists( realpath($_SERVER["DOCUMENT_ROOT"]) . "/Connections/local_config
}
// other constants
if( !defined( 'PAGE_START_SHOP' ) ) define("PAGE_START_SHOP", "/start_shop.php");
if( !defined( 'PAGE_SHOP_LOG' ) ) define("PAGE_SHOP_LOG", "/shop_log.php");
if( !defined( 'PAGE_EDIT_CONTACT' ) ) define("PAGE_EDIT_CONTACT", "/contact_add_edit.php");
if( !defined( 'PAGE_SELECT_CONTACT' ) ) define("PAGE_SELECT_CONTACT", "/contact_add_edit_select.php");
if( !defined( 'PAGE_SHOP_LOG_DELETE_VISIT' ) ) define("PAGE_SHOP_LOG_DELETE_VISIT", "/shop_log_delete_shopvisitid.php");
if( !defined( 'INDIVIDUAL_HOURS_LOG' ) ) define("INDIVIDUAL_HOURS_LOG", "/individual_hours_log.php");
if( !defined( 'INDIVIDUAL_HISTORY_LOG' ) ) define("INDIVIDUAL_HISTORY_LOG", "/individual_history_log.php");
if( !defined( 'PAGE_SALE_LOG' ) ) define("PAGE_SALE_LOG", "/transaction_log.php");
if( !defined( 'PAGE_EDIT_LOCATION' ) ) define("PAGE_EDIT_LOCATION", "/location_add_edit.php");
if( !defined( 'PAGE_SELECT_LOCATION' ) ) define("PAGE_SELECT_LOCATION", "/location_add_edit_select.php");
// Highlight search results in transaction_log
function highlightKeywords($text, $keyword) {
$wordsAry = explode(" ", $keyword);
$wordsCount = count($wordsAry);
// Using REGEXP, this removes regex from search
$find = array('/[\*\.\$\^\?\+\[\]\|\(\)\,\{\}\:\\\]/');
$replace = array('');
for($i=0;$i<$wordsCount;$i++) {
$wordsAry[$i] = preg_replace($find, $replace, $wordsAry[$i]);
$highlighted_text = "<span style='color:black; background:#ffeb3bc7; box-shadow:2px 0 #ffeb3bc7, -2px 0 0 #ffeb3bc7; padding: 0px 0;'>$wordsAry[$i]</span>";
$text = str_ireplace($wordsAry[$i], $highlighted_text, $text);
//$text = str_replace($wordsAry[$i], $highlighted_text, $text);
}
return $text;
}
define("PAGE_START_SHOP", "/start_shop.php");
define("PAGE_SHOP_LOG", "/shop_log.php");
define("PAGE_EDIT_CONTACT", "/contact_add_edit.php");
define("PAGE_SELECT_CONTACT", "/contact_add_edit_select.php");
define("PAGE_SHOP_LOG_DELETE_VISIT", "/shop_log_delete_shopvisitid.php");
define("INDIVIDUAL_HOURS_LOG", "/individual_hours_log.php");
define("INDIVIDUAL_HISTORY_LOG", "/individual_history_log.php");
define("PAGE_SALE_LOG", "/transaction_log.php");
define("PAGE_EDIT_LOCATION", "/location_add_edit.php");
define("PAGE_SELECT_LOCATION", "/location_add_edit_select.php");
//This is a general function to generate the contents of a list box based on a MySQL query. All necessary parameters for the query are passed
function generate_list($querySQL,$list_value,$list_text, $form_name, $default_value, $color)
@ -388,7 +349,7 @@ function generate_list($querySQL,$list_value,$list_text, $form_name, $default_va
$default_delimiter = 'selected="selected"';
} else { $default_delimiter = '';}
echo '<option style="color:' . $color . ';" value="' . $row_recordset[$list_value] . '" ' . $default_delimiter . '>' .
$row_recordset[$list_text] . '</option>';
$row_recordset[$list_text] . '</option>\n';
} while ($row_recordset = mysql_fetch_assoc($recordset));
$rows = mysql_num_rows($recordset);
if($rows > 0) {
@ -766,13 +727,6 @@ function dateandtimein($date, $time){
// Drop-Down lists
function list_contacts_select_contact($form_name = "contact_id", $default_value = "")
{
echo "<select name={$form_name} class='yb_standard'>\n";
echo "<option value='everyone'>Everyone</option>\n";
list_contacts("none",$default_value);
echo "</select>\n";
}
function list_contacts_edit_add($form_name = "contact_id", $default_value = "")
{
@ -884,27 +838,17 @@ function max_shop_id(){
return $row_Recordset1['shop_id'];
}
// Is there currently a shop?
// curl https://ipinfo.io/ip
// Is there currently a shop?
function current_shop_by_ip(){
global $database_YBDB, $YBDB;
$IP = $_SERVER['REMOTE_ADDR'];
$current_date = current_date();
mysql_select_db($database_YBDB, $YBDB);
if( IP == "default") {
$query_Recordset1 = "SELECT shop_id FROM shops WHERE ip_address = '{$IP}' AND date REGEXP '^{$current_date} ' ORDER BY shop_id DESC;";
$Recordset1 = mysql_query($query_Recordset1, $YBDB) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
} else {
$ip = IP;
$query_Recordset1 = "SELECT shop_id FROM shops WHERE ip_address REGEXP '^{$ip}' AND date REGEXP '^{$current_date} ' ORDER BY shop_id DESC;";
$Recordset1 = mysql_query($query_Recordset1, $YBDB) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
}
mysql_select_db($database_YBDB, $YBDB);
$query_Recordset1 = "SELECT shop_id FROM shops WHERE ip_address = '{$IP}' AND date REGEXP '^{$current_date} ' ORDER BY shop_id DESC;";
$Recordset1 = mysql_query($query_Recordset1, $YBDB) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
return $row_Recordset1['shop_id'];
}

View File

@ -7,7 +7,7 @@ In 2014, Positive Spin of Morgantown, WV in the USA was looking for a way to rep
It was a successful choice, and continues to improve! You can read more about the FLOSS process at [bikecollectives.org in this presentation](https://www.bikecollectives.org/wiki/images/1/1e/2017-SE-BikeBike-Libre-slides.pdf).
There is a demo at [https://ybdb.bikelover.org](https://ybdb.bikelover.org). Try it out!
There is a demo at [http://ybdb.wvcompletestreets.org](http://ybdb.wvcompletestreets.org). Try it out!
Docker Development is at [https://github.com/fspc/ybdb](https://github.com/fspc/ybdb).

View File

@ -17,7 +17,7 @@ include("include_header.html");
?>
<div id="contact_id" style="display:none;"><?php echo $contact_id; ?></div>
<div style="text-align:center;"><div id="name" style="align-content:center; font-size:2em;"></div><div id="membership_status"></div></div>
<div style="text-align:center;"><div id="name" style="align-content:center; font-size:2em;"></div></div>
<div id="individual_history"></div>
<div class="stats-clear nextprev" style="text-align:center; display:block; margin-top:9px;">

View File

@ -36,32 +36,18 @@ $(function(){
$(".stats-left").attr("href","/individual_history_log.php?contact_id=" + prev);
$(".stats-right").attr("href","/individual_history_log.php?contact_id=" + next);
var record_count;
$.post("json/reports.php", { record_count: 1 }, function (data) {
record_count = data;
record_count = $.parseJSON(data);
});
// name
var date;
$.post("json/reports.php", { name: 1, contact_id: contact_id }, function (data) {
if (data) {
var d = new Date();
date = d.toISOString().split('T')[0];
var obj = $.parseJSON(data);
var full_name_with_link = '<a style="color: rgb(27, 105, 30); text-decoration: none; cursor: crosshair;"' +
' href="transaction_log.php?trans_date=' + date +
'&trans_type=all_types&shop_dayname=alldays&record_count=' + record_count.record_count +
'&contact_id_search=' +
contact_id + '">' + obj.full_name + "</a>";
$("#name").html(full_name_with_link);
$("#name").text(obj.full_name);
var pad_name;
if (obj.configurations.prefix) {
pad_name = obj.configurations.prefix + "_pad_contact_id_" + contact_id;
} else {
pad_name = "pad_contact_id_" + contact_id;
}
//console.log(pad_name);
console.log(pad_name);
if ( obj.configurations.host && obj.full_name ) {
$("#individual_history_pad").pad({
"padId": pad_name,
@ -128,59 +114,6 @@ $(function(){
}); // tabulator
// Is contact a member
var contacts = "contact_id=" + contact_id;
$.post("json/transaction.php", { membership_benefits: 1, contact_id: contacts }, function (data) {
var membership, membership_obj, membership_objs = $.parseJSON(data);
/*
Weird hack, before improving performance #46, there was always a property for membership_obj,
membership_discount:10, which just allowed the code to work, now it is empty when a patron
actually is not a paid member, so this creates that obj & property if that is the case.
*/
membership_obj = membership_objs[0] || { membership_discount: 10 };
var title = membership_obj.normal_full_name + "\r\n" +
membership_obj.email + "\r\n" +
membership_obj.phone + "\r\n" +
"expiration: " + membership_obj.expiration_date;
var expiration_date;
var d = new Date();
if (membership_obj.expiration_date) {
var exp = membership_obj.expiration_date;
expiration_date = new Date(exp.split("-").toString());
if (d < expiration_date) {
membership = true;
}
}
if (typeof membership_obj.expiration_date && membership_obj.expiration_date !== undefined) {
if (d >= expiration_date) {
var membership = '<a href="transaction_log.php?trans_date=' + date +
'&trans_type=all_types&shop_dayname=alldays&record_count=' + record_count.record_count +
'&contact_id_search=' +
contact_id + '">' + "Expired Membership</a>";
$("#membership_status").prop("title",title).html(membership).children().
css({color: "rgb(27, 105, 30)", textAlign: "center", cursor: "help", textDecoration: "none"});
} else if (d < expiration_date) {
var membership = '<a href="transaction_log.php?trans_date=' + date +
'&trans_type=all_types&shop_dayname=alldays&record_count=' + record_count.record_count +
'&contact_id_search=' +
contact_id + '">' + "Paid Membership</a>";
$("#membership_status").prop("title",title).html(membership).children().
css({color: "rgb(27, 105, 30)", textAlign: "center", cursor: "help", textDecoration: "none"});
}
}
}); // Is contact a member
} // if contact_id
// stats_userhours

View File

@ -32,23 +32,6 @@ $(function(){
});
$(banned_list).css({backgroundColor: "red"}).prop("title", "BANNED");
// return probation list
var probation_list, pl;
$.post("json/contact.php", {probation: 1}, function (data) {
if (data) {
pl = $.parseJSON(data);
$(pl).each(function(i,v) {
if (i === 0) {
probation_list = "#" + v;
} else {
probation_list = probation_list + ",#" + v;
}
});
}
});
$(probation_list).css({backgroundColor: "#eed202"}).prop("title", "PROBATION");
// error handler for shops with a popup dialog (TODO)
function error_handler(input,error_span,error,error_text,event) {
@ -104,6 +87,7 @@ $(function(){
} );
// could have done this in php, but this separates out the view logic
var membership_ids, volunteer_ids;
var last_index = $("#shop_log tr[id]").length;

View File

@ -68,120 +68,4 @@ $(function(){
e.preventDefault();
});
var volunteer_ids;
var last_index = $("tr[id]").length;
if (last_index) {
last_index = last_index - 1;
$.each($("tr[id]"), function(index) {
if (this.id) {
var id = this.id;
if (last_index < 1) {
volunteer_ids = "contacts.contact_id=" + id;
}
else if (!volunteer_ids) {
volunteer_ids = "(contacts.contact_id=" + id + " OR ";
} else if ( index === last_index) {
volunteer_ids += "contacts.contact_id=" + id + ")";
} else {
volunteer_ids += "contacts.contact_id=" + id + " OR ";
}
}
});
}
var d = new Date();
volunteer_status(volunteer_ids);
// volunteer status
// Essentially, the same function (but with modifications) as in shop.js and transaction.js
function volunteer_status(contacts) {
var all_members_obj; //reuse this object
var year = d.getFullYear();
if (contacts) {
$.post("../json/transaction.php", { volunteer_benefits: 1, contact_id: contacts }, function (data) {
all_members_obj = $.parseJSON(data);
$.each(all_members_obj, function() {
var bikes_earned = 0;
var volunteer_hours_redeemed = 0;
var obj = this;
var volunteer = "", remaining = 0, vhr = "", max_bikes_earned = 0;
if (obj.volunteer) {
volunteer = $.parseJSON(obj.volunteer);
if (volunteer.hasOwnProperty(year)) {
remaining = obj.current_year_volunteer_hours - volunteer[year].volunteer_hours_redeemed;
vhr = volunteer[year].volunteer_hours_redeemed;
max_bikes_earned = volunteer[year].max_bike_earned;
}
} else {
vhr = 0;
}
var title = obj.normal_full_name + "\r\n" +
"Volunteer Hours for last 365 days: " + obj.volunteer_hours + "\r\n" +
"Volunteer Hours \(" + year + "\): " + obj.current_year_volunteer_hours + "\r\n" +
"Volunteer Hours Redeemed: " + vhr + "\r\n" +
"Volunteer Hours Remaining: " + remaining + "\r\n" +
"Max Bikes Earned: " + max_bikes_earned;
var volunteer_with_redeemed_hours_at_zero = obj.current_year_volunteer_hours - vhr;
if (obj.contact_id) {
if (obj.volunteer_hours && obj.volunteer_hours !== '0') {
if (volunteer_with_redeemed_hours_at_zero !== 0) {
$("#" + obj.contact_id + " td").first().
css({textAlign: "center", cursor: "cell"}).
prop("title",title).css({textAlign: "center"});
} else {
$("#" + obj.contact_id + " td").first().
css({backgroundColor: "rgb(216, 198, 39)", textAlign: "center", cursor: "cell"}).
prop("title",title).css({textAlign: "center"});
}
} else {
title = obj.normal_full_name + "\r\n" +
"Volunteer Hours for last 365 days: None" + "\r\n";
$("#" + obj.contact_id + " td").first().
css({backgroundColor: "rgb(190, 199, 204)", textAlign: "center", cursor: "cell"}).
prop("title",title).css({textAlign: "center"});
}
} else {
var name = $("#" + id + " td a[href*='individual']").text();
var name_obj = name.trim().split(", ");
name = name_obj[1] + " " + name_obj[0];
title = name + "\r\n" +
"Volunteer Hours for last 365 days: None" + "\r\n";
$("#" + obj.contact_id + " td").first().
css({backgroundColor: "rgb(190, 199, 204)", textAlign: "center", cursor: "cell"}).
prop("title",title).css({textAlign: "center"});
}
}); // each all_members_obj
}); // post volunteer benefits
} // if this is a volunteer
} // function volunteer_status
});

View File

@ -10,10 +10,9 @@ $(function() {
// but all ajax needs to be synchronous in this program because of the use of an "ancient" mysql
$("[name='transaction_type']").attr("tabindex",1);
$("[name='transaction_type']").focus().scrollTop();
$("[name='transaction_type']").focus();
$("input[value='Create Transaction']").attr("tabindex",2);
$("#trans_date").mask("0000-00-00", {placeholder: "yyyy-mm-dd" });
$("[name='contact_id']").attr("tabindex",3);
// Add focus for easier tab browsing
// use .paid parent and hover & classes
@ -89,6 +88,38 @@ $(function() {
}
} );
// Provide membership and volunteer information for patrons
/*
$("[href^='individual_history_log.php']").each( function() { console.log(this.href.split("=")[1]); }); // check for duplicates
var membership_ids, volunteer_ids;
var last_index = $("[href^='individual_history_log.php']").length;
if (last_index) {
last_index = last_index - 1;
$.each($("[href^='individual_history_log.php']"), function(index) {
if (this.id) {
var id = this.id;
if (last_index <= 1) {
membership_ids = "contact_id=" + id;
}
else if (!membership_ids) {
membership_ids = "(contact_id=" + id + " OR ";
} else if ( index === last_index) {
membership_ids += "contact_id=" + id + ")";
} else {
membership_ids += "contact_id=" + id + " OR ";
}
}
});
if (membership_ids) {
volunteer_ids = membership_ids.replace(/contact_id/g,"contacts.contact_id");
}
}
*/
// paid or not?
$(":checked").parent("td").prev().children().not("#payment_type_label").hide(); // need to watch that not introduction bugs
$(".paid").click(function() {
@ -152,165 +183,7 @@ $(function() {
}
}
});
// contact search on main page
$("select[name='contact_id_search']").chosen();
// Volunteer Information on mouseover of contact
var volunteer_ids;
var last_index = $("td a[href*='individual_history']").length;
if (last_index) {
last_index = last_index - 1;
$.each($("td a[href*='individual_history']"), function(index) {
if (this.href.match(/\d*$/)) {
var id = this.href.match(/\d+$/);
if (last_index < 1) {
volunteer_ids = "contacts.contact_id=" + id;
}
else if (!volunteer_ids) {
volunteer_ids = "(contacts.contact_id=" + id + " OR ";
} else if ( index === last_index) {
volunteer_ids += "contacts.contact_id=" + id + ")";
} else {
volunteer_ids += "contacts.contact_id=" + id + " OR ";
}
}
});
}
// For performance
if (last_index <= 200) {
volunteer_status(volunteer_ids);
}
// volunteer status
function volunteer_status(contacts) {
var d = new Date();
var all_members_obj; //reuse this object
var year = d.getFullYear();
if (contacts) {
$.post("json/transaction.php", { volunteer_benefits: 1, contact_id: contacts }, function (data) {
all_members_obj = $.parseJSON(data);
$.each(all_members_obj, function() {
var bikes_earned = 0;
var volunteer_hours_redeemed = 0;
var obj = this;
var volunteer = "", remaining = 0, vhr = "", max_bikes_earned = 0;
if (obj.volunteer) {
volunteer = $.parseJSON(obj.volunteer);
if (volunteer.hasOwnProperty(year)) {
remaining = obj.current_year_volunteer_hours - volunteer[year].volunteer_hours_redeemed;
vhr = volunteer[year].volunteer_hours_redeemed;
max_bikes_earned = volunteer[year].max_bike_earned;
}
} else {
vhr = 0;
}
var title = obj.normal_full_name + "\r\n" +
"Volunteer Hours for last 365 days: " + obj.volunteer_hours + "\r\n" +
"Volunteer Hours \(" + year + "\): " + obj.current_year_volunteer_hours + "\r\n" +
"Volunteer Hours Redeemed: " + vhr + "\r\n" +
"Volunteer Hours Remaining: " + remaining + "\r\n" +
"Max Bikes Earned: " + max_bikes_earned;
var volunteer_with_redeemed_hours_at_zero = obj.current_year_volunteer_hours - vhr;
if (obj.contact_id) {
//#d8c62757
if (obj.volunteer_hours && obj.volunteer_hours !== '0') {
if (volunteer_with_redeemed_hours_at_zero !== 0) {
$("td a[href='individual_history_log.php?contact_id=" + obj.contact_id + "']").
parent().css({backgroundColor: "#19a0cc2b", cursor: "cell"}).
prop("title",title);
$("td a[href='individual_history_log.php?contact_id=" + obj.contact_id + "']").css({color: "#1b691e", textDecoration: "none", cursor: "crosshair"});
$("td a[href='individual_history_log.php?contact_id=" + obj.contact_id + "']").hover( function(e){ $(this).css("color",e.type === "mouseenter"?"blue":"#1b691e");});
} else {
$("td a[href='individual_history_log.php?contact_id=" + obj.contact_id + "']").
parent().css({backgroundColor: "#d8c62757", cursor: "cell"}).
prop("title",title);
$("td a[href='individual_history_log.php?contact_id=" + obj.contact_id + "']").css({color: "#1b691e", textDecoration: "none", cursor: "crosshair"});
$("td a[href='individual_history_log.php?contact_id=" + obj.contact_id + "']").hover( function(e){ $(this).css("color",e.type === "mouseenter"?"blue":"#1b691e");});
}
} else {
title = obj.normal_full_name + "\r\n" +
"Volunteer Hours for last 365 days: None" + "\r\n";
$("td a[href='individual_history_log.php?contact_id=" + obj.contact_id + "']").
parent().css({backgroundColor: "#bec7cc91", textAlign: "center", cursor: "cell"}).
prop("title",title);
$("td a[href='individual_history_log.php?contact_id=" + obj.contact_id + "']").css({color: "#1b691e", textDecoration: "none", cursor: "crosshair"});
$("td a[href='individual_history_log.php?contact_id=" + obj.contact_id + "']").hover( function(e){ $(this).css("color",e.type === "mouseenter"?"blue":"#1b691e");});
}
} else {
var name = $("#" + id + " td a[href*='individual']").text();
var name_obj = name.trim().split(", ");
name = name_obj[1] + " " + name_obj[0];
title = name + "\r\n" +
"Volunteer Hours for last 365 days: None" + "\r\n";
$("td a[href='individual_history_log.php?contact_id=" + obj.contact_id + "']").
parent().css({backgroundColor: "rgb(190, 199, 204)", textAlign: "center", cursor: "cell"}).
prop("title",title);
$("td a[href='individual_history_log.php?contact_id=" + obj.contact_id + "']").css({color: "#1b691e", textDecoration: "none", cursor: "crosshair"});
$("td a[href='individual_history_log.php?contact_id=" + obj.contact_id + "']").hover( function(e){ $(this).css("color",e.type === "mouseenter"?"blue":"#1b691e");});
}
}); // each all_members_obj
}); // post volunteer benefits
} // if this is a volunteer
// not a current volunteer within the last 365 days, or never has been a volunteer
$("td a[href*='individual_history']").parent(":not([title])").children().each( function() {
var name = $(this).text();
var name_obj = name.trim().split(", ");
name = name_obj[1] + " " + name_obj[0];
var id = this.href.split("=")[1];
var title = name + "\r\n" +
"Volunteer Hours for last 365 days: None" + "\r\n";
if (id) {
$("td a[href='individual_history_log.php?contact_id=" + id + "']").
parent().css({cursor: "cell"}).
prop("title",title);
$("td a[href='individual_history_log.php?contact_id=" + id + "']").css({color: "#1b691e", textDecoration: "none", cursor: "crosshair"});
$("td a[href='individual_history_log.php?contact_id=" + id + "']").hover( function(e){ $(this).css("color",e.type === "mouseenter"?"blue":"#1b691e");});
}
}); // .each not a current volunteer
} // end function volunteer_status
// transaction slider - on reload
transaction_slider();
@ -404,14 +277,8 @@ $(function() {
// watch that percentage doesn't acquire too many decimal points.
//console.dir(range_obj);
// If no min is found this makes it the same as max
// only a problem for non transaction_log pages using transaction.js if there is only one deposit for the last year
// not sure what will happen with 0 deposits for the last year
if ( !range_obj["min"] ) {
range_obj["min"] = range_obj["max"];
}
//initialize slider
//initialize slider
if (!slider) {
slider = $('#gnucash_csv_range').noUiSlider({
start: [ prev_trans, max_range ],
@ -902,6 +769,8 @@ $(function() {
} // end function redeemable
// editing a transaction
if ( $("input[name='shop_id']").length ) {
@ -1041,7 +910,6 @@ $(function() {
sold_to.change(function() {
//sold_to.hide();
amount.prop("disabled","");
var membership_obj; //reuse this object
@ -1524,26 +1392,15 @@ $(function() {
var vhr;
if ($("#redeemable_hours").val() === "") {
vhr = "0.00";
} else {
} else {
vhr = parseFloat($("#redeemable_hours").val());
}
}
// Don't require paid to be selected, only amount >= 0
//
// Here is where equitable behaviour for earned bikes could be turned off/on
// However, it actually was a feature induced bug or undesired depending how you look at it,
// see #78 and #80,
// because vhr always became 0 when amount was added if spinner was not used if the
// patron had become volunteer, which at the time made sense, but there
// are exceptions to the rule, and it actually was not fair, but penalized those
// who chose to volunteer and purchase a bike (usually for someone else) without redeeming hours
// and then later redeemed their hours for a bike for themselves, only to find out they had already hit their
// max eab.
// Don't require paid to be selected, only amount >= 0
var max_bike_earned = 0, maximum_allowable_earned_bikes;
if ($("#transaction_type").val() === "Bicycles") {
// hours were redeemed and this is a Bicycle transaction
if (vhr !== "0.00" && vhr !== 0) {
if (vhr !== "0.00") {
max_bike_earned = 1;
}
}
@ -1584,15 +1441,8 @@ $(function() {
} else {
if ($("#redeemable_hours").val().length) {
// NaN bug #75
if (volunteer_benefits_history[year].volunteer_hours_redeemed === "NaN") {
vhr = 0;
} else {
vhr = parseFloat(volunteer_benefits_history[year].volunteer_hours_redeemed);
}
volunteer_benefits_history[year].volunteer_hours_redeemed = vhr + parseFloat($("#redeemable_hours").val());
volunteer_benefits_history[year].volunteer_hours_redeemed = parseFloat(volunteer_benefits_history[year].volunteer_hours_redeemed) +
parseFloat($("#redeemable_hours").val());
if (parseFloat(volunteer_benefits_history[year].max_bike_earned) < maximum_allowable_earned_bikes) {
volunteer_benefits_history[year].max_bike_earned = parseFloat(volunteer_benefits_history[year].max_bike_earned) +
@ -1665,14 +1515,11 @@ $(function() {
}
}
// Assuming local time is correct and synchronized with mysql time d.toLocaleDateString().replace(/\//g,'-')
var current_date_time = d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate() + " " + d.toLocaleTimeString().split(' ')[0];
var current_transaction =
{
transaction_id: transaction_id,
date_startstorage: $("#date_startstorage").val(),
date: current_date_time,
date: date,
transaction_type: $("#transaction_type").val(),
original_price: original_price,
amount: price,

View File

@ -57,15 +57,6 @@ $ssl_certificate = SSL_CERTIFICATE;
}
// pass probation contact_id values if they exist
if (isset($_POST['probation'])) {
if ($probation_individuals) {
echo json_encode($probation_individuals);
}
}
// update email_list
if( isset($_POST['email_list']) ) {
@ -103,7 +94,7 @@ $ssl_certificate = SSL_CERTIFICATE;
CURLOPT_SSL_VERIFYPEER => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => json_encode($json),
);
);
if ($ssl_certificate) {
$curlConfig[CURLOPT_CAINFO] = $ssl_certificate;

View File

@ -129,15 +129,5 @@ $handler->start();
echo json_encode($result);
} // return everyone
// Latest transaction_id
if (isset($_POST['record_count'])) {
$query = 'SELECT MAX(transaction_id) AS record_count FROM transaction_log;';
$sql = mysql_query($query, $YBDB) or die(mysql_error());
$result = mysql_fetch_assoc($sql);
echo json_encode($result);
}
?>

View File

@ -14,6 +14,7 @@ $change_fund = CHANGE_FUND;
$csv_directory = CSV_DIRECTORY;
$stand_time_hourly_rate = STAND_TIME_HOURLY_RATE;
$stand_time_grace_period = STAND_TIME_GRACE_PERIOD;
$stand_time_value = STAND_TIME_VALUE;
$free_stand_time_period = FREE_STAND_TIME_PERIOD;
$timezone = TIMEZONE;
$sweat_equity_limit = SWEAT_EQUITY_LIMIT;
@ -60,7 +61,6 @@ $membership_discount = MEMBERSHIP_DISCOUNT;
}
// If payment_type check is selected - return check number if exists
if (isset($_POST['check_number'])) {
@ -160,7 +160,7 @@ $membership_discount = MEMBERSHIP_DISCOUNT;
$result["volunteer_discount"] = $volunteer_discount;
$result["special_volunteer_hours_qualification"] = $special_volunteer_hours_qualification;
$result["special_volunteer_discount"] = $special_volunteer_discount;
$result["stand_time_value"] = $stand_time_hourly_rate;
$result["stand_time_value"] = $stand_time_value;
$result["redeem_one_to_one"] = $redeem_one_to_one;
$volunteers[] = $result;
}
@ -464,7 +464,7 @@ $membership_discount = MEMBERSHIP_DISCOUNT;
}
// second statement to find normal transactions
$query = "SELECT SUBSTRING_INDEX(date, ' ', 1) AS 'date', transaction_id, transaction_type, check_number, description, amount, history, " .
$query = "SELECT SUBSTRING_INDEX(date, ' ', 1) AS 'date', transaction_id, transaction_type, check_number, description, amount, " .
"CONCAT(contacts.first_name, ' ', contacts.last_name) AS 'patron' " .
"FROM transaction_log, contacts WHERE paid=1 AND date!='NULL' " .
"AND (payment_type='cash' OR payment_type='check') " .
@ -473,7 +473,7 @@ $membership_discount = MEMBERSHIP_DISCOUNT;
$sql2 = mysql_query($query, $YBDB) or die(mysql_error());
// third statement to find anonymous transactions
$query = "SELECT SUBSTRING_INDEX(date, ' ', 1) AS 'date', transaction_id, transaction_type, check_number, description, amount, history " .
$query = "SELECT SUBSTRING_INDEX(date, ' ', 1) AS 'date', transaction_id, transaction_type, check_number, description, amount " .
"FROM transaction_log WHERE paid=1 AND date!='NULL' " .
"AND (payment_type='cash' OR payment_type='check') " .
"AND anonymous=1 " .
@ -484,11 +484,6 @@ $membership_discount = MEMBERSHIP_DISCOUNT;
// normal transaction
while ( $result = mysql_fetch_assoc($sql2) ) {
$history = json_decode($result['history']);
end($history);
$key = key($history);
$description = preg_replace('/\n/', ' \r ', $result['description']);
$description = preg_replace('/\r/', '\r', $description);
$description = preg_replace('/,/', ';', $description);
@ -497,20 +492,13 @@ $membership_discount = MEMBERSHIP_DISCOUNT;
}
$gnucash_csv_file .= $result['date'] . ', ' . $result['transaction_id'] . ' ' . $check_number .
',' . ' [' . $coordinator[$result['transaction_id']] . ' => ' . $result['patron'] . '] ' .
$description . ' (Income:' . $result['transaction_type'] . ') ' .
' [O:' . $history[$key]->original_price . '; P:' . $history[$key]->amount .
'; R:' . $history[$key]->redeemed_hours . ']' .
$description . ' (Income:' . $result['transaction_type'] . ') ' .
', ' . $result['amount'] . ', ' .
$accounts_gnucash['checking'] . "\n";
}
// anonymous transaction
while ( $result = mysql_fetch_assoc($sql3) ) {
$history = json_decode($result['history']);
end($history);
$key = key($history);
$description = preg_replace('/\n/', ' \r ', $result['description']);
$description = preg_replace('/\r/', '\r', $description);
$description = preg_replace('/,/', ';', $description);
@ -520,8 +508,6 @@ $membership_discount = MEMBERSHIP_DISCOUNT;
$gnucash_csv_file .= $result['date'] . ', ' . $result['transaction_id'] . ' ' . $check_number .
',' . ' [' . $coordinator[$result['transaction_id']] . ' => Anonymous] ' .
$description . ' (Income:' . $result['transaction_type'] . ') ' .
' [O:' . $history[$key]->original_price . '; P:' . $history[$key]->amount .
'; R:' . $history[$key]->redeemed_hours . ']' .
', ' . $result['amount'] . ', ' .
$accounts_gnucash['checking'] . "\n";
}
@ -553,7 +539,7 @@ $membership_discount = MEMBERSHIP_DISCOUNT;
}
// second statement to find normal transactions
$query = "SELECT SUBSTRING_INDEX(date, ' ', 1) AS 'date', transaction_id, transaction_type, description, amount, history, " .
$query = "SELECT SUBSTRING_INDEX(date, ' ', 1) AS 'date', transaction_id, transaction_type, description, amount, " .
"CONCAT(contacts.first_name, ' ', contacts.last_name) AS 'patron' " .
"FROM transaction_log, contacts WHERE paid=1 AND date!='NULL' " .
"AND payment_type='credit' " .
@ -562,7 +548,7 @@ $membership_discount = MEMBERSHIP_DISCOUNT;
$sql2 = mysql_query($query, $YBDB) or die(mysql_error());
// third statement to find anonymous transactions
$query = "SELECT SUBSTRING_INDEX(date, ' ', 1) AS 'date', transaction_id, transaction_type, description, amount, history " .
$query = "SELECT SUBSTRING_INDEX(date, ' ', 1) AS 'date', transaction_id, transaction_type, description, amount " .
"FROM transaction_log WHERE paid=1 AND date!='NULL' " .
"AND payment_type='credit' " .
"AND anonymous=1 " .
@ -573,38 +559,24 @@ $membership_discount = MEMBERSHIP_DISCOUNT;
// normal transaction
while ( $result = mysql_fetch_assoc($sql2) ) {
$history = json_decode($result['history']);
end($history);
$key = key($history);
$description = preg_replace('/\n/', ' \r ', $result['description']);
$description = preg_replace('/\r/', '\r', $description);
$description = preg_replace('/,/', ';', $description);
$gnucash_csv_file .= $result['date'] . ', ' . $result['transaction_id'] .
',' . ' [' . $coordinator[$result['transaction_id']] . ' => ' . $result['patron'] . '] ' .
$description . ' (Income:' . $result['transaction_type'] . ') ' .
' [O:' . $history[$key]->original_price . '; P:' . $history[$key]->amount .
'; R:' . $history[$key]->redeemed_hours . ']' .
$description . ' (Income:' . $result['transaction_type'] . ') ' .
', ' . $result['amount'] . ', ' .
$accounts_gnucash['credit'] . "\n";
}
// anonymous transaction
while ( $result = mysql_fetch_assoc($sql3) ) {
$history = json_decode($result['history']);
end($history);
$key = key($history);
$description = preg_replace('/\n/', ' \r ', $result['description']);
$description = preg_replace('/\r/', '\r', $description);
$description = preg_replace('/,/', ';', $description);
$gnucash_csv_file .= $result['date'] . ', ' . $result['transaction_id'] .
',' . ' [' . $coordinator[$result['transaction_id']] . ' => Anonymous] ' .
$description . ' (Income:' . $result['transaction_type'] . ') ' .
' [O:' . $history[$key]->original_price . '; P:' . $history[$key]->amount .
'; R:' . $history[$key]->redeemed_hours . ']' .
$description . ' (Income:' . $result['transaction_type'] . ') ' .
', ' . $result['amount'] . ', ' .
$accounts_gnucash['credit'] . "\n";
}
@ -708,12 +680,12 @@ $membership_discount = MEMBERSHIP_DISCOUNT;
$query = "SELECT contacts.contact_id, CONCAT(last_name, ', ', first_name, ' ',middle_initial) AS full_name,
CONCAT(first_name, ' ', last_name) AS normal_full_name, contacts.email AS email, contacts.phone AS phone,
MAX(transaction_log.date) AS membership_start, MAX(SUBSTRING_INDEX(DATE_ADD(date, INTERVAL 365 DAY), ' ', 1)) AS expiration_date
transaction_log.date AS membership_start, SUBSTRING_INDEX(DATE_ADD(date, INTERVAL 365 DAY), ' ', 1) AS expiration_date
FROM transaction_log LEFT JOIN contacts ON transaction_log.sold_to = contacts.contact_id
WHERE SUBSTRING_INDEX(date, ' ', 1) <= DATE_ADD(date, INTERVAL 365 DAY)
AND (transaction_type='Memberships' AND paid=1) AND " .
$contact_id .
" GROUP BY contact_id ORDER by membership_start DESC;";
" ORDER by membership_start DESC;";
$sql = mysql_query($query, $YBDB) or die(mysql_error());

View File

@ -198,7 +198,7 @@ INSERT INTO transaction_types
("Used Parts", 3, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales", 1, 0, 0),
("Trade-ups/Ins", 4, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales", 1, 0, 0),
("Helmets", 5, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales", 1, 0, 0),
("Donations", 6, 1, 0, 1, 1, 0, 0, 1, 1, 1, "Donation Date", "Received by"," ", "Donated by", 0, "Description", "Donations", 0, 1, 1),
("Donations", 6, 1, 0, 1, 1, 0, 0, 1, 1, 1, "Donation Date", "Received by"," ", "Donated by", 1, "Description", "Donations", 0, 1, 0),
("Monetary Donations", 7, 1, 0, 1, 1, 0, 1, 1, 1, 1, "Donation Date", "Received by"," ", "Donated by", 1, "Description", "Sales", 1, 1, 0),
("Memberships", 8, 1, 0, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales", 1, 0, 0),
("New Parts", 9, 1, 1, 1, 1, 0, 1, 1, 1, 1, "Sale Date", "Sold By"," ", "Sold To", 1, "Description", "Sales", 1, 0, 0),

View File

@ -54,7 +54,7 @@ $editFormAction_no_shopid = $_SERVER['PHP_SELF'] . "?shop_date=$shop_date";
mysql_select_db($database_YBDB, $YBDB);
$query_Recordset1 = "SELECT shops.shop_id, date, DAYNAME(date) as day ,shop_location, shop_type, ip_address,
IF(SUBSTRING(date,1,10) = curdate(),1,0) AS CanEdit,
COUNT(DISTINCT contact_id) AS num_visitors,
COUNT(shop_visit_id) AS num_visitors,
ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS total_hours
FROM shops LEFT JOIN shop_hours ON shops.shop_id = shop_hours.shop_id
WHERE date <= '{$shop_date}' {$shop_dayname} GROUP BY shop_id

View File

@ -41,16 +41,30 @@ if (isset($_POST['range1'])) {
$today = $range2;
}
/*
SELECT contacts.contact_id, CONCAT(last_name, ', ', first_name, ' ',middle_initial) AS full_name,
COUNT(shop_hours.contact_id) as cs_volunteer_visits,
ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS cs_volunteer_hours
FROM shop_hours
LEFT JOIN contacts ON shop_hours.contact_id = contacts.contact_id
LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id
WHERE (time_in > DATE_SUB(CURDATE(),INTERVAL $days_range1 DAY) AND time_in <= DATE_SUB(CURDATE(), INTERVAL $days_range2 DAY))
AND shop_user_roles.other_volunteer = 1
GROUP BY contact_id
ORDER BY sort_hours DESC;
*/
$query = "SELECT contacts.contact_id, CONCAT(last_name, ', ', first_name, ' ',middle_initial) AS full_name,
COUNT(shop_hours.contact_id) as cs_volunteer_visits,
ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS cs_volunteer_hours
ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS cs_volunteer_hours
FROM shop_hours
LEFT JOIN contacts ON shop_hours.contact_id = contacts.contact_id
LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id
WHERE (SUBSTRING_INDEX(time_in, ' ', 1) >= DATE_SUB(CURDATE(),INTERVAL $days_range1 DAY) AND SUBSTRING_INDEX(time_in, ' ', 1) <= DATE_SUB(CURDATE(), INTERVAL $days_range2 DAY))
AND shop_user_roles.other_volunteer = 1
AND shop_hours.shop_user_role = 'Student Volunteer/Community Service Hours'
GROUP BY contact_id
ORDER BY cs_volunteer_hours DESC;";
$cs_volunteers_sql = mysql_query($query, $YBDB) or die(mysql_error());

View File

@ -39,13 +39,43 @@ if (isset($_POST['range1'])) {
$today = $range2;
}
/*
SELECT contact_id, full_name, email, phone, sort_visits, sort_hours FROM
(SELECT contacts.contact_id, CONCAT(last_name, ', ', first_name, ' ',middle_initial) AS full_name,
contacts.email AS email, contacts.phone AS phone,
COUNT(shop_hours.contact_id) as sort_visits,
ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS sort_hours
FROM shop_hours
LEFT JOIN contacts ON shop_hours.contact_id = contacts.contact_id
LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id
WHERE (time_in > DATE_SUB(CURDATE(),INTERVAL 12 MONTH))
AND shop_user_roles.volunteer = 1 GROUP BY contact_id) AS members
WHERE sort_hours >= 8 AND sort_visits >= 2
GROUP by contact_id ORDER by sort_hours DESC, sort_visits DESC;
SELECT contacts.contact_id,
CONCAT(last_name, ', ', first_name, ' ',middle_initial) AS full_name,
CONCAT(first_name, ' ', last_name) AS normal_full_name,
contacts.email AS email, contacts.phone AS phone,
transaction_log.date as sort_hours
FROM transaction_log
LEFT JOIN contacts ON transaction_log.sold_to = contacts.contact_id
WHERE (SUBSTRING_INDEX(date, ' ', 1) >= DATE_SUB(CURDATE(),INTERVAL 365 DAY)
AND SUBSTRING_INDEX(date, ' ', 1) <= DATE_SUB(CURDATE(), INTERVAL 0 DAY))
AND (transaction_type="Memberships" AND paid=1);
*/
// Membership via volunteering
$query = "SELECT contact_id, full_name, normal_full_name, email, phone, sort_visits, sort_hours FROM
(SELECT contacts.contact_id, CONCAT(last_name, ', ', first_name, ' ',middle_initial) AS full_name,
CONCAT(first_name, ' ', last_name) AS normal_full_name,
contacts.email AS email, contacts.phone AS phone,
COUNT(shop_hours.contact_id) as sort_visits,
ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS sort_hours
ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS sort_hours
FROM shop_hours
LEFT JOIN contacts ON shop_hours.contact_id = contacts.contact_id
LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id
@ -97,11 +127,11 @@ while ($result = mysql_fetch_assoc($purchased_membership)) {
while ($result = mysql_fetch_assoc($members)) {
//do {
?>
<tr id="<?php echo $result['contact_id']; ?>">
<?php if( isset($purchased_membership_dictionary[$result['contact_id']]) ) { ?>
<td class="yb_standardRIGHTred"><a style="text-decoration:none" href="<?php echo "{$page_individual_history_log}?contact_id=" . $result['contact_id']; ?>"><?php echo $result['full_name']; ?></a><br \>(paid until <?php echo $purchased_membership_dictionary[$result['contact_id']]['expiration_date']; ?>)</td>
<tr>
<?php if( isset($purchased_membership_dictionary[$result['contact_id']]) ) { ?>
<td class="yb_standardRIGHTred"><a href="<?php echo "{$page_individual_history_log}?contact_id=" . $result['contact_id']; ?>"><?php echo $result['full_name']; ?></a><br \>(paid until <?php echo $purchased_membership_dictionary[$result['contact_id']]['expiration_date']; ?>)</td>
<?php } else { ?>
<td class="yb_standardRIGHTred"><a style="text-decoration:none" href="<?php echo "{$page_individual_history_log}?contact_id=" . $result['contact_id']; ?>"><?php echo $result['full_name']; ?></a></td>
<td class="yb_standardRIGHTred"><a href="<?php echo "{$page_individual_history_log}?contact_id=" . $result['contact_id']; ?>"><?php echo $result['full_name']; ?></a></td>
<?php } ?>
<td class="yb_standardRIGHT"><?php echo number_format($result['sort_visits'],0); ?></td>
<td class="yb_standardRIGHT"><?php echo number_format($result['sort_hours'],0); ?></td>

View File

@ -7,13 +7,41 @@ $page_individual_history_log = INDIVIDUAL_HISTORY_LOG;
mysql_select_db($database_YBDB, $YBDB);
$today = date("Y/m/d");
$year_ago = date("Y/m/d", strtotime("$today -1 year"));
$today_date = new DateTime('now');
$past = new DateTime($year_ago);
$interval = $today_date->diff($past);
$chosen_date = $today;
$days_range1 = $interval->days;
$days_range2 = 0;
// Do some ajax stuff
if (isset($_POST['range1'])) {
$range1 = $_POST['range1'];
$range2 = $_POST['range2'];
$choice1 = new DateTime($range1);
$interval = $today_date->diff($choice1);
$days_range1 = $interval->days;
$choice2 = new DateTime($range2);
$interval = $today_date->diff($choice2);
$days_range2 = $interval->days;
$year_ago = $range1;
$today = $range2;
}
// Membership via volunteering
$query = "SELECT contact_id, full_name, normal_full_name, email, phone, sort_visits, sort_hours FROM
(SELECT contacts.contact_id, CONCAT(last_name, ', ', first_name, ' ',middle_initial) AS full_name,
CONCAT(first_name, ' ', last_name) AS normal_full_name,
contacts.email AS email, contacts.phone AS phone,
COUNT(shop_hours.contact_id) as sort_visits,
ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS sort_hours
ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS sort_hours
FROM shop_hours
LEFT JOIN contacts ON shop_hours.contact_id = contacts.contact_id
LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id
@ -65,14 +93,7 @@ $num_member_rows = mysql_num_rows($purchased_membership);
?>
<tr>
<td class="yb_standardRIGHTred"><a href="<?php echo "{$page_individual_history_log}?contact_id=" . $result['contact_id']; ?>"><?php echo $result['full_name']; ?></a></td>
<td class="yb_standardRIGHTred"><?php
if( strtotime($result['expiration_date']) <= time() ) {
echo $result['expiration_date'];
} else {
echo "<span style='color:blue;'>" . $result['expiration_date'] . "</span>";
}
?></td>
<td class="yb_standardRIGHTred"><?php echo $result['expiration_date']; ?></td>
<td class="yb_standardRIGHT"><?php echo number_format($purchased_membership_dictionary[$result['contact_id']]['sort_visits'],0); ?></td>
<td class="yb_standardRIGHT"><?php echo number_format($purchased_membership_dictionary[$result['contact_id']]['sort_hours'],0); ?></td>
</tr>

View File

@ -33,6 +33,7 @@ if (isset($_POST['range1'])) {
$today = $range2;
}
$query = "SELECT COUNT(shop_id) as total_shops from shops
WHERE (date >= DATE_SUB(CURDATE(),INTERVAL $days_range1 DAY) AND date <= DATE_SUB(CURDATE(), INTERVAL $days_range2 DAY));";
$shop_totals_sql = mysql_query($query, $YBDB) or die(mysql_error());

View File

@ -20,7 +20,7 @@ mysql_select_db($database_YBDB, $YBDB);
$query_Recordset1 = "SELECT year(t.date) as Year,quarter(t.date) as Quarter, month(t.date) as Month, round(sum(amount),2) as TotalSales, tt.accounting_group as AccountingGroup
FROM transaction_log t
LEFT JOIN transaction_types tt ON t.transaction_type = tt.transaction_type_id
WHERE tt.accounting_group = '$accounting_group' AND t.paid=1
WHERE tt.accounting_group = '$accounting_group'
GROUP BY year(t.date), month(t.date)
ORDER BY year(t.date) DESC, month(t.date) DESC;";
$Recordset1 = mysql_query($query_Recordset1, $YBDB) or die(mysql_error());
@ -37,13 +37,13 @@ $totalRows_Recordset1 = mysql_num_rows($Recordset1);
</tr>
<tr>
<td>
<table id="monthlysalestax" border="1" cellpadding="1" cellspacing="0">
<table border="1" cellpadding="1" cellspacing="0">
<tr valign="top" bgcolor="#99CC33" class="yb_standardCENTER">
<th width="120" height="35">Year</th>
<th width="60">Month</th>
<th width="100">Total Sales</th>
<th width="110">Accounting Group</th>
<td width="60" height="35">Year</td>
<td width="60">Month</td>
<td width="100">Total Sales</td>
<td width="110">Accounting Group</td>
</tr>
<form method="post" name="FormUpdate_<?php echo $row_Recordset1['shop_id']; ?>" action="<?php echo $editFormAction; ?>">
<?php while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)) { //do {
@ -62,11 +62,9 @@ $totalRows_Recordset1 = mysql_num_rows($Recordset1);
<?php } else { // end if EDIT RECORD ?>
<tr>
<td><?php echo $row_Recordset1['Year']; ?></td>
<td>
<?php echo '<a href="/transaction_log.php?month_search=' . $row_Recordset1['Year'] . '-' . $row_Recordset1['Month'] . '-01">' . $row_Recordset1['Month'] . '</a>'; ?>
</td>
<td>&nbsp;<?php echo $row_Recordset1['Month']; ?></td>
<td class="yb_standardRIGHT"><?php currency_format($row_Recordset1['TotalSales'],2);?></td>
<td><?php echo $row_Recordset1['AccountingGroup']; ?></td>
<td>&nbsp;<?php echo $row_Recordset1['AccountingGroup']; ?></td>
</tr>
<?php
} // end if EDIT RECORD

View File

@ -20,7 +20,7 @@ $query_Recordset1 = "SELECT *
FROM (SELECT IF(Week(time_in) DIV 2 <>0,Year(time_in),Year(time_in)-1) as Year,
IF(Week(time_in) DIV 2 <>0,Week(time_in) DIV 2,26 ) as PayPeriod, contacts.contact_id as ContactID, CONCAT(last_name, ', ', first_name, ' ',middle_initial) AS Name,
COUNT(shop_hours.contact_id) as Shifts,
ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS Hours
ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60),1) AS Hours
FROM shop_hours
LEFT JOIN contacts ON shop_hours.contact_id = contacts.contact_id
LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id

View File

@ -20,7 +20,7 @@ $query_Recordset1 = "SELECT *
FROM (SELECT IF(Week(time_in) DIV 2 <>0,Year(time_in),Year(time_in)-1) as Year,
IF(Week(time_in) DIV 2 <>0,Week(time_in) DIV 2,26 ) as PayPeriod, contacts.contact_id as ContactID, CONCAT(last_name, ', ', first_name, ' ',middle_initial) AS Name,
COUNT(shop_hours.contact_id) as Shifts,
ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS Hours
ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60),1) AS Hours
FROM shop_hours
LEFT JOIN contacts ON shop_hours.contact_id = contacts.contact_id
LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id

View File

@ -21,7 +21,7 @@ shops.shop_type as ShopType, ROUND(sum(t.amount),2) as Total, count(t.transactio
FROM transaction_log t
LEFT JOIN shops ON t.shop_id=shops.shop_id
LEFT JOIN transaction_types AS ttype ON t.transaction_type = ttype.transaction_type_id
WHERE (ttype.accounting_group = 'Sales' AND t.paid=1) OR ttype.transaction_type_id = 'Incoming Donation - Cash'
WHERE ttype.accounting_group = 'Sales' OR ttype.transaction_type_id = 'Incoming Donation - Cash'
GROUP BY t.shop_id, date_format(t.date,'%m/%d/%Y')
ORDER BY t.date DESC, t.shop_id DESC;";
$Recordset1 = mysql_query($query_Recordset1, $YBDB) or die(mysql_error());
@ -65,7 +65,7 @@ $totalRows_Recordset1 = mysql_num_rows($Recordset1);
<?php } else { // end if EDIT RECORD ?>
<tr>
<td><?php echo $row_Recordset1['ShopDate']; ?></td>
<td><?php echo '<a href="/transaction_log.php?shop_id_search=' . $row_Recordset1['ShopID'] . '">' . $row_Recordset1['ShopID'] . '</a>'; ?></td>
<td><?php echo $row_Recordset1['ShopID']; ?></td>
<td valign="middle"><?php echo $row_Recordset1['Day']; ?></td>
<td valign="middle"><?php echo $row_Recordset1['ShopType']; ?></td>
<td class="yb_standardRIGHT"><?php currency_format($row_Recordset1['Total'],2);?></td>

View File

@ -18,7 +18,7 @@ default:
mysql_select_db($database_YBDB, $YBDB);
$query_Recordset1 = "SELECT * FROM (SELECT contacts.contact_id, CONCAT(last_name, ', ', first_name, ' ',middle_initial) AS full_name,
COUNT(shop_hours.contact_id) as th_visits,
ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS th_hours
ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS th_hours
FROM shop_hours
LEFT JOIN contacts ON shop_hours.contact_id = contacts.contact_id
LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id
@ -26,7 +26,7 @@ GROUP BY contact_id
ORDER BY last_name, first_name) AS total_hours
LEFT JOIN (SELECT contacts.contact_id AS vh_contact_id,
COUNT(shop_hours.contact_id) as vh_visits,
ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS vh_hours
ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS vh_hours
FROM shop_hours
LEFT JOIN contacts ON shop_hours.contact_id = contacts.contact_id
LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id
@ -35,7 +35,7 @@ GROUP BY contacts.contact_id
ORDER BY last_name, first_name) AS volunteer_hours ON total_hours.contact_id = volunteer_hours.vh_contact_id
LEFT JOIN (SELECT contacts.contact_id AS th3_contact_id,
COUNT(shop_hours.contact_id) as th3_visits,
ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS th3_hours
ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS th3_hours
FROM shop_hours
LEFT JOIN contacts ON shop_hours.contact_id = contacts.contact_id
LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id
@ -44,7 +44,7 @@ GROUP BY contacts.contact_id
ORDER BY last_name, first_name) AS total_hours3 ON total_hours.contact_id = total_hours3.th3_contact_id
LEFT JOIN (SELECT contacts.contact_id AS vh3_contact_id,
COUNT(shop_hours.contact_id) as vh3_visits,
ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS vh3_hours
ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS vh3_hours
FROM shop_hours
LEFT JOIN contacts ON shop_hours.contact_id = contacts.contact_id
LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id

View File

@ -18,7 +18,7 @@ default:
mysql_select_db($database_YBDB, $YBDB);
$query_Recordset1 = "SELECT * FROM (SELECT contacts.contact_id, CONCAT(last_name, ', ', first_name, ' ',middle_initial) AS full_name,
COUNT(shop_hours.contact_id) as sort_visits,
ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS sort_hours
ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS sort_hours
FROM shop_hours
LEFT JOIN contacts ON shop_hours.contact_id = contacts.contact_id
LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id
@ -27,7 +27,7 @@ GROUP BY contact_id
ORDER BY sort_hours DESC) AS sort_hours
LEFT JOIN (SELECT contacts.contact_id AS vh_contact_id,
COUNT(shop_hours.contact_id) as th_visits,
ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS th_hours
ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS th_hours
FROM shop_hours
LEFT JOIN contacts ON shop_hours.contact_id = contacts.contact_id
LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id
@ -35,7 +35,7 @@ GROUP BY contacts.contact_id
ORDER BY last_name, first_name) AS total_hours ON sort_hours.contact_id = total_hours.vh_contact_id
LEFT JOIN (SELECT contacts.contact_id AS vh_contact_id,
COUNT(shop_hours.contact_id) as vh_visits,
ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS vh_hours
ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS vh_hours
FROM shop_hours
LEFT JOIN contacts ON shop_hours.contact_id = contacts.contact_id
LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id
@ -44,7 +44,7 @@ GROUP BY contacts.contact_id
ORDER BY last_name, first_name) AS volunteer_hours ON sort_hours.contact_id = volunteer_hours.vh_contact_id
LEFT JOIN (SELECT contacts.contact_id AS th3_contact_id,
COUNT(shop_hours.contact_id) as th3_visits,
ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS th3_hours
ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS th3_hours
FROM shop_hours
LEFT JOIN contacts ON shop_hours.contact_id = contacts.contact_id
LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id
@ -53,7 +53,7 @@ GROUP BY contacts.contact_id
ORDER BY last_name, first_name) AS total_hours3 ON sort_hours.contact_id = total_hours3.th3_contact_id
LEFT JOIN (SELECT contacts.contact_id AS vh3_contact_id,
COUNT(shop_hours.contact_id) as vh3_visits,
ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS vh3_hours
ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS vh3_hours
FROM shop_hours
LEFT JOIN contacts ON shop_hours.contact_id = contacts.contact_id
LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id

View File

@ -20,7 +20,7 @@ $query_Recordset1 = "SELECT * FROM
(SELECT contacts.contact_id, CONCAT(last_name, ', ', first_name, ' ',middle_initial) AS full_name,
COUNT(shop_hours.contact_id) as sort_visits,
ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS sort_hours
ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS sort_hours
FROM shop_hours
LEFT JOIN contacts ON shop_hours.contact_id = contacts.contact_id
LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id
@ -30,7 +30,7 @@ ORDER BY sort_hours DESC) AS sort_hours
LEFT JOIN (SELECT contacts.contact_id AS vh_contact_id,
COUNT(shop_hours.contact_id) as th_visits,
ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS th_hours
ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS th_hours
FROM shop_hours
LEFT JOIN contacts ON shop_hours.contact_id = contacts.contact_id
LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id
@ -39,7 +39,7 @@ ORDER BY last_name, first_name) AS total_hours ON sort_hours.contact_id = total_
LEFT JOIN (SELECT contacts.contact_id AS vh_contact_id,
COUNT(shop_hours.contact_id) as vh_visits,
ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS vh_hours
ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS vh_hours
FROM shop_hours
LEFT JOIN contacts ON shop_hours.contact_id = contacts.contact_id
LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id
@ -49,7 +49,7 @@ ORDER BY last_name, first_name) AS volunteer_hours ON sort_hours.contact_id = vo
LEFT JOIN (SELECT contacts.contact_id AS th3_contact_id,
COUNT(shop_hours.contact_id) as th3_visits,
ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS th3_hours
ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS th3_hours
FROM shop_hours
LEFT JOIN contacts ON shop_hours.contact_id = contacts.contact_id
LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id
@ -59,7 +59,7 @@ ORDER BY last_name, first_name) AS total_hours3 ON sort_hours.contact_id = total
LEFT JOIN (SELECT contacts.contact_id AS vh3_contact_id,
COUNT(shop_hours.contact_id) as vh3_visits,
ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS vh3_hours
ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS vh3_hours
FROM shop_hours
LEFT JOIN contacts ON shop_hours.contact_id = contacts.contact_id
LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id

View File

@ -27,7 +27,7 @@ $total_users = $row_Recordset2['total_users'];
$query_Recordset3 = "SELECT year(date), week(date),
COUNT(shop_visit_id) AS total_visitors,
ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS total_hours
ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS total_hours
FROM shops LEFT JOIN shop_hours ON shops.shop_id = shop_hours.shop_id
GROUP BY year(date), week(date)
ORDER BY year(date) DESC, week(date) DESC";
@ -37,7 +37,7 @@ $totalRows_Recordset3 = mysql_num_rows($Recordset3);
$query_Recordset4 = "SELECT year(date), week(date),
COUNT(shop_visit_id) AS volunteer_visitors,
ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS volunteer_hours
ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS volunteer_hours
FROM shops
LEFT JOIN shop_hours ON shops.shop_id = shop_hours.shop_id
LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id

View File

@ -42,8 +42,8 @@ if (isset($_POST['range1'])) {
$query = "SELECT shop_user_role,
COUNT(DISTINCT shop_hours.contact_id) as unique_volunteers,
COUNT(shop_hours.contact_id) as volunteer_visits,
ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS volunteer_hours
COUNT(shop_hours.contact_id) as volunteer_visits,
ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS volunteer_hours
FROM shop_hours
LEFT JOIN contacts ON shop_hours.contact_id = contacts.contact_id
LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id
@ -54,7 +54,7 @@ $query = "SELECT shop_user_role,
$query = "SELECT COUNT(DISTINCT shop_hours.contact_id) as unique_volunteers,
COUNT(shop_hours.contact_id) as volunteer_visits,
ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS volunteer_hours
ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS volunteer_hours
FROM shop_hours
LEFT JOIN contacts ON shop_hours.contact_id = contacts.contact_id
LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id
@ -64,7 +64,8 @@ $total_volunteers_sql = mysql_query($query, $YBDB) or die(mysql_error());
$query = "SELECT shop_user_role, COUNT(DISTINCT shop_hours.contact_id) as unique_visitors,
COUNT(shop_hours.contact_id) as visits,
ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS hours
ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out),
TIME(time_in)))/60)) AS hours
FROM shop_hours
LEFT JOIN contacts ON shop_hours.contact_id = contacts.contact_id
LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id
@ -76,7 +77,7 @@ $visitors_sql = mysql_query($query, $YBDB) or die(mysql_error());
$query = "SELECT COUNT(DISTINCT shop_hours.contact_id) as unique_visitors,
COUNT(shop_hours.contact_id) as visits,
ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS hours
ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS hours
FROM shop_hours
LEFT JOIN contacts ON shop_hours.contact_id = contacts.contact_id
LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id
@ -86,7 +87,7 @@ $total_visitors_sql = mysql_query($query, $YBDB) or die(mysql_error());
$query = "SELECT COUNT(DISTINCT shop_hours.contact_id) as unique_vv,
COUNT(shop_hours.contact_id) as visits,
ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS hours
ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS hours
FROM shop_hours
LEFT JOIN contacts ON shop_hours.contact_id = contacts.contact_id
LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id

View File

@ -7,7 +7,6 @@ require_once('Connections/database_functions.php');
/*
require_once(realpath($_SERVER["DOCUMENT_ROOT"]) . '/php-console/src/PhpConsole/__autoload.php');
$handler = PhpConsole\Handler::getInstance();
$handler->setErrorsHandlerLevel(E_ALL &~ E_DEPRECATED);
$handler->start();
*/
@ -79,50 +78,7 @@ if($_GET['trans_type']=='all_types'){
$trans_type_state = 'all_types';
}
if($_GET['contact_id_search']=='everyone'){
$contact_id = '';
$contact_id_state = 'everyone';
} elseif(isset($_GET['contact_id_search'])) {
$contact_id = "AND contact_id = '" . $_GET['contact_id_search'] . "'";
$contact_id_state = $_GET['contact_id_search'];
} else {
$contact_id = '';
$contact_id_state = 'everyone';
}
if($_GET['search']==''){
$search = '';
$search_state = '';
} elseif(isset($_GET['search'])) {
$search = "AND description REGEXP" . "'" . $_GET['search'] . "'";
//$search = "AND description LIKE" . "'%" . $_GET['search'] . "%'";
$search_state = $_GET['search'];
} else {
$search = '';
$search_state = '';
}
//// currently used for links in reports, and not for transaction_log page search mechanism
// Shop Transaction Totals (stats_shoptransactiontotals.php) - by shop
if($_GET['shop_id_search']==''){
$shop_id_search = '';
} elseif(isset($_GET['shop_id_search'])) {
$shop_id_search = "AND shop_id = '" . $_GET['shop_id_search'] . "'";
} else {
$shop_id_search = '';
}
// Sales Tax Report (stats_monthlysalestax.php)- by month
if($_GET['month_search']==''){
$month_search = '';
} elseif(isset($_GET['month_search'])) {
$month_search = "AND DATE(date) >='" . $_GET['month_search'] . "' AND DATE(date) <= LAST_DAY('" . $_GET['month_search'] . "')";
} else {
$month_search = '';
}
//// record_count (SQL or state)
//record_count (SQL or state)
if($_GET['record_count']>0){
$record_count = $_GET['record_count'];
$number_of_transactions = $record_count;
@ -132,8 +88,6 @@ if($_GET['record_count']>0){
// create a string to remember state
$search_state_array = array(
"search" => $search_state,
"contact_id_search" => $contact_id_state,
"trans_date" => $trans_date_state,
"trans_type" => $trans_type_state,
"shop_dayname" => $shop_dayname_state,
@ -155,27 +109,6 @@ foreach ( $search_state_array as $key => $value ) {
// What is seen on the main page.
mysql_select_db($database_YBDB, $YBDB);
// count for $month_search and $shop_id_search
if($month_search || $shop_id_search) {
$query_Recordset1 = "SELECT *,
DATE_FORMAT(date,'%m/%d/%y (%a)') as date_wday,
CONCAT('$',FORMAT(amount,2)) as format_amount,
CONCAT(contacts.last_name, ', ', contacts.first_name, ' ',contacts.middle_initial) AS full_name,
LEFT(IF(show_startdate, CONCAT(' [',
DATE_FORMAT(DATE_ADD(date_startstorage,INTERVAL $storage_period DAY),'%W, %M %D'), '] ', transaction_log.description),
IF(community_bike,CONCAT('Quantity(', quantity, ') ', transaction_log.description), description)),2000)
as description_with_locations
FROM transaction_log
LEFT JOIN contacts ON transaction_log.sold_to=contacts.contact_id
LEFT JOIN transaction_types ON transaction_log.transaction_type=transaction_types.transaction_type_id
WHERE 1=1 {$trans_date} {$shop_dayname} {$trans_type} {$contact_id} {$search} {$shop_id_search} {$month_search};";
$Recordset1 = mysql_query($query_Recordset1, $YBDB) or die(mysql_error());
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
//$handler->debug($totalRows_Recordset1);
$record_count = $totalRows_Recordset1;
}
$query_Recordset1 = "SELECT *,
DATE_FORMAT(date,'%m/%d/%y (%a)') as date_wday,
CONCAT('$',FORMAT(amount,2)) as format_amount,
@ -187,13 +120,10 @@ LEFT(IF(show_startdate, CONCAT(' [',
FROM transaction_log
LEFT JOIN contacts ON transaction_log.sold_to=contacts.contact_id
LEFT JOIN transaction_types ON transaction_log.transaction_type=transaction_types.transaction_type_id
WHERE 1=1 {$trans_date} {$shop_dayname} {$trans_type} {$contact_id} {$search} {$shop_id_search} {$month_search} ORDER BY transaction_id DESC LIMIT 0, $record_count;";
WHERE 1=1 {$trans_date} {$shop_dayname} {$trans_type} ORDER BY transaction_id DESC LIMIT 0, $record_count;";
$Recordset1 = mysql_query($query_Recordset1, $YBDB) or die(mysql_error());
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
//$handler->debug($query_Recordset1);
//Action on form update
$editFormAction = "";
@ -388,9 +318,9 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ConfirmDelete") &&
header(sprintf("Location: %s", PAGE_SALE_LOG . "?trans_id={$delete_trans_id}&" . $search_state )); //$editFormAction
}
//Change Date & Transaction Search isset($_POST["MM_update"]) =========================================================
//Change Date isset($_POST["MM_update"]) =========================================================
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {
$editFormAction = "?trans_date={$_POST['trans_date']}&trans_type={$_POST['trans_type']}&shop_dayname={$_POST['dayname']}&record_count={$_POST['record_count']}&contact_id_search={$_POST['contact_id_search']}&search={$_POST['search']}";
$editFormAction = "?trans_date={$_POST['trans_date']}&trans_type={$_POST['trans_type']}&shop_dayname={$_POST['dayname']}&record_count={$_POST['record_count']}";
header(sprintf("Location: %s",$editFormAction )); //$editFormAction
}
@ -710,8 +640,7 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {
<tr bordercolor="#CCCCCC" bgcolor="#CCCC33">
<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" /><span id="current_shop"></span>
</p>
<div></div>
</p>
</td>
</tr>
<input type="hidden" name="MM_insert" value="FormNew" />
@ -750,28 +679,15 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {
$result = mysql_fetch_assoc($sql);
if($result['anonymous']) {
echo "Anonymous";
$whoami = "Anonymous";
echo "Anonymous";
} else {
echo '<a style="color: rgb(27, 105, 30); text-decoration: none; cursor: crosshair;" href="individual_history_log.php?contact_id=' .
$row_Recordset1['contact_id'] . '">' .
$row_Recordset1['full_name'] . "</a>";
$whoami = '<a style="color: rgb(27, 105, 30); text-decoration: none; cursor: crosshair;" href="individual_history_log.php?contact_id=' .
$row_Recordset1['contact_id'] . '">' .
$row_Recordset1['full_name'] . "</a>";
}
?>&nbsp;</td>
<?php
// Highlight search results in Description
$description = $row_Recordset1['description_with_locations'];
if(!empty($_GET["search"])) {
$description = highlightKeywords($row_Recordset1['description_with_locations'],$_GET["search"]);
}
?>
<td <?php echo "title='Description: " . htmlspecialchars($row_Recordset1['description_with_locations'], ENT_QUOTES) . "'"; ?> ><?php echo $description; ?>&nbsp;</td>
<td <?php echo "title='Description: " . htmlspecialchars($row_Recordset1['description_with_locations'], ENT_QUOTES) . "'"; ?> ><?php echo $row_Recordset1['description_with_locations']; ?>&nbsp;</td>
<td><?php echo $row_Recordset1['payment_type']; ?>&nbsp;</td>
<td <?php
$history = json_decode($row_Recordset1['history']);
@ -783,25 +699,19 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {
$sql = mysql_query($query, $YBDB) or die(mysql_error());
$result = mysql_fetch_assoc($sql);
if ( $history[$key]->original_price ) {
$title = "Date: " . $history[$key]->date. "\r\n" .
"Sold By: " . $result['full_name']. "\r\n" .
$title = "Sold By: " . $result['full_name']. "\r\n" .
"Original Price: " . $history[$key]->original_price . "\r\n" .
"Paid: " . $history[$key]->amount . "\r\n" .
"Redeemed Hours: " . floatval($history[$key]->redeemed_hours);
echo "title='" . $title . "'";
} else {
$title = "Date: " . $history[$key]->date. "\r\n" .
"Transaction Performed By: " . $result['full_name'];
$title = "Transaction Performed By: " . $result['full_name'];
echo "title='" . $title . "'";
}
}
?>
><?php echo $row_Recordset1['format_amount'];
if($row_Recordset1['transaction_type'] !== "Deposit" && $row_Recordset1['paid'] == 1) {
$total = $total + $row_Recordset1['amount'];
}
?>&nbsp;</td>
><?php echo $row_Recordset1['format_amount']; ?>&nbsp;</td>
<td><?php $record_trans_id = $row_Recordset1['transaction_id'];
foreach ($_GET as $i => $value) {
if ($i != "trans_id") {
@ -862,32 +772,10 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {
<input type="hidden" name="shop_visit_id" value="<?php echo $row_Recordset1['transaction_id']; ?>">
</form>
<?php } //while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); // while Recordset1 ?>
<tr>
<td>TOTAL</td><td></td>
<td style="text-align: center;">Transactions: <?php echo $totalRows_Recordset1; ?></td>
<td><?php
if ($contact_id_state !== 'everyone') {
if ($whoami) {
echo $whoami;
} else {
$query = "SELECT CONCAT(last_name, ', ', first_name, ' ', middle_initial) AS full_name
FROM contacts WHERE contact_id=" . $contact_id_state . ";";
$sql = mysql_query($query, $YBDB) or die(mysql_error());
$result = mysql_fetch_assoc($sql);
echo '<a style="color: rgb(27, 105, 30); text-decoration: none; cursor: crosshair;" href="individual_history_log.php?contact_id=' .
$contact_id_state . '">' .
$result['full_name'] . "</a>";
}
}
?></td>
<td></td><td></td>
<td title="Updates on Transaction Search Submit">$<?php echo number_format((float)$total, 2, '.', ''); ?></td>
<td></td><td></td>
</tr>
</table> </tr>
<tr>
<td height="40" valign="bottom" style="white-space: nowrap;"><form id="form1" name="form1" method="post" action="">
<td height="40" valign="bottom"><form id="form1" name="form1" method="post" action="">
<br \>
<label for="transaction_search" style="font-weight:bold;">Transaction Search:</label>
<br \>
@ -928,12 +816,7 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {
<option value="Sunday">Sunday</option>
</select>
transaction type <?php list_transaction_types_withheader('trans_type', 'all_types'); ?> by
<?php list_contacts_select_contact(contact_id_search, $_GET['contact_id_search']);?> <br \> with these words
<input type="text" name="search" value="<?php echo $_GET[search]; ?>" />
transaction type <?php list_transaction_types_withheader('trans_type', 'all_types'); ?>
<input type="submit" name="Submit" value="Submit" />
<input type="hidden" name="MM_insert" value="ChangeDate" />
@ -991,12 +874,11 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {
echo "<td td style='vertical-align:inherit;'><input id='gnucash_csv_submit' type='submit' name='Submit' /></td></tr></table></form>";
?>
</td>
</td>
</tr>
</table>
<p>&nbsp;</p>
<?php include("include_footer.html"); ?>
<?php
mysql_free_result($Recordset1);
?>