improvements

This commit is contained in:
Kevin Papst
2016-10-30 23:39:55 +01:00
parent 55ac11d517
commit 1678129fe9
47 changed files with 4390 additions and 1746 deletions

View File

@@ -42,4 +42,16 @@ class TimesheetController extends Controller
return $this->render('TimesheetBundle:timesheet:index.html.twig', ['entries' => $entries]);
}
public function statusEntryAction()
{
$user = $this->getUser();
$activeEntry = $this->getDoctrine()->getRepository(Timesheet::class)->getActiveEntry($user);
$activeEntry = null;
return $this->render(
'TimesheetBundle:Sidebar:navbar-panel.html.twig',
['entry' => $activeEntry]
);
}
}

View File

@@ -35,6 +35,8 @@ class LoadFixtures extends AppBundleLoadFixtures
const AMOUNT_TIMESHEET = 1000; // timesheet entries total
const AMOUNT_PROJECTS = 20; // projects entries total
const AMOUNT_CUSTOMER = 10; // customer entries total
const RATE_MIN = 10; // minimum rate for one hour
const RATE_MAX = 80; // maximum rate for one hour
/**
* {@inheritdoc}
@@ -96,33 +98,33 @@ class LoadFixtures extends AppBundleLoadFixtures
$amountUser = count($allUser);
$allActivity = $this->getAllActivities($manager);
$amountActivity = count($allActivity);
for ($i = 0; $i <= self::AMOUNT_TIMESHEET; $i++) {
$startDay = round($i / 2);
$start = new \DateTime();
$start = $start->modify('- ' . (rand(1, 400)) . ' days');
$start = $start->modify('- ' . (rand(1, $startDay)) . ' days');
$start = $start->modify('- ' . (rand(1, 86400)) . ' seconds');
$end = clone $start;
$end = $end->modify('+ '.(rand(1, 43200)).' seconds');
//$duration = $end->modify('- ' . $start->getTimestamp() . ' seconds')->getTimestamp();
$duration = $end->getTimestamp() - $start->getTimestamp();
$rate = rand(self::RATE_MIN, self::RATE_MAX);
$entry = new Timesheet();
$entry->setActivity($allActivity[array_rand($allActivity)]);
$entry->setStatusid(1); // TODO
$entry->setBillable($i % 2 == 0);
$entry->setBudget(0);
$entry->setCleared($i % 7 == 0);
$entry->setComment($this->getRandomPhrase());
$entry->setDescription($this->getRandomPhrase());
$entry->setLocation($this->getRandomLocation());
$entry->setStart($start->getTimestamp());
$entry->setEnd($end->getTimestamp());
$entry->setDuration($end->modify('- ' . $start->getTimestamp() . ' seconds')->getTimestamp());
$entry->setUser($allUser[rand(1, $amountUser)]);
//$entry->setApproved(false); // TODO
//$entry->setFixedrate(); // TODO
//$entry->setRate(); // TODO
//$entry->setTrackingnumber(); // TODO
$entry->setRate(round(($duration / 3600) * $rate));
$entry->setBegin($start);
// leave one running time entry
if ($i < self::AMOUNT_TIMESHEET) {
$entry->setEnd($end);
$entry->setDuration($duration);
}
$manager->persist($entry);
}
@@ -137,7 +139,7 @@ class LoadFixtures extends AppBundleLoadFixtures
$entry->setName($this->getRandomProject());
$entry->setBudget(rand(1000, 100000));
$entry->setComment($this->getRandomPhrase());
$entry->setCustomerId(rand(1, self::AMOUNT_CUSTOMER)); // TODO
$entry->setCustomerId(rand(1, self::AMOUNT_CUSTOMER)); // TODO should be a user object
$entry->setVisible($i % 3 != 0);
$manager->persist($entry);

View File

@@ -27,11 +27,11 @@ class Customer
/**
* @var integer
*
* @ORM\Column(name="customerID", type="integer")
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $customerid;
private $id;
/**
* @var string
@@ -52,14 +52,7 @@ class Customer
*
* @ORM\Column(name="visible", type="boolean", nullable=false)
*/
private $visible = '1';
/**
* @var boolean
*
* @ORM\Column(name="filter", type="boolean", nullable=false)
*/
private $filter = '0';
private $visible = true;
/**
* @var string
@@ -153,11 +146,12 @@ class Customer
private $timezone;
/**
* @var boolean
*
* @ORM\Column(name="trash", type="boolean", nullable=false)
* @return int
*/
private $trash = '0';
public function getId()
{
return $this->id;
}
/**
* Set name
@@ -183,78 +177,6 @@ class Customer
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
*
@@ -303,30 +225,6 @@ class Customer
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
*
@@ -638,38 +536,4 @@ class Customer
{
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

@@ -34,7 +34,7 @@ class Project
private $id;
/**
* FIXME
* FIXME manytoone
* @var integer
*
* @ORM\Column(name="customerID", type="integer", nullable=false)
@@ -76,6 +76,16 @@ class Project
*/
private $activities;
/**
* Get projectid
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set customerid
*
@@ -196,16 +206,6 @@ class Project
return $this->budget;
}
/**
* Get projectid
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* @return Activity[]
*/

