Skip to content

Commit

Permalink
Fixed issue #13131: Edit survey participant --> "Invitation sent?" an…
Browse files Browse the repository at this point in the history
…d "Reminder Sent" can't be reset
  • Loading branch information
lacrioque committed Jan 8, 2018
1 parent f60823d commit 19243cf
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 25 deletions.
2 changes: 1 addition & 1 deletion application/controllers/admin/tokens.php
Expand Up @@ -769,7 +769,7 @@ public function edit($iSurveyId, $iTokenId, $ajax = false)
$aTokenData['validuntil'] = $request->getPost('validuntil');
$aTokenData['remindersent'] = flattenText($request->getPost('remindersent'));
$aTokenData['remindercount'] = intval(flattenText($request->getPost('remindercount')));
$udresult = Token::model($iSurveyId)->findAll("tid <> '$iTokenId' and token <> '' and token = '$sSanitizedToken'");
$udresult = Token::model($iSurveyId)->findAll("tid <> :tid and token <> '' and token = :token", [':tid' => $iTokenId, ':token' => $sSanitizedToken] );
$sOutput = '';
if (count($udresult) == 0) {
$attrfieldnames = Survey::model()->findByPk($iSurveyId)->tokenAttributes;
Expand Down
14 changes: 5 additions & 9 deletions application/views/admin/token/tokenform.php
Expand Up @@ -87,7 +87,7 @@
<label class=" control-label" for='completed'>
<?php eT("Completed?"); ?>
</label>
<div class=" <?php echo $sCointainerClass; ?>" id="completed-yes-no-date-container" data-locale="<?php echo convertLStoDateTimePickerLocale(Yii::app()->session['adminlang']); ?>">
<div class="selector__yesNoContainer <?php echo $sCointainerClass; ?>" id="completed-yes-no-date-container" data-locale="<?php echo convertLStoDateTimePickerLocale(Yii::app()->session['adminlang']); ?>">
<div class="row">
<?php if ($oSurvey->anonymized != 'Y'):?>

Expand Down Expand Up @@ -220,7 +220,7 @@
<label class=" control-label" for='sent'>
<?php eT("Invitation sent?"); ?>
</label>
<div class=" <?php echo $sCointainerClass; ?>" id="sent-yes-no-date-container" data-locale="<?php echo convertLStoDateTimePickerLocale(Yii::app()->session['adminlang']); ?>">
<div class="selector__yesNoContainer <?php echo $sCointainerClass; ?>" id="sent-yes-no-date-container" data-locale="<?php echo convertLStoDateTimePickerLocale(Yii::app()->session['adminlang']); ?>">
<div class="row">
<div class="">
<?php if ($oSurvey->anonymized != 'Y'):?>
Expand Down Expand Up @@ -276,7 +276,7 @@
</div>

<div class="">
<div id="sent-date-container" class="date-container" <?php if (!$bSwitchValue):?>style="display: none;"<?php endif; ?>>
<div id="sent-date-container" data-parent="#sent-switch" class="selector__date-container_hidden date-container" <?php if (!$bSwitchValue){ echo "style='display:none;'"; }?> >
<!-- Sent Date -->
<div id="sent-date_datetimepicker" class="input-group date">
<input class="YesNoDatePicker form-control" id="sent-date" type="text" value="<?php echo isset($sent) ? $sent : ''?>" name="sent-date" data-date-format="<?php echo $dateformatdetails['jsdate']; ?> HH:mm">
Expand All @@ -293,7 +293,7 @@
<label class=" control-label" for='remindersent'>
<?php eT("Reminder sent?"); ?>
</label>
<div class=" <?php echo $sCointainerClass; ?>" id="remind-yes-no-date-container" data-locale="<?php echo convertLStoDateTimePickerLocale(Yii::app()->session['adminlang']); ?>">
<div class="selector__yesNoContainer <?php echo $sCointainerClass; ?>" id="remind-yes-no-date-container" data-locale="<?php echo convertLStoDateTimePickerLocale(Yii::app()->session['adminlang']); ?>">

<div class="row">
<div class="">
Expand Down Expand Up @@ -322,8 +322,7 @@
</div>

<div class="">
<div id="remind-date-container" class="date-container" <?php if (!$bRemindSwitchValue):?>style="display: none;"
<?php endif; ?>>
<div id="remind-date-container" data-parent="#remind-switch" class="selector__date-container_hidden date-container" <?php if (!$bRemindSwitchValue){ echo "style='display:none;'"; }?> >

<div id="remind-date_datetimepicker" class="input-group date">
<input class="YesNoDatePicker form-control" id="remind-date" type="text" value="<?php echo isset($remindersent) ? $remindersent : ''?>" name="remind-date" data-date-format="<?php echo $dateformatdetails['jsdate']; ?> HH:mm">
Expand Down Expand Up @@ -449,7 +448,4 @@
));
?>
</div>
<script>
$(function(){$('.action_toggle_bootstrap_switch').bootstrapSwitch();});
</script>
</div>
38 changes: 23 additions & 15 deletions assets/scripts/admin/tokens.js
Expand Up @@ -12,23 +12,33 @@ $.fn.YesNoDate = function(options)
{
var that = $(this); // calling element
that.onReadyMethod = function(){
var $elSwitch = that.find('.YesNoDateSwitch').first(); // switch element (generated with YiiWheels widgets)
var $elDateContainer = that.find('.date-container').first(); // date time picker container (to show/hide)
var $elDate = that.find('.YesNoDatePicker').first(); // date time picker element (generated with YiiWheels widgets)
var $elHiddenInput = that.find('.YesNoDateHidden').first(); // input form, containing the value to submit to the database
var $elSwitch = that.find('.YesNoDateSwitch').first(), // switch element (generated with YiiWheels widgets)
$elDateContainer = that.find('.date-container').first(), // date time picker container (to show/hide)
$elDate = that.find('.YesNoDatePicker').first(), // date time picker element (generated with YiiWheels widgets)
$elHiddenInput = that.find('.YesNoDateHidden').first(); // input form, containing the value to submit to the database

console.ls.log('tokenform', {
$elSwitch : $elSwitch,
$elDateContainer : $elDateContainer,
$elDate : $elDate,
$elHiddenInput : $elHiddenInput
});

// The view is called without processing output (no javascript)
// So we must apply js to widget elements
$elSwitch.bootstrapSwitch(); // Generate the switch
$elDate.datetimepicker({locale: that.data('locale')}); // Generate the date time picker

console.ls.log('$elSwitch', $elSwitch);
// When user switch
$(document).on( 'switchChange.bootstrapSwitch', '#'+$elSwitch.attr('id'), function(event, state)
$elSwitch.on('switchChange.bootstrapSwitch', function(event, state)
{
console.ls.log('$elSwitch', event, state);
if (state==true)
{
// Show date
$elDateContainer.show();
$elHiddenInput.attr('value', moment().format($elDateContainer.data('date-format')));
}
else
{
Expand All @@ -39,12 +49,11 @@ $.fn.YesNoDate = function(options)
});

// When user change date
$(document).on('dp.change', '#'+$elDate.attr('id')+'_datetimepicker', function(e){
$elDate.on('dp.change', function(e){
$elHiddenInput.attr('value', e.date.format('YYYY-MM-DD HH:mm'));
})
};
$(document).on('ready pjax:scriptcomplete', that.onReadyMethod);
$(document).on(' pjax:scriptcomplete',that.onReadyMethod);
return that;
}

$.fn.YesNo = function(options)
Expand All @@ -57,7 +66,7 @@ $.fn.YesNo = function(options)
$elSwitch.bootstrapSwitch(); // Generate the switch

// When user change date
$(document).on( 'switchChange.bootstrapSwitch', '#'+$elSwitch.attr('id'), function(event, state)
$elSwitch.on( 'switchChange.bootstrapSwitch', function(event, state)
{
if (state==true)
{
Expand All @@ -72,8 +81,7 @@ $.fn.YesNo = function(options)
})

};
$(document).on('ready pjax:scriptcomplete', that.onReadyMethod);
$(document).on(' pjax:scriptcomplete',that.onReadyMethod);
return that;
}

/**
Expand Down Expand Up @@ -167,11 +175,11 @@ $(document).on('ready pjax:scriptcomplete', function(){
{
$('#general').stickLabelOnLeft();

$('.yes-no-date-container').each(function(el){
$('.yes-no-date-container').each(function(i,el){
$(this).YesNoDate();
});

$('.yes-no-container').each(function(el){
$('.yes-no-container').each(function(i,el){
$(this).YesNo();
});

Expand Down Expand Up @@ -363,12 +371,12 @@ var startEditToken = function(){
*/

$('.yes-no-date-container').each(function(el){
$(this).YesNoDate();
$(this).YesNoDate().onReadyMethod();
});


$('.yes-no-container').each(function(el){
$(this).YesNo();
$(this).YesNo().onReadyMethod();
});

$('#validfrom').datetimepicker({locale: $('#validfrom').data('locale')});
Expand Down

0 comments on commit 19243cf

Please sign in to comment.