mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Merge pull request #6687 from turbo124/v5-develop
Add inline download capability
This commit is contained in:
commit
f572b61d61
@ -123,7 +123,7 @@ class EmailTemplateDefaults
|
||||
|
||||
public static function emailInvoiceTemplate()
|
||||
{
|
||||
$invoice_message = '<p>'.self::transformText('invoice_message').'</p><div class="center">$view_link</div>';
|
||||
$invoice_message = '<p>'.self::transformText('invoice_message').'</p><div class="center">$view_button</div>';
|
||||
|
||||
return $invoice_message;
|
||||
}
|
||||
@ -135,7 +135,7 @@ class EmailTemplateDefaults
|
||||
|
||||
public static function emailQuoteTemplate()
|
||||
{
|
||||
$quote_message = '<p>'.self::transformText('quote_message').'</p><div class="center">$view_link</div>';
|
||||
$quote_message = '<p>'.self::transformText('quote_message').'</p><div class="center">$view_button</div>';
|
||||
|
||||
return $quote_message;
|
||||
}
|
||||
@ -147,21 +147,21 @@ class EmailTemplateDefaults
|
||||
|
||||
public static function emailPaymentTemplate()
|
||||
{
|
||||
$payment_message = '<p>'.self::transformText('payment_message').'</p><div class="center">$view_link</div>';
|
||||
$payment_message = '<p>'.self::transformText('payment_message').'</p><div class="center">$view_button</div>';
|
||||
|
||||
return $payment_message;
|
||||
}
|
||||
|
||||
public static function emailCreditTemplate()
|
||||
{
|
||||
$credit_message = '<p>'.self::transformText('credit_message').'</p><div class="center">$view_link</div>';
|
||||
$credit_message = '<p>'.self::transformText('credit_message').'</p><div class="center">$view_button</div>';
|
||||
|
||||
return $credit_message;
|
||||
}
|
||||
|
||||
public static function emailPaymentPartialTemplate()
|
||||
{
|
||||
$payment_message = '<p>'.self::transformText('payment_message').'</p><div class="center">$view_link</div>';
|
||||
$payment_message = '<p>'.self::transformText('payment_message').'</p><div class="center">$view_button</div>';
|
||||
|
||||
return $payment_message;
|
||||
}
|
||||
|
@ -589,14 +589,20 @@ class CreditController extends BaseController
|
||||
public function downloadPdf($invitation_key)
|
||||
{
|
||||
$invitation = $this->credit_repository->getInvitationByKey($invitation_key);
|
||||
// $contact = $invitation->contact;
|
||||
|
||||
$credit = $invitation->credit;
|
||||
|
||||
$file = $credit->service()->getCreditPdf($invitation);
|
||||
|
||||
$headers = ['Content-Type' => 'application/pdf'];
|
||||
|
||||
if(request()->input('inline') == 'true')
|
||||
$headers = array_merge($headers, ['Content-Disposition' => 'inline']);
|
||||
|
||||
return response()->streamDownload(function () use($file) {
|
||||
echo Storage::get($file);
|
||||
}, basename($file), ['Content-Type' => 'application/pdf']);
|
||||
}, basename($file), $headers);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -804,9 +804,15 @@ class InvoiceController extends BaseController
|
||||
|
||||
$file = $invoice->service()->getInvoicePdf($contact);
|
||||
|
||||
$headers = ['Content-Type' => 'application/pdf'];
|
||||
|
||||
if(request()->input('inline') == 'true')
|
||||
$headers = array_merge($headers, ['Content-Disposition' => 'inline']);
|
||||
|
||||
return response()->streamDownload(function () use($file) {
|
||||
echo Storage::get($file);
|
||||
}, basename($file), ['Content-Type' => 'application/pdf']);
|
||||
}, basename($file), $headers);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -740,11 +740,16 @@ class QuoteController extends BaseController
|
||||
|
||||
$file = $quote->service()->getQuotePdf($contact);
|
||||
|
||||
$headers = ['Content-Type' => 'application/pdf'];
|
||||
|
||||
if(request()->input('inline') == 'true')
|
||||
$headers = array_merge($headers, ['Content-Disposition' => 'inline']);
|
||||
|
||||
return response()->streamDownload(function () use($file) {
|
||||
echo Storage::get($file);
|
||||
}, basename($file), ['Content-Type' => 'application/pdf']);
|
||||
}, basename($file), $headers);
|
||||
|
||||
|
||||
// return response()->download($file_path, basename($file_path), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -514,7 +514,7 @@ class CompanyExport implements ShouldQueue
|
||||
$nmo->company = $company_reference;
|
||||
$nmo->settings = $this->company->settings;
|
||||
|
||||
NinjaMailerJob::dispatch($nmo);
|
||||
NinjaMailerJob::dispatch($nmo, true);
|
||||
|
||||
if(Ninja::isHosted()){
|
||||
sleep(3);
|
||||
|
@ -13,6 +13,7 @@ namespace App\Jobs\Company;
|
||||
|
||||
use App\Exceptions\ImportCompanyFailed;
|
||||
use App\Exceptions\NonExistingMigrationFile;
|
||||
use App\Factory\ClientContactFactory;
|
||||
use App\Jobs\Mail\NinjaMailerJob;
|
||||
use App\Jobs\Mail\NinjaMailerObject;
|
||||
use App\Jobs\Util\UnlinkFile;
|
||||
@ -65,14 +66,15 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use JsonMachine\JsonDecoder\ExtJsonDecoder;
|
||||
use JsonMachine\JsonMachine;
|
||||
use ZipArchive;
|
||||
use ZipStream\Option\Archive;
|
||||
use ZipStream\ZipStream;
|
||||
use JsonMachine\JsonMachine;
|
||||
use JsonMachine\JsonDecoder\ExtJsonDecoder;
|
||||
|
||||
class CompanyImport implements ShouldQueue
|
||||
{
|
||||
@ -208,7 +210,8 @@ class CompanyImport implements ShouldQueue
|
||||
|
||||
$this->preFlightChecks()
|
||||
->purgeCompanyData()
|
||||
->importData();
|
||||
->importData()
|
||||
->postImportCleanup();
|
||||
|
||||
$data = [
|
||||
'errors' => []
|
||||
@ -234,11 +237,31 @@ class CompanyImport implements ShouldQueue
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
private function postImportCleanup()
|
||||
{
|
||||
//ensure all clients have a contact
|
||||
|
||||
$this->company
|
||||
->clients()
|
||||
->whereDoesntHave('contacts')
|
||||
->cursor()
|
||||
->each(function ($client){
|
||||
|
||||
$new_contact = ClientContactFactory::create($client->company_id, $client->user_id);
|
||||
$new_contact->client_id = $client->id;
|
||||
$new_contact->contact_key = Str::random(40);
|
||||
$new_contact->is_primary = true;
|
||||
$new_contact->confirmed = true;
|
||||
$new_contact->email = ' ';
|
||||
$new_contact->save();
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private function unzipFile()
|
||||
{
|
||||
|
||||
// if(mime_content_type(Storage::path($this->file_location)) == 'text/plain')
|
||||
// return Storage::path($this->file_location);
|
||||
|
||||
$path = TempFile::filePath(Storage::disk(config('filesystems.default'))->get($this->file_location), basename($this->file_location));
|
||||
|
||||
@ -1391,13 +1414,16 @@ class CompanyImport implements ShouldQueue
|
||||
|
||||
private function sendImportMail($message){
|
||||
|
||||
App::forgetInstance('translator');
|
||||
$t = app('translator');
|
||||
$t->replace(Ninja::transformTranslations($this->company->settings));
|
||||
|
||||
$nmo = new NinjaMailerObject;
|
||||
$nmo->mailable = new CompanyImportFailure($this->company, $message);
|
||||
$nmo->company = $this->company;
|
||||
$nmo->settings = $this->company->settings;
|
||||
$nmo->to_user = $this->company->owner();
|
||||
NinjaMailerJob::dispatchNow($nmo);
|
||||
$nmo = new NinjaMailerObject;
|
||||
$nmo->mailable = new CompanyImportFailure($this->company, $message);
|
||||
$nmo->company = $this->company;
|
||||
$nmo->settings = $this->company->settings;
|
||||
$nmo->to_user = $this->company->owner();
|
||||
NinjaMailerJob::dispatchNow($nmo);
|
||||
|
||||
}
|
||||
}
|
@ -120,7 +120,7 @@ class WebhookHandler implements ShouldQueue
|
||||
SystemLog::CATEGORY_WEBHOOK,
|
||||
SystemLog::EVENT_WEBHOOK_SUCCESS,
|
||||
SystemLog::TYPE_WEBHOOK_RESPONSE,
|
||||
$this->company->clients->first(),
|
||||
$this->resolveClient(),
|
||||
$this->company
|
||||
);
|
||||
|
||||
@ -137,7 +137,7 @@ class WebhookHandler implements ShouldQueue
|
||||
SystemLog::CATEGORY_WEBHOOK,
|
||||
SystemLog::EVENT_WEBHOOK_RESPONSE,
|
||||
SystemLog::TYPE_WEBHOOK_RESPONSE,
|
||||
$this->company->clients->first(),
|
||||
$this->resolveClient(),
|
||||
$this->company,
|
||||
);
|
||||
|
||||
@ -145,6 +145,15 @@ class WebhookHandler implements ShouldQueue
|
||||
|
||||
}
|
||||
|
||||
private function resolveClient()
|
||||
{
|
||||
if($this->entity->client()->exists()){
|
||||
return $this->entity->client;
|
||||
}
|
||||
|
||||
return $this->company->clients->first();
|
||||
}
|
||||
|
||||
public function failed($exception)
|
||||
{
|
||||
nlog(print_r($exception->getMessage(), 1));
|
||||
|
@ -135,6 +135,7 @@ class PaymentEmailEngine extends BaseEmailEngine
|
||||
{
|
||||
$data = [];
|
||||
|
||||
|
||||
$data['$from'] = ['value' => '', 'label' => ctrans('texts.from')];
|
||||
$data['$to'] = ['value' => '', 'label' => ctrans('texts.to')];
|
||||
$data['$number'] = ['value' => $this->payment->number ?: ' ', 'label' => ctrans('texts.payment_number')];
|
||||
@ -227,6 +228,7 @@ class PaymentEmailEngine extends BaseEmailEngine
|
||||
$data['$company4'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company4', $this->settings->custom_value4, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'company4')];
|
||||
|
||||
$data['$view_link'] = ['value' => '<a class="button" href="'.$this->payment->getLink().'">'.ctrans('texts.view_payment').'</a>', 'label' => ctrans('texts.view_payment')];
|
||||
$data['$view_button'] = &$data['$view_link'];
|
||||
$data['$paymentLink'] = &$data['$view_link'];
|
||||
$data['$portalButton'] = ['value' => "<a href='{$this->payment->getPortalLink()}'>".ctrans('texts.login')."</a>", 'label' =>''];
|
||||
$data['$portal_url'] = &$data['$portalButton'];
|
||||
|
@ -30,7 +30,7 @@ class InvoiceObserver
|
||||
public function created(Invoice $invoice)
|
||||
{
|
||||
|
||||
$subscriptions = Webhook::where('company_id', $invoice->company->id)
|
||||
$subscriptions = Webhook::where('company_id', $invoice->company_id)
|
||||
->where('event_id', Webhook::EVENT_CREATE_INVOICE)
|
||||
->exists();
|
||||
|
||||
@ -47,7 +47,7 @@ class InvoiceObserver
|
||||
*/
|
||||
public function updated(Invoice $invoice)
|
||||
{
|
||||
$subscriptions = Webhook::where('company_id', $invoice->company->id)
|
||||
$subscriptions = Webhook::where('company_id', $invoice->company_id)
|
||||
->where('event_id', Webhook::EVENT_UPDATE_INVOICE)
|
||||
->exists();
|
||||
|
||||
@ -65,7 +65,7 @@ class InvoiceObserver
|
||||
*/
|
||||
public function deleted(Invoice $invoice)
|
||||
{
|
||||
$subscriptions = Webhook::where('company_id', $invoice->company->id)
|
||||
$subscriptions = Webhook::where('company_id', $invoice->company_id)
|
||||
->where('event_id', Webhook::EVENT_DELETE_INVOICE)
|
||||
->exists();
|
||||
|
||||
|
@ -132,6 +132,7 @@ class HtmlEngine
|
||||
$data['$view_link'] = ['value' => '<a class="button" href="'.$this->invitation->getLink().'">'.ctrans('texts.view_invoice').'</a>', 'label' => ctrans('texts.view_invoice')];
|
||||
$data['$viewLink'] = &$data['$view_link'];
|
||||
$data['$viewButton'] = &$data['$view_link'];
|
||||
$data['$view_button'] = &$data['$view_link'];
|
||||
$data['$paymentButton'] = &$data['$view_link'];
|
||||
$data['$view_url'] = ['value' => $this->invitation->getLink(), 'label' => ctrans('texts.view_invoice')];
|
||||
$data['$date'] = ['value' => $this->translateDate($this->entity->date, $this->entity->client->date_format(), $this->entity->client->locale()) ?: ' ', 'label' => ctrans('texts.invoice_date')];
|
||||
|
@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html data-report-errors="{{ $report_errors }}" data-rc="{{ $rc }}" data-build="{{ $build }}" user-agent="{{ $user_agent }}">
|
||||
<html data-report-errors="{{ $report_errors }}" data-rc="{{ $rc }}" data-user-agent="{{ $user_agent }}">
|
||||
<head>
|
||||
<!-- Source: https://github.com/invoiceninja/invoiceninja -->
|
||||
<!-- Version: {{ config('ninja.app_version') }} -->
|
||||
|
Loading…
x
Reference in New Issue
Block a user