From ae16eb66e581307d4299deb908c5f57080e5e124 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 17 Mar 2022 13:20:58 +1100 Subject: [PATCH 1/3] Fixes for documents --- app/Http/Controllers/DocumentController.php | 3 +-- app/Repositories/DocumentRepository.php | 21 ++++++++++++------- .../components/general/sidebar/main.blade.php | 4 ++-- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/app/Http/Controllers/DocumentController.php b/app/Http/Controllers/DocumentController.php index cf673fcbe7..dd785fca7f 100644 --- a/app/Http/Controllers/DocumentController.php +++ b/app/Http/Controllers/DocumentController.php @@ -189,12 +189,11 @@ class DocumentController extends BaseController */ $documents->each(function ($document, $key) use ($action) { if (auth()->user()->can('edit', $document)) { - $this->{$action}($document); + $this->document_repo->{$action}($document); } }); /* Need to understand which permission are required for the given bulk action ie. view / edit */ - return $this->listResponse(Document::withTrashed()->whereIn('id', $this->transformKeys($ids))->company()); } } diff --git a/app/Repositories/DocumentRepository.php b/app/Repositories/DocumentRepository.php index 25a381853b..9c85d9c5a1 100644 --- a/app/Repositories/DocumentRepository.php +++ b/app/Repositories/DocumentRepository.php @@ -19,6 +19,7 @@ use App\Utils\Ninja; */ class DocumentRepository extends BaseRepository { + public function delete($document) { $document->deleteFile(); @@ -27,14 +28,18 @@ class DocumentRepository extends BaseRepository public function restore($document) { - if (! $document->trashed()) { - return; - } - - $document->restore(); - - // if (class_exists($className)) { - // event(new $className($document, $document->company, Ninja::eventVars())); + return; + // if (! $document->trashed()) { + // return; // } + + // $document->restore(); + } + + public function archive($document) + { + return; + } + } diff --git a/resources/views/portal/ninja2020/components/general/sidebar/main.blade.php b/resources/views/portal/ninja2020/components/general/sidebar/main.blade.php index 7182395724..8044253e01 100644 --- a/resources/views/portal/ninja2020/components/general/sidebar/main.blade.php +++ b/resources/views/portal/ninja2020/components/general/sidebar/main.blade.php @@ -4,7 +4,7 @@ @keydown.window.escape="sidebarOpen = false" id="main-sidebar"> - @if($settings->enable_client_portal) + @if($settings && $settings->enable_client_portal) @include('portal.ninja2020.components.general.sidebar.mobile') @@ -15,7 +15,7 @@ @endif
- @if($settings->enable_client_portal) + @if($settings && $settings->enable_client_portal) @include('portal.ninja2020.components.general.sidebar.header') @endif From 4900946fa1b430c1ab9a5f81edd78764320c34b5 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 17 Mar 2022 13:41:46 +1100 Subject: [PATCH 2/3] do no auto convert quote if converted by admin user --- app/Http/Controllers/QuoteController.php | 2 +- app/Repositories/TaskRepository.php | 4 ++++ app/Services/Quote/QuoteService.php | 9 +++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/QuoteController.php b/app/Http/Controllers/QuoteController.php index 9d06d20860..7bd39ed643 100644 --- a/app/Http/Controllers/QuoteController.php +++ b/app/Http/Controllers/QuoteController.php @@ -676,7 +676,7 @@ class QuoteController extends BaseController return response()->json(['message' => ctrans('texts.quote_unapprovable')], 400); } - return $this->itemResponse($quote->service()->approve()->save()); + return $this->itemResponse($quote->service()->approveWithNoCoversion()->save()); break; case 'history': // code... diff --git a/app/Repositories/TaskRepository.php b/app/Repositories/TaskRepository.php index 2dc14e4acf..518a70a979 100644 --- a/app/Repositories/TaskRepository.php +++ b/app/Repositories/TaskRepository.php @@ -185,6 +185,10 @@ class TaskRepository extends BaseRepository public function start(Task $task) { + //do no allow an task to be restarted if it has been invoiced + if($task->invoice_id) + return; + if(strlen($task->time_log) < 5) { $log = []; diff --git a/app/Services/Quote/QuoteService.php b/app/Services/Quote/QuoteService.php index 77b134103a..960fce39fe 100644 --- a/app/Services/Quote/QuoteService.php +++ b/app/Services/Quote/QuoteService.php @@ -126,6 +126,15 @@ class QuoteService return $this; } + + public function approveWithNoCoversion($contact = null) :self + { + $this->setStatus(Quote::STATUS_APPROVED)->save(); + + return $this; + } + + public function convertToInvoice() { From cf3140f03250219552630522d67cd60949b4cff7 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 17 Mar 2022 15:48:50 +1100 Subject: [PATCH 3/3] Minor fixes for quote approvals --- VERSION.txt | 2 +- app/Services/Quote/QuoteService.php | 6 ++++++ config/ninja.php | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index 6d00630e87..b2c42b050e 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.3.69 \ No newline at end of file +5.3.70 \ No newline at end of file diff --git a/app/Services/Quote/QuoteService.php b/app/Services/Quote/QuoteService.php index 960fce39fe..f04eb84447 100644 --- a/app/Services/Quote/QuoteService.php +++ b/app/Services/Quote/QuoteService.php @@ -131,6 +131,12 @@ class QuoteService { $this->setStatus(Quote::STATUS_APPROVED)->save(); + if (!$contact) { + $contact = $this->quote->invitations->first()->contact; + } + + event(new QuoteWasApproved($contact, $this->quote, $this->quote->company, Ninja::eventVars())); + return $this; } diff --git a/config/ninja.php b/config/ninja.php index c611199a95..cc95a2475b 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -14,8 +14,8 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', 'invoicing.co'), - 'app_version' => '5.3.69', - 'app_tag' => '5.3.69', + 'app_version' => '5.3.70', + 'app_tag' => '5.3.70', 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', ''),