/** * Payments grid operations handler * @param string $op * @param array $ids */ public function paymentsGridOpsHandler($op, $ids) { $me = $this->getUser()->getIdentity(); switch ($op) { case "delete": foreach ($ids as $id) { $this->doDeletePayment($id); } break; case "markCash": foreach ($ids as $id) { try { $this->paymentService->markAsDoneCash($id, $me); } catch (Exceptions\DataErrorException $ex) { $this->handleDataSave($id, "this", $ex); } } break; case "markAcc": foreach ($ids as $id) { try { $this->paymentService->markAsDoneAcc($id, $me); } catch (Exceptions\DataErrorException $ex) { $this->handleDataSave($id, "this", $ex); } } break; case "markSent": foreach ($ids as $id) { $this->paymentService->markAsSent($id, $me); } break; } $this->redirect("this"); }
/** * User's payments grid factory * @param string $name * @return Grid */ public function createComponentUserPaymentsGrid($name) { try { $seasons = $this->seasonService->getSelectSeasons(); } catch (Exceptions\DataErrorException $ex) { $this->handleDataLoad(null, ":System:Default:userRoot", $ex); } $grid = new Grid($this, $name); $grid->setModel($this->paymentService->getPaymentsDataSource($this->getUser()->getIdentity())); $grid->setTranslator($this->getTranslator()); $grid->setPrimaryKey("id"); $grid->addColumnNumber('id', '#')->cellPrototype->class[] = 'center'; $headerId = $grid->getColumn('id')->headerPrototype; $headerId->class[] = 'center'; $headerId->rowspan = "2"; $headerId->style['width'] = '0.1%'; $grid->addColumnNumber('amount', $this->tt('paymentsModule.admin.grid.amount'))->setSortable()->setFilterNumber(); $headerAm = $grid->getColumn('amount')->headerPrototype; $headerAm->class[] = 'center'; $grid->addColumnText('subject', $this->tt('paymentsModule.admin.grid.subject'))->setCustomRender($this->subjectRender)->setSortable()->setFilterText(); $headerSeas = $grid->getColumn('subject')->headerPrototype; $headerSeas->class[] = 'center'; $grid->addColumnDate('dueDate', $this->tt('paymentsModule.admin.grid.dueDate'), self::DATE_FORMAT)->setSortable()->setFilterDateRange(); $headerOrdered = $grid->getColumn('dueDate')->headerPrototype; $headerOrdered->class[] = 'center'; $states = [null => null] + PaymentStatus::getOptions(); $grid->addColumnText('status', $this->tt('paymentsModule.admin.grid.status'))->setTruncate(9)->setSortable()->setCustomRender($this->statusRender)->setFilterSelect($states); $grid->addColumnText('season', $this->tt('paymentsModule.admin.grid.season'))->setSortable()->setFilterSelect($seasons); $headerSeas = $grid->getColumn('season')->headerPrototype; $headerSeas->class[] = 'center'; $headerSta = $grid->getColumn('status')->headerPrototype; $headerSta->class[] = 'center'; $grid->addActionHref("show", "", "paymentDetails")->setIcon("eye-open"); $grid->addActionHref("markAsSent", "", "markAsSent!")->setIcon("check")->setConfirm(function ($u) { return $this->tt("paymentsModule.protected.grid.messages.rlyMarkAsSent", null, ["id" => $u->getId()]); }); $grid->setFilterRenderType($this->filterRenderType); return $grid; }