View File

@@ -18,38 +18,48 @@ use Doctrine\ORM\Mapping as ORM;
* Timesheet entity.
*
* @ORM\Entity(repositoryClass="TimesheetBundle\Repository\TimesheetRepository")
* @ORM\Table(name="timeSheet", indexes={@ORM\Index(columns={"userID"}), @ORM\Index(name="activity", columns={"activity"})})
* @ORM\Table(name="timesheet", indexes={@ORM\Index(columns={"user"}), @ORM\Index(name="activity", columns={"activity"})})
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class Timesheet
{
/**
* @var integer
*
* @ORM\Column(name="start", type="integer", nullable=false)
*/
private $start = '0';
/**
* @var integer
*
* @ORM\Column(name="end", type="integer", nullable=false)
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $end = '0';
private $id;
/**
* @var \DateTime
*
* @ORM\Column(name="start_time", type="datetime", nullable=false)
*/
private $begin;
/**
* @var \DateTime
*
* @ORM\Column(name="end_time", type="datetime", nullable=true)
*/
private $end;
/**
* @var integer
*
* @ORM\Column(name="duration", type="integer", nullable=false)
* @ORM\Column(name="duration", type="integer", nullable=true)
*/
private $duration = '0';
private $duration = 0;
/**
* @var User
*
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\User")
* @ORM\JoinColumn(name="userID", referencedColumnName="userID")
* @ORM\JoinColumn(name="user", referencedColumnName="id")
*/
private $user;
@@ -68,142 +78,59 @@ class Timesheet
*/
private $description;
/**
* @var string
*
* @ORM\Column(name="comment", type="text", length=65535, nullable=true)
*/
private $comment;
/**
* @var boolean
*
* @ORM\Column(name="commentType", type="boolean", nullable=false)
*/
private $commenttype = '0';
/**
* @var boolean
*
* @ORM\Column(name="cleared", type="boolean", nullable=false)
*/
private $cleared = '0';
/**
* @var string
*
* @ORM\Column(name="location", type="string", length=50, nullable=true)
*/
private $location;
/**
* @var string
*
* @ORM\Column(name="trackingNumber", type="string", length=30, nullable=true)
*/
private $trackingnumber;
/**
* @var string
*
* @ORM\Column(name="rate", type="decimal", precision=10, scale=2, nullable=false)
*/
private $rate = '0.00';
private $rate = 0.00;
/**
* @var string
* Get entry id
*
* @ORM\Column(name="fixedRate", type="decimal", precision=10, scale=2, nullable=false)
* @return integer
*/
private $fixedrate = '0.00';
public function getId()
{
return $this->id;
}
/**
* @var string
*
* @ORM\Column(name="budget", type="decimal", precision=10, scale=2, nullable=true)
* @return \DateTime
*/
private $budget;
public function getBegin()
{
return $this->begin;
}
/**
* @var string
*
* @ORM\Column(name="approved", type="decimal", precision=10, scale=2, nullable=true)
*/
private $approved;
/**
* @var integer
*
* @ORM\Column(name="statusID", type="smallint", nullable=false)
*/
private $statusid;
/**
* @var boolean
*
* @ORM\Column(name="billable", type="boolean", nullable=true)
*/
private $billable;
/**
* @var integer
*
* @ORM\Column(name="timeEntryID", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $timeentryid;
/**
* Set start
*
* @param integer $start
*
* @param \DateTime $begin
* @return Timesheet
*/
public function setStart($start)
public function setBegin($begin)
{
$this->start = $start;
$this->begin = $begin;
return $this;
}
/**
* Get start
*
* @return integer
* @return \DateTime
*/
public function getStart()
public function getEnd()
{
return $this->start;
return $this->end;
}
/**
* Set end
*
* @param integer $end
*
* @param \DateTime $end
* @return Timesheet
*/
public function setEnd($end)
{
$this->end = $end;
return $this;
}
/**
* Get end
*
* @return integer
*/
public function getEnd()
{
return $this->end;
}
/**
* Set duration
*
@@ -214,7 +141,6 @@ class Timesheet
public function setDuration($duration)
{
$this->duration = $duration;
return $this;
}
@@ -238,7 +164,6 @@ class Timesheet
public function setUser(User $user)
{
$this->user = $user;
return $this;
}
@@ -262,7 +187,6 @@ class Timesheet
public function setActivity($activity)
{
$this->activity = $activity;
return $this;
}
@@ -286,7 +210,6 @@ class Timesheet
public function setDescription($description)
{
$this->description = $description;
return $this;
}
@@ -300,126 +223,6 @@ class Timesheet
return $this->description;
}
/**
* Set comment
*
* @param string $comment
*
* @return Timesheet
*/
public function setComment($comment)
{
$this->comment = $comment;
return $this;
}
/**
* Get comment
*
* @return string
*/
public function getComment()
{
return $this->comment;
}
/**
* Set commenttype
*
* @param boolean $commenttype
*
* @return Timesheet
*/
public function setCommenttype($commenttype)
{
$this->commenttype = $commenttype;
return $this;
}
/**
* Get commenttype
*
* @return boolean
*/
public function getCommenttype()
{
return $this->commenttype;
}
/**
* Set cleared
*
* @param boolean $cleared
*
* @return Timesheet
*/
public function setCleared($cleared)
{
$this->cleared = $cleared;
return $this;
}
/**
* Get cleared
*
* @return boolean
*/
public function getCleared()
{
return $this->cleared;
}
/**
* Set location
*
* @param string $location
*
* @return Timesheet
*/
public function setLocation($location)
{
$this->location = $location;
return $this;
}
/**
* Get location
*
* @return string
*/
public function getLocation()
{
return $this->location;
}
/**
* Set trackingnumber
*
* @param string $trackingnumber
*
* @return Timesheet
*/
public function setTrackingnumber($trackingnumber)
{
$this->trackingnumber = $trackingnumber;
return $this;
}
/**
* Get trackingnumber
*
* @return string
*/
public function getTrackingnumber()
{
return $this->trackingnumber;
}
/**
* Set rate
*
@@ -430,7 +233,6 @@ class Timesheet
public function setRate($rate)
{
$this->rate = $rate;
return $this;
}
@@ -443,134 +245,4 @@ class Timesheet
{
return $this->rate;
}
/**
* Set fixedrate
*
* @param string $fixedrate
*
* @return Timesheet
*/
public function setFixedrate($fixedrate)
{
$this->fixedrate = $fixedrate;
return $this;
}
/**
* Get fixedrate
*
* @return string
*/
public function getFixedrate()
{
return $this->fixedrate;
}
/**
* Set budget
*
* @param string $budget
*
* @return Timesheet
*/
public function setBudget($budget)
{
$this->budget = $budget;
return $this;
}
/**
* Get budget
*
* @return string
*/
public function getBudget()
{
return $this->budget;
}
/**
* Set approved
*
* @param string $approved
*
* @return Timesheet
*/
public function setApproved($approved)
{
$this->approved = $approved;
return $this;
}
/**
* Get approved
*
* @return string
*/
public function getApproved()
{
return $this->approved;
}
/**
* Set statusid
*
* @param integer $statusid
*
* @return Timesheet
*/
public function setStatusid($statusid)
{
$this->statusid = $statusid;
return $this;
}
/**
* Get statusid
*
* @return integer
*/
public function getStatusid()
{
return $this->statusid;
}
/**
* Set billable
*
* @param boolean $billable
*
* @return Timesheet
*/
public function setBillable($billable)
{
$this->billable = $billable;
return $this;
}
/**
* Get billable
*
* @return boolean
*/
public function getBillable()
{
return $this->billable;
}
/**
* Get timeentryid
*
* @return integer
*/
public function getTimeentryid()
{
return $this->timeentryid;
}
}

View File

@@ -0,0 +1,41 @@
<?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\Model;
/**
* Activity statistics
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class ActivityStatistic
{
/**
* @var int
*/
protected $totalAmount = 0;
/**
* @return int
*/
public function getTotalAmount()
{
return $this->totalAmount;
}
/**
* @param int $totalAmount
*/
public function setTotalAmount($totalAmount)
{
$this->totalAmount = $totalAmount;
}
}

View File

@@ -0,0 +1,41 @@
<?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\Model;
/**
* Project statistics
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class ProjectStatistic
{
/**
* @var int
*/
protected $totalAmount = 0;
/**
* @return int
*/
public function getTotalAmount()
{
return $this->totalAmount;
}
/**
* @param int $totalAmount
*/
public function setTotalAmount($totalAmount)
{
$this->totalAmount = $totalAmount;
}
}

View File

@@ -0,0 +1,81 @@
<?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\Model;
/**
* Timesheet statistics
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class TimesheetGlobalStatistic extends TimesheetStatistic
{
/**
* @var int
*/
protected $activeThisMonth = 0;
/**
* @var int
*/
protected $activeTotal = 0;
/**
* @var int
*/
protected $activeCurrently = 0;
/**
* @return int
*/
public function getActiveCurrently()
{
return $this->activeCurrently;
}
/**
* @param int $activeCurrently
*/
public function setActiveCurrently($activeCurrently)
{
$this->activeCurrently = $activeCurrently;
}
/**
* @return int
*/
public function getActiveThisMonth()
{
return $this->activeThisMonth;
}
/**
* @param int $activeThisMonth
*/
public function setActiveThisMonth($activeThisMonth)
{
$this->activeThisMonth = $activeThisMonth;
}
/**
* @return int
*/
public function getActiveTotal()
{
return $this->activeTotal;
}
/**
* @param int $activeTotal
*/
public function setActiveTotal($activeTotal)
{
$this->activeTotal = $activeTotal;
}
}

