Commit f6e72598 authored by Celine Noirot's avatar Celine Noirot

Improve email ; List all project #18 ; Extend and remove a purge if project is linked to

parent 5c9e2015
......@@ -873,7 +873,7 @@ class tx_nG6_eid {
$res = tx_nG6_db::delete_purge_demand($purge_ids,$user_login, $user_pwd, $data_folder);
}
print $res;
} elseif ($type == 'extend_retention_date') {
} elseif ($type == 'extend_retention_date_from_demand') {
//Extend the retention date for the
$purge_ids = trim(t3lib_div::_GP('purge_demand'));
$value = trim(t3lib_div::_GP('date_value'));
......@@ -881,8 +881,19 @@ class tx_nG6_eid {
//Change date format
$date = explode('/', $value);
$timestamp = mktime (0, 0, 1, $date[1], $date[0], $date[2]);
print json_encode(tx_nG6_db::extend_retention_date(explode(',',$purge_ids),$timestamp,$type_extend));
}
print json_encode(tx_nG6_db::extend_retention_date_from_demand(explode(',',$purge_ids),$timestamp,$type_extend));
} elseif ($type == 'extend_retention_date_from_project') {
//Extend the retention date for the
$projects_id_str = trim(t3lib_div::_GP('projects_id'));
$value = trim(t3lib_div::_GP('date_value'));
//Change date format
$date = explode('/', $value);
$timestamp = mktime (0, 0, 1, $date[1], $date[0], $date[2]);
//TODO project
print json_encode(tx_nG6_db::extend_retention_date_from_project($projects_id_str,$timestamp, TRUE));
} elseif ($type == 'get_all_project') {
print json_encode(tx_nG6_db::select_all_projects());
}
}
}
......
This diff is collapsed.
......@@ -178,7 +178,7 @@ class tx_nG6_utils {
return $value;
}
function get_purge_email($project_name, $project_id, $nb_run_purgeable,$nb_analyse_purgeable, $demand_id,
function get_purge_mail($project_name, $project_id, $nb_run_purgeable,$nb_analyse_purgeable, $demand_id,
$purgeable_size, $project_size, $purge_delay, $url_price, $min_extention_duration,
$min_extention_size, $emails, $runs_list, $analyse_list) {
......@@ -187,7 +187,7 @@ Dear user,
The two years data storage period of your ###PROJECT_NAME### project (###nb_run### run(s) and ###nb_analyse### analyse(s)) is ended.
This purge alert No ###DEMAND_ID### corresponds to ###PURGEABLE_SIZE### purgeable data on ###PROJECT_SIZE### of whole project see list of impacted files below.
This purge alert No ###DEMAND_ID### corresponds to ###SIZE_STR### see list of impacted files below.
In ###PURGE_DELAY### days, your data will be deleted. Keep us informed if you wish to extend the storage period,
please have a look at our storage fees (###URL_PRICE###) and reply to this email with the following information:
......@@ -207,13 +207,17 @@ Files impacted of:
- runs names: ###RUNS_LIST###
- analyses ids: ###ANALYSES_LIST###
';
$size_str = $purgeable_size . " purgeable data on ". $project_size ." of whole project";
if ($purgeable_size == $project_size) {
$size_str = "whole project (".$purgeable_size . ")";
}
$search=array("###nb_run###","###nb_analyse###","###PROJECT_NAME###","###PROJET_ID###","###DEMAND_ID###",
"###EMAILS###","###RUNS_LIST###","###ANALYSES_LIST###","###PURGEABLE_SIZE###", "###PROJECT_SIZE###",
"###EMAILS###","###RUNS_LIST###","###ANALYSES_LIST###","###SIZE_STR###",
"###EXTENSION_DURATION###","###EXTENSION_SIZE###","###URL_PRICE###","###PURGE_DELAY###");
$replace=array($nb_run_purgeable,$nb_analyse_purgeable,$project_name,$project_id, $demand_id ,
$emails, $runs_list, $analyse_list, $purgeable_size,$project_size,
$emails, $runs_list, $analyse_list, $size_str,
$min_extention_duration, $min_extention_size, $url_price, $purge_delay);
$mail=str_replace($search, $replace, $template_mail);
......
......@@ -44,7 +44,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<li><a href="#wf_monitoring" data-toggle="tab">Workflows monitoring</a></li>
<li><a href="#project_data_management" data-toggle="tab">Mail obsolete project</a></li>
<li><a href="#purge_demand_management" data-toggle="tab">Process mail demands</a></li>
<li><a href="#list_all_project" data-toggle="tab">Extend project</a></li>
<li><a href="#all_project_extention" data-toggle="tab">Extend project</a></li>
</ul>
<div id="myTabContent" class="tab-content">
......@@ -444,8 +444,46 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</table>
</div> <!--end purge_demand_list-->
</div> <!--purge demand management-->
</div> <!--Extend projects-->
<div class="tab-pane fade" id="all_project_extention">
<div>
<p>
Following table contains all projects.</br>
</p>
</div>
<div class="tx-nG6-wait" id="all_project_wait">Please wait while processing ...</div>
<div class="alert alert-danger" id="all_project_error"></div>
<div id="all_project_list">
<table class="table table-striped table-bordered dataTable" id="data_table_allproject">
<thead>
<tr>
<th><center><input type="checkbox" id="all_chk_project"></center></th>
<th>Project name</th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
<tr>
<th align="left" colspan="2">
<div style="float: left;">
Select extention date :
<input id="input_extend_all_project" class="form-control" type="text" value="" data-date-format="dd/mm/yyyy" data-provide="datepicker" name="change_retention_date"/>
</div>
<div class="btn-group" style="float: right;">
<button id="btn_extend_all_project" type="button" class="btn btn-sm btn-default"><i class="glyphicon glyphicon-pencil"></i> Extend retention date </button>
</div>
</th>
</tr>
</tfoot>
</table>
</div> <!--all_project_list-->
</div> <!--Extend projects-->
</div>
......
......@@ -102,7 +102,7 @@ class tx_nG6_pi6 extends tslib_pibase {
return $smarty->fetch('administration_view.tpl');
}
function send_purge_demand_mail($user_id,$project_ids) {
function send_purge_demand_mail($project_ids) {
$project_name="";
foreach(explode(",", $project_ids) as $project_id){
......@@ -161,7 +161,7 @@ class tx_nG6_pi6 extends tslib_pibase {
//TODO RETURN TOTAL SIZE tx_nG6_utils::get_octet_string_representation($p[$project_id]["total_size"]
$total_project_size = tx_nG6_db::get_project_size($project_id, true) ;
$mail = tx_nG6_utils::get_purge_email($p[$project_id]["project_name"],$project_id, $nb_run_purgeable,$nb_analyse_purgeable, $purge_demand_id,
$mail = tx_nG6_utils::get_purge_mail($p[$project_id]["project_name"],$project_id, $nb_run_purgeable,$nb_analyse_purgeable, $purge_demand_id,
tx_nG6_utils::get_octet_string_representation($p[$project_id]["total_purgeable_size"]), tx_nG6_utils::get_octet_string_representation($total_project_size),
$GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['ng6']['delay_purge'],
$GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['ng6']['extension_url_price'], $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['ng6']['min_extension_duration'],
......@@ -174,11 +174,34 @@ class tx_nG6_pi6 extends tslib_pibase {
#TODO Uncomment
$to = "celine.noirot@inra.fr";
mail($to, $subject, $mail, implode("\r\n", $headers));
}
return implode("\r\n", $headers).$mail;
//TODO check return function mail ok
}
return "Mail sent";
}
function resend_purge_demand_mail ($demands_id) {
$res_demands = tx_nG6_db::get_purge_demand_from_id($demands_id);
foreach($res_demands as $res_demand){
$res_project = tx_nG6_db::select_project($res_demand["project_id"]);
$total_project_size = tx_nG6_db::get_project_size($res_demand["project_id"], true) ;
$mail = tx_nG6_utils::get_purge_mail($res_project["name"],$res_demand["project_id"],
count(explode(",", $res_demand["run_ids"])), count(explode(",", $res_demand["analyze_ids"])), $res_demand["demand_id"],
tx_nG6_utils::get_octet_string_representation($res_demand["purge_size"]), tx_nG6_utils::get_octet_string_representation($total_project_size),
$GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['ng6']['delay_purge'],
$GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['ng6']['extension_url_price'], $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['ng6']['min_extension_duration'],
$GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['ng6']['min_extension_size'], "This email was send to ". join(', ',$res_demand["emails"]).". ", $res_demand["run_ids"], $res_demand["analyze_ids"]);
$subject = '[nG6 purge / reminder] No '.$res_demand["demand_id"].' - Project '.$res_project["name"];
$headers[] = 'From: '.$GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['ng6']['email_from'];
$headers[] = 'X-Mailer: PHP/' . phpversion();
$to= join(",",$res_demand["emails"]);
#TODO Uncomment
$to = "celine.noirot@inra.fr";
mail($to, $subject, $mail, implode("\r\n", $headers));
}
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/nG6/pi6/class.tx_nG6_pi6.php']) {
......
This diff is collapsed.
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