This commit is contained in:
rahul shukla 2018-12-04 09:53:52 +05:30
parent 984ff18267
commit 27f5e1d93d
27 changed files with 4854 additions and 81 deletions

View File

@ -104,7 +104,12 @@ class CustomerDataGrid
'alias' => 'Email',
'type' => 'string',
'label' => 'Email',
],
], [
'column' => 'cg.name',
'alias' => 'CustomerGroupName',
'type' => 'string',
'label' => 'Group Name',
]
],
//don't use aliasing in case of searchables
@ -139,10 +144,10 @@ class CustomerDataGrid
}
public function render()
public function render($pagination = true)
{
return $this->createCustomerDataGrid()->render();
return $this->createCustomerDataGrid()->render($pagination);
}
}

View File

@ -171,8 +171,8 @@ class OrderDataGrid
]);
}
public function render()
public function render($pagination = true)
{
return $this->createOrderDataGrid()->render();
return $this->createOrderDataGrid()->render($pagination);
}
}

View File

@ -137,8 +137,8 @@ class OrderInvoicesDataGrid
]);
}
public function render()
public function render($pagination = true)
{
return $this->createOrderInvoicesDataGrid()->render();
return $this->createOrderInvoicesDataGrid()->render($pagination);
}
}

View File

@ -133,8 +133,8 @@ class OrderShipmentsDataGrid
]);
}
public function render()
public function render($pagination = true)
{
return $this->createOrderShipmentsDataGrid()->render();
return $this->createOrderShipmentsDataGrid()->render($pagination);
}
}

View File

@ -185,4 +185,10 @@ class ProductDataGrid
}
public function export()
{
$paginate = false;
return $this->createProductDataGrid()->render($paginate);
}
}

View File

@ -54,13 +54,13 @@ class Handler extends ExceptionHandler
return response()->view('shop::errors.500', [], 500);
}
}
} else if ($exception instanceof \ModelNotFoundException) {
} else if ($exception instanceof ModelNotFoundException) {
if (strpos($_SERVER['REQUEST_URI'], 'admin') !== false){
return response()->view('admin::errors.404', [], 404);
}else {
return response()->view('shop::errors.404', [], 404);
}
} else if ($exception instanceof \PDOException) {
} else if ($exception instanceof PDOException) {
if (strpos($_SERVER['REQUEST_URI'], 'admin') !== false){
return response()->view('admin::errors.500', [], 500);
} else {

View File

@ -34,20 +34,17 @@ class DataGridExport implements FromView, ShouldAutoSize
$this->gridData = $gridData;
}
/**
* function to create a blade view for export.
*
*/
public function view(): View
{
$results = $this->gridData->render();
$header = [];
foreach($results->columns as $col) {
$header[] = $col->label;
}
$pagination = false;
return view('admin::export.export', [
'results' => $this->gridData->render()->results,
'columns' => $this->gridData->render()->columns,
'header' => $header
'results' => $this->gridData->render($pagination)->results,
'columns' => $this->gridData->render($pagination)->columns,
]);
}
}

View File

@ -5,14 +5,12 @@ namespace Webkul\Admin\Http\Controllers\Customer;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Webkul\Admin\Http\Controllers\Controller;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Webkul\Customer\Repositories\CustomerRepository as Customer;
use Webkul\Customer\Repositories\CustomerGroupRepository as CustomerGroup;
use Webkul\Core\Repositories\ChannelRepository as Channel;
use Webkul\Admin\DataGrids\CustomerDataGrid as CustomerDataGrid;
use Webkul\Admin\Exports\DataGridExport;
use Excel;
/**
* Customer controlller
*
@ -49,23 +47,15 @@ class CustomerController extends Controller
*/
protected $channel;
/**
* CustomerDataGrid object
*
* @var array
*/
protected $customerDataGrid;
/**
* Create a new controller instance.
*
* @param Webkul\Customer\Repositories\CustomerRepository as customer;
* @param Webkul\Customer\Repositories\CustomerGroupRepository as customerGroup;
* @param Webkul\Core\Repositories\ChannelRepository as Channel;
* @param Webkul\Admin\DataGrids\CustomerDataGrid as customerDataGrid;
* @return void
*/
public function __construct(Customer $customer, CustomerGroup $customerGroup, Channel $channel, CustomerDataGrid $customerDataGrid)
public function __construct(Customer $customer, CustomerGroup $customerGroup, Channel $channel)
{
$this->_config = request('_config');
@ -77,8 +67,6 @@ class CustomerController extends Controller
$this->channel = $channel;
$this->customerDataGrid = $customerDataGrid;
}
/**
@ -190,15 +178,4 @@ class CustomerController extends Controller
return redirect()->back();
}
/**
* function to export datagrid
*
*/
public function export()
{
$data = $this->customerDataGrid;
return Excel::download(new DataGridExport($data), 'customers.xlsx');
}
}

