Exemple #1
0
 /**
  * List all the clients.
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function indexAction()
 {
     $gridCollection = new GridCollection();
     $gridCollection->add('csbill.client.grid', 'active', 'check');
     $gridCollection->add('csbill.client.grid.archived', 'archived', 'archive');
     $gridCollection->add('csbill.client.grid.deleted', 'deleted', 'times');
     $grid = $this->get('grid')->create($gridCollection);
     return $grid->getGridResponse();
 }
Exemple #2
0
 /**
  * List all the available quotes.
  *
  * @return Response
  */
 public function indexAction()
 {
     $gridCollection = new GridCollection();
     $gridCollection->add('csbill.quote.grid.default_grid', 'active', 'check');
     $gridCollection->add('csbill.quote.grid.archived_grid', 'archived', 'archive');
     $grid = $this->get('grid')->create($gridCollection);
     /** @var QuoteRepository $quoteRepository */
     $quoteRepository = $this->getRepository('CSBillQuoteBundle:Quote');
     // Return the response of the grid to the template
     return $grid->getGridResponse(array('status_list' => array(Graph::STATUS_PENDING, Graph::STATUS_ACCEPTED, Graph::STATUS_CANCELLED, Graph::STATUS_DRAFT, Graph::STATUS_DECLINED), 'status_list_count' => array(Graph::STATUS_PENDING => $quoteRepository->getTotalQuotes(Graph::STATUS_PENDING), Graph::STATUS_ACCEPTED => $quoteRepository->getTotalQuotes(Graph::STATUS_ACCEPTED), Graph::STATUS_CANCELLED => $quoteRepository->getTotalQuotes(Graph::STATUS_CANCELLED), Graph::STATUS_DRAFT => $quoteRepository->getTotalQuotes(Graph::STATUS_DRAFT), Graph::STATUS_DECLINED => $quoteRepository->getTotalQuotes(Graph::STATUS_DECLINED))));
 }
Exemple #3
0
 /**
  * List all the invoices.
  *
  * @return Response
  */
 public function indexAction()
 {
     $gridCollection = new GridCollection();
     $gridCollection->add('csbill.invoice.grid.default_grid', 'active', 'check');
     $gridCollection->add('csbill.invoice.grid.archived_grid', 'archived', 'archive');
     $gridCollection->add('csbill.invoice.grid.recurring_grid', 'recurring', 'refresh');
     $grid = $this->get('grid')->create($gridCollection);
     /** @var \CSBill\InvoiceBundle\Repository\InvoiceRepository $invoiceRepository */
     $invoiceRepository = $this->getRepository('CSBillInvoiceBundle:Invoice');
     // Return the response of the grid to the template
     return $grid->getGridResponse(array('status_list' => array(Graph::STATUS_PENDING, Graph::STATUS_PAID, Graph::STATUS_CANCELLED, Graph::STATUS_DRAFT, Graph::STATUS_OVERDUE), 'status_list_count' => array(Graph::STATUS_PENDING => $invoiceRepository->getCountByStatus(Graph::STATUS_PENDING), Graph::STATUS_PAID => $invoiceRepository->getCountByStatus(Graph::STATUS_PAID), Graph::STATUS_CANCELLED => $invoiceRepository->getCountByStatus(Graph::STATUS_CANCELLED), Graph::STATUS_DRAFT => $invoiceRepository->getCountByStatus(Graph::STATUS_DRAFT), Graph::STATUS_OVERDUE => $invoiceRepository->getCountByStatus(Graph::STATUS_OVERDUE)), 'total_income' => $this->getRepository('CSBillPaymentBundle:Payment')->getTotalIncome(), 'total_outstanding' => $invoiceRepository->getTotalOutstanding()));
 }
Exemple #4
0
 /**
  * @param GridInterface|string $grid
  *
  * @return $this
  *
  * @throws \Exception
  */
 public function create($grid)
 {
     if ($grid instanceof GridCollection) {
         $this->collection = $grid;
         $activeGrid = $this->request->query->get('grid');
         $this->collection->setActive($activeGrid);
         $grid = $this->collection->getGrid($activeGrid)['grid'];
     }
     if (is_string($grid)) {
         $grid = $this->container->get($grid);
     }
     if (!$grid instanceof GridInterface) {
         throw new \Exception('Grid needs to implement GridInterface');
     }
     $this->entity = $grid;
     $source = $grid->getSource();
     $this->filters = new Filters($this->request->get('filter'));
     $grid->getFilters($this->filters);
     $searchString = $this->request->get('search');
     $source->manipulateQuery(function (QueryBuilder $queryBuilder) use($grid, $searchString) {
         if ($this->filters->isFilterActive()) {
             $filter = $this->filters->getActiveFilter();
             $filter($queryBuilder);
         }
         if (!empty($searchString)) {
             $this->searchString = $searchString;
             $grid->search($queryBuilder, $searchString);
         }
     });
     // Attach the source to the grid
     $this->setSource($source);
     $grid->getRowActions($collection = new Collection());
     if (!$collection->isEmpty()) {
         $actionsRow = $this->getActionColumn($collection);
         $this->addColumn($actionsRow, 100);
     }
     $massActions = $grid->getMassActions();
     array_walk($massActions, array($this, 'addMassAction'));
     $this->createHash();
     $requestData = $this->request->get($this->getHash());
     if (1 === count($requestData) && isset($requestData[self::REQUEST_QUERY_MASS_ACTION_ALL_KEYS_SELECTED]) && $requestData[self::REQUEST_QUERY_MASS_ACTION_ALL_KEYS_SELECTED] === '0') {
         $this->request->request->remove($this->getHash());
     }
     return $this;
 }