예제 #1
0
 public function testStyling()
 {
     BootstrapStyling::applyTo($this->makeGrid());
     $this->checkOutput();
     FoundationStyling::applyTo($this->makeGrid());
     $this->checkOutput();
     SemanticUIStyling::applyTo($this->makeGrid());
     $this->checkOutput();
 }
예제 #2
0
 public function getHistory()
 {
     $coins_list = function () {
         $data = ['' => 'All'];
         foreach (Cache::remember('coin_list', Config::get('cache.ttl'), function () {
             return Wallet::select('short as coin')->get();
         }) as $wallet) {
             $data[$wallet->coin] = $wallet->coin;
         }
         return $data;
     };
     $provider = new EloquentDataProvider(WalletsTransaction::selectRaw('wallets_transactions.id as id, wallets_transactions.amount, wallets_transactions.created_at, wallets_transactions.updated_at, wallets_transactions.txid, wallets_transactions.confirmed, wallets.short as coin')->where('user_id', Auth::user()->id)->leftJoin('wallets', 'wallets.id', '=', 'wallets_transactions.wallet_id'));
     Services::resourceManager()->ignoreCss(['bootstrap']);
     Services::resourceManager()->ignoreJs(['bootstrap']);
     $grid = new Grid($provider, [(new Column('wallets_transactions.id', 'ID'))->setValueFormatter(function ($value, WalletsTransaction $row = null) {
         if (!empty($row->id)) {
             return $row->id;
         } else {
             return $value;
         }
     }), new Column('txid', 'TxID'), (new Column('amount'))->setValueFormatter(function ($value, WalletsTransaction $row = null) {
         if (!empty($row)) {
             if ($value > 0) {
                 return HTML::tag('span', '+' . $value, ['class' => 'label label-success']);
             } else {
                 return HTML::tag('span', $value, ['class' => 'label label-danger']);
             }
         } else {
             return $value;
         }
     }), new Column('coin', 'Coin'), (new Column('confirmed'))->setValueFormatter(function ($value, WalletsTransaction $row = null) {
         if (!empty($row)) {
             if ($value) {
                 return HTML::tag('span', 'Confirmed', ['class' => 'label label-success']);
             } else {
                 return HTML::tag('span', 'Pending', ['class' => 'label label-info']);
             }
         }
     }), (new Column('wallets_transactions.created_at', 'Created At'))->setValueFormatter(function ($value, WalletsTransaction $row = null) {
         if (!empty($row->created_at)) {
             return $row->created_at;
         } else {
             return $value;
         }
     }), new Column('updated_at'), new AjaxDetailsRow(function (WalletsTransaction $row) {
         return url('/user/wallets/details', ['id' => $row->id]);
     }), new FilterControl('txid', FilterOperation::OPERATOR_STR_CONTAINS, new InputOption('txid', ['txid' => Input::get('txid')])), (new FilterControl('wallets.short', FilterOperation::OPERATOR_EQ, new InputOption('coin', ['coin' => Input::get('coin')])))->setView(new TemplateView('select', ['options' => $coins_list(), 'label' => 'Coin', 'inputAttributes' => ['style' => 'width: 50px;']])), (new FilterControl('confirmed', FilterOperation::OPERATOR_EQ, new InputOption('confirmed', ['confirmed' => Input::get('confirmed')])))->setView(new TemplateView('select', ['options' => ['' => 'All', 0 => 'Pending', 1 => 'Confirmed']])), new PageSizeSelectControl(new InputOption('ps', ['ps' => Input::get('ps')], 10), [10, 50, 100, 500, 1000]), new CsvExport(new InputOption('csv', ['csv' => Input::get('csv')])), new ResetButton(), new PageTotalsRow(['amount' => PageTotalsRow::OPERATION_SUM]), new PaginationControl(new InputOption('page', ['page' => Input::get('page')], 1), 10, $provider), new ColumnSortingControl('wallets_transactions.id', new InputOption('sort', ['sort' => Input::get('sort')], 'wallets_transactions.id-dir-desc')), new ColumnSortingControl('amount', new InputOption('sort', ['sort' => Input::get('sort')])), new ColumnSortingControl('wallets_transactions.created_at', new InputOption('sort', ['sort' => Input::get('sort')]))]);
     $customization = new BootstrapStyling();
     $customization->apply($grid);
     $grid = $grid->render();
     return view('user.wallets.history', compact('grid'));
 }