View File

@ -125,7 +125,7 @@ class CustomerGroupController extends Controller
{
$group = $this->customerGroup->findOneWhere(['id'=>$id]);
if(!$group->is_user_defined) {
if($group->is_user_defined) {
session()->flash('error', 'This Customer Group can not be deleted');
} else {
$this->customerGroup->delete($id);

View File

@ -0,0 +1,45 @@
<?php
namespace Webkul\Admin\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Webkul\Admin\Http\Controllers\Controller;
use Webkul\Admin\Exports\DataGridExport;
use Excel;
/**
* Export controlller
*
* @author Rahul Shukla <rahulshukla.symfony517@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class ExportController extends Controller
{
/**
* Create a new controller instance.
*
*/
public function __construct()
{
$this->middleware('admin');
}
/**
* function for export datagrid
*
* @return \Illuminate\Http\Response
*/
public function export()
{
$results = unserialize(request()->all()['gridData']);
$file_name = class_basename($results);
if(request()->all()['format'] == 'csv') {
return Excel::download(new DataGridExport($results), $file_name.'.csv');
} else {
return Excel::download(new DataGridExport($results), $file_name.'.xlsx');
}
}
}

View File

@ -66,8 +66,6 @@ Route::group(['middleware' => ['web']], function () {
Route::get('customers/delete/{id}', 'Webkul\Admin\Http\Controllers\Customer\CustomerController@destroy')->name('admin.customer.delete');
//DataGrid Export
Route::get('customer-export', 'Webkul\Admin\Http\Controllers\Customer\CustomerController@export')->name('admin.customer.export');
Route::get('reviews', 'Webkul\Product\Http\Controllers\ReviewController@index')->defaults('_config',[
'view' => 'admin::customers.review.index'
@ -560,6 +558,10 @@ Route::group(['middleware' => ['web']], function () {
Route::get('/tax-rates/delete/{id}', 'Webkul\Tax\Http\Controllers\TaxRateController@destroy')->name('admin.tax-rates.delete');
//tax rate ends
//DataGrid Export
Route::post('admin/export', 'Webkul\Admin\Http\Controllers\ExportController@export')->name('admin.datagrid.export');
});
});
});

View File

@ -542,6 +542,16 @@ body {
.page-action {
float: left;
.export {
display: flex;
cursor: pointer;
span {
margin-top: 7px;
margin-left: 5px
}
}
}
.control-group {

View File

@ -531,8 +531,7 @@ return [
'channel_name' => 'Channel Name',
'state' => 'State',
'select-state' => 'Select a region, state or province.',
'country' => 'Country',
'export' => 'Export'
'country' => 'Country'
],
'reviews' => [
'title' => 'Reviews',
@ -570,5 +569,11 @@ return [
'title' => 'Unauthorized Error',
'message' => 'The request has not been applied because it lacks valid authentication credentials for the target resource.'
],
],
'export' => [
'export' => 'Export',
'format' => 'Select Format',
'download' => 'Download'
]
];

View File

@ -21,19 +21,19 @@
</div>
<div class="page-content">
<div class="form-container">
@csrf()
<accordian :title="'{{ __('admin::app.catalog.families.general') }}'" :active="true">
<div slot="body">
<div class="control-group" :class="[errors.has('code') ? 'has-error' : '']">
<label for="code" class="required">{{ __('admin::app.catalog.families.code') }}</label>
<input type="text" v-validate="'required'" class="control" id="code" name="code" value="{{ old('code') }}" data-vv-as="&quot;{{ __('admin::app.catalog.families.code') }}&quot;" v-code/>
<span class="control-error" v-if="errors.has('code')">@{{ errors.first('code') }}</span>
</div>
<div class="control-group" :class="[errors.has('name') ? 'has-error' : '']">
<label for="name" class="required">{{ __('admin::app.catalog.families.name') }}</label>
<input type="text" v-validate="'required'" class="control" id="name" name="name" value="{{ old('name') }}" data-vv-as="&quot;{{ __('admin::app.catalog.families.name') }}&quot;"/>
@ -66,6 +66,7 @@
<group-form></group-form>
</div>
</modal>
@stop
@push('scripts')
@ -173,7 +174,7 @@
</div>
</accordian>
</script>
<script>
var groups = @json($attributeFamily ? $attributeFamily->attribute_groups : []);
var custom_attributes = @json($custom_attributes);
@ -216,7 +217,7 @@
groups.push(this.group);
groups = this.sortGroups();
this.group = {'groupName': '', 'position': '', 'is_user_defined': 1, 'custom_attributes': []};
this.$parent.closeModal();
@ -273,7 +274,7 @@
addAttributes (groupIndex, attributeIds) {
attributeIds.forEach(function(attributeId) {
var attribute = this.custom_attributes.filter(attribute => attribute.id == attributeId)
this.groups[groupIndex].custom_attributes.push(attribute[0]);
let index = this.custom_attributes.indexOf(attribute[0])
@ -321,7 +322,7 @@
$(e.target).prev().find('li input').each(function() {
var attributeId = $(this).val();
if($(this).is(':checked')) {
attributeIds.push(attributeId);
@ -340,4 +341,4 @@
}
});
</script>
@endpush
@endpush

View File

@ -4,6 +4,8 @@
{{ __('admin::app.customers.customers.title') }}
@stop
@inject('customer','Webkul\Admin\DataGrids\CustomerDataGrid')
@section('content')
<div class="content">
@ -16,15 +18,18 @@
{{ __('admin::app.customers.customers.add-title') }}
</a>
<a href="{{ route('admin.customer.export') }}" class="btn btn-lg btn-primary">
{{ __('admin::app.customers.customers.export') }}
</a>
<form method="POST" action="{{ route('admin.datagrid.export') }}">
@csrf()
<button type="submit" class="btn btn-lg btn-primary">
{{ __('admin::app.customers.customers.export') }}
</button>
<input type="hidden" name="gridData" value="{{serialize($customer)}}">
</form>
</div>
</div>
<div class="page-content">
@inject('customer','Webkul\Admin\DataGrids\CustomerDataGrid')
{!! $customer->render() !!}
</div>
</div>

View File

@ -1,8 +1,8 @@
<table>
<thead>
<tr>
@foreach($header as $col)
<th> {{ $col}} </th>
@foreach ($columns as $column)
<th>{{ $column->label }}</th>
@endforeach
</tr>
</thead>

View File

@ -4,6 +4,8 @@
{{ __('admin::app.sales.invoices.title') }}
@stop
@inject('orderInvoicesGrid', 'Webkul\Admin\DataGrids\OrderInvoicesDataGrid')
@section('content')
<div class="content full-page">
<div class="page-header">
@ -12,12 +14,71 @@
</div>
<div class="page-action">
<div class="export">
<i class="export-icon"></i>
<span @click="showModal('downloadDataGrid')">
{{ __('admin::app.export.export') }}
</span>
</div>
</div>
</div>
<div class="page-content">
@inject('orderInvoicesGrid', 'Webkul\Admin\DataGrids\OrderInvoicesDataGrid')
{!! $orderInvoicesGrid->render() !!}
</div>
</div>
@stop
<modal id="downloadDataGrid" :is-open="modalIds.downloadDataGrid">
<h3 slot="header">{{ __('admin::app.export.download') }}</h3>
<div slot="body">
<export-form></export-form>
</div>
</modal>
@stop
@push('scripts')
<script type="text/x-template" id="export-form-template">
<form method="POST" action="{{ route('admin.datagrid.export') }}">
<div class="page-content">
<div class="form-container">
@csrf()
<input type="hidden" name="gridData" value="{{serialize($orderInvoicesGrid)}}">
<div class="control-group">
<label for="format" class="required">
{{ __('admin::app.export.format') }}
</label>
<select name="format" class="control" v-validate="'required'">
<option value="xls">XLS</option>
<option value="csv">CSV</option>
</select>
</div>
</div>
</div>
<button type="submit" class="btn btn-lg btn-primary" @click="closeModal">
{{ __('admin::app.export.export') }}
</button>
</form>
</script>
<script>
Vue.component('export-form', {
template: '#export-form-template',
methods: {
closeModal () {
this.$parent.closeModal();
}
}
});
</script>
@endpush

View File

@ -4,6 +4,8 @@
{{ __('admin::app.sales.orders.title') }}
@stop
@inject('orderGrid', 'Webkul\Admin\DataGrids\OrderDataGrid')
@section('content')
<div class="content full-page">
<div class="page-header">
@ -12,11 +14,17 @@
</div>
<div class="page-action">
<form method="POST" action="{{ route('admin.datagrid.export') }}">
@csrf()
<button type="submit" class="btn btn-lg btn-primary">
{{ __('admin::app.customers.customers.export') }}
</button>
<input type="hidden" name="gridData" value="{{serialize($orderGrid)}}">
</form>
</div>
</div>
<div class="page-content">
@inject('orderGrid', 'Webkul\Admin\DataGrids\OrderDataGrid')
{!! $orderGrid->render() !!}
</div>
</div>

View File

@ -4,6 +4,8 @@
{{ __('admin::app.sales.shipments.title') }}
@stop
@inject('orderShipmentsGrid', 'Webkul\Admin\DataGrids\OrderShipmentsDataGrid')
@section('content')
<div class="content full-page">
<div class="page-header">
@ -12,11 +14,17 @@
</div>
<div class="page-action">
<form method="POST" action="{{ route('admin.datagrid.export') }}">
@csrf()
<button type="submit" class="btn btn-lg btn-primary">
{{ __('admin::app.customers.customers.export') }}
</button>
<input type="hidden" name="gridData" value="{{serialize($orderShipmentsGrid)}}">
</form>
</div>
</div>
<div class="page-content">
@inject('orderShipmentsGrid', 'Webkul\Admin\DataGrids\OrderShipmentsDataGrid')
{!! $orderShipmentsGrid->render() !!}
</div>
</div>

View File

@ -57,7 +57,7 @@
<div class="horizontal-rule mb-10 mt-10"></div>
@endforeach
@else
<div class="empty">
<div class="empty mt-15">
{{ __('customer::app.reviews.empty') }}
</div>
@endif

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="32px" height="32px" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 50 (54983) - http://www.bohemiancoding.com/sketch -->
<title>Icon-Export</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Icon-Export" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round">
<g transform="translate(1.000000, 6.000000)" stroke="#979797" stroke-width="2">
<path d="M19,5.5 C19,2.78076172 19,0.947428385 19,0 L0,0 L0,20 L19,20 L19,14.5" id="Path-2"></path>
<path d="M8,10 L28.068125,10" id="Path-3"></path>
<polyline id="Path-4" points="26 5.18359375 29.9388428 10.1218262 26 14.894043"></polyline>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 881 B

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
{
"/js/ui.js": "/js/ui.js?id=b25a07d206dd0b89048f",
"/css/ui.css": "/css/ui.css?id=856413ffffbe95f7b91d"
}
"/js/ui.js": "/js/ui.js",
"/css/ui.css": "/css/ui.css"
}

View File

@ -654,7 +654,7 @@ class DataGrid
}
}
private function getDbQueryResults()
private function getDbQueryResults($pagination = true)
{
$parsed = $this->parse();
@ -751,7 +751,9 @@ class DataGrid
$this->results = $this->query->get();
$this->results = $this->query->paginate($this->perpage)->appends(request()->except('page'));
if($pagination == true) {
$this->results = $this->query->paginate($this->perpage)->appends(request()->except('page'));
}
return $this->results;
@ -769,7 +771,9 @@ class DataGrid
$this->results = $this->query->get();
$this->results = $this->query->paginate($this->perpage)->appends(request()->except('page'));
if($pagination == true) {
$this->results = $this->query->paginate($this->perpage)->appends(request()->except('page'));
}
return $this->results;
}
@ -783,9 +787,9 @@ class DataGrid
* @return view
*/
public function render()
public function render($pagination = true)
{
$this->getDbQueryResults();
$this->getDbQueryResults($pagination);
return view('ui::datagrid.index', [
'css' => $this->css,

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="32px" height="32px" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 50 (54983) - http://www.bohemiancoding.com/sketch -->
<title>Icon-Export</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Icon-Export" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round">
<g transform="translate(1.000000, 6.000000)" stroke="#979797" stroke-width="2">
<path d="M19,5.5 C19,2.78076172 19,0.947428385 19,0 L0,0 L0,20 L19,20 L19,14.5" id="Path-2"></path>
<path d="M8,10 L28.068125,10" id="Path-3"></path>
<polyline id="Path-4" points="26 5.18359375 29.9388428 10.1218262 26 14.894043"></polyline>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 881 B

View File

@ -286,3 +286,9 @@
width: 255px;
height: 255px;
}
.export-icon {
background-image: url("../images/Icon-Export.svg");
width: 32px;
height: 32px;
}