Commit 1c4bfd06 authored by Jerome Mariette's avatar Jerome Mariette
Browse files

menu statistics ok

parent cfb59259
...@@ -689,7 +689,7 @@ class tx_nG6_eid { ...@@ -689,7 +689,7 @@ class tx_nG6_eid {
} }
} }
print $res; print $res;
} elseif($type == 'project_repartition') { } elseif($type == 'project_data_repartition') {
$role = trim(t3lib_div::_GP('role')); $role = trim(t3lib_div::_GP('role'));
$by = trim(t3lib_div::_GP('by')); $by = trim(t3lib_div::_GP('by'));
print json_encode(tx_nG6_db::select_projects_repartition($role, $by)); print json_encode(tx_nG6_db::select_projects_repartition($role, $by));
......
...@@ -216,8 +216,8 @@ class tx_nG6_db { ...@@ -216,8 +216,8 @@ class tx_nG6_db {
if (!isset ($by_title[$res_row['title']])) { if (!isset ($by_title[$res_row['title']])) {
$by_title[$res_row['title']] = array( $by_title[$res_row['title']] = array(
'count' => 1, 'count' => 1,
'organism' => $row['organism'], 'organism' => $res_row['organism'],
'location' => $row['location']); 'location' => $res_row['location']);
} else { } else {
$by_title[$res_row['title']]['count'] += 1; $by_title[$res_row['title']]['count'] += 1;
} }
...@@ -244,8 +244,7 @@ class tx_nG6_db { ...@@ -244,8 +244,7 @@ class tx_nG6_db {
return ($by_location); return ($by_location);
} }
} }
/* /*
* Project functions * Project functions
*------------------------------------------------------------*/ *------------------------------------------------------------*/
......
...@@ -37,48 +37,94 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. ...@@ -37,48 +37,94 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<ul id="myTab" class="nav nav-tabs"> <ul id="myTab" class="nav nav-tabs">
<li class="active"><a href="#wf_monitoring" data-toggle="tab">Workflows monitoring</a></li> <li class="active"><a href="#wf_monitoring" data-toggle="tab">Workflows monitoring</a></li>
<li><a href="#project_stat" data-toggle="tab">Project statistics</a></li> <li><a href="#statistics" data-toggle="tab">Statistics</a></li>
<li><a href="#data_stat" data-toggle="tab">Data statistics</a></li>
</ul> </ul>
<div id="myTabContent" class="tab-content"> <div id="myTabContent" class="tab-content">
<div class="tab-pane fade in active" id="wf_monitoring"></div> <div class="tab-pane fade in active" id="wf_monitoring"></div>
<div class="tab-pane fade" id="project_stat"> <div class="tab-pane fade" id="statistics">
{include file="statistics_menu.tpl" prefix="project"} <div id="stat_menu">
<div id="project_graph"> </div>
</div> <legend>1. Which users should be considered ?</legend>
<label class="radio">
<div class="tab-pane fade" id="data_stat"> <input type="radio" name="users_to_consider" id="select_cruser" value="create_user" checked>
{include file="statistics_menu.tpl" prefix="data"} users who have added data
<div id="data_graph"> </div> </label>
<!-- <label class="radio">
<div id="size_chart"></div> <input type="radio" name="users_to_consider" id="select_owner" value="manager">
<div id="chart_options" class="form-inline"> users for whom data were made ​​available
<label class="control-label" for="group_list" style="font-size:12px">Select a user group</label> </label>
<select id="group_list"> <br />
<option value="0">All</option>
{foreach from=$group_list key=g_id item=g_val} <legend>2. How should they be grouped ?</legend>
<option value="{$g_val.uid}">{$g_val.title}</option> <label class="radio">
{/foreach} <input type="radio" name="group_by" id="by_laboratories" value="title" checked>
</select> by laboratories
&nbsp;&nbsp;&nbsp;
<label class="checkbox" style="font-size:12px">
<input id="chk_get_analyzes" type="checkbox">
Includes analyses
</label> </label>
&nbsp;&nbsp;&nbsp; <label class="radio">
<label class="checkbox" style="font-size:12px"> <input type="radio" name="group_by" id="by_organizations" value="organism">
<input id="chk_get_cumulative" type="checkbox"> by organization
Cumulate values
</label> </label>
<label class="radio">
<input type="radio" name="group_by" id="by_locations" value="location">
by location
</label>
<br />
<legend>3. Which <span id="by_span">laboratories</span> should be displayed ? <small> non selected ones will be gathered in the "others" group </small></legend>
<table class="table table-striped table-bordered dataTable" id="data_table_laboratories">
<thead>
<th><center><input type="checkbox" id="chk_all_laboratories"></center></th>
<th>Laboratories</th>
<th>Organizations</th>
<th>Locations</th>
<th>Number of project</th>
</thead>
<tbody>
{foreach $distribution key=group_name item=group_values}
<tr>
<td><center><input type="checkbox" value="{$group_name}"></center></td>
<td>{$group_name}</td>
<td>{$group_values.organism}</td>
<td>{$group_values.location}</td>
<td>{$group_values.count}</td>
</tr>
{/foreach}
</tbody>
</table>
<table class="table table-striped table-bordered dataTable" id="data_table_organizations">
<thead>
<th><center><input type="checkbox" id="chk_all_organizations"></center></th>
<th>Organizations</th>
<th>Number of project</th>
</thead>
<tbody></tbody>
</table>
<table class="table table-striped table-bordered dataTable" id="data_table_locations">
<thead>
<th><center><input type="checkbox" id="chk_all_locations"></center></th>
<th>Locations</th>
<th>Number of project</th>
</thead>
<tbody></tbody>
</table>
<br />
<div class="row">
<div class="span2 offset9">
<div class="btn-group" data-toggle="buttons-radio">
<button type="button" id="distribution" class="btn btn-primary"> <i class="icon-certificate icon-white"></i> distribution</button>
<button type="button" id="evolution" class="btn"><i class="icon-random"></i> evolution</button>
</div>
</div>
</div>
</div> </div>
--> <div id="project_graph"> </div>
</div> </div>
</div> </div>
</div> </div>
......
{*
Copyright (C) 2009 INRA
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*}
<div class="accordion" id="{$prefix}_stat_menu">
<legend>1. Which users should be considered ?</legend>
<label class="radio">
<input type="radio" name="users_to_consider_{$prefix}" id="select_cruser_{$prefix}" value="create_user" checked>
users who have added data
</label>
<label class="radio">
<input type="radio" name="users_to_consider_{$prefix}" id="select_owner_{$prefix}" value="manager">
users for whom data were made ​​available
</label>
<br />
<legend>2. How should they be grouped ?</legend>
<label class="radio">
<input type="radio" name="group_by_{$prefix}" id="by_laboratories_{$prefix}" value="title" checked>
by laboratories
</label>
<label class="radio">
<input type="radio" name="group_by_{$prefix}" id="by_organization_{$prefix}" value="organism">
by organization
</label>
<label class="radio">
<input type="radio" name="group_by_{$prefix}" id="by_location_{$prefix}" value="location">
by location
</label>
<br />
<legend>3. Which <span id="by_span_{$prefix}">laboratories</span> should be displayed ? <small> non selected ones will be gathered in the "others" group </small></legend>
<table class="table table-striped table-bordered dataTable" id="data_table_{$prefix}">
<thead>
<th><center><input type="checkbox" id="{$prefix}_chk_all_group"></center></th>
<th>Group name</th>
<th>Organism</th>
<th>Location</th>
<th>Number of project</th>
</thead>
<tbody>
{foreach $distribution key=group_name item=group_values}
<tr>
<td><center><input type="checkbox" id="{$prefix}_chk_group_" value="group_"></center></td>
<td>{$group_name}</td>
<td>{$group_values.organism}</td>
<td>{$group_values.location}</td>
<td>{$group_values.count}</td>
</tr>
{/foreach}
</tbody>
</table>
<br />
<div class="row">
<div class="span2 offset9">
<div class="btn-group" data-toggle="buttons-radio">
<button type="button" id="distribution_{$prefix}" class="btn btn-primary"> <i class="icon-certificate icon-white"></i> distribution</button>
<button type="button" id="evolution_{$prefix}" class="btn"><i class="icon-random"></i> evolution</button>
</div>
</div>
</div>
</div>
\ No newline at end of file
...@@ -266,3 +266,8 @@ div#chart_options{ ...@@ -266,3 +266,8 @@ div#chart_options{
background: white url('../img/mini_light_wait.gif') no-repeat; background: white url('../img/mini_light_wait.gif') no-repeat;
background-position: 98% 50%; /* x:right, y:center */ background-position: 98% 50%; /* x:right, y:center */
} }
.tx-nG6-hidden{
display: none;
}
}
\ No newline at end of file
...@@ -32,7 +32,7 @@ $(function () { ...@@ -32,7 +32,7 @@ $(function () {
redraw_chart(); redraw_chart();
// Init tables // Init tables
var groupTable = initGroupTable(); var stat_tables = initStatMenuDataTable();
// group list // group list
$("select[id=group_list]").change(function(){ $("select[id=group_list]").change(function(){
...@@ -49,28 +49,35 @@ $(function () { ...@@ -49,28 +49,35 @@ $(function () {
redraw_chart(); redraw_chart();
}); });
// statistics menu handling // statistics menu handling
$(':radio[id^=select_cruser_]').attr('checked','checked'); $(':radio[id=select_cruser]').attr('checked','checked');
$(':radio[id^=by_laboratories_]').attr('checked','checked'); $(':radio[id=by_laboratories]').attr('checked','checked');
$(':radio[id^=distribution_]').attr('checked','checked'); $(':radio[id=distribution]').attr('checked','checked');
$(":radio[id^=by_]").change(function(){ $(":radio[id^=by_]").change(function(){
var prefix = $(this).attr("id").split("_")[2]; var group_by = $(this).attr("id").split("_")[1];
$("#by_span_"+prefix).html(($(this).val())); $("#by_span").html(group_by);
refreshTable(prefix); refreshTable(stat_tables);
// Hidden others table
$("table[id^=data_table_]").each(function() {
if( $(this).attr('id') != "data_table_" + group_by ) {
$(this).parents('div.dataTables_wrapper').first().hide();
}
});
}); });
$(":radio[id^=select_]").change(function(){ $(":radio[id^=select_]").change(function(){
var prefix = $(this).attr("id").split("_")[2]; refreshTable(stat_tables);
refreshTable(prefix);
}); });
$("[id^=data_table_]").dataTable({
"aaSorting": [[ 1, "asc" ]],
"aoColumns": [
{ "bSortable": false },
null,
null,
null,
null]
});
...@@ -99,7 +106,6 @@ $(function () { ...@@ -99,7 +106,6 @@ $(function () {
url: "index.php?eID=tx_nG6&type=project_repartition&role=create_user", url: "index.php?eID=tx_nG6&type=project_repartition&role=create_user",
dataType: "json", dataType: "json",
success: function(data) { success: function(data) {
console.log(data);
$('#project_graph').highcharts({ $('#project_graph').highcharts({
chart: { chart: {
plotBackgroundColor: null, plotBackgroundColor: null,
...@@ -275,23 +281,61 @@ $(function () { ...@@ -275,23 +281,61 @@ $(function () {
}); });
function initGroupTable () {
var groupTable = $('#group_data_table').dataTable(); function initStatMenuDataTable () {
return groupTable; var stat_tables = {};
stat_tables["laboratories"] = $("[id^=data_table_laboratories]").dataTable({
"aaSorting": [[ 1, "asc" ]],
"aoColumns": [
{ "bSortable": false },
null,
null,
null,
null]
});
stat_tables["organizations"] = $("[id^=data_table_organizations]").dataTable({
"aaSorting": [[ 1, "asc" ]],
"aoColumns": [
{ "bSortable": false },
null,
null]
});
stat_tables["locations"] = $("[id^=data_table_locations]").dataTable({
"aaSorting": [[ 1, "asc" ]],
"aoColumns": [
{ "bSortable": false },
null,
null]
});
stat_tables["organizations"].parents('div.dataTables_wrapper').first().hide();
stat_tables["locations"].parents('div.dataTables_wrapper').first().hide();
return stat_tables;
} }
function refreshTable(kind) { function refreshTable(stat_tables) {
var role = $("[name=users_to_consider_"+kind+"]:checked").val(); var role = $("[name=users_to_consider]:checked").val();
var by = $("[name=group_by_"+kind+"]:checked").val(); var by = $("[name=group_by]:checked").val();
if (kind == "project") { var r_by = $("[name=group_by]:checked").attr("id").split("_")[1];
$.ajax({ $.ajax({
url: "index.php?eID=tx_nG6&type=project_repartition&role="+role+"&by="+by, url: "index.php?eID=tx_nG6&type=project_data_repartition&role="+role+"&by="+by,
dataType: 'json', dataType: 'json',
success: function(val, status, xhr) { success: function(val, status, xhr) {
console.log(val); oTable = stat_tables[ r_by];
} oTable.fnClearTable();
}); if( r_by == 'laboratories' ) {
} for( key in val ) {
var checkbox = '<center><input type="checkbox" value="' + key + '"></center>' ;
oTable.fnAddData( [checkbox, key, val[key]["organism"], val[key]["location"], val[key]["count"] ]);
}
} else {
for ( key in val ) {
var checkbox = '<center><input type="checkbox" value="' + key + '"></center>' ;
oTable.fnAddData( [checkbox, key, val[key]["count"] ]);
}
}
oTable.parents('div.dataTables_wrapper').first().show();
}
});
} }
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment