Added more custom fields

This commit is contained in:
Hillel Coren 2018-04-04 22:08:37 +03:00
parent 721b48c73f
commit 9fe4339066
19 changed files with 184 additions and 80 deletions

View File

@ -231,6 +231,14 @@ class Account extends Eloquent
'invoice2',
'invoice_surcharge1',
'invoice_surcharge2',
'task1',
'task2',
'project1',
'project2',
'expense1',
'expense2',
'vendor1',
'vendor2',
];
public static $customLabels = [

View File

@ -52,6 +52,8 @@ class Expense extends EntityModel
'transaction_reference',
'invoice_documents',
'should_be_invoiced',
'custom_value1',
'custom_value2',
];
public static function getImportColumns()

View File

@ -28,6 +28,8 @@ class Project extends EntityModel
'private_notes',
'due_date',
'budgeted_hours',
'custom_value1',
'custom_value2',
];
/**

View File

@ -24,6 +24,8 @@ class Task extends EntityModel
'description',
'time_log',
'is_running',
'custom_value1',
'custom_value2',
];
/**

View File

@ -44,6 +44,8 @@ class Vendor extends EntityModel
'currency_id',
'website',
'transaction_name',
'custom_value1',
'custom_value2',
];
/**

View File

@ -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'])) {

View File

@ -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();
});
}
/**

View File

@ -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;

View File

@ -224,90 +224,76 @@
<div role="tabpanel">
<ul class="nav nav-tabs" role="tablist" style="border: none">
<li role="presentation" class="active">
<a href="#client_fields" aria-controls="client_fields" role="tab" data-toggle="tab">{{ trans('texts.client_fields') }}</a>
<a href="#product_fields" aria-controls="product_fields" role="tab" data-toggle="tab">{{ trans('texts.products') }}</a>
</li>
<li role="presentation">
<a href="#contact_fields" aria-controls="contact_fields" role="tab" data-toggle="tab">{{ trans('texts.contact_fields') }}</a>
<a href="#client_fields" aria-controls="client_fields" role="tab" data-toggle="tab">{{ trans('texts.clients') }}</a>
</li>
<li role="presentation">
<a href="#company_fields" aria-controls="company_fields" role="tab" data-toggle="tab">{{ trans('texts.company_fields') }}</a>
<a href="#invoice_fields" aria-controls="invoice_fields" role="tab" data-toggle="tab">{{ trans('texts.invoices') }}</a>
</li>
<li role="presentation">
<a href="#product_fields" aria-controls="product_fields" role="tab" data-toggle="tab">{{ trans('texts.product_fields') }}</a>
<a href="#task_fields" aria-controls="expense_fields" role="tab" data-toggle="tab">{{ trans('texts.tasks') }}</a>
</li>
<li role="presentation">
<a href="#invoice_fields" aria-controls="invoice_fields" role="tab" data-toggle="tab">{{ trans('texts.invoice_fields') }}</a>
<a href="#expense_fields" aria-controls="task_fields" role="tab" data-toggle="tab">{{ trans('texts.expenses') }}</a>
</li>
<li role="presentation">
<a href="#company_fields" aria-controls="company_fields" role="tab" data-toggle="tab">{{ trans('texts.company') }}</a>
</li>
</ul>
</div>
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="client_fields">
<div class="panel-body">
{!! 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')) !!}
</div>
</div>
<div role="tabpanel" class="tab-pane" id="contact_fields">
<div class="panel-body">
{!! 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')) !!}
</div>
</div>
<div role="tabpanel" class="tab-pane" id="company_fields">
<div class="panel-body">
{!! 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_fields[account2]')
->label(trans('texts.field_label')) !!}
{!! Former::text('custom_value2')
->label(trans('texts.field_value'))
->help(trans('texts.custom_account_fields_helps')) !!}
</div>
</div>
<div role="tabpanel" class="tab-pane" id="product_fields">
<div role="tabpanel" class="tab-pane active" id="product_fields">
<div class="panel-body">
{!! 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')) !!}
</div>
</div>
<div role="tabpanel" class="tab-pane" id="client_fields">
<div class="panel-body">
{!! 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')) !!}
<br/>
{!! 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')) !!}
</div>
</div>
<div role="tabpanel" class="tab-pane" id="invoice_fields">
<div class="panel-body">
{!! 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 @@
</div>
</div>
<div role="tabpanel" class="tab-pane" id="task_fields">
<div class="panel-body">
{!! 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')) !!}
<br/>
{!! 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')) !!}
</div>
</div>
<div role="tabpanel" class="tab-pane" id="expense_fields">
<div class="panel-body">
{!! 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')) !!}
<br/>
{!! 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')) !!}
</div>
</div>
<div role="tabpanel" class="tab-pane" id="company_fields">
<div class="panel-body">
{!! Former::text('custom_fields[account1]')
->label(trans('texts.company_field')) !!}
{!! Former::text('custom_value1')
->label(trans('texts.field_value')) !!}
<p>&nbsp;</p>
{!! 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')) !!}
</div>
</div>
</div>
</div>
</div>

View File

@ -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') !!}

View File

@ -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') !!}

View File

@ -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')

View File

@ -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

View File

@ -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) !!}
</div>

View File

@ -71,6 +71,14 @@
@if ($project->present()->defaultTaskRate)
{{ trans('texts.task_rate') . ': ' . $project->present()->defaultTaskRate }}<br/>
@endif
@if ($account->customLabel('project1') && $project->custom_value1)
{{ $account->present()->customLabel('project1') . ': ' . $project->custom_value1 }}<br/>
@endif
@if ($account->customLabel('project2') && $project->custom_value2)
{{ $account->present()->customLabel('project2') . ': ' . $project->custom_value2 }}<br/>
@endif
</div>
<div class="col-md-3">

View File

@ -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));
}

View File

@ -65,6 +65,8 @@
->label(trans('texts.project')) !!}
@endif
@include('partials/custom_fields', ['entityType' => ENTITY_TASK])
{!! Former::textarea('description')->rows(4) !!}
@if ($task)

View File

@ -44,6 +44,7 @@
{!! Former::text('website') !!}
{!! Former::text('work_phone') !!}
@include('partials/custom_fields', ['entityType' => ENTITY_VENDOR])
</div>
</div>

View File

@ -88,6 +88,14 @@
<p><i class="fa fa-vat-number" style="width: 20px"></i>{{ trans('texts.vat_number').': '.$vendor->vat_number }}</p>
@endif
@if ($vendor->account->customLabel('vendor1') && $vendor->custom_value1)
{{ $vendor->account->present()->customLabel('vendor1') . ': ' . $vendor->custom_value1 }}<br/>
@endif
@if ($vendor->account->customLabel('vendor2') && $vendor->custom_value2)
{{ $vendor->account->present()->customLabel('vendor2') . ': ' . $vendor->custom_value2 }}<br/>
@endif
@if ($vendor->address1)
{{ $vendor->address1 }}<br/>
@endif