mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Enabled setting custom invoice item labels
This commit is contained in:
parent
57b5db4ed8
commit
976773ce7b
@ -209,6 +209,7 @@ class AccountController extends BaseController
|
||||
|
||||
$data['invoice'] = $invoice;
|
||||
$data['invoiceDesigns'] = InvoiceDesign::availableDesigns();
|
||||
$data['invoiceLabels'] = json_decode($account->invoice_labels);
|
||||
} else if ($subSection == ACCOUNT_EMAIL_TEMPLATES) {
|
||||
$data['invoiceEmail'] = $account->getEmailTemplate(ENTITY_INVOICE);
|
||||
$data['quoteEmail'] = $account->getEmailTemplate(ENTITY_QUOTE);
|
||||
@ -334,6 +335,13 @@ class AccountController extends BaseController
|
||||
if (Input::has('font_size')) {
|
||||
$account->font_size = intval(Input::get('font_size'));
|
||||
}
|
||||
|
||||
$labels = [];
|
||||
foreach (['item', 'description', 'unit_cost', 'quantity'] as $field) {
|
||||
$labels[$field] = trim(Input::get("labels_{$field}"));
|
||||
}
|
||||
$account->invoice_labels = json_encode($labels);
|
||||
|
||||
$account->save();
|
||||
|
||||
Session::flash('message', trans('texts.updated_settings'));
|
||||
|
@ -367,7 +367,9 @@ class InvoiceController extends BaseController
|
||||
6 => 'Six months',
|
||||
7 => 'Annually',
|
||||
),
|
||||
'recurringHelp' => $recurringHelp
|
||||
'recurringHelp' => $recurringHelp,
|
||||
'invoiceLabels' => Auth::user()->account->getInvoiceLabels(),
|
||||
|
||||
];
|
||||
|
||||
}
|
||||
|
@ -212,6 +212,8 @@ class Account extends Eloquent
|
||||
public function getInvoiceLabels()
|
||||
{
|
||||
$data = [];
|
||||
$custom = (array) json_decode($this->invoice_labels);
|
||||
|
||||
$fields = [
|
||||
'invoice',
|
||||
'invoice_date',
|
||||
@ -241,7 +243,11 @@ class Account extends Eloquent
|
||||
];
|
||||
|
||||
foreach ($fields as $field) {
|
||||
$data[$field] = trans("texts.$field");
|
||||
if (isset($custom[$field]) && $custom[$field]) {
|
||||
$data[$field] = $custom[$field];
|
||||
} else {
|
||||
$data[$field] = trans("texts.$field");
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
@ -378,6 +378,7 @@ class InvoiceRepository
|
||||
if (isset($item['task_public_id']) && $item['task_public_id']) {
|
||||
$task = Task::scope($item['task_public_id'])->where('invoice_id', '=', null)->firstOrFail();
|
||||
$task->invoice_id = $invoice->id;
|
||||
$task->client_id = $invoice->client_id;
|
||||
$task->save();
|
||||
} else if ($item['product_key']) {
|
||||
$product = Product::findProductByKey(trim($item['product_key']));
|
||||
|
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddCustomInvoiceLabels extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('accounts', function($table)
|
||||
{
|
||||
$table->text('invoice_labels')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('accounts', function($table)
|
||||
{
|
||||
$table->dropColumn('invoice_labels');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
2
public/css/built.css
vendored
2
public/css/built.css
vendored
@ -3227,7 +3227,7 @@ div.checkbox > label {
|
||||
}
|
||||
|
||||
div.alert {
|
||||
z-index: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.alert-hide {
|
||||
|
2
public/css/style.css
vendored
2
public/css/style.css
vendored
@ -843,7 +843,7 @@ div.checkbox > label {
|
||||
}
|
||||
|
||||
div.alert {
|
||||
z-index: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.alert-hide {
|
||||
|
@ -667,7 +667,9 @@ return array(
|
||||
'create_task' => 'Create Task',
|
||||
'stopped_task' => 'Successfully stopped task',
|
||||
'invoice_task' => 'Invoice Task',
|
||||
|
||||
'invoice_labels' => 'Invoice Labels',
|
||||
'prefix' => 'Prefix',
|
||||
'counter' => 'Counter',
|
||||
|
||||
|
||||
);
|
||||
|
@ -42,6 +42,19 @@
|
||||
NINJA.secondaryColor = $('#secondary_color').val();
|
||||
NINJA.fontSize = parseInt($('#font_size').val());
|
||||
|
||||
var fields = ['item', 'description', 'unit_cost', 'quantity'];
|
||||
invoiceLabels.old = {};
|
||||
for (var i=0; i<fields.length; i++) {
|
||||
var field = fields[i];
|
||||
var val = $('#labels_' + field).val();
|
||||
if (invoiceLabels.old.hasOwnProperty(field)) {
|
||||
invoiceLabels.old[field] = invoiceLabels[field];
|
||||
}
|
||||
if (val) {
|
||||
invoiceLabels[field] = val;
|
||||
}
|
||||
}
|
||||
|
||||
doc = generatePDF(invoice, getDesignJavascript(), true);
|
||||
doc.getDataUrl(cb);
|
||||
}
|
||||
@ -72,6 +85,9 @@
|
||||
{!! Former::populate($account) !!}
|
||||
{!! Former::populateField('hide_quantity', intval($account->hide_quantity)) !!}
|
||||
{!! Former::populateField('hide_paid_to_date', intval($account->hide_paid_to_date)) !!}
|
||||
@foreach ($invoiceLabels as $field => $value)
|
||||
{!! Former::populateField("labels_{$field}", $value) !!}
|
||||
@endforeach
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
@ -96,6 +112,20 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">{!! trans('texts.invoice_labels') !!}</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
|
||||
{!! Former::text('labels_item')->label(trans('texts.item')) !!}
|
||||
{!! Former::text('labels_description')->label(trans('texts.description')) !!}
|
||||
{!! Former::text('labels_unit_cost')->label(trans('texts.unit_cost')) !!}
|
||||
{!! Former::text('labels_quantity')->label(trans('texts.quantity')) !!}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">{!! trans('texts.invoice_options') !!}</h3>
|
||||
|
@ -74,8 +74,8 @@
|
||||
<h3 class="panel-title">{!! trans('texts.invoice_number') !!}</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{!! Former::text('invoice_number_prefix')->label(trans('texts.invoice_number_prefix')) !!}
|
||||
{!! Former::text('invoice_number_counter')->label(trans('texts.invoice_number_counter')) !!}
|
||||
{!! Former::text('invoice_number_prefix')->label(trans('texts.prefix')) !!}
|
||||
{!! Former::text('invoice_number_counter')->label(trans('texts.counter')) !!}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -85,8 +85,8 @@
|
||||
<h3 class="panel-title">{!! trans('texts.quote_number') !!}</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{!! Former::text('quote_number_prefix')->label(trans('texts.quote_number_prefix')) !!}
|
||||
{!! Former::text('quote_number_counter')->label(trans('texts.quote_number_counter'))
|
||||
{!! Former::text('quote_number_prefix')->label(trans('texts.prefix')) !!}
|
||||
{!! Former::text('quote_number_counter')->label(trans('texts.counter'))
|
||||
->append(Former::checkbox('share_counter')->raw()->onclick('setQuoteNumberEnabled()') . ' ' . trans('texts.share_invoice_counter')) !!}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -150,10 +150,10 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="min-width:32px;" class="hide-border"></th>
|
||||
<th style="min-width:160px">{{ trans('texts.item') }}</th>
|
||||
<th style="width:100%">{{ trans('texts.description') }}</th>
|
||||
<th style="min-width:120px">{{ trans('texts.unit_cost') }}</th>
|
||||
<th style="{{ $account->hide_quantity ? 'display:none' : 'min-width:120px' }}">{{ trans('texts.quantity') }}</th>
|
||||
<th style="min-width:160px">{{ $invoiceLabels['item'] }}</th>
|
||||
<th style="width:100%">{{ $invoiceLabels['description'] }}</th>
|
||||
<th style="min-width:120px">{{ $invoiceLabels['unit_cost'] }}</th>
|
||||
<th style="{{ $account->hide_quantity ? 'display:none' : 'min-width:120px' }}">{{ $invoiceLabels['quantity'] }}</th>
|
||||
<th style="min-width:120px;display:none;" data-bind="visible: $root.invoice_item_taxes.show">{{ trans('texts.tax') }}</th>
|
||||
<th style="min-width:120px;">{{ trans('texts.line_total') }}</th>
|
||||
<th style="min-width:32px;" class="hide-border"></th>
|
||||
|
Loading…
x
Reference in New Issue
Block a user