From 1009b52531f377f0d58767d52ee6cc0172bf9568 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 2 Jul 2024 18:33:15 +1000 Subject: [PATCH 1/4] Fixes for task assigned user --- app/Jobs/Task/TaskAssigned.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Jobs/Task/TaskAssigned.php b/app/Jobs/Task/TaskAssigned.php index 63f79109a376..064363c418a0 100644 --- a/app/Jobs/Task/TaskAssigned.php +++ b/app/Jobs/Task/TaskAssigned.php @@ -47,7 +47,7 @@ class TaskAssigned implements ShouldQueue $company_user = $this->task->assignedCompanyUser(); - if($this->findEntityAssignedNotification($company_user, 'task')) + if($company_user && $this->findEntityAssignedNotification($company_user, 'task')) { $mo = new EmailObject(); $mo->subject = ctrans('texts.task_assigned_subject', ['task' => $this->task->number, 'date' => now()->setTimeZone($this->task->company->timezone()->name)->format($this->task->company->date_format()) ]); From a67de99b49eceea7a3f29a88aa9c1f1ed6beda91 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 2 Jul 2024 18:35:10 +1000 Subject: [PATCH 2/4] Fixes for task assigned user --- app/Utils/TempFile.php | 59 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/app/Utils/TempFile.php b/app/Utils/TempFile.php index 5f8409555f66..16b1dc1a932a 100644 --- a/app/Utils/TempFile.php +++ b/app/Utils/TempFile.php @@ -11,6 +11,8 @@ namespace App\Utils; +use Illuminate\Http\File; +use Illuminate\Http\UploadedFile; class TempFile { public static function path($url): string @@ -34,4 +36,61 @@ class TempFile return $file_path; } + + public static function UploadedFileFromRaw(string $fileData, string|null $fileName = null, string|null $mimeType = null): UploadedFile + { + // Create temp file and get its absolute path + $tempFile = tmpfile(); + $tempFilePath = stream_get_meta_data($tempFile)['uri']; + + // Save file data in file + file_put_contents($tempFilePath, $fileData); + + $tempFileObject = new File($tempFilePath); + $file = new UploadedFile( + $tempFileObject->getPathname(), + $fileName ?: $tempFileObject->getFilename(), + $mimeType ?: $tempFileObject->getMimeType(), + 0, + true // Mark it as test, since the file isn't from real HTTP POST. + ); + + // Close this file after response is sent. + // Closing the file will cause to remove it from temp director! + app()->terminating(function () use ($tempFile) { + fclose($tempFile); + }); + + // return UploadedFile object + return $file; + } + + /* create a tmp file from a raw string: https://gist.github.com/waska14/8b3bcebfad1f86f7fcd3b82927576e38*/ + public static function UploadedFileFromUrl(string $url, string|null $fileName = null, string|null $mimeType = null): UploadedFile + { + // Create temp file and get its absolute path + $tempFile = tmpfile(); + $tempFilePath = stream_get_meta_data($tempFile)['uri']; + + // Save file data in file + file_put_contents($tempFilePath, file_get_contents($url)); + + $tempFileObject = new File($tempFilePath); + $file = new UploadedFile( + $tempFileObject->getPathname(), + $fileName ?: $tempFileObject->getFilename(), + $mimeType ?: $tempFileObject->getMimeType(), + 0, + true // Mark it as test, since the file isn't from real HTTP POST. + ); + + // Close this file after response is sent. + // Closing the file will cause to remove it from temp director! + app()->terminating(function () use ($tempFile) { + fclose($tempFile); + }); + + // return UploadedFile object + return $file; + } } From bb159be38683139f4fd6650a66d286aa678e1bbb Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 2 Jul 2024 18:36:53 +1000 Subject: [PATCH 3/4] Minor fixes for zug docs --- app/Services/EDocument/Imports/ZugferdEDocument.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Services/EDocument/Imports/ZugferdEDocument.php b/app/Services/EDocument/Imports/ZugferdEDocument.php index f8ec7a6f7dd9..2f2384998201 100644 --- a/app/Services/EDocument/Imports/ZugferdEDocument.php +++ b/app/Services/EDocument/Imports/ZugferdEDocument.php @@ -41,6 +41,7 @@ class ZugferdEDocument extends AbstractService { */ public function run(): Expense { + /** @var \App\Models\User $user */ $user = auth()->user(); $this->document = ZugferdDocumentReader::readAndGuessFromContent($this->tempdocument); $this->document->getDocumentInformation($documentno, $documenttypecode, $documentdate, $invoiceCurrency, $taxCurrency, $documentname, $documentlanguage, $effectiveSpecifiedPeriod); @@ -102,13 +103,13 @@ class ZugferdEDocument extends AbstractService { if ($taxid != null) { $vendor->vat_number = $taxid; } - $vendor->currency_id = Currency::whereCode($invoiceCurrency)->first()->id; + $vendor->currency_id = Currency::query()->where('code', $invoiceCurrency)->first()->id; $vendor->phone = $contact_phone; $vendor->address1 = $address_1; $vendor->address2 = $address_2; $vendor->city = $city; $vendor->postal_code = $postcode; - $vendor->country_id = Country::where('iso_3166_2', $country)->first()->id; + $vendor->country_id = Country::query()->where('iso_3166_2', $country)->first()->id; $vendor->save(); $expense->vendor_id = $vendor->id; From 78ed14074dfd448b90b37b20017d7278a615715a Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 3 Jul 2024 14:06:41 +1000 Subject: [PATCH 4/4] Updates for react changer --- app/Http/Controllers/AccountController.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index fca1806e1632..fd28026b6fe8 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -115,13 +115,8 @@ class AccountController extends BaseController public function update(UpdateAccountRequest $request, Account $account) { - $fi = new \FilesystemIterator(public_path('react'), \FilesystemIterator::SKIP_DOTS); - if (iterator_count($fi) < 30) { - return response()->json(['message' => 'React App Not Installed, Please install the React app before attempting to switch.'], 400); - } - - $account->fill($request->all()); + $account->set_react_as_default_ap = $request->input('set_react_as_default_ap'); $account->save(); $this->entity_type = Account::class;