Ejemplo n.º 1
0
*/
use Picker\Mood;
use Picker\MoodLevel;
use Utils\Session;
use Utils\Cookie;
use Utils\TextHelper;
// results of the day
$dayMoods = Mood::CountDayMoods();
$dayBads = $dayMoods[MoodLevel::BAD];
$dayGoods = $dayMoods[MoodLevel::GOOD];
$dayCount = $dayMoods['count'];
$this->assign('moods', $dayCount);
if ($dayCount > 0) {
    $this->assign('goods_percentage', $dayGoods * 100 / $dayCount);
    $this->assign('bads_percentage', $dayBads * 100 / $dayCount);
    $s = "\n    \$(function(){\n        var data = [\n            {\n                value: " . $dayBads . ",\n                color: \$('#color_picker .progress-bar-danger').css('background-color'),\n                label: 'Bad Mood'\n            },\n            {\n                value: " . $dayGoods . ",\n                color: \$('#color_picker .progress-bar-success').css('background-color'),\n                label: 'Good Mood'\n            }\n        ]; \n        new Chart(document.getElementById('dayChart').getContext('2d')).Doughnut(data, { \n            animation: true, animationEasing: 'linear', animationSteps: 25,\n            tooltipFontFamily: \$('body').css('font-family'),\n            tooltipFontSize: 12,\n            segmentShowStroke: false,\n            percentageInnerCutout : 60\n        });\n    });";
    $this->register('script', TextHelper::removeLineBreak($s));
}
// stats of the month
$monthMoods = Mood::CountMonthMoods();
$monthGoods = $monthMoods[MoodLevel::GOOD];
$monthBads = $monthMoods[MoodLevel::BAD];
$monthCount = max(1, $monthBads + $monthGoods);
$this->assign('month_goods_percentage', $monthGoods * 100 / $monthCount);
$this->assign('month_bads_percentage', $monthBads * 100 / $monthCount);
$this->assign('month_goods', $monthGoods);
$this->assign('month_bads', $monthBads);
// javascript dependancy
if ($dayCount > 0) {
    $this->register('script_file', 'chart.min.js');
}