mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Fixes for updating pdf_variables in CompanySettings (#3465)
* Fixes for setting pdf_variables in company settings * Fixes for company settings saver
This commit is contained in:
parent
25e29ed54c
commit
efa6350008
@ -224,7 +224,7 @@ class CompanySettings extends BaseSettings {
|
||||
public $embed_documents = false;
|
||||
public $all_pages_header = false;
|
||||
public $all_pages_footer = false;
|
||||
public $pdf_variables = [];
|
||||
public $pdf_variables = '';
|
||||
|
||||
public static $casts = [
|
||||
'portal_design_id' => 'string',
|
||||
@ -429,7 +429,7 @@ class CompanySettings extends BaseSettings {
|
||||
$data->date_format_id = (string) config('ninja.i18n.date_format_id');
|
||||
$data->country_id = (string) config('ninja.i18n.country_id');
|
||||
$data->translations = (object) [];
|
||||
$data->pdf_variables = (array) self::getEntityVariableDefaults();
|
||||
$data->pdf_variables = (object) self::getEntityVariableDefaults();
|
||||
|
||||
// $data->email_subject_invoice = EmailTemplateDefaults::emailInvoiceSubject();
|
||||
// $data->email_template_invoice = EmailTemplateDefaults:: emailInvoiceTemplate();
|
||||
@ -479,6 +479,7 @@ class CompanySettings extends BaseSettings {
|
||||
}
|
||||
|
||||
private static function getEntityVariableDefaults() {
|
||||
|
||||
$variables = [
|
||||
'client_details' => [
|
||||
'name',
|
||||
@ -546,7 +547,7 @@ class CompanySettings extends BaseSettings {
|
||||
'line_total'
|
||||
],
|
||||
];
|
||||
|
||||
return $variables;
|
||||
|
||||
return json_decode(json_encode($variables));
|
||||
}
|
||||
}
|
||||
|
@ -42,9 +42,9 @@ trait CompanySettingsSaver
|
||||
$settings = $this->checkSettingType($settings);
|
||||
|
||||
$company_settings = CompanySettings::defaults();
|
||||
|
||||
//Iterate and set NEW settings
|
||||
foreach ($settings as $key => $value) {
|
||||
|
||||
if (is_null($settings->{$key})) {
|
||||
$company_settings->{$key} = '';
|
||||
} else {
|
||||
@ -73,8 +73,8 @@ trait CompanySettingsSaver
|
||||
|
||||
$casts = CompanySettings::$casts;
|
||||
|
||||
if(property_exists($settings, 'pdf_variables'))
|
||||
unset($settings->pdf_variables);
|
||||
// if(property_exists($settings, 'pdf_variables'))
|
||||
// unset($settings->pdf_variables);
|
||||
|
||||
ksort($casts);
|
||||
|
||||
@ -103,6 +103,9 @@ trait CompanySettingsSaver
|
||||
|
||||
continue;
|
||||
}
|
||||
elseif($key == 'pdf_variables') {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Handles unset settings or blank strings */
|
||||
if (!property_exists($settings, $key) || is_null($settings->{$key}) || !isset($settings->{$key}) || $settings->{$key} == '')
|
||||
@ -174,6 +177,9 @@ trait CompanySettingsSaver
|
||||
|
||||
continue;
|
||||
}
|
||||
elseif($key == 'pdf_variables') {
|
||||
settype($settings->{$key}, 'object');
|
||||
}
|
||||
|
||||
/* Handles unset settings or blank strings */
|
||||
if (!property_exists($settings, $key) || is_null($settings->{$key}) || !isset($settings->{$key}) || $settings->{$key} == '')
|
||||
|
@ -70,8 +70,8 @@ trait SettingsSaver
|
||||
$settings = (object)$settings;
|
||||
$casts = CompanySettings::$casts;
|
||||
|
||||
if(property_exists($settings, 'pdf_variables'))
|
||||
unset($settings->pdf_variables);
|
||||
// if(property_exists($settings, 'pdf_variables'))
|
||||
// unset($settings->pdf_variables);
|
||||
|
||||
ksort($casts);
|
||||
|
||||
@ -98,6 +98,9 @@ trait SettingsSaver
|
||||
|
||||
continue;
|
||||
}
|
||||
elseif($key == 'pdf_variables') {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Handles unset settings or blank strings */
|
||||
if (!property_exists($settings, $key) || is_null($settings->{$key}) || !isset($settings->{$key}) || $settings->{$key} == '') {
|
||||
|
Loading…
x
Reference in New Issue
Block a user