1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Fixes for vendor documents

This commit is contained in:
David Bomba 2022-07-27 16:09:25 +10:00
parent 2942dfa528
commit 6df802509b
3 changed files with 125 additions and 4 deletions

View File

@ -27,6 +27,8 @@ class DocumentController extends Controller
{
use MakesHash;
public const MODULE_PURCHASE_ORDERS = 16384;
/**
* @return Factory|View
*/
@ -42,12 +44,34 @@ class DocumentController extends Controller
*/
public function show(ShowDocumentRequest $request, Document $document)
{
return render('documents.show', [
return render('documents.vendor_show', [
'document' => $document,
'settings' => auth()->guard('vendor')->user()->company->settings
'settings' => auth()->guard('vendor')->user()->company->settings,
'sidebar' => $this->sidebarMenu(),
'company' => auth()->guard('vendor')->user()->company,
]);
}
private function sidebarMenu() :array
{
$enabled_modules = auth()->guard('vendor')->user()->company->enabled_modules;
$data = [];
// TODO: Enable dashboard once it's completed.
// $this->settings->enable_client_portal_dashboard
// $data[] = [ 'title' => ctrans('texts.dashboard'), 'url' => 'client.dashboard', 'icon' => 'activity'];
if (self::MODULE_PURCHASE_ORDERS & $enabled_modules) {
$data[] = ['title' => ctrans('texts.purchase_orders'), 'url' => 'vendor.purchase_orders.index', 'icon' => 'file-text'];
}
// $data[] = ['title' => ctrans('texts.documents'), 'url' => 'client.documents.index', 'icon' => 'download'];
return $data;
}
public function download(ShowDocumentRequest $request, Document $document)
{
return Storage::disk($document->disk)->download($document->url, $document->name);

View File

@ -0,0 +1,95 @@
@extends('portal.ninja2020.layout.vendor_app')
@section('meta_title', ctrans('texts.document'))
@section('body')
<div class="container mx-auto">
<div class="grid grid-cols-12">
<div class="col-span-12 lg:col-span-7 lg:col-start-3">
<div class="bg-white shadow overflow-hidden sm:rounded-lg">
<div class="px-4 py-5 border-b border-gray-200 sm:px-6">
<h3 class="text-lg leading-6 font-medium text-gray-900">
{{ ctrans('texts.document') }}
</h3>
<p class="mt-1 max-w-2xl text-sm leading-5 text-gray-500">
{{ ctrans('texts.document_details') }}
</p>
</div>
<div>
<dl>
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
<dt class="text-sm leading-5 font-medium text-gray-500">
{{ ctrans('texts.name') }}
</dt>
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2 flex items-center">
{{ Illuminate\Support\Str::limit($document->name, 40) }}
</dd>
</div>
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
<dt class="text-sm leading-5 font-medium text-gray-500">
{{ ctrans('texts.type') }}
</dt>
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
{{ App\Models\Document::$types[$document->type]['mime'] }}
</dd>
</div>
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
<dt class="text-sm leading-5 font-medium text-gray-500">
{{ ctrans('texts.hash') }}
</dt>
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
{{ $document->hash }}
</dd>
</div>
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
<dt class="text-sm leading-5 font-medium text-gray-500">
{{ ctrans('texts.size') }}
</dt>
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
{{ $document->size / 1000 }} kB
</dd>
</div>
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
<dt class="text-sm leading-5 font-medium text-gray-500">
{{ ctrans('texts.width') }}
</dt>
<div class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
{{ $document->width }}px
</div>
</div>
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
<dt class="text-sm leading-5 font-medium text-gray-500">
{{ ctrans('texts.height') }}
</dt>
<div class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
{{ $document->height }}px
</div>
</div>
</dl>
</div>
</div>
<div class="flex justify-end my-4">
<a href="{{ route('vendor.documents.download', $document->hashed_id) }}" class="button button-link bg-link text-gray-900 inline-flex items-center" download>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-download-cloud">
<polyline points="8 17 12 21 16 17"></polyline>
<line x1="12" y1="12" x2="12" y2="21"></line>
<path d="M20.88 18.09A5 5 0 0 0 18 9h-1.26A8 8 0 1 0 3 16.29"></path>
</svg>
<span class="ml-2">{{ ctrans('texts.download') }}</span>
</a>
<a href="{{ $document->generateUrl() }}" target="_blank" class="button button-primary bg-primary text-white inline-flex items-center">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather">
<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path>
<polyline points="15 3 21 3 21 9"></polyline>
<line x1="10" y1="14" x2="21" y2="3"></line>
</svg>
<span class="ml-2">{{ ctrans('texts.open_in_new_tab') }}</span>
</a>
</div>
</div>
</div>
</div>
@endsection

View File

@ -10,7 +10,6 @@
|
*/
use App\Http\Controllers\Auth\VendorContactLoginController;
use App\Http\Controllers\VendorPortal\DocumentController;
use App\Http\Controllers\VendorPortal\InvitationController;
use App\Http\Controllers\VendorPortal\PurchaseOrderController;
use App\Http\Controllers\VendorPortal\UploadController;
@ -42,7 +41,10 @@ Route::group(['middleware' => ['auth:vendor', 'vendor_locale', 'domain_db'], 'pr
Route::post('purchase_orders/bulk', [PurchaseOrderController::class, 'bulk'])->name('purchase_orders.bulk');
Route::get('logout', [VendorContactLoginController::class, 'logout'])->name('logout');
Route::post('purchase_order/upload/{purchase_order}', [UploadController::class,'upload'])->name('upload.store');
Route::resource('documents', DocumentController::class)->only(['index', 'show']);
Route::post('documents/download_multiple', [App\Http\Controllers\VendorPortal\DocumentController::class, 'downloadMultiple'])->name('documents.download_multiple');
Route::get('documents/{document}/download', [App\Http\Controllers\VendorPortal\DocumentController::class, 'download'])->name('documents.download');
Route::resource('documents', App\Http\Controllers\VendorPortal\DocumentController::class)->only(['index', 'show']);
});