Skip to content

Commit

Permalink
improves dashboard statistics
Browse files Browse the repository at this point in the history
Fixes missing czech translation for statistics header. Improves clarity
of displayed information. Removes useless registration count. Adds data
for any paid orders.
  • Loading branch information
Amunak committed Jul 3, 2015
1 parent 529bad9 commit 08cfc71
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 26 deletions.
8 changes: 4 additions & 4 deletions src/Sylius/Bundle/CoreBundle/Doctrine/ORM/OrderRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,10 @@ protected function getCollectionQueryBuilderBetweenDates(\DateTime $from, \DateT
{
$queryBuilder = $this->getCollectionQueryBuilder();
if (null !== $state) {
$queryBuilder
->andWhere('o.state = :state')
->setParameter('state', $state)
;
$queryBuilder
->andWhere('o.state in (:state)')
->setParameter('state', (array) $state)
;
}

return $queryBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,23 @@ public function mainAction()
{
$orderRepository = $this->get('sylius.repository.order');
$userRepository = $this->get('sylius.repository.user');
$productRepository = $this->get('sylius.repository.product');

$date_from = new \DateTime('30 days ago');
$date_to = new \DateTime();

return $this->render('SyliusWebBundle:Backend/Dashboard:main.html.twig', array(
'orders_count' => $orderRepository->countBetweenDates(new \DateTime('1 month ago'), new \DateTime()),
'orders' => $orderRepository->findBy(array(), array('updatedAt' => 'desc'), 5),
'users' => $userRepository->findBy(array(), array('id' => 'desc'), 5),
'registrations_count' => $userRepository->countBetweenDates(new \DateTime('1 month ago'), new \DateTime()),
'sales' => $orderRepository->revenueBetweenDates(new \DateTime('1 month ago'), new \DateTime()),
'sales_confirmed' => $orderRepository->revenueBetweenDates(new \DateTime('1 month ago'), new \DateTime(), OrderInterface::STATE_CONFIRMED),
'products' => $productRepository->findUpcomingEvents(),
'orders' => $orderRepository->findBy(array(), array('updatedAt' => 'desc'), 5),
'orders_count' => $orderRepository->countBetweenDates($date_from, $date_to),
'orders_count_confirmed' => $orderRepository->countBetweenDates($date_from, $date_to, array(
OrderInterface::STATE_CONFIRMED,
OrderInterface::STATE_SHIPPED,
)),
'sales' => $orderRepository->revenueBetweenDates($date_from, $date_to),
'sales_confirmed' => $orderRepository->revenueBetweenDates($date_from, $date_to, array(
OrderInterface::STATE_CONFIRMED,
OrderInterface::STATE_SHIPPED,
)),
'users' => $userRepository->findBy(array(), array('id' => 'desc'), 5),
));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ sylius:
products: Produkty
users: Uživatelé
statistics:
header: Statistiky za posledních 30 dní
orders_confirmed_this_month: Objednávek zaplaceno
orders_this_month: Celkem objednávek
registrations_this_month: Celkem registrací
sales_confirmed_this_month: Z toho zaplaceno
sales_this_month: Prodeje
block:
body: Tělo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@ sylius:
products: Your products
users: Users
statistics:
header: This month's statistics
header: Statistics for the past 30 days
orders_confirmed_this_month: Orders paid
orders_this_month: Total orders
registrations_this_month: Total registrations
sales_confirmed_this_month: Confirmed sales
sales_this_month: Sales
backend_welcome: Hello <b>%name%</b>!
block:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@
<table class="table table-condensed">
<thead>
<tr>
<th colspan="2">{{ 'sylius.backend.statistics.header'|trans }}</th>
<th colspan="4">{{ 'sylius.backend.statistics.header'|trans }}</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ 'sylius.backend.statistics.sales_this_month'|trans }}</td>
<td>{{ sales|sylius_price }} ({{ sales_confirmed|sylius_price }})</td>
</tr>
<tr>
<td>{{ 'sylius.backend.statistics.orders_this_month'|trans }}</td>
<td>{{ orders_count }}</td>
</tr>
<tr>
<td>{{ 'sylius.backend.statistics.registrations_this_month'|trans }}</td>
<td>{{ registrations_count }}</td>
</tr>
<tr>
<td>{{ 'sylius.backend.statistics.sales_this_month'|trans }}</td>
<td>{{ sales|sylius_price }}</td>
<td>{{ 'sylius.backend.statistics.sales_confirmed_this_month'|trans }}</td>
<td>{{ sales_confirmed|sylius_price }}</td>
</tr>
<tr>
<td>{{ 'sylius.backend.statistics.orders_this_month'|trans }}</td>
<td>{{ orders_count }}</td>
<td>{{ 'sylius.backend.statistics.orders_confirmed_this_month'|trans }}</td>
<td>{{ orders_count_confirmed }}</td>
</tr>
</tbody>
</table>
</div>
Expand Down

0 comments on commit 08cfc71

Please sign in to comment.