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
|
* @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
|
* @var string
|
||||||
@ -89,6 +89,9 @@ class CheckData extends Command
|
|||||||
|
|
||||||
protected $wrong_balances = 0;
|
protected $wrong_balances = 0;
|
||||||
|
|
||||||
|
protected $wrong_paid_status = 0;
|
||||||
|
|
||||||
|
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$time_start = microtime(true);
|
$time_start = microtime(true);
|
||||||
@ -109,6 +112,7 @@ class CheckData extends Command
|
|||||||
$this->checkVendorContacts();
|
$this->checkVendorContacts();
|
||||||
$this->checkEntityInvitations();
|
$this->checkEntityInvitations();
|
||||||
$this->checkCompanyData();
|
$this->checkCompanyData();
|
||||||
|
$this->checkBalanceVsPaidStatus();
|
||||||
|
|
||||||
if(Ninja::isHosted())
|
if(Ninja::isHosted())
|
||||||
$this->checkAccountStatuses();
|
$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 $primary_color = '#298AAB';
|
||||||
public $secondary_color = '#7081e0';
|
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 $hide_paid_to_date = false; //@TODO where?
|
||||||
public $embed_documents = false; //@TODO where?
|
public $embed_documents = false; //@TODO where?
|
||||||
public $all_pages_header = false; //@deprecated 31-05-2021
|
public $all_pages_header = false; //@deprecated 31-05-2021
|
||||||
@ -274,6 +277,8 @@ class CompanySettings extends BaseSettings
|
|||||||
public $auto_archive_invoice_cancelled = false;
|
public $auto_archive_invoice_cancelled = false;
|
||||||
|
|
||||||
public static $casts = [
|
public static $casts = [
|
||||||
|
'page_numbering_alignment' => 'string',
|
||||||
|
'page_numbering' => 'bool',
|
||||||
'auto_archive_invoice_cancelled' => 'bool',
|
'auto_archive_invoice_cancelled' => 'bool',
|
||||||
'email_from_name' => 'string',
|
'email_from_name' => 'string',
|
||||||
'show_all_tasks_client_portal' => 'string',
|
'show_all_tasks_client_portal' => 'string',
|
||||||
|
@ -17,6 +17,7 @@ use App\Transformers\ActivityTransformer;
|
|||||||
use App\Utils\HostedPDF\NinjaPdf;
|
use App\Utils\HostedPDF\NinjaPdf;
|
||||||
use App\Utils\Ninja;
|
use App\Utils\Ninja;
|
||||||
use App\Utils\PhantomJS\Phantom;
|
use App\Utils\PhantomJS\Phantom;
|
||||||
|
use App\Utils\Traits\Pdf\PageNumbering;
|
||||||
use App\Utils\Traits\Pdf\PdfMaker;
|
use App\Utils\Traits\Pdf\PdfMaker;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@ -27,7 +28,7 @@ use stdClass;
|
|||||||
|
|
||||||
class ActivityController extends BaseController
|
class ActivityController extends BaseController
|
||||||
{
|
{
|
||||||
use PdfMaker;
|
use PdfMaker, PageNumbering;
|
||||||
|
|
||||||
protected $entity_type = Activity::class;
|
protected $entity_type = Activity::class;
|
||||||
|
|
||||||
@ -164,12 +165,35 @@ class ActivityController extends BaseController
|
|||||||
|
|
||||||
if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') {
|
if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') {
|
||||||
$pdf = (new Phantom)->convertHtmlToPdf($html_backup);
|
$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'){
|
elseif(config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja'){
|
||||||
$pdf = (new NinjaPdf())->build($html_backup);
|
$pdf = (new NinjaPdf())->build($html_backup);
|
||||||
|
|
||||||
|
$numbered_pdf = $this->pageNumbering($pdf, $activity->company);
|
||||||
|
|
||||||
|
if($numbered_pdf)
|
||||||
|
$pdf = $numbered_pdf;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$pdf = $this->makePdf(null, null, $html_backup);
|
$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)) {
|
if (isset($activity->invoice_id)) {
|
||||||
|
@ -191,7 +191,6 @@ class InvitationController extends Controller
|
|||||||
return response()->json(["message" => "no record found"], 400);
|
return response()->json(["message" => "no record found"], 400);
|
||||||
|
|
||||||
$file_name = $invitation->{$entity}->numberFormatter().'.pdf';
|
$file_name = $invitation->{$entity}->numberFormatter().'.pdf';
|
||||||
nlog($file_name);
|
|
||||||
|
|
||||||
$file = CreateRawPdf::dispatchNow($invitation, $invitation->company->db);
|
$file = CreateRawPdf::dispatchNow($invitation, $invitation->company->db);
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ use App\Utils\Ninja;
|
|||||||
use App\Utils\PhantomJS\Phantom;
|
use App\Utils\PhantomJS\Phantom;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
use App\Utils\Traits\MakesInvoiceHtml;
|
use App\Utils\Traits\MakesInvoiceHtml;
|
||||||
|
use App\Utils\Traits\Pdf\PageNumbering;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Lang;
|
use Illuminate\Support\Facades\Lang;
|
||||||
@ -51,6 +52,8 @@ class PreviewController extends BaseController
|
|||||||
{
|
{
|
||||||
use MakesHash;
|
use MakesHash;
|
||||||
use MakesInvoiceHtml;
|
use MakesInvoiceHtml;
|
||||||
|
use PageNumbering;
|
||||||
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
@ -157,7 +160,15 @@ class PreviewController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja'){
|
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
|
//else
|
||||||
@ -285,7 +296,14 @@ class PreviewController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja'){
|
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);
|
$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'){
|
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());
|
$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'){
|
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());
|
$file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), auth()->user()->company());
|
||||||
|
@ -134,13 +134,21 @@ class SelfUpdateController extends BaseController
|
|||||||
|
|
||||||
nlog("Extracting zip");
|
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");
|
nlog("Finished extracting files");
|
||||||
|
|
||||||
|
@ -48,14 +48,14 @@ class SetupController extends Controller
|
|||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$check = SystemHealth::check(false);
|
$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('/');
|
return redirect('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Ninja::isHosted())
|
if(Ninja::isHosted())
|
||||||
return redirect('/');
|
return redirect('/');
|
||||||
|
|
||||||
return view('setup.index', ['check' => $check]);
|
return view('setup.index', ['check' => $check]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,29 +211,31 @@ class SetupController extends Controller
|
|||||||
public function checkPdf(Request $request)
|
public function checkPdf(Request $request)
|
||||||
{
|
{
|
||||||
try {
|
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 = new Snappdf();
|
||||||
$pdf->setChromiumPath(config('ninja.snappdf_chromium_path'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config('ninja.snappdf_chromium_arguments')) {
|
// if (config('ninja.snappdf_chromium_path')) {
|
||||||
$pdf->clearChromiumArguments();
|
// $pdf->setChromiumPath(config('ninja.snappdf_chromium_path'));
|
||||||
$pdf->addChromiumArguments(config('ninja.snappdf_chromium_arguments'));
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
$pdf = $pdf
|
// if (config('ninja.snappdf_chromium_arguments')) {
|
||||||
->setHtml('GENERATING PDFs WORKS! Thank you for using Invoice Ninja!')
|
// $pdf->clearChromiumArguments();
|
||||||
->generate();
|
// $pdf->addChromiumArguments(config('ninja.snappdf_chromium_arguments'));
|
||||||
|
// }
|
||||||
|
|
||||||
Storage::disk(config('filesystems.default'))->put('test.pdf', $pdf);
|
// $pdf = $pdf
|
||||||
Storage::disk('local')->put('test.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) {
|
} catch (Exception $e) {
|
||||||
nlog($e->getMessage());
|
nlog($e->getMessage());
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ class GenericReportRequest extends Request
|
|||||||
'start_date' => 'string|date',
|
'start_date' => 'string|date',
|
||||||
'end_date' => 'string|date',
|
'end_date' => 'string|date',
|
||||||
'date_key' => 'string',
|
'date_key' => 'string',
|
||||||
'date_range' => 'required|string',
|
'date_range' => 'sometimes|string',
|
||||||
'report_keys' => 'present|array',
|
'report_keys' => 'present|array',
|
||||||
'send_email' => 'required|bool',
|
'send_email' => 'required|bool',
|
||||||
];
|
];
|
||||||
@ -41,6 +41,8 @@ class GenericReportRequest extends Request
|
|||||||
{
|
{
|
||||||
$input = $this->all();
|
$input = $this->all();
|
||||||
|
|
||||||
|
if(!array_key_exists('date_range', $input))
|
||||||
|
$input['date_range'] = 'all';
|
||||||
|
|
||||||
if(!array_key_exists('report_keys', $input))
|
if(!array_key_exists('report_keys', $input))
|
||||||
$input['report_keys'] = [];
|
$input['report_keys'] = [];
|
||||||
|
@ -33,8 +33,18 @@ class ProfitLossRequest extends Request
|
|||||||
'is_income_billed' => 'required|bail|bool',
|
'is_income_billed' => 'required|bail|bool',
|
||||||
'is_expense_billed' => 'required|bail|bool',
|
'is_expense_billed' => 'required|bail|bool',
|
||||||
'include_tax' => 'required|bail|bool',
|
'include_tax' => 'required|bail|bool',
|
||||||
'date_range' => 'required|bail|string',
|
'date_range' => 'sometimes|string',
|
||||||
'send_email' => 'bool',
|
'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\MakesHash;
|
||||||
use App\Utils\Traits\MakesInvoiceHtml;
|
use App\Utils\Traits\MakesInvoiceHtml;
|
||||||
use App\Utils\Traits\NumberFormatter;
|
use App\Utils\Traits\NumberFormatter;
|
||||||
|
use App\Utils\Traits\Pdf\PageNumbering;
|
||||||
|
use App\Utils\Traits\Pdf\PDF;
|
||||||
use App\Utils\Traits\Pdf\PdfMaker;
|
use App\Utils\Traits\Pdf\PdfMaker;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
@ -43,10 +45,11 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
use Illuminate\Support\Facades\Lang;
|
use Illuminate\Support\Facades\Lang;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use setasign\Fpdi\PdfParser\StreamReader;
|
||||||
|
|
||||||
class CreateEntityPdf implements ShouldQueue
|
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;
|
public $entity;
|
||||||
|
|
||||||
@ -102,6 +105,7 @@ class CreateEntityPdf implements ShouldQueue
|
|||||||
|
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
|
|
||||||
MultiDB::setDb($this->company->db);
|
MultiDB::setDb($this->company->db);
|
||||||
|
|
||||||
/* Forget the singleton*/
|
/* Forget the singleton*/
|
||||||
@ -186,9 +190,23 @@ class CreateEntityPdf implements ShouldQueue
|
|||||||
|
|
||||||
if(config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja'){
|
if(config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja'){
|
||||||
$pdf = (new NinjaPdf())->build($maker->getCompiledHTML(true));
|
$pdf = (new NinjaPdf())->build($maker->getCompiledHTML(true));
|
||||||
|
|
||||||
|
$numbered_pdf = $this->pageNumbering($pdf, $this->company);
|
||||||
|
|
||||||
|
if($numbered_pdf)
|
||||||
|
$pdf = $numbered_pdf;
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
$pdf = $this->makePdf(null, null, $maker->getCompiledHTML(true));
|
$pdf = $this->makePdf(null, null, $maker->getCompiledHTML(true));
|
||||||
|
|
||||||
|
$numbered_pdf = $this->pageNumbering($pdf, $this->company);
|
||||||
|
|
||||||
|
if($numbered_pdf)
|
||||||
|
$pdf = $numbered_pdf;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@ -203,10 +221,10 @@ class CreateEntityPdf implements ShouldQueue
|
|||||||
|
|
||||||
try{
|
try{
|
||||||
|
|
||||||
if(!Storage::disk($this->disk)->exists($path))
|
if(!Storage::disk($this->disk)->exists($path))
|
||||||
|
|
||||||
Storage::disk($this->disk)->makeDirectory($path, 0775);
|
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)
|
catch(\Exception $e)
|
||||||
@ -216,7 +234,7 @@ class CreateEntityPdf implements ShouldQueue
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $file_path;
|
return $file_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,4 +243,5 @@ class CreateEntityPdf implements ShouldQueue
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entity Ninja (https://entityninja.com).
|
* Entity Ninja (https://entityninja.com).
|
||||||
*
|
*
|
||||||
@ -34,6 +33,7 @@ use App\Utils\PhantomJS\Phantom;
|
|||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
use App\Utils\Traits\MakesInvoiceHtml;
|
use App\Utils\Traits\MakesInvoiceHtml;
|
||||||
use App\Utils\Traits\NumberFormatter;
|
use App\Utils\Traits\NumberFormatter;
|
||||||
|
use App\Utils\Traits\Pdf\PageNumbering;
|
||||||
use App\Utils\Traits\Pdf\PdfMaker;
|
use App\Utils\Traits\Pdf\PdfMaker;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
@ -46,7 +46,7 @@ use Illuminate\Support\Facades\Storage;
|
|||||||
|
|
||||||
class CreateRawPdf implements ShouldQueue
|
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;
|
public $entity;
|
||||||
|
|
||||||
@ -177,11 +177,22 @@ class CreateRawPdf implements ShouldQueue
|
|||||||
if($finfo->buffer($pdf) != 'application/pdf; charset=binary')
|
if($finfo->buffer($pdf) != 'application/pdf; charset=binary')
|
||||||
{
|
{
|
||||||
$pdf = $this->makePdf(null, null, $maker->getCompiledHTML(true));
|
$pdf = $this->makePdf(null, null, $maker->getCompiledHTML(true));
|
||||||
|
|
||||||
|
$numbered_pdf = $this->pageNumbering($pdf, $this->company);
|
||||||
|
|
||||||
|
if($numbered_pdf)
|
||||||
|
$pdf = $numbered_pdf;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$pdf = $this->makePdf(null, null, $maker->getCompiledHTML(true));
|
$pdf = $this->makePdf(null, null, $maker->getCompiledHTML(true));
|
||||||
|
|
||||||
|
$numbered_pdf = $this->pageNumbering($pdf, $this->company);
|
||||||
|
|
||||||
|
if($numbered_pdf)
|
||||||
|
$pdf = $numbered_pdf;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace App\Jobs\Util;
|
namespace App\Jobs\Util;
|
||||||
|
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
|
use App\Utils\Traits\Pdf\PageNumbering;
|
||||||
use App\Utils\Traits\Pdf\PdfMaker;
|
use App\Utils\Traits\Pdf\PdfMaker;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
@ -21,7 +22,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
|
|
||||||
class PreviewPdf implements ShouldQueue
|
class PreviewPdf implements ShouldQueue
|
||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PdfMaker;
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, PdfMaker, PageNumbering;
|
||||||
|
|
||||||
public $company;
|
public $company;
|
||||||
|
|
||||||
@ -46,6 +47,13 @@ class PreviewPdf implements ShouldQueue
|
|||||||
|
|
||||||
public function handle()
|
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;
|
$analytics_id = $company->google_analytics_key;
|
||||||
|
|
||||||
|
if(!strlen($analytics_id) > 2)
|
||||||
|
return;
|
||||||
|
|
||||||
$client = $payment->client;
|
$client = $payment->client;
|
||||||
$amount = $payment->amount;
|
$amount = $payment->amount;
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use App\DataMapper\CompanySettings;
|
||||||
use App\Models\Language;
|
use App\Models\Language;
|
||||||
use App\Models\Presenters\CompanyPresenter;
|
use App\Models\Presenters\CompanyPresenter;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
@ -402,6 +403,12 @@ class Company extends BaseModel
|
|||||||
return $this->settings->{$setting};
|
return $this->settings->{$setting};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$cs = CompanySettings::defaults();
|
||||||
|
|
||||||
|
if (property_exists($cs, $setting) != false) {
|
||||||
|
return $cs->{$setting};
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ use App\Services\PdfMaker\PdfMaker as PdfMakerService;
|
|||||||
use App\Utils\CurlUtils;
|
use App\Utils\CurlUtils;
|
||||||
use App\Utils\HtmlEngine;
|
use App\Utils\HtmlEngine;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
|
use App\Utils\Traits\Pdf\PageNumbering;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
use Illuminate\Support\Facades\Response;
|
use Illuminate\Support\Facades\Response;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
@ -33,7 +34,7 @@ use Illuminate\Support\Str;
|
|||||||
|
|
||||||
class Phantom
|
class Phantom
|
||||||
{
|
{
|
||||||
use MakesHash;
|
use MakesHash, PageNumbering;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a PDF from the
|
* Generate a PDF from the
|
||||||
@ -99,6 +100,12 @@ class Phantom
|
|||||||
|
|
||||||
$this->checkMime($pdf, $invitation, $entity);
|
$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))
|
if(!Storage::disk(config('filesystems.default'))->exists($path))
|
||||||
Storage::disk(config('filesystems.default'))->makeDirectory($path, 0775);
|
Storage::disk(config('filesystems.default'))->makeDirectory($path, 0775);
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ class SystemHealth
|
|||||||
'open_basedir' => (bool)self::checkOpenBaseDir(),
|
'open_basedir' => (bool)self::checkOpenBaseDir(),
|
||||||
'mail_mailer' => (string)self::checkMailMailer(),
|
'mail_mailer' => (string)self::checkMailMailer(),
|
||||||
'flutter_renderer' => (string)config('ninja.flutter_canvas_kit'),
|
'flutter_renderer' => (string)config('ninja.flutter_canvas_kit'),
|
||||||
'jobs_pending' => (int) Queue::size(),
|
'jobs_pending' => (int) self::checkQueueSize(),
|
||||||
'pdf_engine' => (string) self::getPdfEngine(),
|
'pdf_engine' => (string) self::getPdfEngine(),
|
||||||
'queue' => (string) config('queue.default'),
|
'queue' => (string) config('queue.default'),
|
||||||
'trailing_slash' => (bool) self::checkUrlState(),
|
'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()
|
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)
|
if($generated)
|
||||||
return $generated;
|
return $generated;
|
||||||
|
|
||||||
|
|
||||||
throw new InternalPDFFailure('There was an issue generating the PDF locally');
|
throw new InternalPDFFailure('There was an issue generating the PDF locally');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,8 @@
|
|||||||
"predis/predis": "^1.1",
|
"predis/predis": "^1.1",
|
||||||
"razorpay/razorpay": "2.*",
|
"razorpay/razorpay": "2.*",
|
||||||
"sentry/sentry-laravel": "^2",
|
"sentry/sentry-laravel": "^2",
|
||||||
|
"setasign/fpdf": "^1.8",
|
||||||
|
"setasign/fpdi": "^2.3",
|
||||||
"square/square": "13.0.0.20210721",
|
"square/square": "13.0.0.20210721",
|
||||||
"stripe/stripe-php": "^7.50",
|
"stripe/stripe-php": "^7.50",
|
||||||
"symfony/http-client": "^5.2",
|
"symfony/http-client": "^5.2",
|
||||||
@ -148,4 +150,4 @@
|
|||||||
},
|
},
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"prefer-stable": true
|
"prefer-stable": true
|
||||||
}
|
}
|
||||||
|
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),
|
'require_https' => env('REQUIRE_HTTPS', true),
|
||||||
'app_url' => rtrim(env('APP_URL', ''), '/'),
|
'app_url' => rtrim(env('APP_URL', ''), '/'),
|
||||||
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
|
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
|
||||||
'app_version' => '5.3.91',
|
'app_version' => '5.3.92',
|
||||||
'app_tag' => '5.3.91',
|
'app_tag' => '5.3.92',
|
||||||
'minimum_client_version' => '5.0.16',
|
'minimum_client_version' => '5.0.16',
|
||||||
'terms_version' => '1.0.1',
|
'terms_version' => '1.0.1',
|
||||||
'api_secret' => env('API_SECRET', ''),
|
'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 TEMP = 'flutter-temp-cache';
|
||||||
const CACHE_NAME = 'flutter-app-cache';
|
const CACHE_NAME = 'flutter-app-cache';
|
||||||
const RESOURCES = {
|
const RESOURCES = {
|
||||||
"main.dart.js": "01650cf247d1b2ef31e4bb84a76b28fd",
|
"main.dart.js": "b552020eead077b50b54a51de32ba513",
|
||||||
"canvaskit/canvaskit.wasm": "4b83d89d9fecbea8ca46f2f760c5a9ba",
|
"canvaskit/canvaskit.wasm": "4b83d89d9fecbea8ca46f2f760c5a9ba",
|
||||||
"canvaskit/profiling/canvaskit.wasm": "95e736ab31147d1b2c7b25f11d4c32cd",
|
"canvaskit/profiling/canvaskit.wasm": "95e736ab31147d1b2c7b25f11d4c32cd",
|
||||||
"canvaskit/profiling/canvaskit.js": "ae2949af4efc61d28a4a80fffa1db900",
|
"canvaskit/profiling/canvaskit.js": "ae2949af4efc61d28a4a80fffa1db900",
|
||||||
"canvaskit/canvaskit.js": "c2b4e5f3d7a3d82aed024e7249a78487",
|
"canvaskit/canvaskit.js": "c2b4e5f3d7a3d82aed024e7249a78487",
|
||||||
"flutter.js": "0816e65a103ba8ba51b174eeeeb2cb67",
|
"flutter.js": "0816e65a103ba8ba51b174eeeeb2cb67",
|
||||||
"/": "eea3dd0db9e972492cf345e1d6676daf",
|
"/": "15b97e9f966c26d599d1d9c0ecd01354",
|
||||||
"favicon.png": "dca91c54388f52eded692718d5a98b8b",
|
"favicon.png": "dca91c54388f52eded692718d5a98b8b",
|
||||||
"version.json": "3afb81924daf4f751571755436069115",
|
"version.json": "3afb81924daf4f751571755436069115",
|
||||||
"assets/AssetManifest.json": "38d9aea341601f3a5c6fa7b5a1216ea5",
|
"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">
|
<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>
|
<div class="alert py-2 bg-white" id="test-pdf-response"></div>
|
||||||
</dd>
|
</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>
|
</div>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user