<?php

$relPath = "./../../pinc/";
include_once $relPath . 'base.inc';
include_once 'common.inc';
require_login();
$graph = new Graph(800, 500, get_image_cache_filename(), 60);
$n_pages_ = array();
$n_available_pages_ = array();
$res = mysql_query("\n    SELECT state, SUM(n_pages), SUM(n_available_pages)\n    FROM projects\n    WHERE state != 'proj_submit_pgposted' AND state != 'project_delete'\n    GROUP BY state\n") or die(mysql_error());
while (list($state, $sum_n_pages, $sum_n_available_pages) = mysql_fetch_row($res)) {
    $n_pages_[$state] = $sum_n_pages;
    $n_available_pages_[$state] = $sum_n_available_pages;
}
$stage_labels = array();
$unavail_n_pages = array();
$waiting_n_pages = array();
$available_n_pages = array();
$progordone_n_pages = array();
// ---------------
$stage_labels[] = 'New';
$unavail_n_pages[] = $n_pages_[PROJ_NEW];
$waiting_n_pages[] = 0;
$available_n_pages[] = 0;
$progordone_n_pages[] = 0;
foreach ($Round_for_round_id_ as $round) {
    $stage_labels[] = $round->id;
    $unavail_n_pages[] = @$n_pages_[$round->project_unavailable_state] + @$n_pages_[$round->project_bad_state];
    $waiting_n_pages[] = @$n_pages_[$round->project_waiting_state];
    $available_n_pages[] = @$n_available_pages_[$round->project_available_state];
    $progordone_n_pages[] = @$n_pages_[$round->project_available_state] - @$n_available_pages_[$round->project_available_state] + @$n_pages[$round->project_complete_state];
include_once 'common.inc';
// This image shows the total number of pages remaining in each round.
// The red bars show the rounds that have more than the average number
// of pages (calculated as the total number of pages over the number of
// rounds). Because this image shows the total number of pages in each
// round, it will not noticeably change day-to-day unless something
// drastic occurs in a given round.
//
// see also: http://www.pgdp.net/wiki/Round_backlog_graphs
// Start with creating the Graph, this enables the use of the cache
// where possisble
$width = 300;
$height = 200;
$cache_timeout = 59;
# in minutes
$graph = new Graph($width, $height, get_image_cache_filename(), $cache_timeout);
// Pull all interested phases, primarily all the rounds and PP
$interested_phases = array_keys($Round_for_round_id_);
$interested_phases[] = "PP";
// Pull the stats data out of the database
$stats = get_round_backlog_stats($interested_phases);
// get the total of all phases
$stats_total = array_sum($stats);
// If this is a new system there won't be any stats so don't divide by zero
if ($stats_total == 0) {
    dpgraph_error(_("No pages found."));
}
// calculate the goal percent as 100 / number_of_phases
$goal_percent = ceil(100 / count($stats));
// colors
$barColors = array();
<?php

$relPath = "./../../pinc/";
include_once $relPath . 'base.inc';
include_once $relPath . 'page_tally.inc';
include_once "common.inc";
// Create the graph. We do this before everything else
// to make use of the jpgraph cache if enabled.
// Last value controls how long the graph is cached for in minutes.
$graph = new Graph(640, 400, get_image_cache_filename(), 1440);
///////////////////////////////////////////////////////////////////
//Number of users who have done X pages, and how recently logged in
//(time scales used: ever, last 90 days, last 28 days, last 7 days)
// define threshold timestamps
$seconds_per_day = 24 * 60 * 60;
$now = time();
$t_90_days_ago = $now - 90 * $seconds_per_day;
$t_28_days_ago = $now - 28 * $seconds_per_day;
$t_7_days_ago = $now - 7 * $seconds_per_day;
// how many bars in the graph?
$result0 = mysql_query("\n    SELECT max({$user_ELR_page_tally_column}) as maxpages FROM users {$joined_with_user_ELR_page_tallies} \n");
$maxpages = mysql_result($result0, 0, "maxpages");
//query db and put results into arrays
$result = mysql_query("\n    SELECT\n        {$user_ELR_page_tally_column}        AS pagescompleted,\n        COUNT(*)                         AS n_all,\n        SUM(last_login > {$t_90_days_ago}) AS n_90d,\n        SUM(last_login > {$t_28_days_ago}) AS n_28d,\n        SUM(last_login > {$t_7_days_ago})  AS n_7d\n    FROM users {$joined_with_user_ELR_page_tallies}\n    GROUP BY pagescompleted\n    ORDER BY pagescompleted ASC\n");
// Initialize the data arrays for all 'possible' values of pagescompleted
// (many of which won't be the current value for any particular user).
//
for ($pagescompleted_i = 0; $pagescompleted_i <= $maxpages; $pagescompleted_i++) {
    $datax[$pagescompleted_i] = $pagescompleted_i;
    $datayAll[$pagescompleted_i] = 0;
    $datay90[$pagescompleted_i] = 0;