1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-09 12:42:36 +01:00

Refactor custom fields

This commit is contained in:
Hillel Coren 2018-04-04 16:24:59 +03:00
parent dba0d28a68
commit eeddf4fea8
33 changed files with 325 additions and 419 deletions

View File

@ -569,10 +569,10 @@ class AccountController extends BaseController
$client->vat_number = $account->vat_number ? '1234567890' : '';
$client->id_number = $account->id_number ? '1234567890' : '';
if ($account->custom_client_label1) {
if ($account->customLabel('client1')) {
$client->custom_value1 = '0000';
}
if ($account->custom_client_label2) {
if ($account->customLabel('client2')) {
$client->custom_value2 = '0000';
}
@ -581,10 +581,10 @@ class AccountController extends BaseController
$invoice->account = json_decode($account->toJson());
$invoice->amount = $invoice->balance = 100;
if ($account->custom_invoice_text_label1) {
if ($account->customLabel('invoice_text1')) {
$invoice->custom_text_value1 = '0000';
}
if ($account->custom_invoice_text_label2) {
if ($account->customLabel('invoice_text2')) {
$invoice->custom_text_value2 = '0000';
}
@ -604,10 +604,10 @@ class AccountController extends BaseController
$invoiceItem->tax_name1 = 'Tax';
$invoiceItem->tax_rate1 = 10;
if ($account->custom_invoice_item_label1) {
if ($account->customLabel('product1')) {
$invoiceItem->custom_value1 = '0000';
}
if ($account->custom_invoice_item_label2) {
if ($account->customLabel('product2')) {
$invoiceItem->custom_value2 = '0000';
}
@ -976,23 +976,11 @@ class AccountController extends BaseController
->withInput();
} else {
$account = Auth::user()->account;
$account->custom_label1 = trim(Input::get('custom_label1'));
$account->custom_value1 = trim(Input::get('custom_value1'));
$account->custom_label2 = trim(Input::get('custom_label2'));
$account->custom_value2 = trim(Input::get('custom_value2'));
$account->custom_client_label1 = trim(Input::get('custom_client_label1'));
$account->custom_client_label2 = trim(Input::get('custom_client_label2'));
$account->custom_contact_label1 = trim(Input::get('custom_contact_label1'));
$account->custom_contact_label2 = trim(Input::get('custom_contact_label2'));
$account->custom_invoice_label1 = trim(Input::get('custom_invoice_label1'));
$account->custom_invoice_label2 = trim(Input::get('custom_invoice_label2'));
$account->custom_value1 = Input::get('custom_value1');
$account->custom_value2 = Input::get('custom_value2');
$account->custom_invoice_taxes1 = Input::get('custom_invoice_taxes1') ? true : false;
$account->custom_invoice_taxes2 = Input::get('custom_invoice_taxes2') ? true : false;
$account->custom_invoice_text_label1 = trim(Input::get('custom_invoice_text_label1'));
$account->custom_invoice_text_label2 = trim(Input::get('custom_invoice_text_label2'));
$account->custom_invoice_item_label1 = trim(Input::get('custom_invoice_item_label1'));
$account->custom_invoice_item_label2 = trim(Input::get('custom_invoice_item_label2'));
$account->custom_fields = request()->custom_fields;
$account->invoice_number_padding = Input::get('invoice_number_padding');
$account->invoice_number_counter = Input::get('invoice_number_counter');
$account->quote_number_prefix = Input::get('quote_number_prefix');

View File

@ -197,8 +197,8 @@ class ClientController extends BaseController
'data' => Input::old('data'),
'account' => Auth::user()->account,
'sizes' => Cache::get('sizes'),
'customLabel1' => Auth::user()->account->custom_client_label1,
'customLabel2' => Auth::user()->account->custom_client_label2,
'customLabel1' => Auth::user()->account->customLabel('client1'),
'customLabel2' => Auth::user()->account->customLabel('client2'),
];
}

View File

@ -219,6 +219,19 @@ class Account extends Eloquent
'outstanding' => 4,
];
public static $customFields = [
'client1',
'client2',
'contact1',
'contact2',
'product1',
'product2',
'invoice1',
'invoice2',
'invoice_surcharge1',
'invoice_surcharge2',
];
public static $customLabels = [
'balance_due',
'credit_card',
@ -483,6 +496,34 @@ class Account extends Eloquent
$this->attributes['size_id'] = $value ?: null;
}
/**
* @param $value
*/
public function setCustomFieldsAttribute($data)
{
$fields = [];
foreach ($data as $key => $value) {
if ($value) {
$fields[$key] = $value;
}
}
$this->attributes['custom_fields'] = count($fields) ? json_encode($fields) : null;
}
public function getCustomFieldsAttribute($value)
{
return json_decode($value ?: '{}');
}
public function customLabel($field)
{
$labels = $this->custom_fields;
return ! empty($labels->$field) ? $labels->$field : '';
}
/**
* @param int $gatewayId
*
@ -1462,28 +1503,6 @@ class Account extends Eloquent
return true;
}
/**
* @param $field
* @param bool $entity
*
* @return bool
*/
public function showCustomField($field, $entity = false)
{
if ($this->hasFeature(FEATURE_INVOICE_SETTINGS) && $this->$field) {
return true;
}
if (! $entity) {
return false;
}
// convert (for example) 'custom_invoice_label1' to 'invoice.custom_value1'
$field = str_replace(['invoice_', 'label'], ['', 'value'], $field);
return Utils::isEmpty($entity->$field) ? false : true;
}
/**
* @return bool
*/

View File

@ -1,32 +0,0 @@
<?php
namespace App\Models;
use Eloquent;
/**
* Class Account.
*/
class AccountCustomSettings extends Eloquent
{
/**
* @var array
*/
protected $fillable = [
'custom_label1',
'custom_value1',
'custom_label2',
'custom_value2',
'custom_client_label1',
'custom_client_label2',
'custom_invoice_label1',
'custom_invoice_label2',
'custom_invoice_taxes1',
'custom_invoice_taxes2',
'custom_invoice_text_label1',
'custom_invoice_text_label2',
'custom_invoice_item_label1',
'custom_invoice_item_label2',
];
}

View File

@ -1001,28 +1001,17 @@ class Invoice extends EntityModel implements BalanceAffecting
'country',
'country_id',
'currency_id',
'custom_label1',
'custom_fields',
'custom_value1',
'custom_label2',
'custom_value2',
'custom_client_label1',
'custom_client_label2',
'custom_contact_label1',
'custom_contact_label2',
'primary_color',
'secondary_color',
'hide_quantity',
'hide_paid_to_date',
'all_pages_header',
'all_pages_footer',
'custom_invoice_label1',
'custom_invoice_label2',
'pdf_email_attachment',
'show_item_taxes',
'custom_invoice_text_label1',
'custom_invoice_text_label2',
'custom_invoice_item_label1',
'custom_invoice_item_label2',
'invoice_embed_documents',
'page_size',
'include_item_taxes_inline',

View File

@ -101,22 +101,22 @@ trait PresentsInvoice
]
];
if ($this->custom_invoice_text_label1) {
if ($this->customLabel('invoice_text1')) {
$fields[INVOICE_FIELDS_INVOICE][] = 'invoice.custom_text_value1';
}
if ($this->custom_invoice_text_label2) {
if ($this->customLabel('invoice_text2')) {
$fields[INVOICE_FIELDS_INVOICE][] = 'invoice.custom_text_value2';
}
if ($this->custom_client_label1) {
if ($this->customLabel('client1')) {
$fields[INVOICE_FIELDS_CLIENT][] = 'client.custom_value1';
}
if ($this->custom_client_label2) {
if ($this->customLabel('client2')) {
$fields[INVOICE_FIELDS_CLIENT][] = 'client.custom_value2';
}
if ($this->custom_contact_label1) {
if ($this->customLabel('contact1')) {
$fields[INVOICE_FIELDS_CLIENT][] = 'contact.custom_value1';
}
if ($this->custom_contact_label2) {
if ($this->customLabel('contact2')) {
$fields[INVOICE_FIELDS_CLIENT][] = 'contact.custom_value2';
}
if ($this->custom_label1) {
@ -354,18 +354,18 @@ trait PresentsInvoice
}
foreach ([
'account.custom_value1' => 'custom_label1',
'account.custom_value2' => 'custom_label2',
'invoice.custom_text_value1' => 'custom_invoice_text_label1',
'invoice.custom_text_value2' => 'custom_invoice_text_label2',
'client.custom_value1' => 'custom_client_label1',
'client.custom_value2' => 'custom_client_label2',
'contact.custom_value1' => 'custom_contact_label1',
'contact.custom_value2' => 'custom_contact_label2',
'product.custom_value1' => 'custom_invoice_item_label1',
'product.custom_value2' => 'custom_invoice_item_label2',
'account.custom_value1' => 'account1',
'account.custom_value2' => 'account2',
'invoice.custom_text_value1' => 'invoice_text1',
'invoice.custom_text_value2' => 'invoice_text2',
'client.custom_value1' => 'client1',
'client.custom_value2' => 'client2',
'contact.custom_value1' => 'contact1',
'contact.custom_value2' => 'contact2',
'product.custom_value1' => 'product1',
'product.custom_value2' => 'product2',
] as $field => $property) {
$data[$field] = e(Utils::getCustomLabel($this->$property)) ?: trans('texts.custom_field');
$data[$field] = e($this->present()->customLabel($property)) ?: trans('texts.custom_field');
}
return $data;

View File

@ -47,14 +47,14 @@ class ProductDatatable extends EntityDatatable
function ($model) {
return $model->custom_value1;
},
$account->custom_invoice_item_label1
$account->customLabel('product1')
],
[
'custom_value2',
function ($model) {
return $model->custom_value2;
},
$account->custom_invoice_item_label2
$account->customLabel('product2')
]
];
}

View File

@ -265,55 +265,8 @@ class AccountPresenter extends Presenter
return $url;
}
public function customClientLabel1()
public function customLabel($field)
{
return Utils::getCustomLabel($this->entity->custom_client_label1);
return Utils::getCustomLabel($this->entity->customLabel($field));
}
public function customClientLabel2()
{
return Utils::getCustomLabel($this->entity->custom_client_label2);
}
public function customContactLabel1()
{
return Utils::getCustomLabel($this->entity->custom_contact_label1);
}
public function customContactLabel2()
{
return Utils::getCustomLabel($this->entity->custom_contact_label2);
}
public function customInvoiceLabel1()
{
return Utils::getCustomLabel($this->entity->custom_invoice_label1);
}
public function customInvoiceLabel2()
{
return Utils::getCustomLabel($this->entity->custom_invoice_label2);
}
public function customInvoiceTextLabel1()
{
return Utils::getCustomLabel($this->entity->custom_invoice_text_label1);
}
public function customInvoiceTextLabel2()
{
return Utils::getCustomLabel($this->entity->custom_invoice_text_label1);
}
public function customProductLabel1()
{
return Utils::getCustomLabel($this->entity->custom_invoice_item_label1);
}
public function customProductLabel2()
{
return Utils::getCustomLabel($this->entity->custom_invoice_item_label2);
}
}

View File

@ -22,11 +22,11 @@ class ClientReport extends AbstractReport
$user = auth()->user();
$account = $user->account;
if ($account->custom_client_label1) {
$columns[$account->present()->customClientLabel1] = ['columnSelector-false', 'custom'];
if ($account->customLabel('client1')) {
$columns[$account->present()->customLabel('client1')] = ['columnSelector-false', 'custom'];
}
if ($account->custom_client_label2) {
$columns[$account->present()->customClientLabel2] = ['columnSelector-false', 'custom'];
if ($account->customLabel('client2')) {
$columns[$account->present()->customLabel('client2')] = ['columnSelector-false', 'custom'];
}
return $columns;
@ -75,10 +75,10 @@ class ClientReport extends AbstractReport
$client->user->getDisplayName(),
];
if ($account->custom_client_label1) {
if ($account->customLabel('client1')) {
$row[] = $client->custom_value1;
}
if ($account->custom_client_label2) {
if ($account->customLabel('client2')) {
$row[] = $client->custom_value2;
}

View File

@ -31,11 +31,11 @@ class InvoiceReport extends AbstractReport
$account = auth()->user()->account;
if ($account->custom_invoice_text_label1) {
$columns[$account->present()->customInvoiceTextLabel1] = ['columnSelector-false', 'custom'];
if ($account->customLabel('invoice_text1')) {
$columns[$account->present()->customLabel('invoice_text1')] = ['columnSelector-false', 'custom'];
}
if ($account->custom_invoice_text_label1) {
$columns[$account->present()->customInvoiceTextLabel2] = ['columnSelector-false', 'custom'];
if ($account->customLabel('invoice_text1')) {
$columns[$account->present()->customLabel('invoice_text2')] = ['columnSelector-false', 'custom'];
}
return $columns;
@ -108,10 +108,10 @@ class InvoiceReport extends AbstractReport
$row[] = $isFirst ? $account->formatMoney($invoice->getTaxTotal(), $client) : '';
}
if ($account->custom_invoice_text_label1) {
if ($account->customLabel('invoice_text1')) {
$row[] = $invoice->custom_text_value1;
}
if ($account->custom_invoice_text_label2) {
if ($account->customLabel('invoice_text2')) {
$row[] = $invoice->custom_text_value2;
}

View File

@ -31,12 +31,12 @@ class ProductReport extends AbstractReport
}
}
if ($account->custom_invoice_item_label1) {
$columns[$account->present()->customProductLabel1] = ['columnSelector-false', 'custom'];
if ($account->customLabel('product1')) {
$columns[$account->present()->customLabel('product1')] = ['columnSelector-false', 'custom'];
}
if ($account->custom_invoice_item_label2) {
$columns[$account->present()->customProductLabel2] = ['columnSelector-false', 'custom'];
if ($account->customLabel('product2')) {
$columns[$account->present()->customLabel('product2')] = ['columnSelector-false', 'custom'];
}
return $columns;
@ -81,11 +81,11 @@ class ProductReport extends AbstractReport
}
}
if ($account->custom_invoice_item_label1) {
if ($account->customLabel('product1')) {
$row[] = $item->custom_value1;
}
if ($account->custom_invoice_item_label2) {
if ($account->customLabel('product2')) {
$row[] = $item->custom_value2;
}

View File

@ -27,11 +27,11 @@ class QuoteReport extends AbstractReport
$account = auth()->user()->account;
if ($account->custom_invoice_text_label1) {
$columns[$account->present()->customInvoiceTextLabel1] = ['columnSelector-false', 'custom'];
if ($account->customLabel('invoice_text1')) {
$columns[$account->present()->customLabel('invoice_text1')] = ['columnSelector-false', 'custom'];
}
if ($account->custom_invoice_text_label1) {
$columns[$account->present()->customInvoiceTextLabel2] = ['columnSelector-false', 'custom'];
if ($account->customLabel('invoice_text1')) {
$columns[$account->present()->customLabel('invoice_text2')] = ['columnSelector-false', 'custom'];
}
return $columns;
@ -93,10 +93,10 @@ class QuoteReport extends AbstractReport
$row[] = $account->formatMoney($invoice->getTaxTotal(), $client);
}
if ($account->custom_invoice_text_label1) {
if ($account->customLabel('invoice_text1')) {
$row[] = $invoice->custom_text_value1;
}
if ($account->custom_invoice_text_label2) {
if ($account->customLabel('invoice_text2')) {
$row[] = $invoice->custom_text_value2;
}

View File

@ -169,11 +169,11 @@ class AccountRepository
];
// include custom client fields in search
if ($account->custom_client_label1) {
$data[$account->present()->customClientLabel1] = [];
if ($account->customLabel('client1')) {
$data[$account->present()->customLabel('client1')] = [];
}
if ($account->custom_client_label2) {
$data[$account->present()->customClientLabel2] = [];
if ($account->customLabel('client2')) {
$data[$account->present()->customLabel('client2')] = [];
}
if ($user->hasPermission('view_all')) {
@ -203,14 +203,14 @@ class AccountRepository
}
if ($client->custom_value1) {
$data[$account->present()->customClientLabel1][] = [
$data[$account->present()->customLabel('client1')][] = [
'value' => "{$client->custom_value1}: " . $client->getDisplayName(),
'tokens' => $client->custom_value1,
'url' => $client->present()->url,
];
}
if ($client->custom_value2) {
$data[$account->present()->customClientLabel2][] = [
$data[$account->present()->customLabel('client2')][] = [
'value' => "{$client->custom_value2}: " . $client->getDisplayName(),
'tokens' => $client->custom_value2,
'url' => $client->present()->url,

View File

@ -179,8 +179,8 @@ 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->custom_invoice_label1,
'custom_invoice_label2' => $account->custom_invoice_label2,
'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,
@ -189,8 +189,8 @@ class AccountTransformer extends EntityTransformer
'custom_value2' => $account->custom_value2,
'primary_color' => $account->primary_color,
'secondary_color' => $account->secondary_color,
'custom_client_label1' => $account->custom_client_label1,
'custom_client_label2' => $account->custom_client_label2,
'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 +215,8 @@ 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->custom_invoice_text_label1,
'custom_invoice_text_label2' => $account->custom_invoice_text_label2,
'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 +245,8 @@ 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->custom_invoice_item_label1,
'custom_invoice_item_label2' => $account->custom_invoice_item_label2,
'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,8 +277,8 @@ 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->custom_contact_label1,
'custom_contact_label2' => $account->custom_contact_label2,
'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,

View File

@ -3,6 +3,7 @@
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use App\Models\Account;
class AddMoreCustomFields extends Migration
{
@ -13,73 +14,58 @@ class AddMoreCustomFields extends Migration
*/
public function up()
{
Schema::create('account_custom_settings', function ($table) {
$table->increments('id');
$table->unsignedInteger('account_id')->index();
$table->timestamps();
$table->string('custom_account_label1')->nullable();
$table->string('custom_account_value1')->nullable();
$table->string('custom_account_label2')->nullable();
$table->string('custom_account_value2')->nullable();
$table->string('custom_client_label1')->nullable();
$table->string('custom_client_label2')->nullable();
$table->string('custom_invoice_label1')->nullable();
$table->string('custom_invoice_label2')->nullable();
$table->string('custom_invoice_taxes1')->nullable();
$table->string('custom_invoice_taxes2')->nullable();
$table->string('custom_invoice_text_label1')->nullable();
$table->string('custom_invoice_text_label2')->nullable();
$table->string('custom_product_label1')->nullable();
$table->string('custom_product_label2')->nullable();
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
Schema::table('accounts', function ($table) {
$table->mediumText('custom_fields')->nullable();
});
DB::statement('insert into account_custom_settings (account_id,
custom_account_label1,
custom_account_value1,
custom_account_label2,
custom_account_value2,
custom_client_label1,
custom_client_label2,
custom_invoice_label1,
custom_invoice_label2,
custom_invoice_taxes1,
custom_invoice_taxes2,
custom_invoice_text_label1,
custom_invoice_text_label2,
custom_product_label1,
custom_product_label2
)
select id,
custom_label1,
custom_value1,
custom_label2,
custom_value2,
custom_client_label1,
custom_client_label2,
custom_invoice_label1,
custom_invoice_label2,
custom_invoice_taxes1,
custom_invoice_taxes2,
custom_invoice_text_label1,
custom_invoice_text_label2,
custom_invoice_item_label1,
custom_invoice_item_label2
from accounts;');
$accounts = Account::where('custom_label1', '!=', '')
->orWhere('custom_label2', '!=', '')
->orWhere('custom_client_label1', '!=', '')
->orWhere('custom_client_label2', '!=', '')
->orWhere('custom_invoice_label1', '!=', '')
->orWhere('custom_invoice_label2', '!=', '')
->orWhere('custom_invoice_text_label1', '!=', '')
->orWhere('custom_invoice_text_label2', '!=', '')
->orWhere('custom_invoice_item_label1', '!=', '')
->orWhere('custom_invoice_item_label2', '!=', '')
->orderBy('id')
->get();
$fields = [
'account1' => 'custom_label1',
'account2' => 'custom_label2',
'client1' => 'custom_client_label1',
'client2' => 'custom_client_label2',
'invoice1' => 'custom_invoice_label1',
'invoice2' => 'custom_invoice_label2',
'invoice_text1' => 'custom_invoice_text_label1',
'invoice_text2' => 'custom_invoice_text_label2',
'product1' => 'custom_invoice_item_label1',
'product2' => 'custom_invoice_item_label2',
];
foreach ($accounts as $accounts) {
$config = [];
foreach ($fields as $key => $field) {
if ($account->$field) {
$config[$key] = $account->$field;
}
}
if (count($config)) {
$account->custom_fields = $config;
$account->save();
}
}
Schema::table('accounts', function ($table) {
$table->dropColumn('custom_label1');
$table->dropColumn('custom_value1');
$table->dropColumn('custom_label2');
$table->dropColumn('custom_value2');
$table->dropColumn('custom_client_label1');
$table->dropColumn('custom_client_label2');
$table->dropColumn('custom_invoice_label1');
$table->dropColumn('custom_invoice_label2');
$table->dropColumn('custom_invoice_taxes1');
$table->dropColumn('custom_invoice_taxes2');
$table->dropColumn('custom_invoice_text_label1');
$table->dropColumn('custom_invoice_text_label2');
$table->dropColumn('custom_invoice_item_label1');

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -689,13 +689,13 @@ NINJA.invoiceLines = function(invoice, isSecondTable) {
if (field == 'custom_value1') {
if (invoice.has_custom_item_value1) {
value = NINJA.getCustomLabel(account.custom_invoice_item_label1);
value = NINJA.getCustomLabel(account.custom_fields.product1);
} else {
continue;
}
} else if (field == 'custom_value2') {
if (invoice.has_custom_item_value2) {
value = NINJA.getCustomLabel(account.custom_invoice_item_label2);
value = NINJA.getCustomLabel(account.custom_fields.product2);
} else {
continue;
}
@ -935,10 +935,10 @@ NINJA.subtotals = function(invoice, hideBalance)
}
var customValue1 = NINJA.parseFloat(invoice.custom_value1);
var customValue1Label = account.custom_invoice_label1 || invoiceLabels.surcharge;
var customValue1Label = account.custom_fields.invoice1 || invoiceLabels.surcharge;
var customValue2 = NINJA.parseFloat(invoice.custom_value2);
var customValue2Label = account.custom_invoice_label2 || invoiceLabels.surcharge;
var customValue2Label = account.custom_fields.invoice2 || invoiceLabels.surcharge;
if (customValue1 && invoice.custom_taxes1 == '1') {
data.push([{text: customValue1Label, style: ['subtotalsLabel', 'customTax1Label']}, {text: formatMoneyInvoice(invoice.custom_value1, invoice), style: ['subtotals', 'customTax1']}]);
@ -1184,23 +1184,23 @@ NINJA.renderField = function(invoice, field, twoColumn) {
} else if (field == 'client.phone') {
value = contact.phone;
} else if (field == 'client.custom_value1') {
if (account.custom_client_label1 && client.custom_value1) {
label = NINJA.getCustomLabel(account.custom_client_label1);
if (account.custom_fields.client1 && client.custom_value1) {
label = NINJA.getCustomLabel(account.custom_fields.client1);
value = client.custom_value1;
}
} else if (field == 'client.custom_value2') {
if (account.custom_client_label2 && client.custom_value2) {
label = NINJA.getCustomLabel(account.custom_client_label2);
if (account.custom_fields.client2 && client.custom_value2) {
label = NINJA.getCustomLabel(account.custom_fields.client2);
value = client.custom_value2;
}
} else if (field == 'contact.custom_value1') {
if (account.custom_contact_label1 && contact.custom_value1) {
label = NINJA.getCustomLabel(account.custom_contact_label1);
if (account.custom_fields.contact1 && contact.custom_value1) {
label = NINJA.getCustomLabel(account.custom_fields.contact1);
value = contact.custom_value1;
}
} else if (field == 'contact.custom_value2') {
if (account.custom_contact_label2 && contact.custom_value2) {
label = NINJA.getCustomLabel(account.custom_contact_label2);
if (account.custom_fields.contact2 && contact.custom_value2) {
label = NINJA.getCustomLabel(account.custom_fields.contact2);
value = contact.custom_value2;
}
} else if (field == 'account.company_name') {
@ -1241,13 +1241,13 @@ NINJA.renderField = function(invoice, field, twoColumn) {
} else if (field == 'account.country') {
value = account.country ? account.country.name : false;
} else if (field == 'account.custom_value1') {
if (invoice.account.custom_label1 && invoice.account.custom_value1) {
label = invoice.account.custom_label1;
if (invoice.account.custom_fields.account1 && invoice.account.custom_value1) {
label = invoice.account.custom_fields.account1;
value = invoice.account.custom_value1;
}
} else if (field == 'account.custom_value2') {
if (invoice.account.custom_label2 && invoice.account.custom_value2) {
label = invoice.account.custom_label2;
if (invoice.account.custom_fields.account2 && invoice.account.custom_value2) {
label = invoice.account.custom_fields.account2;
value = invoice.account.custom_value2;
}
} else if (field == 'invoice.invoice_number') {
@ -1268,13 +1268,13 @@ NINJA.renderField = function(invoice, field, twoColumn) {
value = invoice.due_date;
}
} else if (field == 'invoice.custom_text_value1') {
if (invoice.custom_text_value1 && account.custom_invoice_text_label1) {
label = NINJA.getCustomLabel(invoice.account.custom_invoice_text_label1);
if (invoice.custom_text_value1 && account.custom_fields.invoice_text1) {
label = NINJA.getCustomLabel(invoice.account.custom_fields.invoice_text1);
value = invoice.is_recurring ? processVariables(invoice.custom_text_value1) : invoice.custom_text_value1;
}
} else if (field == 'invoice.custom_text_value2') {
if (invoice.custom_text_value2 && account.custom_invoice_text_label2) {
label = NINJA.getCustomLabel(invoice.account.custom_invoice_text_label2);
if (invoice.custom_text_value2 && account.custom_fields.invoice_text2) {
label = NINJA.getCustomLabel(invoice.account.custom_fields.invoice_text2);
value = invoice.is_recurring ? processVariables(invoice.custom_text_value2) : invoice.custom_text_value2;
}
} else if (field == 'invoice.balance_due') {

View File

@ -29,6 +29,9 @@
{{ Former::populateField('custom_invoice_taxes1', intval($account->custom_invoice_taxes1)) }}
{{ Former::populateField('custom_invoice_taxes2', intval($account->custom_invoice_taxes2)) }}
{{ Former::populateField('share_counter', intval($account->share_counter)) }}
@foreach (App\Models\Account::$customFields as $field)
{{ Former::populateField("custom_fields[$field]", $account->customLabel($field)) }}
@endforeach
<div class="panel panel-default">
<div class="panel-heading">
@ -241,9 +244,9 @@
<div role="tabpanel" class="tab-pane active" id="client_fields">
<div class="panel-body">
{!! Former::text('custom_client_label1')
{!! Former::text('custom_fields[client1]')
->label(trans('texts.field_label')) !!}
{!! Former::text('custom_client_label2')
{!! Former::text('custom_fields[client2]')
->label(trans('texts.field_label'))
->help(trans('texts.custom_client_fields_helps') . ' ' . trans('texts.custom_fields_tip')) !!}
@ -252,9 +255,9 @@
<div role="tabpanel" class="tab-pane" id="contact_fields">
<div class="panel-body">
{!! Former::text('custom_contact_label1')
{!! Former::text('custom_fields[contact1]')
->label(trans('texts.field_label')) !!}
{!! Former::text('custom_contact_label2')
{!! Former::text('custom_fields[contact2]')
->label(trans('texts.field_label'))
->help(trans('texts.custom_contact_fields_help') . ' ' . trans('texts.custom_fields_tip')) !!}
@ -263,12 +266,12 @@
<div role="tabpanel" class="tab-pane" id="company_fields">
<div class="panel-body">
{!! Former::text('custom_label1')
{!! Former::text('custom_fields[account1]')
->label(trans('texts.field_label')) !!}
{!! Former::text('custom_value1')
->label(trans('texts.field_value')) !!}
<p>&nbsp;</p>
{!! Former::text('custom_label2')
{!! Former::text('custom_fields[account2]')
->label(trans('texts.field_label')) !!}
{!! Former::text('custom_value2')
->label(trans('texts.field_value'))
@ -279,9 +282,9 @@
<div role="tabpanel" class="tab-pane" id="product_fields">
<div class="panel-body">
{!! Former::text('custom_invoice_item_label1')
{!! Former::text('custom_fields[product1]')
->label(trans('texts.field_label')) !!}
{!! Former::text('custom_invoice_item_label2')
{!! Former::text('custom_fields[product2]')
->label(trans('texts.field_label'))
->help(trans('texts.custom_product_fields_help') . ' ' . trans('texts.custom_fields_tip')) !!}
@ -290,20 +293,20 @@
<div role="tabpanel" class="tab-pane" id="invoice_fields">
<div class="panel-body">
{!! Former::text('custom_invoice_text_label1')
{!! Former::text('custom_fields[invoice_text1]')
->label(trans('texts.field_label')) !!}
{!! Former::text('custom_invoice_text_label2')
{!! Former::text('custom_fields[invoice_text2]')
->label(trans('texts.field_label'))
->help(trans('texts.custom_invoice_fields_helps') . ' ' . trans('texts.custom_fields_tip')) !!}
{!! Former::text('custom_invoice_label1')
{!! Former::text('custom_fields[invoice1]')
->label(trans('texts.surcharge_label'))
->addGroupClass('pad-checkbox')
->append(Former::checkbox('custom_invoice_taxes1')
->value(1)
->raw() . trans('texts.charge_taxes')) !!}
{!! Former::text('custom_invoice_label2')
{!! Former::text('custom_fields[invoice2]')
->label(trans('texts.surcharge_label'))
->addGroupClass('pad-checkbox')
->append(Former::checkbox('custom_invoice_taxes2')

View File

@ -29,16 +29,16 @@
{!! Former::textarea('notes')->rows(6) !!}
@if ($account->hasFeature(FEATURE_INVOICE_SETTINGS))
@if ($account->custom_invoice_item_label1)
@if ($account->customLabel('product1'))
@include('partials.custom_field', [
'field' => 'custom_value1',
'label' => $account->custom_invoice_item_label1
'label' => $account->customLabel('product1')
])
@endif
@if ($account->custom_invoice_item_label2)
@if ($account->customLabel('product2'))
@include('partials.custom_field', [
'field' => 'custom_value2',
'label' => $account->custom_invoice_item_label2
'label' => $account->customLabel('product2')
])
@endif
@endif

View File

@ -160,18 +160,18 @@
@endif
@if (Auth::user()->hasFeature(FEATURE_INVOICE_SETTINGS))
@if ($account->custom_contact_label1)
@if ($account->customLabel('contact1'))
@include('partials.custom_field', [
'field' => 'custom_contact1',
'label' => $account->custom_contact_label1,
'label' => $account->customLabel('contact1'),
'databind' => "value: custom_value1, valueUpdate: 'afterkeydown',
attr: {name: 'contacts[' + \$index() + '][custom_value1]'}",
])
@endif
@if ($account->custom_contact_label2)
@if ($account->customLabel('contact2'))
@include('partials.custom_field', [
'field' => 'custom_contact2',
'label' => $account->custom_contact_label2,
'label' => $account->customLabel('contact2'),
'databind' => "value: custom_value2, valueUpdate: 'afterkeydown',
attr: {name: 'contacts[' + \$index() + '][custom_value2]'}",
])

View File

@ -100,11 +100,11 @@
<p><i class="fa fa-vat-number" style="width: 20px"></i>{{ trans('texts.vat_number').': '.$client->vat_number }}</p>
@endif
@if ($client->account->custom_client_label1 && $client->custom_value1)
{{ $client->account->present()->customClientLabel1 . ': ' . $client->custom_value1 }}<br/>
@if ($client->account->customLabel('client1') && $client->custom_value1)
{{ $client->account->present()->customLabel('client1') . ': ' . $client->custom_value1 }}<br/>
@endif
@if ($client->account->custom_client_label2 && $client->custom_value2)
{{ $client->account->present()->customClientLabel2 . ': ' . $client->custom_value2 }}<br/>
@if ($client->account->customLabel('client2') && $client->custom_value2)
{{ $client->account->present()->customLabel('client2') . ': ' . $client->custom_value2 }}<br/>
@endif
@if ($client->work_phone)
@ -182,11 +182,11 @@
<i class="fa fa-phone" style="width: 20px"></i>{{ $contact->phone }}<br/>
@endif
@if ($client->account->custom_contact_label1 && $contact->custom_value1)
{{ $client->account->present()->customContactLabel1() . ': ' . $contact->custom_value1 }}<br/>
@if ($client->account->customLabel('contact1') && $contact->custom_value1)
{{ $client->account->present()->customLabel('contact1') . ': ' . $contact->custom_value1 }}<br/>
@endif
@if ($client->account->custom_contact_label2 && $contact->custom_value2)
{{ $client->account->present()->customContactLabel2() . ': ' . $contact->custom_value2 }}<br/>
@if ($client->account->customLabel('contact2') && $contact->custom_value2)
{{ $client->account->present()->customLabel('contact2') . ': ' . $contact->custom_value2 }}<br/>
@endif
@if (Auth::user()->confirmed && $client->account->enable_client_portal)

View File

@ -24,11 +24,11 @@
<td>{{ trans('texts.currency') }}</td>
<td>{{ trans('texts.public_notes') }}</td>
<td>{{ trans('texts.private_notes') }}</td>
@if ($account->custom_client_label1)
<td>{{ $account->present()->customClientLabel1 }}</td>
@if ($account->customLabel('client1'))
<td>{{ $account->present()->customLabel('client1') }}</td>
@endif
@if ($account->custom_client_label2)
<td>{{ $account->present()->customClientLabel2 }}</td>
@if ($account->customLabel('client2'))
<td>{{ $account->present()->customLabel('client2') }}</td>
@endif
@if ($account->hasReminders())
<td>{{ trans('texts.reminders') }}</td>
@ -37,11 +37,11 @@
<td>{{ trans('texts.last_name') }}</td>
<td>{{ trans('texts.email') }}</td>
<td>{{ trans('texts.phone') }}</td>
@if ($account->custom_contact_label1)
<td>{{ $account->present()->customContactLabel1 }}</td>
@if ($account->customLabel('contact1'))
<td>{{ $account->present()->customLabel('contact1') }}</td>
@endif
@if ($account->custom_contact_label2)
<td>{{ $account->present()->customContactLabel2 }}</td>
@if ($account->customLabel('contact2'))
<td>{{ $account->present()->customLabel('contact2') }}</td>
@endif
</tr>
@ -72,10 +72,10 @@
<td>{{ $client->currency ? $client->currency->code : '' }}</td>
<td>{{ $client->public_notes }}</td>
<td>{{ $client->private_notes }}</td>
@if ($account->custom_client_label1)
@if ($account->customLabel('client1'))
<td>{{ $client->custom_value1 }}</td>
@endif
@if ($account->custom_client_label2)
@if ($account->customLabel('client2'))
<td>{{ $client->custom_value2 }}</td>
@endif
@if ($account->hasReminders())
@ -85,10 +85,10 @@
<td>{{ $client->contacts[0]->last_name }}</td>
<td>{{ $client->contacts[0]->email }}</td>
<td>{{ $client->contacts[0]->phone }}</td>
@if ($account->custom_contact_label1)
@if ($account->customLabel('contact1'))
<td>{{ $client->contacts[0]->custom_value1 }}</td>
@endif
@if ($account->custom_contact_label2)
@if ($account->customLabel('contact2'))
<td>{{ $client->contacts[0]->custom_value2 }}</td>
@endif
</tr>

View File

@ -7,11 +7,11 @@
<td>{{ trans('texts.last_name') }}</td>
<td>{{ trans('texts.email') }}</td>
<td>{{ trans('texts.phone') }}</td>
@if ($account->custom_contact_label1)
<td>{{ $account->present()->customContactLabel1 }}</td>
@if ($account->customLabel('contact1'))
<td>{{ $account->present()->customLabel('contact1') }}</td>
@endif
@if ($account->custom_contact_label2)
<td>{{ $account->present()->customContactLabel2 }}</td>
@if ($account->customLabel('contact2'))
<td>{{ $account->present()->customLabel('contact2') }}</td>
@endif
</tr>
@ -26,10 +26,10 @@
<td>{{ $contact->last_name }}</td>
<td>{{ $contact->email }}</td>
<td>{{ $contact->phone }}</td>
@if ($account->custom_contact_label1)
@if ($account->customLabel('contact1'))
<td>{{ $contact->custom_value1 }}</td>
@endif
@if ($account->custom_contact_label2)
@if ($account->customLabel('contact2'))
<td>{{ $contact->custom_value2 }}</td>
@endif
</tr>

View File

@ -17,25 +17,25 @@
@endif
<td>{{ trans('texts.public_notes') }}</td>
<td>{{ trans('texts.private_notes') }}</td>
@if ($account->custom_invoice_label1)
<td>{{ $account->present()->customInvoiceLabel1 }}</td>
@if ($account->customLabel('invoice1'))
<td>{{ $account->present()->customLabel('invoice1') }}</td>
@endif
@if ($account->custom_invoice_label2)
<td>{{ $account->present()->customInvoiceLabel2 }}</td>
@if ($account->customLabel('invoice2'))
<td>{{ $account->present()->customLabel('invoice2') }}</td>
@endif
@if ($account->custom_invoice_text_label1)
<td>{{ $account->present()->customInvoiceTextLabel1 }}</td>
@if ($account->customLabel('invoice_text1'))
<td>{{ $account->present()->customLabel('invoice_text1') }}</td>
@endif
@if ($account->custom_invoice_text_label2)
<td>{{ $account->present()->customInvoiceTextLabel1 }}</td>
@if ($account->customLabel('invoice_text2'))
<td>{{ $account->present()->customLabel('invoice_text1') }}</td>
@endif
<td>{{ trans('texts.item_product') }}</td>
<td>{{ trans('texts.item_notes') }}</td>
@if ($account->custom_invoice_item_label1)
<td>{{ $account->present()->customProductLabel1 }}</td>
@if ($account->customLabel('product1'))
<td>{{ $account->present()->customLabel('product1') }}</td>
@endif
@if ($account->custom_invoice_item_label2)
<td>{{ $account->present()->customProductLabel2 }}</td>
@if ($account->customLabel('product2'))
<td>{{ $account->present()->customLabel('product2') }}</td>
@endif
<td>{{ trans('texts.item_cost') }}</td>
<td>{{ trans('texts.item_quantity') }}</td>
@ -71,24 +71,24 @@
@endif
<td>{{ $invoice->public_notes }}</td>
<td>{{ $invoice->private_notes }}</td>
@if ($account->custom_invoice_label1)
@if ($account->customLabel('invoice1'))
<td>{{ $invoice->custom_value1 }}</td>
@endif
@if ($account->custom_invoice_label2)
@if ($account->customLabel('invoice2'))
<td>{{ $invoice->custom_value2 }}</td>
@endif
@if ($account->custom_invoice_text_label1)
@if ($account->customLabel('invoice_text1'))
<td>{{ $invoice->custom_text_value1 }}</td>
@endif
@if ($account->custom_invoice_text_label2)
@if ($account->customLabel('invoice_text2'))
<td>{{ $invoice->custom_text_value2 }}</td>
@endif
<td>{{ $item->product_key }}</td>
<td>{{ $item->notes }}</td>
@if ($account->custom_invoice_item_label1)
@if ($account->customLabel('product1'))
<td>{{ $item->custom_value1 }}</td>
@endif
@if ($account->custom_invoice_item_label2)
@if ($account->customLabel('product2'))
<td>{{ $item->custom_value2 }}</td>
@endif
<td>{{ $item->cost }}</td>

View File

@ -5,11 +5,11 @@
<td>{{ trans('texts.product') }}</td>
<td>{{ trans('texts.notes') }}</td>
<td>{{ trans('texts.cost') }}</td>
@if ($account->custom_invoice_item_label1)
<td>{{ $account->present()->customProductLabel1 }}</td>
@if ($account->customLabel('product1'))
<td>{{ $account->present()->customLabel('product1') }}</td>
@endif
@if ($account->custom_invoice_item_label2)
<td>{{ $account->present()->customProductLabel2 }}</td>
@if ($account->customLabel('product2'))
<td>{{ $account->present()->customLabel('product2') }}</td>
@endif
</tr>
@ -21,13 +21,13 @@
<td>{{ $product->product_key }}</td>
<td>{{ $product->notes }}</td>
<td>{{ $product->cost }}</td>
@if ($account->custom_invoice_item_label1)
@if ($account->customLabel('product1'))
@endif
@if ($account->custom_invoice_item_label1)
@if ($account->customLabel('product1'))
<td>{{ $product->custom_value1 }}</td>
@endif
@if ($account->custom_invoice_item_label2)
@if ($account->customLabel('product2'))
<td>{{ $product->custom_value2 }}</td>
@endif
</tr>

View File

@ -9,25 +9,25 @@
<td>{{ trans('texts.amount') }}</td>
<td>{{ trans('texts.po_number') }}</td>
<td>{{ trans('texts.status') }}</td>
@if ($account->custom_invoice_label1)
<td>{{ $account->present()->customInvoiceLabel1 }}</td>
@if ($account->customLabel('invoice1'))
<td>{{ $account->present()->customLabel('invoice1') }}</td>
@endif
@if ($account->custom_invoice_label2)
<td>{{ $account->present()->customInvoiceLabel2 }}</td>
@if ($account->customLabel('invoice2'))
<td>{{ $account->present()->customLabel('invoice2') }}</td>
@endif
@if ($account->custom_invoice_text_label1)
<td>{{ $account->present()->customInvoiceTextLabel1 }}</td>
@if ($account->customLabel('invoice_text1'))
<td>{{ $account->present()->customLabel('invoice_text1') }}</td>
@endif
@if ($account->custom_invoice_text_label2)
<td>{{ $account->present()->customInvoiceTextLabel2 }}</td>
@if ($account->customLabel('invoice_text2'))
<td>{{ $account->present()->customLabel('invoice_text2') }}</td>
@endif
<td>{{ trans('texts.item_product') }}</td>
<td>{{ trans('texts.item_notes') }}</td>
@if ($account->custom_invoice_item_label1)
<td>{{ $account->present()->customProductLabel1 }}</td>
@if ($account->customLabel('product1'))
<td>{{ $account->present()->customLabel('product1') }}</td>
@endif
@if ($account->custom_invoice_item_label2)
<td>{{ $account->present()->customProductLabel2 }}</td>
@if ($account->customLabel('product2'))
<td>{{ $account->present()->customLabel('product2') }}</td>
@endif
<td>{{ trans('texts.item_cost') }}</td>
<td>{{ trans('texts.item_quantity') }}</td>
@ -55,24 +55,24 @@
<td>{{ $account->formatMoney($invoice->amount, $invoice->client) }}</td>
<td>{{ $invoice->po_number }}</td>
<td>{{ $invoice->present()->status }}</td>
@if ($account->custom_invoice_label1)
@if ($account->customLabel('invoice1'))
<td>{{ $invoice->custom_value1 }}</td>
@endif
@if ($account->custom_invoice_label2)
@if ($account->customLabel('invoice2'))
<td>{{ $invoice->custom_value2 }}</td>
@endif
@if ($account->custom_invoice_text_label1)
@if ($account->customLabel('invoice_text1'))
<td>{{ $invoice->custom_text_value1 }}</td>
@endif
@if ($account->custom_invoice_text_label2)
@if ($account->customLabel('invoice_text2'))
<td>{{ $invoice->custom_text_value2 }}</td>
@endif
<td>{{ $item->product_key }}</td>
<td>{{ $item->notes }}</td>
@if ($account->custom_invoice_item_label1)
@if ($account->customLabel('product1'))
<td>{{ $item->custom_value1 }}</td>
@endif
@if ($account->custom_invoice_item_label2)
@if ($account->customLabel('product2'))
<td>{{ $item->custom_value2 }}</td>
@endif
<td>{{ $item->cost }}</td>

View File

@ -61,25 +61,25 @@
hint: true,
highlight: true,
}
@if (Auth::check() && Auth::user()->account->custom_client_label1)
@if (Auth::check() && Auth::user()->account->customLabel('client1'))
,{
name: 'data',
limit: 3,
display: 'value',
source: searchData(data['{{ Auth::user()->account->present()->customClientLabel1 }}'], 'tokens'),
source: searchData(data['{{ Auth::user()->account->present()->customLabel('client1') }}'], 'tokens'),
templates: {
header: '&nbsp;<span style="font-weight:600;font-size:16px">{{ Auth::user()->account->present()->customClientLabel1 }}</span>'
header: '&nbsp;<span style="font-weight:600;font-size:16px">{{ Auth::user()->account->present()->customLabel('client1') }}</span>'
}
}
@endif
@if (Auth::check() && Auth::user()->account->custom_client_label2)
@if (Auth::check() && Auth::user()->account->customLabel('client2'))
,{
name: 'data',
limit: 3,
display: 'value',
source: searchData(data['{{ Auth::user()->account->present()->customClientLabel2 }}'], 'tokens'),
source: searchData(data['{{ Auth::user()->account->present()->customLabel('client2') }}'], 'tokens'),
templates: {
header: '&nbsp;<span style="font-weight:600;font-size:16px">{{ Auth::user()->account->present()->customClientLabel2 }}</span>'
header: '&nbsp;<span style="font-weight:600;font-size:16px">{{ Auth::user()->account->present()->customLabel('client2') }}</span>'
}
}
@endif

View File

@ -224,10 +224,10 @@
</div>
@endif
@if ($account->showCustomField('custom_invoice_text_label1', $invoice))
@if ($account->customLabel('invoice_text1'))
@include('partials.custom_field', [
'field' => 'custom_text_value1',
'label' => $account->custom_invoice_text_label1,
'label' => $account->customLabel('invoice_text1'),
'databind' => "value: custom_text_value1, valueUpdate: 'afterkeydown'",
])
@endif
@ -276,10 +276,10 @@
->raw()
) !!}
@if ($account->showCustomField('custom_invoice_text_label2', $invoice))
@if ($account->customLabel('invoice_text2'))
@include('partials.custom_field', [
'field' => 'custom_text_value2',
'label' => $account->custom_invoice_text_label2,
'label' => $account->customLabel('invoice_text2'),
'databind' => "value: custom_text_value2, valueUpdate: 'afterkeydown'",
])
@endif
@ -329,15 +329,15 @@
<td style="text-align: right"><span data-bind="text: totals.discounted"/></td>
</tr>
@if ($account->showCustomField('custom_invoice_label1', $invoice) && $invoice->custom_taxes1)
@if ($account->customLabel('invoice1') && $invoice->custom_taxes1)
<tr>
<td colspan="2">{{ $account->custom_invoice_label1 ?: trans('texts.surcharge') }}</td>
<td colspan="2">{{ $account->customLabel('invoice1') ?: trans('texts.surcharge') }}</td>
<td><input name="custom_value1" class="form-control" data-bind="value: custom_value1, valueUpdate: 'afterkeydown'"/></td>
</tr>
@endif
@if ($account->showCustomField('custom_invoice_label2', $invoice) && $invoice->custom_taxes2)
@if ($account->customLabel('invoice2') && $invoice->custom_taxes2)
<tr>
<td colspan="2">{{ $account->custom_invoice_label2 ?: trans('texts.surcharge') }}</td>
<td colspan="2">{{ $account->customLabel('invoice2') ?: trans('texts.surcharge') }}</td>
<td><input name="custom_value2" class="form-control" data-bind="value: custom_value2, valueUpdate: 'afterkeydown'"/></td>
</tr>
@endif
@ -374,16 +374,16 @@
<td style="text-align: right"><span data-bind="text: totals.taxAmount"/></td>
</tr>
@if ($account->showCustomField('custom_invoice_label1', $invoice) && !$invoice->custom_taxes1)
@if ($account->customLabel('invoice1') && !$invoice->custom_taxes1)
<tr>
<td colspan="2">{{ $account->custom_invoice_label1 ?: trans('texts.surcharge') }}</td>
<td colspan="2">{{ $account->customLabel('invoice1') ?: trans('texts.surcharge') }}</td>
<td><input name="custom_value1" class="form-control" data-bind="value: custom_value1, valueUpdate: 'afterkeydown'"/></td>
</tr>
@endif
@if ($account->showCustomField('custom_invoice_label2', $invoice) && !$invoice->custom_taxes2)
@if ($account->customLabel('invoice2') && !$invoice->custom_taxes2)
<tr>
<td colspan="2">{{ $account->custom_invoice_label2 ?: trans('texts.surcharge') }}</td>
<td colspan="2">{{ $account->customLabel('invoice2') ?: trans('texts.surcharge') }}</td>
<td><input name="custom_value2" class="form-control" data-bind="value: custom_value2, valueUpdate: 'afterkeydown'"/></td>
</tr>
@endif
@ -626,17 +626,17 @@
</span>
@if (Auth::user()->hasFeature(FEATURE_INVOICE_SETTINGS))
@if ($account->custom_client_label1)
@if ($account->customLabel('client1'))
@include('partials.custom_field', [
'field' => 'client[custom_value1]',
'label' => $account->custom_client_label1,
'label' => $account->customLabel('client1'),
'databind' => "value: custom_value1, valueUpdate: 'afterkeydown'",
])
@endif
@if ($account->custom_client_label2)
@if ($account->customLabel('client2'))
@include('partials.custom_field', [
'field' => 'client[custom_value2]',
'label' => $account->custom_client_label2,
'label' => $account->customLabel('client2'),
'databind' => "value: custom_value1, valueUpdate: 'afterkeydown'",
])
@endif
@ -690,18 +690,18 @@
attr: {name: 'client[contacts][' + \$index() + '][password]'}")->autocomplete('new-password')->data_lpignore('true') !!}
@endif
@if (Auth::user()->hasFeature(FEATURE_INVOICE_SETTINGS))
@if ($account->custom_contact_label1)
@if ($account->customLabel('contact1'))
@include('partials.custom_field', [
'field' => 'custom_contact1',
'label' => $account->custom_contact_label1,
'label' => $account->customLabel('contact1'),
'databind' => "value: custom_value1, valueUpdate: 'afterkeydown',
attr: {name: 'client[contacts][' + \$index() + '][custom_value1]'}",
])
@endif
@if ($account->custom_contact_label2)
@if ($account->customLabel('contact2'))
@include('partials.custom_field', [
'field' => 'custom_contact2',
'label' => $account->custom_contact_label2,
'label' => $account->customLabel('contact2'),
'databind' => "value: custom_value2, valueUpdate: 'afterkeydown',
attr: {name: 'client[contacts][' + \$index() + '][custom_value2]'}",
])

View File

@ -9,11 +9,11 @@
<th style="min-width:32px;" class="hide-border"></th>
<th style="min-width:120px;width:25%">{{ $invoiceLabels[$isTasks ? 'service' : 'item'] }}</th>
<th style="width:100%">{{ $invoiceLabels['description'] }}</th>
@if ($account->showCustomField('custom_invoice_item_label1'))
<th style="min-width:120px">{{ $account->present()->customProductLabel1 }}</th>
@if ($account->customLabel('product1'))
<th style="min-width:120px">{{ $account->present()->customLabel('product1') }}</th>
@endif
@if ($account->showCustomField('custom_invoice_item_label2'))
<th style="min-width:120px">{{ $account->present()->customProductLabel2 }}</th>
@if ($account->customLabel('product2'))
<th style="min-width:120px">{{ $account->present()->customLabel('product2') }}</th>
@endif
<th style="min-width:120px">{{ $invoiceLabels[$isTasks ? 'rate' : 'unit_cost'] }}</th>
<th style="min-width:120px;display:{{ $account->hasInvoiceField($isTasks ? 'task' : 'product', $isTasks ? 'product.hours' : 'product.quantity') ? 'table-cell' : 'none' }}">{{ $invoiceLabels[$isTasks ? 'hours' : 'quantity'] }}</th>
@ -42,22 +42,22 @@
<input type="text" data-bind="value: expense_public_id, attr: {name: 'invoice_items[{{ $isTasks ? 'T' : '' }}' + $index() + '][expense_public_id]'}" style="display: none"/>
<input type="text" data-bind="value: invoice_item_type_id, attr: {name: 'invoice_items[{{ $isTasks ? 'T' : '' }}' + $index() + '][invoice_item_type_id]'}" style="display: none"/>
</td>
@if ($account->showCustomField('custom_invoice_item_label1'))
@if ($account->customLabel('product1'))
<td>
@include('partials.custom_field', [
'field' => 'custom_invoice_item_label1',
'label' => $account->custom_invoice_item_label1,
'label' => $account->customLabel('product1'),
'databind' => "value: custom_value1, valueUpdate: 'afterkeydown',
attr: {name: 'invoice_items[" . ($isTasks ? 'T' : '') . "' + \$index() + '][custom_value1]'}",
'raw' => true,
])
</td>
@endif
@if ($account->showCustomField('custom_invoice_item_label2'))
@if ($account->customLabel('product2'))
<td>
@include('partials.custom_field', [
'field' => 'custom_invoice_item_label2',
'label' => $account->custom_invoice_item_label2,
'label' => $account->customLabel('product2'),
'databind' => "value: custom_value2, valueUpdate: 'afterkeydown',
attr: {name: 'invoice_items[" . ($isTasks ? 'T' : '') . "' + \$index() + '][custom_value2]'}",
'raw' => true,

View File

@ -1072,9 +1072,9 @@ ko.bindingHandlers.productTypeahead = {
from: currencyMap[accountCurrencyId].code,
to: currencyMap[clientCurrencyId].code,
});
if ((account.custom_invoice_text_label1 || '').toLowerCase() == "{{ strtolower(trans('texts.exchange_rate')) }}") {
if ((account.custom_fields.invoice_text1 || '').toLowerCase() == "{{ strtolower(trans('texts.exchange_rate')) }}") {
window.model.invoice().custom_text_value1(roundToFour(rate, true));
} else if ((account.custom_invoice_text_label2 || '').toLowerCase() == "{{ strtolower(trans('texts.exchange_rate')) }}") {
} else if ((account.custom_fields.invoice_text1 || '').toLowerCase() == "{{ strtolower(trans('texts.exchange_rate')) }}") {
window.model.invoice().custom_text_value2(roundToFour(rate, true));
}
}
@ -1097,12 +1097,12 @@ ko.bindingHandlers.productTypeahead = {
$select.val('0 ' + datum.tax_rate2 + ' ' + datum.tax_name2).trigger('change');
}
@endif
@if (Auth::user()->isPro() && $account->custom_invoice_item_label1)
@if (Auth::user()->isPro() && $account->customLabel('product1'))
if (datum.custom_value1) {
model.custom_value1(datum.custom_value1);
}
@endif
@if (Auth::user()->isPro() && $account->custom_invoice_item_label2)
@if (Auth::user()->isPro() && $account->customLabel('product2'))
if (datum.custom_value2) {
model.custom_value2(datum.custom_value2);
}

View File

@ -155,25 +155,25 @@
@endif
@endforeach
</ul>
@if ($account->custom_client_label1 || $account->custom_contact_label1 || $account->custom_invoice_text_label1)
@if ($account->customLabel('client1') || $account->customLabel('contact1') || $account->customLabel('invoice_text1'))
<p>{{ trans('texts.custom_variables') }}</p>
<ul>
@if ($account->custom_client_label1)
@if ($account->customLabel('client1'))
<li>$customClient1</li>
@endif
@if ($account->custom_client_label2)
@if ($account->customLabel('client2'))
<li>$customClient2</li>
@endif
@if ($account->custom_contact_label1)
@if ($account->customLabel('contact1'))
<li>$customContact1</li>
@endif
@if ($account->custom_contact_label2)
@if ($account->customLabel('contact2'))
<li>$customContact2</li>
@endif
@if ($account->custom_invoice_text_label1)
@if ($account->customLabel('invoice_text1'))
<li>$customInvoice1</li>
@endif
@if ($account->custom_invoice_text_label2)
@if ($account->customLabel('invoice_text2'))
<li>$customInvoice2</li>
@endif
</ul>

View File

@ -17,16 +17,16 @@
<li>${{ $entityType }}.footer</li>
<li>${{ $entityType }}.partial</li>
<li>${{ $entityType }}.partialDueDate</li>
@if ($account->custom_invoice_label1)
@if ($account->customLabel('invoice1'))
<li>${{ $entityType }}.customValue1</li>
@endif
@if ($account->custom_invoice_label2)
@if ($account->customLabel('invoice2'))
<li>${{ $entityType }}.customValue2</li>
@endif
@if ($account->custom_invoice_text_label1)
@if ($account->customLabel('invoice_text1'))
<li>${{ $entityType }}.customTextValue1</li>
@endif
@if ($account->custom_invoice_text_label2)
@if ($account->customLabel('invoice_text2'))
<li>${{ $entityType }}.customTextValue2</li>
@endif
</ul>
@ -63,10 +63,10 @@
<li>$client.country.name</li>
<li>$client.phone</li>
<li>$client.balance</li>
@if ($account->custom_client_label1)
@if ($account->customLabel('client1'))
<li>$client.customValue1</li>
@endif
@if ($account->custom_client_label2)
@if ($account->customLabel('client2'))
<li>$client.customValue2</li>
@endif
</ul>
@ -75,10 +75,10 @@
<li>$contact.lastName</li>
<li>$contact.email</li>
<li>$contact.phone</li>
@if ($account->custom_contact_label1)
@if ($account->customLabel('contact1'))
<li>$contact.customValue1</li>
@endif
@if ($account->custom_contact_label2)
@if ($account->customLabel('contact2'))
<li>$contact.customValue2</li>
@endif
</ul>