Updated the customer document module

This commit is contained in:
Prashant Singh 2019-06-28 17:01:00 +05:30
parent 794aac2c8e
commit baf104509b
18 changed files with 892 additions and 64 deletions

View File

@ -1,18 +1,18 @@
APP_NAME=Laravel
APP_NAME=Razzo
APP_ENV=local
APP_VERSION=0.1.6
APP_KEY=
APP_KEY=base64:uHLkdcrc7RN8pzmDeJNtZrHCI6NmuCXETdocCr1ogAY=
APP_DEBUG=true
APP_URL=http://localhost
APP_URL=http://bagsaas.com
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
DB_DATABASE=bagsaas1
DB_USERNAME=root
DB_PASSWORD=12345678
BROADCAST_DRIVER=log
CACHE_DRIVER=file
@ -27,16 +27,24 @@ REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=tls
SHOP_MAIL_FROM=shop@bagsaas.com
ADMIN_MAIL_TO=admin@bagsaas.com
STRIPE_ENABLE_TESTING=
STRIPE_TEST_PUBLISHABLE_KEY=
STRIPE_TEST_SECRET_KEY=
STRIPE_LIVE_PUBLISHABLE_KEY=
STRIPE_LIVE_SECRET_KEY=
STRIPE_STATEMENT_DESCRIPTOR=
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

View File

@ -0,0 +1,10 @@
<?php
return [
[
'key' => 'account.documents',
'name' => 'customerdocument::app.admin.customers.documents',
'route' =>'customer.documents.index',
'sort' => 6
]
];

View File

@ -2,11 +2,18 @@
return [
[
'key' => 'account.documents',
'key' => 'documents',
'name' => 'customerdocument::app.admin.customers.documents',
'route' =>'customer.documents.index',
'sort' => 6
]
'route' => 'admin.documents.index',
'sort' => 6,
'icon-class' => 'sales-icon',
], [
'key' => 'documents.files',
'name' => 'customerdocument::app.admin.documents.b2b-files',
'route' => 'admin.documents.index',
'sort' => 1,
'icon-class' => '',
],
];
?>

View File

