Datagrid enhancements and fault tolerant to column orders display and safe implementation of wrappers
This commit is contained in:
parent
436557fe81
commit
6f4aebe423
|
|
@ -75,7 +75,13 @@ class AttributeDataGrid extends AbsGrid
|
|||
'type' => 'boolean',
|
||||
'sortable' => true,
|
||||
'searchable' => false,
|
||||
'width' => '100px'
|
||||
'width' => '100px',
|
||||
'wrapper' => function($value){
|
||||
if($value == 1)
|
||||
return 'True';
|
||||
else
|
||||
return 'False';
|
||||
}
|
||||
]);
|
||||
|
||||
$this->addColumn([
|
||||
|
|
@ -85,7 +91,13 @@ class AttributeDataGrid extends AbsGrid
|
|||
'type' => 'boolean',
|
||||
'sortable' => true,
|
||||
'searchable' => false,
|
||||
'width' => '100px'
|
||||
'width' => '100px',
|
||||
'wrapper' => function($value){
|
||||
if($value == 1)
|
||||
return 'True';
|
||||
else
|
||||
return 'False';
|
||||
}
|
||||
]);
|
||||
|
||||
$this->addColumn([
|
||||
|
|
@ -95,7 +107,13 @@ class AttributeDataGrid extends AbsGrid
|
|||
'type' => 'boolean',
|
||||
'sortable' => true,
|
||||
'searchable' => false,
|
||||
'width' => '100px'
|
||||
'width' => '100px',
|
||||
'wrapper' => function($value){
|
||||
if($value == 1)
|
||||
return 'True';
|
||||
else
|
||||
return 'False';
|
||||
}
|
||||
]);
|
||||
|
||||
$this->addColumn([
|
||||
|
|
@ -105,7 +123,13 @@ class AttributeDataGrid extends AbsGrid
|
|||
'type' => 'boolean',
|
||||
'sortable' => true,
|
||||
'searchable' => false,
|
||||
'width' => '100px'
|
||||
'width' => '100px',
|
||||
'wrapper' => function($value){
|
||||
if($value == 1)
|
||||
return 'True';
|
||||
else
|
||||
return 'False';
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,11 +61,17 @@ class CategoryDataGrid extends AbsGrid
|
|||
$this->addColumn([
|
||||
'index' => 'cat.status',
|
||||
'alias' => 'catStatus',
|
||||
'label' => 'Type',
|
||||
'label' => 'Status',
|
||||
'type' => 'boolean',
|
||||
'sortable' => true,
|
||||
'searchable' => true,
|
||||
'width' => '100px'
|
||||
'width' => '100px',
|
||||
'wrapper' => function($value){
|
||||
if($value == 1)
|
||||
return 'Active';
|
||||
else
|
||||
return 'Inactive';
|
||||
}
|
||||
]);
|
||||
|
||||
$this->addColumn([
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class CustomerDataGrid extends AbsGrid
|
|||
public function addColumns()
|
||||
{
|
||||
$this->addColumn([
|
||||
'column' => 'cus.id',
|
||||
'index' => 'cus.id',
|
||||
'alias' => 'customerId',
|
||||
'label' => 'ID',
|
||||
'type' => 'number',
|
||||
|
|
@ -40,7 +40,7 @@ class CustomerDataGrid extends AbsGrid
|
|||
|
||||
$this->addColumn([
|
||||
// 'column' => 'CONCAT(cus.first_name, " ", cus.last_name)',
|
||||
'column' => 'cus.first_name',
|
||||
'index' => 'cus.first_name',
|
||||
'alias' => 'customerFullName',
|
||||
'label' => 'Name',
|
||||
'type' => 'string',
|
||||
|
|
@ -50,7 +50,7 @@ class CustomerDataGrid extends AbsGrid
|
|||
]);
|
||||
|
||||
$this->addColumn([
|
||||
'column' => 'cus.email',
|
||||
'index' => 'cus.email',
|
||||
'alias' => 'customerEmail',
|
||||
'label' => 'Email',
|
||||
'type' => 'string',
|
||||
|
|
@ -60,7 +60,7 @@ class CustomerDataGrid extends AbsGrid
|
|||
]);
|
||||
|
||||
$this->addColumn([
|
||||
'column' => 'cg.name',
|
||||
'index' => 'cg.name',
|
||||
'alias' => 'customerGroupName',
|
||||
'label' => 'Group',
|
||||
'type' => 'string',
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class CustomerGroupDataGrid extends AbsGrid
|
|||
public function addColumns()
|
||||
{
|
||||
$this->addColumn([
|
||||
'column' => 'id',
|
||||
'index' => 'id',
|
||||
'alias' => 'groupId',
|
||||
'label' => 'ID',
|
||||
'type' => 'number',
|
||||
|
|
@ -40,7 +40,7 @@ class CustomerGroupDataGrid extends AbsGrid
|
|||
|
||||
$this->addColumn([
|
||||
// 'column' => 'CONCAT(cus.first_name, " ", cus.last_name)',
|
||||
'column' => 'name',
|
||||
'index' => 'name',
|
||||
'alias' => 'groupName',
|
||||
'label' => 'Name',
|
||||
'type' => 'string',
|
||||
|
|
|
|||
|
|
@ -75,7 +75,14 @@ class CustomerReviewDataGrid extends AbsGrid
|
|||
'type' => 'boolean',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'width' => '100px'
|
||||
'width' => '100px',
|
||||
'closure' => true,
|
||||
'wrapper' => function ($value) {
|
||||
if($value == 'approved')
|
||||
return '<span class="badge badge-md badge-success">Approved</span>';
|
||||
else if($value == "pending")
|
||||
return '<span class="badge badge-md badge-warning">Pending</span>';
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -75,7 +75,13 @@ class InventorySourcesDataGrid extends AbsGrid
|
|||
'type' => 'boolean',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'width' => '100px'
|
||||
'width' => '100px',
|
||||
'wrapper' => function($value){
|
||||
if($value == 1)
|
||||
return 'Active';
|
||||
else
|
||||
return 'Inactive';
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,13 @@ class NewsLetterDataGrid extends AbsGrid
|
|||
'type' => 'string',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'width' => '100px'
|
||||
'width' => '100px',
|
||||
'wrapper' => function($value){
|
||||
if($value == 1)
|
||||
return 'True';
|
||||
else
|
||||
return 'False';
|
||||
}
|
||||
]);
|
||||
|
||||
$this->addColumn([
|
||||
|
|
|
|||
|
|
@ -2,177 +2,139 @@
|
|||
|
||||
namespace Webkul\Admin\DataGrids;
|
||||
|
||||
use Illuminate\View\View;
|
||||
use Webkul\Ui\DataGrid\Facades\DataGrid;
|
||||
use Webkul\Ui\DataGrid\AbsGrid;
|
||||
use DB;
|
||||
|
||||
/**
|
||||
* OrderDataGrid
|
||||
* Product Data Grid class
|
||||
*
|
||||
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
|
||||
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
|
||||
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
|
||||
*/
|
||||
class OrderDataGrid
|
||||
class OrderDataGrid extends AbsGrid
|
||||
{
|
||||
public $allColumns = [];
|
||||
|
||||
/**
|
||||
* The Data Grid implementation for orders
|
||||
*/
|
||||
public function createOrderDataGrid()
|
||||
public function prepareQueryBuilder()
|
||||
{
|
||||
return DataGrid::make([
|
||||
'name' => 'orders',
|
||||
'table' => 'orders as or',
|
||||
'select' => 'or.id',
|
||||
'perpage' => 10,
|
||||
'aliased' => false, //True in case of joins else aliasing key required on all cases
|
||||
$queryBuilder = DB::table('orders')->select('id', 'base_grand_total', 'grand_total', 'created_at', 'channel_name', 'status')->addSelect(DB::raw('CONCAT(customer_first_name, " ", customer_last_name) as fullname'));
|
||||
|
||||
'massoperations' =>[
|
||||
// [
|
||||
// 'route' => route('admin.datagrid.delete'),
|
||||
// 'method' => 'DELETE',
|
||||
// 'label' => 'Delete',
|
||||
// 'type' => 'button',
|
||||
// ],
|
||||
],
|
||||
$this->setQueryBuilder($queryBuilder);
|
||||
}
|
||||
|
||||
'actions' => [
|
||||
[
|
||||
'type' => 'View',
|
||||
'route' => 'admin.sales.orders.view',
|
||||
// 'confirm_text' => 'Do you really want to view this record?',
|
||||
'icon' => 'icon eye-icon',
|
||||
'icon-alt' => 'View'
|
||||
]
|
||||
],
|
||||
public function setIndex() {
|
||||
$this->index = 'id'; //the column that needs to be treated as index column
|
||||
}
|
||||
|
||||
'join' => [],
|
||||
public function addColumns()
|
||||
{
|
||||
$this->addColumn([
|
||||
'index' => 'id',
|
||||
'alias' => 'orderId',
|
||||
'label' => 'ID',
|
||||
'type' => 'number',
|
||||
'searchable' => false,
|
||||
'sortable' => true,
|
||||
'width' => '40px'
|
||||
]);
|
||||
|
||||
//use aliasing on secodary columns if join is performed
|
||||
'columns' => [
|
||||
[
|
||||
'name' => 'or.id',
|
||||
'alias' => 'orderid',
|
||||
'type' => 'number',
|
||||
'label' => 'ID',
|
||||
'sortable' => true,
|
||||
], [
|
||||
'name' => 'CONCAT(or.customer_first_name, " ", or.customer_last_name)',
|
||||
'alias' => 'oafirstname',
|
||||
'type' => 'string',
|
||||
'label' => 'Billed To',
|
||||
'sortable' => false,
|
||||
], [
|
||||
'name' => 'or.base_grand_total',
|
||||
'alias' => 'orbasegrandtotal',
|
||||
'type' => 'string',
|
||||
'label' => 'Base Total',
|
||||
'sortable' => true,
|
||||
'wrapper' => function ($value) {
|
||||
return core()->formatBasePrice($value);
|
||||
}
|
||||
], [
|
||||
'name' => 'or.grand_total',
|
||||
'alias' => 'oagrandtotal',
|
||||
'type' => 'string',
|
||||
'label' => 'Grand Total',
|
||||
'sortable' => false,
|
||||
'wrapper' => function ($value) {
|
||||
return core()->formatBasePrice($value);
|
||||
}
|
||||
], [
|
||||
'name' => 'or.created_at',
|
||||
'alias' => 'createdat',
|
||||
'type' => 'datetime',
|
||||
'label' => 'Order Date',
|
||||
'sortable' => true,
|
||||
], [
|
||||
'name' => 'or.channel_name',
|
||||
'alias' => 'channelname',
|
||||
'type' => 'string',
|
||||
'label' => 'Channel Name',
|
||||
'sortable' => true,
|
||||
], [
|
||||
'name' => 'or.status',
|
||||
'alias' => 'orstatus',
|
||||
'type' => 'string',
|
||||
'label' => 'Status',
|
||||
'sortable' => true,
|
||||
'closure' => true, //to be used when ever wrappers or callables are used
|
||||
'wrapper' => function ($value) {
|
||||
if($value == 'processing')
|
||||
return '<span class="badge badge-md badge-success">Processing</span>';
|
||||
else if($value == 'completed')
|
||||
return '<span class="badge badge-md badge-success">Completed</span>';
|
||||
else if($value == "canceled")
|
||||
return '<span class="badge badge-md badge-danger">Canceled</span>';
|
||||
else if($value == "closed")
|
||||
return '<span class="badge badge-md badge-info">Closed</span>';
|
||||
else if($value == "pending")
|
||||
return '<span class="badge badge-md badge-warning">Pending</span>';
|
||||
else if($value == "pending_payment")
|
||||
return '<span class="badge badge-md badge-warning">Pending Payment</span>';
|
||||
else if($value == "fraud")
|
||||
return '<span class="badge badge-md badge-danger">Fraud</span>';
|
||||
},
|
||||
],
|
||||
],
|
||||
$this->addColumn([
|
||||
'index' => 'base_grand_total',
|
||||
'alias' => 'baseGrandTotal',
|
||||
'label' => 'Base Total',
|
||||
'type' => 'string',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'width' => '100px',
|
||||
'wrapper' => function ($value) {
|
||||
return core()->formatBasePrice($value);
|
||||
}
|
||||
]);
|
||||
|
||||
'filterable' => [
|
||||
[
|
||||
'column' => 'or.id',
|
||||
'alias' => 'orderid',
|
||||
'type' => 'number',
|
||||
'label' => 'ID',
|
||||
], [
|
||||
'column' => 'or.status',
|
||||
'alias' => 'orstatus',
|
||||
'type' => 'string',
|
||||
'label' => 'Status'
|
||||
], [
|
||||
'column' => 'or.created_at',
|
||||
'alias' => 'createdat',
|
||||
'type' => 'datetime',
|
||||
'label' => 'Order Date',
|
||||
], [
|
||||
'column' => 'CONCAT(or.customer_first_name, " ", or.customer_last_name)',
|
||||
'alias' => 'oafirstname',
|
||||
'type' => 'string',
|
||||
'label' => 'Billed To',
|
||||
],
|
||||
],
|
||||
$this->addColumn([
|
||||
'index' => 'grand_total',
|
||||
'alias' => 'grandTotal',
|
||||
'label' => 'Grand Total',
|
||||
'type' => 'string',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'width' => '100px',
|
||||
'wrapper' => function ($value) {
|
||||
return core()->formatBasePrice($value);
|
||||
}
|
||||
]);
|
||||
|
||||
//don't use aliasing in case of searchables
|
||||
'searchable' => [
|
||||
[
|
||||
'column' => 'or.id',
|
||||
'alias' => 'orderid',
|
||||
'type' => 'number',
|
||||
], [
|
||||
'column' => 'or.status',
|
||||
'alias' => 'orstatus',
|
||||
'type' => 'string',
|
||||
]
|
||||
],
|
||||
$this->addColumn([
|
||||
'index' => 'created_at',
|
||||
'alias' => 'orderDate',
|
||||
'label' => 'Order Date',
|
||||
'type' => 'string',
|
||||
'sortable' => true,
|
||||
'searchable' => true,
|
||||
'width' => '100px',
|
||||
]);
|
||||
|
||||
//list of viable operators that will be used
|
||||
'operators' => [
|
||||
'eq' => "=",
|
||||
'lt' => "<",
|
||||
'gt' => ">",
|
||||
'lte' => "<=",
|
||||
'gte' => ">=",
|
||||
'neqs' => "<>",
|
||||
'neqn' => "!=",
|
||||
'like' => "like",
|
||||
'nlike' => "not like",
|
||||
],
|
||||
$this->addColumn([
|
||||
'index' => 'channel_name',
|
||||
'alias' => 'channelName',
|
||||
'label' => 'Channel Name',
|
||||
'type' => 'string',
|
||||
'sortable' => true,
|
||||
'searchable' => false,
|
||||
'width' => '100px'
|
||||
]);
|
||||
|
||||
// 'css' => []
|
||||
$this->addColumn([
|
||||
'index' => 'status',
|
||||
'alias' => 'status',
|
||||
'label' => 'Status',
|
||||
'type' => 'string',
|
||||
'sortable' => true,
|
||||
'searchable' => false,
|
||||
'width' => '100px',
|
||||
'closure' => true,
|
||||
'wrapper' => function ($value) {
|
||||
if($value == 'processing')
|
||||
return '<span class="badge badge-md badge-success">Processing</span>';
|
||||
else if($value == 'completed')
|
||||
return '<span class="badge badge-md badge-success">Completed</span>';
|
||||
else if($value == "canceled")
|
||||
return '<span class="badge badge-md badge-danger">Canceled</span>';
|
||||
else if($value == "closed")
|
||||
return '<span class="badge badge-md badge-info">Closed</span>';
|
||||
else if($value == "pending")
|
||||
return '<span class="badge badge-md badge-warning">Pending</span>';
|
||||
else if($value == "pending_payment")
|
||||
return '<span class="badge badge-md badge-warning">Pending Payment</span>';
|
||||
else if($value == "fraud")
|
||||
return '<span class="badge badge-md badge-danger">Fraud</span>';
|
||||
}
|
||||
]);
|
||||
|
||||
$this->addColumn([
|
||||
'index' => 'fullname',
|
||||
'alias' => 'fullName',
|
||||
'label' => 'Billed To',
|
||||
'type' => 'string',
|
||||
'searchable' => false,
|
||||
'sortable' => true,
|
||||
'width' => '100px'
|
||||
]);
|
||||
}
|
||||
|
||||
public function render($pagination = true)
|
||||
{
|
||||
return $this->createOrderDataGrid()->render($pagination);
|
||||
public function prepareActions() {
|
||||
$this->addAction([
|
||||
'type' => 'View',
|
||||
'route' => 'admin.sales.orders.view',
|
||||
'icon' => 'icon eye-icon'
|
||||
]);
|
||||
}
|
||||
|
||||
public function prepareMassActions() {
|
||||
// $this->addMassAction([
|
||||
// 'type' => 'delete',
|
||||
// 'action' => route('admin.catalog.attributes.massdelete'),
|
||||
// 'method' => 'DELETE'
|
||||
// ]);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,156 +2,86 @@
|
|||
|
||||
namespace Webkul\Admin\DataGrids;
|
||||
|
||||
use Illuminate\View\View;
|
||||
use Webkul\Ui\DataGrid\Facades\DataGrid;
|
||||
use Webkul\Ui\DataGrid\AbsGrid;
|
||||
use DB;
|
||||
|
||||
/**
|
||||
* OrderInvoicesDataGrid
|
||||
* Product Data Grid class
|
||||
*
|
||||
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
|
||||
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
|
||||
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
|
||||
*/
|
||||
class OrderInvoicesDataGrid
|
||||
class OrderInvoicesDataGrid extends AbsGrid
|
||||
{
|
||||
public $allColumns = [];
|
||||
|
||||
/**
|
||||
* The Order invoices Data Grid implementation for invoices of orders
|
||||
*/
|
||||
public function createOrderInvoicesDataGrid()
|
||||
public function prepareQueryBuilder()
|
||||
{
|
||||
$queryBuilder = DB::table('invoices')->select('id', 'order_id', 'state', 'grand_total', 'created_at');
|
||||
|
||||
return DataGrid::make([
|
||||
'name' => 'invoices',
|
||||
'table' => 'invoices as inv',
|
||||
'select' => 'inv.id',
|
||||
'perpage' => 10,
|
||||
'aliased' => false,
|
||||
$this->setQueryBuilder($queryBuilder);
|
||||
}
|
||||
|
||||
'massoperations' =>[
|
||||
// [
|
||||
// 'route' => route('admin.datagrid.delete'),
|
||||
// 'method' => 'DELETE',
|
||||
// 'label' => 'Delete',
|
||||
// 'type' => 'button',
|
||||
// ],
|
||||
],
|
||||
public function setIndex() {
|
||||
$this->index = 'id'; //the column that needs to be treated as index column
|
||||
}
|
||||
|
||||
'actions' => [
|
||||
[
|
||||
'type' => 'View',
|
||||
'route' => 'admin.sales.invoices.view',
|
||||
// 'confirm_text' => 'Do you really want to view this record?',
|
||||
'icon' => 'icon eye-icon',
|
||||
'icon-alt' => 'View'
|
||||
],
|
||||
],
|
||||
public function addColumns()
|
||||
{
|
||||
$this->addColumn([
|
||||
'index' => 'id',
|
||||
'alias' => 'invid',
|
||||
'label' => 'ID',
|
||||
'type' => 'number',
|
||||
'searchable' => false,
|
||||
'sortable' => true,
|
||||
'width' => '40px'
|
||||
]);
|
||||
|
||||
'join' => [
|
||||
// [
|
||||
// 'join' => 'leftjoin',
|
||||
// 'table' => 'orders as ors',
|
||||
// 'primaryKey' => 'inv.order_id',
|
||||
// 'condition' => '=',
|
||||
// 'secondaryKey' => 'ors.id',
|
||||
// ]
|
||||
],
|
||||
$this->addColumn([
|
||||
'index' => 'order_id',
|
||||
'alias' => 'orderId',
|
||||
'label' => 'Order ID',
|
||||
'type' => 'number',
|
||||
'searchable' => false,
|
||||
'sortable' => true,
|
||||
'width' => '100px'
|
||||
]);
|
||||
|
||||
//use aliasing on secodary columns if join is performed
|
||||
$this->addColumn([
|
||||
'index' => 'grand_total',
|
||||
'alias' => 'invgrandtotal',
|
||||
'label' => 'Grand Total',
|
||||
'type' => 'string',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'width' => '100px',
|
||||
]);
|
||||
|
||||
'columns' => [
|
||||
[
|
||||
'name' => 'inv.id',
|
||||
'alias' => 'invid',
|
||||
'type' => 'number',
|
||||
'label' => 'ID',
|
||||
'sortable' => true
|
||||
], [
|
||||
'name' => 'inv.order_id',
|
||||
'alias' => 'invorderid',
|
||||
'type' => 'number',
|
||||
'label' => 'Order ID',
|
||||
'sortable' => true
|
||||
], [
|
||||
'name' => 'inv.state',
|
||||
'alias' => 'invstate',
|
||||
'type' => 'string',
|
||||
'label' => 'State',
|
||||
'sortable' => true
|
||||
], [
|
||||
'name' => 'inv.grand_total',
|
||||
'alias' => 'invgrandtotal',
|
||||
'type' => 'number',
|
||||
'label' => 'Amount',
|
||||
'sortable' => true,
|
||||
'wrapper' => function ($value) {
|
||||
return core()->formatBasePrice($value);
|
||||
},
|
||||
], [
|
||||
'name' => 'inv.created_at',
|
||||
'alias' => 'invcreated_at',
|
||||
'type' => 'datetime',
|
||||
'label' => 'Invoice Date',
|
||||
'sortable' => true
|
||||
]
|
||||
],
|
||||
|
||||
'filterable' => [
|
||||
[
|
||||
'column' => 'inv.id',
|
||||
'alias' => 'invid',
|
||||
'type' => 'number',
|
||||
'label' => 'ID',
|
||||
], [
|
||||
'column' => 'inv.order_id',
|
||||
'alias' => 'invorderid',
|
||||
'type' => 'number',
|
||||
'label' => 'Order ID',
|
||||
], [
|
||||
'column' => 'inv.state',
|
||||
'alias' => 'invstate',
|
||||
'type' => 'string',
|
||||
'label' => 'State',
|
||||
], [
|
||||
'column' => 'inv.grand_total',
|
||||
'alias' => 'invgrandtotal',
|
||||
'type' => 'number',
|
||||
'label' => 'Amount',
|
||||
], [
|
||||
'column' => 'inv.created_at',
|
||||
'alias' => 'invcreated_at',
|
||||
'type' => 'datetime',
|
||||
'label' => 'Invoice Date',
|
||||
]
|
||||
],
|
||||
//don't use aliasing in case of searchables
|
||||
|
||||
'searchable' => [
|
||||
// [
|
||||
// 'column' => 'or.id',
|
||||
// 'alias' => 'orderid',
|
||||
// 'type' => 'number',
|
||||
// 'label' => 'ID',
|
||||
// ]
|
||||
],
|
||||
|
||||
//list of viable operators that will be used
|
||||
'operators' => [
|
||||
'eq' => "=",
|
||||
'lt' => "<",
|
||||
'gt' => ">",
|
||||
'lte' => "<=",
|
||||
'gte' => ">=",
|
||||
'neqs' => "<>",
|
||||
'neqn' => "!=",
|
||||
'like' => "like",
|
||||
'nlike' => "not like",
|
||||
],
|
||||
// 'css' => []
|
||||
$this->addColumn([
|
||||
'index' => 'created_at',
|
||||
'alias' => 'invcreatedat',
|
||||
'label' => 'Invoice Date',
|
||||
'type' => 'datetime',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'width' => '100px',
|
||||
]);
|
||||
}
|
||||
|
||||
public function render($pagination = true)
|
||||
{
|
||||
return $this->createOrderInvoicesDataGrid()->render($pagination);
|
||||
public function prepareActions() {
|
||||
$this->addAction([
|
||||
'type' => 'View',
|
||||
'route' => 'admin.sales.invoices.view',
|
||||
'icon' => 'icon eye-icon'
|
||||
]);
|
||||
}
|
||||
|
||||
public function prepareMassActions() {
|
||||
// $this->addMassAction([
|
||||
// 'type' => 'delete',
|
||||
// 'action' => route('admin.catalog.attributes.massdelete'),
|
||||
// 'method' => 'DELETE'
|
||||
// ]);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,154 +2,116 @@
|
|||
|
||||
namespace Webkul\Admin\DataGrids;
|
||||
|
||||
use Illuminate\View\View;
|
||||
use Webkul\Ui\DataGrid\Facades\DataGrid;
|
||||
use Webkul\Ui\DataGrid\AbsGrid;
|
||||
use DB;
|
||||
|
||||
/**
|
||||
* OrderShipmentsDataGrid
|
||||
* Product Data Grid class
|
||||
*
|
||||
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
|
||||
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
|
||||
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
|
||||
*/
|
||||
class OrderShipmentsDataGrid
|
||||
class OrderShipmentsDataGrid extends AbsGrid
|
||||
{
|
||||
public $allColumns = [];
|
||||
|
||||
/**
|
||||
* The Order Shipments Data Grid implementation for shipments of orders
|
||||
*/
|
||||
public function createOrderShipmentsDataGrid()
|
||||
public function prepareQueryBuilder()
|
||||
{
|
||||
return DataGrid::make([
|
||||
'name' => 'shipments',
|
||||
'table' => 'shipments as ship',
|
||||
'select' => 'ship.id',
|
||||
'perpage' => 10,
|
||||
'aliased' => true,
|
||||
$queryBuilder = DB::table('shipments as ship')->select('ship.id', 'ship.order_id', 'ship.total_qty', 'is.name', 'ors.created_at as orderdate', 'ship.created_at')->addSelect(DB::raw('CONCAT(ors.customer_first_name, " ", ors.customer_last_name) as custname'))->leftJoin('orders as ors', 'ship.order_id', '=', 'ors.id')->leftJoin('inventory_sources as is', 'ship.inventory_source_id', '=', 'is.id');
|
||||
|
||||
'massoperations' =>[
|
||||
// [
|
||||
// 'route' => route('admin.datagrid.delete'),
|
||||
// 'method' => 'DELETE',
|
||||
// 'label' => 'Delete',
|
||||
// 'type' => 'button',
|
||||
// ],
|
||||
],
|
||||
$this->setQueryBuilder($queryBuilder);
|
||||
}
|
||||
|
||||
'actions' => [
|
||||
[
|
||||
'type' => 'View',
|
||||
'route' => 'admin.sales.shipments.view',
|
||||
// 'confirm_text' => 'Do you really want to view this record?',
|
||||
'icon' => 'icon eye-icon',
|
||||
'icon-alt' => 'View'
|
||||
],
|
||||
],
|
||||
public function setIndex() {
|
||||
$this->index = 'id'; //the column that needs to be treated as index column
|
||||
}
|
||||
|
||||
'join' => [
|
||||
[
|
||||
'join' => 'leftjoin',
|
||||
'table' => 'orders as ors',
|
||||
'primaryKey' => 'ship.order_id',
|
||||
'condition' => '=',
|
||||
'secondaryKey' => 'ors.id',
|
||||
], [
|
||||
'join' => 'leftjoin',
|
||||
'table' => 'inventory_sources as is',
|
||||
'primaryKey' => 'ship.inventory_source_id',
|
||||
'condition' => '=',
|
||||
'secondaryKey' => 'is.id',
|
||||
]
|
||||
],
|
||||
public function addColumns()
|
||||
{
|
||||
$this->addColumn([
|
||||
'index' => 'ship.id',
|
||||
'alias' => 'shipId',
|
||||
'label' => 'ID',
|
||||
'type' => 'number',
|
||||
'searchable' => false,
|
||||
'sortable' => true,
|
||||
'width' => '40px'
|
||||
]);
|
||||
|
||||
//use aliasing on secodary columns if join is performed
|
||||
'columns' => [
|
||||
[
|
||||
'name' => 'ship.id',
|
||||
'alias' => 'shipID',
|
||||
'type' => 'number',
|
||||
'label' => 'ID',
|
||||
'sortable' => true
|
||||
], [
|
||||
'name' => 'ship.order_id',
|
||||
'alias' => 'orderid',
|
||||
'type' => 'number',
|
||||
'label' => 'Order ID',
|
||||
'sortable' => true
|
||||
], [
|
||||
'name' => 'ship.total_qty',
|
||||
'alias' => 'shiptotalqty',
|
||||
'type' => 'number',
|
||||
'label' => 'Total Quantity',
|
||||
'sortable' => true
|
||||
], [
|
||||
'name' => 'CONCAT(ors.customer_first_name, " ", ors.customer_last_name)',
|
||||
'alias' => 'ordercustomerfirstname',
|
||||
'type' => 'string',
|
||||
'label' => 'Customer Name',
|
||||
'sortable' => false,
|
||||
], [
|
||||
'name' => 'is.name',
|
||||
'alias' => 'inventorySourceName',
|
||||
'type' => 'string',
|
||||
'label' => 'Inventory Source',
|
||||
'sortable' => true
|
||||
], [
|
||||
'name' => 'ors.created_at',
|
||||
'alias' => 'orscreated',
|
||||
'type' => 'date',
|
||||
'label' => 'Order Date',
|
||||
'sortable' => true
|
||||
], [
|
||||
'name' => 'ship.created_at',
|
||||
'alias' => 'shipdate',
|
||||
'type' => 'datetime',
|
||||
'label' => 'Shipment Date',
|
||||
'sortable' => true
|
||||
]
|
||||
],
|
||||
$this->addColumn([
|
||||
'index' => 'ship.order_id',
|
||||
'alias' => 'orderId',
|
||||
'label' => 'Order ID',
|
||||
'type' => 'number',
|
||||
'searchable' => false,
|
||||
'sortable' => true,
|
||||
'width' => '100px'
|
||||
]);
|
||||
|
||||
'filterable' => [
|
||||
[
|
||||
'column' => 'ship.id',
|
||||
'alias' => 'shipID',
|
||||
'type' => 'number',
|
||||
'label' => 'ID',
|
||||
], [
|
||||
'column' => 'ship.created_at',
|
||||
'alias' => 'shipdate',
|
||||
'type' => 'datetime',
|
||||
'label' => 'Shipment Date',
|
||||
]
|
||||
],
|
||||
//don't use aliasing in case of searchables
|
||||
$this->addColumn([
|
||||
'index' => 'ship.total_qty',
|
||||
'alias' => 'shipTotalQty',
|
||||
'label' => 'Total Qty',
|
||||
'type' => 'number',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'width' => '100px',
|
||||
]);
|
||||
|
||||
'searchable' => [
|
||||
// [
|
||||
// 'column' => 'ors.customer_first_name',
|
||||
// 'alias' => 'ordercustomerfirstname',
|
||||
// 'type' => 'string',
|
||||
// ]
|
||||
],
|
||||
$this->addColumn([
|
||||
'index' => 'is.name',
|
||||
'alias' => 'shipInventoryName',
|
||||
'label' => 'Inventory Source',
|
||||
'type' => 'string',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'width' => '100px',
|
||||
]);
|
||||
|
||||
//list of viable operators that will be used
|
||||
'operators' => [
|
||||
'eq' => "=",
|
||||
'lt' => "<",
|
||||
'gt' => ">",
|
||||
'lte' => "<=",
|
||||
'gte' => ">=",
|
||||
'neqs' => "<>",
|
||||
'neqn' => "!=",
|
||||
'like' => "like",
|
||||
'nlike' => "not like",
|
||||
],
|
||||
// 'css' => []
|
||||
$this->addColumn([
|
||||
'index' => 'orderdate',
|
||||
'alias' => 'shipOrderDate',
|
||||
'label' => 'Order Date',
|
||||
'type' => 'datetime',
|
||||
'sortable' => true,
|
||||
'searchable' => true,
|
||||
'width' => '100px'
|
||||
]);
|
||||
|
||||
$this->addColumn([
|
||||
'index' => 'ship.created_at',
|
||||
'alias' => 'shipDate',
|
||||
'label' => 'Shipment Date',
|
||||
'type' => 'datetime',
|
||||
'sortable' => true,
|
||||
'searchable' => false,
|
||||
'width' => '100px'
|
||||
]);
|
||||
|
||||
$this->addColumn([
|
||||
'index' => 'custname',
|
||||
'alias' => 'shipTO',
|
||||
'label' => 'Shipping To',
|
||||
'type' => 'string',
|
||||
'sortable' => true,
|
||||
'searchable' => false,
|
||||
'width' => '100px'
|
||||
]);
|
||||
}
|
||||
|
||||
public function render($pagination = true)
|
||||
{
|
||||
return $this->createOrderShipmentsDataGrid()->render($pagination);
|
||||
public function prepareActions() {
|
||||
$this->addAction([
|
||||
'type' => 'View',
|
||||
'route' => 'admin.sales.orders.view',
|
||||
'icon' => 'icon eye-icon'
|
||||
]);
|
||||
}
|
||||
|
||||
public function prepareMassActions() {
|
||||
// $this->addMassAction([
|
||||
// 'type' => 'delete',
|
||||
// 'action' => route('admin.catalog.attributes.massdelete'),
|
||||
// 'method' => 'DELETE'
|
||||
// ]);
|
||||
}
|
||||
}
|
||||
|
|
@ -79,7 +79,13 @@ class TestDataGrid extends AbsGrid
|
|||
'type' => 'boolean',
|
||||
'sortable' => true,
|
||||
'searchable' => false,
|
||||
'width' => '100px'
|
||||
'width' => '100px',
|
||||
'wrapper' => function($value) {
|
||||
if($value == 1)
|
||||
return 'Active';
|
||||
else
|
||||
return 'Inactive';
|
||||
}
|
||||
]);
|
||||
|
||||
$this->addColumn([
|
||||
|
|
@ -89,11 +95,13 @@ class TestDataGrid extends AbsGrid
|
|||
'type' => 'number',
|
||||
'sortable' => true,
|
||||
'searchable' => false,
|
||||
'width' => '100px'
|
||||
'width' => '100px',
|
||||
'wrapper' => function($value) {
|
||||
return core()->formatBasePrice($value);
|
||||
}
|
||||
]);
|
||||
|
||||
$this->addColumn([
|
||||
// 'column' => 'products_grid.quantity',
|
||||
'index' => 'products_grid.quantity',
|
||||
'alias' => 'productqty',
|
||||
'label' => 'Quantity',
|
||||
|
|
|
|||
|
|
@ -57,10 +57,10 @@ class UserDataGrid extends AbsGrid
|
|||
'sortable' => true,
|
||||
'width' => '100px',
|
||||
'wrapper' => function($value) {
|
||||
if($value == 0) {
|
||||
return false;
|
||||
if($value == 1) {
|
||||
return 'Active';
|
||||
} else {
|
||||
return true;
|
||||
return 'Inactive';
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -11,14 +11,14 @@
|
|||
<h1>{{ __('admin::app.sales.invoices.title') }}</h1>
|
||||
</div>
|
||||
|
||||
<div class="page-action">
|
||||
{{-- <div class="page-action">
|
||||
<div class="export" @click="showModal('downloadDataGrid')">
|
||||
<i class="export-icon"></i>
|
||||
<span>
|
||||
{{ __('admin::app.export.export') }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div> --}}
|
||||
</div>
|
||||
|
||||
<div class="page-content">
|
||||
|
|
@ -27,18 +27,18 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<modal id="downloadDataGrid" :is-open="modalIds.downloadDataGrid">
|
||||
{{-- <modal id="downloadDataGrid" :is-open="modalIds.downloadDataGrid">
|
||||
<h3 slot="header">{{ __('admin::app.export.download') }}</h3>
|
||||
<div slot="body">
|
||||
<export-form></export-form>
|
||||
</div>
|
||||
</modal>
|
||||
</modal> --}}
|
||||
|
||||
@stop
|
||||
|
||||
@push('scripts')
|
||||
|
||||
<script type="text/x-template" id="export-form-template">
|
||||
{{-- <script type="text/x-template" id="export-form-template">
|
||||
<form method="POST" action="{{ route('admin.datagrid.export') }}">
|
||||
|
||||
<div class="page-content">
|
||||
|
|
@ -76,6 +76,6 @@
|
|||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</script> --}}
|
||||
|
||||
@endpush
|
||||
|
|
@ -11,14 +11,14 @@
|
|||
<h1>{{ __('admin::app.sales.orders.title') }}</h1>
|
||||
</div>
|
||||
|
||||
<div class="page-action">
|
||||
{{-- <div class="page-action">
|
||||
<div class="export" @click="showModal('downloadDataGrid')">
|
||||
<i class="export-icon"></i>
|
||||
<span>
|
||||
{{ __('admin::app.export.export') }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div> --}}
|
||||
</div>
|
||||
|
||||
<div class="page-content">
|
||||
|
|
@ -27,18 +27,18 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<modal id="downloadDataGrid" :is-open="modalIds.downloadDataGrid">
|
||||
{{-- <modal id="downloadDataGrid" :is-open="modalIds.downloadDataGrid">
|
||||
<h3 slot="header">{{ __('admin::app.export.download') }}</h3>
|
||||
<div slot="body">
|
||||
<export-form></export-form>
|
||||
</div>
|
||||
</modal>
|
||||
</modal> --}}
|
||||
|
||||
@stop
|
||||
|
||||
@push('scripts')
|
||||
|
||||
<script type="text/x-template" id="export-form-template">
|
||||
{{-- <script type="text/x-template" id="export-form-template">
|
||||
<form method="POST" action="{{ route('admin.datagrid.export') }}">
|
||||
|
||||
<div class="page-content">
|
||||
|
|
@ -65,7 +65,7 @@
|
|||
</button>
|
||||
|
||||
</form>
|
||||
</script>
|
||||
</script> --}}
|
||||
|
||||
<script>
|
||||
Vue.component('export-form', {
|
||||
|
|
|
|||
|
|
@ -11,14 +11,14 @@
|
|||
<h1>{{ __('admin::app.sales.shipments.title') }}</h1>
|
||||
</div>
|
||||
|
||||
<div class="page-action">
|
||||
{{-- <div class="page-action">
|
||||
<div class="export" @click="showModal('downloadDataGrid')">
|
||||
<i class="export-icon"></i>
|
||||
<span>
|
||||
{{ __('admin::app.export.export') }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div> --}}
|
||||
</div>
|
||||
|
||||
<div class="page-content">
|
||||
|
|
@ -27,18 +27,18 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<modal id="downloadDataGrid" :is-open="modalIds.downloadDataGrid">
|
||||
{{-- <modal id="downloadDataGrid" :is-open="modalIds.downloadDataGrid">
|
||||
<h3 slot="header">{{ __('admin::app.export.download') }}</h3>
|
||||
<div slot="body">
|
||||
<export-form></export-form>
|
||||
</div>
|
||||
</modal>
|
||||
</modal> --}}
|
||||
|
||||
@stop
|
||||
|
||||
@push('scripts')
|
||||
|
||||
<script type="text/x-template" id="export-form-template">
|
||||
{{-- <script type="text/x-template" id="export-form-template">
|
||||
<form method="POST" action="{{ route('admin.datagrid.export') }}">
|
||||
|
||||
<div class="page-content">
|
||||
|
|
@ -76,6 +76,6 @@
|
|||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</script> --}}
|
||||
|
||||
@endpush
|
||||
|
|
@ -18,7 +18,7 @@ class Toolbar extends AbstractProduct
|
|||
'created_at-desc' => 'newest-first',
|
||||
'created_at-asc' => 'oldest-first',
|
||||
'price-asc' => 'cheapest-first',
|
||||
'price-desc' => 'expansive-first'
|
||||
'price-desc' => 'expensive-first'
|
||||
];
|
||||
}
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -8,24 +8,23 @@
|
|||
<label class="checkbox-view" for="checkbox1"></label>
|
||||
</span>
|
||||
</td>
|
||||
<?php $i = 0; ?>
|
||||
@foreach($record as $key1 => $column)
|
||||
@if($columns[$i]['type'] == 'boolean' && $columns[$i]['label'] == 'Status')
|
||||
@if($column == 0)
|
||||
<td>Inactive</td>
|
||||
|
||||
@foreach($columns as $column)
|
||||
@php
|
||||
$index = explode('.', $column['index']);
|
||||
|
||||
$index = end($index);
|
||||
@endphp
|
||||
|
||||
@if(isset($column['wrapper']))
|
||||
@if(isset($column['closure']) && $column['closure'] == true)
|
||||
<td>{!! $column['wrapper']($record->{$index}) !!}</td>
|
||||
@else
|
||||
<td>Active</td>
|
||||
@endif
|
||||
@elseif($columns[$i]['type'] == 'boolean' && $columns[$i]['label'] != 'Status')
|
||||
@if($column == 0)
|
||||
<td>False</td>
|
||||
@else
|
||||
<td>True</td>
|
||||
<td>{{ $column['wrapper']($record->{$index}) }}</td>
|
||||
@endif
|
||||
@else
|
||||
<td>{{ $column }}</td>
|
||||
<td>{{ $record->{$index} }}</td>
|
||||
@endif
|
||||
<?php $i++; ?>
|
||||
@endforeach
|
||||
|
||||
<td style="width: 50px;">
|
||||
|
|
|
|||
Loading…
Reference in New Issue