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