From 35ccc65342e84464457f032c93bd24d469e730ef Mon Sep 17 00:00:00 2001 From: jitendra Date: Mon, 4 Feb 2019 15:23:06 +0530 Subject: [PATCH] Fixed shipment grid shipped to column --- packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php | 3 ++- .../Admin/src/DataGrids/OrderShipmentsDataGrid.php | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php index f008f7433..87cf74dea 100755 --- a/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php @@ -32,7 +32,8 @@ class OrderDataGrid extends DataGrid ->addSelect(DB::raw('CONCAT(order_address_billing.first_name, " ", order_address_billing.last_name) as billed_to')) ->addSelect(DB::raw('CONCAT(order_address_shipping.first_name, " ", order_address_shipping.last_name) as shipped_to')); - $this->addFilter('full_name', DB::raw('CONCAT(customer_first_name, " ", customer_last_name)')); + $this->addFilter('billed_to', DB::raw('CONCAT(order_address_billing.first_name, " ", order_address_billing.last_name)')); + $this->addFilter('shipped_to', DB::raw('CONCAT(order_address_shipping.first_name, " ", order_address_shipping.last_name)')); $this->setQueryBuilder($queryBuilder); } diff --git a/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php index 7d8ea2cf6..4e0403456 100755 --- a/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php @@ -20,10 +20,14 @@ class OrderShipmentsDataGrid extends DataGrid public function prepareQueryBuilder() { $queryBuilder = DB::table('shipments as ship') + ->leftJoin('order_address as order_address_shipping', function($leftJoin) { + $leftJoin->on('order_address_shipping.order_id', '=', 'ship.order_address_id') + ->where('order_address_shipping.address_type', 'shipping'); + }) ->leftJoin('orders as ors', 'ship.order_id', '=', 'ors.id') ->leftJoin('inventory_sources as is', 'ship.inventory_source_id', '=', 'is.id') ->select('ship.id as shipment_id', 'ship.order_id as shipment_order_id', 'ship.total_qty as shipment_total_qty', 'is.name as inventory_source_name', 'ors.created_at as orderdate', 'ship.created_at as shipment_created_at') - ->addSelect(DB::raw('CONCAT(ors.customer_first_name, " ", ors.customer_last_name) as custname')); + ->addSelect(DB::raw('CONCAT(order_address_shipping.first_name, " ", order_address_shipping.last_name) as shipped_to')); $this->addFilter('shipment_id', 'ship.id'); $this->addFilter('shipment_order_id', 'ship.order_id'); @@ -31,7 +35,7 @@ class OrderShipmentsDataGrid extends DataGrid $this->addFilter('inventory_source_name', 'is.name'); $this->addFilter('orderdate', 'ors.created_at'); $this->addFilter('shipment_created_at', 'ship.created_at'); - $this->addFilter('custname', DB::raw('CONCAT(ors.customer_first_name, " ", ors.customer_last_name)')); + $this->addFilter('shipped_to', DB::raw('CONCAT(ors.customer_first_name, " ", ors.customer_last_name)')); $this->setQueryBuilder($queryBuilder); } @@ -87,7 +91,7 @@ class OrderShipmentsDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'custname', + 'index' => 'shipped_to', 'label' => trans('admin::app.datagrid.shipment-to'), 'type' => 'string', 'sortable' => true,