View File

@@ -0,0 +1,101 @@
<?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\Model;
/**
* Timesheet statistics
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class TimesheetStatistic
{
/**
* @var int
*/
protected $durationThisMonth = 0;
/**
* @var int
*/
protected $durationTotal = 0;
/**
* @var int
*/
protected $amountThisMonth = 0;
/**
* @var int
*/
protected $amountTotal = 0;
/**
* @return int
*/
public function getDurationThisMonth()
{
return $this->durationThisMonth;
}
/**
* @param int $durationThisMonth
*/
public function setDurationThisMonth($durationThisMonth)
{
$this->durationThisMonth = $durationThisMonth;
}
/**
* @return int
*/
public function getAmountTotal()
{
return $this->amountTotal;
}
/**
* @param int $amountTotal
*/
public function setAmountTotal($amountTotal)
{
$this->amountTotal = $amountTotal;
}
/**
* @return int
*/
public function getDurationTotal()
{
return $this->durationTotal;
}
/**
* @param int $durationTotal
*/
public function setDurationTotal($durationTotal)
{
$this->durationTotal = $durationTotal;
}
/**
* @return int
*/
public function getAmountThisMonth()
{
return $this->amountThisMonth;
}
/**
* @param int $amountThisMonth
*/
public function setAmountThisMonth($amountThisMonth)
{
$this->amountThisMonth = $amountThisMonth;
}
}

View File

