diff --git a/app/Http/Controllers/EstimatesController.php b/app/Http/Controllers/EstimatesController.php index ef84d541..39a69c1c 100644 --- a/app/Http/Controllers/EstimatesController.php +++ b/app/Http/Controllers/EstimatesController.php @@ -306,8 +306,6 @@ class EstimatesController extends Controller public function sendEstimate(Request $request) { $estimate = Estimate::findOrFail($request->id); - $estimate->status = Estimate::STATUS_SENT; - $estimate->save(); $data['estimate'] = $estimate->toArray(); $userId = $data['estimate']['user_id']; @@ -330,6 +328,11 @@ class EstimatesController extends Controller ]); } + if ($estimate->status == Estimate::STATUS_DRAFT) { + $estimate->status = Estimate::STATUS_SENT; + $estimate->save(); + } + \Mail::to($email)->send(new EstimatePdf($data, $notificationEmail)); return response()->json([ diff --git a/app/Http/Controllers/InvoicesController.php b/app/Http/Controllers/InvoicesController.php index 7eaebb7b..a91df038 100644 --- a/app/Http/Controllers/InvoicesController.php +++ b/app/Http/Controllers/InvoicesController.php @@ -371,12 +371,6 @@ class InvoicesController extends Controller { $invoice = Invoice::findOrFail($request->id); - if ($invoice->status == Invoice::STATUS_DRAFT) { - $invoice->status = Invoice::STATUS_SENT; - $invoice->sent = true; - $invoice->save(); - } - $data['invoice'] = $invoice->toArray(); $userId = $data['invoice']['user_id']; $data['user'] = User::find($userId)->toArray(); @@ -398,6 +392,12 @@ class InvoicesController extends Controller ]); } + if ($invoice->status == Invoice::STATUS_DRAFT) { + $invoice->status = Invoice::STATUS_SENT; + $invoice->sent = true; + $invoice->save(); + } + \Mail::to($email)->send(new invoicePdf($data, $notificationEmail)); return response()->json([ diff --git a/app/Http/Controllers/UpdateController.php b/app/Http/Controllers/UpdateController.php index 2b1049d9..736fac56 100644 --- a/app/Http/Controllers/UpdateController.php +++ b/app/Http/Controllers/UpdateController.php @@ -12,7 +12,7 @@ class UpdateController extends Controller { set_time_limit(600); // 10 minutes - $json = Updater::update($request->installed, $request->version); + $json = Updater::update($request->installed, $request->version, $request->isMinor); return response()->json($json); } diff --git a/app/Listeners/Updates/Listener.php b/app/Listeners/Updates/Listener.php index 6dab62a8..f0aa524d 100644 --- a/app/Listeners/Updates/Listener.php +++ b/app/Listeners/Updates/Listener.php @@ -15,9 +15,9 @@ class Listener protected function check($event) { // Do not apply to the same or newer versions - // if (version_compare($event->old, static::VERSION, '>=')) { - // return false; - // } + if (version_compare($event->old, static::VERSION, '>=')) { + return false; + } return true; } diff --git a/app/Listeners/Updates/V10/Version101.php b/app/Listeners/Updates/V10/Version101.php index 03de4a34..ff6fe22f 100644 --- a/app/Listeners/Updates/V10/Version101.php +++ b/app/Listeners/Updates/V10/Version101.php @@ -21,12 +21,12 @@ class Version101 extends Listener */ public function handle(UpdateFinished $event) { - // if (!$this->check($event)) { - // return; - // } + if (!$this->check($event)) { + return; + } Artisan::call('db:seed', ['--class' => 'DemoSeeder', '--force' => true]); - Setting::getSetting('version', self::VERSION); + Setting::setSetting('version', self::VERSION); } } diff --git a/app/Space/Updater.php b/app/Space/Updater.php index b5d8b369..6dd0b165 100644 --- a/app/Space/Updater.php +++ b/app/Space/Updater.php @@ -13,12 +13,12 @@ class Updater { use SiteApi; - public static function update($installed, $version) + public static function update($installed, $version, $isMinor) { $data = null; $path = null; - $url = '/download/'.$version; + $url = '/download/'.$version.'?type=update'; $response = static::getRemote($url, ['timeout' => 100, 'track_redirects' => true]); @@ -40,8 +40,8 @@ class Updater // Create temp directory $path = 'temp-' . md5(mt_rand()); $path2 = 'temp2-' . md5(mt_rand()); - $temp_path = storage_path('app/temp') . '/' . $path; - $temp_path2 = storage_path('app/temp') . '/' . $path2; + $temp_path = storage_path('app') . '/' . $path; + $temp_path2 = storage_path('app') . '/' . $path2; if (!File::isDirectory($temp_path)) { File::makeDirectory($temp_path); @@ -78,7 +78,9 @@ class Updater File::deleteDirectory($temp_path2); try { - event(new UpdateFinished($installed, $version)); + if (!$isMinor) { + event(new UpdateFinished($installed, $version)); + } return [ 'success' => true, diff --git a/resources/assets/js/plugins/en.js b/resources/assets/js/plugins/en.js index 64b09749..6bd34c4d 100644 --- a/resources/assets/js/plugins/en.js +++ b/resources/assets/js/plugins/en.js @@ -668,8 +668,13 @@ export default { }, update_app: { title: 'Update App', - description: 'update app description', - update: 'Update' + description: 'You can easily update Crater by checking for a new update by clicking the button below', + check_update: 'Check for updates', + avail_update: 'New Update available', + next_version: 'Next version', + update: 'Update', + update_progress: 'Update in progress...', + progress_text: 'It will just take a few minutes. Please do not refresh the screen or close the window before the update finishes' } }, wizard: { diff --git a/resources/assets/js/views/settings/UpdateApp.vue b/resources/assets/js/views/settings/UpdateApp.vue index 4c3183d2..787d066d 100644 --- a/resources/assets/js/views/settings/UpdateApp.vue +++ b/resources/assets/js/views/settings/UpdateApp.vue @@ -6,50 +6,89 @@

{{ $t('settings.update_app.description') }}

- - {{ $t('settings.update_app.update') }} +
+ + + + {{ $t('settings.update_app.check_update') }} -
-
+
+
+

{{ $t('settings.update_app.avail_update') }}

+
+ +

+ {{ description }} +

+ + {{ $t('settings.update_app.update') }} +
+
+ + diff --git a/resources/assets/sass/pages/settings.scss b/resources/assets/sass/pages/settings.scss index e6ece508..3e451271 100644 --- a/resources/assets/sass/pages/settings.scss +++ b/resources/assets/sass/pages/settings.scss @@ -150,6 +150,15 @@ overflow: hidden; } } + + .version { + background: #EAF1FB; + border: 1px solid #EAF1FB; + box-sizing: border-box; + border-radius: 5px; + padding: 10px; + margin-bottom: 15px; + } } @media(max-width: $x-small-breakpoint ) {