diff --git a/app/Models/Account.php b/app/Models/Account.php index e38cb25980d0..ac7dea62756c 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -231,6 +231,14 @@ class Account extends Eloquent 'invoice2', 'invoice_surcharge1', 'invoice_surcharge2', + 'task1', + 'task2', + 'project1', + 'project2', + 'expense1', + 'expense2', + 'vendor1', + 'vendor2', ]; public static $customLabels = [ diff --git a/app/Models/Expense.php b/app/Models/Expense.php index 34c92288a83c..a71612ca5fe7 100644 --- a/app/Models/Expense.php +++ b/app/Models/Expense.php @@ -52,6 +52,8 @@ class Expense extends EntityModel 'transaction_reference', 'invoice_documents', 'should_be_invoiced', + 'custom_value1', + 'custom_value2', ]; public static function getImportColumns() diff --git a/app/Models/Project.php b/app/Models/Project.php index 7b694a42b419..54d70fc473e4 100644 --- a/app/Models/Project.php +++ b/app/Models/Project.php @@ -28,6 +28,8 @@ class Project extends EntityModel 'private_notes', 'due_date', 'budgeted_hours', + 'custom_value1', + 'custom_value2', ]; /** diff --git a/app/Models/Task.php b/app/Models/Task.php index 5c54c6ba42b4..f14dd5098feb 100644 --- a/app/Models/Task.php +++ b/app/Models/Task.php @@ -24,6 +24,8 @@ class Task extends EntityModel 'description', 'time_log', 'is_running', + 'custom_value1', + 'custom_value2', ]; /** diff --git a/app/Models/Vendor.php b/app/Models/Vendor.php index 8ed404cd7201..a3cd62178243 100644 --- a/app/Models/Vendor.php +++ b/app/Models/Vendor.php @@ -44,6 +44,8 @@ class Vendor extends EntityModel 'currency_id', 'website', 'transaction_name', + 'custom_value1', + 'custom_value2', ]; /** diff --git a/app/Ninja/Repositories/TaskRepository.php b/app/Ninja/Repositories/TaskRepository.php index f1c5993d6163..e021628bfa9f 100644 --- a/app/Ninja/Repositories/TaskRepository.php +++ b/app/Ninja/Repositories/TaskRepository.php @@ -159,6 +159,8 @@ class TaskRepository extends BaseRepository return $task; } + $task->fill($data); + if (isset($data['client'])) { $task->client_id = $data['client'] ? Client::getPrivateId($data['client']) : null; } elseif (isset($data['client_id'])) { diff --git a/database/migrations/2018_03_30_115805_add_more_custom_fields.php b/database/migrations/2018_03_30_115805_add_more_custom_fields.php index dc7c01d1c069..c4d9dc99e5ed 100644 --- a/database/migrations/2018_03_30_115805_add_more_custom_fields.php +++ b/database/migrations/2018_03_30_115805_add_more_custom_fields.php @@ -71,6 +71,26 @@ class AddMoreCustomFields extends Migration $table->dropColumn('custom_invoice_item_label1'); $table->dropColumn('custom_invoice_item_label2'); }); + + Schema::table('tasks', function ($table) { + $table->string('custom_value1')->nullable(); + $table->string('custom_value2')->nullable(); + }); + + Schema::table('projects', function ($table) { + $table->string('custom_value1')->nullable(); + $table->string('custom_value2')->nullable(); + }); + + Schema::table('expenses', function ($table) { + $table->string('custom_value1')->nullable(); + $table->string('custom_value2')->nullable(); + }); + + Schema::table('vendors', function ($table) { + $table->string('custom_value1')->nullable(); + $table->string('custom_value2')->nullable(); + }); } /** diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index b85b7f56544a..56988b37cff7 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -2803,7 +2803,21 @@ $LANG = array( 'vendors_will_create' => 'vendors will be created', 'created_vendors' => 'Successfully created :count vendor(s)', 'import_vendors' => 'Import Vendors', - + 'company' => 'Company', + 'client_field' => 'Client Field', + 'contact_field' => 'Contact Field', + 'product_field' => 'Product Field', + 'task_field' => 'Task Field', + 'project_field' => 'Project Field', + 'expense_field' => 'Expense Field', + 'vendor_field' => 'Vendor Field', + 'company_field' => 'Company Field', + 'invoice_field' => 'Invoice Field', + 'invoice_surcharge' => 'Invoice Surcharge', + 'custom_task_fields_help' => 'Add a field when creating a task.', + 'custom_project_fields_help' => 'Add a field when creating a project.', + 'custom_expense_fields_help' => 'Add a field when creating an expense.', + 'custom_vendor_fields_help' => 'Add a field when creating a vendor.', ); return $LANG; diff --git a/resources/views/accounts/invoice_settings.blade.php b/resources/views/accounts/invoice_settings.blade.php index 849a2fe05f61..53bc7c049d6c 100644 --- a/resources/views/accounts/invoice_settings.blade.php +++ b/resources/views/accounts/invoice_settings.blade.php @@ -224,90 +224,76 @@
-
-
- - {!! Former::text('custom_fields[client1]') - ->label(trans('texts.field_label')) !!} - {!! Former::text('custom_fields[client2]') - ->label(trans('texts.field_label')) - ->help(trans('texts.custom_client_fields_helps') . ' ' . trans('texts.custom_fields_tip')) !!} - -
-
-
-
- - {!! Former::text('custom_fields[contact1]') - ->label(trans('texts.field_label')) !!} - {!! Former::text('custom_fields[contact2]') - ->label(trans('texts.field_label')) - ->help(trans('texts.custom_contact_fields_help') . ' ' . trans('texts.custom_fields_tip')) !!} - -
-
-
-
- - {!! Former::text('custom_fields[account1]') - ->label(trans('texts.field_label')) !!} - {!! Former::text('custom_value1') - ->label(trans('texts.field_value')) !!} -

 

- {!! Former::text('custom_fields[account2]') - ->label(trans('texts.field_label')) !!} - {!! Former::text('custom_value2') - ->label(trans('texts.field_value')) - ->help(trans('texts.custom_account_fields_helps')) !!} - -
-
-
+
{!! Former::text('custom_fields[product1]') - ->label(trans('texts.field_label')) !!} + ->label('product_field') + ->data_lpignore('true') !!} {!! Former::text('custom_fields[product2]') - ->label(trans('texts.field_label')) + ->label('product_field') + ->data_lpignore('true') ->help(trans('texts.custom_product_fields_help') . ' ' . trans('texts.custom_fields_tip')) !!}
+
+
+ + {!! Former::text('custom_fields[client1]') + ->label('client_field') !!} + {!! Former::text('custom_fields[client2]') + ->label('client_field') + ->help(trans('texts.custom_client_fields_helps') . ' ' . trans('texts.custom_fields_tip')) !!} + +
+ + {!! Former::text('custom_fields[contact1]') + ->label('contact_field') !!} + {!! Former::text('custom_fields[contact2]') + ->label('contact_field') + ->help(trans('texts.custom_contact_fields_help') . ' ' . trans('texts.custom_fields_tip')) !!} + +
+
{!! Former::text('custom_fields[invoice_text1]') - ->label(trans('texts.field_label')) !!} + ->label('invoice_field') !!} {!! Former::text('custom_fields[invoice_text2]') - ->label(trans('texts.field_label')) + ->label('invoice_field') ->help(trans('texts.custom_invoice_fields_helps') . ' ' . trans('texts.custom_fields_tip')) !!} {!! Former::text('custom_fields[invoice1]') - ->label(trans('texts.surcharge_label')) + ->label('invoice_surcharge') ->addGroupClass('pad-checkbox') ->append(Former::checkbox('custom_invoice_taxes1') ->value(1) ->raw() . trans('texts.charge_taxes')) !!} {!! Former::text('custom_fields[invoice2]') - ->label(trans('texts.surcharge_label')) + ->label('invoice_surcharge') ->addGroupClass('pad-checkbox') ->append(Former::checkbox('custom_invoice_taxes2') ->value(1) @@ -316,6 +302,60 @@
+
+
+ + {!! Former::text('custom_fields[task1]') + ->label('task_field') !!} + {!! Former::text('custom_fields[task2]') + ->label('task_field') + ->help(trans('texts.custom_task_fields_help') . ' ' . trans('texts.custom_fields_tip')) !!} + +
+ + {!! Former::text('custom_fields[project1]') + ->label('project_field') !!} + {!! Former::text('custom_fields[project2]') + ->label('project_field') + ->help(trans('texts.custom_project_fields_help') . ' ' . trans('texts.custom_fields_tip')) !!} + +
+
+
+
+ + {!! Former::text('custom_fields[expense1]') + ->label(trans('texts.expense_field')) !!} + {!! Former::text('custom_fields[expense2]') + ->label(trans('texts.expense_field')) + ->help(trans('texts.custom_expense_fields_help') . ' ' . trans('texts.custom_fields_tip')) !!} + +
+ + {!! Former::text('custom_fields[vendor1]') + ->label(trans('texts.vendor_field')) !!} + {!! Former::text('custom_fields[vendor2]') + ->label(trans('texts.vendor_field')) + ->help(trans('texts.custom_vendor_fields_help') . ' ' . trans('texts.custom_fields_tip')) !!} + +
+
+
+
+ + {!! Former::text('custom_fields[account1]') + ->label(trans('texts.company_field')) !!} + {!! Former::text('custom_value1') + ->label(trans('texts.field_value')) !!} +

 

+ {!! Former::text('custom_fields[account2]') + ->label(trans('texts.company_field')) !!} + {!! Former::text('custom_value2') + ->label(trans('texts.field_value')) + ->help(trans('texts.custom_account_fields_help')) !!} + +
+
diff --git a/resources/views/accounts/product.blade.php b/resources/views/accounts/product.blade.php index 8b0a91931f65..279540070e86 100644 --- a/resources/views/accounts/product.blade.php +++ b/resources/views/accounts/product.blade.php @@ -28,20 +28,7 @@ {!! Former::text('product_key')->label('texts.product') !!} {!! Former::textarea('notes')->rows(6) !!} - @if ($account->hasFeature(FEATURE_INVOICE_SETTINGS)) - @if ($account->customLabel('product1')) - @include('partials.custom_field', [ - 'field' => 'custom_value1', - 'label' => $account->customLabel('product1') - ]) - @endif - @if ($account->customLabel('product2')) - @include('partials.custom_field', [ - 'field' => 'custom_value2', - 'label' => $account->customLabel('product2') - ]) - @endif - @endif + @include('partials/custom_fields', ['entityType' => ENTITY_PRODUCT]) {!! Former::text('cost') !!} diff --git a/resources/views/clients/edit.blade.php b/resources/views/clients/edit.blade.php index b521c094d64d..6552f119f57c 100644 --- a/resources/views/clients/edit.blade.php +++ b/resources/views/clients/edit.blade.php @@ -52,20 +52,8 @@ {!! Former::text('website') !!} {!! Former::text('work_phone') !!} - @if (Auth::user()->hasFeature(FEATURE_INVOICE_SETTINGS)) - @if ($customLabel1) - @include('partials.custom_field', [ - 'field' => 'custom_value1', - 'label' => $customLabel1 - ]) - @endif - @if ($customLabel2) - @include('partials.custom_field', [ - 'field' => 'custom_value2', - 'label' => $customLabel2 - ]) - @endif - @endif + + @include('partials/custom_fields', ['entityType' => ENTITY_CLIENT]) @if ($account->usesClientInvoiceCounter()) {!! Former::text('invoice_number_counter')->label('invoice_counter') !!} diff --git a/resources/views/expenses/edit.blade.php b/resources/views/expenses/edit.blade.php index 9be579914b31..8ea7282a4f1e 100644 --- a/resources/views/expenses/edit.blade.php +++ b/resources/views/expenses/edit.blade.php @@ -79,6 +79,8 @@ ->addGroupClass('client-select') !!} @endif + @include('partials/custom_fields', ['entityType' => ENTITY_EXPENSE]) + @if (count($taxRates)) @if (!$expense || ($expense && (!$expense->tax_name1 && !$expense->tax_name2))) {!! Former::checkbox('apply_taxes') diff --git a/resources/views/partials/custom_fields.blade.php b/resources/views/partials/custom_fields.blade.php new file mode 100644 index 000000000000..5f2647cd8608 --- /dev/null +++ b/resources/views/partials/custom_fields.blade.php @@ -0,0 +1,14 @@ +@if (Auth::user()->hasFeature(FEATURE_INVOICE_SETTINGS)) + @if ($customLabel = $account->customLabel($entityType . '1')) + @include('partials.custom_field', [ + 'field' => 'custom_value1', + 'label' => $customLabel + ]) + @endif + @if ($customLabel = $account->customLabel($entityType . '2')) + @include('partials.custom_field', [ + 'field' => 'custom_value2', + 'label' => $customLabel + ]) + @endif +@endif diff --git a/resources/views/projects/edit.blade.php b/resources/views/projects/edit.blade.php index 5a7b1931cf77..5353c59e1681 100644 --- a/resources/views/projects/edit.blade.php +++ b/resources/views/projects/edit.blade.php @@ -51,6 +51,8 @@ ->placeholder($project && $project->client->task_rate ? $project->client->present()->taskRate : $account->present()->taskRate) ->help('task_rate_help') !!} + @include('partials/custom_fields', ['entityType' => ENTITY_PROJECT]) + {!! Former::textarea('private_notes')->rows(4) !!} diff --git a/resources/views/projects/show.blade.php b/resources/views/projects/show.blade.php index 586524793cf3..cd587fb2f7cf 100644 --- a/resources/views/projects/show.blade.php +++ b/resources/views/projects/show.blade.php @@ -71,6 +71,14 @@ @if ($project->present()->defaultTaskRate) {{ trans('texts.task_rate') . ': ' . $project->present()->defaultTaskRate }}
@endif + + @if ($account->customLabel('project1') && $project->custom_value1) + {{ $account->present()->customLabel('project1') . ': ' . $project->custom_value1 }}
+ @endif + @if ($account->customLabel('project2') && $project->custom_value2) + {{ $account->present()->customLabel('project2') . ': ' . $project->custom_value2 }}
+ @endif +
diff --git a/resources/views/reports/report_builder.blade.php b/resources/views/reports/report_builder.blade.php index 79dbfc009ba0..990832c14d9f 100644 --- a/resources/views/reports/report_builder.blade.php +++ b/resources/views/reports/report_builder.blade.php @@ -699,7 +699,7 @@ var subtotal = 0; $rows.each(function() { var txt = $(this).find("td").eq(i).text(); - subtotal += convertStringToNumber(txt); + subtotal += convertStringToNumber(txt) || 0; }); $cell.find(".group-count").append(' - ' + label + ': ' + roundToTwo(subtotal, true)); } diff --git a/resources/views/tasks/edit.blade.php b/resources/views/tasks/edit.blade.php index e7cf89737fdd..a8919040309e 100644 --- a/resources/views/tasks/edit.blade.php +++ b/resources/views/tasks/edit.blade.php @@ -65,6 +65,8 @@ ->label(trans('texts.project')) !!} @endif + @include('partials/custom_fields', ['entityType' => ENTITY_TASK]) + {!! Former::textarea('description')->rows(4) !!} @if ($task) diff --git a/resources/views/vendors/edit.blade.php b/resources/views/vendors/edit.blade.php index d34101bdfb42..b28183978cb5 100644 --- a/resources/views/vendors/edit.blade.php +++ b/resources/views/vendors/edit.blade.php @@ -44,6 +44,7 @@ {!! Former::text('website') !!} {!! Former::text('work_phone') !!} + @include('partials/custom_fields', ['entityType' => ENTITY_VENDOR])
diff --git a/resources/views/vendors/show.blade.php b/resources/views/vendors/show.blade.php index e927bf3da5f3..d7700466ed0b 100644 --- a/resources/views/vendors/show.blade.php +++ b/resources/views/vendors/show.blade.php @@ -88,6 +88,14 @@

{{ trans('texts.vat_number').': '.$vendor->vat_number }}

@endif + @if ($vendor->account->customLabel('vendor1') && $vendor->custom_value1) + {{ $vendor->account->present()->customLabel('vendor1') . ': ' . $vendor->custom_value1 }}
+ @endif + @if ($vendor->account->customLabel('vendor2') && $vendor->custom_value2) + {{ $vendor->account->present()->customLabel('vendor2') . ': ' . $vendor->custom_value2 }}
+ @endif + + @if ($vendor->address1) {{ $vendor->address1 }}
@endif