Skip to content

Commit

Permalink
Fixed issue #8926: Add filtered participants to a survey adds ALL par…
Browse files Browse the repository at this point in the history
…ticipants to the survey
  • Loading branch information
c-schmitz committed Apr 14, 2014
1 parent 24a1a6c commit 3ee523d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 76 deletions.
5 changes: 3 additions & 2 deletions application/controllers/admin/participantsaction.php
Expand Up @@ -681,13 +681,14 @@ function getaddtosurveymsg()
*/
function getSearchIDs()
{
$searchcondition = basename(Yii::app()->request->getPost('searchcondition')); // get the search condition from the URL
$searchcondition = Yii::app()->request->getPost('searchcondition'); // get the search condition from the URL
$sSearchURL = basename(Yii::app()->request->getPost('searchURL')); // get the search condition from the URL
/* a search contains posted data inside $_POST['searchcondition'].
* Each separate query is made up of 3 fields, separated by double-pipes ("|")
* EG: fname||eq||jason||lname||ct||c
*
*/
if ($searchcondition != 'getParticipants_json') // if there is a search condition present
if ($sSearchURL != 'getParticipants_json') // if there is a search condition present
{
$participantid = "";
$condition = explode("||", $searchcondition); // explode the condition to the array
Expand Down
78 changes: 4 additions & 74 deletions scripts/admin/participantdisplay.js
Expand Up @@ -559,7 +559,10 @@ $(document).ready(function() {
if(rows=="") { /* All in grid */
$.post(
getSearchIDs,
{ searchcondition: jQuery('#displayparticipants').jqGrid('getGridParam','url')},
{
searchcondition: searchconditions,
searchURL: jQuery('#displayparticipants').jqGrid('getGridParam', 'url')
},
function(data) {
$('#count').val(totalitems);
$('#participant_id').val(data);
Expand Down Expand Up @@ -640,79 +643,6 @@ $(document).ready(function() {
return path.replace(/\\/g,'/').replace( /.*\//, '' );
}

$('#addtosurvey').click(function() {
var selected = "";
var myGrid = $("#displayparticipants").jqGrid();
/* the rows variable will contain the UUID of individual items that been ticked in the jqGrid */
/* if it is empty, then no items have been ticked */
var rows = myGrid.getGridParam('selarrrow');

if(rows=="") {
var totalitems = myGrid.getGridParam('records');
$('#allinview').text(addAllInViewTxt.replace('%s', totalitems));
$('#allinview').show();
$('#selecteditems').hide();
} else {
var totalitems = rows.length;
$('#selecteditems').text(addSelectedItemsTxt.replace('%s', totalitems));
$('#selecteditems').show();
$('#allinview').hide();
}

var dialog_buttons={};
dialog_buttons[mapButton]=function(){
var survey_id=$('#survey_id').val();
var redirect ="";
if(survey_id===null) {
/* No survey has been selected */
alert(selectSurvey);
} else {
/* Check if user wants to see token table after adding new participants */
if(jQuery('#redirect').is(":checked")) {
redirect = "redirect";
} else {
redirect = "";
}
/* Submit the form with appropriate options depending on whether
individual users are selected, or the whole grid is to be copied */
if(rows=="") { /* All in grid */
$.post(
getSearchIDs,
{ searchcondition: jQuery('#displayparticipants').jqGrid('getGridParam','url')},
function(data) {
$('#count').val(totalitems);
$('#participant_id').val(data);
$("#addsurvey").submit();
});
} else { /* Add selected (checked) jqGrid items only */
rows = myGrid.getGridParam('selarrrow');
$('#count').val(totalitems);
$('#participant_id').val(rows);
$("#addsurvey").submit();
}
}
};
dialog_buttons[cancelBtn]=function(){
$(this).dialog("close");
};
/* End of building array containing button functions */

$("#addsurvey").dialog({
height: 500,
width: 500,
title : addsurvey,
modal: true,
open: function(event, ui) {
$('#addsurvey').dialog('option', 'title', addsurvey + ' ('+totalitems+')');
},
buttons: dialog_buttons
});

if (!($("#survey_id").length > 0)) {
$('#addsurvey').html(addpartErrorMsg);
}
});

function editModifier(id, subgrid_id, method) {
var parid = id.split('_');
var participant_id = $("#displayparticipants_"+parid[0]+"_t").getCell(id,'participant_id');
Expand Down

0 comments on commit 3ee523d

Please sign in to comment.