Skip to content

Commit

Permalink
Fixed issue #10274: bad layout of mini calendar in statistics
Browse files Browse the repository at this point in the history
Dev: Replace date-picker with Yii widget.
  • Loading branch information
olleharstedt committed Apr 21, 2016
1 parent 2318361 commit 89b6cdc
Show file tree
Hide file tree
Showing 10 changed files with 172 additions and 47 deletions.
16 changes: 16 additions & 0 deletions application/controllers/admin/dataentry.php
Expand Up @@ -730,6 +730,22 @@ public function editdata($subaction, $id, $surveyid, $language='')
'onkeypress' => 'return goodchars(event,\''.$goodchars.'\')'
)
);
/*
$aDataentryoutput .= Yii::app()->getController()->widget('yiiwheels.widgets.daterangepicker.WhDateRangePicker', array(
'name' => $fname['fieldname'],
'id' => 'datestampL',
'value' => $thisdate,
'pluginOptions' => array(
'format' => $dateformatdetails['jsdate'] . " HH:MM",
'singleDatePicker' => true,
'startDate' => date("Y-m-d", time()),
'drops' => 'up', // TODO: Does not work. Why?
'timePicker' => true,
'timePicker12Hour' => false, // NB: timePicker24Hour = true does not work
'timePickerIncrement' => 1
)
));
*/
$aDataentryoutput .= CHtml::hiddenField('dateformat'.$fname['fieldname'], $dateformatdetails['jsdate'],
array( 'id' => "dateformat{$fname['fieldname']}" )
);
Expand Down
1 change: 1 addition & 0 deletions application/controllers/admin/statistics.php
Expand Up @@ -517,6 +517,7 @@ public function run($surveyid = 0, $subaction = null)
$aData['error'] = $error;
$aData['oStatisticsHelper'] = $helper;
$aData['fresults'] = (isset($aData['fresults']))?$aData['fresults']:false;
$aData['dateformatdetails'] = getDateFormatData(Yii::app()->session['dateformat']);

$this->_renderWrappedTemplate('export', 'statistics_view', $aData);

Expand Down
1 change: 1 addition & 0 deletions application/controllers/admin/surveyadmin.php
Expand Up @@ -1020,6 +1020,7 @@ public function editlocalsettings($iSurveyID)
$aData['esrow'] = $esrow;
$aData['action'] = "editsurveylocalesettings";
$aData['i'] = $i;
$aData['dateformatdetails'] = getDateFormatData(Yii::app()->session['dateformat']);
$aTabContents[$sLang] = $this->getController()->renderPartial('/admin/survey/editLocalSettings_view', $aData, true);
}

