Wallet > Payments History * @copyright Tamaranga */ class HistoryBlock extends Block { public function init() { parent::init(); $this->setTitle(_t('bills', 'Transactions History')); $this->setKey('account.wallet.history'); $this->setTemplate('account/history.block', 'bills'); } public function data() { $data = parent::data(); $perPage = $this->input->postget('page', TYPE_INT); # кол-во на страницу # per page $data['pgn_pp'] = [ -1 => ['t' => _t('pgn', 'show all'), 'c' => 100], 15 => ['t' => _t('pgn', '[cnt] per page', ['cnt' => 15]), 'c' => 15], 25 => ['t' => _t('pgn', '[cnt] per page', ['cnt' => 25]), 'c' => 25], 50 => ['t' => _t('pgn', '[cnt] per page', ['cnt' => 50]), 'c' => 50], ]; if (! isset($data['pgn_pp'][$perPage])) { $perPage = 15; } $filter = [ 'user_id' => $this->request->userId(), 'status' => Bills::STATUS_COMPLETED, ]; $total = Bills::model()->billsList($filter, true); $pages = new Pagination($total, $data['pgn_pp'][$perPage]['c'], '?' . Pagination::PAGE_PARAM); $data['page'] = $pages->getCurrentPage(); if ($total > 0) { $data['pgn'] = $pages->view([], tpl::PGN_COMPACT); $data['list'] = Bills::model()->billsList($filter, false, $pages->getLimitOffset()); if ($data['list']) { foreach ($data['list'] as &$bill) { $bill['plus'] = ($bill['type'] != Bills::TYPE_OUT_SERVICE); $bill['amount_formatted'] = Currency::formatPriceAndCurrency($bill['amount']); } unset($bill); } } else { $data['pgn'] = ''; $data['list'] = []; } $data['currency'] = Currency::default(); $data['statusText'] = [ Bills::TYPE_IN_PAY => _t('bills', 'Balance Top Up'), Bills::TYPE_IN_GIFT => _t('bills', 'Balance Top Up'), Bills::TYPE_OUT_SERVICE => _t('bills', 'Payment for the service'), ]; $data['list'] = Bills::template('account/history.list.block', $data); $data['list_empty'] = ($total <= 1); $data['total'] = $total; $data['perPage'] = $perPage; return $data; } public function onBillsHistoryListAction() { $data = $this->data(); return $this->getActionResponse([ 'pgn' => $data['pgn'], 'list' => $data['list'], 'total' => $data['total'], ]); } }