Working on PDF generator flags

This commit is contained in:
David Bomba 2021-05-09 21:30:31 +10:00
parent a9f93a2796
commit 87ddad6670
8 changed files with 16 additions and 12 deletions

View File

@ -51,11 +51,13 @@ TRUSTED_PROXIES=
NINJA_ENVIRONMENT=selfhost
PHANTOMJS_PDF_GENERATION=true
#options - snappdf / phantom / hosted_ninja
PDF_GENERATOR=phantom
PHANTOMJS_KEY='a-demo-key-with-low-quota-per-ip-address'
PHANTOMJS_SECRET=secret
UPDATE_SECRET=
UPDATE_SECRET=secret
COMPOSER_AUTH='{"github-oauth": {"github.com": "${{ secrets.GITHUB_TOKEN }}"}}'
SENTRY_LARAVEL_DSN=https://cc7e8e2c678041689e53e409b7dba236@sentry.invoicing.co/5

View File

@ -141,10 +141,10 @@ class ActivityController extends BaseController
return response()->json(['message'=> ctrans('texts.no_backup_exists'), 'errors' => new stdClass], 404);
}
if (config('ninja.phantomjs_pdf_generation')) {
if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') {
$pdf = (new Phantom)->convertHtmlToPdf($backup->html_backup);
}
elseif(config('ninja.invoiceninja_hosted_pdf_generation')){
elseif(config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja'){
$pdf = (new NinjaPdf())->build($backup->html_backup);
}
else {

View File

@ -131,11 +131,11 @@ class PreviewController extends BaseController
}
//if phantom js...... inject here..
if (config('ninja.phantomjs_pdf_generation')) {
if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') {
return (new Phantom)->convertHtmlToPdf($maker->getCompiledHTML(true));
}
if(config('ninja.invoiceninja_hosted_pdf_generation')){
if(config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja'){
return (new NinjaPdf())->build($maker->getCompiledHTML(true));
}

View File

@ -105,7 +105,7 @@ class CreateEntityPdf implements ShouldQueue
$this->entity->service()->deletePdf();
if (config('ninja.phantomjs_pdf_generation')) {
if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') {
return (new Phantom)->generate($this->invitation);
}
@ -171,7 +171,7 @@ class CreateEntityPdf implements ShouldQueue
try {
if(config('ninja.invoiceninja_hosted_pdf_generation')){
if(config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja'){
$pdf = (new NinjaPdf())->build($maker->getCompiledHTML(true));
}
else {

View File

@ -60,7 +60,7 @@ class GenerateDeliveryNote
$file_path = sprintf('%s%s_delivery_note.pdf', $this->invoice->client->invoice_filepath(), $this->invoice->number);
if (config('ninja.phantomjs_pdf_generation')) {
if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') {
return (new Phantom)->generate($this->invoice->invitations->first());
}
@ -92,7 +92,7 @@ class GenerateDeliveryNote
// Storage::makeDirectory($this->invoice->client->invoice_filepath(), 0775);
if(config('ninja.invoiceninja_hosted_pdf_generation')){
if(config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja'){
$pdf = (new NinjaPdf())->build($maker->getCompiledHTML(true));
}
else {

View File

@ -17,6 +17,7 @@ use Exception;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Queue;
/**
* Class SystemHealth.
@ -80,6 +81,7 @@ class SystemHealth
'open_basedir' => (bool)self::checkOpenBaseDir(),
'mail_mailer' => (string)self::checkMailMailer(),
'flutter_renderer' => (string)config('ninja.flutter_canvas_kit'),
'jobs_pending' => (int) Queue::size(),
];
}

View File

@ -18,7 +18,7 @@ return [
'app_tag' => '5.1.61-release',
'minimum_client_version' => '5.0.16',
'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', false),
'api_secret' => env('API_SECRET', ''),
'google_maps_api_key' => env('GOOGLE_MAPS_API_KEY'),
'google_analytics_url' => env('GOOGLE_ANALYTICS_URL', 'https://www.google-analytics.com/collect'),
'key_length' => 64,
@ -148,4 +148,5 @@ return [
'disable_auto_update' => env('DISABLE_AUTO_UPDATE', false),
'invoiceninja_hosted_pdf_generation' => env('NINJA_HOSTED_PDF', false),
'ninja_stripe_key' => env('NINJA_STRIPE_KEY', null),
'pdf_generator' => env('PDF_GENERATOR', false),
];

View File

@ -52,7 +52,6 @@ class InvitationTest extends TestCase
try {
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->put('/api/v1/invoices/'.$this->encodePrimaryKey($this->invoice->id), $this->invoice->toArray());
} catch (\Exception $e) {