@ -0,0 +1,91 @@
<?php
namespace Webkul\CustomerDocument\DataGrids;
use Webkul\Ui\DataGrid\DataGrid;
use DB;
/**
* CustomerDocumentDataGrid class
*
* @author Rahul Shukla <rahulshukla.symfony517@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class CustomerDocumentDataGrid extends DataGrid
{
protected $index = 'id'; //the column that needs to be treated as index column
protected $sortOrder = 'desc'; //asc or desc
protected $itemsPerPage = 10;
public function prepareQueryBuilder()
{
$queryBuilder = DB::table('customer_documents')
->addSelect('id', 'name', 'status', 'type');
$this->setQueryBuilder($queryBuilder);
}
public function addColumns()
{
$this->addColumn([
'index' => 'id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
'sortable' => true,
'filterable' => true
]);
$this->addColumn([
'index' => 'name',
'label' => trans('admin::app.datagrid.name'),
'type' => 'string',
'searchable' => true,
'sortable' => true,
'filterable' => true
]);
$this->addColumn([
'index' => 'status',
'label' => trans('admin::app.datagrid.status'),
'type' => 'string',
'searchable' => true,
'sortable' => true,
'filterable' => true,
'wrapper' => function($value) {
if ($value->status == 1)
return 'Active';
else
return 'Inactive';
}
]);
$this->addColumn([
'index' => 'type',
'label' => trans('admin::app.datagrid.type'),
'type' => 'string',
'searchable' => false,
'sortable' => true,
'filterable' => true
]);
}
public function prepareActions() {
$this->addAction([
'type' => 'Edit',
'method' => 'GET',
'route' => 'admin.documents.edit',
'icon' => 'icon pencil-lg-icon'
]);
$this->addAction([
'type' => 'Delete',
'method' => 'POST', // use GET request only for redirect purposes
'route' => 'admin.documents.delete',
'confirm_text' => trans('ui::app.datagrid.massaction.delete', ['resource' => 'product']),
'icon' => 'icon trash-icon'
]);
}
}

View File

@ -17,9 +17,10 @@ class CustomerDocumentsTable extends Migration
$table->increments('id');
$table->string('name');
$table->text('description')->nullable();
$table->boolean('status')->default(1);
$table->string('type');
$table->string('path');
$table->integer('customer_id')->unsigned();
$table->foreign('customer_id')->references('id')->on('customers')->onDelete('cascade');
$table->integer('customer_id')->default(0);
$table->timestamps();
});
}

View File

@ -0,0 +1,280 @@
<?php
namespace Webkul\CustomerDocument\Http\Controllers\Admin;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Webkul\CustomerDocument\Repositories\CustomerDocumentRepository;
use Webkul\CustomerDocument\Http\Controllers\Controller;
use Illuminate\Support\Facades\Storage;
/**
* Document controlller
*
* @author Rahul Shukla <rahulshukla.symfony517@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class DocumentController extends Controller
{
/**
* Contains route related configuration
*
* @var array
*/
protected $_config;
/**
* CustomerDocumentRepository object
*
* @var array
*/
protected $customerDocument;
/**
* Create a new controller instance.
*
* @param \Webkul\Customer\Repositories\CustomerDocumentRepository $customerDocument
*/
public function __construct(CustomerDocumentRepository $customerDocument)
{
$this->_config = request('_config');
$this->customerDocument = $customerDocument;
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return view($this->_config['view']);
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
return view($this->_config['view']);
}
/**
* Store a newly created resource in storage.
*
* @return \Illuminate\Http\Response
*/
public function store()
{
$excludedExtensions = core()->getConfigData('customer.settings.documents.allowed_extensions');
$maxSize = core()->getConfigData('customer.settings.documents.size');
if ($excludedExtensions != '') {
$valid_extension = explode(',', $excludedExtensions);
} else {
$valid_extension = [];
}
$originalSize = filesize(request()->file('file')) / 1000;
if ($maxSize != null) {
$maxSize = (float) $maxSize * 1000;
} else {
$maxSize = 5 * 1024;
}
if (! ($originalSize <= $maxSize) || $originalSize == 0) {
session()->flash('error', trans('customerdocument::app.admin.customers.size-error'));
return redirect()->back();
}
if (! empty($valid_extension) && (! in_array(request()->file('file')->getClientOriginalExtension(), $valid_extension))) {
session()->flash('error', trans('customerdocument::app.admin.customers.upload-error'));
return redirect()->back();
} else {
try {
$data = request()->all();
if (request()->hasFile('file')) {
$dir = 'customer';
$document['path'] = request()->file('file')->store($dir);
}
if (isset($data['customer_id'])) {
$document['customer_id'] = $data['customer_id'];
} else {
$document['customer_id'] = 0;
}
if (isset($data['status'])) {
$document['status'] = $data['status'];
} else {
$document['status'] = 1;
}
$document['name'] = $data['name'];
$document['description'] = $data['description'];
$document['type'] = $data['type'];
$this->customerDocument->create($document);
session()->flash('success', trans('customerdocument::app.admin.customers.upload-success'));
if (isset($data['customer_id'])) {
return redirect()->back();
}
return redirect()->route($this->_config['redirect']);
} catch (\Exception $e) {
session()->flash('error', $e);
return redirect()->back();
}
}
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
$document = $this->customerDocument->findOrFail($id);
return view($this->_config['view'], compact('document'));
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
$excludedExtensions = core()->getConfigData('customer.settings.documents.allowed_extensions');
$maxSize = core()->getConfigData('customer.settings.documents.size');
if ($excludedExtensions != '') {
$valid_extension = explode(',', $excludedExtensions);
} else {
$valid_extension = [];
}
$originalSize = filesize(request()->file('file')) / 1000;
if ($maxSize != null) {
$maxSize = (float) $maxSize * 1000;
} else {
$maxSize = 5 * 1024;
}
if (! ($originalSize <= $maxSize)) {
session()->flash('error', trans('customerdocument::app.admin.customers.size-error'));
return redirect()->back();
}
if (! empty($valid_extension) && (! in_array(request()->file('file')->getClientOriginalExtension(), $valid_extension))) {
session()->flash('error', trans('customerdocument::app.admin.customers.upload-error'));
return redirect()->back();
} else {
try {
$data = request()->all();
$uploaDocument = $this->customerDocument->findOrfail($id);
if (request()->hasFile('file')) {
$dir = 'customer';
$document['path'] = request()->file('file')->store($dir);
Storage::delete($uploaDocument['path']);
}
$document['name'] = $data['name'];
$document['description'] = $data['description'];
$document['type'] = $data['type'];
$document['status'] = $data['status'];
$this->customerDocument->update($document, $id);
session()->flash('success', trans('customerdocument::app.admin.customers.upload-success'));
return redirect()->route($this->_config['redirect']);
} catch (\Exception $e) {
session()->flash('error', $e);
return redirect()->back();
}
}
}
/**
* Remove the specified resource from storage..
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$document = $this->customerDocument->findOrfail($id);
try {
$this->customerDocument->delete($id);
Storage::delete($document['path']);
session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Document']));
return response()->json(['message' => true], 200);
} catch (\Exception $e) {
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Document']));
}
return response()->json(['message' => false], 400);
}
/**
* download the file for the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function download($id)
{
$document = $this->customerDocument->findOrfail($id);
$extension = explode('.', $document['path']);
$name = $document['name'].'.'.end($extension);
return Storage::download($document['path'], $name);
}
/**
* Remove the specified resource from storage..
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function delete($id)
{
$document = $this->customerDocument->findOrfail($id);
$this->customerDocument->delete($id);
Storage::delete($document['path']);
session()->flash('success', trans('customerdocument::app.admin.customers.delete-success'));
return redirect()->back();
}
}

View File

@ -0,0 +1,83 @@
<?php
namespace Webkul\CustomerDocument\Http\Controllers\Shop;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Webkul\CustomerDocument\Repositories\CustomerDocumentRepository;
use Webkul\CustomerDocument\Http\Controllers\Controller;
use Illuminate\Support\Facades\Storage;
/**
* Document controlller
*
* @author Rahul Shukla <rahulshukla.symfony517@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class DocumentController extends Controller
{
/**
* Contains route related configuration
*
* @var array
*/
protected $_config;
/**
* CustomerDocumentRepository object
*
* @var array
*/
protected $customerDocument;
/**
* Create a new controller instance.
*
* @param \Webkul\Customer\Repositories\CustomerDocumentRepository $customerDocument
*/
public function __construct(CustomerDocumentRepository $customerDocument)
{
$this->_config = request('_config');
$this->customerDocument = $customerDocument;
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$documents = $this->customerDocument->getDocuments(auth()->guard('customer')->user()->id);
$productDocument = $marketingDocument = [];
foreach($documents as $document) {
if ($document->type == 'marketing') {
$marketingDocument[] = $document;
} else if ($document->type == 'product') {
$productDocument[] = $document;
}
}
return view($this->_config['view'], compact('productDocument', 'marketingDocument'));
}
/**
* download the file for the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function download($id)
{
$document = $this->customerDocument->findOrfail($id);
$extension = explode('.', $document['path']);
$name = $document['name'].'.'.end($extension);
return Storage::download($document['path'], $name);
}
}

View File

@ -7,18 +7,33 @@ Route::group(['middleware' => ['web']], function () {
Route::group(['middleware' => ['admin']], function () {
//document Management Routes
Route::post('upload-document', 'Webkul\CustomerDocument\Http\Controllers\DocumentController@upload')->defaults('_config', [
'redirect' => 'admin.customer.index'
])->name('admin.customer.document.upload');
Route::get('documents', 'Webkul\CustomerDocument\Http\Controllers\Admin\DocumentController@index')->defaults('_config',[
'view' => 'customerdocument::admin.documents.index'
])->name('admin.documents.index');
Route::get('download-document/{id}', 'Webkul\CustomerDocument\Http\Controllers\DocumentController@download')->defaults('_config', [
'redirect' => 'admin.customer.index'
])->name('admin.customer.document.download');
Route::get('documents/create', 'Webkul\CustomerDocument\Http\Controllers\Admin\DocumentController@create')->defaults('_config',[
'view' => 'customerdocument::admin.documents.create'
])->name('admin.documents.create');
Route::get('delete-document/{id}', 'Webkul\CustomerDocument\Http\Controllers\DocumentController@delete')->defaults('_config', [
'redirect' => 'admin.customer.index'
])->name('admin.customer.document.delete');
Route::post('documents/create', 'Webkul\CustomerDocument\Http\Controllers\Admin\DocumentController@store')->defaults('_config',[
'redirect' => 'admin.documents.index'
])->name('admin.documents.store');
Route::get('documents/edit/{id}', 'Webkul\CustomerDocument\Http\Controllers\Admin\DocumentController@edit')->defaults('_config',[
'view' => 'customerdocument::admin.documents.edit'
])->name('admin.documents.edit');
Route::put('documents/edit/{id}', 'Webkul\CustomerDocument\Http\Controllers\Admin\DocumentController@update')->defaults('_config',[
'redirect' => 'admin.documents.index'
])->name('admin.documents.update');
Route::post('documents/delete/{id}', 'Webkul\CustomerDocument\Http\Controllers\Admin\DocumentController@destroy')->name('admin.documents.delete');
Route::get('download-document/{id}', 'Webkul\CustomerDocument\Http\Controllers\Admin\DocumentController@download')->defaults('_config', [
'view' => 'customerdocument::admin.documents.edit'
])->name('admin.documents.download');
Route::get('customer-documents/delete/{id}', 'Webkul\CustomerDocument\Http\Controllers\Admin\DocumentController@delete')->name('admin.customer.documents.delete');
});
});

View File

@ -8,11 +8,11 @@ Route::group(['middleware' => ['web', 'locale', 'theme', 'currency']], function
Route::prefix('account')->group(function () {
Route::get('documents', 'Webkul\CustomerDocument\Http\Controllers\DocumentController@index')->defaults('_config', [
Route::get('documents', 'Webkul\CustomerDocument\Http\Controllers\Shop\DocumentController@index')->defaults('_config', [
'view' => 'customerdocument::shop.customers.document'
])->name('customer.documents.index');
Route::get('download-document/{id}', 'Webkul\CustomerDocument\Http\Controllers\DocumentController@download')->defaults('_config', [
Route::get('download-document/{id}', 'Webkul\CustomerDocument\Http\Controllers\Shop\DocumentController@download')->defaults('_config', [
'redirect' => 'admin.customer.index'
])->name('customer.document.download');
});

View File

@ -9,5 +9,5 @@ class CustomerDocument extends Model implements CustomerDocumentContract
{
protected $table = 'customer_documents';
protected $fillable = ['name', 'path', 'customer_id', 'description'];
protected $fillable = ['name', 'path', 'customer_id', 'description', 'type', 'status'];
}

View File

@ -47,7 +47,11 @@ class CustomerDocumentServiceProvider extends ServiceProvider
protected function registerConfig()
{
$this->mergeConfigFrom(
dirname(__DIR__) . '/Config/menu.php', 'menu.customer'
dirname(__DIR__) . '/Config/menu.php', 'menu.admin'
);
$this->mergeConfigFrom(
dirname(__DIR__) . '/Config/customer-menu.php', 'menu.customer'
);
$this->mergeConfigFrom(

View File

@ -17,9 +17,23 @@ class CustomerDocumentRepository extends Repository
*
* @return mixed
*/
function model()
{
return 'Webkul\CustomerDocument\Contracts\CustomerDocument';
}
/**
* get All Documents
*
* @param int $id
* @return array
*/
function getDocuments($id)
{
return $this->model
->whereIn('customer_id', [$id, 0])
->where('status', '1')
->get();
}
}

