mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 12:34:30 -04:00
Added custom contact fields
This commit is contained in:
parent
b327a20f10
commit
96de6739bb
@ -892,6 +892,8 @@ class AccountController extends BaseController
|
||||
$account->custom_value2 = trim(Input::get('custom_value2'));
|
||||
$account->custom_client_label1 = trim(Input::get('custom_client_label1'));
|
||||
$account->custom_client_label2 = trim(Input::get('custom_client_label2'));
|
||||
$account->custom_contact_label1 = trim(Input::get('custom_contact_label1'));
|
||||
$account->custom_contact_label2 = trim(Input::get('custom_contact_label2'));
|
||||
$account->custom_invoice_label1 = trim(Input::get('custom_invoice_label1'));
|
||||
$account->custom_invoice_label2 = trim(Input::get('custom_invoice_label2'));
|
||||
$account->custom_invoice_taxes1 = Input::get('custom_invoice_taxes1') ? true : false;
|
||||
|
@ -92,9 +92,6 @@ class Account extends Eloquent
|
||||
'quote_number_counter',
|
||||
'share_counter',
|
||||
'id_number',
|
||||
'email_template_invoice',
|
||||
'email_template_quote',
|
||||
'email_template_payment',
|
||||
'token_billing_type_id',
|
||||
'invoice_footer',
|
||||
'pdf_email_attachment',
|
||||
@ -103,15 +100,6 @@ class Account extends Eloquent
|
||||
'custom_design',
|
||||
'show_item_taxes',
|
||||
'military_time',
|
||||
'email_subject_invoice',
|
||||
'email_subject_quote',
|
||||
'email_subject_payment',
|
||||
'email_subject_reminder1',
|
||||
'email_subject_reminder2',
|
||||
'email_subject_reminder3',
|
||||
'email_template_reminder1',
|
||||
'email_template_reminder2',
|
||||
'email_template_reminder3',
|
||||
'enable_reminder1',
|
||||
'enable_reminder2',
|
||||
'enable_reminder3',
|
||||
@ -173,6 +161,8 @@ class Account extends Eloquent
|
||||
'payment_type_id',
|
||||
'gateway_fee_enabled',
|
||||
'reset_counter_date',
|
||||
'custom_contact_label1',
|
||||
'custom_contact_label2',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -37,6 +37,8 @@ class Contact extends EntityModel implements AuthenticatableContract, CanResetPa
|
||||
'email',
|
||||
'phone',
|
||||
'send_invoice',
|
||||
'custom_value1',
|
||||
'custom_value2',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -901,6 +901,8 @@ class Invoice extends EntityModel implements BalanceAffecting
|
||||
'last_name',
|
||||
'email',
|
||||
'phone',
|
||||
'custom_value1',
|
||||
'custom_value2',
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -68,6 +68,12 @@ trait PresentsInvoice
|
||||
if ($this->custom_client_label2) {
|
||||
$fields[INVOICE_FIELDS_CLIENT][] = 'client.custom_value2';
|
||||
}
|
||||
if ($this->custom_contact_label1) {
|
||||
$fields[INVOICE_FIELDS_CLIENT][] = 'contact.custom_value1';
|
||||
}
|
||||
if ($this->custom_contact_label2) {
|
||||
$fields[INVOICE_FIELDS_CLIENT][] = 'contact.custom_value2';
|
||||
}
|
||||
if ($this->custom_label1) {
|
||||
$fields['account_fields2'][] = 'account.custom_value1';
|
||||
}
|
||||
@ -108,6 +114,8 @@ trait PresentsInvoice
|
||||
'client.phone',
|
||||
'client.custom_value1',
|
||||
'client.custom_value2',
|
||||
'contact.custom_value1',
|
||||
'contact.custom_value2',
|
||||
'.blank',
|
||||
],
|
||||
INVOICE_FIELDS_ACCOUNT => [
|
||||
@ -242,12 +250,14 @@ trait PresentsInvoice
|
||||
}
|
||||
|
||||
foreach ([
|
||||
'account.custom_value1' => 'custom_label1',
|
||||
'account.custom_value2' => 'custom_label2',
|
||||
'invoice.custom_text_value1' => 'custom_invoice_text_label1',
|
||||
'invoice.custom_text_value2' => 'custom_invoice_text_label2',
|
||||
'client.custom_value1' => 'custom_client_label1',
|
||||
'client.custom_value2' => 'custom_client_label2',
|
||||
'account.custom_value1' => 'custom_label1',
|
||||
'account.custom_value2' => 'custom_label2',
|
||||
'contact.custom_value1' => 'custom_contact_label1',
|
||||
'contact.custom_value2' => 'custom_contact_label2',
|
||||
] as $field => $property) {
|
||||
$data[$field] = $this->$property ?: trans('texts.custom_field');
|
||||
}
|
||||
|
@ -155,6 +155,8 @@ class AccountPresenter extends Presenter
|
||||
$fields = [
|
||||
'custom_client_label1' => 'custom_client1',
|
||||
'custom_client_label2' => 'custom_client2',
|
||||
'custom_contact_label1' => 'custom_contact1',
|
||||
'custom_contact_label2' => 'custom_contact2',
|
||||
'custom_invoice_text_label1' => 'custom_invoice1',
|
||||
'custom_invoice_text_label2' => 'custom_invoice2',
|
||||
'custom_invoice_item_label1' => 'custom_product1',
|
||||
|
@ -266,6 +266,8 @@ class AccountTransformer extends EntityTransformer
|
||||
'payment_type_id' => (int) $account->payment_type_id,
|
||||
'gateway_fee_enabled' => (bool) $account->gateway_fee_enabled,
|
||||
'reset_counter_date' => $account->reset_counter_date,
|
||||
'custom_contact_label1' => $account->custom_contact_label1,
|
||||
'custom_contact_label2' => $account->custom_contact_label2,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,8 @@ class ContactTransformer extends EntityTransformer
|
||||
* @SWG\Property(property="phone", type="string", example="(212) 555-1212")
|
||||
* @SWG\Property(property="last_login", type="string", format="date-time", example="2016-01-01 12:10:00")
|
||||
* @SWG\Property(property="send_invoice", type="boolean", example=false)
|
||||
* @SWG\Property(property="custom_value1", type="string", example="Value")
|
||||
* @SWG\Property(property="custom_value2", type="string", example="Value")
|
||||
*/
|
||||
public function transform(Contact $contact)
|
||||
{
|
||||
@ -40,6 +42,8 @@ class ContactTransformer extends EntityTransformer
|
||||
'phone' => $contact->phone,
|
||||
'last_login' => $contact->last_login,
|
||||
'send_invoice' => (bool) $contact->send_invoice,
|
||||
'custom_value1' => $contact->custom_value1,
|
||||
'custom_value2' => $contact->custom_value2,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ class TemplateService
|
||||
$invitation = $data['invitation'];
|
||||
|
||||
$invoice = $invitation->invoice;
|
||||
$contact = $invitation->contact;
|
||||
$passwordHTML = isset($data['password']) ? '<p>'.trans('texts.password').': '.$data['password'].'<p>' : false;
|
||||
$documentsHTML = '';
|
||||
|
||||
@ -50,8 +51,8 @@ class TemplateService
|
||||
'$account' => $account->getDisplayName(),
|
||||
'$dueDate' => $account->formatDate($invoice->due_date),
|
||||
'$invoiceDate' => $account->formatDate($invoice->invoice_date),
|
||||
'$contact' => $invitation->contact->getDisplayName(),
|
||||
'$firstName' => $invitation->contact->first_name,
|
||||
'$contact' => $contact->getDisplayName(),
|
||||
'$firstName' => $contact->first_name,
|
||||
'$amount' => $account->formatMoney($data['amount'], $client),
|
||||
'$invoice' => $invoice->invoice_number,
|
||||
'$quote' => $invoice->invoice_number,
|
||||
@ -63,6 +64,8 @@ class TemplateService
|
||||
'$paymentButton' => Form::emailPaymentButton($invitation->getLink('payment')).'$password',
|
||||
'$customClient1' => $client->custom_value1,
|
||||
'$customClient2' => $client->custom_value2,
|
||||
'$customContact1' => $contact->custom_value1,
|
||||
'$customContact2' => $contact->custom_value2,
|
||||
'$customInvoice1' => $invoice->custom_text_value1,
|
||||
'$customInvoice2' => $invoice->custom_text_value2,
|
||||
'$documents' => $documentsHTML,
|
||||
|
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddCustomContactFields extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('accounts', function ($table) {
|
||||
$table->string('custom_contact_label1')->nullable();
|
||||
$table->string('custom_contact_label2')->nullable();
|
||||
});
|
||||
|
||||
Schema::table('contacts', 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_contact_label1');
|
||||
$table->dropColumn('custom_contact_label2');
|
||||
});
|
||||
|
||||
Schema::table('contacts', function ($table) {
|
||||
$table->dropColumn('custom_value1');
|
||||
$table->dropColumn('custom_value2');
|
||||
});
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -884,6 +884,10 @@ NINJA.renderClientOrAccountField = function(invoice, field) {
|
||||
return {text: account.custom_client_label1 && client.custom_value1 ? account.custom_client_label1 + ' ' + client.custom_value1 : false};
|
||||
} else if (field == 'client.custom_value2') {
|
||||
return {text: account.custom_client_label2 && client.custom_value2 ? account.custom_client_label2 + ' ' + client.custom_value2 : false};
|
||||
} else if (field == 'contact.custom_value1') {
|
||||
return {text:contact.custom_value1};
|
||||
} else if (field == 'contact.custom_value2') {
|
||||
return {text:contact.custom_value2};
|
||||
}
|
||||
|
||||
if (field == 'account.company_name') {
|
||||
@ -948,6 +952,8 @@ NINJA.clientDetails = function(invoice) {
|
||||
'client.email',
|
||||
'client.custom_value1',
|
||||
'client.custom_value2',
|
||||
'contact.custom_value1',
|
||||
'contact.custom_value2',
|
||||
];
|
||||
}
|
||||
var data = [];
|
||||
|
@ -2475,6 +2475,9 @@ $LANG = array(
|
||||
'recommend_on' => 'We recommend <b>enabling</b> this setting.',
|
||||
'recommend_off' => 'We recommend <b>disabling</b> this setting.',
|
||||
'notes_auto_billed' => 'Auto-billed',
|
||||
'surcharge_label' => 'Surcharge Label',
|
||||
'contact_fields' => 'Contact Fields',
|
||||
'custom_contact_fields_help' => 'Add a field when creating a contact and display the label and value on the PDF.',
|
||||
|
||||
);
|
||||
|
||||
|
@ -187,6 +187,9 @@
|
||||
<li role="presentation" class="active">
|
||||
<a href="#client_fields" aria-controls="client_fields" role="tab" data-toggle="tab">{{ trans('texts.client_fields') }}</a>
|
||||
</li>
|
||||
<li role="presentation">
|
||||
<a href="#contact_fields" aria-controls="contact_fields" role="tab" data-toggle="tab">{{ trans('texts.contact_fields') }}</a>
|
||||
</li>
|
||||
<li role="presentation">
|
||||
<a href="#company_fields" aria-controls="company_fields" role="tab" data-toggle="tab">{{ trans('texts.company_fields') }}</a>
|
||||
</li>
|
||||
@ -196,9 +199,6 @@
|
||||
<li role="presentation">
|
||||
<a href="#invoice_fields" aria-controls="invoice_fields" role="tab" data-toggle="tab">{{ trans('texts.invoice_fields') }}</a>
|
||||
</li>
|
||||
<li role="presentation">
|
||||
<a href="#invoice_surcharges" aria-controls="invoice_surcharges" role="tab" data-toggle="tab">{{ trans('texts.invoice_charges') }}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="tab-content">
|
||||
@ -213,6 +213,17 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div role="tabpanel" class="tab-pane" id="contact_fields">
|
||||
<div class="panel-body">
|
||||
|
||||
{!! Former::text('custom_contact_label1')
|
||||
->label(trans('texts.field_label')) !!}
|
||||
{!! Former::text('custom_contact_label2')
|
||||
->label(trans('texts.field_label'))
|
||||
->help(trans('texts.custom_contact_fields_help')) !!}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div role="tabpanel" class="tab-pane" id="company_fields">
|
||||
<div class="panel-body">
|
||||
|
||||
@ -249,20 +260,15 @@
|
||||
->label(trans('texts.field_label'))
|
||||
->help(trans('texts.custom_invoice_fields_helps')) !!}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div role="tabpanel" class="tab-pane" id="invoice_surcharges">
|
||||
<div class="panel-body">
|
||||
|
||||
{!! Former::text('custom_invoice_label1')
|
||||
->label(trans('texts.field_label'))
|
||||
->label(trans('texts.surcharge_label'))
|
||||
->addGroupClass('pad-checkbox')
|
||||
->append(Former::checkbox('custom_invoice_taxes1')
|
||||
->value(1)
|
||||
->raw() . trans('texts.charge_taxes')) !!}
|
||||
|
||||
{!! Former::text('custom_invoice_label2')
|
||||
->label(trans('texts.field_label'))
|
||||
->label(trans('texts.surcharge_label'))
|
||||
->addGroupClass('pad-checkbox')
|
||||
->append(Former::checkbox('custom_invoice_taxes2')
|
||||
->value(1)
|
||||
|
@ -174,6 +174,12 @@
|
||||
@if ($account->custom_client_label2)
|
||||
<li>$customClient2</li>
|
||||
@endif
|
||||
@if ($account->custom_contact_label1)
|
||||
<li>$customContact1</li>
|
||||
@endif
|
||||
@if ($account->custom_contact_label2)
|
||||
<li>$customContact2</li>
|
||||
@endif
|
||||
@if ($account->custom_invoice_text_label1)
|
||||
<li>$customInvoice1</li>
|
||||
@endif
|
||||
|
@ -110,6 +110,20 @@
|
||||
{!! Former::password('password')->data_bind("value: password()?'-%unchanged%-':'', valueUpdate: 'afterkeydown',
|
||||
attr: {name: 'contacts[' + \$index() + '][password]'}")->autocomplete('new-password') !!}
|
||||
@endif
|
||||
|
||||
@if (Auth::user()->hasFeature(FEATURE_INVOICE_SETTINGS))
|
||||
@if ($account->custom_contact_label1)
|
||||
{!! Former::text('custom_contact1')->data_bind("value: custom_value1, valueUpdate: 'afterkeydown',
|
||||
attr: {name: 'contacts[' + \$index() + '][custom_value1]'}")
|
||||
->label($account->custom_contact_label1) !!}
|
||||
@endif
|
||||
@if ($account->custom_contact_label2)
|
||||
{!! Former::text('custom_contact2')->data_bind("value: custom_value2, valueUpdate: 'afterkeydown',
|
||||
attr: {name: 'contacts[' + \$index() + '][custom_value2]'}")
|
||||
->label($account->custom_contact_label2) !!}
|
||||
@endif
|
||||
@endif
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-lg-8 col-lg-offset-4 bold">
|
||||
<span class="redlink bold" data-bind="visible: $parent.contacts().length > 1">
|
||||
@ -212,6 +226,8 @@
|
||||
self.email = ko.observable('');
|
||||
self.phone = ko.observable('');
|
||||
self.password = ko.observable('');
|
||||
self.custom_value1 = ko.observable('');
|
||||
self.custom_value2 = ko.observable('');
|
||||
|
||||
if (data) {
|
||||
ko.mapping.fromJS(data, {}, this);
|
||||
|
@ -156,6 +156,14 @@
|
||||
@if ($contact->phone)
|
||||
<i class="fa fa-phone" style="width: 20px"></i>{{ $contact->phone }}<br/>
|
||||
@endif
|
||||
|
||||
@if ($client->account->custom_contact_label1 && $contact->custom_value1)
|
||||
{{ $client->account->custom_contact_label1 . ': ' . $contact->custom_value1 }}<br/>
|
||||
@endif
|
||||
@if ($client->account->custom_contact_label2 && $contact->custom_value2)
|
||||
{{ $client->account->custom_contact_label2 . ': ' . $contact->custom_value2 }}<br/>
|
||||
@endif
|
||||
|
||||
@if (Auth::user()->confirmed && $client->account->enable_client_portal)
|
||||
<i class="fa fa-dashboard" style="width: 20px"></i><a href="{{ $contact->link }}"
|
||||
onclick="window.open('{{ $contact->link }}?silent=true', '_blank');return false;">{{ trans('texts.view_client_portal') }}
|
||||
|
@ -7,6 +7,12 @@
|
||||
<td>{{ trans('texts.last_name') }}</td>
|
||||
<td>{{ trans('texts.email') }}</td>
|
||||
<td>{{ trans('texts.phone') }}</td>
|
||||
@if ($account->custom_contact_label1)
|
||||
<td>{{ $account->custom_contact_label1 }}</td>
|
||||
@endif
|
||||
@if ($account->custom_contact_label2)
|
||||
<td>{{ $account->custom_contact_label2 }}</td>
|
||||
@endif
|
||||
</tr>
|
||||
|
||||
@foreach ($contacts as $contact)
|
||||
@ -20,6 +26,12 @@
|
||||
<td>{{ $contact->last_name }}</td>
|
||||
<td>{{ $contact->email }}</td>
|
||||
<td>{{ $contact->phone }}</td>
|
||||
@if ($account->custom_contact_label1)
|
||||
<td>{{ $contact->custom_value1 }}</td>
|
||||
@endif
|
||||
@if ($account->custom_contact_label2)
|
||||
<td>{{ $contact->custom_value2 }}</td>
|
||||
@endif
|
||||
</tr>
|
||||
@endif
|
||||
@endforeach
|
||||
|
@ -699,6 +699,18 @@
|
||||
{!! Former::password('password')->data_bind("value: (typeof password=='function'?password():null)?'-%unchanged%-':'', valueUpdate: 'afterkeydown',
|
||||
attr: {name: 'client[contacts][' + \$index() + '][password]'}")->autocomplete('new-password') !!}
|
||||
@endif
|
||||
@if (Auth::user()->hasFeature(FEATURE_INVOICE_SETTINGS))
|
||||
@if ($account->custom_contact_label1)
|
||||
{!! Former::text('custom_contact1')->data_bind("value: custom_value1, valueUpdate: 'afterkeydown',
|
||||
attr: {name: 'client[contacts][' + \$index() + '][custom_value1]'}")
|
||||
->label($account->custom_contact_label1) !!}
|
||||
@endif
|
||||
@if ($account->custom_contact_label2)
|
||||
{!! Former::text('custom_contact2')->data_bind("value: custom_value2, valueUpdate: 'afterkeydown',
|
||||
attr: {name: 'client[contacts][' + \$index() + '][custom_value2]'}")
|
||||
->label($account->custom_contact_label2) !!}
|
||||
@endif
|
||||
@endif
|
||||
<div class="form-group">
|
||||
<div class="col-lg-8 col-lg-offset-4">
|
||||
<span class="redlink bold" data-bind="visible: $parent.contacts().length > 1">
|
||||
|
@ -646,6 +646,8 @@ function ContactModel(data) {
|
||||
self.email_error = ko.observable('');
|
||||
self.invitation_signature_svg = ko.observable('');
|
||||
self.invitation_signature_date = ko.observable('');
|
||||
self.custom_value1 = ko.observable('');
|
||||
self.custom_value2 = ko.observable('');
|
||||
|
||||
if (data) {
|
||||
ko.mapping.fromJS(data, {}, this);
|
||||
|
@ -35,6 +35,8 @@
|
||||
'portalButton': '{!! Form::flatButton('view_portal', '#36c157') !!}',
|
||||
'customClient1': invoice ? invoice.client.custom_value1 : 'custom value',
|
||||
'customClient2': invoice ? invoice.client.custom_value2 : 'custom value',
|
||||
'customContact1': invoice ? invoice.client.contacts[0].custom_value1 : 'custom value',
|
||||
'customContact2': invoice ? invoice.client.contacts[0].custom_value2 : 'custom value',
|
||||
'customInvoice1': invoice ? invoice.custom_value1 : 'custom value',
|
||||
'customInvoice2': invoice ? invoice.custom_value2 : 'custom value',
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user