addHelperPath('App/License/View/Helper/', 'App\License\View\Helper\\'); $this->addColumn('text', 'id', ['title' => '#', 'orderBy' => 'id']); $this->addColumn('dateRange', 'period', [ 'title' => 'Taxation Period', 'orderBy' => 'start', 'start' => 'start', 'end' => 'end', ]); $this->addColumn('naicsCodes', 'naicsCodes', ['title' => 'Vendor Classifications']); $this->addColumn('money', 'total', ['orderBy' => 'total']); $this->addColumn('payment', 'payment', [ 'title' => 'Payment', 'orderBy' => 'status', 'elements' => [], 'initCallback' => [$this, 'initPaymentColumn'], ]); return parent::_initColumns(); } protected function url(array $query = []) { return View::getPage('url') . ($query ? '?' . http_build_query($query) : ''); } /** * @param $options * @return $this */ public function initPaymentColumn(&$options) { $options['items'] = []; $column = &$options['column']; $row = $options['row']; $column['elements'][] = $this->getStatusElement($row); if ($row['status'] == Entity::STATUS_PAID) { if ($row['transactionId']) { $column['elements'][] = ['a', 'View Receipt', [ 'target' => '_blank', 'href' => PdfView::getReceiptUrl($row['id']), ]]; } return $this; } $column['elements'][] = ['a', 'Download Tax Invoice', [ 'target' => '_blank', 'href' => Qs_FileFs::getUrl($row['invoiceFile']), ]]; if (!$row['transactionId']) { $column['elements'][] = ['a', 'Pay Invoice', [ 'href' => PayView::getStepUrl(PayView::STEP_PAYMENT) . '/' . $row['id'], ]]; } if ('y' == $row['inDispute']) { $column['elements'][] = ['label', 'Dispute sent', [ 'title' => 'Your dispute has been sent and is being processed', 'class' => 'label label-danger', ]]; } else { $column['elements'][] = ['a', 'Dispute Invoice', [ 'onclick' => "return confirm('Do you really want to dispute Taxation Invoice #{$row['id']}?')", 'href' => $this->url(['action' => 'disputeInvoice', 'id' => $row['id']]), ]]; } return $this; } public function getStatusElement(array $row) { static $statuses; if (null === $statuses) { $statuses = $this->getConfigArray('statuses'); $statuses[Entity::STATUS_PENDING] = 'Pending Payment'; } $statusTitle = Qs_Array::get($statuses, $row['status']); if ($row['transactionId']) { $paymentMethodTitle = $this->getConfigArray('paymentMethods')[$row['paymentMethod']]; return ['label', $statusTitle, [ 'title' => 'Paid by ' . $paymentMethodTitle . '. Transaction ID = ' . $row['transactionId'], 'class' => 'label ' . (($row['status'] == Entity::STATUS_PAID) ? 'label-success' : 'label-warning'), ]]; } return ['span', $statusTitle]; } }