mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
wip
This commit is contained in:
parent
ce97a0d32e
commit
aacc3b6602
@ -76,10 +76,10 @@ class DocumentController extends Controller
|
||||
|
||||
$options->setSendHttpHeaders(true);
|
||||
|
||||
$zip = new ZipStream('files.zip', $options);
|
||||
$zip = new ZipStream(now() . '-documents.zip', $options);
|
||||
|
||||
foreach ($documents as $document) {
|
||||
$zip->addFileFromPath(basename($document->filePath()), TempFile::path($document->filePath()));
|
||||
$zip->addFileFromPath(basename($document->diskPath()), TempFile::path($document->diskPath()));
|
||||
}
|
||||
|
||||
$zip->finish();
|
||||
|
@ -25,38 +25,15 @@ class DocumentsTable extends Component
|
||||
|
||||
public $per_page = 10;
|
||||
|
||||
public $status = [
|
||||
'resources',
|
||||
];
|
||||
|
||||
public function mount($client)
|
||||
{
|
||||
$this->client = $client;
|
||||
}
|
||||
|
||||
public function statusChange($status)
|
||||
{
|
||||
if (in_array($status, $this->status)) {
|
||||
return $this->status = array_diff($this->status, [$status]);
|
||||
}
|
||||
|
||||
array_push($this->status, $status);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$query = $this->client->documents();
|
||||
|
||||
if (in_array('resources', $this->status) && ! in_array('client', $this->status)) {
|
||||
$query = $query->where('documentable_type', '!=', Client::class);
|
||||
}
|
||||
|
||||
if (in_array('client', $this->status) && ! in_array('resources', $this->status)) {
|
||||
$query = $query->where('documentable_type', Client::class);
|
||||
}
|
||||
|
||||
$query = $query
|
||||
->where('is_public', true)
|
||||
$query = $this->client
|
||||
->documents()
|
||||
->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc')
|
||||
->paginate($this->per_page);
|
||||
|
||||
|
@ -27,7 +27,8 @@ class ShowDocumentRequest extends FormRequest
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return auth()->user('contact')->client->id == $this->document->documentable_id;
|
||||
return auth()->user('contact')->client->id == $this->document->documentable_id
|
||||
|| $this->document->documentable->client_id == auth()->user('contact')->client->id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -131,4 +131,9 @@ class Document extends BaseModel
|
||||
{
|
||||
return Storage::disk($this->disk)->url($this->url);
|
||||
}
|
||||
|
||||
public function diskPath(): string
|
||||
{
|
||||
return Storage::disk($this->disk)->path($this->url);
|
||||
}
|
||||
}
|
||||
|
2
public/css/app.css
vendored
2
public/css/app.css
vendored
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
||||
{
|
||||
"/js/app.js": "/js/app.js?id=1ee684e58f9f6eb754d5",
|
||||
"/css/app.css": "/css/app.css?id=599b11149976e86c83a3",
|
||||
"/css/app.css": "/css/app.css?id=57bdc19c89dc8191d03c",
|
||||
"/js/clients/invoices/action-selectors.js": "/js/clients/invoices/action-selectors.js?id=a09bb529b8e1826f13b4",
|
||||
"/js/clients/invoices/payment.js": "/js/clients/invoices/payment.js?id=8ce8955ba775ea5f47d1",
|
||||
"/js/clients/payment_methods/authorize-authorize-card.js": "/js/clients/payment_methods/authorize-authorize-card.js?id=206d7de4ac97612980ff",
|
||||
|
@ -15,16 +15,6 @@
|
||||
<svg class="md:hidden" 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"><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>
|
||||
</button>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
<div class="mr-3">
|
||||
<input wire:click="statusChange('resources')" type="checkbox" class="form-checkbox cursor-pointer" id="resources-checkbox" checked>
|
||||
<label for="resources-checkbox" class="text-sm cursor-pointer">{{ ctrans('texts.resources') }}</label>
|
||||
</div>
|
||||
<div class="mr-3">
|
||||
<input wire:click="statusChange('client')" type="checkbox" class="form-checkbox cursor-pointer" id="client-checkbox">
|
||||
<label for="client-checkbox" class="text-sm cursor-pointer">{{ ctrans('texts.client') }}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="-my-2 py-2 overflow-x-auto sm:-mx-6 sm:px-6 lg:-mx-8 lg:px-8">
|
||||
<div class="align-middle inline-block min-w-full overflow-hidden rounded">
|
||||
@ -106,4 +96,4 @@
|
||||
@endif
|
||||
{{ $documents->links('portal/ninja2020/vendor/pagination') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -13,5 +13,6 @@
|
||||
<form action="{{ route('client.documents.download_multiple') }}" method="post" id="multiple-downloads">
|
||||
@csrf
|
||||
</form>
|
||||
|
||||
@livewire('documents-table', ['client' => $client])
|
||||
@endsection
|
||||
@endsection
|
||||
|
@ -43,7 +43,7 @@
|
||||
</div>
|
||||
</form>
|
||||
@else
|
||||
<div class="bg-white shadow sm:rounded-lg mb-4" translate>
|
||||
<div class="bg-white shadow sm:rounded-lg mb-4">
|
||||
<div class="px-4 py-5 sm:p-6">
|
||||
<div class="sm:flex sm:items-start sm:justify-between">
|
||||
<div>
|
||||
@ -57,7 +57,37 @@
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="flex items-center justify-between">
|
||||
@if($invoice->documents->count() > 0)
|
||||
<div class="bg-white shadow sm:rounded-lg mb-4">
|
||||
<div class="px-4 py-5 sm:p-6">
|
||||
<div class="sm:flex sm:items-start sm:justify-between">
|
||||
<div>
|
||||
<p class="text-lg leading-6 font-medium text-gray-900">{{ ctrans('texts.attachments') }}:</p>
|
||||
@foreach($invoice->documents as $document)
|
||||
<div class="inline-flex items-center space-x-1">
|
||||
<a href="{{ route('client.documents.show', $document->hashed_id) }}" target="_blank"
|
||||
class="block text-sm button-link text-primary">{{ Illuminate\Support\Str::limit($document->name, 40) }}</a>
|
||||
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"
|
||||
fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
|
||||
stroke-linejoin="round" class="text-primary h-6 w-4">
|
||||
<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>
|
||||
|
||||
@if(!$loop->last)
|
||||
<span>—</span>
|
||||
@endif
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="flex items-center justify-between mt-4">
|
||||
<section class="flex items-center">
|
||||
<div class="items-center" style="display: none" id="pagination-button-container">
|
||||
<button class="input-label focus:outline-none hover:text-blue-600 transition ease-in-out duration-300" id="previous-page-button" title="Previous page">
|
||||
|
Loading…
x
Reference in New Issue
Block a user