mirror of
https://github.com/fspc/Yellow-Bike-Database.git
synced 2025-02-23 01:03:23 -05:00
Fixes a bug, and adds membership_benefits function for easier querying.
This commit is contained in:
parent
ff0142aa30
commit
f1daa79213
@ -147,7 +147,6 @@ $timezone = TIMEZONE;
|
|||||||
|
|
||||||
$result = (object)array_merge((array)$result, (array)$result2);
|
$result = (object)array_merge((array)$result, (array)$result2);
|
||||||
|
|
||||||
|
|
||||||
echo json_encode($result);
|
echo json_encode($result);
|
||||||
|
|
||||||
} // Volunteer Benefits
|
} // Volunteer Benefits
|
||||||
@ -155,6 +154,7 @@ $timezone = TIMEZONE;
|
|||||||
// Stand Time
|
// Stand Time
|
||||||
if (isset($_POST['stand_time'])) {
|
if (isset($_POST['stand_time'])) {
|
||||||
|
|
||||||
|
|
||||||
// use the most recent login status; can do calculations here
|
// use the most recent login status; can do calculations here
|
||||||
// ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60))
|
// ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60))
|
||||||
// SUBSTRING_INDEX(time_in, ' ', 1)
|
// SUBSTRING_INDEX(time_in, ' ', 1)
|
||||||
@ -172,6 +172,8 @@ $timezone = TIMEZONE;
|
|||||||
$sql = mysql_query($query, $YBDB) or die(mysql_error());
|
$sql = mysql_query($query, $YBDB) or die(mysql_error());
|
||||||
while ( $results = mysql_fetch_assoc($sql) ) {
|
while ( $results = mysql_fetch_assoc($sql) ) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$sign_in = new DateTime($results['time_in'], new DateTimeZone($timezone));
|
$sign_in = new DateTime($results['time_in'], new DateTimeZone($timezone));
|
||||||
$sign_out = new DateTime("", new DateTimeZone($timezone));
|
$sign_out = new DateTime("", new DateTimeZone($timezone));
|
||||||
|
|
||||||
@ -207,11 +209,11 @@ $timezone = TIMEZONE;
|
|||||||
} elseif($total_minutes != $stand_time_remainder && $stand_time_remainder > $stand_time_grace_period) { // outside grace period
|
} elseif($total_minutes != $stand_time_remainder && $stand_time_remainder > $stand_time_grace_period) { // outside grace period
|
||||||
$answer = "outside grace period $hours $minutes";
|
$answer = "outside grace period $hours $minutes";
|
||||||
$stand_time = $hours + 1;
|
$stand_time = $hours + 1;
|
||||||
} elseif($total_minutes == $stand_time_remainder && $difference->i > $stand_time_grace_period) { // 1hr or less outside grace period
|
} elseif($total_minutes == $stand_time_remainder && $minutes > $stand_time_grace_period) { // 1hr or less outside grace period
|
||||||
$answer = "1hr or less $hours $minutes";
|
$answer = "1hr or less $hours $minutes";
|
||||||
$stand_time = 1;
|
$stand_time = 1;
|
||||||
} elseif($total_minutes <= $stand_time_grace_period) { // first hour still within grace period
|
} elseif($total_minutes <= $stand_time_grace_period) { // first hour still within grace period
|
||||||
$answer = "less than 1hr and within grace period $difference->h $difference->i";
|
$answer = "less than 1hr and within grace period $hours $minutes";
|
||||||
$stand_time = $hours;
|
$stand_time = $hours;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -577,4 +579,24 @@ $timezone = TIMEZONE;
|
|||||||
|
|
||||||
} // End Deposit Calculator
|
} // End Deposit Calculator
|
||||||
|
|
||||||
|
function membership_benefits($contact_id) {
|
||||||
|
|
||||||
|
global $database_YBDB, $YBDB;
|
||||||
|
mysql_select_db($database_YBDB, $YBDB);
|
||||||
|
|
||||||
|
$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,
|
||||||
|
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=" .
|
||||||
|
$contact_id .
|
||||||
|
" ORDER by membership_start DESC;";
|
||||||
|
|
||||||
|
$sql = mysql_query($query, $YBDB) or die(mysql_error());
|
||||||
|
$result = mysql_fetch_assoc($sql);
|
||||||
|
return $result;
|
||||||
|
|
||||||
|
} // end membership_benefits
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
x
Reference in New Issue
Block a user