1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-22 09:21:34 +02:00

Merge pull request #9521 from turbo124/v5-develop

v5.8.56
This commit is contained in:
David Bomba 2024-05-15 09:31:46 +10:00 committed by GitHub
commit 5b19bf9bca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 92 additions and 42 deletions

View File

@ -1 +1 @@
5.8.55
5.8.56

View File

@ -705,8 +705,25 @@ class CompanyController extends BaseController
$logo = strlen($company->settings->company_logo) > 5 ? $company->settings->company_logo : 'https://pdf.invoicing.co/favicon-v2.png';
$headers = ['Content-Disposition' => 'inline'];
try{
$response = \Illuminate\Support\Facades\Http::get($logo);
if ($response->successful()) {
$logo = $response->body();
}
else {
$logo = base64_decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=');
}
}
catch(\Exception $e){
$logo = base64_decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=');
}
return response()->streamDownload(function () use ($logo) {
echo @file_get_contents($logo);
echo $logo;
}, 'logo.png', $headers);
}

View File

@ -121,7 +121,8 @@ class DocumentController extends BaseController
}
return response()->streamDownload(function () use ($document) {
echo file_get_contents($document->generateUrl());
// echo file_get_contents($document->generateUrl());
echo $document->getFile();
}, basename($document->generateUrl()), $headers);
}

View File

@ -137,9 +137,12 @@ class UpdateCompanyRequest extends Request
}
if (isset($settings['email_style_custom'])) {
$settings['email_style_custom'] = str_replace(['{!!','!!}','{{','}}','@if(','@endif','@isset','@unless','@auth','@empty','@guest','@env','@section','@switch', '@foreach', '@while', '@include', '@each', '@once', '@push', '@use', '@forelse', '@verbatim', '<?php', '@php', '@for'], '', $settings['email_style_custom']);
$settings['email_style_custom'] = str_replace(['{!!','!!}','{{','}}','@dd', '@dump', '@if', '@if(','@endif','@isset','@unless','@auth','@empty','@guest','@env','@section','@switch', '@foreach', '@while', '@include', '@each', '@once', '@push', '@use', '@forelse', '@verbatim', '<?php', '@php', '@for','@class','</s','<s','html;base64'], '', $settings['email_style_custom']);
}
if(isset($settings['company_logo']) && strlen($settings['company_logo']) > 2)
$settings['company_logo'] = $this->forceScheme($settings['company_logo']);
if (! $account->isFreeHostedClient()) {
return $settings;
}
@ -164,4 +167,9 @@ class UpdateCompanyRequest extends Request
return rtrim($url, '/');
}
private function forceScheme($url){
return stripos($url, 'http') !== false ? $url : "https://{$url}";
}
}

View File

@ -215,6 +215,14 @@ class CompanyImport implements ShouldQueue
"convert_rate_to_client",
];
private array $protected_input = [
'client_portal_privacy_policy',
'client_portal_terms',
'portal_custom_footer',
'portal_custom_css',
'portal_custom_head'
];
private array $version_keys = [
'baseline' => [],
'5.7.35' => [
@ -475,9 +483,16 @@ class CompanyImport implements ShouldQueue
$settings->payment_number_counter = 1;
$settings->project_number_counter = 1;
$settings->purchase_order_number_counter = 1;
$this->company->settings = $co->settings;
$this->company->saveSettings($co->settings, $this->company);
$settings->email_style_custom = str_replace(['{!!','!!}','{{','}}','@dd', '@dump', '@if', '@if(','@endif','@isset','@unless','@auth','@empty','@guest','@env','@section','@switch', '@foreach', '@while', '@include', '@each', '@once', '@push', '@use', '@forelse', '@verbatim', '<?php', '@php', '@for','@class','</s','<s','html;base64'], '', $settings->email_style_custom);
$settings->company_logo = (strlen($settings->company_logo) > 2 && stripos($settings->company_logo, 'http') !== false) ? $settings->company_logo : "https://{$settings->company_logo}";
foreach($this->protected_input as $protected_var)
{
$settings->{$protected_var} = str_replace("script", "", $settings->{$protected_var});
}
$this->company->saveSettings($settings, $this->company);
$this->company->save();

View File

@ -103,7 +103,7 @@ class CreateUbl implements ShouldQueue
$ubl_invoice->setLegalMonetaryTotal((new LegalMonetaryTotal())
//->setLineExtensionAmount()
->setTaxInclusiveAmount($taxtotal->getTaxAmount())
->setTaxInclusiveAmount($invoice->balance)
->setTaxExclusiveAmount($taxable)
->setPayableAmount($invoice->balance));

View File

@ -88,7 +88,6 @@ class CompanyPresenter extends EntityPresenter
return "data:image/png;base64, ". base64_encode(@file_get_contents(url('') . $settings->company_logo, false, stream_context_create($context_options)));
} else {
return "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";
//return "data:image/png;base64, ". base64_encode(@file_get_contents(asset('images/new_logo.png'), false, stream_context_create($context_options)));
}
}

