Commit c3155e78 by Denis Chenu

[dev] Move to po/mo for translation

parent cdbe0e53
......@@ -7,7 +7,7 @@
* @copyright 2016 Advantage <http://www.advantage.fr>
* @license AGPL v3
* @version 1.1.1
* @version 2.0.0
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
......@@ -19,15 +19,16 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
class adminStats extends \ls\pluginmanager\PluginBase
class quickStatAdminParticipationAndStat extends \ls\pluginmanager\PluginBase
{
protected $storage = 'DbStorage';
static protected $description = 'Do the statitics at the Advantage way';
static protected $name = 'adminStats';
static protected $description = 'Show some specific statitics to your admin user.';
static protected $name = 'quickStatAdminParticipationAndStat';
/**
* @var string[] : this answer (label) must be moved at end
* @todo : move this to settings
*/
private $aPushTokenValue=array(
'Autre',
......@@ -45,11 +46,6 @@ class adminStats extends \ls\pluginmanager\PluginBase
private $aRenderData = array();
/**
* @var \translate class
*/
private $translate;
/**
* @var string : language for survey
*/
private $surveyLanguage;
......@@ -61,14 +57,12 @@ class adminStats extends \ls\pluginmanager\PluginBase
),
'dailyRateEnterAllow'=>array(
'type'=>'checkbox',
'label'=>"Activer le taux d'entrée journalier",
'help'=>"Ceci va activer ou non la possibilté dans la gestion du questionnaire",
'label'=>"Activate daily participation",
'default'=>1,
),
'dailyRateActionAllow'=>array(
'type'=>'checkbox',
'label'=>"Activer le taux d'action journalier",
'help'=>"Ceci va activer ou non la possibilté dans la gestion du questionnaire",
'label'=>"Activate daily action",
'default'=>0,
),
);
......@@ -76,13 +70,20 @@ class adminStats extends \ls\pluginmanager\PluginBase
public function init()
{
/* Disable default admin view */
$this->subscribe('beforeControllerAction');
//~ $this->subscribe('afterSuccessfulLogin');
/* Survey settings */
$this->subscribe('beforeSurveySettings');
$this->subscribe('newSurveySettings');
/* Show page */
$this->subscribe('newDirectRequest');
/* register language */
$this->subscribe('afterPluginLoad');
}
public function beforeSurveySettings()
......@@ -98,24 +99,25 @@ class adminStats extends \ls\pluginmanager\PluginBase
{
$aSettings["statlink"]=array(
'type'=>'info',
'content'=>"<h5 class='alert alert-info'>Lien vers les statistiques : <a href='{$url}'>{$url}</a></h5>",
'content'=>"<h5 class='alert alert-info'>".$this->_translate("Link to statitics :")."<a href='{$url}'>{$url}</a></h5>",
);
}
else
{
$aSettings["statlink"]=array(
'type'=>'info',
'content'=>"<p class='alert alert-info'>Survey is not activated : no statistics can be shown.</p>",
'content'=>"<p class='alert alert-info'>".$this->_translate("Survey is not activated : no statistics can be shown.")."</p>",
);
}
$aSettings["alternateTitle"]=array(
'type'=>'string',
'label'=>"Titre alternatif",
'label'=>$this->_translate("Alternate title"),
'current'=>$this->get("alternateTitle","Survey",$oEvent->get('survey'),""),
);
$aSettings["numberMax"]=array(
'type'=>'int',
'label'=>"Nombre d'envoi global (sans invitations)",
'label'=>$this->_translate("Expected participation"),
'help'=>$this->_translate("If survey didn't have token : used for participation rate."),
'htmlOptions'=>array(
'min'=>0,
),
......@@ -124,12 +126,12 @@ class adminStats extends \ls\pluginmanager\PluginBase
$aSettings["CrossTitle"]=array(
'type'=>'info',
'content'=>"<h5 class='alert alert-info'>Onglet participation</h5>"
'content'=>"<h5 class='alert alert-info'>".$this->_translate("Participation tab")."</h5>"
);
if($oSurvey->datestamp=="Y"){
$aSettings["participationComment"]=array(
'type'=>'html',
'label'=>"Zone de commentaires pour la participation",
'label'=>$this->_translate("Description for participation tab"),
'current'=>$this->get("participationComment","Survey",$oEvent->get('survey'),""),
'height'=>'8em',
'editorOptions'=>array(
......@@ -139,7 +141,7 @@ class adminStats extends \ls\pluginmanager\PluginBase
);
$aSettings["dailyRate"]=array(
'type'=>'select',
'label'=>"Montrer le nombre de réponses finalisées journalier",
'label'=>$this->_translate("Show the number of completed daily responses."),
'options'=>array(
'1'=>gT('Yes'),
'0'=>gT('No'),
......@@ -148,7 +150,7 @@ class adminStats extends \ls\pluginmanager\PluginBase
);
$aSettings["dailyRateCumulative"]=array(
'type'=>'select',
'label'=>"Montrer le nombre de réponses finalisées cumulées journalier",
'label'=>$this->_translate("Show the number of completed daily cumulative responses."),
'options'=>array(
'1'=>gT('Yes'),
'0'=>gT('No'),
......@@ -159,7 +161,7 @@ class adminStats extends \ls\pluginmanager\PluginBase
{
$aSettings["dailyRateEnter"]=array(
'type'=>'select',
'label'=>"Montrer le nombre d'entrées journalier",
'label'=>$this->_translate("Show the number of daily entries."),
'options'=>array(
'1'=>gT('Yes'),
'0'=>gT('No'),
......@@ -171,7 +173,7 @@ class adminStats extends \ls\pluginmanager\PluginBase
{
$aSettings["dailyRateAction"]=array(
'type'=>'select',
'label'=>"Montrer le nombre d'actions journalier",
'label'=>$this->_translate("Show the number of daily activities."),
'options'=>array(
'1'=>gT('Yes'),
'0'=>gT('No'),
......@@ -182,7 +184,7 @@ class adminStats extends \ls\pluginmanager\PluginBase
}else{
$aSettings["dailyRate"]=array(
'type'=>'info',
'label'=>"Le questionnaire n'est pas daté: impossible de montrer les taux journalier",
'label'=>$this->_translate("Survey are not date stamped: Le questionnaire n'est pas daté: it's not possible to show daily rates."),
);
}
/* Token attribute */
......@@ -223,7 +225,7 @@ class adminStats extends \ls\pluginmanager\PluginBase
}
$aSettings["tokenAttributes"]=array(
'type'=>'select',
'label'=>"Attribut d'invitation pour les croisements",
'label'=>$this->_translate("Token attributes for pivot (cross-sectional)"),
'options'=>$aOptions,
'htmlOptions'=>array(
'multiple'=>'multiple',
......@@ -245,7 +247,7 @@ class adminStats extends \ls\pluginmanager\PluginBase
{
$aSettings["questionCross"]=array(
'type'=>'select',
'label'=>"Question pour les croisements",
'label'=>$this->_translate("Question for pivot (cross-sectional)"),
'options'=>CHtml::listData($aoSingleQuestion,'qid',function($oSingleQuestion) {return "[".$oSingleQuestion->title."] ".viewHelper::flatEllipsizeText($oSingleQuestion->question,1,80,"...",0.6);}),
'htmlOptions'=>array(
'multiple'=>'multiple',
......@@ -335,11 +337,11 @@ class adminStats extends \ls\pluginmanager\PluginBase
{
$aSettings["SatTitle"]=array(
'type'=>'info',
'content'=>"<h5 class='alert alert-info'>Onglet satisfaction</h5>"
'content'=>"<h5 class='alert alert-info'>".$this->_translate("Satisfaction tab")."</h5>"
);
$aSettings["satisfactionComment"]=array(
'type'=>'html',
'label'=>"Zone de commentaires pour la satisfaction",
'label'=>$this->_translate("Description for satisfaction tab"),
'current'=>$this->get("satisfactionComment","Survey",$oEvent->get('survey'),""),
'height'=>'8em',
'editorOptions'=>array(
......@@ -350,7 +352,7 @@ class adminStats extends \ls\pluginmanager\PluginBase
$aSettings["questionNumeric"]=array(
'type'=>'select',
'label'=>"Question pour les moyennes",
'label'=>$this->_translate("Questions of satisfaction"),
'options'=>$aQuestionNumeric,
'htmlOptions'=>array(
'multiple'=>'multiple',
......@@ -366,7 +368,7 @@ class adminStats extends \ls\pluginmanager\PluginBase
}
$aSettings["tokenAttributesSatisfaction"]=array(
'type'=>'select',
'label'=>"Attribut d'invitation pour les croisements de satisfaction",
'label'=>$this->_translate("Token attributes for pivot (cross-sectional)"),
'options'=>$aOptions,
'htmlOptions'=>array(
'multiple'=>'multiple',
......@@ -378,7 +380,7 @@ class adminStats extends \ls\pluginmanager\PluginBase
{
$aSettings["questionCrossSatisfaction"]=array(
'type'=>'select',
'label'=>"Question pour les croisements de satisfaction (en graphique)",
'label'=>$this->_translate("Question for pivot (in graphic)"),
'options'=>CHtml::listData($aoSingleQuestion,'qid',function($oSingleQuestion) {return "[".$oSingleQuestion->title."] ".viewHelper::flatEllipsizeText($oSingleQuestion->question,1,80,"...",0.6);}),
'htmlOptions'=>array(
'multiple'=>'multiple',
......@@ -387,7 +389,7 @@ class adminStats extends \ls\pluginmanager\PluginBase
);
$aSettings["questionCrossSatisfactionTable"]=array(
'type'=>'select',
'label'=>"Question pour les croisements de satisfaction (en tableau)",
'label'=>$this->_translate("Question for pivot (in array)"),
'options'=>CHtml::listData($aoSingleQuestion,'qid',function($oSingleQuestion) {return "[".$oSingleQuestion->title."] ".viewHelper::flatEllipsizeText($oSingleQuestion->question,1,80,"...",0.6);}),
'htmlOptions'=>array(
'multiple'=>'multiple',
......@@ -483,9 +485,6 @@ class adminStats extends \ls\pluginmanager\PluginBase
{
$sAction=false;
}
Yii::setPathOfAlias('adminStats', dirname(__FILE__));
Yii::import("adminStats.translate");
$this->aRenderData['translate'] = $this->translate = new translate;
switch ($sAction)
{
case "list":
......@@ -565,10 +564,10 @@ class adminStats extends \ls\pluginmanager\PluginBase
$max=$this->get("numberMax","Survey",$iSurveyId,0);
}
$aResponses['total']=array(
'title'=>$this->translate->gT("Population"),
'title'=>$this->_translate("Population"),
'max'=>$max,
'data'=>array(
array('title'=>$this->translate->gT("Total Population"),'max'=>$max,'completed'=>Response::model($iSurveyId)->count("submitdate IS NOT NULL")),
array('title'=>$this->_translate("Total Population"),'max'=>$max,'completed'=>Response::model($iSurveyId)->count("submitdate IS NOT NULL")),
),
);
/* by token */
......@@ -765,7 +764,7 @@ class adminStats extends \ls\pluginmanager\PluginBase
if(!empty($aData))
{
$aResponses['total']=array(
'title'=>$this->translate->gT("Population"),
'title'=>$this->_translate("Population"),
'aSatisfactions'=>$aData,
);
}
......@@ -933,12 +932,11 @@ class adminStats extends \ls\pluginmanager\PluginBase
$state='submitdate';
}
$aDatas=$this->getDailyResponsesRate($oSurvey->sid,$state);
$aHeader=array(gT("Day"),gT("Nb"));
$aHeader=array(gT("Day"),$this->_translate("Nb"));
header("Content-Disposition: attachment; filename=" . $state.".csv");
header("Content-type: text/comma-separated-values; charset=UTF-8");
echo implode(",",$aHeader). PHP_EOL;
foreach($aDatas as $key=>$value)
{
foreach($aDatas as $key=>$value) {
echo $key.",".$value. PHP_EOL;
}
die();
......@@ -1016,16 +1014,16 @@ class adminStats extends \ls\pluginmanager\PluginBase
*/
private function render($fileRender)
{
Yii::setPathOfAlias('adminStats', dirname(__FILE__));
Yii::app()->clientScript->addPackage( 'boostrap-adminStats', array(
'basePath' => 'adminStats.vendor.bootstrap',
Yii::setPathOfAlias('quickStatAdminParticipationAndStat', dirname(__FILE__));
Yii::app()->clientScript->addPackage( 'boostrap-quickStatAdminParticipationAndStat', array(
'basePath' => 'quickStatAdminParticipationAndStat.vendor.bootstrap',
'css' => array('css/bootstrap.min.css'),
'js' => array('js/bootstrap.min.js'),
'depends' => array('jquery')
));
$oEvent=$this->event;
Yii::app()->controller->layout='bare'; // bare don't have any HTML
Yii::app()->getClientScript()->registerPackage('boostrap-adminStats');
Yii::app()->getClientScript()->registerPackage('boostrap-quickStatAdminParticipationAndStat');
$this->aRenderData['assetUrl']=$sAssetUrl=Yii::app()->assetManager->publish(dirname(__FILE__) . '/assets');
//~ $this->aRenderData['chartjsUrl']=Yii::app()->assetManager->publish(dirname(__FILE__) . '/vendor/Chart.js');
$this->aRenderData['jqplotUrl']=Yii::app()->assetManager->publish(dirname(__FILE__) . '/vendor/jquery.jqplot');
......@@ -1034,8 +1032,8 @@ class adminStats extends \ls\pluginmanager\PluginBase
$this->aRenderData['showSatisfaction']=count($this->get("questionNumeric","Survey",$this->iSurveyId,array()));
$this->aRenderData['showAdminSurvey']=Permission::model()->hasSurveyPermission($this->iSurveyId,'surveysettings','update') && !$this->onlyStatAccess();
$this->aRenderData['showAdmin']=!$this->onlyStatAccess();
Yii::app()->controller->render("adminStats.views.layout",$this->aRenderData);
$this->aRenderData['className']=self::$name;
Yii::app()->controller->render("quickStatAdminParticipationAndStat.views.layout",$this->aRenderData);
}
/**
* Return the survey with allowed access
......@@ -1078,12 +1076,16 @@ class adminStats extends \ls\pluginmanager\PluginBase
/**
* Update plugin settings for the link
* Update plugin settings for the link and lang
*/
public function getPluginSettings($getValues=true)
{
$url=$this->api->createUrl('plugins/direct', array('plugin' => $this->getName(), 'function' => 'list'));
$this->settings['docu']['content']= "<p class='alert alert-info'>The link to the statitsics is : <a href='{$url}'>{$url}</a></p>";
$this->settings['docu']['content']= "<p class='alert alert-info'>".$this->_translate("The link to the statistics is:")."<a href='{$url}'>{$url}</a></p>";
$this->settings['dailyRateEnterAllow']['label'] = $this->_translate("Activate daily participation");
$this->settings['dailyRateEnterAllow']['help'] = $this->_translate("This allow to activate daily participation by survey");
$this->settings['dailyRateActionAllow']['label'] = $this->_translate("Activate daily action");
$this->settings['dailyRateActionAllow']['help'] = $this->_translate("This allow to activate daily action by survey");
return parent::getPluginSettings($getValues);
}
......@@ -1257,13 +1259,10 @@ class adminStats extends \ls\pluginmanager\PluginBase
'order'=>$attribute,
'distinct'=>true,
));
if($oTokenValues)
{
if($oTokenValues) {
$aTokenValues=CHtml::listData($oTokenValues,$attribute,$attribute);
foreach($this->aPushTokenValue as $sPushToken)
{
if(array_key_exists($sPushToken,$aTokenValues))
{
foreach($this->aPushTokenValue as $sPushToken) {
if(array_key_exists($sPushToken,$aTokenValues)) {
unset($aTokenValues[$sPushToken]);
$aTokenValues[$sPushToken]=$sPushToken;
}
......@@ -1271,4 +1270,29 @@ class adminStats extends \ls\pluginmanager\PluginBase
return $aTokenValues;
}
}
/**
* Translate a plugin string
* @param string $string to translate
* @return string
*/
private function _translate($string){
return Yii::t('',$string,array(),self::$name);
}
/**
* Add this translation just after loaded all plugins
* @see event afterPluginLoad
*/
public function afterPluginLoad(){
$oLang=array(
'class' => 'CGettextMessageSource',
'cacheID' => self::$name.'Lang',
'cachingDuration'=>3600,
'forceTranslation' => true,
'useMoFile' => true,
'basePath' => __DIR__ . DIRECTORY_SEPARATOR.'locale',
'catalog'=>'messages',// default from Yii
);
Yii::app()->setComponent(self::$name,$oLang);
}
}
<?php
/**
* A class for language
*
* @author Denis Chenu <denis@sondages.pro>
* @copyright 2016 Denis Chenu <http://www.sondages.pro>
* @license GPL v3
* @version 0.0.1
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
class translate
{
/**
* @var array[] translation text : 1st jey is string, second key is lang
*/
private $aTranslation=array(
'fr'=>array(
'Mails sent'=>'Nombre d\'envoi',
'Daily participation'=>'Participation journalière',
'Daily participation (cumulative)'=>'Participation journalière cumulée',
'Participation rate'=>'Taux de participations',
'Total responses: %s'=>'Nombre total : %s',
'Total Population'=>'Population Totale',
'Population'=>'Population',
),
);
/**
* Quick translate function
*/
public function gT($string)
{
if(isset($this->aTranslation[App()->language][$string])){
return $this->aTranslation[App()->language][$string];
}
return gT($string);
}
}
......@@ -48,14 +48,14 @@
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="sr-only"><?php \Yii::t('',"Toggle navigation",array(),$className); ?></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<?php echo CHtml::link(
CHtml::tag("span",array("class"=>''),Yii::app()->getConfig("sitename")),
array("plugins/direct","plugin"=>"adminStats","function"=>"list"),
array("plugins/direct","plugin"=>$className,"function"=>"list"),
array("class"=>'navbar-brand')
); ?>
</div>
......@@ -82,7 +82,7 @@
</nav>
<div class="container">
<?php
Yii::app()->getController()->renderPartial("adminStats.views.{$subview}",$_data_);
Yii::app()->getController()->renderPartial("{$className}.views.{$subview}",$_data_);
?>
</div> <!-- /container -->
</body>
......@@ -4,8 +4,8 @@
<tr class="bg-primary">
<?php
echo CHtml::tag("th",array("class"=>'answer'),"");
echo CHtml::tag("td",array("class"=>"cell population"),$translate->gT("Population"));
echo CHtml::tag("td",array("class"=>"cell satisfaction"),$translate->gT("Satisfaction"));
echo CHtml::tag("td",array("class"=>"cell population"),\Yii::t('',"Population",array(),$className));
echo CHtml::tag("td",array("class"=>"cell satisfaction"),\Yii::t('',"Satisfaction",array(),$className));
?>
</tr>
</thead>
......
......@@ -24,7 +24,7 @@
'sortable'=>true,
'header'=>gT("ID"),
'type' => 'raw',
'value'=>'CHtml::link($data["sid"],array("plugins/direct","plugin"=>"adminStats","function"=>"participation","sid"=>$data["sid"]))',
'value'=>'CHtml::link($data["sid"],array("plugins/direct","plugin"=>"'.$className.'","function"=>"participation","sid"=>$data["sid"]))',
),
array(
'name'=>'surveyls_title',
......@@ -35,13 +35,13 @@
array(
'name'=>'responsesCount',
'sortable'=>true,
'header'=>$translate->gT("Responses"),
'header'=>\Yii::t('',"Responses",array(),$className),
'value'=>'$data["responsesCount"]',
),
array(
'name'=>'tokensCount',
'sortable'=>true,
'header'=>$translate->gT("Mails sent"),
'header'=>\Yii::t('',"Expected participants",array(),$className),
'value'=>'($data["tokensCount"] ? $data["tokensCount"] : "/");',
),
),
......
<h1><?php echo $titre; ?></h1>
<ul class="nav nav-tabs">
<li role="presentation" class="active"><a href="#"><?php echo gT("Participation") ?></a></li>
<li role="presentation" class="active"><a href="#"><?php echo \Yii::t('',"Participation",array(),$className) ?></a></li>
<?php if($showSatisfaction) { ?>
<li role="presentation"><?php echo CHtml::link(gT("Satisfaction"),array("plugins/direct","plugin"=>"adminStats","function"=>"satisfaction","sid"=>$oSurvey->sid)) ?></li>
<li role="presentation"><?php echo CHtml::link(\Yii::t('',"Satisfaction",array(),$className),array("plugins/direct","plugin"=>"{$className}","function"=>"satisfaction","sid"=>$oSurvey->sid)) ?></li>
<?php } ?>
<?php if($showAdminSurvey) { ?>
<li role="presentation"><?php echo CHtml::link(gT("Administration"),array("admin/survey","sa"=>"editsurveysettings","surveyid"=>$oSurvey->sid,'#'=>'pluginsettings')); ?></a></li>
<li role="presentation"><?php echo CHtml::link(gT("Administration"),array("admin/survey","sa"=>"view","surveyid"=>$oSurvey->sid)); ?></a></li>
<?php } ?>
</ul>
<?php
......@@ -15,56 +15,56 @@
}
?>
<?php if(!empty($aDailyResponses)){
Yii::app()->getController()->renderPartial("adminStats.views.subviews.participation_rate",array(
'title'=>$translate->gT("Daily participation"),
Yii::app()->getController()->renderPartial("{$className}.views.subviews.participation_rate",array(
'title'=>\Yii::t('',"Daily participation",array(),$className),
'type'=>'',
'aResponses'=>$aDailyResponses,
'oSurvey'=>$oSurvey,
'showExport'=>$showAdmin,
'showSum'=>true,
'translate'=>$translate,
'className'=>$className,
));
}?>
<?php if(!empty($aDailyResponsesCumulative)){
Yii::app()->getController()->renderPartial("adminStats.views.subviews.participation_rate",array(
'title'=>$translate->gT("Daily participation (cumulative)"),
Yii::app()->getController()->renderPartial("{$className}.views.subviews.participation_rate",array(
'title'=>\Yii::t('',("Daily participation (cumulative)"),array(),$className),
'type'=>'cumul',
'aResponses'=>$aDailyResponsesCumulative,
'oSurvey'=>$oSurvey,
'showExport'=>false,
'translate'=>$translate,
'className'=>$className,
));
}?>
<?php if(!empty($aDailyEnter)){
Yii::app()->getController()->renderPartial("adminStats.views.subviews.participation_rate",array(
'title'=>$translate->gT("Nombre de connexions"),
Yii::app()->getController()->renderPartial("{$className}.views.subviews.participation_rate",array(
'title'=>\Yii::t('',("Number of connections"),array(),$className),
'type'=>'enter',
'aResponses'=>$aDailyEnter,
'oSurvey'=>$oSurvey,
'showExport'=>$showAdmin,
'translate'=>$translate,
'className'=>$className,
));
}?>
<?php if(!empty($aDailyAction)){
Yii::app()->getController()->renderPartial("adminStats.views.subviews.participation_rate",array(
'title'=>$translate->gT("Taux d'action journalier"),
Yii::app()->getController()->renderPartial("{$className}.views.subviews.participation_rate",array(
'title'=>\Yii::t('',("Daily participation rate"),array(),$className),
'type'=>'action',
'aResponses'=>$aDailyAction,
'oSurvey'=>$oSurvey,
'showExport'=>$showAdmin,
'translate'=>$translate,
'className'=>$className,
));
}?>
<h2><?php echo $translate->gT("Participation rate"); ?></h2>
<h2><?php echo \Yii::t('',"Participation rate",array(),$className); ?></h2>
<?php foreach($aResponses as $aResponse){ ?>
<table class="table table-bordered <?php echo ($aResponse['max']>0) ? "" :" nopercentage"; ?>">
<thead>
<tr class="header">
<?php
echo CHtml::tag("th",array("class"=>'answer'),$aResponse['title']);
echo CHtml::tag("td",array("class"=>"cell nbsend"),($aResponse['max']>0) ? $translate->gT("Mails sent") :"");
echo CHtml::tag("td",array("class"=>"cell nbsend"),($aResponse['max']>0) ? \Yii::t('',"Expected participants",array(),$className) :"");
echo CHtml::tag("td",array("class"=>"cell response"),gT("Responses"));
echo CHtml::tag("td",array("class"=>"cell rate"),($aResponse['max']>0) ? $translate->gT("Participation rate") :"");
echo CHtml::tag("td",array("class"=>"cell rate"),($aResponse['max']>0) ? \Yii::t('',"Participation rate",array(),$className) :"");
?>
</tr>
</thead>
......
......@@ -2,10 +2,10 @@
echo CHtml::tag("h2",array("class"=>''),$title);
if(!empty($showSum))
{
echo CHtml::tag("h4",array("class"=>''),sprintf($translate->gT("Total responses: %s"),array_sum($aResponses)));
echo CHtml::tag("h4",array("class"=>''),sprintf(\Yii::t('',"Total responses: %s",array(),$className),array_sum($aResponses)));
}
echo CHtml::tag("div",array("id"=>"chart-daily{$type}",'class'=>'chart-day graph jqplot-line'),"",true);
echo CHtml::link(gT("Export"),App()->createUrl('plugins/direct', array('plugin' => 'adminStats', 'function' => 'export','sid'=>$oSurvey->sid,'export'=>"dayresponse",'state'=>$type)),array());
echo CHtml::link(gT("Export"),App()->createUrl('plugins/direct', array('plugin' => $className, 'function' => 'export','sid'=>$oSurvey->sid,'export'=>"dayresponse",'state'=>$type)),array());
?>
<script>
$(document).ready(function(){
......
<h1><?php echo $titre; ?></h1>
<ul class="nav nav-tabs">
<li role="presentation"><?php echo CHtml::link($translate->gT("Participation"),array("plugins/direct","plugin"=>"adminStats","function"=>"participation","sid"=>$oSurvey->sid)); ?></li>
<li role="presentation"><?php echo CHtml::link(\Yii::t('',"Participation",array(),$className),array("plugins/direct","plugin"=>$className,"function"=>"participation","sid"=>$oSurvey->sid)); ?></li>
<?php if($showSatisfaction) { ?>
<li role="presentation" class="active"><a href="#"><?php echo $translate->gT("Satisfaction") ?></a></li>
<li role="presentation" class="active"><a href="#"><?php echo \Yii::t('',"Satisfaction",array(),$className); ?></a></li>
<?php } ?>
<?php if($showAdminSurvey) { ?>
<li role="presentation"><?php echo CHtml::link($translate->gT("Administration"),array("admin/survey","sa"=>"editsurveysettings","surveyid"=>$oSurvey->sid,'#'=>'pluginsettings')); ?></a></li>
<li role="presentation"><?php echo CHtml::link(\Yii::t('',"Administration",array(),$className),array("admin/survey","sa"=>"view","surveyid"=>$oSurvey->sid)); ?></a></li>
<?php } ?>
</ul>
<?php
......@@ -40,20 +40,20 @@
<?php
switch($aResponse['type']){
case 'table':
echo Yii::app()->controller->renderPartial("adminStats.views.subviews.inc_satisfaction_table",array(
echo Yii::app()->controller->renderPartial("{$className}.views.subviews.inc_satisfaction_table",array(
'repKey'=>$repKey,
'iSatId'=>$iSatId,
'aResponse'=>$aResponse,
'translate'=>$translate,
'className'=>$className,
),true);
break;
case 'graph':
default:
echo Yii::app()->controller->renderPartial("adminStats.views.subviews.inc_satisfaction_graph",array(
echo Yii::app()->controller->renderPartial("{$className}.views.subviews.inc_satisfaction_graph",array(
'repKey'=>$repKey,
'iSatId'=>$iSatId,
'aResponse'=>$aResponse,
'translate'=>$translate,
'className'=>$className,
),true);
break;
}
......
<h1><?php echo $titre; ?></h1>
<ul class="nav nav-tabs">
<li role="presentation"><?php echo CHtml::link($translate->gT("Participation"),array("plugins/direct","plugin"=>"adminStats","function"=>"participation","sid"=>$oSurvey->sid)); ?></li>
<li role="presentation" class="active"><a href="#"><?php echo $translate->gT("Satisfaction") ?></a></li>
</ul>
<?php foreach($aResponses as $repKey=>$aResponse){ ?>
<h2><?php echo $aResponse['title'] ?></h2>
<?php foreach($aResponse['aSatisfactions'] as $iSatId=>$aSatisfaction){ ?>
<h3><?php echo $aSatisfaction['title'] ?></h2>
<?php
echo CHtml::tag("canvas",array("id"=>"chart-r{$repKey}-s{$iSatId}","width"=>"400","height"=>"100"),"",true);
?>
<?php
$aLabels=array();
$aAverage=array();
foreach($aSatisfaction['datas'] as $aDatas) {
$aLabels[]="{$aDatas['title']} ({$aDatas['count']})";
$aAverage[]=$aDatas['average'];
} ?>
<script>
var data = {
labels: <?php echo json_encode($aLabels) ?>,
datasets: [
{
label: "",
backgroundColor: "#0092dd",
data: <?php echo json_encode($aAverage) ?>,
}
]
};
var ctx = document.getElementById('<?php echo "chart-r{$repKey}-s{$iSatId}" ?>');
var myBarChart = new Chart(ctx, {
type: 'bar',
data: data,
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero:true
}
}]
},
onAnimationComplete: function()
{
console.log("complete");
this.showTooltip(this.datasets[0].bars, true);
}
}
});
</script>
<?php } ?>
<?php } ?>
<h1><?php echo $titre; ?></h1>
<ul class="nav nav-tabs">
<li role="presentation"><?php echo CHtml::link($translate->gT("Participation"),array("plugins/direct","plugin"=>"adminStats","function"=>"participation","sid"=>$oSurvey->sid)); ?></li>
<?php if($showSatisfaction) { ?>
<li role="presentation" class="active"><a href="#"><?php echo $translate->gT("Satisfaction") ?></a></li>
<?php } ?>
<?php if($showAdminSurvey) { ?>
<li role="presentation"><?php echo CHtml::link($translate->gT("Administration"),array("admin/survey","sa"=>"editsurveysettings","surveyid"=>$oSurvey->sid,'#'=>'pluginsettings')); ?></a></li>
<?php } ?>
</ul>
<?php foreach($aResponses as $repKey=>$aResponse){ ?>
<h2><?php echo $aResponse['title'] ?></h2>
<?php foreach($aResponse['aSatisfactions'] as $iSatId=>$aSatisfaction){ ?>
<h3><?php echo $aSatisfaction['title'] ?></h2>
<?php
echo CHtml::tag("div",array("id"=>"chart-r{$repKey}-s{$iSatId}",'class'=>'graph'),"",true);
?>
<?php
$aLabels=array();
$aAverage=array();
foreach($aSatisfaction['datas'] as $aDatas) {
$aLabels[]="{$aDatas['title']} ({$aDatas['count']})";
$aAverage[]=$aDatas['average'];
} ?>
<?php $angle=(count($aLabels)>6 ? -15:0); // Evaluat number of columns ?>
<script>
$(document).ready(function(){
$.jqplot.config.enablePlugins = true;
var s1 = <?php echo json_encode($aAverage); ?>;
var ticks = <?php echo json_encode($aLabels); ?>;
<?php echo "plotr{$repKey}s{$iSatId}" ?> = $.jqplot('<?php echo "chart-r{$repKey}-s{$iSatId}"; ?>', [s1], {