View File

@ -21,5 +21,20 @@ return [
'size' => 'Max Size Allowed (MB)',
'any-type' => 'All file types are allowed'
],
'documents' => [
'title' => 'Documents',
'add-document' => 'Add Document',
'b2b-files' => 'B2B Files',
'save-document' => 'Save Document',
'type' => 'Type',
'status' => 'Status',
'active' => 'Active',
'in-active' => 'Inacvtive',
'product' => 'Product',
'marketing' => 'Marketing',
'add-document' => 'Add Document',
'edit-document' => 'Edit Document'
],
],
];

View File

@ -2,7 +2,7 @@
$customerDocumentRepository = app('Webkul\CustomerDocument\Repositories\CustomerDocumentRepository');
$documents = $customerDocumentRepository->findWhere(['customer_id' => $customer->id]);
$documents = $customerDocumentRepository->findWhere(['customer_id' => $customer->id, 'status' => 1]);
?>
@ -18,6 +18,7 @@ $documents = $customerDocumentRepository->findWhere(['customer_id' => $customer-
<thead>
<tr>
<th>{{ __('customerdocument::app.admin.customers.name') }}</th>
<th>{{ __('customerdocument::app.admin.documents.type') }}</th>
<th>{{ __('customerdocument::app.admin.customers.description') }}</th>
<th>{{ __('customerdocument::app.admin.customers.download') }}</th>
<th></th>
@ -28,14 +29,15 @@ $documents = $customerDocumentRepository->findWhere(['customer_id' => $customer-
@foreach ($documents as $document)
<tr>
<td>{{ $document->name }}</td>
<td>{{ $document->type }}</td>
<td>{{ $document->description }}</td>
<td>
<a href="{{ route('admin.customer.document.download', $document->id) }}">
<a href="{{ route('admin.documents.download', $document->id) }}">
<i class="icon sort-down-icon"></i>
</a>
</td>
<td class="actions">
<a href="{{ route('admin.customer.document.delete', $document->id) }}">
<a href="{{ route('admin.customer.documents.delete', $document->id) }}">
<i class="icon trash-icon"></i>
</a>
</td>
@ -52,7 +54,7 @@ $documents = $customerDocumentRepository->findWhere(['customer_id' => $customer-
<h3 slot="header">{{ __('customerdocument::app.admin.customers.add-document') }}</h3>
<div slot="body">
<form method="POST" action="{{ route('admin.customer.document.upload') }}" enctype="multipart/form-data" @submit.prevent="onSubmit">
<form method="POST" action="{{ route('admin.documents.store') }}" enctype="multipart/form-data" @submit.prevent="onSubmit">
@csrf()
<input type="hidden" name="customer_id" value="{{ $customer->id }}">
@ -63,6 +65,15 @@ $documents = $customerDocumentRepository->findWhere(['customer_id' => $customer-
<span class="control-error" v-if="errors.has('name')">@{{ errors.first('name') }}</span>
</div>
<div class="control-group" :class="[errors.has('type') ? 'has-error' : '']">
<label for="type" class="required">{{ __('customerdocument::app.admin.documents.type') }}</label>
<select name="type" class="control" v-validate="'required'" data-vv-as="&quot;{{ __('customerdocument::app.admin.documents.type') }}&quot;">
<option value="product">{{ __('customerdocument::app.admin.documents.product') }}</option>
<option value="marketing">{{ __('customerdocument::app.admin.documents.marketing') }}</option>
</select>
<span class="control-error" v-if="errors.has('type')">@{{ errors.first('type') }}</span>
</div>
<div class="control-group" :class="[errors.has('description') ? 'has-error' : '']">
<label for="description">{{ __('customerdocument::app.admin.customers.description') }}</label>

View File

@ -0,0 +1,97 @@
@extends('admin::layouts.content')
@section('page_title')
{{ __('customerdocument::app.admin.documents.add-document') }}
@stop
@section('content')
<div class="content">
<form method="POST" action="{{ route('admin.documents.store') }}" @submit.prevent="onSubmit" enctype="multipart/form-data">
<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>
{{ __('customerdocument::app.admin.documents.add-document') }}
</h1>
</div>
<div class="page-action">
<button type="submit" class="btn btn-lg btn-primary">
{{ __('customerdocument::app.admin.documents.save-document') }}
</button>
</div>
</div>
<div class="page-content">
<div class="form-container">
@csrf()
<div class="control-group" :class="[errors.has('name') ? 'has-error' : '']">
<label for="name" class="required">{{ __('customerdocument::app.admin.customers.name') }}</label>
<input v-validate="'required'" type="text" class="control" id="name" name="name" data-vv-as="&quot;{{ __('customerdocument::app.admin.customers.name') }}&quot;" value="{{ old('name') }}"/>
<span class="control-error" v-if="errors.has('name')">@{{ errors.first('name') }}</span>
</div>
<div class="control-group" :class="[errors.has('type') ? 'has-error' : '']">
<label for="type" class="required">{{ __('customerdocument::app.admin.documents.type') }}</label>
<select name="type" class="control" v-validate="'required'" data-vv-as="&quot;{{ __('customerdocument::app.admin.documents.type') }}&quot;">
<option value="product">{{ __('customerdocument::app.admin.documents.product') }}</option>
<option value="marketing">{{ __('customerdocument::app.admin.documents.marketing') }}</option>
</select>
<span class="control-error" v-if="errors.has('type')">@{{ errors.first('type') }}</span>
</div>
<div class="control-group" :class="[errors.has('status') ? 'has-error' : '']">
<label for="status" class="required">{{ __('customerdocument::app.admin.documents.status') }}</label>
<select name="status" class="control" v-validate="'required'" data-vv-as="&quot;{{ __('customerdocument::app.admin.documents.status') }}&quot;">
<option value="1">{{ __('customerdocument::app.admin.documents.active') }}</option>
<option value="0">{{ __('customerdocument::app.admin.documents.in-active') }}</option>
</select>
<span class="control-error" v-if="errors.has('status')">@{{ errors.first('status') }}</span>
</div>
<div class="control-group" :class="[errors.has('description') ? 'has-error' : '']">
<label for="description">{{ __('customerdocument::app.admin.customers.description') }}</label>
<textarea class="control" id="description" name="description" data-vv-as="&quot;{{ __('customerdocument::app.admin.customers.description') }}&quot;" value="{{ old('description') }}"/
></textarea>
<span class="control-error" v-if="errors.has('description')">@{{ errors.first('description') }}</span>
</div>
<div class="control-group" :class="[errors.has('file') ? 'has-error' : '']">
<label for="file" class="required">{{ __
('customerdocument::app.admin.customers.file') }}</label>
<input v-validate="'required'" type="file" class="control" id="file" name="file" data-vv-as="&quot;{{ __('customerdocument::app.admin.customers.file') }}&quot;" value="{{ old('file') }}" style="padding-top: 5px">
@php
$allowedTypes = core()->getConfigData('customer.settings.documents.allowed_extensions');
@endphp
<div>
<span>{{ __('customerdocument::app.admin.customers.allowed-types-one') }}</span>
<span>
<b>
@if ($allowedTypes != null)
{{ $allowedTypes }}
@else
{{ __('customerdocument::app.admin.customers.any-type') }}
@endif
</b>
</span>
</div>
<span class="control-error" v-if="errors.has('file')">@{{ errors.first('file') }}</span>
</div>
</div>
</div>
</form>
</div>
@stop

View File

@ -0,0 +1,105 @@
@extends('admin::layouts.content')
@section('page_title')
{{ __('customerdocument::app.admin.documents.edit-document') }}
@stop
@section('content')
<div class="content">
<form method="POST" action="{{ route('admin.documents.update', $document->id) }}" @submit.prevent="onSubmit" enctype="multipart/form-data">
<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>
{{ __('customerdocument::app.admin.documents.edit-document') }}
</h1>
</div>
<div class="page-action">
<button type="submit" class="btn btn-lg btn-primary">
{{ __('customerdocument::app.admin.documents.save-document') }}
</button>
</div>
</div>
<div class="page-content">
<div class="form-container">
@csrf()
<input name="_method" type="hidden" value="PUT">
<div class="control-group" :class="[errors.has('name') ? 'has-error' : '']">
<label for="name" class="required">{{ __('customerdocument::app.admin.customers.name') }}</label>
<input v-validate="'required'" type="text" class="control" id="name" name="name" value="{{ $document->name }}" data-vv-as="&quot;{{ __('customerdocument::app.admin.customers.name') }}&quot;"/>
<span class="control-error" v-if="errors.has('name')">@{{ errors.first('name') }}</span>
</div>
<div class="control-group" :class="[errors.has('type') ? 'has-error' : '']">
<label for="type" class="required">{{ __('customerdocument::app.admin.documents.type') }}</label>
<select name="type" class="control" v-validate="'required'" value="{{ $document->type }}" data-vv-as="&quot;{{ __('customerdocument::app.admin.documents.type') }}&quot;">
<option value="product" {{ $document->type == "product" ? 'selected' : '' }}>{{ __('customerdocument::app.admin.documents.product') }}</option>
<option value="marketing" {{ $document->type == "marketing" ? 'selected' : '' }}>{{ __('customerdocument::app.admin.documents.marketing') }}</option>
</select>
<span class="control-error" v-if="errors.has('type')">@{{ errors.first('type') }}</span>
</div>
<div class="control-group" :class="[errors.has('status') ? 'has-error' : '']">
<label for="status" class="required">{{ __('customerdocument::app.admin.documents.status') }}</label>
<select name="status" class="control" value="{{ $document->status }}" v-validate="'required'" data-vv-as="&quot;{{ __('customerdocument::app.admin.documents.status') }}&quot;">
<option value="1" {{ $document->status == "1" ? 'selected' : '' }}>{{ __('customerdocument::app.admin.documents.active') }}</option>
<option value="0" {{ $document->status == "0" ? 'selected' : '' }}>{{ __('customerdocument::app.admin.documents.in-active') }}</option>
</select>
<span class="control-error" v-if="errors.has('status')">@{{ errors.first('status') }}</span>
</div>
<div class="control-group" :class="[errors.has('description') ? 'has-error' : '']">
<label for="description">{{ __('customerdocument::app.admin.customers.description') }}</label>
<textarea class="control" id="description" name="description" data-vv-as="&quot;{{ __('customerdocument::app.admin.customers.description') }}&quot;"/
>
{{ $document->description }}
</textarea>
<span class="control-error" v-if="errors.has('description')">@{{ errors.first('description') }}</span>
</div>
<div class="control-group" :class="[errors.has('file') ? 'has-error' : '']">
<label for="file" class="required">{{ __
('customerdocument::app.admin.customers.file') }}</label>
<a href="{{ route('admin.documents.download', $document->id) }}">
<i class="icon sort-down-icon download"></i>
</a>
<input type="file" class="control" id="file" name="file" data-vv-as="&quot;{{ __('customerdocument::app.admin.customers.file') }}&quot;" value="{{ old('file') }}" style="padding-top: 5px">
@php
$allowedTypes = core()->getConfigData('customer.settings.documents.allowed_extensions');
@endphp
<div>
<span>{{ __('customerdocument::app.admin.customers.allowed-types-one') }}</span>
<span>
<b>
@if ($allowedTypes != null)
{{ $allowedTypes }}
@else
{{ __('customerdocument::app.admin.customers.any-type') }}
@endif
</b>
</span>
</div>
<span class="control-error" v-if="errors.has('file')">@{{ errors.first('file') }}</span>
</div>
</div>
</div>
</form>
</div>
@stop

View File

@ -0,0 +1,29 @@
@extends('admin::layouts.content')
@section('page_title')
{{ __('customerdocument::app.admin.documents.title') }}
@stop
@section('content')
<div class="content">
<div class="page-header">
<div class="page-title">
<h1>{{ __('customerdocument::app.admin.documents.title') }}</h1>
</div>
<div class="page-action">
<a href="{{ route('admin.documents.create') }}" class="btn btn-lg btn-primary">
{{ __('customerdocument::app.admin.documents.add-document') }}
</a>
</div>
</div>
<div class="page-content">
@inject('customerDocumentGrid','Webkul\CustomerDocument\DataGrids\CustomerDocumentDataGrid')
{!! $customerDocumentGrid->render() !!}
</div>
</div>
@stop

View File

@ -7,6 +7,7 @@
@section('content-wrapper')
<div class="account-content">
@include('shop::customers.account.partials.sidemenu')
<div class="account-layout">
@ -17,41 +18,98 @@
<div class="horizontal-rule"></div>
</div>
<div class="account-items-list">
@if ($documents->count())
<div class="table" style="margin-bottom: 20px;">
<table>
<thead>
<tr>
<th>{{ __('customerdocument::app.admin.customers.name') }}</th>
<th>{{ __('customerdocument::app.admin.customers.description') }}</th>
<th>{{ __('customerdocument::app.admin.customers.download') }}</th>
<th></th>
</tr>
</thead>
<div class="sale-container">
<tbody>
@foreach ($documents as $document)
<tr>
<td>{{ $document->name }}</td>
<td>{{ $document->description }}</td>
<td>
<a href="{{ route('customer.document.download', $document->id) }}">
<i class="icon sort-down-icon"></i>
</a>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@else
<tabs>
@if (! empty($productDocument))
<tab name="{{ __('customerdocument::app.admin.documents.product') }}" :selected="true">
<div class="account-items-list" style="display: none;">
<div class="table" style="margin-bottom: 20px;">
<table>
<thead>
<tr>
<th>{{ __('customerdocument::app.admin.customers.name') }}</th>
<th>{{ __('customerdocument::app.admin.customers.description') }}</th>
<th>{{ __('customerdocument::app.admin.customers.download') }}</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach ($productDocument as $document)
<tr>
<td>{{ $document->name }}</td>
<td>{{ $document->description }}</td>
<td>
<a href="{{ route('customer.document.download', $document->id) }}">
<i class="icon sort-down-icon"></i>
</a>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</tab>
@endif
@if (! empty($productDocument))
<tab name="{{ __('customerdocument::app.admin.documents.marketing') }}">
<div class="account-items-list" style="display: none;">
<div class="table" style="margin-bottom: 20px;">
<table>
<thead>
<tr>
<th>{{ __('customerdocument::app.admin.customers.name') }}</th>
<th>{{ __('customerdocument::app.admin.customers.description') }}</th>
<th>{{ __('customerdocument::app.admin.customers.download') }}</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach ($marketingDocument as $document)
<tr>
<td>{{ $document->name }}</td>
<td>{{ $document->description }}</td>
<td>
<a href="{{ route('customer.document.download', $document->id) }}">
<i class="icon sort-down-icon"></i>
</a>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</tab>
@endif
</tabs>
@if (empty($productDocument) && empty($productDocument))
<div class="empty">
{{ __('customerdocument::app.admin.customers.empty') }}
</div>
@endif
</div>
</div>
</div>
@endsection
@endsection
@push('scripts')
<script>
$(document).ready(function() {
$('.account-items-list').css('display','block');
});
</script>
@endpush