1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00
This commit is contained in:
= 2020-08-22 09:32:24 +10:00
commit 8bfb778d86
18 changed files with 178 additions and 14 deletions

View File

@ -70,6 +70,31 @@ class DemoMode extends Command
{
set_time_limit(0);
$cached_tables = config('ninja.cached_tables');
foreach ($cached_tables as $name => $class) {
if (! Cache::has($name)) {
// check that the table exists in case the migration is pending
if (! Schema::hasTable((new $class())->getTable())) {
continue;
}
if ($name == 'payment_terms') {
$orderBy = 'num_days';
} elseif ($name == 'fonts') {
$orderBy = 'sort_order';
} elseif (in_array($name, ['currencies', 'industries', 'languages', 'countries', 'banks'])) {
$orderBy = 'name';
} else {
$orderBy = 'id';
}
$tableData = $class::orderBy($orderBy)->get();
if ($tableData->count()) {
Cache::forever($name, $tableData);
}
}
}
$this->info("Migrating");
Artisan::call('migrate:fresh --force');
@ -257,7 +282,7 @@ class DemoMode extends Command
'company_id' => $company->id
]);
factory(\App\Models\ClientContact::class, 1)->create([
factory(\App\Models\ClientContact::class)->create([
'user_id' => $user->id,
'client_id' => $client->id,
'company_id' => $company->id,
@ -301,7 +326,7 @@ class DemoMode extends Command
]);
factory(\App\Models\VendorContact::class, 1)->create([
factory(\App\Models\VendorContact::class)->create([
'user_id' => $client->user->id,
'vendor_id' => $vendor->id,
'company_id' => $client->company_id,

View File

@ -151,7 +151,14 @@ class EmailTemplateDefaults
public static function emailPaymentTemplate()
{
return Parsedown::instance()->line(self::transformText('payment_message'));
$converter = new CommonMarkConverter([
'html_input' => 'strip',
'allow_unsafe_links' => false,
]);
return $converter->convertToHtml(self::transformText('payment_message'));
// return Parsedown::instance()->line(self::transformText('payment_message'));
}
public static function emailReminder1Subject()

View File

@ -13,10 +13,14 @@
namespace App\Http\Controllers\ClientPortal;
use App\Http\Controllers\Controller;
use App\Http\Requests\Document\DownloadMultipleDocumentsRequest;
use App\Http\Requests\Document\ShowDocumentRequest;
use App\Models\Document;
use App\Utils\TempFile;
use App\Utils\Traits\MakesHash;
use Illuminate\Support\Facades\Storage;
use ZipStream\Option\Archive;
use ZipStream\ZipStream;
class DownloadController extends Controller
{
@ -43,10 +47,30 @@ class DownloadController extends Controller
/**
* @param \App\Http\Requests\Document\ShowDocumentRequest $request
* @param \App\Models\Document $download
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
* @param bool $bulk
* @return mixed
*/
public function download(ShowDocumentRequest $request, Document $download)
{
return Storage::disk($download->disk)->download($download->url, $download->name);
}
public function downloadMultiple(DownloadMultipleDocumentsRequest $request)
{
$documents = Document::whereIn('id', $this->transformKeys($request->file_hash))
->where('company_id', auth('contact')->user()->company->id)
->get();
$options = new Archive();
$options->setSendHttpHeaders(true);
$zip = new ZipStream('files.zip', $options);
foreach ($documents as $document) {
$zip->addFileFromPath(basename($document->filePath()), TempFile::path($document->filePath()));
}
$zip->finish();
}
}

View File

@ -1,5 +1,15 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Http\Controllers\ClientPortal;
use App\Http\Controllers\Controller;

View File

@ -0,0 +1,40 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Http\Requests\Document;
use Illuminate\Foundation\Http\FormRequest;
class DownloadMultipleDocumentsRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return auth()->user()->can('view', $this->document);
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'file_hash' => ['required'],
];
}
}

View File

@ -22,8 +22,7 @@ class ShowDocumentRequest extends Request
*/
public function authorize() : bool
{
return true;
// return auth()->user()->can('view', $this->document);
return auth()->user()->can('view', $this->document);
}
/**

View File

@ -123,4 +123,9 @@ class Document extends BaseModel
{
Storage::disk($this->disk)->delete($this->url);
}
public function filePath()
{
return Storage::disk($this->disk)->url($this->url);
}
}

View File

@ -122,8 +122,8 @@ class HtmlEngine
$data['$number'] = ['value' => $this->entity->number ?: '&nbsp;', 'label' => ctrans('texts.invoice_number')];
$data['$entity.terms'] = ['value' => $this->entity->terms ?: '&nbsp;', 'label' => ctrans('texts.invoice_terms')];
$data['$terms'] = &$data['$entity.terms'];
// $data['$view_link'] = ['value' => '<a href="' .$this->invitation->getLink() .'">'. ctrans('texts.view_invoice').'</a>', 'label' => ctrans('texts.view_invoice')];
$data['$view_link'] = ['value' => $this->invitation->getLink(), 'label' => ctrans('texts.view_invoice')];
$data['$view_link'] = ['value' => '<a href="' .$this->invitation->getLink() .'">'. ctrans('texts.view_invoice').'</a>', 'label' => ctrans('texts.view_invoice')];
// $data['$view_link'] = ['value' => $this->invitation->getLink(), 'label' => ctrans('texts.view_invoice')];
}
@ -132,8 +132,8 @@ class HtmlEngine
$data['$number'] = ['value' => $this->entity->number ?: '&nbsp;', 'label' => ctrans('texts.quote_number')];
$data['$entity.terms'] = ['value' => $this->entity->terms ?: '&nbsp;', 'label' => ctrans('texts.quote_terms')];
$data['$terms'] = &$data['$entity.terms'];
// $data['$view_link'] = ['value' => '<a href="' .$this->invitation->getLink() .'">'. ctrans('texts.view_quote').'</a>', 'label' => ctrans('texts.view_quote')];
$data['$view_link'] = ['value' => $this->invitation->getLink(), 'label' => ctrans('texts.view_quote')];
$data['$view_link'] = ['value' => '<a href="' .$this->invitation->getLink() .'">'. ctrans('texts.view_quote').'</a>', 'label' => ctrans('texts.view_quote')];
// $data['$view_link'] = ['value' => $this->invitation->getLink(), 'label' => ctrans('texts.view_quote')];
}
if ($this->entity_string == 'credit') {
@ -141,8 +141,8 @@ class HtmlEngine
$data['$number'] = ['value' => $this->entity->number ?: '&nbsp;', 'label' => ctrans('texts.credit_number')];
$data['$entity.terms'] = ['value' => $this->entity->terms ?: '&nbsp;', 'label' => ctrans('texts.credit_terms')];
$data['$terms'] = &$data['$entity.terms'];
// $data['$view_link'] = ['value' => '<a href="' .$this->invitation->getLink() .'">'. ctrans('texts.view_credit').'</a>', 'label' => ctrans('texts.view_credit')];
$data['$view_link'] = ['value' => $this->invitation->getLink(), 'label' => ctrans('texts.view_credit')];
$data['$view_link'] = ['value' => '<a href="' .$this->invitation->getLink() .'">'. ctrans('texts.view_credit').'</a>', 'label' => ctrans('texts.view_credit')];
// $data['$view_link'] = ['value' => $this->invitation->getLink(), 'label' => ctrans('texts.view_credit')];
}
$data['$entity_number'] = &$data['$number'];

View File

@ -24,6 +24,7 @@ class AddIsPublicToDocumentsTable extends Migration
Schema::table('company_gateways', function (Blueprint $table) {
$table->enum('token_billing', ['off', 'always','optin','optout'])->default('off');
$table->string('label', 255)->nullable();
});
}

View File

@ -0,0 +1 @@
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=16)}({16:function(e,t,n){e.exports=n("W54t")},W54t:function(e,t){window.appendToElement=function(e,t){var n=document.getElementById(e),r=n.querySelector('input[value="'.concat(t,'"]'));if(r)return r.remove();var o=document.createElement("INPUT");o.setAttribute("name","file_hash[]"),o.setAttribute("value",t),o.hidden=!0,n.append(o)}}});

View File

@ -14,6 +14,7 @@
"/js/clients/payments/sofort.js": "/js/clients/payments/sofort.js?id=ff4ad07a93bd9fb327c1",
"/js/clients/quotes/action-selectors.js": "/js/clients/quotes/action-selectors.js?id=b6b33ab51b58b51e1212",
"/js/clients/quotes/approve.js": "/js/clients/quotes/approve.js?id=1c5d76fb5f98bd49f6c8",
"/js/clients/shared/multiple-downloads.js": "/js/clients/shared/multiple-downloads.js?id=bf87649ca30c9a3fba59",
"/js/clients/shared/pdf.js": "/js/clients/shared/pdf.js?id=86f3b8d82f809268b3de",
"/js/setup/setup.js": "/js/setup/setup.js?id=c4cd098778bf824a3470",
"/css/card-js.min.css": "/css/card-js.min.css?id=62afeb675235451543ad"

View File

@ -0,0 +1,29 @@
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
const appendToElement = (parent, value) => {
let _parent = document.getElementById(parent);
let _possibleElement = _parent.querySelector(`input[value="${value}"]`);
if (_possibleElement) {
return _possibleElement.remove();
}
let _temp = document.createElement('INPUT');
_temp.setAttribute('name', 'file_hash[]');
_temp.setAttribute('value', value);
_temp.hidden = true;
_parent.append(_temp);
};
window.appendToElement = appendToElement;

View File

@ -3261,5 +3261,7 @@ return [
'allowed_file_types' => 'Allowed file types:',
'common_codes' => 'Common codes and their meanings',
'payment_error_code_20087' => '20087: Bad Track Data (invalid CVV and/or expiry date)',
'payment_error_code_20087' => '20087: Bad Track Data (invalid CVV and/or expiry date)',
'download_selected' => 'Download selected',
];

View File

@ -8,6 +8,12 @@
<option>15</option>
<option>20</option>
</select>
<button x-on:click="document.getElementById('multiple-downloads').submit()" class="button button-primary py-2 ml-2">
<span class="hidden md:block">
{{ ctrans('texts.download_selected') }}
</span>
<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">
@ -25,6 +31,7 @@
<table class="min-w-full shadow rounded border border-gray-200 mt-4 credits-table">
<thead>
<tr>
<th class="px-6 py-3 border-b border-gray-200 bg-gray-50 text-left text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider" />
<th class="px-6 py-3 border-b border-gray-200 bg-gray-50 text-left text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider">
<span role="button" wire:click="sortBy('name')" class="cursor-pointer">
{{ ctrans('texts.name') }}
@ -54,6 +61,9 @@
<tbody>
@forelse($downloads as $download)
<tr class="bg-white group hover:bg-gray-100">
<td class="px-6 py-4 whitespace-no-wrap text-sm leading-5 text-gray-500">
<input type="checkbox" class="form-checkbox cursor-pointer" onchange="appendToElement('multiple-downloads', '{{ $download->hashed_id }}')" />
</td>
<td class="px-6 py-4 whitespace-no-wrap text-sm leading-5 text-gray-500">
{{ Illuminate\Support\Str::limit($download->name, 20) }}
</td>

View File

@ -5,8 +5,13 @@
@if($client->getSetting('client_portal_enable_uploads'))
@component('portal.ninja2020.upload.index') @endcomponent
@endif
<script src="{{ asset('js/clients/shared/multiple-downloads.js') }}"></script>
@endsection
@section('body')
<form action="{{ route('client.downloads.multiple') }}" method="post" id="multiple-downloads">
@csrf
</form>
@livewire('downloads-table')
@endsection

View File

@ -2,7 +2,7 @@
<script src="{{ asset('vendor/dropzone-5.7.0/dist/min/dropzone.min.js') }}"></script>
<div class="bg-white rounded shadow p-4 mb-10">
<span class="text-sm mb-4 block text-gray-500">{{ ctrans('texts.allowed_file_types' )}} png,ai,svg,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx</span>
<span class="text-sm mb-4 block text-gray-500 break-words">{{ ctrans('texts.allowed_file_types' )}} png, ai, svg, jpeg, tiff, pdf, gif, psd, txt, doc, xls, ppt, xlsx, docx, pptx</span>
<form action="{{ route('client.upload.store') }}" class="dropzone" method="post" enctype="multipart/form-data">
@csrf
<div class="fallback">

View File

@ -60,6 +60,7 @@ Route::group(['middleware' => ['auth:contact','locale'], 'prefix' => 'client', '
Route::get('client/switch_company/{contact}', 'ClientPortal\SwitchCompanyController')->name('switch_company');
Route::post('downloads/multiple', 'ClientPortal\DownloadController@downloadMultiple')->name('downloads.multiple');
Route::get('downloads/{download}/download', 'ClientPortal\DownloadController@download')->name('downloads.download');
Route::resource('downloads', 'ClientPortal\DownloadController')->only(['index', 'show']);

4
webpack.mix.js vendored
View File

@ -61,6 +61,10 @@ mix.js("resources/js/app.js", "public/js")
.js(
"resources/js/clients/shared/pdf.js",
"public/js/clients/shared/pdf.js"
)
.js(
"resources/js/clients/shared/multiple-downloads.js",
"public/js/clients/shared/multiple-downloads.js"
);
mix.copyDirectory('node_modules/card-js/card-js.min.css', 'public/css/card-js.min.css');