major refactoring and cleanup

This commit is contained in:
Kevin Papst
2016-10-23 00:12:32 +02:00
parent 5a85b1d37e
commit c492d30be3
70 changed files with 1304 additions and 4027 deletions

View File

@@ -0,0 +1,43 @@
<?php
/*
* This file is part of the Kimai package.
*
* (c) Kevin Papst <kevin@kevinpapst.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace TimesheetBundle\Controller\Admin;
use TimesheetBundle\Entity\Timesheet;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
/**
* Controller used for manage timesheet entries in the admin part of the site.
*
* @Route("/admin/timesheet")
* @Security("has_role('ROLE_CUSTOMER')")
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class TimesheetController extends Controller
{
/**
* @Route("/", defaults={"page": 1}, name="admin_timesheet_index")
* @Route("/timesheet/{page}", requirements={"page": "[1-9]\d*"}, name="admin_timesheet_index_paginated")
* @Method("GET")
* @Cache(smaxage="10")
*/
public function indexAction($page)
{
$entries = $this->getDoctrine()->getRepository(Timesheet::class)->findLatest($page);
return $this->render('TimesheetBundle:timesheet:index.html.twig', ['entries' => $entries]);
}
}

View File

@@ -44,7 +44,12 @@ class LoadFixtures extends AppBundleLoadFixtures
private function loadTimesheet(ObjectManager $manager)
{
$amountUsers = count($manager->getRepository(User::class)->findAll());
$allUsers = [];
$users = $manager->getRepository(User::class)->findAll();
foreach ($users as $user) {
$allUsers[$user->getId()] = $user;
}
$amountUsers = count($allUsers);
for ($i = 0; $i <= self::AMOUNT_TIMESHEET; $i++) {
@@ -67,7 +72,7 @@ class LoadFixtures extends AppBundleLoadFixtures
$entry->setStart($start->getTimestamp());
$entry->setEnd($end->getTimestamp());
$entry->setDuration($end->modify('- ' . $start->getTimestamp() . ' seconds')->getTimestamp());
$entry->setUserid(rand(1, $amountUsers));
$entry->setUser($allUsers[rand(1, $amountUsers)]);
//$entry->setApproved(false); // TODO
//$entry->setFixedrate(); // TODO
//$entry->setRate(); // TODO

View File

@@ -0,0 +1,200 @@
<?php
/*
* This file is part of the Kimai package.
*
* (c) Kevin Papst <kevin@kevinpapst.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace TimesheetBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Activity
*
* @ORM\Table(name="activities")
* @ORM\Entity
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class Activity
{
/**
* @var integer
*
* @ORM\Column(name="activityID", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $activityid;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=false)
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="comment", type="text", length=65535, nullable=true)
*/
private $comment;
/**
* @var boolean
*
* @ORM\Column(name="visible", type="boolean", nullable=false)
*/
private $visible = '1';
/**
* @var boolean
*
* @ORM\Column(name="filter", type="boolean", nullable=false)
*/
private $filter = '0';
/**
* @var boolean
*
* @ORM\Column(name="trash", type="boolean", nullable=false)
*/
private $trash = '0';
/**
* Set name
*
* @param string $name
*
* @return Activity
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set comment
*
* @param string $comment
*
* @return Activity
*/
public function setComment($comment)
{
$this->comment = $comment;
return $this;
}
/**
* Get comment
*
* @return string
*/
public function getComment()
{
return $this->comment;
}
/**
* Set visible
*
* @param boolean $visible
*
* @return Activity
*/
public function setVisible($visible)
{
$this->visible = $visible;
return $this;
}
/**
* Get visible
*
* @return boolean
*/
public function getVisible()
{
return $this->visible;
}
/**
* Set filter
*
* @param boolean $filter
*
* @return Activity
*/
public function setFilter($filter)
{
$this->filter = $filter;
return $this;
}
/**
* Get filter
*
* @return boolean
*/
public function getFilter()
{
return $this->filter;
}
/**
* Set trash
*
* @param boolean $trash
*
* @return Activity
*/
public function setTrash($trash)
{
$this->trash = $trash;
return $this;
}
/**
* Get trash
*
* @return boolean
*/
public function getTrash()
{
return $this->trash;
}
/**
* Get activityid
*
* @return integer
*/
public function getActivityid()
{
return $this->activityid;
}
}

View File

@@ -0,0 +1,675 @@
<?php
/*
* This file is part of the Kimai package.
*
* (c) Kevin Papst <kevin@kevinpapst.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace TimesheetBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Customer
*
* @ORM\Table(name="customers")
* @ORM\Entity
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class Customer
{
/**
* @var integer
*
* @ORM\Column(name="customerID", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $customerid;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=false)
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="comment", type="text", length=65535, nullable=true)
*/
private $comment;
/**
* @var boolean
*
* @ORM\Column(name="visible", type="boolean", nullable=false)
*/
private $visible = '1';
/**
* @var boolean
*
* @ORM\Column(name="filter", type="boolean", nullable=false)
*/
private $filter = '0';
/**
* @var string
*
* @ORM\Column(name="company", type="string", length=255, nullable=true)
*/
private $company;
/**
* @var string
*
* @ORM\Column(name="vat", type="string", length=255, nullable=true)
*/
private $vat;
/**
* @var string
*
* @ORM\Column(name="contact", type="string", length=255, nullable=true)
*/
private $contact;
/**
* @var string
*
* @ORM\Column(name="street", type="string", length=255, nullable=true)
*/
private $street;
/**
* @var string
*
* @ORM\Column(name="zipcode", type="string", length=255, nullable=true)
*/
private $zipcode;
/**
* @var string
*
* @ORM\Column(name="city", type="string", length=255, nullable=true)
*/
private $city;
/**
* @var string
*
* @ORM\Column(name="country", type="string", length=2, nullable=true)
*/
private $country;
/**
* @var string
*
* @ORM\Column(name="phone", type="string", length=255, nullable=true)
*/
private $phone;
/**
* @var string
*
* @ORM\Column(name="fax", type="string", length=255, nullable=true)
*/
private $fax;
/**
* @var string
*
* @ORM\Column(name="mobile", type="string", length=255, nullable=true)
*/
private $mobile;
/**
* @var string
*
* @ORM\Column(name="mail", type="string", length=255, nullable=true)
*/
private $mail;
/**
* @var string
*
* @ORM\Column(name="homepage", type="string", length=255, nullable=true)
*/
private $homepage;
/**
* @var string
*
* @ORM\Column(name="timezone", type="string", length=255, nullable=false)
*/
private $timezone;
/**
* @var boolean
*
* @ORM\Column(name="trash", type="boolean", nullable=false)
*/
private $trash = '0';
/**
* Set name
*
* @param string $name
*
* @return Customer
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set password
*
* @param string $password
*
* @return Customer
*/
public function setPassword($password)
{
$this->password = $password;
return $this;
}
/**
* Get password
*
* @return string
*/
public function getPassword()
{
return $this->password;
}
/**
* Set passwordresethash
*
* @param string $passwordresethash
*
* @return Customer
*/
public function setPasswordresethash($passwordresethash)
{
$this->passwordresethash = $passwordresethash;
return $this;
}
/**
* Get passwordresethash
*
* @return string
*/
public function getPasswordresethash()
{
return $this->passwordresethash;
}
/**
* Set secure
*
* @param string $secure
*
* @return Customer
*/
public function setSecure($secure)
{
$this->secure = $secure;
return $this;
}
/**
* Get secure
*
* @return string
*/
public function getSecure()
{
return $this->secure;
}
/**
* Set comment
*
* @param string $comment
*
* @return Customer
*/
public function setComment($comment)
{
$this->comment = $comment;
return $this;
}
/**
* Get comment
*
* @return string
*/
public function getComment()
{
return $this->comment;
}
/**
* Set visible
*
* @param boolean $visible
*
* @return Customer
*/
public function setVisible($visible)
{
$this->visible = $visible;
return $this;
}
/**
* Get visible
*
* @return boolean
*/
public function getVisible()
{
return $this->visible;
}
/**
* Set filter
*
* @param boolean $filter
*
* @return Customer
*/
public function setFilter($filter)
{
$this->filter = $filter;
return $this;
}
/**
* Get filter
*
* @return boolean
*/
public function getFilter()
{
return $this->filter;
}
/**
* Set company
*
* @param string $company
*
* @return Customer
*/
public function setCompany($company)
{
$this->company = $company;
return $this;
}
/**
* Get company
*
* @return string
*/
public function getCompany()
{
return $this->company;
}
/**
* Set vat
*
* @param string $vat
*
* @return Customer
*/
public function setVat($vat)
{
$this->vat = $vat;
return $this;
}
/**
* Get vat
*
* @return string
*/
public function getVat()
{
return $this->vat;
}
/**
* Set contact
*
* @param string $contact
*
* @return Customer
*/
public function setContact($contact)
{
$this->contact = $contact;
return $this;
}
/**
* Get contact
*
* @return string
*/
public function getContact()
{
return $this->contact;
}
/**
* Set street
*
* @param string $street
*
* @return Customer
*/
public function setStreet($street)
{
$this->street = $street;
return $this;
}
/**
* Get street
*
* @return string
*/
public function getStreet()
{
return $this->street;
}
/**
* Set zipcode
*
* @param string $zipcode
*
* @return Customer
*/
public function setZipcode($zipcode)
{
$this->zipcode = $zipcode;
return $this;
}
/**
* Get zipcode
*
* @return string
*/
public function getZipcode()
{
return $this->zipcode;
}
/**
* Set city
*
* @param string $city
*
* @return Customer
*/
public function setCity($city)
{
$this->city = $city;
return $this;
}
/**
* Get city
*
* @return string
*/
public function getCity()
{
return $this->city;
}
/**
* Set country
*
* @param string $country
*
* @return Customer
*/
public function setCountry($country)
{
$this->country = $country;
return $this;
}
/**
* Get country
*
* @return string
*/
public function getCountry()
{
return $this->country;
}
/**
* Set phone
*
* @param string $phone
*
* @return Customer
*/
public function setPhone($phone)
{
$this->phone = $phone;
return $this;
}
/**
* Get phone
*
* @return string
*/
public function getPhone()
{
return $this->phone;
}
/**
* Set fax
*
* @param string $fax
*
* @return Customer
*/
public function setFax($fax)
{
$this->fax = $fax;
return $this;
}
/**
* Get fax
*
* @return string
*/
public function getFax()
{
return $this->fax;
}
/**
* Set mobile
*
* @param string $mobile
*
* @return Customer
*/
public function setMobile($mobile)
{
$this->mobile = $mobile;
return $this;
}
/**
* Get mobile
*
* @return string
*/
public function getMobile()
{
return $this->mobile;
}
/**
* Set mail
*
* @param string $mail
*
* @return Customer
*/
public function setMail($mail)
{
$this->mail = $mail;
return $this;
}
/**
* Get mail
*
* @return string
*/
public function getMail()
{
return $this->mail;
}
/**
* Set homepage
*
* @param string $homepage
*
* @return Customer
*/
public function setHomepage($homepage)
{
$this->homepage = $homepage;
return $this;
}
/**
* Get homepage
*
* @return string
*/
public function getHomepage()
{
return $this->homepage;
}
/**
* Set timezone
*
* @param string $timezone
*
* @return Customer
*/
public function setTimezone($timezone)
{
$this->timezone = $timezone;
return $this;
}
/**
* Get timezone
*
* @return string
*/
public function getTimezone()
{
return $this->timezone;
}
/**
* Set trash
*
* @param boolean $trash
*
* @return Customer
*/
public function setTrash($trash)
{
$this->trash = $trash;
return $this;
}
/**
* Get trash
*
* @return boolean
*/
public function getTrash()
{
return $this->trash;
}
/**
* Get customerid
*
* @return integer
*/
public function getCustomerid()
{
return $this->customerid;
}
}

