From 51026b0dfd6b96529576b957c5bc1a7dc73ecfad Mon Sep 17 00:00:00 2001 From: prashant-webkul Date: Thu, 18 Oct 2018 12:45:32 +0530 Subject: [PATCH 1/8] Mergin --- .../Admin/src/DataGrids/OrderDataGrid.php | 169 +++++++++--------- .../src/Providers/AdminServiceProvider.php | 16 +- .../src/Providers/EventServiceProvider.php | 18 ++ .../views/sales/orders/index.blade.php | 3 +- .../account/wishlist/wishlist.blade.php | 2 +- 5 files changed, 114 insertions(+), 94 deletions(-) diff --git a/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php index 5324637a4..d61e4a429 100644 --- a/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php @@ -6,7 +6,7 @@ use Illuminate\View\View; use Webkul\Ui\DataGrid\Facades\DataGrid; /** - * Order DataGrid + * orderDataGrid * * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) @@ -14,20 +14,20 @@ use Webkul\Ui\DataGrid\Facades\DataGrid; class OrderDataGrid { + /** * The Data Grid implementation. * - * @var AttributeDataGrid - * for countries + * @var orderDataGrid + * for orders */ - - public function createCategoryDataGrid() + public function createOrderDataGrid() { return DataGrid::make([ - 'name' => 'Orders', - 'table' => 'orders as ord', - 'select' => 'ord.id', + 'name' => 'orders', + 'table' => 'orders as or', + 'select' => 'or.id', 'perpage' => 5, 'aliased' => true, //use this with false as default and true in case of joins @@ -55,104 +55,105 @@ class OrderDataGrid ], 'join' => [ - [ - 'join' => 'leftjoin', - 'table' => 'category_translations as ct', - 'primaryKey' => 'cat.id', - 'condition' => '=', - 'secondaryKey' => 'ct.category_id', - ], [ - 'join' => 'leftjoin', - 'table' => 'category_translations as cta', - 'primaryKey' => 'cat.parent_id', - 'condition' => '=', - 'secondaryKey' => 'cta.category_id', - ], + // [ + // 'join' => 'leftjoin', + // 'table' => 'order_address as oa', + // 'primaryKey' => 'or.id', + // 'condition' => '=', + // 'secondaryKey' => 'oa.order_id', + // ], + // [ + // 'join' => 'leftjoin', + // 'table' => 'category_translations as cta', + // 'primaryKey' => 'cat.parent_id', + // 'condition' => '=', + // 'secondaryKey' => 'cta.category_id', + // ], ], //use aliasing on secodary columns if join is performed 'columns' => [ [ - 'name' => 'cat.id', - 'alias' => 'catID', + 'name' => 'or.id', + 'alias' => 'orderid', 'type' => 'number', - 'label' => 'Category ID', + 'label' => 'ID', 'sortable' => true, ], [ - 'name' => 'ct.name', - 'alias' => 'catName', + 'name' => 'or.status', + 'alias' => 'orstatus', 'type' => 'string', - 'label' => 'Category Name', - 'sortable' => false, - ], [ - 'name' => 'cat.position', - 'alias' => 'catPosition', - 'type' => 'string', - 'label' => 'Category Position', - 'sortable' => false, - ], [ - 'name' => 'cta.name', - 'alias' => 'parentName', - 'type' => 'string', - 'label' => 'Parent Name', + 'label' => 'Status', 'sortable' => true, + // 'wrapper' => function ($value) { + // if($value == 0) + // return "False"; + // else + // return "True"; + // }, ], [ - 'name' => 'cat.status', - 'alias' => 'catStatus', + 'name' => 'or.base_grand_total', + 'alias' => 'orbasegrandtotal', 'type' => 'string', - 'label' => 'Visible in Menu', + 'label' => 'Base Total', 'sortable' => true, - 'wrapper' => function ($value) { - if($value == 0) - return "False"; - else - return "True"; - }, ], - + // [ + // 'name' => 'or.customer_first_name', + // 'alias' => 'oafirstname', + // 'type' => 'string', + // 'label' => 'Billed To', + // 'sortable' => false, + // ], [ + // 'name' => 'oa.first_name', + // 'alias' => 'oafirstname', + // 'type' => 'string', + // 'label' => 'Shipped To', + // 'sortable' => false, + // ], ], 'filterable' => [ - [ - 'column' => 'cat.id', - 'alias' => 'catID', - 'type' => 'number', - 'label' => 'Category ID', - ], [ - 'column' => 'ct.name', - 'alias' => 'catName', - 'type' => 'string', - 'label' => 'Category Name', - ], [ - 'column' => 'cta.name', - 'alias' => 'parentName', - 'type' => 'string', - 'label' => 'Parent Name', - ], [ - 'column' => 'cat.status', - 'alias' => 'catStatus', - 'type' => 'string', - 'label' => 'Visible in Menu', - ], + // [ + // 'column' => 'cat.id', + // 'alias' => 'catID', + // 'type' => 'number', + // 'label' => 'Category ID', + // ], [ + // 'column' => 'ct.name', + // 'alias' => 'catName', + // 'type' => 'string', + // 'label' => 'Category Name', + // ], [ + // 'column' => 'cta.name', + // 'alias' => 'parentName', + // 'type' => 'string', + // 'label' => 'Parent Name', + // ], [ + // 'column' => 'cat.status', + // 'alias' => 'catStatus', + // 'type' => 'string', + // 'label' => 'Visible in Menu', + // ], ], //don't use aliasing in case of searchables 'searchable' => [ - [ - 'column' => 'cat.id', - 'type' => 'number', - 'label' => 'Category ID', - ], [ - 'column' => 'ct.name', - 'type' => 'string', - 'label' => 'Category Name', - ], [ - 'column' => 'cat.status', - 'type' => 'string', - 'label' => 'Visible in Menu', - ] + // [ + // 'column' => 'cat.id', + // 'type' => 'number', + // 'label' => 'Category ID', + // ], [ + // 'column' => 'ct.name', + // 'type' => 'string', + // 'label' => 'Category Name', + // ], [ + // 'column' => 'cat.status', + // 'type' => 'string', + // 'label' => 'Visible in Menu', + // ] ], //list of viable operators that will be used @@ -173,7 +174,7 @@ class OrderDataGrid public function render() { - return $this->createCategoryDataGrid()->render(); + return $this->createOrderDataGrid()->render(); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/Providers/AdminServiceProvider.php b/packages/Webkul/Admin/src/Providers/AdminServiceProvider.php index 1fe463fbb..7e1c6936c 100644 --- a/packages/Webkul/Admin/src/Providers/AdminServiceProvider.php +++ b/packages/Webkul/Admin/src/Providers/AdminServiceProvider.php @@ -58,17 +58,17 @@ class AdminServiceProvider extends ServiceProvider $subMenus = $tabs = []; if (count($keys) > 1) { $subMenus = [ - 'items' => $menu->sortItems(array_get($menu->items, current($keys) . '.children')), - 'current' => $menu->current, - 'currentKey' => $menu->currentKey - ]; + 'items' => $menu->sortItems(array_get($menu->items, current($keys) . '.children')), + 'current' => $menu->current, + 'currentKey' => $menu->currentKey + ]; if (count($keys) > 2) { $tabs = [ - 'items' => $menu->sortItems(array_get($menu->items, implode('.children.', array_slice($keys, 0, 2)) . '.children')), - 'current' => $menu->current, - 'currentKey' => $menu->currentKey - ]; + 'items' => $menu->sortItems(array_get($menu->items, implode('.children.', array_slice($keys, 0, 2)) . '.children')), + 'current' => $menu->current, + 'currentKey' => $menu->currentKey + ]; } } diff --git a/packages/Webkul/Admin/src/Providers/EventServiceProvider.php b/packages/Webkul/Admin/src/Providers/EventServiceProvider.php index 0ed37ee12..8b5747b22 100644 --- a/packages/Webkul/Admin/src/Providers/EventServiceProvider.php +++ b/packages/Webkul/Admin/src/Providers/EventServiceProvider.php @@ -23,6 +23,24 @@ class EventServiceProvider extends ServiceProvider 'route' => 'admin.sales.orders.index', 'sort' => 2, 'icon-class' => 'sales-icon', + ], [ + 'key' => 'sales.orders', + 'name' => 'Orders', + 'route' => 'admin.sales.orders.index', + 'sort' => 1, + 'icon-class' => '', + ], [ + 'key' => 'sales.shipments', + 'name' => 'Shipments', + 'route' => 'admin.sales.orders.index', + 'sort' => 2, + 'icon-class' => '', + ], [ + 'key' => 'sales.invoices', + 'name' => 'Invoices', + 'route' => 'admin.sales.orders.index', + 'sort' => 3, + 'icon-class' => '', ], [ 'key' => 'catalog', 'name' => 'Catalog', diff --git a/packages/Webkul/Admin/src/Resources/views/sales/orders/index.blade.php b/packages/Webkul/Admin/src/Resources/views/sales/orders/index.blade.php index 77b45387e..927a6334f 100644 --- a/packages/Webkul/Admin/src/Resources/views/sales/orders/index.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/sales/orders/index.blade.php @@ -16,7 +16,8 @@
- + @inject('orderGrid', 'Webkul\Admin\DataGrids\OrderDataGrid') + {!! $orderGrid->render() !!}
@stop \ No newline at end of file diff --git a/packages/Webkul/Shop/src/Resources/views/customers/account/wishlist/wishlist.blade.php b/packages/Webkul/Shop/src/Resources/views/customers/account/wishlist/wishlist.blade.php index bfb929133..0bcaffe0a 100644 --- a/packages/Webkul/Shop/src/Resources/views/customers/account/wishlist/wishlist.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/customers/account/wishlist/wishlist.blade.php @@ -53,4 +53,4 @@ -@endsection +@endsection \ No newline at end of file From 806ffb460fa23b26ee1050746e71ccf081acb36e Mon Sep 17 00:00:00 2001 From: prashant-webkul Date: Thu, 18 Oct 2018 16:34:55 +0530 Subject: [PATCH 2/8] Order Datagrid, Datagrid Currency Capabilities via wrapper and UI fixes in storefront navigation bar, admin panel menu item, datagrid actions checks before rendering of datagrid --- .../src/DataGrids/ExchangeRatesDataGrid.php | 35 +++-- .../Admin/src/DataGrids/OrderDataGrid.php | 123 +++++++----------- .../Admin/src/DataGrids/UserDataGrid.php | 15 +-- .../src/Providers/EventServiceProvider.php | 28 ++-- .../views/sales/orders/index.blade.php | 4 +- ...2_create_currency_exchange_rates_table.php | 1 - .../Shop/src/Resources/assets/sass/app.scss | 4 +- .../views/products/buy-now.blade.php | 4 +- .../Ui/src/Resources/assets/sass/app.scss | 27 ++-- .../views/datagrid/table/body.blade.php | 4 +- .../views/datagrid/table/head.blade.php | 8 +- public/themes/default/assets/css/shop.css | 11 +- 12 files changed, 111 insertions(+), 153 deletions(-) diff --git a/packages/Webkul/Admin/src/DataGrids/ExchangeRatesDataGrid.php b/packages/Webkul/Admin/src/DataGrids/ExchangeRatesDataGrid.php index 9d4f085e0..9171064dd 100644 --- a/packages/Webkul/Admin/src/DataGrids/ExchangeRatesDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/ExchangeRatesDataGrid.php @@ -27,10 +27,10 @@ class ExchangeRatesDataGrid return DataGrid::make([ 'name' => 'Exchange Rates', - 'table' => 'currency_exchange_rates', - 'select' => 'id', + 'table' => 'currency_exchange_rates as cer', + 'select' => 'cer.id', 'perpage' => 5, - 'aliased' => false, //use this with false as default and true in case of joins + 'aliased' => true, //use this with false as default and true in case of joins 'massoperations' =>[ [ @@ -56,13 +56,13 @@ class ExchangeRatesDataGrid ], 'join' => [ - // [ - // 'join' => 'leftjoin', - // 'table' => 'roles as r', - // 'primaryKey' => 'u.role_id', - // 'condition' => '=', - // 'secondaryKey' => 'r.id', - // ] + [ + 'join' => 'leftjoin', + 'table' => 'currencies as curr', + 'primaryKey' => 'cer.target_currency', + 'condition' => '=', + 'secondaryKey' => 'curr.id', + ] ], //use aliasing on secodary columns if join is performed @@ -70,39 +70,38 @@ class ExchangeRatesDataGrid 'columns' => [ [ - 'name' => 'id', + 'name' => 'cer.id', 'alias' => 'exchID', 'type' => 'number', 'label' => 'Rate ID', 'sortable' => true, ], [ - 'name' => 'target_currency', - 'alias' => 'exchTargetCurrency', + 'name' => 'curr.name', + 'alias' => 'currencyname', 'type' => 'string', - 'label' => 'Target Currency', + 'label' => 'Currency Name', 'sortable' => true, ], [ - 'name' => 'rate', + 'name' => 'cer.rate', 'alias' => 'exchRate', 'type' => 'string', 'label' => 'Exchange Rate', ], - ], //don't use aliasing in case of filters 'filterable' => [ [ - 'column' => 'id', + 'column' => 'cer.id', 'alias' => 'exchId', 'type' => 'number', 'label' => 'Rate ID', ], [ - 'column' => 'target_currency', + 'column' => 'curr.name', 'alias' => 'exchTargetCurrency', 'type' => 'string', 'label' => 'Target Currency', diff --git a/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php index d61e4a429..9d5678b37 100644 --- a/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php @@ -29,7 +29,8 @@ class OrderDataGrid 'table' => 'orders as or', 'select' => 'or.id', 'perpage' => 5, - 'aliased' => true, //use this with false as default and true in case of joins + 'aliased' => false, + //True in case of joins else aliasing key required on all cases 'massoperations' =>[ [ @@ -40,36 +41,9 @@ class OrderDataGrid ], ], - 'actions' => [ - [ - 'type' => 'Edit', - 'route' => route('admin.datagrid.delete'), - 'confirm_text' => 'Do you really want to do this?', - 'icon' => 'icon pencil-lg-icon', - ], [ - 'type' => 'Delete', - 'route' => route('admin.datagrid.delete'), - 'confirm_text' => 'Do you really want to do this?', - 'icon' => 'icon trash-icon', - ], - ], + 'actions' => [ ], - 'join' => [ - // [ - // 'join' => 'leftjoin', - // 'table' => 'order_address as oa', - // 'primaryKey' => 'or.id', - // 'condition' => '=', - // 'secondaryKey' => 'oa.order_id', - // ], - // [ - // 'join' => 'leftjoin', - // 'table' => 'category_translations as cta', - // 'primaryKey' => 'cat.parent_id', - // 'condition' => '=', - // 'secondaryKey' => 'cta.category_id', - // ], - ], + 'join' => [], //use aliasing on secodary columns if join is performed @@ -81,63 +55,62 @@ class OrderDataGrid 'label' => 'ID', 'sortable' => true, ], [ - 'name' => 'or.status', - 'alias' => 'orstatus', + 'name' => 'or.customer_first_name', + 'alias' => 'oafirstname', 'type' => 'string', - 'label' => 'Status', - 'sortable' => true, - // 'wrapper' => function ($value) { - // if($value == 0) - // return "False"; - // else - // return "True"; - // }, + 'label' => 'Billed To', + 'sortable' => false, ], [ 'name' => 'or.base_grand_total', 'alias' => 'orbasegrandtotal', 'type' => 'string', 'label' => 'Base Total', 'sortable' => true, + 'wrapper' => function ($value) { + return core()->currency($value); + } + ], [ + 'name' => 'or.grand_total', + 'alias' => 'oagrandtotal', + 'type' => 'string', + 'label' => 'Grand Total', + 'sortable' => false, + 'wrapper' => function ($value) { + return core()->currency($value); + } + ], [ + 'name' => 'or.status', + 'alias' => 'orstatus', + 'type' => 'string', + 'label' => 'Status', + 'sortable' => true, + 'wrapper' => function ($value) { + if($value == 'completed') + return 'Completed'; + else if($value == "cancelled") + return 'Completed'; + else if($value == "closed") + return 'Completed'; + else if($value == "pending") + return 'Pending'; + + }, ], - // [ - // 'name' => 'or.customer_first_name', - // 'alias' => 'oafirstname', - // 'type' => 'string', - // 'label' => 'Billed To', - // 'sortable' => false, - // ], [ - // 'name' => 'oa.first_name', - // 'alias' => 'oafirstname', - // 'type' => 'string', - // 'label' => 'Shipped To', - // 'sortable' => false, - // ], ], 'filterable' => [ - // [ - // 'column' => 'cat.id', - // 'alias' => 'catID', - // 'type' => 'number', - // 'label' => 'Category ID', - // ], [ - // 'column' => 'ct.name', - // 'alias' => 'catName', - // 'type' => 'string', - // 'label' => 'Category Name', - // ], [ - // 'column' => 'cta.name', - // 'alias' => 'parentName', - // 'type' => 'string', - // 'label' => 'Parent Name', - // ], [ - // 'column' => 'cat.status', - // 'alias' => 'catStatus', - // 'type' => 'string', - // 'label' => 'Visible in Menu', - // ], + [ + 'column' => 'or.id', + 'alias' => 'orderid', + 'type' => 'number', + 'label' => 'ID', + ], [ + 'name' => 'or.status', + 'alias' => 'orstatus', + 'type' => 'string', + 'label' => 'Status' + ] ], - //don't use aliasing in case of searchables 'searchable' => [ diff --git a/packages/Webkul/Admin/src/DataGrids/UserDataGrid.php b/packages/Webkul/Admin/src/DataGrids/UserDataGrid.php index 85432930a..d639b1071 100644 --- a/packages/Webkul/Admin/src/DataGrids/UserDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/UserDataGrid.php @@ -111,13 +111,7 @@ class UserDataGrid 'label' => 'Role Name', 'sortable' => true, ], - [ - 'name' => 'r.id', - 'alias' => 'xc', - 'type' => 'string', - 'label' => 'Role ID', - 'sortable' => true, - ], + ], //don't use aliasing in case of filters 'filterable' => [ @@ -133,12 +127,7 @@ class UserDataGrid 'type' => 'number', 'label' => 'Admin ID' ], - [ - 'column' => 'r.id', - 'alias' => 'xc', - 'type' => 'number', - 'label' => 'Role ID' - ] + ], //don't use aliasing in case of searchables 'searchable' => [ diff --git a/packages/Webkul/Admin/src/Providers/EventServiceProvider.php b/packages/Webkul/Admin/src/Providers/EventServiceProvider.php index 8b5747b22..6eb34a845 100644 --- a/packages/Webkul/Admin/src/Providers/EventServiceProvider.php +++ b/packages/Webkul/Admin/src/Providers/EventServiceProvider.php @@ -29,19 +29,21 @@ class EventServiceProvider extends ServiceProvider 'route' => 'admin.sales.orders.index', 'sort' => 1, 'icon-class' => '', - ], [ - 'key' => 'sales.shipments', - 'name' => 'Shipments', - 'route' => 'admin.sales.orders.index', - 'sort' => 2, - 'icon-class' => '', - ], [ - 'key' => 'sales.invoices', - 'name' => 'Invoices', - 'route' => 'admin.sales.orders.index', - 'sort' => 3, - 'icon-class' => '', - ], [ + ], + // [ + // 'key' => 'sales.shipments', + // 'name' => 'Shipments', + // 'route' => 'admin.sales.orders.index', + // 'sort' => 2, + // 'icon-class' => '', + // ], [ + // 'key' => 'sales.invoices', + // 'name' => 'Invoices', + // 'route' => 'admin.sales.orders.index', + // 'sort' => 3, + // 'icon-class' => '', + // ], + [ 'key' => 'catalog', 'name' => 'Catalog', 'route' => 'admin.catalog.products.index', diff --git a/packages/Webkul/Admin/src/Resources/views/sales/orders/index.blade.php b/packages/Webkul/Admin/src/Resources/views/sales/orders/index.blade.php index 927a6334f..696d9c3c7 100644 --- a/packages/Webkul/Admin/src/Resources/views/sales/orders/index.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/sales/orders/index.blade.php @@ -1,10 +1,10 @@ -@extends('admin::layouts.master') +@extends('admin::layouts.content') @section('page_title') {{ __('admin::app.sales.orders.title') }} @stop -@section('content-wrapper') +@section('content')