diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 88336226e3d6..c4f9f8924744 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -974,22 +974,7 @@ class AccountController extends BaseController $account->page_size = Input::get('page_size'); $labels = []; - foreach ([ - 'item', - 'description', - 'unit_cost', - 'quantity', - 'line_total', - 'terms', - 'balance_due', - 'partial_due', - 'subtotal', - 'paid_to_date', - 'discount', - 'tax', - 'po_number', - 'due_date', - ] as $field) { + foreach (Account::$customLabels as $field) { $labels[$field] = Input::get("labels_{$field}"); } $account->invoice_labels = json_encode($labels); diff --git a/app/Models/Account.php b/app/Models/Account.php index f8a90d4344da..a4ba22678e5b 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -219,6 +219,23 @@ class Account extends Eloquent 'outstanding' => 4, ]; + public static $customLabels = [ + 'item', + 'description', + 'unit_cost', + 'quantity', + 'line_total', + 'terms', + 'balance_due', + 'partial_due', + 'subtotal', + 'paid_to_date', + 'discount', + 'tax', + 'po_number', + 'due_date', + ]; + /** * @return \Illuminate\Database\Eloquent\Relations\HasMany */ diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index bd933d61e974..bc2e3627f074 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -2266,7 +2266,8 @@ $LANG = array( 'mailgun_domain' => 'Mailgun Domain', 'mailgun_private_key' => 'Mailgun Private Key', 'send_test_email' => 'Send test email', - + 'select_field' => 'Select field', + 'field' => 'Field', ); diff --git a/resources/views/accounts/invoice_design.blade.php b/resources/views/accounts/invoice_design.blade.php index 1412e6b384c9..00f8cc585f94 100644 --- a/resources/views/accounts/invoice_design.blade.php +++ b/resources/views/accounts/invoice_design.blade.php @@ -10,8 +10,16 @@ +@stop +@section('head_css') + @parent + @stop @section('content') @@ -91,6 +99,24 @@ generatePDF(invoice, getDesignJavascript(), true, cb); } + function updateFieldLabels() { + @foreach (App\Models\Account::$customLabels as $field) + if ($('#labels_{{ $field }}').val()) { + $('.{{ $field }}-label-group').show(); + } else { + $('.{{ $field }}-label-group').hide(); + } + @endforeach + } + + function onFieldChange() { + var $select = $('#label_field'); + var id = $select.val(); + $select.val(null); + $('.' + id + '-label-group').fadeIn(); + console.log(id); + } + $(function() { var options = { preferredFormat: 'hex', @@ -106,6 +132,7 @@ $('#header_font_id').change(function(){loadFont($('#header_font_id').val())}); $('#body_font_id').change(function(){loadFont($('#body_font_id').val())}); + updateFieldLabels(); refreshPDF(); }); @@ -208,22 +235,27 @@