diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 90b6ef930b..a3ba45a5cc 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -684,6 +684,8 @@ class AccountController extends BaseController $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->invoice_number_counter = Input::get('invoice_number_counter'); $account->quote_number_prefix = Input::get('quote_number_prefix'); diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index e60a06f8d4..340ce419b7 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -455,12 +455,16 @@ class Invoice extends EntityModel implements BalanceAffecting 'show_item_taxes', 'custom_invoice_text_label1', 'custom_invoice_text_label2', + 'custom_invoice_item_label1', + 'custom_invoice_item_label2', ]); foreach ($this->invoice_items as $invoiceItem) { $invoiceItem->setVisible([ 'product_key', 'notes', + 'custom_value1', + 'custom_value2', 'cost', 'qty', 'tax_name', diff --git a/app/Ninja/Repositories/InvoiceRepository.php b/app/Ninja/Repositories/InvoiceRepository.php index 3c4072122d..aa0e09f632 100644 --- a/app/Ninja/Repositories/InvoiceRepository.php +++ b/app/Ninja/Repositories/InvoiceRepository.php @@ -398,7 +398,7 @@ class InvoiceRepository extends BaseRepository foreach ($data['invoice_items'] as $item) { $item = (array) $item; - if (!$item['cost'] && !$item['product_key'] && !$item['notes']) { + if (empty($item['cost']) && empty($item['product_key']) && empty($item['notes']) && empty($item['custom_value1']) && empty($item['custom_value2'])) { continue; } @@ -439,6 +439,13 @@ class InvoiceRepository extends BaseRepository $invoiceItem->qty = Utils::parseFloat($item['qty']); $invoiceItem->tax_rate = 0; + if (isset($item['custom_value1'])) { + $invoiceItem->custom_value1 = $item['custom_value1']; + } + if (isset($item['custom_value2'])) { + $invoiceItem->custom_value2 = $item['custom_value2']; + } + if (isset($item['tax_rate']) && isset($item['tax_name']) && $item['tax_name']) { $invoiceItem['tax_rate'] = Utils::parseFloat($item['tax_rate']); $invoiceItem['tax_name'] = trim($item['tax_name']); diff --git a/database/migrations/2016_02_28_081424_add_custom_invoice_fields.php b/database/migrations/2016_02_28_081424_add_custom_invoice_fields.php new file mode 100644 index 0000000000..3364261e33 --- /dev/null +++ b/database/migrations/2016_02_28_081424_add_custom_invoice_fields.php @@ -0,0 +1,51 @@ +string('custom_invoice_item_label1')->nullable(); + $table->string('custom_invoice_item_label2')->nullable(); + $table->string('recurring_invoice_number_prefix')->default('R'); + $table->boolean('enable_client_portal')->default(true); + $table->text('invoice_fields')->nullable(); + $table->text('devices')->nullable(); + }); + + Schema::table('invoice_items', function($table) { + $table->string('custom_value1')->nullable(); + $table->string('custom_value2')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('accounts', function($table) { + $table->dropColumn('custom_invoice_item_label1'); + $table->dropColumn('custom_invoice_item_label2'); + $table->dropColumn('recurring_invoice_number_prefix'); + $table->dropColumn('enable_client_portal'); + $table->dropColumn('invoice_fields'); + $table->dropColumn('devices'); + }); + + Schema::table('accounts', function($table) { + $table->dropColumn('custom_value1'); + $table->dropColumn('custom_value2'); + }); + } +} diff --git a/public/built.js b/public/built.js index 1c8aad7f62..51c66b75cd 100644 --- a/public/built.js +++ b/public/built.js @@ -31216,6 +31216,13 @@ NINJA.invoiceColumns = function(invoice) columns.push("*") + if (account.custom_invoice_item_label1) { + columns.push("10%"); + } + if (account.custom_invoice_item_label2) { + columns.push("10%"); + } + var count = 3; if (account.hide_quantity == '1') { count--; @@ -31226,6 +31233,7 @@ NINJA.invoiceColumns = function(invoice) for (var i=0; i 'Customize the invoice link subdomain or display the invoice on your own website.', 'invoice_number_help' => 'Specify a prefix or use a custom pattern to dynamically set the invoice number.', 'quote_number_help' => 'Specify a prefix or use a custom pattern to dynamically set the quote number.', - 'custom_client_fields_helps' => 'Add a text input to the client create/edit page and display the label and value on the PDF.', + 'custom_client_fields_helps' => 'Add a field when creating/editing a client and display the label and value on the PDF.', 'custom_account_fields_helps' => 'Add a label and value to the company details section of the PDF.', - 'custom_invoice_fields_helps' => 'Add a text input to the invoice create/edit page and display the label and value on the PDF.', - 'custom_invoice_charges_helps' => 'Add a text input to the invoice create/edit page and include the charge in the invoice subtotals.', + 'custom_invoice_fields_helps' => 'Add a field when creating an invoice and display the label and value on the PDF.', + 'custom_invoice_charges_helps' => 'Add a field when creating an invoice and include the charge in the invoice subtotals.', 'token_expired' => 'Validation token was expired. Please try again.', 'invoice_link' => 'Invoice Link', 'button_confirmation_message' => 'Click to confirm your email address.', @@ -1045,6 +1045,8 @@ $LANG = array( 'new_product' => 'New Product', 'new_tax_rate' => 'New Tax Rate', 'invoiced_amount' => 'Invoiced Amount', + 'invoice_item_fields' => 'Invoice Item Fields', + 'custom_invoice_item_fields_help' => 'Add a field when creating an invoice item and display the label and value on the PDF.', ); diff --git a/resources/views/accounts/invoice_settings.blade.php b/resources/views/accounts/invoice_settings.blade.php index af9bdefada..e0194dcd0f 100644 --- a/resources/views/accounts/invoice_settings.blade.php +++ b/resources/views/accounts/invoice_settings.blade.php @@ -108,10 +108,21 @@
@@ -153,6 +164,17 @@
+
+
+ + {!! Former::text('custom_invoice_item_label1') + ->label(trans('texts.field_label')) !!} + {!! Former::text('custom_invoice_item_label2') + ->label(trans('texts.field_label')) + ->help(trans('texts.custom_invoice_item_fields_help')) !!} + +
+
diff --git a/resources/views/invoices/edit.blade.php b/resources/views/invoices/edit.blade.php index 456ef501f7..548cc41e23 100644 --- a/resources/views/invoices/edit.blade.php +++ b/resources/views/invoices/edit.blade.php @@ -189,6 +189,12 @@ {{ $invoiceLabels['item'] }} {{ $invoiceLabels['description'] }} + @if ($account->custom_invoice_item_label1) + {{ $account->custom_invoice_item_label1 }} + @endif + @if ($account->custom_invoice_item_label2) + {{ $account->custom_invoice_item_label2 }} + @endif {{ $invoiceLabels['unit_cost'] }} {{ $invoiceLabels['quantity'] }} {{ trans('texts.tax') }} @@ -215,6 +221,16 @@ + @if ($account->custom_invoice_item_label1) + + + + @endif + @if ($account->custom_invoice_item_label2) + + + + @endif @@ -243,7 +259,7 @@ - +
diff --git a/resources/views/invoices/knockout.blade.php b/resources/views/invoices/knockout.blade.php index 1f1d210b87..adeb775991 100644 --- a/resources/views/invoices/knockout.blade.php +++ b/resources/views/invoices/knockout.blade.php @@ -714,6 +714,8 @@ function ItemModel(data) { self.notes = ko.observable(''); self.cost = ko.observable(0); self.qty = ko.observable(0); + self.custom_value1 = ko.observable(''); + self.custom_value2 = ko.observable(''); self.tax_name = ko.observable(''); self.tax_rate = ko.observable(0); self.task_public_id = ko.observable('');