예제 #3
0
 public function getHistory()
 {
     $coins_list = function () {
         $data = ['' => 'All'];
         foreach (Cache::remember('coin_list', Config::get('cache.ttl'), function () {
             return Wallet::select('short as coin')->get();
         }) as $wallet) {
             $data[$wallet->coin] = $wallet->coin;
         }
         return $data;
     };
     $provider = new EloquentDataProvider(OrdersTransaction::selectRaw('0 as total, orders_transactions.fee as fee, orders_transactions.id as id, orders_transactions.order_id as order_id, orders_transactions.amount, orders_transactions.price, orders_transactions.created_at, orders_transactions.updated_at, orders_transactions.type, w1.short as coin1, w2.short as coin2')->where('user_id', Auth::user()->id)->leftJoin('wallets as w1', 'w1.id', '=', 'orders_transactions.wallet_id')->leftJoin('wallets as w2', 'w2.id', '=', 'orders_transactions.want_wallet_id'));
     Services::resourceManager()->ignoreCss(['bootstrap']);
     Services::resourceManager()->ignoreJs(['bootstrap']);
     $grid = new Grid($provider, [(new Column('orders_transactions.id', 'ID'))->setValueFormatter(function ($value, OrdersTransaction $row = null) {
         if (!empty($row->id)) {
             return $row->id;
         } else {
             return $value;
         }
     }), (new Column('orders_transactions.order_id', 'Order ID'))->setValueFormatter(function ($value, OrdersTransaction $row = null) {
         if (!empty($row->order_id)) {
             return $row->order_id;
         } else {
             return $value;
         }
     }), (new Column('coin1'))->setValueFormatter(function ($value, OrdersTransaction $row = null) {
         if (!empty($row)) {
             return $row->coin2 . '/' . $row->coin1;
         } else {
             return $value;
         }
     }), (new Column('type'))->setValueFormatter(function ($value, OrdersTransaction $row = null) {
         if (!empty($row)) {
             if ($value == 'buy') {
                 return HTML::tag('span', $value, ['class' => 'label label-success']);
             } else {
                 return HTML::tag('span', $value, ['class' => 'label label-danger']);
             }
         } else {
             return $value;
         }
     }), (new Column('amount'))->setValueFormatter(function ($value, OrdersTransaction $row = null) {
         if (!empty($row)) {
             return HTML::tag('span', sprintf('%.8f %s', $row->amount, $row->coin2));
         } else {
             return $value;
         }
     }), (new Column('price'))->setValueFormatter(function ($value, OrdersTransaction $row = null) {
         if (!empty($row)) {
             return HTML::tag('span', sprintf('%.8f %s', $row->price, $row->coin1));
         } else {
             return $value;
         }
     }), (new Column('fee'))->setValueFormatter(function ($value, OrdersTransaction $row = null) {
         if (!empty($row)) {
             if ($row->type == 'sell') {
                 return HTML::tag('span', sprintf('%.8f %s (%.2f%%)', Order::calcFee($row->amount, $row->fee), $row->coin1, $row->fee));
             } else {
                 return HTML::tag('span', sprintf('%.8f %s (%.2f%%)', Order::calcFee($row->amount * $row->price, $row->fee), $row->coin2, $row->fee));
             }
         } else {
             return $value;
         }
     }), (new Column('total'))->setValueFormatter(function ($value, OrdersTransaction $row = null) {
         if (!empty($row)) {
             if ($row->type == 'buy') {
                 return HTML::tag('span', sprintf('%.8f %s', $row->amount - Order::calcFee($row->amount, $row->fee), $row->coin2));
             } else {
                 return HTML::tag('span', sprintf('%.8f %s', $row->amount * $row->price - Order::calcFee($row->amount * $row->price, $row->fee), $row->coin1));
             }
         } else {
             return $value;
         }
     }), (new Column('orders_transactions.created_at', 'Created At'))->setValueFormatter(function ($value, OrdersTransaction $row = null) {
         if (!empty($row->created_at)) {
             return $row->created_at;
         } else {
             return $value;
         }
     }), new Column('updated_at'), (new FilterControl('wallets.short', FilterOperation::OPERATOR_EQ, new InputOption('coin', ['coin' => Input::get('coin')])))->setView(new TemplateView('select', ['options' => $coins_list(), 'label' => 'Coin', 'inputAttributes' => ['style' => 'width: 50px;']])), new PageSizeSelectControl(new InputOption('ps', ['ps' => Input::get('ps')], 10), [10, 50, 100, 500, 1000]), new CsvExport(new InputOption('csv', ['csv' => Input::get('csv')])), new ResetButton(), new PageTotalsRow(['amount' => PageTotalsRow::OPERATION_SUM]), new PaginationControl(new InputOption('page', ['page' => Input::get('page')], 1), 10, $provider), new ColumnSortingControl('orders_transactions.id', new InputOption('sort', ['sort' => Input::get('sort')], 'orders_transactions.id-dir-desc')), new ColumnSortingControl('amount', new InputOption('sort', ['sort' => Input::get('sort')])), new ColumnSortingControl('orders_transactions.created_at', new InputOption('sort', ['sort' => Input::get('sort')]))]);
     $customization = new BootstrapStyling();
     $customization->apply($grid);
     $grid = $grid->render();
     return view('user.orders.history', compact('grid'));
 }
예제 #4
0
 protected function demo14Details()
 {
     $provider = $this->getDataProvider();
     $provider->operations()->add(new FilterOperation('id', FilterOperation::OPERATOR_EQ, $_GET['id']));
     foreach ($provider as $item) {
         $view = new TemplateView('data_view/table', get_object_vars($item));
         BootstrapStyling::applyTo($view);
         $layout = new DataView(function () use($view) {
             $out = $view->render();
             return "<div class='panel panel-default'>\n                <div class='panel-body'>{$out}</div>\n            </div>";
         });
         return $layout->render();
     }
 }
 protected function styledPage($view, $title = '')
 {
     $this->layout()->mainSection()->addChild($view);
     BootstrapStyling::applyTo($this->layout());
     return $this->page(null, $title);
 }