Browse Source

Adds a Calendar Date Picker (PickMeUp).

This is nice stuff, always a delight to utilize ajax.  More stat pages may have
this change with stats.js operated globally.
devel
Jonathan Rosenbaum 9 years ago
parent
commit
d26dc1cef1
  1. 86
      css/pickmeup.css
  2. 4
      include_header_stats.html
  3. 1141
      js/jquery.pickmeup.js
  4. 85
      stats/status_totals.php

86
css/pickmeup.css

@ -0,0 +1,86 @@
/**
* @package PickMeUp - jQuery datepicker plugin
* @author Nazar Mokrynskyi <nazar@mokrynskyi.com>
* @author Stefan Petre <www.eyecon.ro>
* @copyright Copyright (c) 2013-2015, Nazar Mokrynskyi
* @copyright Copyright (c) 2008-2009, Stefan Petre
* @license MIT License, see license.txt
*/
.pickmeup {
background: #000;
border-radius: 0.4em;
-moz-box-sizing: content-box;
box-sizing: content-box;
display: none;
position: absolute; }
.pickmeup * {
-moz-box-sizing: border-box;
box-sizing: border-box; }
.pickmeup .pmu-instance {
display: inline-block;
height: 13.8em;
padding: .5em;
text-align: center;
width: 15em; }
.pickmeup .pmu-instance .pmu-button {
color: #eee;
cursor: pointer;
outline: none;
text-decoration: none; }
.pickmeup .pmu-instance .pmu-today {
background: #17384d;
color: #88c5eb; }
.pickmeup .pmu-instance .pmu-button:hover {
background: "transparent";
color: #88c5eb; }
.pickmeup .pmu-instance .pmu-not-in-month {
color: #666; }
.pickmeup .pmu-instance .pmu-disabled,
.pickmeup .pmu-instance .pmu-disabled:hover {
color: #333;
cursor: default; }
.pickmeup .pmu-instance .pmu-selected {
background: #136a9f;
color: #eee; }
.pickmeup .pmu-instance .pmu-not-in-month.pmu-selected {
background: #17384d; }
.pickmeup .pmu-instance nav {
color: #eee;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
line-height: 2em; }
.pickmeup .pmu-instance nav *:first-child :hover {
color: #88c5eb; }
.pickmeup .pmu-instance nav .pmu-prev,
.pickmeup .pmu-instance nav .pmu-next {
display: none;
height: 2em;
width: 1em; }
.pickmeup .pmu-instance nav .pmu-month {
width: 14em; }
.pickmeup .pmu-instance .pmu-years *,
.pickmeup .pmu-instance .pmu-months * {
display: inline-block;
line-height: 3.6em;
width: 3.5em; }
.pickmeup .pmu-instance .pmu-day-of-week {
color: #999;
cursor: default; }
.pickmeup .pmu-instance .pmu-day-of-week *,
.pickmeup .pmu-instance .pmu-days * {
display: inline-block;
line-height: 1.5em;
width: 2em; }
.pickmeup .pmu-instance .pmu-day-of-week * {
line-height: 1.8em; }
.pickmeup .pmu-instance:first-child .pmu-prev,
.pickmeup .pmu-instance:last-child .pmu-next {
display: block; }
.pickmeup .pmu-instance:first-child .pmu-month,
.pickmeup .pmu-instance:last-child .pmu-month {
width: 13em; }
.pickmeup .pmu-instance:first-child:last-child .pmu-month {
width: 12em; }
.pickmeup:not(.pmu-view-days) .pmu-days, .pickmeup:not(.pmu-view-days) .pmu-day-of-week, .pickmeup:not(.pmu-view-months) .pmu-months, .pickmeup:not(.pmu-view-years) .pmu-years {
display: none; }

4
include_header_stats.html

@ -24,9 +24,11 @@ function resetTimer()
<link href="../css/transactions.css" rel="stylesheet" type="text/css" /> <link href="../css/transactions.css" rel="stylesheet" type="text/css" />
<link href="../css/contacts.css" rel="stylesheet" type="text/css" /> <link href="../css/contacts.css" rel="stylesheet" type="text/css" />
<link href="../css/css_yb_standard.css" rel="stylesheet" type="text/css" /> <link href="../css/css_yb_standard.css" rel="stylesheet" type="text/css" />
<link href="../css/pickmeup.css" rel="stylesheet" type="text/css" />
<script src="../js/jquery-2.1.1.js"></script> <script src="../js/jquery-2.1.1.js"></script>
<script src="../js/jquery.pickmeup.js"></script>
<script src="../js/stats.js"></script>
</head> </head>

1141
js/jquery.pickmeup.js

File diff suppressed because it is too large

85
stats/status_totals.php

@ -9,19 +9,48 @@ mysql_select_db($database_YBDB, $YBDB);
// SELECT shop_user_role_id FROM shop_user_roles WHERE volunteer=1 AND other_volunteer!=1;; // SELECT shop_user_role_id FROM shop_user_roles WHERE volunteer=1 AND other_volunteer!=1;;
// Defaults
$query = "SELECT shop_user_role, COUNT(DISTINCT shop_hours.contact_id) as unique_volunteers,
COUNT(shop_hours.contact_id) as volunteer_visits, $today = date("Y/m/d");
ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), $year_ago = date("Y/m/d", strtotime("$today -1 year"));
TIME(time_in)))/60)) AS volunteer_hours
$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;
}
$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(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS volunteer_hours
FROM shop_hours FROM shop_hours
LEFT JOIN contacts ON shop_hours.contact_id = contacts.contact_id 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 LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id
WHERE shop_user_roles.volunteer = 1 WHERE (time_in > DATE_SUB(CURDATE(),INTERVAL $days_range1 DAY) AND time_in <= DATE_SUB(CURDATE(), INTERVAL $days_range2 DAY))
OR shop_user_roles.other_volunteer = 1 AND (shop_user_roles.volunteer = 1 OR shop_user_roles.other_volunteer = 1)
AND time_in > DATE_SUB(CURDATE(),INTERVAL 12 MONTH) GROUP BY shop_user_role GROUP BY shop_user_role ORDER BY volunteer_hours DESC;";
ORDER BY volunteer_hours DESC;"; $volunteers_sql = mysql_query($query, $YBDB) or die(mysql_error());
$volunteers_sql = mysql_query($query, $YBDB) or die(mysql_error());
$query = "SELECT COUNT(DISTINCT shop_hours.contact_id) as unique_volunteers, $query = "SELECT COUNT(DISTINCT shop_hours.contact_id) as unique_volunteers,
COUNT(shop_hours.contact_id) as volunteer_visits, COUNT(shop_hours.contact_id) as volunteer_visits,
@ -29,9 +58,8 @@ $query = "SELECT COUNT(DISTINCT shop_hours.contact_id) as unique_volunteers,
FROM shop_hours FROM shop_hours
LEFT JOIN contacts ON shop_hours.contact_id = contacts.contact_id 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 LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id
WHERE shop_user_roles.volunteer = 1 WHERE (time_in > DATE_SUB(CURDATE(),INTERVAL $days_range1 DAY) AND time_in <= DATE_SUB(CURDATE(), INTERVAL $days_range2 DAY))
OR shop_user_roles.other_volunteer = 1 AND (shop_user_roles.volunteer = 1 OR shop_user_roles.other_volunteer = 1);";
AND time_in > DATE_SUB(CURDATE(),INTERVAL 12 MONTH);";
$total_volunteers_sql = mysql_query($query, $YBDB) or die(mysql_error()); $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, $query = "SELECT shop_user_role, COUNT(DISTINCT shop_hours.contact_id) as unique_visitors,
@ -41,9 +69,9 @@ $query = "SELECT shop_user_role, COUNT(DISTINCT shop_hours.contact_id) as unique
FROM shop_hours FROM shop_hours
LEFT JOIN contacts ON shop_hours.contact_id = contacts.contact_id 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 LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id
WHERE shop_user_roles.volunteer = 0 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 = 0 AND (shop_user_roles.volunteer = 0 AND shop_user_roles.other_volunteer = 0)
AND time_in > DATE_SUB(CURDATE(),INTERVAL 12 MONTH) GROUP BY shop_user_role GROUP BY shop_user_role
ORDER BY hours DESC;"; ORDER BY hours DESC;";
$visitors_sql = mysql_query($query, $YBDB) or die(mysql_error()); $visitors_sql = mysql_query($query, $YBDB) or die(mysql_error());
@ -53,9 +81,8 @@ $query = "SELECT COUNT(DISTINCT shop_hours.contact_id) as unique_visitors,
FROM shop_hours FROM shop_hours
LEFT JOIN contacts ON shop_hours.contact_id = contacts.contact_id 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 LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id
WHERE shop_user_roles.volunteer = 0 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 = 0 AND (shop_user_roles.volunteer = 0 AND shop_user_roles.other_volunteer = 0);";
AND time_in > DATE_SUB(CURDATE(),INTERVAL 12 MONTH);";
$total_visitors_sql = mysql_query($query, $YBDB) or die(mysql_error()); $total_visitors_sql = mysql_query($query, $YBDB) or die(mysql_error());
$query = "SELECT COUNT(DISTINCT shop_hours.contact_id) as unique_vv, $query = "SELECT COUNT(DISTINCT shop_hours.contact_id) as unique_vv,
@ -64,9 +91,8 @@ $query = "SELECT COUNT(DISTINCT shop_hours.contact_id) as unique_vv,
FROM shop_hours FROM shop_hours
LEFT JOIN contacts ON shop_hours.contact_id = contacts.contact_id 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 LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id
WHERE shop_user_roles.volunteer >= 0 WHERE (time_in > DATE_SUB(CURDATE(),INTERVAL $days_range1 DAY) AND time_in <= DATE_SUB(CURDATE(), INTERVAL $days_range2 DAY))
OR shop_user_roles.other_volunteer >= 0 AND (shop_user_roles.volunteer >= 0 OR shop_user_roles.other_volunteer >= 0);";
AND time_in > DATE_SUB(CURDATE(),INTERVAL 12 MONTH);";
$total_sql = mysql_query($query, $YBDB) or die(mysql_error()); $total_sql = mysql_query($query, $YBDB) or die(mysql_error());
?> ?>
@ -213,11 +239,22 @@ $total_sql = mysql_query($query, $YBDB) or die(mysql_error());
</table> </td> </table> </td>
</tr> </tr>
</table> </table>
<br \><br \>
<div id="range_input">Date Range: <?php echo "$year_ago - $today"; ?></div>
<div id="range"></div>
<br \>
<form method="post" name="range_query">
<input id="submit_contact" type="submit" value="Submit" tabindex="14">
</form>
<?php include("../include_footer.html"); ?> <?php include("../include_footer.html"); ?>
<?php <?php
mysql_free_result($volunteers_sql); mysql_free_result($volunteers_sql);
mysql_free_result($total_volunteers_sql); mysql_free_result($total_volunteers_sql);
mysql_free_result($visitors_sql); mysql_free_result($visitors_sql);
mysql_free_result($total_visitors_sql); mysql_free_result($total_visitors_sql);
mysql_free_result($total_sql);
?> ?>

Loading…
Cancel
Save