Merge pull request #3239 from ghermans/development

Customer details
This commit is contained in:
Jitendra Singh 2020-06-16 13:03:50 +05:30 committed by GitHub
commit 9f27e46d5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 163 additions and 157 deletions

View File

@ -53,13 +53,13 @@ return [
'key' => 'catalog.categories',
'name' => 'admin::app.layouts.categories',
'route' => 'admin.catalog.categories.index',
'sort' => 3,
'sort' => 2,
'icon-class' => '',
], [
'key' => 'catalog.attributes',
'name' => 'admin::app.layouts.attributes',
'route' => 'admin.catalog.attributes.index',
'sort' => 2,
'sort' => 3,
'icon-class' => '',
], [
'key' => 'catalog.families',

View File

@ -59,13 +59,12 @@ class AddressDataGrid extends DataGrid
$queryBuilder->groupBy('ca.id')
->addSelect(DB::raw(DB::getTablePrefix() . 'country_states.default_name as state_name'));
$this->addFilter('address_id', 'ca.id');
$this->addFilter('company_name', 'ca.company_name');
$this->addFilter('address1', 'ca.address1');
$this->addFilter('postcode', 'ca.postcode');
$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('postcode', 'ca.postcode');
$this->addFilter('default_address', 'ca.default_address');
$this->setQueryBuilder($queryBuilder);
@ -73,15 +72,6 @@ class AddressDataGrid extends DataGrid
public function addColumns()
{
$this->addColumn([
'index' => 'address_id',
'label' => trans('admin::app.customers.addresses.address-id'),
'type' => 'number',
'searchable' => true,
'sortable' => true,
'filterable' => true,
]);
$this->addColumn([
'index' => 'company_name',
'label' => trans('admin::app.customers.addresses.company-name'),
@ -100,6 +90,15 @@ class AddressDataGrid extends DataGrid
'filterable' => true,
]);
$this->addColumn([
'index' => 'postcode',
'label' => trans('admin::app.customers.addresses.postcode'),
'type' => 'string',
'searchable' => true,
'sortable' => true,
'filterable' => true,
]);
$this->addColumn([
'index' => 'city',
'label' => trans('admin::app.customers.addresses.city'),
@ -127,15 +126,6 @@ class AddressDataGrid extends DataGrid
'filterable' => true,
]);
$this->addColumn([
'index' => 'postcode',
'label' => trans('admin::app.customers.addresses.postcode'),
'type' => 'string',
'searchable' => true,
'sortable' => true,
'filterable' => true,
]);
$this->addColumn([
'index' => 'default_address',
'label' => trans('admin::app.customers.addresses.default-address'),

View File

@ -5,8 +5,11 @@ namespace Webkul\Admin\Http\Controllers\Customer;
use Illuminate\Support\Facades\Event;
use Webkul\Admin\Http\Controllers\Controller;
use Webkul\Customer\Repositories\CustomerRepository;
use Webkul\Customer\Repositories\CustomerAddressRepository;
use Webkul\Customer\Repositories\CustomerGroupRepository;
use Webkul\Core\Repositories\ChannelRepository;
use Webkul\Admin\Mail\NewCustomerNotification;
use Mail;
@ -26,6 +29,13 @@ class CustomerController extends Controller
*/
protected $customerRepository;
/**
* CustomerAddress Repository object
*
* @var \Webkul\Customer\Repositories\CustomerAddressRepository
*/
protected $customerAddressRepository;
/**
* CustomerGroupRepository object
*
@ -44,26 +54,26 @@ class CustomerController extends Controller
* Create a new controller instance.
*
* @param \Webkul\Customer\Repositories\CustomerRepository $customerRepository
* @param \Webkul\Customer\Repositories\CustomerAddressRepository $customerAddressRepository
* @param \Webkul\Customer\Repositories\CustomerGroupRepository $customerGroupRepository
* @param \Webkul\Core\Repositories\ChannelRepository $channelRepository
*/
public function __construct(
CustomerRepository $customerRepository,
CustomerAddressRepository $customerAddressRepository,
CustomerGroupRepository $customerGroupRepository,
ChannelRepository $channelRepository
)
{
$this->_config = request('_config');
$this->middleware('admin');
$this->customerRepository = $customerRepository;
$this->customerGroupRepository = $customerGroupRepository;
$this->channelRepository = $channelRepository;
}
)
{
$this->_config = request('_config');
$this->middleware('admin');
$this->customerRepository = $customerRepository;
$this->customerAddressRepository = $customerAddressRepository;
$this->customerGroupRepository = $customerGroupRepository;
$this->channelRepository = $channelRepository;
}
/**
* Display a listing of the resource.
@ -141,12 +151,11 @@ class CustomerController extends Controller
public function edit($id)
{
$customer = $this->customerRepository->findOrFail($id);
$address = $this->customerAddressRepository->find($id);
$customerGroup = $this->customerGroupRepository->findWhere([['code', '<>', 'guest']]);
$channelName = $this->channelRepository->all();
return view($this->_config['view'], compact('customer', 'customerGroup', 'channelName'));
return view($this->_config['view'], compact('customer', 'address', 'customerGroup', 'channelName'));
}
/**

View File

@ -6,129 +6,31 @@
@section('content')
<div class="content">
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="history.length > 1 ? history.go(-1) : window.location = '{{ url('/admin/dashboard') }}';"></i>
{{ $customer->first_name . " " . $customer->last_name }}
</h1>
</div>
</div>
<tabs>
{!! view_render_event('bagisto.admin.customer.edit.before', ['customer' => $customer]) !!}
<form method="POST" action="{{ route('admin.customer.update', $customer->id) }}">
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="history.length > 1 ? history.go(-1) : window.location = '{{ url('/admin/dashboard') }}';"></i>
{{ __('admin::app.customers.customers.title') }}
</h1>
<tab name="{{ __('admin::app.sales.orders.info') }}" :selected="true">
<div class="sale-container">
@include('admin::customers.general')
</div>
</tab>
<div class="page-action">
<button type="submit" class="btn btn-lg btn-primary">
{{ __('admin::app.customers.customers.save-btn-title') }}
</button>
<tab name="{{ __('admin::app.customers.customers.addresses') }}" :selected="false">
<div class="style:overflow: auto;">&nbsp;</div>
{!! view_render_event('bagisto.admin.customer.addresses.list.before') !!}
{!! app('Webkul\Admin\DataGrids\AddressDataGrid')->render() !!}
{!! view_render_event('bagisto.admin.customer.addresses.list.after') !!}
</div>
</div>
<div class="page-content">
<div class="form-container">
@csrf()
<input name="_method" type="hidden" value="PUT">
<accordian :title="'{{ __('admin::app.account.general') }}'" :active="true">
<div slot="body">
{!! view_render_event('bagisto.admin.customer.edit.form.before', ['customer' => $customer]) !!}
<div class="control-group" :class="[errors.has('first_name') ? 'has-error' : '']">
<label for="first_name" class="required"> {{ __('admin::app.customers.customers.first_name') }}</label>
<input type="text" class="control" name="first_name" v-validate="'required'" value="{{old('first_name') ?:$customer->first_name}}"
data-vv-as="&quot;{{ __('shop::app.customer.signup-form.firstname') }}&quot;"/>
<span class="control-error" v-if="errors.has('first_name')">@{{ errors.first('first_name') }}</span>
</div>
{!! view_render_event('bagisto.admin.customer.edit.first_name.after', ['customer' => $customer]) !!}
<div class="control-group" :class="[errors.has('last_name') ? 'has-error' : '']">
<label for="last_name" class="required"> {{ __('admin::app.customers.customers.last_name') }}</label>
<input type="text" class="control" name="last_name" v-validate="'required'" value="{{old('last_name') ?:$customer->last_name}}" data-vv-as="&quot;{{ __('shop::app.customer.signup-form.lastname') }}&quot;">
<span class="control-error" v-if="errors.has('last_name')">@{{ errors.first('last_name') }}</span>
</div>
{!! view_render_event('bagisto.admin.customer.edit.last_name.after', ['customer' => $customer]) !!}
<div class="control-group" :class="[errors.has('email') ? 'has-error' : '']">
<label for="email" class="required"> {{ __('admin::app.customers.customers.email') }}</label>
<input type="email" class="control" name="email" v-validate="'required|email'" value="{{old('email') ?:$customer->email}}" data-vv-as="&quot;{{ __('shop::app.customer.signup-form.email') }}&quot;">
<span class="control-error" v-if="errors.has('email')">@{{ errors.first('email') }}</span>
</div>
{!! view_render_event('bagisto.admin.customer.edit.email.after', ['customer' => $customer]) !!}
<div class="control-group" :class="[errors.has('gender') ? 'has-error' : '']">
<label for="gender" class="required">{{ __('admin::app.customers.customers.gender') }}</label>
<select name="gender" class="control" value="{{ $customer->gender }}" v-validate="'required'" data-vv-as="&quot;{{ __('admin::app.customers.customers.gender') }}&quot;">
<option value="" {{ $customer->gender == "" ? 'selected' : '' }}></option>
<option value="{{ __('admin::app.customers.customers.male') }}" {{ $customer->gender == __('admin::app.customers.customers.male') ? 'selected' : '' }}>{{ __('admin::app.customers.customers.male') }}</option>
<option value="{{ __('admin::app.customers.customers.female') }}" {{ $customer->gender == __('admin::app.customers.customers.female') ? 'selected' : '' }}>{{ __('admin::app.customers.customers.female') }}</option>
<option value="{{ __('admin::app.customers.customers.other') }}" {{ $customer->gender == __('admin::app.customers.customers.other') ? 'selected' : '' }}>{{ __('admin::app.customers.customers.other') }}</option>
</select>
<span class="control-error" v-if="errors.has('gender')">@{{ errors.first('gender') }}</span>
</div>
{!! view_render_event('bagisto.admin.customer.edit.gender.after', ['customer' => $customer]) !!}
<div class="control-group">
<label for="status" class="required">{{ __('admin::app.customers.customers.status') }}</label>
<label class="switch">
<input type="checkbox" id="status" name="status" value="{{ $customer->status }}" {{ $customer->status ? 'checked' : '' }}>
<span class="slider round"></span>
</label>
<span class="control-error" v-if="errors.has('status')">@{{ errors.first('status') }}</span>
</div>
{!! view_render_event('bagisto.admin.customer.edit.status.after', ['customer' => $customer]) !!}
<div class="control-group" :class="[errors.has('date_of_birth') ? 'has-error' : '']">
<label for="dob">{{ __('admin::app.customers.customers.date_of_birth') }}</label>
<input type="date" class="control" name="date_of_birth" value="{{ old('date_of_birth') ?:$customer->date_of_birth }}" v-validate="" data-vv-as="&quot;{{ __('admin::app.customers.customers.date_of_birth') }}&quot;">
<span class="control-error" v-if="errors.has('date_of_birth')">@{{ errors.first('date_of_birth') }}</span>
</div>
{!! view_render_event('bagisto.admin.customer.edit.date_of_birth.after', ['customer' => $customer]) !!}
<div class="control-group" :class="[errors.has('phone') ? 'has-error' : '']">
<label for="phone">{{ __('admin::app.customers.customers.phone') }}</label>
<input type="text" class="control" name="phone" value="{{ $customer->phone }}" data-vv-as="&quot;{{ __('admin::app.customers.customers.phone') }}&quot;">
<span class="control-error" v-if="errors.has('phone')">@{{ errors.first('phone') }}</span>
</div>
{!! view_render_event('bagisto.admin.customer.edit.phone.after', ['customer' => $customer]) !!}
<div class="control-group">
<label for="customerGroup" >{{ __('admin::app.customers.customers.customer_group') }}</label>
@if (! is_null($customer->customer_group_id))
<?php $selectedCustomerOption = $customer->group->id ?>
@else
<?php $selectedCustomerOption = '' ?>
@endif
<select class="control" name="customer_group_id">
@foreach ($customerGroup as $group)
<option value="{{ $group->id }}" {{ $selectedCustomerOption == $group->id ? 'selected' : '' }}>
{{ $group->name}}
</option>
@endforeach
</select>
</div>
</div>
</accordian>
</div>
</div>
</form>
</tab>
{!! view_render_event('bagisto.admin.customer.edit.after', ['customer' => $customer]) !!}
</tabs>
</div>
@stop

View File

@ -0,0 +1,105 @@
{!! view_render_event('bagisto.admin.customer.edit.before', ['customer' => $customer]) !!}
<form method="POST" action="{{ route('admin.customer.update', $customer->id) }}">
<div class="page-content">
<div class="form-container">
@csrf()
<input name="_method" type="hidden" value="PUT">
<div class="style:overflow: auto;">&nbsp;</div>
<div slot="body">
{!! view_render_event('bagisto.admin.customer.edit.form.before', ['customer' => $customer]) !!}
<div class="control-group" :class="[errors.has('first_name') ? 'has-error' : '']">
<label for="first_name" class="required"> {{ __('admin::app.customers.customers.first_name') }}</label>
<input type="text" class="control" name="first_name" v-validate="'required'" value="{{old('first_name') ?:$customer->first_name}}"
data-vv-as="&quot;{{ __('shop::app.customer.signup-form.firstname') }}&quot;"/>
<span class="control-error" v-if="errors.has('first_name')">@{{ errors.first('first_name') }}</span>
</div>
{!! view_render_event('bagisto.admin.customer.edit.first_name.after', ['customer' => $customer]) !!}
<div class="control-group" :class="[errors.has('last_name') ? 'has-error' : '']">
<label for="last_name" class="required"> {{ __('admin::app.customers.customers.last_name') }}</label>
<input type="text" class="control" name="last_name" v-validate="'required'" value="{{old('last_name') ?:$customer->last_name}}" data-vv-as="&quot;{{ __('shop::app.customer.signup-form.lastname') }}&quot;">
<span class="control-error" v-if="errors.has('last_name')">@{{ errors.first('last_name') }}</span>
</div>
{!! view_render_event('bagisto.admin.customer.edit.last_name.after', ['customer' => $customer]) !!}
<div class="control-group" :class="[errors.has('email') ? 'has-error' : '']">
<label for="email" class="required"> {{ __('admin::app.customers.customers.email') }}</label>
<input type="email" class="control" name="email" v-validate="'required|email'" value="{{old('email') ?:$customer->email}}" data-vv-as="&quot;{{ __('shop::app.customer.signup-form.email') }}&quot;">
<span class="control-error" v-if="errors.has('email')">@{{ errors.first('email') }}</span>
</div>
{!! view_render_event('bagisto.admin.customer.edit.email.after', ['customer' => $customer]) !!}
<div class="control-group" :class="[errors.has('gender') ? 'has-error' : '']">
<label for="gender" class="required">{{ __('admin::app.customers.customers.gender') }}</label>
<select name="gender" class="control" value="{{ $customer->gender }}" v-validate="'required'" data-vv-as="&quot;{{ __('admin::app.customers.customers.gender') }}&quot;">
<option value="" {{ $customer->gender == "" ? 'selected' : '' }}></option>
<option value="{{ __('admin::app.customers.customers.male') }}" {{ $customer->gender == __('admin::app.customers.customers.male') ? 'selected' : '' }}>{{ __('admin::app.customers.customers.male') }}</option>
<option value="{{ __('admin::app.customers.customers.female') }}" {{ $customer->gender == __('admin::app.customers.customers.female') ? 'selected' : '' }}>{{ __('admin::app.customers.customers.female') }}</option>
<option value="{{ __('admin::app.customers.customers.other') }}" {{ $customer->gender == __('admin::app.customers.customers.other') ? 'selected' : '' }}>{{ __('admin::app.customers.customers.other') }}</option>
</select>
<span class="control-error" v-if="errors.has('gender')">@{{ errors.first('gender') }}</span>
</div>
{!! view_render_event('bagisto.admin.customer.edit.gender.after', ['customer' => $customer]) !!}
<div class="control-group">
<label for="status" class="required">{{ __('admin::app.customers.customers.status') }}</label>
<label class="switch">
<input type="checkbox" id="status" name="status" value="{{ $customer->status }}" {{ $customer->status ? 'checked' : '' }}>
<span class="slider round"></span>
</label>
<span class="control-error" v-if="errors.has('status')">@{{ errors.first('status') }}</span>
</div>
{!! view_render_event('bagisto.admin.customer.edit.status.after', ['customer' => $customer]) !!}
<div class="control-group" :class="[errors.has('date_of_birth') ? 'has-error' : '']">
<label for="dob">{{ __('admin::app.customers.customers.date_of_birth') }}</label>
<input type="date" class="control" name="date_of_birth" value="{{ old('date_of_birth') ?:$customer->date_of_birth }}" v-validate="" data-vv-as="&quot;{{ __('admin::app.customers.customers.date_of_birth') }}&quot;">
<span class="control-error" v-if="errors.has('date_of_birth')">@{{ errors.first('date_of_birth') }}</span>
</div>
{!! view_render_event('bagisto.admin.customer.edit.date_of_birth.after', ['customer' => $customer]) !!}
<div class="control-group" :class="[errors.has('phone') ? 'has-error' : '']">
<label for="phone">{{ __('admin::app.customers.customers.phone') }}</label>
<input type="text" class="control" name="phone" value="{{ $customer->phone }}" data-vv-as="&quot;{{ __('admin::app.customers.customers.phone') }}&quot;">
<span class="control-error" v-if="errors.has('phone')">@{{ errors.first('phone') }}</span>
</div>
{!! view_render_event('bagisto.admin.customer.edit.phone.after', ['customer' => $customer]) !!}
<div class="control-group">
<label for="customerGroup" >{{ __('admin::app.customers.customers.customer_group') }}</label>
@if (! is_null($customer->customer_group_id))
<?php $selectedCustomerOption = $customer->group->id ?>
@else
<?php $selectedCustomerOption = '' ?>
@endif
<select class="control" name="customer_group_id">
@foreach ($customerGroup as $group)
<option value="{{ $group->id }}" {{ $selectedCustomerOption == $group->id ? 'selected' : '' }}>
{{ $group->name}}
</option>
@endforeach
</select>
</div>
</div>
<button type="submit" class="btn btn-lg btn-primary">
{{ __('admin::app.customers.customers.save-btn-title') }}
</button>
</div>
</div>
</form>
{!! view_render_event('bagisto.admin.customer.edit.after', ['customer' => $customer]) !!}