Commit 8277886f authored by Penom Nom's avatar Penom Nom
Browse files

Draft project evolution.

parent 179608e9
......@@ -698,7 +698,12 @@ class tx_nG6_eid {
$by = trim(t3lib_div::_GP('by'));
$role = trim(t3lib_div::_GP('role'));
print json_encode(tx_nG6_db::select_projects_distribution($values, $by, $role));
}
} elseif($type == 'project_evolution') {
$values = split(",", trim(t3lib_div::_GP('values')));
$by = trim(t3lib_div::_GP('by'));
$role = trim(t3lib_div::_GP('role'));
print json_encode(tx_nG6_db::select_projects_evolution($values, $by, $role));
}
}
/**
......
......@@ -245,6 +245,41 @@ class tx_nG6_db {
}
}
function select_projects_evolution($values, $by, $role) {
if ($by == "organism" || $by == "location") {
$by = "tx_nG6_".$by;
}
$from = "" ;
$where = "fe_groups.".$by." IN ('".implode("', '", $values)."')" ;
if ($role == "create_user") {
$from = 'tx_nG6_project '
.' INNER JOIN fe_users ON tx_nG6_project.cruser_id=fe_users.uid '
.' INNER JOIN fe_groups ON fe_groups.uid=fe_users.usergroup ' ;
} else if ($role == "manager") {
$from = 'tx_nG6_project '
.' INNER JOIN fe_rights ON tx_nG6_project.uid=fe_rights.project_id '
.' INNER JOIN fe_users ON fe_rights.fe_user_id=fe_users.uid '
.' INNER JOIN fe_groups ON fe_groups.uid=fe_users.usergroup ';
$where .= " fe_rights.right_id=1" ;
}
$queryParts = array(
'SELECT' => 'tx_nG6_projects.timestamp, count(tx_nG6_projects.timestamp) nb',
'FROM' => $from,
'WHERE' => $where,
'GROUPBY' => 'tx_nG6_projects.timestamp',
'ORDERBY' => '',
'LIMIT' => ''
);
$results = array();
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
while($res_row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$results[] = array($res_row["tx_nG6_projects.timestamp"], $res_row["nb"]);
}
return $results;
}
function select_projects_distribution($values, $by, $role) {
$from = "" ;
$where = "" ;
......
......@@ -231,6 +231,36 @@ $(function () {
});
function projectEvolutionHandler() {
$("table[id^=data_table_]").each(function(){
if ($(this).parent('div.dataTables_wrapper').first().css("display") != 'none') {
var group_by = $("[name=group_by]:checked").val();
var real_group = "laboratories";
if (group_by == "organism") {
real_group = "organizations";
} else if (group_by == "location") {
real_group = "locations";
}
var role = $("[name=users_to_consider]:checked").val();
var values = new Array();
$(this).find(":checked").each(function(){
values.push($(this).val());
});
$.ajax({
url: "index.php?eID=tx_nG6&type=project_evolution&by="+group_by+"&role="+role+"&values="+values.join(","),
dataType: 'json',
success: function(val, status, xhr) {
// reformat the data with values to integer
for (var i=0; i <val.length; i++ ) {
val[i][1] = parseInt(val[i][1]);
}
console.log(val);
}
});
}
});
}
function projectDistributionHandler() {
$("table[id^=data_table_]").each(function(){
if ($(this).parent('div.dataTables_wrapper').first().css("display") != 'none') {
......
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