@@ -17,6 +17,7 @@ use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query;
use Pagerfanta\Adapter\DoctrineORMAdapter;
use Pagerfanta\Pagerfanta;
use TimesheetBundle\Model\ActivityStatistic;
/**
* Class ActivityRepository
@@ -26,17 +27,48 @@ use Pagerfanta\Pagerfanta;
class ActivityRepository extends EntityRepository
{
/**
* Return statistic data for all user.
*
* @return ActivityStatistic
*/
public function getGlobalStatistics()
{
$countAll = $this->getEntityManager()
->createQuery('SELECT COUNT(a.id) FROM TimesheetBundle:Activity a')
->getSingleScalarResult();
$stats = new ActivityStatistic();
$stats->setTotalAmount($countAll);
return $stats;
}
/**
* @param User $user
* @return Query
*/
public function queryLatest(User $user = null)
protected function queryLatest(User $user = null)
{
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select('a')
->from('TimesheetBundle:Activity', 'a')
->orderBy('a.name', 'DESC');
->orderBy('a.id', 'DESC');
return $qb->getQuery();
}
/**
* @param string $orderBy
* @return Query
*/
protected function queryAll($orderBy = 'id')
{
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select('a')
->from('TimesheetBundle:Activity', 'a')
->orderBy('a.' . $orderBy, 'ASC');
return $qb->getQuery();
}

View File

