Commit 7789af45 authored by Romain Therville's avatar Romain Therville 🐭

Update to the "Admin > Process mail demands" tab

2 search criterias have been added, filter on space (project space_id)
and delay exceeded (yes or no).

And there is a new "Refresh list" button to handle the new filters.

issue #161
parent 2b23b278
......@@ -920,7 +920,9 @@ class tx_nG6_eid {
print json_encode(tx_nG6_pi6::resend_purge_demand_mail($purge_ids));
} elseif ($type == 'refresh_purge_demand') {
$purge_delay = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('purge_delay'));
print json_encode(tx_nG6_db::get_purge_demand_list($purge_delay));
$purge_demand_filter_space = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('purge_demand_filter_space'));
$purge_demand_filter_delay_exceeded = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('purge_demand_filter_delay_exceeded'));
print json_encode(tx_nG6_db::get_purge_demand_list($purge_delay,$purge_demand_filter_space,$purge_demand_filter_delay_exceeded));
} elseif ($type == 'refresh_purge_list') {
$max_retention_date = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('max_retention_date'));
$filter_space = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('filter_space'));
......
......@@ -419,7 +419,21 @@ class tx_nG6_db {
}
static function get_purge_demand_list($delay_in_days){
static function get_purge_demand_list($delay_in_days,$space_filter,$delay_exceeded_filter){
#We first build the WHERE conditions from the given parameters
if ($space_filter != "") {
$conditions[] = "space_id = '$space_filter'";
}
//For an unknown reason, we can't use the alias 'delay_excedeed' in the WHERE clause...
if ($delay_exceeded_filter == 'yes') {
$conditions[] = "DATEDIFF( now( ), FROM_UNIXTIME( tx_nG6_purge_demand.mail_sent_date ) ) >".$delay_in_days;
}elseif($delay_exceeded_filter == 'no'){
$conditions[] = "DATEDIFF( now( ), FROM_UNIXTIME( tx_nG6_purge_demand.mail_sent_date ) ) <".$delay_in_days;
}
$conditions[] = '`tx_nG6_purge_demand`.processed_date IS NULL';
$where = join(' AND ', $conditions);
#select all demand id not processed
$queryParts=array(
'SELECT' => 'tx_nG6_purge_demand.uid AS demand_id, `tx_nG6_purge_demand`.project_id AS project_id, tx_nG6_project.name as project_name,
......@@ -431,11 +445,14 @@ INNER JOIN tx_nG6_project ON tx_nG6_project.uid = tx_nG6_purge_demand.project_id
INNER JOIN `tx_nG6_purge_demand_fe_users` ON `tx_nG6_purge_demand_fe_users`.`purge_demand_id` = tx_nG6_purge_demand.uid
INNER JOIN fe_users ON fe_users.uid = `tx_nG6_purge_demand_fe_users`.`fe_users_id`
INNER JOIN fe_groups ON fe_groups.uid = fe_users.usergroup',
'WHERE' => '`tx_nG6_purge_demand`.processed_date IS NULL',
'WHERE' => $where,
'GROUPBY' => '',
'ORDERBY' => '',
'LIMIT' => ''
);
file_put_contents ('/work/ng6-test/jflow_rtherville/ng6_php.log',"IN tx_nG6_db.php, get_purge_demand_list. queryParts=".print_r($queryParts,TRUE));
$results=array();
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
while($res_row= $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
......
......@@ -467,6 +467,41 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</p>
</div>
<div class="col-sm-6">
<fieldset class="col-sm-12">
<h4>1. Filter on space</h4>
<div class="text">
<select name="space_select_options" id="purge_demand_filter_space" >
<option value="">No filter</option>
{foreach $available_space_ids key=space_id item=space_name}
<option value="{$space_name}">{$space_name}</option>
{/foreach}
</select>
</div>
</fieldset>
</div>
<div class="col-sm-6">
<fieldset class="col-sm-12">
<h4>2. Delay exceeded : </h4>
<div class="text">
<select name="delay_exceeded_options" id="purge_demand_filter_delay_exceeded" >
<option value="">No filter</option>
<option value="yes">Yes</option>
<option value="no">No</option>
</select>
</div>
</fieldset>
</div>
<div class="row">
<div class="col-sm-offset-10 col-sm-2">
<button type="button" id="refresh_purge_demands_list_btn" class="multiple-selection-btn btn btn-primary"> <i class="glyphicon glyphicon-refresh"></i> Refresh list</button>
</div>
</div>
</br>
<div class="tx-nG6-wait" id="data_table_purge_demand_wait">Please wait while processing ...</div>
<div class="alert alert-danger" id="purge_demand_error"></div>
<div id="purge_demand_list">
......
......@@ -571,6 +571,12 @@ $(function () {
/****************************************
* tab process mail demand
***************************************/
//refresh purge demands list button
$("#refresh_purge_demands_list_btn").click(function(){
refresh_purge_demand(purge_table["demand"]);
});
//resend email
$("#btn_demand_resend_mail").click(function(){
var demands = getPurgeDatatableCheckedValue(purge_table["demand"],"demand");
......@@ -814,12 +820,15 @@ $(function () {
}
function refresh_purge_demand(purge_demand_datatable){
var purge_delay=$("#purge_delay").val();
var purge_demand_filter_delay_exceeded = $("#purge_demand_filter_delay_exceeded").val();
var purge_demand_filter_space = $("#purge_demand_filter_space").val();
$("#purge_demand_error").hide();
$('#data_table_purge_demand_wait').show();
$('#purge_demand_list').hide();
$.ajax({
url: "index.php?eID=tx_nG6&type=refresh_purge_demand&purge_delay="+purge_delay,
url: "index.php?eID=tx_nG6&type=refresh_purge_demand&purge_delay="+purge_delay+"&purge_demand_filter_space="+purge_demand_filter_space+"&purge_demand_filter_delay_exceeded="+purge_demand_filter_delay_exceeded,
dataType: 'json',
success: function(val, status, xhr) {
oTable = purge_demand_datatable;
......
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