Expand Down
24 changes: 12 additions & 12 deletions application/helpers/surveytranslator_helper.php
Expand Up @@ -34,18 +34,18 @@
function getDateFormatData($iDateFormat=0,$sLanguageCode='en')
{
$aDateFormats= array(
1=> array ('phpdate' => 'd.m.Y', 'jsdate' => 'dd.mm.yy', 'dateformat' => gT('dd.mm.yyyy')),
2=> array ('phpdate' => 'd-m-Y', 'jsdate' => 'dd-mm-yy', 'dateformat' => gT('dd-mm-yyyy')),
3=> array ('phpdate' => 'Y.m.d', 'jsdate' => 'yy.mm.dd', 'dateformat' => gT('yyyy.mm.dd')),
4=> array ('phpdate' => 'j.n.Y', 'jsdate' => 'd.m.yy', 'dateformat' => gT('d.m.yyyy')),
5=> array ('phpdate' => 'd/m/Y', 'jsdate' => 'dd/mm/yy', 'dateformat' => gT('dd/mm/yyyy')),
6=> array ('phpdate' => 'Y-m-d', 'jsdate' => 'yy-mm-dd', 'dateformat' => gT('yyyy-mm-dd')),
7=> array ('phpdate' => 'Y/m/d', 'jsdate' => 'yy/mm/dd', 'dateformat' => gT('yyyy/mm/dd')),
8=> array ('phpdate' => 'j/n/Y', 'jsdate' => 'd/m/yy', 'dateformat' => gT('d/m/yyyy')),
9=> array ('phpdate' => 'm-d-Y', 'jsdate' => 'mm-dd-yy', 'dateformat' => gT('mm-dd-yyyy')),
10=>array ('phpdate' => 'm.d.Y', 'jsdate' => 'mm.dd.yy', 'dateformat' => gT('mm.dd.yyyy')),
11=>array ('phpdate' => 'm/d/Y', 'jsdate' => 'mm/dd/yy', 'dateformat' => gT('mm/dd/yyyy')),
12=>array ('phpdate' => 'j-n-Y', 'jsdate' => 'd-m-yy', 'dateformat' => gT('d-m-yyyy'))
1=> array ('phpdate' => 'd.m.Y', 'jsdate' => 'DD.MM.YYYY', 'dateformat' => gT('dd.mm.yyyy')),
2=> array ('phpdate' => 'd-m-Y', 'jsdate' => 'DD-MM-YYYY', 'dateformat' => gT('dd-mm-yyyy')),
3=> array ('phpdate' => 'Y.m.d', 'jsdate' => 'YYYY.MM.DD', 'dateformat' => gT('yyyy.mm.dd')),
4=> array ('phpdate' => 'j.n.Y', 'jsdate' => 'D.M.YYYY', 'dateformat' => gT('d.m.yyyy')),
5=> array ('phpdate' => 'd/m/Y', 'jsdate' => 'DD/MM/YYYY', 'dateformat' => gT('dd/mm/yyyy')),
6=> array ('phpdate' => 'Y-m-d', 'jsdate' => 'YYYY-MM-DD', 'dateformat' => gT('yyyy-mm-dd')),
7=> array ('phpdate' => 'Y/m/d', 'jsdate' => 'YYYY/MM/DD', 'dateformat' => gT('yyyy/mm/dd')),
8=> array ('phpdate' => 'j/n/Y', 'jsdate' => 'D/M/YYYY', 'dateformat' => gT('d/m/yyyy')),
9=> array ('phpdate' => 'm-d-Y', 'jsdate' => 'MM-DD-YYYY', 'dateformat' => gT('mm-dd-yyyy')),
10=>array ('phpdate' => 'm.d.Y', 'jsdate' => 'MM.DD.YYYY', 'dateformat' => gT('mm.dd.yyyy')),
11=>array ('phpdate' => 'm/d/Y', 'jsdate' => 'MM/DD/YYYY', 'dateformat' => gT('mm/dd/yyyy')),
12=>array ('phpdate' => 'j-n-Y', 'jsdate' => 'D-M-YYYY', 'dateformat' => gT('d-m-yyyy'))
);

if ($iDateFormat > 12 || $iDateFormat<0) {
Expand Down
Expand Up @@ -7,24 +7,66 @@
<div class='form-group'>
<label class="col-sm-4 control-label" for='datestampE'><?php eT("Equals:"); ?></label>
<div class="col-sm-5">
<?php echo CHtml::textField('datestampE',isset($_POST['datestampE'])?$_POST['datestampE']:'',array('id'=>'datestampE', 'class'=>'popupdate', 'size'=>'12'));?>
<?php $this->widget('yiiwheels.widgets.daterangepicker.WhDateRangePicker', array(
'name' => "datestampE",
'id' => 'datestampE',
'value' => isset($_POST['datestampE']) ? $_POST['datestampE'] : '',
'pluginOptions' => array(
'format' => $dateformatdetails['jsdate'] . " HH:MM",
'singleDatePicker' => true,
'startDate' => date("Y-m-d", time()),
'drops' => 'up', // TODO: Does not work. Why?
'timePicker' => true,
'timePicker12Hour' => false, // NB: timePicker24Hour = true does not work
'timePickerIncrement' => 1
)
));
?>
</div>
</div>
<div class='form-group'>
<label class="col-sm-4 control-label" for='datestampG'><?php eT("Later than:");?></label>
<div class="col-sm-5">
<?php echo CHtml::textField('datestampG',isset($_POST['datestampG'])?$_POST['datestampG']:'',array('id'=>'datestampG', 'class'=>'popupdate', 'size'=>'12'));?>
<?php $this->widget('yiiwheels.widgets.daterangepicker.WhDateRangePicker', array(
'name' => "datestampG",
'id' => 'datestampG',
'value' => isset($_POST['datestampG']) ? $_POST['datestampG'] : '',
'pluginOptions' => array(
'format' => $dateformatdetails['jsdate'] . " HH:MM",
'singleDatePicker' => true,
'startDate' => date("Y-m-d", time()),
'drops' => 'up', // TODO: Does not work. Why?
'timePicker' => true,
'timePicker12Hour' => false, // NB: timePicker24Hour = true does not work
'timePickerIncrement' => 1
)
));
?>
</div>
</div>
<div class='form-group'>
<label class="col-sm-4 control-label" for='datestampL'><?php eT("Earlier than:");?></label>
<div class="col-sm-5">
<?php echo CHtml::textField('datestampL',isset($_POST['datestampL'])?$_POST['datestampL']:'',array('id'=>'datestampL', 'class'=>'popupdate', 'size'=>'12'));?>
<?php $this->widget('yiiwheels.widgets.daterangepicker.WhDateRangePicker', array(
'name' => "datestampL",
'id' => 'datestampL',
'value' => isset($_POST['datestampL']) ? $_POST['datestampL'] : '',
'pluginOptions' => array(
'format' => $dateformatdetails['jsdate'] . " HH:MM",
'singleDatePicker' => true,
'startDate' => date("Y-m-d", time()),
'drops' => 'up', // TODO: Does not work. Why?
'timePicker' => true,
'timePicker12Hour' => false, // NB: timePicker24Hour = true does not work
'timePickerIncrement' => 1
)
));
?>
</div>
</div>
<input type='hidden' name='summary[]' value='datestampE' />
<input type='hidden' name='summary[]' value='datestampG' />
<input type='hidden' name='summary[]' value='datestampL' />
</div>
</div>
<?php endif; ?>
<?php endif; ?>
2 changes: 1 addition & 1 deletion application/views/admin/export/statistics_view.php
Expand Up @@ -39,7 +39,7 @@
<!-- Output options -->
<?php $this->renderPartial('/admin/export/statistics_subviews/_outputoptions', array('error'=>$error, 'showtextinline'=>$showtextinline, 'usegraph'=>$usegraph, 'showtextinline'=>$showtextinline)) ; ?>
<!-- Submission date -->
<?php $this->renderPartial('/admin/export/statistics_subviews/_submissiondate', array('datestamp'=>$datestamp)) ; ?>
<?php $this->renderPartial('/admin/export/statistics_subviews/_submissiondate', array('datestamp'=>$datestamp, 'dateformatdetails' => $dateformatdetails)) ; ?>
</div>
</div>

Expand Down
Expand Up @@ -31,15 +31,43 @@
<div class="form-group">
<label class="col-sm-6 control-label" for='startdate'><?php eT("Start date/time:"); ?></label>
<div class="col-sm-6">
<input type='text' class='popupdatetime' id='startdate' size='20' name='startdate' value="<?php echo $startdate; ?>" />
<?php $this->widget('yiiwheels.widgets.daterangepicker.WhDateRangePicker', array(
'name' => "startdate",
'id' => 'startdate',
'value' => $startdate,
'pluginOptions' => array(
'format' => $dateformatdetails['jsdate'] . " HH:MM",
'singleDatePicker' => true,
'startDate' => date("Y-m-d hh:ii", time()),
'drops' => 'up', // TODO: Does not work. Why?
'timePicker' => true,
'timePicker12Hour' => false, // NB: timePicker24Hour = true does not work
'timePickerIncrement' => 1
)
));
?>
</div>
</div>

<!-- Expiry date/time -->
<div class="form-group">
<label class="col-sm-6 control-label" for='expires'><?php eT("Expiry date/time:"); ?></label>
<div class="col-sm-6">
<input type='text' class='popupdatetime' id='expires' size='20' name='expires' value="<?php echo $expires; ?>" />
<?php $this->widget('yiiwheels.widgets.daterangepicker.WhDateRangePicker', array(
'name' => "expires",
'id' => 'expires',
'value' => $expires,
'pluginOptions' => array(
'format' => $dateformatdetails['jsdate'] . " HH:MM",
'singleDatePicker' => true,
'startDate' => date("Y-m-d", time()),
'drops' => 'up', // TODO: Does not work. Why?
'timePicker' => true,
'timePicker12Hour' => false, // NB: timePicker24Hour = true does not work
'timePickerIncrement' => 1
)
));
?>
</div>
</div>

Expand Down
35 changes: 31 additions & 4 deletions application/views/admin/token/dummytokenform.php
Expand Up @@ -79,13 +79,40 @@
<div class="form-group">
<label class="col-sm-2 control-label" for='validfrom'><?php eT("Valid from"); ?>:</label>
<div class="col-sm-3">
<input type='text' class='popupdatetime' size='20' id='validfrom' name='validfrom' value="<?php if (isset($validfrom)){$datetimeobj = new Date_Time_Converter($validfrom, "Y-m-d H:i:s");echo $datetimeobj->convert($dateformatdetails['phpdate'] . ' H:i');}?>" />
<?php $this->widget('yiiwheels.widgets.daterangepicker.WhDateRangePicker', array(
'name' => "validfrom",
'value' => isset($validfrom) ? $validfrom : '',
'pluginOptions' => array(
'format' => $dateformatdetails['jsdate'] . " HH:MM",
'singleDatePicker' => true,
'startDate' => date("Y-m-d", time()),
'drops' => 'up', // TODO: Does not work. Why?
'timePicker' => true,
'timePicker12Hour' => false, // NB: timePicker24Hour = true does not work
'timePickerIncrement' => 1
)
));
?>
<span class="help-block"><?php printf(gT('Format: %s'), $dateformatdetails['jsdate'] . ' ' . gT('hh:mm')); ?></span>
</div>

<label class="col-sm-2 control-label" for='validuntil'><?php eT('until'); ?></label>
<label class="col-sm-2 control-label" for='validuntil'><?php eT('Until:'); ?></label>
<div class="col-sm-3">
<input type='text' size='20' id='validuntil' name='validuntil' class='popupdatetime' value="<?php if (isset($validuntil)){$datetimeobj = new Date_Time_Converter($validuntil, "Y-m-d H:i:s");echo $datetimeobj->convert($dateformatdetails['phpdate'] . ' H:i');}?>" />
<span class="help-block"><?php printf(gT('Format: %s'), $dateformatdetails['dateformat'] . ' ' . gT('hh:mm')); ?></span>
<?php $this->widget('yiiwheels.widgets.daterangepicker.WhDateRangePicker', array(
'name' => "validuntil",
'value' => isset($validuntil) ? $validuntil : '',
'pluginOptions' => array(
'format' => $dateformatdetails['jsdate'] . " HH:MM",
'singleDatePicker' => true,
'startDate' => date("Y-m-d", time()),
'drops' => 'up',
'timePicker' => true,
'timePicker12Hour' => false,
'timePickerIncrement' => 1
)
));
?>
<span class="help-block"><?php printf(gT('Format: %s'), $dateformatdetails['jsdate'] . ' ' . gT('hh:mm')); ?></span>
</div>
</div>

Expand Down
39 changes: 34 additions & 5 deletions application/views/admin/token/tokenform.php
Expand Up @@ -137,15 +137,44 @@
<div class="form-group">
<label class="col-sm-2 control-label" for='validfrom'><?php eT("Valid from"); ?>:</label>
<div class="col-sm-2">
<input type='text' class='popupdatetime' size='20' id='validfrom' name='validfrom' value="<?php if (isset($validfrom)){Yii::import('application.libraries.Date_Time_Converter', true);$datetimeobj = new Date_Time_Converter($validfrom, "Y-m-d H:i:s"); echo $datetimeobj->convert($dateformatdetails['phpdate'] . ' H:i');} ?>" />
<?php $this->widget('yiiwheels.widgets.daterangepicker.WhDateRangePicker', array(
'name' => "validfrom",
'value' => isset($validfrom) ? $validfrom : '',
'pluginOptions' => array(
'format' => $dateformatdetails['jsdate'] . " HH:MM",
'singleDatePicker' => true,
'startDate' => date("Y-m-d", time()),
'drops' => 'up', // TODO: Does not work. Why?
'timePicker' => true,
'timePicker12Hour' => false, // NB: timePicker24Hour = true does not work
'timePickerIncrement' => 1
)
));
?>
<span class='help-block'><?php echo sprintf(gT('Format: %s'), $dateformatdetails['jsdate'] . ' ' . gT('hh:mm')); ?></span>
</div>

<label class="col-sm-2 control-label" for='validuntil'><?php eT('until'); ?></label>
<div class="col-sm-5">
<input type='text' size='20' id='validuntil' name='validuntil' class='popupdatetime' value="<?php if (isset($validuntil)){$datetimeobj = new Date_Time_Converter($validuntil, "Y-m-d H:i:s");echo $datetimeobj->convert($dateformatdetails['phpdate'] . ' H:i');}?>" /> <span class='annotation'><?php echo sprintf(gT('Format: %s'), $dateformatdetails['dateformat'] . ' ' . gT('hh:mm')); ?></span>
<label class="col-sm-2 control-label" for='validuntil'><?php eT('Until:'); ?></label>
<div class="col-sm-2">
<?php $this->widget('yiiwheels.widgets.daterangepicker.WhDateRangePicker', array(
'name' => "validuntil",
'value' => isset($validuntil) ? $validuntil : '',
'pluginOptions' => array(
'format' => $dateformatdetails['jsdate'] . " HH:MM",
'singleDatePicker' => true,
'startDate' => date("Y-m-d", time()),
'drops' => 'up',
'timePicker' => true,
'timePicker12Hour' => false,
'timePickerIncrement' => 1
)
));
?>
<span class='help-block'><?php echo sprintf(gT('Format: %s'), $dateformatdetails['jsdate'] . ' ' . gT('hh:mm')); ?></span>
</div>
</div>

</div>

<!-- Attributes -->
<?php foreach ($attrfieldnames as $attr_name => $attr_description): ?>
<div class="form-group">
Expand Down

0 comments on commit 89b6cdc

Please sign in to comment.