@@ -17,6 +17,7 @@ use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query;
use Pagerfanta\Adapter\DoctrineORMAdapter;
use Pagerfanta\Pagerfanta;
use TimesheetBundle\Model\ProjectStatistic;
/**
* Class ProjectRepository
@@ -26,11 +27,27 @@ use Pagerfanta\Pagerfanta;
class ProjectRepository extends EntityRepository
{
/**
* Return statistic data for all user.
*
* @return ProjectStatistic
*/
public function getGlobalStatistics()
{
$countAll = $this->getEntityManager()
->createQuery('SELECT COUNT(p.id) FROM TimesheetBundle:Project p')
->getSingleScalarResult();
$stats = new ProjectStatistic();
$stats->setTotalAmount($countAll);
return $stats;
}
/**
* @param User $user
* @return Query
*/
public function queryLatest(User $user = null)
protected function queryLatest(User $user = null)
{
$qb = $this->getEntityManager()->createQueryBuilder();
@@ -41,7 +58,11 @@ class ProjectRepository extends EntityRepository
return $qb->getQuery();
}
public function queryAll($orderBy = 'id')
/**
* @param string $orderBy
* @return Query
*/
protected function queryAll($orderBy = 'id')
{
$qb = $this->getEntityManager()->createQueryBuilder();

View File

@@ -15,8 +15,12 @@ use AppBundle\Entity\User;
use TimesheetBundle\Entity\Timesheet;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query;
use Doctrine\DBAL\Types\Type;
use Pagerfanta\Adapter\DoctrineORMAdapter;
use Pagerfanta\Pagerfanta;
use TimesheetBundle\Model\TimesheetGlobalStatistic;
use TimesheetBundle\Model\TimesheetStatistic;
use DateTime;
/**
* Class TimesheetRepository
@@ -26,6 +30,122 @@ use Pagerfanta\Pagerfanta;
class TimesheetRepository extends EntityRepository
{
protected function queryThisMonth($select, User $user = null)
{
$qb = $this->getEntityManager()->createQueryBuilder();
// FIXME
$end = new DateTime();
$begin = $end->sub(new \DateInterval("P30D"));
$qb->select($select)
->from('TimesheetBundle:Timesheet', 't')
->where($qb->expr()->gt('t.begin', ':from'))
->andWhere($qb->expr()->gt('t.end', ':to'))
->setParameter('from', $begin, Type::DATETIME)
->setParameter('to', $end, Type::DATETIME);
if (null !== $user) {
$qb->andWhere('t.user = :user')
->setParameter('user', $user);
}
return $qb;
}
/**
* Fetch statistic data for one user.
*
* @param User $user
* @return TimesheetStatistic
*/
public function getUserStatistics(User $user)
{
$durationTotal = $this->getEntityManager()
->createQuery('SELECT SUM(t.duration) FROM TimesheetBundle:Timesheet t WHERE t.user = :user')
->setParameter('user', $user)
->getSingleScalarResult();
$rateTotal = $this->getEntityManager()
->createQuery('SELECT SUM(t.rate) FROM TimesheetBundle:Timesheet t WHERE t.user = :user')
->setParameter('user', $user)
->getSingleScalarResult();
$amountMonth = $this->queryThisMonth('SUM(t.rate)', $user)
->getQuery()
->getSingleScalarResult();
$durationMonth = $this->queryThisMonth('SUM(t.duration)', $user)
->getQuery()
->getSingleScalarResult();
$stats = new TimesheetStatistic();
$stats->setAmountTotal($rateTotal);
$stats->setDurationTotal($durationTotal);
$stats->setAmountThisMonth($amountMonth);
$stats->setDurationThisMonth($durationMonth);
return $stats;
}
/**
* Fetch statistic data for all user.
*
* @return TimesheetStatistic
*/
public function getGlobalStatistics()
{
$durationTotal = $this->getEntityManager()
->createQuery('SELECT SUM(t.duration) FROM TimesheetBundle:Timesheet t')
->getSingleScalarResult();
$rateTotal = $this->getEntityManager()
->createQuery('SELECT SUM(t.rate) FROM TimesheetBundle:Timesheet t')
->getSingleScalarResult();
$userTotal = $this->getEntityManager()
->createQuery('SELECT COUNT(DISTINCT(t.user)) FROM TimesheetBundle:Timesheet t')
->getSingleScalarResult();
$activeNow = $this->getActiveEntry();
$amountMonth = $this->queryThisMonth('SUM(t.rate)')
->getQuery()
->getSingleScalarResult();
$durationMonth = $this->queryThisMonth('SUM(t.duration)')
->getQuery()
->getSingleScalarResult();
$activeMonth = $this->queryThisMonth('COUNT(DISTINCT(t.user))')
->getQuery()
->getSingleScalarResult();
$stats = new TimesheetGlobalStatistic();
$stats->setAmountTotal($rateTotal);
$stats->setDurationTotal($durationTotal);
$stats->setActiveTotal($userTotal);
$stats->setActiveCurrently(count($activeNow));
$stats->setActiveThisMonth($activeMonth);
$stats->setAmountThisMonth($amountMonth);
$stats->setDurationThisMonth($durationMonth);
return $stats;
}
/**
* @param User $user
* @return Query
*/
public function getActiveEntry(User $user = null)
{
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select('t')
->from('TimesheetBundle:Timesheet', 't')
->where('t.begin > 0')
->andWhere('t.end is NULL');
$params = [];
if (null !== $user) {
$qb->andWhere('t.user = :user');
$params['user'] = $user;
}
return $qb->getQuery()->execute($params);
}
/**
* @param User $user
* @return Query
@@ -36,7 +156,7 @@ class TimesheetRepository extends EntityRepository
$qb->select('t')
->from('TimesheetBundle:Timesheet', 't')
->orderBy('t.start', 'DESC');
->orderBy('t.begin', 'DESC');
if (null !== $user) {
$qb->where('t.user = :user')

View File

@@ -0,0 +1,12 @@
{% import "AvanzuAdminThemeBundle:layout:macros.html.twig" as macro %}
<!-- Sidebar user panel -->
<div class="user-panel">
<div class="pull-left image">
<a href="#" id="ticktac">
<img src="{{ asset('images/buzzer-on.png') }}"/>
</a>
</div>
<div class="pull-left info">
<p>10:39:05</p>
</div>
</div>

View File

@@ -1,37 +1,31 @@
{% extends 'base.html.twig' %}
{% import "macros/widgets.html.twig" as widgets %}
{% import "macros/datatables.html.twig" as tables %}
{% block page_title %}{{ 'admin_activity.title'|trans }}{% endblock %}
{% block page_subtitle %}{{ 'admin_activity.subtitle'|trans }}{% endblock %}
{% block main %}
{% if entries.count > 0 %}
<table class="table table-striped">
<thead>
<tr>
<th>{{ 'label.id'|trans }}</th>
<th><i class="fa fa-bookmark-o"></i> {{ 'label.name'|trans }}</th>
<th><i class="fa fa-book"></i> {{ 'label.project'|trans }}</th>
<th><i class="fa fa-comment-o"></i> {{ 'label.comment'|trans }}</th>
<th><i class="fa fa-eye"></i> {{ 'label.visible'|trans }}</th>
</tr>
</thead>
<tbody>
{% for entry in entries %}
<tr>
<td>{{ entry.id }}</td>
<td>{{ entry.name }}</td>
<td>{{ entry.project }}</td>
<td>{{ entry.comment }}</td>
<td>{{ widgets.badge_visible(entry.visible) }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{{ tables.data_table_header({
'label.id': '',
'label.name': 'bookmark-o',
'label.project': 'book',
'label.comment': 'comment-o',
'label.visible': 'eye',
}) }}
<div class="navigation text-center">
{{ pagerfanta(entries, 'twitter_bootstrap3_translated', { routeName: 'admin_activity_paginated' }) }}
</div>
{% for entry in entries %}
<tr>
<td>{{ entry.id }}</td>
<td>{{ entry.name }}</td>
<td>{{ entry.project }}</td>
<td>{{ entry.comment }}</td>
<td>{{ widgets.label_visible(entry.visible) }}</td>
</tr>
{% endfor %}
{{ tables.data_table_footer(entries, 'admin_activity_paginated') }}
{% else %}
{{ widgets.callout('warning', 'error.no_entries_found') }}
{% endif %}

View File

@@ -1,39 +1,33 @@
{% extends 'base.html.twig' %}
{% import "macros/widgets.html.twig" as widgets %}
{% import "macros/datatables.html.twig" as tables %}
{% block page_title %}{{ 'admin_project.title'|trans }}{% endblock %}
{% block page_subtitle %}{{ 'admin_project.subtitle'|trans }}{% endblock %}
{% block main %}
{% if entries.count > 0 %}
<table class="table table-striped">
<thead>
<tr>
<th>{{ 'label.id'|trans }}</th>
<th><i class="fa fa-bookmark-o"></i> {{ 'label.name'|trans }}</th>
<th><i class="fa fa-comment-o"></i> {{ 'label.comment'|trans }}</th>
<th><i class="fa fa-eye"></i> {{ 'label.visible'|trans }}</th>
<th><i class="fa fa-tasks"></i> {{ 'label.activity'|trans }}</th>
<th><i class="fa fa-credit-card"></i> {{ 'label.budget'|trans }}</th>
</tr>
</thead>
<tbody>
{% for entry in entries %}
<tr>
<td>{{ entry.id }}</td>
<td>{{ entry.name }}</td>
<td>{{ entry.comment }}</td>
<td>{{ widgets.badge_visible(entry.visible) }}</td>
<td>{{ widgets.badge_counter(entry.activities.count) }}</td>
<td>{{ entry.budget}}</td>
</tr>
{% endfor %}
</tbody>
</table>
{{ tables.data_table_header({
'label.id': '',
'label.name': 'bookmark-o',
'label.comment': 'comment-o',
'label.activity': 'tasks',
'label.budget': 'credit-card',
'label.visible': 'eye',
}) }}
<div class="navigation text-center">
{{ pagerfanta(entries, 'twitter_bootstrap3_translated', { routeName: 'admin_project_paginated' }) }}
</div>
{% for entry in entries %}
<tr>
<td>{{ entry.id }}</td>
<td>{{ entry.name }}</td>
<td>{{ entry.comment }}</td>
<td>{{ widgets.badge_counter(entry.activities.count) }}</td>
<td>{{ entry.budget|money}}</td>
<td>{{ widgets.label_visible(entry.visible) }}</td>
</tr>
{% endfor %}
{{ tables.data_table_footer(entries, 'admin_project_paginated') }}
{% else %}
{{ widgets.callout('warning', 'error.no_entries_found') }}
{% endif %}

View File

@@ -1,39 +1,32 @@
{% extends 'base.html.twig' %}
{% import "macros/widgets.html.twig" as widgets %}
{% import "macros/datatables.html.twig" as widgets %}
{% block page_title %}{{ 'admin_timesheet.title'|trans }}{% endblock %}
{% block page_subtitle %}{{ 'admin_timesheet.subtitle'|trans }}{% endblock %}
{% block main %}
{% if entries.count > 0 %}
<table class="table table-striped">
<thead>
<tr>
<th><i class="fa fa-calendar"></i> {{ 'label.date'|trans }}</th>
<th><i class="fa fa-hourglass-start"></i> {{ 'label.starttime'|trans }}</th>
<th><i class="fa fa-hourglass-end"></i> {{ 'label.endtime'|trans }}</th>
<th><i class="fa fa-clock-o"></i> {{ 'label.duration'|trans }}</th>
<th><i class="fa fa-user"></i> {{ 'label.username'|trans }}</th>
<th><i class="fa fa-pencil-square-o"></i> {{ 'label.description'|trans }}</th>
</tr>
</thead>
<tbody>
{% for entry in entries %}
<tr>
<td>{{ entry.start|date(kimai_context.date_1) }}</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>
{{ widgets.data_table_header({
'label.date': 'calendar',
'label.starttime': 'hourglass-start',
'label.endtime': 'hourglass-end',
'label.duration': 'clock-o',
'label.username': 'user',
'label.description': 'pencil-square-o',
}) }}
<div class="navigation text-center">
{{ pagerfanta(entries, 'twitter_bootstrap3_translated', { routeName: 'admin_timesheet_paginated' }) }}
</div>
{% for entry in entries %}
<tr>
<td>{{ entry.begin|date(kimai_context.date_1) }}</td>
<td>{{ entry.begin|date("H:i") }}</td>
<td>{{ entry.end|date("H:i") }}</td>
<td>{{ entry.duration|duration }}</td>
<td>{{ entry.user.username }}</td>
<td>{{ entry.description }}</td>
</tr>
{% endfor %}
{{ widgets.data_table_footer(entries, 'admin_timesheet_paginated') }}
{% else %}
{{ widgets.callout('warning', 'error.no_entries_found') }}
{% endif %}

View File

@@ -1,39 +1,30 @@
{% extends 'base.html.twig' %}
{% import "macros/widgets.html.twig" as widgets %}
{% import "macros/datatables.html.twig" as widgets %}
{% block page_title %}{{ 'timesheet.title'|trans }}{% endblock %}
{% block page_subtitle %}{{ 'timesheet.subtitle'|trans }}{% endblock %}
{% block main %}
{% if entries.count > 0 %}
<table class="table table-striped">
<thead>
<tr>
<th><i class="fa fa-calendar"></i> {{ 'label.date'|trans }}</th>
<th><i class="fa fa-hourglass-start"></i> {{ 'label.starttime'|trans }}</th>
<th><i class="fa fa-hourglass-end"></i> {{ 'label.endtime'|trans }}</th>
<th><i class="fa fa-clock-o"></i> {{ 'label.duration'|trans }}</th>
<th><i class="fa fa-user"></i> {{ 'label.username'|trans }}</th>
<th><i class="fa fa-pencil-square-o"></i> {{ 'label.description'|trans }}</th>
</tr>
</thead>
<tbody>
{% for entry in entries %}
<tr>
<td>{{ entry.start|date(kimai_context.date_1) }}</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>
{{ widgets.data_table_header({
'label.date': 'calendar',
'label.starttime': 'hourglass-start',
'label.endtime': 'hourglass-end',
'label.duration': 'clock-o',
'label.description': 'pencil-square-o',
}) }}
<div class="navigation text-center">
{{ pagerfanta(entries, 'twitter_bootstrap3_translated', { routeName: 'timesheet_paginated' }) }}
</div>
{% for entry in entries %}
<tr>
<td>{{ entry.begin|date(kimai_context.date_1) }}</td>
<td>{{ entry.begin|date("H:i") }}</td>
<td>{{ entry.end|date("H:i") }}</td>
<td>{{ entry.duration|duration }}</td>
<td>{{ entry.description }}</td>
</tr>
{% endfor %}
{{ widgets.data_table_footer(entries, 'timesheet_paginated') }}
{% else %}
{{ widgets.callout('warning', 'error.no_entries_found') }}
{% endif %}