Add customer functionality (#26)
* improved toolbar * added "create customer" functionality #22
This commit is contained in:
@@ -56,12 +56,13 @@ abstract class AbstractRepository extends EntityRepository
|
||||
/**
|
||||
* @param Query $query
|
||||
* @param int $page
|
||||
* @param int $maxPerPage
|
||||
* @return Pagerfanta
|
||||
*/
|
||||
protected function getPager(Query $query, $page = 1)
|
||||
protected function getPager(Query $query, $page = 1, $maxPerPage = 25)
|
||||
{
|
||||
$paginator = new Pagerfanta(new DoctrineORMAdapter($query, false));
|
||||
$paginator->setMaxPerPage(25);
|
||||
$paginator->setMaxPerPage($maxPerPage);
|
||||
$paginator->setCurrentPage($page);
|
||||
|
||||
return $paginator;
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace TimesheetBundle\Repository;
|
||||
|
||||
use TimesheetBundle\Entity\Customer;
|
||||
use TimesheetBundle\Model\CustomerStatistic;
|
||||
use TimesheetBundle\Model\Query\CustomerQuery;
|
||||
|
||||
/**
|
||||
* Class CustomerRepository
|
||||
@@ -47,4 +48,25 @@ class CustomerRepository extends AbstractRepository
|
||||
$stats->setTotalAmount($countAll);
|
||||
return $stats;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CustomerQuery $query
|
||||
* @return \Pagerfanta\Pagerfanta
|
||||
*/
|
||||
public function findByQuery(CustomerQuery $query)
|
||||
{
|
||||
$qb = $this->getEntityManager()->createQueryBuilder();
|
||||
|
||||
$qb->select('c')
|
||||
->from('TimesheetBundle:Customer', 'c')
|
||||
->orderBy('c.' . $query->getOrderBy(), 'ASC');
|
||||
|
||||
if ($query->getVisibility() === CustomerQuery::SHOW_VISIBLE) {
|
||||
$qb->andWhere('c.visible = 1');
|
||||
} elseif ($query->getVisibility() === CustomerQuery::SHOW_HIDDEN) {
|
||||
$qb->andWhere('c.visible = 0');
|
||||
}
|
||||
|
||||
return $this->getPager($qb->getQuery(), $query->getPage(), $query->getPageSize());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user