Commit 8786b756 authored by Celine Noirot's avatar Celine Noirot

add project extention from a purge demand #17

parent 38e805d5
......@@ -882,18 +882,19 @@ class tx_nG6_eid {
}
print $res;
}
} elseif ($type == 'extend_rentention_date') {
} elseif ($type == 'extend_retention_date') {
//Extend the retention date for the
//TODO check if user is still logged
if ($user_id == ""){
print json_encode("Error: reconnect");
} else {
$purge_ids = trim(t3lib_div::_GP('purge_demand'));
$value = trim(t3lib_div::_GP('date_value'));
$value = trim(t3lib_div::_GP('date_value'));
$type_extend = trim(t3lib_div::_GP('type_extend')); //all project or only run/analyse obsolete
//Change date format
$date = explode('/', $value);
$timestamp = mktime (0, 0, 1, $date[1], $date[0], $date[2]);
print json_encode(tx_nG6_pi6::extend_rentention_date(explode(',',$purge_ids),$timestamp));
print json_encode(tx_nG6_pi6::extend_retention_date(explode(',',$purge_ids),$timestamp,$type_extend));
}
}
......
......@@ -189,16 +189,21 @@ class tx_nG6_db {
return (tx_nG6_db::select_list_retention_data_info($where));
}
function select_a_project_retention_data_info($project_id) {
$where = ' DATEDIFF( FROM_UNIXTIME( retention_date ) , now( ) ) <0';
$where .=" AND project_id = " . $project_id ;
function select_a_project_retention_data_info($project_id=null, $all=FALSE) {
$condition=Array();
if ($all === FALSE) {
$condition[]='DATEDIFF( FROM_UNIXTIME( retention_date ) , now( ) ) <0';
}
if (null != $project_id) {
$condition[]="project_id = " . $project_id ;
}
$where = join( ' AND ', $condition);
return(tx_nG6_db::select_list_retention_data_info($where));
}
function select_list_retention_data_info($where) {
$by_project=array();
$empty_res_structure = array(
'project_id' => "",
'project_name' => "",
'state' => array("purged" => array ('nb_run' => 0, 'size_run' => 0, 'run_ids'=> array(),
"nb_analyze"=> 0, "size_analyze"=> 0, 'analysis_ids'=> array()),
......
......@@ -205,16 +205,35 @@ Files impacted of:
return implode("\r\n", $headers).$mail;
}
function extend_rentention_date($demand_ids, $date){
function extend_retention_date($demand_ids, $date, $type_extend){
//TODO extend thanks to the type
//extend
$all_demands=tx_nG6_db::get_purge_demand_from_id($demand_ids);
$all_demands=tx_nG6_db::get_purge_demand_from_id( join(', ', $demand_ids));
$all_runs=array();
$all_analyses=array();
foreach($all_demands as $res){
if ($res["state"] != "deleted")
{
$all_analyses=array_merge($all_analyses,explode(',',$res["analyze_ids"]));
if ($type_extend == 'extend_all_project') {
//extend all project
$curr_project_id=$res["project_id"];
// get all info of a project even non obsolete run analyse (by TRUE parameter)
$curr_project=tx_nG6_db::select_a_project_retention_data_info($curr_project_id, TRUE);
$states = array('extended','stored') ;
foreach ($states as $state){
//list all analyse (run/project)
$all_analyses=array_merge($all_analyses,$curr_project[$curr_project_id]["state"][$state]['analysis_ids']);
//list all run
$all_runs=array_merge($all_runs,$curr_project[$curr_project_id]["state"][$state]['run_ids']);
}
}
else {
$all_analyses=array_merge($all_analyses,explode(',',$res["analyze_ids"]));
$all_runs=array_merge($all_runs,explode(',',$res["run_ids"]));
}
}
}
tx_nG6_db::update_field('tx_nG6_run', $all_runs,
......
......@@ -493,21 +493,34 @@ function extend_date(list_ids, purge_demand_datatable, obsolete_project_datatabl
$("#modal-label-tmpl").html("Extend retention date");
$("#modal-body-tmpl").html('<div class="form-group param-field">'
+'<fieldset>'
+'<label id="label_default" class="col-sm-2 control-label" for="username">Extend retention date to : </label>'
+'<div class="col-sm-10">'
+'<label id="label_default" class="col-sm-4 control-label" for="change_retention_date">Select extention date: </label>'
+'<div class="col-sm-8">'
+'<input id="change_retention_date" class="form-control" type="text" value="" data-date-format="dd/mm/yyyy" data-provide="datepicker" name="change_retention_date"/>'
+'<span class="help-block">Select a date</span>'
+'</fieldset>'
+'<fieldset>'
+'<legend>Extend for</legend>'
+'<div class="col-sm-8">'
+'<input type="radio" id="extend_purgeable_element" name="is_all_project" checked />'
+'<label for="extend_purgeable_element">Only obsolete run and analyse</label><br/>'
+'<input type="radio" id="extend_all_project" name="is_all_project" />'
+'<label for="extend_all_project">The projects entirelly</label>'
+'</fieldset>'
+'</div>');
$("#modal-foot-tmpl").html('<button id="close" class="btn btn-default" data-dismiss="modal"><i class="glyphicon glyphicon-remove"></i> Close</button> </div> '
+'<button id="modal-btn-send-extend" class="btn btn-primary">Change</button>');
$("#ng6modal").modal();
+'<button id="modal-btn-send-extend" class="btn btn-primary" disabled="true">Change</button>');
$("#ng6modal").modal();
$("#change_retention_date").change(function(){
$("#modal-btn-send-extend").prop('disabled', false);
});
$("#modal-btn-send-extend").click(function(){
date_send = $("#change_retention_date").val();
type_extend = $('input[type=radio][name=is_all_project]:checked').attr('id');
$('#data_table_purge_demand_wait').show();
$('#purge_demand_list').hide();
$.ajax({
url: "index.php?eID=tx_nG6&type=extend_rentention_date&purge_demand="+list_ids+"&date_value="+date_send+"&user_id="+$('input[id=user_id]').val(),
url: "index.php?eID=tx_nG6&type=extend_retention_date&purge_demand="+list_ids+"&date_value="+date_send+"&user_id="+$('input[id=user_id]').val()+'&type_extend='+type_extend,
dataType: 'json',
success: function(val, status, xhr) {
$("#ng6modal").modal('hide');
......@@ -630,7 +643,6 @@ function refresh_project_obsolete(obsolete_project_datatable){
row.push("-")
}
row.push(get_octet_string_representation(values["total_purgeable_size"],2))
console.log("nb_purgeable_element: ", nb_purgeable_element,"; nb_all_element ", nb_all_element);
if (nb_purgeable_element != nb_all_element) {
row.push("open")
}else{
......
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