diff --git a/packages/Webkul/Admin/src/DataGrids/AddressDataGrid.php b/packages/Webkul/Admin/src/DataGrids/AddressDataGrid.php index ac7bbc749..b9db127b1 100644 --- a/packages/Webkul/Admin/src/DataGrids/AddressDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/AddressDataGrid.php @@ -52,7 +52,7 @@ class AddressDataGrid extends DataGrid $queryBuilder = DB::table('customer_addresses as ca') ->leftJoin('countries', 'ca.country', '=', 'countries.code') ->leftJoin('customers as c', 'ca.customer_id', '=', 'c.id') - ->addSelect('ca.id as address_id', 'ca.address1', 'ca.country', DB::raw(''.DB::getTablePrefix().'countries.name as country_name'), 'ca.state', 'ca.city', 'ca.postcode', 'ca.phone', 'ca.default_address') + ->addSelect('ca.id as address_id', 'ca.address1', 'ca.country', DB::raw('' . DB::getTablePrefix() . 'countries.name as country_name'), 'ca.state', 'ca.city', 'ca.postcode', 'ca.phone', 'ca.default_address') ->where('c.id', $customer->id); $queryBuilder = $queryBuilder->leftJoin('country_states', function($qb) { @@ -62,13 +62,13 @@ class AddressDataGrid extends DataGrid $queryBuilder ->groupBy('ca.id') - ->addSelect(DB::raw(''.DB::getTablePrefix().'country_states.default_name as state_name')); + ->addSelect(DB::raw(DB::getTablePrefix() . 'country_states.default_name as state_name')); $this->addFilter('address_id', 'ca.id'); $this->addFilter('address1', 'ca.address1'); $this->addFilter('city', 'ca.city'); - $this->addFilter('state_name', DB::raw(''.DB::getTablePrefix().'country_states.default_name')); - $this->addFilter('country_name', DB::raw(''.DB::getTablePrefix().'countries.name')); + $this->addFilter('state_name', DB::raw(DB::getTablePrefix() . 'country_states.default_name')); + $this->addFilter('country_name', DB::raw(DB::getTablePrefix() . 'countries.name')); $this->addFilter('postcode', 'ca.postcode'); $this->addFilter('default_address', 'ca.default_address'); diff --git a/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php index 98f7152a7..44b174a7b 100755 --- a/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php @@ -21,7 +21,7 @@ class CategoryDataGrid extends DataGrid { $queryBuilder = DB::table('categories as cat') ->select('cat.id as category_id', 'ct.name', 'cat.position', 'cat.status', 'ct.locale', - DB::raw('COUNT(DISTINCT '.DB::getTablePrefix().'pc.product_id) as count')) + DB::raw('COUNT(DISTINCT ' . DB::getTablePrefix() . 'pc.product_id) as count')) ->leftJoin('category_translations as ct', function($leftJoin) { $leftJoin->on('cat.id', '=', 'ct.category_id') ->where('ct.locale', app()->getLocale()); diff --git a/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php index beba7a4b9..7345ea683 100755 --- a/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php @@ -25,10 +25,10 @@ class CustomerDataGrid extends DataGrid $queryBuilder = DB::table('customers') ->leftJoin('customer_groups', 'customers.customer_group_id', '=', 'customer_groups.id') ->addSelect('customers.id as customer_id', 'customers.email', 'customer_groups.name', 'customers.phone', 'customers.gender', 'status') - ->addSelect(DB::raw('CONCAT('.DB::getTablePrefix().'customers.first_name, " ", '.DB::getTablePrefix().'customers.last_name) as full_name')); + ->addSelect(DB::raw('CONCAT(' . DB::getTablePrefix() . 'customers.first_name, " ", ' . DB::getTablePrefix() . 'customers.last_name) as full_name')); $this->addFilter('customer_id', 'customers.id'); - $this->addFilter('full_name', DB::raw('CONCAT('.DB::getTablePrefix().'customers.first_name, " ", '.DB::getTablePrefix().'customers.last_name)')); + $this->addFilter('full_name', DB::raw('CONCAT(' . DB::getTablePrefix() . 'customers.first_name, " ", ' . DB::getTablePrefix() . 'customers.last_name)')); $this->addFilter('phone', 'customers.phone'); $this->addFilter('gender', 'customers.gender'); diff --git a/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php index 7b8049f84..3e8255453 100755 --- a/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php @@ -29,11 +29,11 @@ class OrderDataGrid extends DataGrid ->where('order_address_billing.address_type', 'billing'); }) ->addSelect('orders.id','orders.increment_id', 'orders.base_sub_total', 'orders.base_grand_total', 'orders.created_at', 'channel_name', 'status') - ->addSelect(DB::raw('CONCAT('.DB::getTablePrefix().'order_address_billing.first_name, " ", '.DB::getTablePrefix().'order_address_billing.last_name) as billed_to')) - ->addSelect(DB::raw('CONCAT('.DB::getTablePrefix().'order_address_shipping.first_name, " ", '.DB::getTablePrefix().'order_address_shipping.last_name) as shipped_to')); + ->addSelect(DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_billing.first_name, " ", ' . DB::getTablePrefix() . 'order_address_billing.last_name) as billed_to')) + ->addSelect(DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_shipping.first_name, " ", ' . DB::getTablePrefix() . 'order_address_shipping.last_name) as shipped_to')); - $this->addFilter('billed_to', DB::raw('CONCAT('.DB::getTablePrefix().'order_address_billing.first_name, " ", '.DB::getTablePrefix().'order_address_billing.last_name)')); - $this->addFilter('shipped_to', DB::raw('CONCAT('.DB::getTablePrefix().'order_address_shipping.first_name, " ", '.DB::getTablePrefix().'order_address_shipping.last_name)')); + $this->addFilter('billed_to', DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_billing.first_name, " ", ' . DB::getTablePrefix() . 'order_address_billing.last_name)')); + $this->addFilter('shipped_to', DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_shipping.first_name, " ", ' . DB::getTablePrefix() . 'order_address_shipping.last_name)')); $this->addFilter('increment_id', 'orders.increment_id'); $this->addFilter('created_at', 'orders.created_at'); diff --git a/packages/Webkul/Admin/src/DataGrids/OrderRefundDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderRefundDataGrid.php index 2c425cb70..787b1512e 100755 --- a/packages/Webkul/Admin/src/DataGrids/OrderRefundDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderRefundDataGrid.php @@ -26,9 +26,9 @@ class OrderRefundDataGrid extends DataGrid $leftJoin->on('order_address_billing.order_id', '=', 'orders.id') ->where('order_address_billing.address_type', 'billing'); }) - ->addSelect(DB::raw('CONCAT('.DB::getTablePrefix().'order_address_billing.first_name, " ", '.DB::getTablePrefix().'order_address_billing.last_name) as billed_to')); + ->addSelect(DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_billing.first_name, " ", ' . DB::getTablePrefix() . 'order_address_billing.last_name) as billed_to')); - $this->addFilter('billed_to', DB::raw('CONCAT('.DB::getTablePrefix().'order_address_billing.first_name, " ", '.DB::getTablePrefix().'order_address_billing.last_name)')); + $this->addFilter('billed_to', DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_billing.first_name, " ", ' . DB::getTablePrefix() . 'order_address_billing.last_name)')); $this->addFilter('id', 'refunds.id'); $this->addFilter('increment_id', 'orders.increment_id'); $this->addFilter('state', 'refunds.state'); diff --git a/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php index c6a30567f..a254af897 100755 --- a/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php @@ -26,16 +26,17 @@ class OrderShipmentsDataGrid extends DataGrid }) ->leftJoin('orders as ors', 'shipments.order_id', '=', 'ors.id') ->leftJoin('inventory_sources as is', 'shipments.inventory_source_id', '=', 'is.id') - ->select('shipments.id as shipment_id', 'ors.increment_id as shipment_order_id', 'shipments.total_qty as shipment_total_qty', 'is.name as inventory_source_name', 'ors.created_at as order_date', 'shipments.created_at as shipment_created_at') - ->addSelect(DB::raw('CONCAT('.DB::getTablePrefix().'order_address_shipping.first_name, " ", '.DB::getTablePrefix().'order_address_shipping.last_name) as shipped_to')); + ->select('shipments.id as shipment_id', 'ors.increment_id as shipment_order_id', 'shipments.total_qty as shipment_total_qty', 'ors.created_at as order_date', 'shipments.created_at as shipment_created_at') + ->addSelect(DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_shipping.first_name, " ", ' . DB::getTablePrefix() . 'order_address_shipping.last_name) as shipped_to')) + ->selectRaw('IF(' . DB::getTablePrefix() . 'shipments.inventory_source_id IS NOT NULL,' . DB::getTablePrefix() . 'is.name, ' . DB::getTablePrefix() . 'shipments.inventory_source_name) as inventory_source_name'); $this->addFilter('shipment_id', 'shipments.id'); $this->addFilter('shipment_order_id', 'ors.increment_id'); $this->addFilter('shipment_total_qty', 'shipments.total_qty'); - $this->addFilter('inventory_source_name', 'is.name'); + $this->addFilter('inventory_source_name', DB::raw('IF(' . DB::getTablePrefix() . 'shipments.inventory_source_id IS NOT NULL,' . DB::getTablePrefix() . 'is.name, ' . DB::getTablePrefix() . 'shipments.inventory_source_name)')); $this->addFilter('order_date', 'ors.created_at'); $this->addFilter('shipment_created_at', 'shipments.created_at'); - $this->addFilter('shipped_to', DB::raw(''.DB::getTablePrefix().'CONCAT(order_address_shipping.first_name, " ", '.DB::getTablePrefix().'order_address_shipping.last_name)')); + $this->addFilter('shipped_to', DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_shipping.first_name, " ", ' . DB::getTablePrefix() . 'order_address_shipping.last_name)')); $this->setQueryBuilder($queryBuilder); } diff --git a/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php b/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php index d254106fb..0e78f1f20 100644 --- a/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php @@ -25,7 +25,7 @@ class ProductDataGrid extends DataGrid ->leftJoin('products', 'product_flat.product_id', '=', 'products.id') ->leftJoin('attribute_families', 'products.attribute_family_id', '=', 'attribute_families.id') ->leftJoin('product_inventories', 'product_flat.product_id', '=', 'product_inventories.product_id') - ->select('product_flat.product_id as product_id', 'product_flat.sku as product_sku', 'product_flat.name as product_name', 'products.type as product_type', 'product_flat.status', 'product_flat.price', 'attribute_families.name as attribute_family', DB::raw('SUM('.DB::getTablePrefix().'product_inventories.qty) as quantity')) + ->select('product_flat.product_id as product_id', 'product_flat.sku as product_sku', 'product_flat.name as product_name', 'products.type as product_type', 'product_flat.status', 'product_flat.price', 'attribute_families.name as attribute_family', DB::raw('SUM(' . DB::getTablePrefix() . 'product_inventories.qty) as quantity')) ->where('channel', core()->getCurrentChannelCode()) ->where('locale', app()->getLocale()) ->groupBy('product_flat.product_id'); diff --git a/packages/Webkul/Admin/src/Http/Controllers/DashboardController.php b/packages/Webkul/Admin/src/Http/Controllers/DashboardController.php index c77a66a73..08a81d355 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/DashboardController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/DashboardController.php @@ -186,7 +186,7 @@ class DashboardController extends Controller ->where('order_items.created_at', '>=', $this->startDate) ->where('order_items.created_at', '<=', $this->endDate) ->addSelect(DB::raw('SUM(qty_invoiced - qty_refunded) as total_qty_invoiced')) - ->addSelect(DB::raw('COUNT('.DB::getTablePrefix().'products.id) as total_products')) + ->addSelect(DB::raw('COUNT(' . DB::getTablePrefix() . 'products.id) as total_products')) ->addSelect('order_items.id', 'categories.id as category_id', 'category_translations.name') ->groupBy('categories.id') ->havingRaw('SUM(qty_invoiced - qty_refunded) > 0') diff --git a/packages/Webkul/Admin/src/Resources/views/sales/shipments/view.blade.php b/packages/Webkul/Admin/src/Resources/views/sales/shipments/view.blade.php index e88d7d50b..df955df12 100755 --- a/packages/Webkul/Admin/src/Resources/views/sales/shipments/view.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/sales/shipments/view.blade.php @@ -195,14 +195,14 @@ - @if ($shipment->inventory_source) + @if ($shipment->inventory_source || $shipment->inventory_source_name)
{{ __('admin::app.sales.shipments.inventory-source') }} - {{ $shipment->inventory_source->name }} + {{ $shipment->inventory_source ? $shipment->inventory_source->name : $shipment->inventory_source_name }}
@endif diff --git a/packages/Webkul/Sales/src/Database/Migrations/2020_01_09_202815_add_inventory_source_name_column_in_shipments_table.php b/packages/Webkul/Sales/src/Database/Migrations/2020_01_09_202815_add_inventory_source_name_column_in_shipments_table.php new file mode 100644 index 000000000..07fd44fa6 --- /dev/null +++ b/packages/Webkul/Sales/src/Database/Migrations/2020_01_09_202815_add_inventory_source_name_column_in_shipments_table.php @@ -0,0 +1,32 @@ +string('inventory_source_name')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('shipments', function (Blueprint $table) { + // + }); + } +} diff --git a/packages/Webkul/Sales/src/Repositories/ShipmentRepository.php b/packages/Webkul/Sales/src/Repositories/ShipmentRepository.php index 99bf2a1eb..83076718d 100755 --- a/packages/Webkul/Sales/src/Repositories/ShipmentRepository.php +++ b/packages/Webkul/Sales/src/Repositories/ShipmentRepository.php @@ -157,7 +157,8 @@ class ShipmentRepository extends Repository } $shipment->update([ - 'total_qty' => $totalQty + 'total_qty' => $totalQty, + 'inventory_source_name' => $shipment->inventory_source->name ]); $this->orderRepository->updateOrderStatus($order); diff --git a/packages/Webkul/Shop/src/DataGrids/DownloadableProductDataGrid.php b/packages/Webkul/Shop/src/DataGrids/DownloadableProductDataGrid.php index ced3940c6..32398ca58 100644 --- a/packages/Webkul/Shop/src/DataGrids/DownloadableProductDataGrid.php +++ b/packages/Webkul/Shop/src/DataGrids/DownloadableProductDataGrid.php @@ -22,7 +22,7 @@ class DownloadableProductDataGrid extends DataGrid $queryBuilder = DB::table('downloadable_link_purchased') ->leftJoin('orders', 'downloadable_link_purchased.order_id', '=', 'orders.id') ->addSelect('downloadable_link_purchased.*', 'orders.increment_id') - ->addSelect(DB::raw('('.DB::getTablePrefix().'downloadable_link_purchased.download_bought - '.DB::getTablePrefix().'downloadable_link_purchased.download_used) as remaining_downloads')) + ->addSelect(DB::raw('(' . DB::getTablePrefix() . 'downloadable_link_purchased.download_bought - ' . DB::getTablePrefix() . 'downloadable_link_purchased.download_used) as remaining_downloads')) ->where('downloadable_link_purchased.customer_id', auth()->guard('customer')->user()->id); $this->addFilter('status', 'downloadable_link_purchased.status'); diff --git a/packages/Webkul/Ui/src/DataGrid/DataGrid.php b/packages/Webkul/Ui/src/DataGrid/DataGrid.php index 7688aac0b..d09d3a7fc 100644 --- a/packages/Webkul/Ui/src/DataGrid/DataGrid.php +++ b/packages/Webkul/Ui/src/DataGrid/DataGrid.php @@ -295,8 +295,8 @@ abstract class DataGrid public function sortOrFilterCollection($collection, $parseInfo) { foreach ($parseInfo as $key => $info) { - $columnType = $this->findColumnType($key)[0]; - $columnName = $this->findColumnType($key)[1]; + $columnType = $this->findColumnType($key)[0] ?? null; + $columnName = $this->findColumnType($key)[1] ?? null; if ($key == "sort") { $count_keys = count(array_keys($info));