View File

@@ -0,0 +1,355 @@
<?php
/*
* This file is part of the Kimai package.
*
* (c) Kevin Papst <kevin@kevinpapst.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace TimesheetBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Project
*
* @ORM\Table(name="projects", indexes={@ORM\Index(name="customerID", columns={"customerID"})})
* @ORM\Entity
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class Project
{
/**
* @var integer
*
* @ORM\Column(name="projectID", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $projectid;
/**
* @var integer
*
* @ORM\Column(name="customerID", type="integer", nullable=false)
*/
private $customerid;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=false)
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="comment", type="text", length=65535, nullable=true)
*/
private $comment;
/**
* @var boolean
*
* @ORM\Column(name="visible", type="boolean", nullable=false)
*/
private $visible = '1';
/**
* @var boolean
*
* @ORM\Column(name="filter", type="boolean", nullable=false)
*/
private $filter = '0';
/**
* @var boolean
*
* @ORM\Column(name="trash", type="boolean", nullable=false)
*/
private $trash = '0';
/**
* @var string
*
* @ORM\Column(name="budget", type="decimal", precision=10, scale=2, nullable=true)
*/
private $budget = '0.00';
/**
* @var string
*
* @ORM\Column(name="effort", type="decimal", precision=10, scale=2, nullable=true)
*/
private $effort;
/**
* @var string
*
* @ORM\Column(name="approved", type="decimal", precision=10, scale=2, nullable=true)
*/
private $approved;
/**
* @var boolean
*
* @ORM\Column(name="internal", type="boolean", nullable=false)
*/
private $internal = '0';
/**
* Set customerid
*
* @param integer $customerid
*
* @return KimaiProjects
*/
public function setCustomerid($customerid)
{
$this->customerid = $customerid;
return $this;
}
/**
* Get customerid
*
* @return integer
*/
public function getCustomerid()
{
return $this->customerid;
}
/**
* Set name
*
* @param string $name
*
* @return KimaiProjects
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set comment
*
* @param string $comment
*
* @return KimaiProjects
*/
public function setComment($comment)
{
$this->comment = $comment;
return $this;
}
/**
* Get comment
*
* @return string
*/
public function getComment()
{
return $this->comment;
}
/**
* Set visible
*
* @param boolean $visible
*
* @return KimaiProjects
*/
public function setVisible($visible)
{
$this->visible = $visible;
return $this;
}
/**
* Get visible
*
* @return boolean
*/
public function getVisible()
{
return $this->visible;
}
/**
* Set filter
*
* @param boolean $filter
*
* @return KimaiProjects
*/
public function setFilter($filter)
{
$this->filter = $filter;
return $this;
}
/**
* Get filter
*
* @return boolean
*/
public function getFilter()
{
return $this->filter;
}
/**
* Set trash
*
* @param boolean $trash
*
* @return KimaiProjects
*/
public function setTrash($trash)
{
$this->trash = $trash;
return $this;
}
/**
* Get trash
*
* @return boolean
*/
public function getTrash()
{
return $this->trash;
}
/**
* Set budget
*
* @param string $budget
*
* @return KimaiProjects
*/
public function setBudget($budget)
{
$this->budget = $budget;
return $this;
}
/**
* Get budget
*
* @return string
*/
public function getBudget()
{
return $this->budget;
}
/**
* Set effort
*
* @param string $effort
*
* @return KimaiProjects
*/
public function setEffort($effort)
{
$this->effort = $effort;
return $this;
}
/**
* Get effort
*
* @return string
*/
public function getEffort()
{
return $this->effort;
}
/**
* Set approved
*
* @param string $approved
*
* @return KimaiProjects
*/
public function setApproved($approved)
{
$this->approved = $approved;
return $this;
}
/**
* Get approved
*
* @return string
*/
public function getApproved()
{
return $this->approved;
}
/**
* Set internal
*
* @param boolean $internal
*
* @return KimaiProjects
*/
public function setInternal($internal)
{
$this->internal = $internal;
return $this;
}
/**
* Get internal
*
* @return boolean
*/
public function getInternal()
{
return $this->internal;
}
/**
* Get projectid
*
* @return integer
*/
public function getProjectid()
{
return $this->projectid;
}
}

