diff --git a/app/Http/Controllers/SetupController.php b/app/Http/Controllers/SetupController.php index e226751c8078..223d0943c216 100644 --- a/app/Http/Controllers/SetupController.php +++ b/app/Http/Controllers/SetupController.php @@ -212,7 +212,7 @@ class SetupController extends Controller public function checkPdf(Request $request) { try { - if (config('ninja.phantomjs_key')) { + if (config('ninja.phantomjs_pdf_generation')) { return $this->testPhantom(); } @@ -240,7 +240,7 @@ class SetupController extends Controller private function testPhantom() { try { - $key = config('ninja.phantomjs_key'); + $key = config('ninja.phantomjs_pdf_generation'); $url = 'https://www.invoiceninja.org/'; $phantom_url = "https://phantomjscloud.com/api/browser/v2/{$key}/?request=%7Burl:%22{$url}%22,renderType:%22pdf%22%7D"; diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index ff320634ea20..7291e6b8bd8d 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -466,6 +466,9 @@ class UserController extends BaseController */ public function destroy(DestroyUserRequest $request, User $user) { + if($user->isOwner()) + return response()->json(['message', 'Cannot detach owner.'],400); + /* If the user passes the company user we archive the company user */ $user = $this->user_repo->delete($request->all(), $user); @@ -603,6 +606,9 @@ class UserController extends BaseController */ public function detach(DetachCompanyUserRequest $request, User $user) { + if($user->isOwner()) + return response()->json(['message', 'Cannot detach owner.'],400); + $company_user = CompanyUser::whereUserId($user->id) ->whereCompanyId(auth()->user()->companyId())->first(); diff --git a/app/Http/Requests/RecurringInvoice/StoreRecurringInvoiceRequest.php b/app/Http/Requests/RecurringInvoice/StoreRecurringInvoiceRequest.php index 184788415ea8..c0bb5bbad037 100644 --- a/app/Http/Requests/RecurringInvoice/StoreRecurringInvoiceRequest.php +++ b/app/Http/Requests/RecurringInvoice/StoreRecurringInvoiceRequest.php @@ -17,6 +17,7 @@ use App\Models\Client; use App\Models\RecurringInvoice; use App\Utils\Traits\CleanLineItems; use App\Utils\Traits\MakesHash; +use Illuminate\Http\UploadedFile; class StoreRecurringInvoiceRequest extends Request { @@ -43,6 +44,7 @@ class StoreRecurringInvoiceRequest extends Request foreach (range(0, $documents) as $index) { $rules['documents.'.$index] = 'file|mimes:png,ai,svg,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000'; } + } elseif ($this->input('documents')) { $rules['documents'] = 'file|mimes:png,ai,svg,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000'; } @@ -62,6 +64,16 @@ class StoreRecurringInvoiceRequest extends Request { $input = $this->all(); + // foreach($this->input('documents') as $document) + // { + // if($document instanceof UploadedFile){ + // nlog("i am an uploaded file"); + // nlog($document); + // } + // else + // nlog($document); + // } + if (array_key_exists('design_id', $input) && is_string($input['design_id'])) { $input['design_id'] = $this->decodePrimaryKey($input['design_id']); } diff --git a/app/Http/Requests/RecurringInvoice/UpdateRecurringInvoiceRequest.php b/app/Http/Requests/RecurringInvoice/UpdateRecurringInvoiceRequest.php index 72258db6fa0e..6d6609534247 100644 --- a/app/Http/Requests/RecurringInvoice/UpdateRecurringInvoiceRequest.php +++ b/app/Http/Requests/RecurringInvoice/UpdateRecurringInvoiceRequest.php @@ -15,6 +15,7 @@ use App\Http\Requests\Request; use App\Utils\Traits\ChecksEntityStatus; use App\Utils\Traits\CleanLineItems; use App\Utils\Traits\MakesHash; +use Illuminate\Http\UploadedFile; class UpdateRecurringInvoiceRequest extends Request { @@ -57,6 +58,16 @@ class UpdateRecurringInvoiceRequest extends Request { $input = $this->all(); + // foreach($this->input('documents') as $document) + // { + // if($document instanceof UploadedFile){ + // nlog("i am an uploaded file"); + // nlog($document); + // } + // else + // nlog($document); + // } + if (array_key_exists('design_id', $input) && is_string($input['design_id'])) { $input['design_id'] = $this->decodePrimaryKey($input['design_id']); } diff --git a/app/Repositories/UserRepository.php b/app/Repositories/UserRepository.php index bc47a2b5bafe..7c5ce316a17d 100644 --- a/app/Repositories/UserRepository.php +++ b/app/Repositories/UserRepository.php @@ -107,6 +107,9 @@ class UserRepository extends BaseRepository public function destroy(array $data, User $user) { + if($user->isOwner()) + return $user; + if (array_key_exists('company_user', $data)) { $this->forced_includes = 'company_users'; diff --git a/app/Utils/PhantomJS/Phantom.php b/app/Utils/PhantomJS/Phantom.php index d34f24961026..4c605273227a 100644 --- a/app/Utils/PhantomJS/Phantom.php +++ b/app/Utils/PhantomJS/Phantom.php @@ -88,9 +88,11 @@ class Phantom $pdf = CurlUtils::get($phantom_url); $this->checkMime($pdf, $invitation, $entity); - + $instance = Storage::disk(config('filesystems.default'))->put($file_path, $pdf); +nlog($instance); +nlog($file_path); return $file_path; } diff --git a/config/ninja.php b/config/ninja.php index db75a9773830..a0634910d285 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -29,7 +29,7 @@ return [ 'hash_salt' => env('HASH_SALT', ''), 'currency_converter_api_key' => env('OPENEXCHANGE_APP_ID', ''), 'enabled_modules' => 32767, - 'phantomjs_key' => env('PHANTOMJS_KEY', false), + 'phantomjs_key' => env('PHANTOMJS_KEY', 'a-demo-key-with-low-quota-per-ip-address'), 'phantomjs_secret' => env('PHANTOMJS_SECRET', false), 'phantomjs_pdf_generation' => env('PHANTOMJS_PDF_GENERATION', true), 'trusted_proxies' => env('TRUSTED_PROXIES', false), diff --git a/resources/views/portal/ninja2020/layout/clean_setup.blade.php b/resources/views/portal/ninja2020/layout/clean_setup.blade.php new file mode 100644 index 000000000000..49f63c5bcd82 --- /dev/null +++ b/resources/views/portal/ninja2020/layout/clean_setup.blade.php @@ -0,0 +1,119 @@ + + + + + + + @if (config('services.analytics.tracking_id')) + + + + @else + + @endif + + + @auth() + @yield('meta_title', '') — {{ auth('contact')->user()->user->account->isPaid() ? auth('contact')->user()->company->present()->name() : 'Invoice Ninja' }} + @endauth + + @guest + @yield('meta_title', '') — {{ config('app.name') }} + @endguest + + + + + + + + + + @if(strpos(Request::url(),'setup') === false) + + @else + + @endif + + + + + + + + @if(strpos(Request::url(),'setup') === false) + + @else + + @endif + {{-- --}} + + + + {{-- Feel free to push anything to header using @push('header') --}} + @stack('head') + + + + + @include('portal.ninja2020.components.primary-color') + + + @if(session()->has('message')) +
+ {{ session('message') }} +
+ @endif + + @yield('body') + + + + + + + + diff --git a/resources/views/setup/index.blade.php b/resources/views/setup/index.blade.php index d5ba98b7a1bc..826c461bf5ff 100644 --- a/resources/views/setup/index.blade.php +++ b/resources/views/setup/index.blade.php @@ -1,4 +1,4 @@ -@extends('portal.ninja2020.layout.clean') +@extends('portal.ninja2020.layout.clean_setup') @section('meta_title', ctrans('texts.setup')) @section('body')