View File

@ -144,6 +144,9 @@ class ClientRepository extends BaseRepository
public function purge($client)
{
nlog("Purging client id => {$client->id}");
$client->contacts()->forceDelete();
$client->tasks()->forceDelete();
$client->invoices()->forceDelete();

View File

@ -56,9 +56,6 @@ class TemplateMock
$this->engines['payments'] = json_decode($this->payment_data, true);
$this->engines['purchase_orders'] = json_decode($this->purchase_order_data, true);
// nlog("engines");
// nlog($this->engines);
return $this;
}

View File

@ -94,6 +94,7 @@ class TemplateService
$this->twig = new \Twig\Environment($loader, [
'debug' => true,
]);
$string_extension = new \Twig\Extension\StringLoaderExtension();
$this->twig->addExtension($string_extension);
$this->twig->addExtension(new IntlExtension());
@ -121,6 +122,26 @@ class TemplateService
$this->twig->addFilter($filter);
$filter = new \Twig\TwigFilter('filter', function ($array, $arrow){
if(is_string($arrow) && in_array($arrow, ['popen','exec','shell_exec','system','passthru','proc_open','pcntl_exec','sleep','escapeshellcmd','escapeshellarg']))
throw new RuntimeError("Attempt to access command line");
if (!is_iterable($array)) {
throw new RuntimeError(sprintf('The "filter" filter expects an array or "Traversable", got "%s".', \is_object($array) ? \get_class($array) : \gettype($array)));
}
if (\is_array($array)) {
return array_filter($array, $arrow, \ARRAY_FILTER_USE_BOTH);
}
// the IteratorIterator wrapping is needed as some internal PHP classes are \Traversable but do not implement \Iterator
return new \CallbackFilterIterator(new \IteratorIterator($array), $arrow);
});
$this->twig->addFilter($filter);
return $this;
}
@ -240,7 +261,7 @@ class TemplateService
*/
public function getPdf(): string
{
if (config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja') {
$pdf = (new NinjaPdf())->build($this->compiled_html);
} else {
@ -271,7 +292,7 @@ class TemplateService
{
$this->data = $this->preProcessDataBlocks($data);
// nlog(json_encode($this->data));
return $this;
}
@ -1211,12 +1232,8 @@ class TemplateService
});
})->toArray();
// nlog($company_details);
$company_details = $include_labels ? $this->labelledFieldStack($company_details, 'company_details-') : $company_details;
// nlog($company_details);
$this->updateElementProperties('company-details', $company_details);
return $this;

View File

@ -44,29 +44,6 @@ trait MakesInvoiceHtml
return Blade::render($string, $data); //potential fix for removing eval()
// $php = Blade::compileString($string);
// $obLevel = ob_get_level();
// ob_start();
// extract($data, EXTR_SKIP);
// try {
// eval('?'.'>'.$php);
// } catch (Exception $e) {
// while (ob_get_level() > $obLevel) {
// ob_end_clean();
// }
// throw $e;
// } catch (Throwable $e) {
// while (ob_get_level() > $obLevel) {
// ob_end_clean();
// }
// throw new \Exception($e->getMessage());
// }
// return ob_get_clean();
}
/*

View File

@ -17,8 +17,8 @@ return [
'require_https' => env('REQUIRE_HTTPS', true),
'app_url' => rtrim(env('APP_URL', ''), '/'),
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
'app_version' => env('APP_VERSION', '5.8.55'),
'app_tag' => env('APP_TAG', '5.8.55'),
'app_version' => env('APP_VERSION', '5.8.56'),
'app_tag' => env('APP_TAG', '5.8.56'),
'minimum_client_version' => '5.0.16',
'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', false),

View File

@ -5304,6 +5304,22 @@ $lang = array(
'always_show_required_fields_help' => 'Displays the required fields form always at checkout',
'advanced_cards' => 'Advanced Cards',
'activity_140' => 'Statement sent to :client',
'invoice_net_amount' => 'Invoice Net Amount',
'round_to_minutes' => 'Round To Minutes',
'1_minute' => '1 Minute',
'5_minutes' => '5 Minutes',
'15_minutes' => '15 Minutes',
'30_minutes' => '30 Minutes',
'1_hour' => '1 Hour',
'1_day' => '1 Day',
'round_tasks' => 'Round Tasks',
'round_tasks_help' => 'Round time intervals when saving tasks',
'direction' => 'Direction',
'round_up' => 'Round Up',
'round_down' => 'Round Down',
'task_round_to_nearest' => 'Round To Nearest',
'bulk_updated' => 'Successfully updated data',
'bulk_update' => 'Bulk Update',
);
return $lang;