*/ 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'); }
protected function buildPage() { // theme $this->template->assign('theme', $this->theme->getTheme()); $this->template->assign('themes', $this->theme->getThemes()); // force to be a specific page $page = is_null($this->fake_page) ? $this->page : $this->fake_page; // infos $this->template->assign('app_name', (new Setting('app_name'))->getValueOrDefault()); $this->template->assign('app_title', (new Setting('app_title'))->getValueOrDefault()); $this->template->assign('app_description', (new Setting('app_description'))->getValueOrDefault()); $this->template->assign('app_copyright', (new Setting('app_copyright'))->getValueOrDefault()); $this->template->assign('app_robots', (new Setting('app_robots'))->getValueOrDefault()); $this->template->assign('app_version', TextHelper::niceVersion(self::VERSION)); $this->template->assign('app_api_version', TextHelper::niceVersion(\Picker\API::VERSION)); $this->template->assign('app_full_version', self::VERSION); $this->template->assign('app_full_api_version', \Picker\API::VERSION); // user infos $this->template->assign('user_isLogged', $this->auth->isLogged()); $this->template->assign('user_email', Session::Get(Authentification::SESSION_USER_EMAIL)); // navbar if (!isset($this->modules[Menu::NAVBAR])) { $m = new Menu(); $m->item('./', 'Home'); $this->modules[Menu::NAVBAR] = $m; } $this->template->assign(Menu::NAVBAR, $this->modules[Menu::NAVBAR]->generate($this->url . $page)); // navbar right if (isset($this->modules[Menu::NAVBAR_RIGHT])) { $this->template->assign(Menu::NAVBAR_RIGHT, $this->modules[Menu::NAVBAR_RIGHT]->generate($this->url . $page)); } // javascript if (isset($this->modules['script_file'])) { $this->template->assign('script_files', $this->modules['script_file']); } if (isset($this->modules['script'])) { $this->template->assign('scripts', $this->modules['script']); } }