From 9683f1d1b5920deda96aa8a3f3d6b900a9392737 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 22 Apr 2014 00:39:42 +0300 Subject: [PATCH] Custom fields --- app/controllers/InvoiceController.php | 1 + .../2014_04_17_145108_add_custom_fields.php | 1 + app/lang/de/texts.php | 6 ++ app/lang/es/texts.php | 6 ++ app/lang/fr/texts.php | 6 ++ app/lang/it/texts.php | 6 ++ app/lang/nl/texts.php | 6 ++ app/lang/pt_BR/texts.php | 6 ++ app/models/Invoice.php | 67 +++++++++++++++++-- 9 files changed, 98 insertions(+), 7 deletions(-) diff --git a/app/controllers/InvoiceController.php b/app/controllers/InvoiceController.php index e9c26bd1bc4c..21c16f96a931 100755 --- a/app/controllers/InvoiceController.php +++ b/app/controllers/InvoiceController.php @@ -330,6 +330,7 @@ class InvoiceController extends \BaseController { { if (Auth::user()->confirmed) { + $message = trans('texts.emailed_invoice'); $this->mailer->sendInvoice($invoice); Session::flash('message', $message); } diff --git a/app/database/migrations/2014_04_17_145108_add_custom_fields.php b/app/database/migrations/2014_04_17_145108_add_custom_fields.php index ac88c4012b70..7e4c3b1958b2 100644 --- a/app/database/migrations/2014_04_17_145108_add_custom_fields.php +++ b/app/database/migrations/2014_04_17_145108_add_custom_fields.php @@ -24,6 +24,7 @@ class AddCustomFields extends Migration { $table->string('custom_client_label2'); }); + Schema::table('clients', function($table) { $table->string('custom_value1'); diff --git a/app/lang/de/texts.php b/app/lang/de/texts.php index 204d2439dfae..585468e3bc95 100644 --- a/app/lang/de/texts.php +++ b/app/lang/de/texts.php @@ -311,6 +311,12 @@ return array( 'pro_plan_success' => 'Thanks for joining! Once the invoice is paid your Pro Plan membership will begin.', 'unsaved_changes' => 'You have unsaved changes', + 'custom_fields' => 'Custom fields', + 'company_fields' => 'Company Fields', + 'client_fields' => 'Client Fields', + 'field_label' => 'Field Label', + 'field_value' => 'Field Value', + 'edit' => 'Edit', ); diff --git a/app/lang/es/texts.php b/app/lang/es/texts.php index 18628e65cfb6..be773a49c3ae 100644 --- a/app/lang/es/texts.php +++ b/app/lang/es/texts.php @@ -310,6 +310,12 @@ return array( 'pro_plan_success' => 'Thanks for joining! Once the invoice is paid your Pro Plan membership will begin.', 'unsaved_changes' => 'You have unsaved changes', + 'custom_fields' => 'Custom fields', + 'company_fields' => 'Company Fields', + 'client_fields' => 'Client Fields', + 'field_label' => 'Field Label', + 'field_value' => 'Field Value', + 'edit' => 'Edit', ); diff --git a/app/lang/fr/texts.php b/app/lang/fr/texts.php index 60b06e3de8f7..bee14daf1011 100644 --- a/app/lang/fr/texts.php +++ b/app/lang/fr/texts.php @@ -311,6 +311,12 @@ return array( 'pro_plan_success' => 'Merci pour votre inscription ! Une fois la facture réglée, votre adhésion au Plan Pro commencera.', 'unsaved_changes' => 'You have unsaved changes', + 'custom_fields' => 'Custom fields', + 'company_fields' => 'Company Fields', + 'client_fields' => 'Client Fields', + 'field_label' => 'Field Label', + 'field_value' => 'Field Value', + 'edit' => 'Edit', ); diff --git a/app/lang/it/texts.php b/app/lang/it/texts.php index aaaf32bb3d7a..27c98416486f 100644 --- a/app/lang/it/texts.php +++ b/app/lang/it/texts.php @@ -311,6 +311,12 @@ return array( 'pro_plan_success' => 'Thanks for joining! Once the invoice is paid your Pro Plan membership will begin.', 'unsaved_changes' => 'You have unsaved changes', + 'custom_fields' => 'Custom fields', + 'company_fields' => 'Company Fields', + 'client_fields' => 'Client Fields', + 'field_label' => 'Field Label', + 'field_value' => 'Field Value', + 'edit' => 'Edit', ); diff --git a/app/lang/nl/texts.php b/app/lang/nl/texts.php index 06bec940f064..fd12717c2247 100644 --- a/app/lang/nl/texts.php +++ b/app/lang/nl/texts.php @@ -311,6 +311,12 @@ return array( 'pro_plan_success' => 'Thanks for joining! Once the invoice is paid your Pro Plan membership will begin.', 'unsaved_changes' => 'You have unsaved changes', + 'custom_fields' => 'Custom fields', + 'company_fields' => 'Company Fields', + 'client_fields' => 'Client Fields', + 'field_label' => 'Field Label', + 'field_value' => 'Field Value', + 'edit' => 'Edit', ); diff --git a/app/lang/pt_BR/texts.php b/app/lang/pt_BR/texts.php index d4f9aa17cf47..2fed2a0de56f 100644 --- a/app/lang/pt_BR/texts.php +++ b/app/lang/pt_BR/texts.php @@ -299,6 +299,12 @@ return array( 'pro_plan_success' => 'Thanks for joining! Once the invoice is paid your Pro Plan membership will begin.', 'unsaved_changes' => 'You have unsaved changes', + 'custom_fields' => 'Custom fields', + 'company_fields' => 'Company Fields', + 'client_fields' => 'Client Fields', + 'field_label' => 'Field Label', + 'field_value' => 'Field Value', + 'edit' => 'Edit', ); diff --git a/app/models/Invoice.php b/app/models/Invoice.php index 4fda510865e6..e49d2b67679d 100755 --- a/app/models/Invoice.php +++ b/app/models/Invoice.php @@ -57,23 +57,76 @@ class Invoice extends EntityModel return $this->invoice_status_id >= INVOICE_STATUS_PAID; } - - public function hidePrivateFields() { - $this->setVisible(['invoice_number', 'discount', 'po_number', 'invoice_date', 'due_date', 'terms', 'public_notes', 'amount', 'balance', 'invoice_items', 'client', 'tax_name', 'tax_rate', 'account', 'invoice_design_id']); + $this->setVisible([ + 'invoice_number', + 'discount', + 'po_number', + 'invoice_date', + 'due_date', + 'terms', + 'public_notes', + 'amount', + 'balance', + 'invoice_items', + 'client', + 'tax_name', + 'tax_rate', + 'account', + 'invoice_design_id']); - $this->client->setVisible(['name', 'address1', 'address2', 'city', 'state', 'postal_code', 'work_phone', 'payment_terms', 'contacts', 'country', 'currency_id' ]); - $this->account->setVisible(['name', 'address1', 'address2', 'city', 'state', 'postal_code', 'work_phone', 'work_email', 'country', 'currency_id']); + $this->client->setVisible([ + 'name', + 'address1', + 'address2', + 'city', + 'state', + 'postal_code', + 'work_phone', + 'payment_terms', + 'contacts', + 'country', + 'currency_id', + 'custom_value1', + 'custom_value2']); + + $this->account->setVisible([ + 'name', + 'address1', + 'address2', + 'city', + 'state', + 'postal_code', + 'work_phone', + 'work_email', + 'country', + 'currency_id', + 'custom_label1', + 'custom_value1', + 'custom_label2', + 'custom_value2', + 'custom_client_label1', + 'custom_client_label2']); foreach ($this->invoice_items as $invoiceItem) { - $invoiceItem->setVisible(['product_key', 'notes', 'cost', 'qty', 'tax_name', 'tax_rate']); + $invoiceItem->setVisible([ + 'product_key', + 'notes', + 'cost', + 'qty', + 'tax_name', + 'tax_rate']); } foreach ($this->client->contacts as $contact) { - $contact->setVisible(['first_name', 'last_name', 'email', 'phone']); + $contact->setVisible([ + 'first_name', + 'last_name', + 'email', + 'phone']); } return $this;