Commit 4d29116d authored by Claire Kuchly's avatar Claire Kuchly
Browse files

management of purged data and modification retention date

parent c7997a10
......@@ -840,19 +840,28 @@ class tx_nG6_eid {
$all_runs = trim(t3lib_div::_GP('all_runs'));
$value = trim(t3lib_div::_GP('date_value'));
//Change date format
$date = explode('-', $value);
$timestamp = mktime (0, 0, 1, $date[1], $date[2], $date[0]);
$date = explode('/', $value);
$timestamp = mktime (0, 0, 1, $date[1], $date[0], $date[2]);
print json_encode(tx_nG6_db::update_purge_date( $all_runs, $all_analyses, "mail_sent_date",$timestamp));
} elseif ($type == 'refresh_purge_list') {
$max_retention_date = trim(t3lib_div::_GP('max_retention_date'));
$filter_size = trim(t3lib_div::_GP('filter_size'));
$with_laboratories = trim(t3lib_div::_GP('with_laboratories'));
$without_laboratories_id = trim(t3lib_div::_GP('without_lab'));
$create_users = trim(t3lib_div::_GP('create_users'));
//Change date format
print json_encode(tx_nG6_db::filter_list_retention_data_info($filter_size,$max_retention_date,$create_users, $with_laboratories));
}
print json_encode(tx_nG6_db::filter_list_retention_data_info($filter_size,$max_retention_date,$create_users, $without_laboratories_id));
} elseif ($type == 'refresh_retention_date') {
$all_analyses = trim(t3lib_div::_GP('all_analyses'));
$all_runs = trim(t3lib_div::_GP('all_runs'));
$value = trim(t3lib_div::_GP('date_value'));
//Change date format
$date = explode('/', $value);
$timestamp = mktime (0, 0, 1, $date[1], $date[0], $date[2]);
print json_encode(tx_nG6_db::update_purge_date( $all_runs, $all_analyses, "retention_date",$timestamp));
}
}
}
......
......@@ -66,6 +66,7 @@ class tx_nG6_db {
tx_nG6_db::update_field('tx_nG6_run', $run_id, $field, $value);
}
error_log("RETENTION DATE run:".$all_runs_ids." analyse:".$all_analyses_ids." filed: ".$field." value".$value." \n",3,"/save/ng6-test/src/nG6/ui/nG6/pi6/test.log");
foreach(explode(",", $all_analyses_ids) as $analyse_id){
tx_nG6_db::update_field('tx_nG6_analyze',$analyse_id,$field,$value);
}
......@@ -101,17 +102,17 @@ class tx_nG6_db {
}
function get_project_list_by_group_filter($create_user_id, $user_group){
function get_project_list_by_group_filter($create_user_id, $user_group_id){
$where="";
$list_project_id_filter_by_group="";
$list_project_id_laboratories="";
if($user_group !=""){
if($user_group_id !=""){
#select all project_id with group OR/AND without group
$queryParts=array(
'SELECT' => 'project_id',
'FROM' => 'tx_nG6_view_project_user',
'WHERE' => 'user_group IN ( '.$user_group .')',
'WHERE' => 'user_group IN ( '.$user_group_id .')',
'GROUPBY' => '',
'ORDERBY' => '',
'LIMIT' => ''
......@@ -119,29 +120,26 @@ class tx_nG6_db {
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
while($res_row= $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
if(!isset( $list_project_id_filter_by_group)){
$list_project_id_filter_by_group = $res_row['project_id'];
}else{
if( $list_project_id_filter_by_group != ""){
$list_project_id_filter_by_group .= ",".$res_row['project_id'];
}else{
$list_project_id_filter_by_group = $res_row['project_id'];
}
}
error_log($list_project_id_filter_by_group,3,"/save/ng6-test/src/nG6/ui/nG6/pi6/test.log");
$where .= "tx_nG6_view_project_user.project_id NOT IN (".$list_project_id_filter_by_group.")";
$where .= "uid NOT IN (".$list_project_id_filter_by_group.")";
}
if($create_user_id != ""){
if($where != ""){
$where .= "AND cruser_id IN (".$create_user_id.")";
$where .= " AND cruser_id IN (".$create_user_id.")";
}else{
$where .= "cruser_id IN (".$create_user_id.")";
}
}
error_log($where,3,"/save/ng6-test/src/nG6/ui/nG6/pi6/test.log");
$queryParts=array(
'SELECT' => 'uid AS project_id',
'FROM' => 'tx_nG6_project'
.' INNER JOIN tx_nG6_view_project_user ON tx_nG6_view_project_user.project_id = uid',
'FROM' => 'tx_nG6_project',
'WHERE' => $where,
'GROUPBY' => '',
'ORDERBY' => '',
......@@ -150,22 +148,26 @@ class tx_nG6_db {
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
while($res_row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
if(!isset ($list_project_id_laboratories)){
$list_project_id_laboratories=$res_row['project_id'];
if ($list_project_id_laboratories != "") {
$list_project_id_laboratories .=",".$res_row['project_id'];
}else{
$list_project_id_laboratories[$res_row['project_id']] .=",".$res_row['project_id'];
$list_project_id_laboratories=$res_row['project_id'];
}
}
error_log("WHERE : ".$where."\n",3,"/save/ng6-test/src/nG6/ui/nG6/pi6/test.log");
error_log("LIST project : ".$list_project_id_laboratories."\n",3,"/save/ng6-test/src/nG6/ui/nG6/pi6/test.log");
return ($list_project_id_laboratories);
}
function select_obsolete_list_retention_data_info() {
$where = ' DATEDIFF( FROM_UNIXTIME( retention_date ) , now( ) ) <0';
return (tx_nG6_db::select_list_retention_data_info($where));
}
function filter_list_retention_data_info($filter_size, $max_retention_date, $create_user_id, $user_group) {
function filter_list_retention_data_info($filter_size, $max_retention_date, $create_user_id, $user_group_id) {
$where = ' DATEDIFF( FROM_UNIXTIME( retention_date ) , now( ) ) <0';
if ($max_retention_date != "") {
$where = ' DATEDIFF( FROM_UNIXTIME( retention_date ) , STR_TO_DATE( "'.$max_retention_date.'", "%d/%m/%Y" ) ) <0';
......@@ -174,11 +176,15 @@ class tx_nG6_db {
$where .=" AND storage_size > $filter_size";
}
$project_list_ids = "";
if ($create_user_id != "" or $user_group != "") {
$project_list_ids = tx_nG6_db::get_project_list_by_group_filter($create_user_id,$user_group);
error_log("user group".$user_group_id."\n",3,"/save/ng6-test/src/nG6/ui/nG6/pi6/test.log");
if ($create_user_id != "" or $user_group_id != "") {
error_log(" \nFILTER USER ".$create_user_id."\n",3,"/save/ng6-test/src/nG6/ui/nG6/pi6/test.log");
error_log(" \nFILTER GROUP ID".$user_group_id."\n",3,"/save/ng6-test/src/nG6/ui/nG6/pi6/test.log");
$project_list_ids = tx_nG6_db::get_project_list_by_group_filter($create_user_id,$user_group_id);
$where .=" AND project_id in (" . $project_list_ids.")" ;
}
error_log("FILTER - WHERE : ".$where."\n",3,"/save/ng6-test/src/nG6/ui/nG6/pi6/test.log");
return (tx_nG6_db::select_list_retention_data_info($where));
}
......@@ -331,7 +337,7 @@ class tx_nG6_db {
if ($role == "create_user") {
$queryParts = array(
'SELECT' => 'tx_nG6_project.uid as pid, fe_groups.title as title, fe_groups.tx_nG6_organism as organism, fe_groups.tx_nG6_location as location',
'SELECT' => 'tx_nG6_project.uid as pid, fe_groups.title as title, fe_groups.uid as group_id , fe_groups.tx_nG6_organism as organism, fe_groups.tx_nG6_location as location',
'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 ',
......@@ -343,7 +349,7 @@ class tx_nG6_db {
//$where = "tx_nG6_project.cruser_id="
} else if ($role == "manager") {
$queryParts = array(
'SELECT' => 'tx_nG6_project.uid as pid, fe_groups.title as title, fe_groups.tx_nG6_organism as organism, fe_groups.tx_nG6_location as location',
'SELECT' => 'tx_nG6_project.uid as pid, fe_groups.title as title, fe_groups.uid as group_id , fe_groups.tx_nG6_organism as organism, fe_groups.tx_nG6_location as location',
'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 '
......@@ -362,6 +368,7 @@ class tx_nG6_db {
if (!isset ($by_title[$res_row['title']])) {
$by_title[$res_row['title']] = array(
'count' => 1,
'group_id' => $res_row['group_id'],
'organism' => $res_row['organism'],
'location' => $res_row['location']);
} else {
......
......@@ -329,7 +329,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<tbody>
{foreach $distribution key=group_name item=group_values}
<tr>
<td><center><input type="checkbox" class="chk_without_lab_element" value="{$group_name}"></center></td>
<td><center><input type="checkbox" class="chk_without_lab_element" value="{$group_values.group_id}"></center></td>
<td>{$group_name}</td>
</tr>
{/foreach}
......@@ -415,6 +415,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
With selection :
<div class="btn-group">
<button id="mail_sent" type="button" class="btn btn-sm btn-default" ><i class="glyphicon glyphicon-envelope"></i> Mark as mail sent </button>
<button id="retention_change" type="button" class="btn btn-sm btn-default"><i class="glyphicon glyphicon-refresh"></i> Change retention date </button>
<button id="purge" type="button" class="btn btn-sm btn-default"><i class="glyphicon glyphicon-minus"></i> purge data</button>
</div>
</th>
......
......@@ -366,21 +366,21 @@ $(function () {
//$('#purge_list').html('<div class="tx-nG6-wait">List generation, please wait ...</div>');
var filter_size = $("#filter_size").val(),
max_retention_date = $("#max_retention_date").val(),
with_lab=[],
without_lab=[],
create_users=[],
with_laboratories="",
without_laboratories="",
create_users_string="";
$(':checked[class^=chk_create_user').each(function(){
create_users.push($(this).val());
});
$(':checked[class^=chk_without_').each(function(){
with_lab.push($(this).val());
$(':checked[class^=chk_without_lab_').each(function(){
without_lab.push($(this).val());
});
with_laboratories = with_lab.join(',');
without_laboratories = without_lab.join(',');
create_users_string = create_users.join(',');
$.ajax({
url: "index.php?eID=tx_nG6&type=refresh_purge_list&max_retention_date="+max_retention_date+"&filter_size="+filter_size+"&create_users="+create_users_string+"&with_lab="+with_lab,
url: "index.php?eID=tx_nG6&type=refresh_purge_list&max_retention_date="+max_retention_date+"&filter_size="+filter_size+"&create_users="+create_users_string+"&without_lab="+without_laboratories,
dataType: 'json',
success: function(val, status, xhr) {
oTable = stat_tables["obsolete"];
......@@ -482,12 +482,66 @@ $(function () {
url: "index.php?eID=tx_nG6&type=purge_managment_mail&all_analyses="+all_analyses+"&all_runs="+all_runs+"&date_value="+date_send,
dataType: 'json',
success: function(val, status, xhr) {
console.log(val);
if(all_analyses == "" | all_runs == ""){
window.alert("You must choose runs and/or analysis. ");
}
$("#ng6modal").modal('hide');
console.log(val);
}
});
});
});
//change retention date
$("#retention_change").click(function(){
var all_runs="",
all_analyses="";
$(':checked[id^=chk_col').each(function(){
col_name=$(this).val();
$(':checked[id^=chk_project').each(function(){
project_id=$(this).val();
if (col_name.startsWith("r") ){
cur_run=$('input[id='+col_name+"_"+project_id+']').attr("values");
if (cur_run != ""){
all_runs+=cur_run+"," ;
}
}else{
cur_analyse = $('input[id='+col_name+"_"+project_id+']').attr("values");
if (cur_analyse != ""){
all_analyses+=cur_analyse+"," ;
}
}
});
});
$("#modal-label-tmpl").html("RetentionDate");
$("#modal-body-tmpl").html("Change retention date");
$("#modal-foot-tmpl").html('<div id="date_change_retention" class="input-group date" data-date="">'
+'<input id="change_retention_date" class="form-control" type="text" value="" data-date-format="dd/mm/yyyy" data-provide="datepicker" name="change_retention_date"/>'
+'</div>'
+'<button id="modal-btn-send" class="btn btn-primary">Change</button>');
$("#ng6modal").modal();
$("#modal-btn-send").click(function(){
date_send = $("#change_retention_date").val();
$.ajax({
url: "index.php?eID=tx_nG6&type=refresh_retention_date&all_analyses="+all_analyses+"&all_runs="+all_runs+"&date_value="+date_send,
dataType: 'json',
success: function(val, status, xhr) {
if(all_analyses == "" | all_runs == ""){
window.alert("You must choose runs and/or analysis. ");
}
$("#ng6modal").modal('hide');
console.log(val);
}
});
});
});
});
......
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