/** * Display dashboard informations * * @param Application $app * @param Request $request * @return JsonResponse */ public function getDashboard(Application $app, Request $request) { $dashboard = new \module_report_dashboard($app, $app['authentication']->getUser()); if ('json' !== $request->getRequestFormat()) { \Session_Logger::updateClientInfos($app, 4); $dashboard->execute(); return $app['twig']->render('report/report_layout_child.html.twig', ['ajax_dash' => true, 'dashboard' => $dashboard, 'home_title' => $app['conf']->get(['registry', 'general', 'title']), 'module' => 'report', 'module_name' => 'Report', 'anonymous' => $app['conf']->get(['registry', 'modules', 'anonymous-report']), 'g_anal' => $app['conf']->get(['registry', 'general', 'analytics']), 'ajax' => false, 'ajax_chart' => false]); } $dmin = $request->request->get('dmin'); $dmax = $request->request->get('dmax'); if ($dmin && $dmax) { $dashboard->setDate($dmin, $dmax); } $dashboard->execute(); return $app->json(['html' => $app['twig']->render('report/ajax_dashboard_content_child.html.twig', ['dashboard' => $dashboard])]); }
/** * Display dashboard informations * * @param Application $app * @param Request $request * @return JsonResponse */ public function getDashboard(Application $app, Request $request) { if ('json' === $request->getRequestFormat()) { \Session_Logger::updateClientInfos($app, 4); $dashboard = new \module_report_dashboard($app, $app['authentication']->getUser()); $dmin = $request->query->get('dmin'); $dmax = $request->query->get('dmax'); if ($dmin && $dmax) { $dashboard->setDate($dmin, $dmax); } $dashboard->execute(); return $app->json(['html' => $app['twig']->render('report/ajax_dashboard_content_child.html.twig', ['dashboard' => $dashboard])]); } $granted = []; foreach ($app['acl']->get($app['authentication']->getUser())->get_granted_base(['canreport']) as $collection) { if (!isset($granted[$collection->get_sbas_id()])) { $granted[$collection->get_sbas_id()] = ['id' => $collection->get_sbas_id(), 'name' => $collection->get_databox()->get_viewname(), 'collections' => []]; } $granted[$collection->get_sbas_id()]['collections'][] = ['id' => $collection->get_coll_id(), 'base_id' => $collection->get_base_id(), 'name' => $collection->get_name()]; } return $app['twig']->render('report/report_layout_child.html.twig', ['ajax_dash' => true, 'dashboard' => null, 'granted_bases' => $granted, 'home_title' => $app['conf']->get(['registry', 'general', 'title']), 'module' => 'report', 'module_name' => 'Report', 'anonymous' => $app['conf']->get(['registry', 'modules', 'anonymous-report']), 'g_anal' => $app['conf']->get(['registry', 'general', 'analytics']), 'ajax' => false, 'ajax_chart' => false]); }