From: Maxious Date: Tue, 06 Mar 2012 06:43:47 +0000 Subject: chart employee growth X-Git-Url: https://maxious.lambdacomplex.org/git/?p=disclosr.git&a=commitdiff&h=31f18df0cec7293d0e673dfafa81cf8122b67c20 --- chart employee growth Former-commit-id: acae8c2c66e158f5126706b9308a5a8282cb4d3c --- --- a/.gitmodules +++ b/.gitmodules @@ -10,10 +10,10 @@ [submodule "lib/php-diff"] path = lib/php-diff url = https://github.com/chrisboulton/php-diff.git -[submodule "javascripts/flot"] - path = javascripts/flot - url = https://github.com/paradoxxxzero/flot.git [submodule "lib/Requests"] path = lib/Requests url = https://github.com/rmccue/Requests.git +[submodule "javascripts/flotr2"] + path = javascripts/flotr2 + url = https://github.com/HumbleSoftware/Flotr2.git --- /dev/null +++ b/admin/exportEmployees.csv.php @@ -1,1 +1,86 @@ +get_db('disclosr-agencies'); +try { + $rows = $db->get_view("app", "all", null, true)->rows; + + $dataValues = Array(); + foreach ($rows as $row) { + if (isset($row->value->statistics->employees)) { + + $headers = array_unique(array_merge($headers, array_keys(object_to_array($row->value->statistics->employees)))); + } + } +} catch (SetteeRestClientException $e) { + setteErrorHandler($e); +} + +$fp = fopen('php://output', 'w'); +if ($fp && $db) { + if ($format == "csv") { + header('Content-Type: text/csv; charset=utf-8'); + header('Content-Disposition: attachment; filename="export.employeestats.' . date("c") . '.csv"'); + } + header('Pragma: no-cache'); + header('Expires: 0'); + if ($format == "csv") { + fputcsv($fp, $headers); + } else if ($format == "json") { + echo '{ + "labels" : ["' . implode('","', $headers) . '"],'.PHP_EOL; + } + try { + $agencies = $db->get_view("app", "all", null, true)->rows; + //print_r($agencies); + $first = true; + if ($format == "json") { + echo '"data" : ['.PHP_EOL; + + } + foreach ($agencies as $agency) { + + if (isset($agency->value->statistics->employees)) { + $row = Array(); + $agencyEmployeesArray = object_to_array($agency->value->statistics->employees); + foreach ($headers as $i => $fieldName) { + if (isset($agencyEmployeesArray[$fieldName])) { + $row[] = '['.$i.','.$agencyEmployeesArray[$fieldName]["value"].']'; + } else { + $row[] = '['.$i.',0]'; + } + } + if ($format == "csv") { + fputcsv($fp, array_values($row)); + } else if ($format == "json") { + if (!$first) echo ","; + echo '{"data" : [' . implode(",", array_values($row)) . '], "label": "'.$agency->value->name.'", "lines" : { "show" : true }, "points" : { "show" : true }}'.PHP_EOL; + $first = false; + } + } + } + if ($format == "json") { + echo '] + }'.PHP_EOL; + + } + } catch (SetteeRestClientException $e) { + setteErrorHandler($e); + } + + die; +} +?> + --- a/charts.php +++ b/charts.php @@ -2,99 +2,130 @@ include_once('include/common.inc.php'); include_header(); $db = $server->get_db('disclosr-agencies'); - - ?>

Charts

Lorem ipsum.

-
+
+
- + - - + --- a/javascripts/flot +++ /dev/null --- /dev/null +++ b/javascripts/flotr2