Commit 9ded8886 authored by Celine Noirot's avatar Celine Noirot
Browse files

Merge branch 'issue#161.2' into 'dev'

Merge branch issue#161.2 with dev

See merge request !97
parents 7b958d66 848db491
...@@ -914,9 +914,16 @@ class tx_nG6_eid { ...@@ -914,9 +914,16 @@ class tx_nG6_eid {
} elseif ($type == 'purge_managment_mail') { } elseif ($type == 'purge_managment_mail') {
$all_projects = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('project')); $all_projects = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('project'));
print json_encode(tx_nG6_pi6::send_purge_demand_mail($all_projects)); $with_extension = 1;
print json_encode(tx_nG6_pi6::send_purge_demand_mail($all_projects,$with_extension));
} elseif ($type == 'purge_managment_mail_without_extension') {
$all_projects = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('project'));
$with_extension = 0;
print json_encode(tx_nG6_pi6::send_purge_demand_mail($all_projects,$with_extension));
} elseif ($type == 'purge_managment_resend_mail') { } elseif ($type == 'purge_managment_resend_mail') {
$purge_ids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('purge_demand')); $purge_ids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('purge_demand'));
print json_encode(tx_nG6_pi6::resend_purge_demand_mail($purge_ids)); print json_encode(tx_nG6_pi6::resend_purge_demand_mail($purge_ids));
} elseif ($type == 'refresh_purge_demand') { } elseif ($type == 'refresh_purge_demand') {
$purge_delay = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('purge_delay')); $purge_delay = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('purge_delay'));
......
...@@ -201,9 +201,9 @@ class tx_nG6_utils { ...@@ -201,9 +201,9 @@ class tx_nG6_utils {
static function get_purge_mail($project_name, $project_id, $nb_run_purgeable,$nb_analyse_purgeable, $demand_id, static 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, $purgeable_size, $project_size, $purge_delay, $url_price, $min_extention_duration,
$min_extention_size, $emails, $runs_list, $analyse_list) { $min_extention_size, $emails, $runs_list, $analyse_list, $with_extension) {
$template_mail= ' $template_mail='
<html> <html>
<head> <head>
<title>Data Purge on nG6</title> <title>Data Purge on nG6</title>
...@@ -215,18 +215,24 @@ class tx_nG6_utils { ...@@ -215,18 +215,24 @@ class tx_nG6_utils {
<p>This purge alert No ###DEMAND_ID### corresponds to ###SIZE_STR### see list of impacted files below.</p> <p>This purge alert No ###DEMAND_ID### corresponds to ###SIZE_STR### see list of impacted files below.</p>
<p>In ###PURGE_DELAY### days, your data will be deleted. Keep us informed if you wish to extend the storage period, <p>In ###PURGE_DELAY### days, your data will be deleted.</p>';
please have a look at our storage fees (<a href="###URL_PRICE###">###URL_PRICE###</a>) and reply to this email with the following information:</p>
<p>----------------------------------------------</p>
<ul><li>Demand number: ###DEMAND_ID###</li>
<li>Request for extension term: XXX (minimal unit: ###EXTENSION_DURATION###)</li>
<li>Request for extension size: XXX (mininal unit: ###EXTENSION_SIZE###)</li>
<li>Laboratory name/Institution: </li></ul>
<p>----------------------------------------------</p>
<p>###EMAILS###We would appreciate if you could group your demands by laboratory.</p> if($with_extension){
$template_mail .= '<p>Keep us informed if you wish to extend the storage period,
please have a look at our storage fees (<a href="###URL_PRICE###">###URL_PRICE###</a>) and reply to this email with the following information:</p>
<p>----------------------------------------------</p>
<ul><li>Demand number: ###DEMAND_ID###</li>
<li>Request for extension term: XXX (minimal unit: ###EXTENSION_DURATION###)</li>
<li>Request for extension size: XXX (mininal unit: ###EXTENSION_SIZE###)</li>
<li>Laboratory name/Institution: </li></ul>
<p>----------------------------------------------</p>
<p>Yours sincerely</p> <p>###EMAILS###We would appreciate if you could group your demands by laboratory.</p>';
}else{
$template_mail .= '<p>###EMAILS###</p>';
}
$template_mail.='<p>Yours sincerely</p>
<p>nG6 team (for GeT-Genotoul and Bioinfo-Genotoul facilities)</p> <p>nG6 team (for GeT-Genotoul and Bioinfo-Genotoul facilities)</p>
<p>Files impacted of:</p> <p>Files impacted of:</p>
......
...@@ -451,6 +451,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. ...@@ -451,6 +451,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
With selection : With selection :
<div class="btn-group"> <div class="btn-group">
<button id="btn_obsolete_mail" type="button" class="btn btn-sm btn-default" ><i class="glyphicon glyphicon-envelope"></i> Send mail </button> <button id="btn_obsolete_mail" type="button" class="btn btn-sm btn-default" ><i class="glyphicon glyphicon-envelope"></i> Send mail </button>
<button id="btn_obsolete_mail_without_extension" type="button" class="btn btn-sm btn-default" ><i class="glyphicon glyphicon-envelope"></i> Send mail without extension</button>
</div> </div>
</th> </th>
</tr> </tr>
......
...@@ -106,9 +106,9 @@ class tx_nG6_pi6 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin { ...@@ -106,9 +106,9 @@ class tx_nG6_pi6 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
return $smarty->fetch('administration_view.tpl'); return $smarty->fetch('administration_view.tpl');
} }
static function send_purge_demand_mail($project_ids) { static function send_purge_demand_mail($project_ids, $extension_allowed = 1) {
$project_name=""; $project_name="";
foreach(explode(",", $project_ids) as $project_id){ foreach(explode(",", $project_ids) as $project_id){
#retrieve project data #retrieve project data
...@@ -197,13 +197,13 @@ class tx_nG6_pi6 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin { ...@@ -197,13 +197,13 @@ class tx_nG6_pi6 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
#Build corresponding string array #Build corresponding string array
//TODO RETURN TOTAL SIZE tx_nG6_utils::get_octet_string_representation($p[$project_id]["total_size"] //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); $total_project_size = tx_nG6_db::get_project_size($project_id, true);
$mail = tx_nG6_utils::get_purge_mail($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), tx_nG6_utils::get_octet_string_representation($p[$project_id]["total_purgeable_size"]), tx_nG6_utils::get_octet_string_representation($total_project_size),
$GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["delay_purge"], $GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["delay_purge"],
$GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["extension_url_price"], $GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["min_extension_duration"], $GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["extension_url_price"], $GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["min_extension_duration"],
$GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["min_extension_size"], $email_warn, join(', ', $run_info), join(', ', $analyses_info)); $GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["min_extension_size"], $email_warn, join(', ', $run_info), join(', ', $analyses_info), $extension_allowed);
$to = $purge_email_to; $to = $purge_email_to;
$subject = '[nG6 purge] No '.$purge_demand_id.' - Project '.$p[$project_id]["project_name"]; $subject = '[nG6 purge] No '.$purge_demand_id.' - Project '.$p[$project_id]["project_name"];
$headers[] = 'From: '.$GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["email_from"]; $headers[] = 'From: '.$GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["email_from"];
...@@ -245,20 +245,13 @@ class tx_nG6_pi6 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin { ...@@ -245,20 +245,13 @@ class tx_nG6_pi6 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
} }
//We now use join(', ', $run_info) and join(', ', $analyses_info) in get_purge_mail(). //We now use join(', ', $run_info) and join(', ', $analyses_info) in get_purge_mail().
/* $extension_allowed = 1;
$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['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["delay_purge"],
$GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["extension_url_price"], $GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["min_extension_duration"],
$GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["min_extension_size"], "This email was send to ". join(', ',$res_demand["emails"]).". ", $res_demand["run_ids"], $res_demand["analyze_ids"]);
*/
$mail = tx_nG6_utils::get_purge_mail($res_project["name"],$res_demand["project_id"], $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"], 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), tx_nG6_utils::get_octet_string_representation($res_demand["purge_size"]), tx_nG6_utils::get_octet_string_representation($total_project_size),
$GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["delay_purge"], $GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["delay_purge"],
$GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["extension_url_price"], $GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["min_extension_duration"], $GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["extension_url_price"], $GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["min_extension_duration"],
$GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["min_extension_size"], "This email was send to ". join(', ',$res_demand["emails"]).". ", join(', ', $run_info), join(', ', $analyses_info)); $GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["min_extension_size"], "This email was send to ". join(', ',$res_demand["emails"]).". ", join(', ', $run_info), join(', ', $analyses_info), $extension_allowed);
$subject = '[nG6 purge / reminder] No '.$res_demand["demand_id"].' - Project '.$res_project["name"]; $subject = '[nG6 purge / reminder] No '.$res_demand["demand_id"].' - Project '.$res_project["name"];
$headers[] = 'From: '.$GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["email_from"]; $headers[] = 'From: '.$GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["email_from"];
......
...@@ -567,6 +567,38 @@ $(function () { ...@@ -567,6 +567,38 @@ $(function () {
} }
}); });
}); });
$("#btn_obsolete_mail_without_extension").click(function(){
$('#data_table_obsolete_wait').show();
$('#obsolete_list').hide();
var all_project=Array();
$("#ng6modal").modal('hide');
all_project = getPurgeDatatableCheckedValue(purge_table["obsolete"], "obsolete")
$.ajax({
url: "index.php?eID=tx_nG6&type=purge_managment_mail_without_extension&project="+all_project.join(',')+"&user_id="+$('input[id=user_id]').val(),
dataType: 'json',
success: function(val, status, xhr) {
refresh_project_obsolete(purge_table["obsolete"]);
refresh_purge_demand(purge_table["demand"]);
$("#purge_demand_error").hide()
},
error: function(returnval){
alert(returnval.status)
//TODO Afficher alerte en cas d'erreur de mail
var message = 'nG6 was unable to perform your action.';
if (returnval.status == 401){
message = 'it seems your session expired. Please re-authenticate!';
}
$('#data_table_obsolete_wait').hide();
$("#data_table_obsolete_error").html("<div class='tx-nG6-pi6-error'>Error : "+message+"</div>");
$("#data_table_obsolete_error").show();
$('#obsolete_list').show();
}
});
});
/**************************************** /****************************************
* tab process mail demand * tab process mail demand
......
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