mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-09 20:52:56 +01:00
Refactor custom fields
This commit is contained in:
parent
eeddf4fea8
commit
721b48c73f
@ -161,8 +161,6 @@ class Account extends Eloquent
|
||||
'gateway_fee_enabled',
|
||||
'send_item_details',
|
||||
'reset_counter_date',
|
||||
'custom_contact_label1',
|
||||
'custom_contact_label2',
|
||||
'domain_id',
|
||||
'analytics_key',
|
||||
'credit_number_counter',
|
||||
@ -172,6 +170,9 @@ class Account extends Eloquent
|
||||
'inclusive_taxes',
|
||||
'convert_products',
|
||||
'signature_on_pdf',
|
||||
'custom_fields',
|
||||
'custom_value1',
|
||||
'custom_value2',
|
||||
];
|
||||
|
||||
/**
|
||||
@ -503,6 +504,10 @@ class Account extends Eloquent
|
||||
{
|
||||
$fields = [];
|
||||
|
||||
if (! is_array($data)) {
|
||||
$data = json_decode($data);
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
if ($value) {
|
||||
$fields[$key] = $value;
|
||||
|
@ -195,20 +195,20 @@ class AccountPresenter extends Presenter
|
||||
public function customTextFields()
|
||||
{
|
||||
$fields = [
|
||||
'custom_client_label1' => 'custom_client1',
|
||||
'custom_client_label2' => 'custom_client2',
|
||||
'custom_contact_label1' => 'custom_contact1',
|
||||
'custom_contact_label2' => 'custom_contact2',
|
||||
'custom_invoice_text_label1' => 'custom_invoice1',
|
||||
'custom_invoice_text_label2' => 'custom_invoice2',
|
||||
'custom_invoice_item_label1' => 'custom_product1',
|
||||
'custom_invoice_item_label2' => 'custom_product2',
|
||||
'client1' => 'custom_client1',
|
||||
'client1' => 'custom_client2',
|
||||
'contact1' => 'custom_contact1',
|
||||
'contact2' => 'custom_contact2',
|
||||
'invoice_text1' => 'custom_invoice1',
|
||||
'invoice_text2' => 'custom_invoice2',
|
||||
'product1' => 'custom_product1',
|
||||
'product2' => 'custom_product2',
|
||||
];
|
||||
$data = [];
|
||||
|
||||
foreach ($fields as $key => $val) {
|
||||
if ($this->$key) {
|
||||
$data[Utils::getCustomLabel($this->$key)] = [
|
||||
if ($label = $this->customLabel($key)) {
|
||||
$data[Utils::getCustomLabel($label)] = [
|
||||
'value' => $val,
|
||||
'name' => $val,
|
||||
];
|
||||
|
@ -179,18 +179,10 @@ class AccountTransformer extends EntityTransformer
|
||||
'fill_products' => (bool) $account->fill_products,
|
||||
'update_products' => (bool) $account->update_products,
|
||||
'vat_number' => $account->vat_number,
|
||||
'custom_invoice_label1' => $account->customLabel('invoice1'),
|
||||
'custom_invoice_label2' => $account->customLabel('invoice2'),
|
||||
'custom_invoice_taxes1' => $account->custom_invoice_taxes1,
|
||||
'custom_invoice_taxes2' => $account->custom_invoice_taxes1,
|
||||
'custom_label1' => $account->custom_label1,
|
||||
'custom_label2' => $account->custom_label2,
|
||||
'custom_value1' => $account->custom_value1,
|
||||
'custom_value2' => $account->custom_value2,
|
||||
'primary_color' => $account->primary_color,
|
||||
'secondary_color' => $account->secondary_color,
|
||||
'custom_client_label1' => $account->customLabel('client1'),
|
||||
'custom_client_label2' => $account->customLabel('client2'),
|
||||
'hide_quantity' => (bool) $account->hide_quantity,
|
||||
'hide_paid_to_date' => (bool) $account->hide_paid_to_date,
|
||||
'invoice_number_prefix' => $account->invoice_number_prefix,
|
||||
@ -215,8 +207,6 @@ class AccountTransformer extends EntityTransformer
|
||||
'num_days_reminder1' => $account->num_days_reminder1,
|
||||
'num_days_reminder2' => $account->num_days_reminder2,
|
||||
'num_days_reminder3' => $account->num_days_reminder3,
|
||||
'custom_invoice_text_label1' => $account->customLabel('invoice_text1'),
|
||||
'custom_invoice_text_label2' => $account->customLabel('invoice_text2'),
|
||||
'tax_name1' => $account->tax_name1 ?: '',
|
||||
'tax_rate1' => (float) $account->tax_rate1,
|
||||
'tax_name2' => $account->tax_name2 ?: '',
|
||||
@ -245,8 +235,6 @@ class AccountTransformer extends EntityTransformer
|
||||
'show_currency_code' => (bool) $account->show_currency_code,
|
||||
'enable_portal_password' => (bool) $account->enable_portal_password,
|
||||
'send_portal_password' => (bool) $account->send_portal_password,
|
||||
'custom_invoice_item_label1' => $account->customLabel('product1'),
|
||||
'custom_invoice_item_label2' => $account->customLabel('product2'),
|
||||
'recurring_invoice_number_prefix' => $account->recurring_invoice_number_prefix,
|
||||
'enable_client_portal' => (bool) $account->enable_client_portal,
|
||||
'invoice_fields' => $account->invoice_fields,
|
||||
@ -277,12 +265,25 @@ class AccountTransformer extends EntityTransformer
|
||||
'gateway_fee_enabled' => (bool) $account->gateway_fee_enabled,
|
||||
'send_item_details' => (bool) $account->send_item_details,
|
||||
'reset_counter_date' => $account->reset_counter_date,
|
||||
'custom_contact_label1' => $account->customLabel('contact1'),
|
||||
'custom_contact_label2' => $account->customLabel('contact2'),
|
||||
'task_rate' => (float) $account->task_rate,
|
||||
'inclusive_taxes' => (bool) $account->inclusive_taxes,
|
||||
'convert_products' => (bool) $account->convert_products,
|
||||
'signature_on_pdf' => (bool) $account->signature_on_pdf,
|
||||
'custom_invoice_taxes1' => $account->custom_invoice_taxes1,
|
||||
'custom_invoice_taxes2' => $account->custom_invoice_taxes1,
|
||||
'custom_fields' => json_encode($account->custom_fields),
|
||||
'custom_invoice_label1' => $account->customLabel('invoice1'),
|
||||
'custom_invoice_label2' => $account->customLabel('invoice2'),
|
||||
'custom_client_label1' => $account->customLabel('client1'),
|
||||
'custom_client_label2' => $account->customLabel('client2'),
|
||||
'custom_contact_label1' => $account->customLabel('contact1'),
|
||||
'custom_contact_label2' => $account->customLabel('contact2'),
|
||||
'custom_label1' => $account->customLabel('account1'),
|
||||
'custom_label2' => $account->customLabel('account2'),
|
||||
'custom_invoice_text_label1' => $account->customLabel('invoice_text1'),
|
||||
'custom_invoice_text_label2' => $account->customLabel('invoice_text2'),
|
||||
'custom_invoice_item_label1' => $account->customLabel('product1'),
|
||||
'custom_invoice_item_label2' => $account->customLabel('product2'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -42,8 +42,8 @@
|
||||
{!! Former::checkboxes('json_include_radio')
|
||||
->label(trans('texts.include'))
|
||||
->checkboxes([
|
||||
trans('texts.data') => 'data',
|
||||
trans('texts.settings') => 'settings',
|
||||
trans('texts.data') => 'data',
|
||||
]) !!}
|
||||
</div>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user