<?php
/**
 * Created by Vladimir Guerra.
 * User: vlade
 * Date: 9/18/14
 * Time: 12:08 AM
 */

namespace VGM\WOBundle\Controller;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\RedirectResponse;
use VGM\UserBundle\Entity\User;
use FOS\UserBundle\Controller\GroupController as BaseController;
use FOS\UserBundle\FOSUserEvents;
use FOS\UserBundle\Event\FilterGroupResponseEvent;
use FOS\UserBundle\Event\FormEvent;
use FOS\UserBundle\Event\GetResponseGroupEvent;
use FOS\UserBundle\Event\GroupEvent;
use Symfony\Component\HttpFoundation\Response;
use VGM\UserBundle\Form\UserType;
use VGM\UserBundle\Form\ChangePasswordType;
class GeneralController extends Controller
{
    public function indexAction()
    {
        if($user = $this->getUser())
            return $this->render('VGMWOBundle:Default:index.html.twig');
        else
            return new RedirectResponse($this->generateUrl('fos_user_security_login'));
        /*$user = $this->getUser();

        if($user != null){
            if($user->hasRole('ROLE_ADMIN'))
                $url = $this->generateUrl('vgm_user_list');
            elseif($user->hasRole('ROLE_OTS_CORDINATOR') || $user->hasRole('ROLE_SUPERVISOR')
                || $user->hasRole('ROLE_SUPER_SUPERVISOR'))
                $url = $this->generateUrl('workorders');
            elseif($user->hasRole('ROLE_HUMAN_RESOURCES'))
                $url = $this->generateUrl('workers');
            else
                $url = $this->generateUrl('vgm_show_profile');
        }
        else
            $url = $this->generateUrl('fos_user_security_login');

        return new RedirectResponse($url);*/
    }

    public function administrationAction()
    {
        return $this->render('VGMWOBundle:General:administration.html.twig');
    }

    public function misionAction()
    {
        return $this->render('VGMWOBundle:General:mision.html.twig');
    }
    public function about_usAction()
    {
        return $this->render('VGMWOBundle:General:about_us.html.twig');
    }
    public function contact_usAction()
    {
        return $this->render('VGMWOBundle:General:contact_us.html.twig');
    }

    public function clockAction()
    {
        if($this->getUser())
            if($this->getUser()->hasRole('ROLE_SUPERVISOR') || $this->getUser()->hasRole('ROLE_SUPER_SUPERVISOR') || $this->getUser()->hasRole('ROLE_ADMIN'))
                return $this->render('VGMWOBundle:TimeRecord/TempTimeRecord:TempTimeReecord.html.twig');
        return $this->render('VGMWOBundle:TimeRecord:clockController.html.twig');
    }
    public function clockTempAction()
    {
        return $this->render('VGMWOBundle:TimeRecord/TempTimeRecord:TempTimeReecord.html.twig');
    }
}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       