Browse Source

This implements etherpad (#39) for individual_history_log!

devel
Jonathan Rosenbaum 7 years ago
parent
commit
959fc08092
  1. 16
      Connections/database_functions.php
  2. 1
      include_header.html
  3. 4
      individual_history_log.php
  4. 29
      js/reports.js
  5. 48
      json/reports.php

16
Connections/database_functions.php

@ -273,6 +273,22 @@ $gnucash_accounts = array( "Assets:Current Assets:Checking Account" => "checking
// Normally, you will want this set at 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.
//
// See https://github.com/ether/etherpad-lite-jquery-plugin for information about configurations.
$etherpad = array(
"host" => "",
"userName" => "PositiveSpin",
"noColors" => true,
"height" => "75%",
"plugins" => array()
);
// END OF USER DEFINED CONFIGURATIONS

1
include_header.html

@ -44,6 +44,7 @@ function resetTimer()
<script src="js/ui/jquery-ui.js"></script>
<script src="js/moment/moment.js"></script>
<script src="js/tabulator/dist/js/tabulator.min.js"></script>
<script src="js/etherpad.js"></script>
</head>

4
individual_history_log.php

@ -25,4 +25,6 @@ include("include_header.html");
<a class="stats-right stats-btn" href="#">Next &#10095;</a>
</div>
<?php include("include_footer.html"); ?>
<?php include("include_footer.html"); ?>
<div id="individual_history_pad"></div>

29
js/reports.js

@ -6,6 +6,7 @@ $(function(){
var contact_id = $("#contact_id").text();
// Basic prev and next buttons, and enhanced version would go in order of login per shop
if (contact_id) {
$("table").attr("width","");
@ -39,7 +40,19 @@ $(function(){
$.post("json/reports.php", { name: 1, contact_id: contact_id }, function (data) {
if (data) {
var obj = $.parseJSON(data);
$("#name").text(obj.full_name)
$("#name").text(obj.full_name);
var pad_name = "pad_contact_id_" + contact_id;
if ( obj.configurations.host ) {
$("#individual_history_pad").pad({
"padId": pad_name,
"host": obj.configurations.host,
"showControls": true,
"height": obj.configurations.height,
"userName": obj.configurations.userName,
"noColors": obj.configurations.noColors,
"plugins" : obj.configurations.plugins
});
}
}
}); // name
@ -96,6 +109,20 @@ $(function(){
}); // tabulator
} // if contact_id
// stats_userhours
if ( document.location.pathname.match(/stats_userhours_new\.php$/) ) {
// everyone
$.post("/json/reports.php", { everyone: 1 }, function (data) {
if (data) {
var obj = $.parseJSON(data);
}
}); // everyone
} // status_userhours
function off(cell){
return false;

48
json/reports.php

@ -29,6 +29,8 @@ $handler->start();
WHERE contact_id=" . $_POST['contact_id'] .";";
$sql = mysql_query($query, $YBDB) or die(mysql_error());
$result = mysql_fetch_assoc($sql);
$etherpad_conf["configurations"] = $etherpad;
$result = (object)array_merge((array)$result, (array)$etherpad_conf);
echo json_encode($result);
}
@ -81,5 +83,51 @@ $handler->start();
} // individual_history
// Return everyone
if (isset($_POST['everyone'])) {
$interval = 1;
$query = "SELECT * FROM (SELECT contacts.contact_id, CONCAT(contacts.first_name, ' ', contacts.middle_initial, ' ',contacts.last_name) 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
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
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
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 shop_user_roles.volunteer = 1
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
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 $interval MONTH)
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
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 shop_user_roles.volunteer = 1 AND time_in > DATE_SUB(CURDATE(),INTERVAL $interval MONTH)
GROUP BY contacts.contact_id
ORDER BY last_name, first_name) AS volunteer_hours3 ON total_hours.contact_id = volunteer_hours3.vh3_contact_id;";
$sql = mysql_query($query, $YBDB) or die(mysql_error());
$result = mysql_fetch_assoc($sql);
echo json_encode($result);
} // return everyone
?>

Loading…
Cancel
Save