<?php
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
class DefaultController extends Controller {
/**
* @Route("/", name="homepage", schemes={"https"})
*/
public function indexAction() {
$em = $this->getDoctrine()->getManager();
$numberOfCallAttemptsSQLQuery = $em->getConnection()->prepare("SELECT COUNT(*) as count FROM callattempts");
$numberOfCallAttemptsSQLQuery->execute();
$numberOfArchivedCallAttemptsSQLQuery = $em->getConnection()->prepare("SELECT COUNT(*) as count FROM archivedcallattempts");
$numberOfArchivedCallAttemptsSQLQuery->execute();
$numberOfMinutesTalkedSQLQuery = $em->getConnection()->prepare("SELECT ROUND(SUM(TIMEDIFF(c.conversationend,c.conversationbegin)/60), 0) AS duration FROM callattempts c");
$numberOfMinutesTalkedSQLQuery->execute();
$numberOfMinutesTalkedArchivedCallAttemptsSQLQuery = $em->getConnection()->prepare("SELECT ROUND(SUM(TIMEDIFF(c.conversationend,c.conversationbegin)/60), 0) AS duration FROM archivedcallattempts c");
$numberOfMinutesTalkedArchivedCallAttemptsSQLQuery->execute();
$numberOfOpportunitiesSQLQuery = $em->getConnection()->prepare("SELECT COUNT(*) as count FROM opportunities");
$numberOfOpportunitiesSQLQuery->execute();
$numberOfAppointmentsSQLQuery = $em->getConnection()->prepare("SELECT COUNT(*) as count FROM appointments");
$numberOfAppointmentsSQLQuery->execute();
return $this->render('index/index.html.twig', array(
'entitymanager' => $em,
'numberOfCallAttempts' => number_format($numberOfCallAttemptsSQLQuery->fetchAll()[0]['count'] + $numberOfArchivedCallAttemptsSQLQuery->fetchAll()[0]['count'], 0, ',', '.'),
'numberOfMinutesTalked' => number_format($numberOfMinutesTalkedSQLQuery->fetchAll()[0]['duration'] + $numberOfMinutesTalkedArchivedCallAttemptsSQLQuery->fetchAll()[0]['duration'], 0, ',', '.'),
'numberOfOpportunities' => number_format($numberOfOpportunitiesSQLQuery->fetchAll()[0]['count'], 0, ',', '.'),
'numberOfAppointments' => number_format($numberOfAppointmentsSQLQuery->fetchAll()[0]['count'], 0, ',', '.')
));
}
/**
* @Route("/phpinfo", name="phpinfo", schemes={"https"})
*/
public function phpinfoAction() {
ob_start();
phpinfo();
$phpinfo = ob_get_clean();
return $this->render('index/phpinfo.html.twig', array('phpinfo' => $phpinfo, 'entitymanager' => $this->getDoctrine()->getManager()));
}
/**
* @Route("/documentation", name="documentation", schemes={"https"})
*/
public function documentationAction() {
return $this->render('index/documentation.html.twig', array('entitymanager' => $this->getDoctrine()->getManager()));
}
}