mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
commit
832043b59d
@ -1 +1 @@
|
||||
5.3.91
|
||||
5.3.92
|
@ -74,7 +74,7 @@ class CheckData extends Command
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'ninja:check-data {--database=} {--fix=} {--client_id=} {--vendor_id=} {--paid_to_date=} {--client_balance=} {--ledger_balance=}';
|
||||
protected $signature = 'ninja:check-data {--database=} {--fix=} {--client_id=} {--vendor_id=} {--paid_to_date=} {--client_balance=} {--ledger_balance=} {--balance_status=}';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
@ -89,6 +89,9 @@ class CheckData extends Command
|
||||
|
||||
protected $wrong_balances = 0;
|
||||
|
||||
protected $wrong_paid_status = 0;
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$time_start = microtime(true);
|
||||
@ -109,6 +112,7 @@ class CheckData extends Command
|
||||
$this->checkVendorContacts();
|
||||
$this->checkEntityInvitations();
|
||||
$this->checkCompanyData();
|
||||
$this->checkBalanceVsPaidStatus();
|
||||
|
||||
if(Ninja::isHosted())
|
||||
$this->checkAccountStatuses();
|
||||
@ -856,4 +860,44 @@ class CheckData extends Command
|
||||
});
|
||||
}
|
||||
|
||||
public function checkBalanceVsPaidStatus()
|
||||
{
|
||||
$this->wrong_paid_status = 0;
|
||||
|
||||
foreach(Invoice::with(['payments'])->whereHas('payments')->where('status_id', 4)->where('balance', '>', 0)->where('is_deleted',0)->cursor() as $invoice)
|
||||
{
|
||||
|
||||
$this->logMessage("# {$invoice->id} " . ' - '.$invoice->number." - Marked as paid, but balance = {$invoice->balance}");
|
||||
|
||||
if($this->option('balance_status')){
|
||||
|
||||
$val = $invoice->balance;
|
||||
|
||||
$invoice->balance = 0;
|
||||
$invoice->paid_to_date=$val;
|
||||
$invoice->save();
|
||||
|
||||
$p = $invoice->payments->first();
|
||||
|
||||
if($p && (int)$p->amount == 0)
|
||||
{
|
||||
$p->amount = $val;
|
||||
$p->applied = $val;
|
||||
$p->save();
|
||||
|
||||
$pivot = $p->paymentables->first();
|
||||
$pivot->amount = $val;
|
||||
$pivot->save();
|
||||
}
|
||||
|
||||
|
||||
$this->logMessage("Fixing {$invoice->id} settings payment to {$val}");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this->logMessage($this->wrong_paid_status." wrong invoices with bad balance state");
|
||||
|
||||
}
|
||||
}
|
@ -249,6 +249,9 @@ class CompanySettings extends BaseSettings
|
||||
public $primary_color = '#298AAB';
|
||||
public $secondary_color = '#7081e0';
|
||||
|
||||
public $page_numbering = false;
|
||||
public $page_numbering_alignment = 'C'; //C,R,L
|
||||
|
||||
public $hide_paid_to_date = false; //@TODO where?
|
||||
public $embed_documents = false; //@TODO where?
|
||||
public $all_pages_header = false; //@deprecated 31-05-2021
|
||||
@ -274,6 +277,8 @@ class CompanySettings extends BaseSettings
|
||||
public $auto_archive_invoice_cancelled = false;
|
||||
|
||||
public static $casts = [
|
||||
'page_numbering_alignment' => 'string',
|
||||
'page_numbering' => 'bool',
|
||||
'auto_archive_invoice_cancelled' => 'bool',
|
||||
'email_from_name' => 'string',
|
||||
'show_all_tasks_client_portal' => 'string',
|
||||
|
@ -17,6 +17,7 @@ use App\Transformers\ActivityTransformer;
|
||||
use App\Utils\HostedPDF\NinjaPdf;
|
||||
use App\Utils\Ninja;
|
||||
use App\Utils\PhantomJS\Phantom;
|
||||
use App\Utils\Traits\Pdf\PageNumbering;
|
||||
use App\Utils\Traits\Pdf\PdfMaker;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@ -27,7 +28,7 @@ use stdClass;
|
||||
|
||||
class ActivityController extends BaseController
|
||||
{
|
||||
use PdfMaker;
|
||||
use PdfMaker, PageNumbering;
|
||||
|
||||
protected $entity_type = Activity::class;
|
||||
|
||||
@ -164,12 +165,35 @@ class ActivityController extends BaseController
|
||||
|
||||
if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') {
|
||||
$pdf = (new Phantom)->convertHtmlToPdf($html_backup);
|
||||
|
||||
$numbered_pdf = $this->pageNumbering($pdf, $activity->company);
|
||||
|
||||
if($numbered_pdf)
|
||||
$pdf = $numbered_pdf;
|
||||
|
||||
|
||||
}
|
||||
elseif(config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja'){
|
||||
$pdf = (new NinjaPdf())->build($html_backup);
|
||||
|
||||
$numbered_pdf = $this->pageNumbering($pdf, $activity->company);
|
||||
|
||||
if($numbered_pdf)
|
||||
$pdf = $numbered_pdf;
|
||||
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
$pdf = $this->makePdf(null, null, $html_backup);
|
||||
|
||||
$numbered_pdf = $this->pageNumbering($pdf, $activity->company);
|
||||
|
||||
if($numbered_pdf)
|
||||
$pdf = $numbered_pdf;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (isset($activity->invoice_id)) {
|
||||
|
@ -191,7 +191,6 @@ class InvitationController extends Controller
|
||||
return response()->json(["message" => "no record found"], 400);
|
||||
|
||||
$file_name = $invitation->{$entity}->numberFormatter().'.pdf';
|
||||
nlog($file_name);
|
||||
|
||||
$file = CreateRawPdf::dispatchNow($invitation, $invitation->company->db);
|
||||
|
||||
|
@ -41,6 +41,7 @@ use App\Utils\Ninja;
|
||||
use App\Utils\PhantomJS\Phantom;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Utils\Traits\MakesInvoiceHtml;
|
||||
use App\Utils\Traits\Pdf\PageNumbering;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Lang;
|
||||
@ -51,6 +52,8 @@ class PreviewController extends BaseController
|
||||
{
|
||||
use MakesHash;
|
||||
use MakesInvoiceHtml;
|
||||
use PageNumbering;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@ -157,7 +160,15 @@ class PreviewController extends BaseController
|
||||
}
|
||||
|
||||
if(config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja'){
|
||||
return (new NinjaPdf())->build($maker->getCompiledHTML(true));
|
||||
$pdf = (new NinjaPdf())->build($maker->getCompiledHTML(true));
|
||||
|
||||
$numbered_pdf = $this->pageNumbering($pdf, auth()->user()->company());
|
||||
|
||||
if($numbered_pdf)
|
||||
$pdf = $numbered_pdf;
|
||||
|
||||
return $pdf;
|
||||
|
||||
}
|
||||
|
||||
//else
|
||||
@ -285,7 +296,14 @@ class PreviewController extends BaseController
|
||||
}
|
||||
|
||||
if(config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja'){
|
||||
return (new NinjaPdf())->build($maker->getCompiledHTML(true));
|
||||
$pdf = (new NinjaPdf())->build($maker->getCompiledHTML(true));
|
||||
|
||||
$numbered_pdf = $this->pageNumbering($pdf, auth()->user()->company());
|
||||
|
||||
if($numbered_pdf)
|
||||
$pdf = $numbered_pdf;
|
||||
|
||||
return $pdf;
|
||||
}
|
||||
|
||||
$file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), $company);
|
||||
@ -354,7 +372,14 @@ class PreviewController extends BaseController
|
||||
}
|
||||
|
||||
if(config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja'){
|
||||
return (new NinjaPdf())->build($maker->getCompiledHTML(true));
|
||||
$pdf = (new NinjaPdf())->build($maker->getCompiledHTML(true));
|
||||
|
||||
$numbered_pdf = $this->pageNumbering($pdf, auth()->user()->company());
|
||||
|
||||
if($numbered_pdf)
|
||||
$pdf = $numbered_pdf;
|
||||
|
||||
return $pdf;
|
||||
}
|
||||
|
||||
$file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), auth()->user()->company());
|
||||
@ -443,7 +468,14 @@ class PreviewController extends BaseController
|
||||
}
|
||||
|
||||
if(config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja'){
|
||||
return (new NinjaPdf())->build($maker->getCompiledHTML(true));
|
||||
$pdf = (new NinjaPdf())->build($maker->getCompiledHTML(true));
|
||||
|
||||
$numbered_pdf = $this->pageNumbering($pdf, auth()->user()->company());
|
||||
|
||||
if($numbered_pdf)
|
||||
$pdf = $numbered_pdf;
|
||||
|
||||
return $pdf;
|
||||
}
|
||||
|
||||
$file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), auth()->user()->company());
|
||||
|
@ -134,13 +134,21 @@ class SelfUpdateController extends BaseController
|
||||
|
||||
nlog("Extracting zip");
|
||||
|
||||
$zipFile = new \PhpZip\ZipFile();
|
||||
// $zipFile = new \PhpZip\ZipFile();
|
||||
|
||||
$zipFile->openFile($file);
|
||||
// $zipFile->openFile($file);
|
||||
|
||||
$zipFile->extractTo(base_path());
|
||||
// $zipFile->extractTo(base_path());
|
||||
|
||||
$zipFile->close();
|
||||
// $zipFile->close();
|
||||
|
||||
$zip = new \ZipArchive;
|
||||
|
||||
$res = $zip->open($file);
|
||||
if ($res === TRUE) {
|
||||
$zip->extractTo(base_path());
|
||||
$zip->close();
|
||||
}
|
||||
|
||||
nlog("Finished extracting files");
|
||||
|
||||
|
@ -49,7 +49,7 @@ class SetupController extends Controller
|
||||
{
|
||||
$check = SystemHealth::check(false);
|
||||
|
||||
if ($check['system_health'] == true && $check['simple_db_check'] && Schema::hasTable('accounts') && $account = Account::all()->first()) {
|
||||
if ($check['system_health'] == true && $check['simple_db_check'] && Schema::hasTable('accounts') && $account = Account::first()) {
|
||||
return redirect('/');
|
||||
}
|
||||
|
||||
@ -211,29 +211,31 @@ class SetupController extends Controller
|
||||
public function checkPdf(Request $request)
|
||||
{
|
||||
try {
|
||||
if (config('ninja.pdf_generator') == 'phantom') {
|
||||
return $this->testPhantom();
|
||||
}
|
||||
|
||||
$pdf = new Snappdf();
|
||||
// if (config('ninja.pdf_generator') == 'phantom') {
|
||||
// return $this->testPhantom();
|
||||
// }
|
||||
|
||||
if (config('ninja.snappdf_chromium_path')) {
|
||||
$pdf->setChromiumPath(config('ninja.snappdf_chromium_path'));
|
||||
}
|
||||
// $pdf = new Snappdf();
|
||||
|
||||
if (config('ninja.snappdf_chromium_arguments')) {
|
||||
$pdf->clearChromiumArguments();
|
||||
$pdf->addChromiumArguments(config('ninja.snappdf_chromium_arguments'));
|
||||
}
|
||||
// if (config('ninja.snappdf_chromium_path')) {
|
||||
// $pdf->setChromiumPath(config('ninja.snappdf_chromium_path'));
|
||||
// }
|
||||
|
||||
$pdf = $pdf
|
||||
->setHtml('GENERATING PDFs WORKS! Thank you for using Invoice Ninja!')
|
||||
->generate();
|
||||
// if (config('ninja.snappdf_chromium_arguments')) {
|
||||
// $pdf->clearChromiumArguments();
|
||||
// $pdf->addChromiumArguments(config('ninja.snappdf_chromium_arguments'));
|
||||
// }
|
||||
|
||||
Storage::disk(config('filesystems.default'))->put('test.pdf', $pdf);
|
||||
Storage::disk('local')->put('test.pdf', $pdf);
|
||||
// $pdf = $pdf
|
||||
// ->setHtml('GENERATING PDFs WORKS! Thank you for using Invoice Ninja!')
|
||||
// ->generate();
|
||||
|
||||
return response(['url' => Storage::disk('local')->url('test.pdf')], 200);
|
||||
// Storage::disk(config('filesystems.default'))->put('test.pdf', $pdf);
|
||||
// Storage::disk('local')->put('test.pdf', $pdf);
|
||||
return response(['url' => ''], 200);
|
||||
|
||||
// return response(['url' => Storage::disk('local')->url('test.pdf')], 200);
|
||||
} catch (Exception $e) {
|
||||
nlog($e->getMessage());
|
||||
|
||||
|
@ -31,7 +31,7 @@ class GenericReportRequest extends Request
|
||||
'start_date' => 'string|date',
|
||||
'end_date' => 'string|date',
|
||||
'date_key' => 'string',
|
||||
'date_range' => 'required|string',
|
||||
'date_range' => 'sometimes|string',
|
||||
'report_keys' => 'present|array',
|
||||
'send_email' => 'required|bool',
|
||||
];
|
||||
@ -41,6 +41,8 @@ class GenericReportRequest extends Request
|
||||
{
|
||||
$input = $this->all();
|
||||
|
||||
if(!array_key_exists('date_range', $input))
|
||||
$input['date_range'] = 'all';
|
||||
|
||||
if(!array_key_exists('report_keys', $input))
|
||||
$input['report_keys'] = [];
|
||||
|
@ -33,8 +33,18 @@ class ProfitLossRequest extends Request
|
||||
'is_income_billed' => 'required|bail|bool',
|
||||
'is_expense_billed' => 'required|bail|bool',
|
||||
'include_tax' => 'required|bail|bool',
|
||||
'date_range' => 'required|bail|string',
|
||||
'date_range' => 'sometimes|string',
|
||||
'send_email' => 'bool',
|
||||
];
|
||||
}
|
||||
|
||||
public function prepareForValidation()
|
||||
{
|
||||
$input = $this->all();
|
||||
|
||||
if(!array_key_exists('date_range', $input))
|
||||
$input['date_range'] = 'all';
|
||||
|
||||
$this->replace($input);
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,8 @@ use App\Utils\PhantomJS\Phantom;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Utils\Traits\MakesInvoiceHtml;
|
||||
use App\Utils\Traits\NumberFormatter;
|
||||
use App\Utils\Traits\Pdf\PageNumbering;
|
||||
use App\Utils\Traits\Pdf\PDF;
|
||||
use App\Utils\Traits\Pdf\PdfMaker;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
@ -43,10 +45,11 @@ use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Lang;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use setasign\Fpdi\PdfParser\StreamReader;
|
||||
|
||||
class CreateEntityPdf implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, NumberFormatter, MakesInvoiceHtml, PdfMaker, MakesHash;
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, NumberFormatter, MakesInvoiceHtml, PdfMaker, MakesHash, PageNumbering;
|
||||
|
||||
public $entity;
|
||||
|
||||
@ -102,6 +105,7 @@ class CreateEntityPdf implements ShouldQueue
|
||||
|
||||
public function handle()
|
||||
{
|
||||
|
||||
MultiDB::setDb($this->company->db);
|
||||
|
||||
/* Forget the singleton*/
|
||||
@ -186,9 +190,23 @@ class CreateEntityPdf implements ShouldQueue
|
||||
|
||||
if(config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja'){
|
||||
$pdf = (new NinjaPdf())->build($maker->getCompiledHTML(true));
|
||||
|
||||
$numbered_pdf = $this->pageNumbering($pdf, $this->company);
|
||||
|
||||
if($numbered_pdf)
|
||||
$pdf = $numbered_pdf;
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
$pdf = $this->makePdf(null, null, $maker->getCompiledHTML(true));
|
||||
|
||||
$numbered_pdf = $this->pageNumbering($pdf, $this->company);
|
||||
|
||||
if($numbered_pdf)
|
||||
$pdf = $numbered_pdf;
|
||||
|
||||
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
@ -204,9 +222,9 @@ class CreateEntityPdf implements ShouldQueue
|
||||
try{
|
||||
|
||||
if(!Storage::disk($this->disk)->exists($path))
|
||||
|
||||
Storage::disk($this->disk)->makeDirectory($path, 0775);
|
||||
Storage::disk($this->disk)->put($file_path, $pdf, 'public');
|
||||
|
||||
Storage::disk($this->disk)->put($file_path, $pdf, 'public');
|
||||
|
||||
}
|
||||
catch(\Exception $e)
|
||||
@ -225,4 +243,5 @@ class CreateEntityPdf implements ShouldQueue
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Entity Ninja (https://entityninja.com).
|
||||
*
|
||||
@ -34,6 +33,7 @@ use App\Utils\PhantomJS\Phantom;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Utils\Traits\MakesInvoiceHtml;
|
||||
use App\Utils\Traits\NumberFormatter;
|
||||
use App\Utils\Traits\Pdf\PageNumbering;
|
||||
use App\Utils\Traits\Pdf\PdfMaker;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
@ -46,7 +46,7 @@ use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class CreateRawPdf implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, NumberFormatter, MakesInvoiceHtml, PdfMaker, MakesHash;
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, NumberFormatter, MakesInvoiceHtml, PdfMaker, MakesHash, PageNumbering;
|
||||
|
||||
public $entity;
|
||||
|
||||
@ -177,11 +177,22 @@ class CreateRawPdf implements ShouldQueue
|
||||
if($finfo->buffer($pdf) != 'application/pdf; charset=binary')
|
||||
{
|
||||
$pdf = $this->makePdf(null, null, $maker->getCompiledHTML(true));
|
||||
|
||||
$numbered_pdf = $this->pageNumbering($pdf, $this->company);
|
||||
|
||||
if($numbered_pdf)
|
||||
$pdf = $numbered_pdf;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
$pdf = $this->makePdf(null, null, $maker->getCompiledHTML(true));
|
||||
|
||||
$numbered_pdf = $this->pageNumbering($pdf, $this->company);
|
||||
|
||||
if($numbered_pdf)
|
||||
$pdf = $numbered_pdf;
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace App\Jobs\Util;
|
||||
|
||||
use App\Models\Company;
|
||||
use App\Utils\Traits\Pdf\PageNumbering;
|
||||
use App\Utils\Traits\Pdf\PdfMaker;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
@ -21,7 +22,7 @@ use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class PreviewPdf implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PdfMaker;
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PdfMaker, PageNumbering;
|
||||
|
||||
public $company;
|
||||
|
||||
@ -46,6 +47,13 @@ class PreviewPdf implements ShouldQueue
|
||||
|
||||
public function handle()
|
||||
{
|
||||
return $this->makePdf(null, null, $this->design_string);
|
||||
$pdf = $this->makePdf(null, null, $this->design_string);
|
||||
|
||||
$numbered_pdf = $this->pageNumbering($pdf, $this->company);
|
||||
|
||||
if($numbered_pdf)
|
||||
$pdf = $numbered_pdf;
|
||||
|
||||
return $pdf;
|
||||
}
|
||||
}
|
||||
|
@ -92,6 +92,9 @@ class PaymentNotification implements ShouldQueue
|
||||
|
||||
$analytics_id = $company->google_analytics_key;
|
||||
|
||||
if(!strlen($analytics_id) > 2)
|
||||
return;
|
||||
|
||||
$client = $payment->client;
|
||||
$amount = $payment->amount;
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\DataMapper\CompanySettings;
|
||||
use App\Models\Language;
|
||||
use App\Models\Presenters\CompanyPresenter;
|
||||
use App\Models\User;
|
||||
@ -402,6 +403,12 @@ class Company extends BaseModel
|
||||
return $this->settings->{$setting};
|
||||
}
|
||||
|
||||
$cs = CompanySettings::defaults();
|
||||
|
||||
if (property_exists($cs, $setting) != false) {
|
||||
return $cs->{$setting};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@ use App\Services\PdfMaker\PdfMaker as PdfMakerService;
|
||||
use App\Utils\CurlUtils;
|
||||
use App\Utils\HtmlEngine;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Utils\Traits\Pdf\PageNumbering;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
@ -33,7 +34,7 @@ use Illuminate\Support\Str;
|
||||
|
||||
class Phantom
|
||||
{
|
||||
use MakesHash;
|
||||
use MakesHash, PageNumbering;
|
||||
|
||||
/**
|
||||
* Generate a PDF from the
|
||||
@ -99,6 +100,12 @@ class Phantom
|
||||
|
||||
$this->checkMime($pdf, $invitation, $entity);
|
||||
|
||||
$numbered_pdf = $this->pageNumbering($pdf, $invitation->company);
|
||||
|
||||
if($numbered_pdf)
|
||||
$pdf = $numbered_pdf;
|
||||
|
||||
|
||||
if(!Storage::disk(config('filesystems.default'))->exists($path))
|
||||
Storage::disk(config('filesystems.default'))->makeDirectory($path, 0775);
|
||||
|
||||
|
@ -77,7 +77,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(),
|
||||
'jobs_pending' => (int) self::checkQueueSize(),
|
||||
'pdf_engine' => (string) self::getPdfEngine(),
|
||||
'queue' => (string) config('queue.default'),
|
||||
'trailing_slash' => (bool) self::checkUrlState(),
|
||||
@ -85,6 +85,20 @@ class SystemHealth
|
||||
];
|
||||
}
|
||||
|
||||
private static function checkQueueSize()
|
||||
{
|
||||
$count = 0;
|
||||
|
||||
try{
|
||||
$count = Queue::size();
|
||||
}
|
||||
catch(\Exception $e){
|
||||
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
public static function checkFileSystem()
|
||||
{
|
||||
|
||||
|
40
app/Utils/Traits/Pdf/PDF.php
Normal file
40
app/Utils/Traits/Pdf/PDF.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Utils\Traits\Pdf;
|
||||
|
||||
use setasign\Fpdi\Fpdi;
|
||||
|
||||
class PDF extends FPDI
|
||||
{
|
||||
|
||||
public $text_alignment = 'L';
|
||||
|
||||
function Footer()
|
||||
{
|
||||
$this->SetXY(0, -5);
|
||||
$this->SetFont('Arial','I', 9);
|
||||
$this->SetTextColor(135,135,135);
|
||||
|
||||
$trans = ctrans('texts.pdf_page_info', ['current' => $this->PageNo(), 'total' => '{nb}']);
|
||||
$this->Cell(0,5, $trans ,0,0, $this->text_alignment);
|
||||
|
||||
}
|
||||
|
||||
public function setAlignment($alignment)
|
||||
{
|
||||
if(in_array($alignment, ['C','L','R']))
|
||||
$this->text_alignment = $alignment;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
54
app/Utils/Traits/Pdf/PageNumbering.php
Normal file
54
app/Utils/Traits/Pdf/PageNumbering.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Utils\Traits\Pdf;
|
||||
use App\Utils\Traits\Pdf\PDF;
|
||||
use setasign\Fpdi\PdfParser\StreamReader;
|
||||
|
||||
trait PageNumbering
|
||||
{
|
||||
private function pageNumbering($pdf_data_object, $company)
|
||||
{
|
||||
|
||||
if(!$company->settings->page_numbering)
|
||||
return $pdf_data_object;
|
||||
|
||||
try
|
||||
{
|
||||
$pdf = new PDF();
|
||||
|
||||
$pdf->setAlignment($company->getSetting('page_numbering_alignment'));
|
||||
|
||||
$pageCount = $pdf->setSourceFile(StreamReader::createByString($pdf_data_object));
|
||||
|
||||
$pdf->AliasNbPages();
|
||||
|
||||
for ($i=1; $i <= $pageCount; $i++) {
|
||||
//import a page then get the id and will be used in the template
|
||||
$tplId = $pdf->importPage($i);
|
||||
|
||||
//create a page
|
||||
$templateSize = $pdf->getTemplateSize($tplId);
|
||||
|
||||
$pdf->AddPage($templateSize['orientation'], [$templateSize['width'], $templateSize['height']]);
|
||||
|
||||
$pdf->useTemplate($tplId);
|
||||
}
|
||||
|
||||
return $pdf->Output('S');
|
||||
|
||||
}
|
||||
catch(\Exception $e) {
|
||||
nlog($e->getMessage());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -46,7 +46,6 @@ trait PdfMaker
|
||||
if($generated)
|
||||
return $generated;
|
||||
|
||||
|
||||
throw new InternalPDFFailure('There was an issue generating the PDF locally');
|
||||
}
|
||||
}
|
||||
|
@ -74,6 +74,8 @@
|
||||
"predis/predis": "^1.1",
|
||||
"razorpay/razorpay": "2.*",
|
||||
"sentry/sentry-laravel": "^2",
|
||||
"setasign/fpdf": "^1.8",
|
||||
"setasign/fpdi": "^2.3",
|
||||
"square/square": "13.0.0.20210721",
|
||||
"stripe/stripe-php": "^7.50",
|
||||
"symfony/http-client": "^5.2",
|
||||
|
721
composer.lock
generated
721
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -14,8 +14,8 @@ return [
|
||||
'require_https' => env('REQUIRE_HTTPS', true),
|
||||
'app_url' => rtrim(env('APP_URL', ''), '/'),
|
||||
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
|
||||
'app_version' => '5.3.91',
|
||||
'app_tag' => '5.3.91',
|
||||
'app_version' => '5.3.92',
|
||||
'app_tag' => '5.3.92',
|
||||
'minimum_client_version' => '5.0.16',
|
||||
'terms_version' => '1.0.1',
|
||||
'api_secret' => env('API_SECRET', ''),
|
||||
|
2184
database/schema/mysql-schema.dump
Normal file
2184
database/schema/mysql-schema.dump
Normal file
File diff suppressed because it is too large
Load Diff
4
public/flutter_service_worker.js
vendored
4
public/flutter_service_worker.js
vendored
@ -3,13 +3,13 @@ const MANIFEST = 'flutter-app-manifest';
|
||||
const TEMP = 'flutter-temp-cache';
|
||||
const CACHE_NAME = 'flutter-app-cache';
|
||||
const RESOURCES = {
|
||||
"main.dart.js": "01650cf247d1b2ef31e4bb84a76b28fd",
|
||||
"main.dart.js": "b552020eead077b50b54a51de32ba513",
|
||||
"canvaskit/canvaskit.wasm": "4b83d89d9fecbea8ca46f2f760c5a9ba",
|
||||
"canvaskit/profiling/canvaskit.wasm": "95e736ab31147d1b2c7b25f11d4c32cd",
|
||||
"canvaskit/profiling/canvaskit.js": "ae2949af4efc61d28a4a80fffa1db900",
|
||||
"canvaskit/canvaskit.js": "c2b4e5f3d7a3d82aed024e7249a78487",
|
||||
"flutter.js": "0816e65a103ba8ba51b174eeeeb2cb67",
|
||||
"/": "eea3dd0db9e972492cf345e1d6676daf",
|
||||
"/": "15b97e9f966c26d599d1d9c0ecd01354",
|
||||
"favicon.png": "dca91c54388f52eded692718d5a98b8b",
|
||||
"version.json": "3afb81924daf4f751571755436069115",
|
||||
"assets/AssetManifest.json": "38d9aea341601f3a5c6fa7b5a1216ea5",
|
||||
|
221631
public/main.dart.js
vendored
221631
public/main.dart.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
187983
public/main.foss.dart.js
vendored
187983
public/main.foss.dart.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
221897
public/main.html.dart.js
vendored
221897
public/main.html.dart.js
vendored
File diff suppressed because one or more lines are too long
187887
public/main.next.dart.js
vendored
187887
public/main.next.dart.js
vendored
File diff suppressed because one or more lines are too long
11150
public/main.profile.dart.js
vendored
11150
public/main.profile.dart.js
vendored
File diff suppressed because one or more lines are too long
@ -52,10 +52,6 @@
|
||||
<dd class="text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
||||
<div class="alert py-2 bg-white" id="test-pdf-response"></div>
|
||||
</dd>
|
||||
<a target="_blank" class="block text-sm text-gray-900 leading-5 underline"
|
||||
href="https://invoiceninja.github.io/docs/self-host-troubleshooting/#pdf-conversion-issues">
|
||||
{{ ctrans('texts.setup_phantomjs_note') }}
|
||||
</a>
|
||||
</div>
|
||||
</dl>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user