From a4d4b2b96c91378d3cc2a5494c7df0bdb49bea08 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Wed, 21 Feb 2018 15:49:18 +0200 Subject: [PATCH] Zip export check if gmp is here #1902 --- app/Jobs/DownloadInvoices.php | 4 ++++ app/Ninja/Reports/DocumentReport.php | 4 ++++ app/Ninja/Reports/ExpenseReport.php | 4 ++++ app/Ninja/Reports/InvoiceReport.php | 4 ++++ app/Ninja/Reports/QuoteReport.php | 4 ++++ resources/lang/en/texts.php | 1 + 6 files changed, 21 insertions(+) diff --git a/app/Jobs/DownloadInvoices.php b/app/Jobs/DownloadInvoices.php index 4c6c88adafbb..2fd37b97198f 100644 --- a/app/Jobs/DownloadInvoices.php +++ b/app/Jobs/DownloadInvoices.php @@ -46,6 +46,10 @@ class DownloadInvoices extends Job */ public function handle(UserMailer $userMailer) { + if (! extension_loaded('GMP')) { + die(trans('texts.gmp_required')); + } + $zip = Archive::instance_by_useragent(date('Y-m-d') . '_' . str_replace(' ', '_', trans('texts.invoice_pdfs'))); foreach ($this->invoices as $invoice) { diff --git a/app/Ninja/Reports/DocumentReport.php b/app/Ninja/Reports/DocumentReport.php index cbdbb426b663..bfa195034dbd 100644 --- a/app/Ninja/Reports/DocumentReport.php +++ b/app/Ninja/Reports/DocumentReport.php @@ -51,6 +51,10 @@ class DocumentReport extends AbstractReport } if ($this->isExport && $exportFormat == 'zip') { + if (! extension_loaded('GMP')) { + die(trans('texts.gmp_required')); + } + $zip = Archive::instance_by_useragent(date('Y-m-d') . '_' . str_replace(' ', '_', trans('texts.documents'))); foreach ($records as $record) { foreach ($record->documents as $document) { diff --git a/app/Ninja/Reports/ExpenseReport.php b/app/Ninja/Reports/ExpenseReport.php index 531df702cd53..85c915d8a159 100644 --- a/app/Ninja/Reports/ExpenseReport.php +++ b/app/Ninja/Reports/ExpenseReport.php @@ -49,6 +49,10 @@ class ExpenseReport extends AbstractReport ->where('expense_date', '<=', $this->endDate); if ($this->isExport && $exportFormat == 'zip') { + if (! extension_loaded('GMP')) { + die(trans('texts.gmp_required')); + } + $zip = Archive::instance_by_useragent(date('Y-m-d') . '_' . str_replace(' ', '_', trans('texts.expense_documents'))); foreach ($expenses->get() as $expense) { foreach ($expense->documents as $document) { diff --git a/app/Ninja/Reports/InvoiceReport.php b/app/Ninja/Reports/InvoiceReport.php index ca592cff563d..51be25981c2a 100644 --- a/app/Ninja/Reports/InvoiceReport.php +++ b/app/Ninja/Reports/InvoiceReport.php @@ -67,6 +67,10 @@ class InvoiceReport extends AbstractReport if ($this->isExport && $exportFormat == 'zip') { + if (! extension_loaded('GMP')) { + die(trans('texts.gmp_required')); + } + $zip = Archive::instance_by_useragent(date('Y-m-d') . '_' . str_replace(' ', '_', trans('texts.invoice_documents'))); foreach ($clients->get() as $client) { foreach ($client->invoices as $invoice) { diff --git a/app/Ninja/Reports/QuoteReport.php b/app/Ninja/Reports/QuoteReport.php index 7e96c75b4f52..fbc1e2152aaa 100644 --- a/app/Ninja/Reports/QuoteReport.php +++ b/app/Ninja/Reports/QuoteReport.php @@ -58,6 +58,10 @@ class QuoteReport extends AbstractReport }]); if ($this->isExport && $exportFormat == 'zip') { + if (! extension_loaded('GMP')) { + die(trans('texts.gmp_required')); + } + $zip = Archive::instance_by_useragent(date('Y-m-d') . '_' . str_replace(' ', '_', trans('texts.quote_documents'))); foreach ($clients->get() as $client) { foreach ($client->invoices as $invoice) { diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 289b5a81a639..c0577af74935 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -2750,6 +2750,7 @@ $LANG = array( 'email_address_changed_message' => 'The email address for your account has been changed from :old_email to :new_email.', 'test' => 'Test', 'beta' => 'Beta', + 'gmp_required' => 'Exporting to ZIP requires the GMP extension', );