View File

@@ -11,13 +11,14 @@
namespace TimesheetBundle\Entity;
use AppBundle\Entity\User;
use Doctrine\ORM\Mapping as ORM;
/**
* Timesheet entity.
*
* @ORM\Entity(repositoryClass="TimesheetBundle\Repository\TimesheetRepository")
* @ORM\Table(name="timeSheet", indexes={@ORM\Index(name="userID", columns={"userID"}), @ORM\Index(name="projectID", columns={"projectID"}), @ORM\Index(name="activityID", columns={"activityID"})})
* @ORM\Table(name="timeSheet", indexes={@ORM\Index(columns={"userID"}), @ORM\Index(columns={"projectID"}), @ORM\Index(name="activityID", columns={"activityID"})})
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
@@ -47,9 +48,10 @@ class Timesheet
/**
* @var integer
*
* @ORM\Column(name="userID", type="integer", nullable=false)
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\User")
* @ORM\JoinColumn(name="userID", referencedColumnName="userID")
*/
private $userid;
private $user;
/**
* @var integer
@@ -165,7 +167,7 @@ class Timesheet
*
* @param integer $start
*
* @return KimaiTimesheet
* @return Timesheet
*/
public function setStart($start)
{
@@ -189,7 +191,7 @@ class Timesheet
*
* @param integer $end
*
* @return KimaiTimesheet
* @return Timesheet
*/
public function setEnd($end)
{
@@ -213,7 +215,7 @@ class Timesheet
*
* @param integer $duration
*
* @return KimaiTimesheet
* @return Timesheet
*/
public function setDuration($duration)
{
@@ -233,27 +235,27 @@ class Timesheet
}
/**
* Set userid
* Set user
*
* @param integer $userid
* @param User $user
*
* @return KimaiTimesheet
* @return Timesheet
*/
public function setUserid($userid)
public function setUser(User $user)
{
$this->userid = $userid;
$this->user = $user;
return $this;
}
/**
* Get userid
* Get user
*
* @return integer
* @return User
*/
public function getUserid()
public function getUser()
{
return $this->userid;
return $this->user;
}
/**
@@ -261,7 +263,7 @@ class Timesheet
*
* @param integer $projectid
*
* @return KimaiTimesheet
* @return Timesheet
*/
public function setProjectid($projectid)
{
@@ -285,7 +287,7 @@ class Timesheet
*
* @param integer $activityid
*
* @return KimaiTimesheet
* @return Timesheet
*/
public function setActivityid($activityid)
{
@@ -309,7 +311,7 @@ class Timesheet
*
* @param string $description
*
* @return KimaiTimesheet
* @return Timesheet
*/
public function setDescription($description)
{
@@ -333,7 +335,7 @@ class Timesheet
*
* @param string $comment
*
* @return KimaiTimesheet
* @return Timesheet
*/
public function setComment($comment)
{
@@ -357,7 +359,7 @@ class Timesheet
*
* @param boolean $commenttype
*
* @return KimaiTimesheet
* @return Timesheet
*/
public function setCommenttype($commenttype)
{
@@ -381,7 +383,7 @@ class Timesheet
*
* @param boolean $cleared
*
* @return KimaiTimesheet
* @return Timesheet
*/
public function setCleared($cleared)
{
@@ -405,7 +407,7 @@ class Timesheet
*
* @param string $location
*
* @return KimaiTimesheet
* @return Timesheet
*/
public function setLocation($location)
{
@@ -429,7 +431,7 @@ class Timesheet
*
* @param string $trackingnumber
*
* @return KimaiTimesheet
* @return Timesheet
*/
public function setTrackingnumber($trackingnumber)
{
@@ -453,7 +455,7 @@ class Timesheet
*
* @param string $rate
*
* @return KimaiTimesheet
* @return Timesheet
*/
public function setRate($rate)
{
@@ -477,7 +479,7 @@ class Timesheet
*
* @param string $fixedrate
*
* @return KimaiTimesheet
* @return Timesheet
*/
public function setFixedrate($fixedrate)
{
@@ -501,7 +503,7 @@ class Timesheet
*
* @param string $budget
*
* @return KimaiTimesheet
* @return Timesheet
*/
public function setBudget($budget)
{
@@ -525,7 +527,7 @@ class Timesheet
*
* @param string $approved
*
* @return KimaiTimesheet
* @return Timesheet
*/
public function setApproved($approved)
{
@@ -549,7 +551,7 @@ class Timesheet
*
* @param integer $statusid
*
* @return KimaiTimesheet
* @return Timesheet
*/
public function setStatusid($statusid)
{
@@ -573,7 +575,7 @@ class Timesheet
*
* @param boolean $billable
*
* @return KimaiTimesheet
* @return Timesheet
*/
public function setBillable($billable)
{

View File

@@ -13,9 +13,12 @@ namespace TimesheetBundle\EventListener;
use AppBundle\Event\ConfigureMainMenuEvent;
use AppBundle\Event\ConfigureAdminMenuEvent;
use Symfony\Component\Security\Core\Authorization\AuthorizationChecker;
use Avanzu\AdminThemeBundle\Model\MenuItemModel;
use Avanzu\AdminThemeBundle\Event\SidebarMenuEvent;
/**
* Class Menu
* Menus for timesheet
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
@@ -27,10 +30,18 @@ class Menu
public function onMainMenuConfigure(ConfigureMainMenuEvent $event)
{
$menu = $event->getMenu();
$auth = $event->getAuth();
$item = $menu->addChild('Timesheet', array('route' => 'timesheet'));
$item->setLabel('menu.timesheet');
$item->setChildrenAttribute('icon', 'clock-o');
$isLoggedIn = $auth->isGranted('IS_AUTHENTICATED_FULLY');
$isAdmin = $isLoggedIn && $auth->isGranted('ROLE_ADMIN');
if (!$isLoggedIn) {
return;
}
$menu->addItem(
new MenuItemModel('timesheet', 'menu.timesheet', 'timesheet', [], 'fa fa-clock-o')
);
}
/**
@@ -38,10 +49,18 @@ class Menu
*/
public function onAdminMenuConfigure(ConfigureAdminMenuEvent $event)
{
$menu = $event->getMenu();
$menu = $event->getAdminMenu();
$auth = $event->getAuth();
$item = $menu->addChild('TimeAdmin', array('route' => 'timesheet'));
//$item->setLabel('menu.admin_timesheet');
$item->setChildrenAttribute('icon', 'clock-o');
$isLoggedIn = $auth->isGranted('IS_AUTHENTICATED_FULLY');
$isAdmin = $isLoggedIn && $auth->isGranted('ROLE_ADMIN');
if (!$isAdmin) {
return;
}
$menu->addChild(
new MenuItemModel('timesheet_admin', 'menu.admin_timesheet', 'admin_timesheet_index', [], 'fa fa-clock-o')
);
}
}

View File

@@ -1,34 +1,34 @@
{% extends 'base.html.twig' %}
{% block body_id 'timesheet_index' %}
{% block page_title %}Timesheet{% endblock %}
{% block page_subtitle %}manage your times{% endblock %}
{% block main %}
{% if entries %}
<table class="table table-striped">
<thead>
<tr>
<th><i class="fa fa-calendar"></i> {{ 'label.date'|trans }}</th>
<th><i class="fa fa-circle-o"></i> {{ 'label.start'|trans }}</th>
<th><i class="fa fa-circle"></i> {{ 'label.end'|trans }}</th>
<th><i class="fa fa-clock-o"></i> {{ 'label.duration'|trans }}</th>
<th><i class="fa fa-user"></i> {{ 'label.user'|trans }}</th>
<th>{{ 'label.description'|trans }}</th>
</tr>
</thead>
<tbody>
{% for entry in entries %}
<table class="table table-striped">
<thead>
<tr>
<td>{{ entry.start|date("m/d/Y") }}</td>
<td>{{ entry.start|date("H:i") }}</td>
<td>{{ entry.end|date("H:i") }}</td>
<td>{{ entry.duration|gmdate }}</td>
<td>{{ entry.userid }}</td>
<td>{{ entry.description }}</td>
<th><i class="fa fa-calendar"></i> {{ 'label.date'|trans }}</th>
<th><i class="fa fa-circle-o"></i> {{ 'label.start'|trans }}</th>
<th><i class="fa fa-circle"></i> {{ 'label.end'|trans }}</th>
<th><i class="fa fa-clock-o"></i> {{ 'label.duration'|trans }}</th>
<th><i class="fa fa-user"></i> {{ 'label.user'|trans }}</th>
<th>{{ 'label.description'|trans }}</th>
</tr>
{% endfor %}
</tbody>
</table>
</thead>
<tbody>
{% for entry in entries %}
<tr>
<td>{{ entry.start|date("m/d/Y") }}</td>
<td>{{ entry.start|date("H:i") }}</td>
<td>{{ entry.end|date("H:i") }}</td>
<td>{{ entry.duration|gmdate }}</td>
<td>{{ entry.user.username }}</td>
<td>{{ entry.description }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<div class="well">{{ 'post.no_posts_found'|trans }}</div>
{% endif %}
@@ -37,7 +37,3 @@
{{ pagerfanta(entries, 'twitter_bootstrap3_translated', { routeName: 'timesheet_paginated' }) }}
</div>
{% endblock %}
{% block sidebar %}
{{ parent() }}
{% endblock %}

View File

@@ -12,6 +12,7 @@
namespace TimesheetBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use TimesheetBundle\EventListener\Menu as MenuListener;
/**
* This class defines the Bundle for all Timesheet related topics
@@ -20,4 +21,14 @@ use Symfony\Component\HttpKernel\Bundle\Bundle;
*/
class TimesheetBundle extends Bundle
{
/**
* Boots the Bundle.
*/
public function boot()
{
$listener = new MenuListener();
/* @var $dispatcher \Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher */
$dispatcher = $this->container->get('event_dispatcher');
}
}