mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 11:34:29 -04:00
Working on invoice fields
This commit is contained in:
parent
d740db676f
commit
08590a4b6f
@ -1026,6 +1026,7 @@ class AccountController extends BaseController
|
||||
$labels[$field] = Input::get("labels_{$field}");
|
||||
}
|
||||
$account->invoice_labels = json_encode($labels);
|
||||
$account->invoice_fields = Input::get('invoice_fields');
|
||||
|
||||
$account->save();
|
||||
|
||||
|
@ -825,7 +825,7 @@ if (!defined('CONTACT_EMAIL')) {
|
||||
|
||||
define('INVOICE_FIELDS_CLIENT', 'client_fields');
|
||||
define('INVOICE_FIELDS_INVOICE', 'invoice_fields');
|
||||
define('INVOICE_FIELDS_ACCOUNT', 'account_fields');
|
||||
define('INVOICE_FIELDS_COMPANY', 'company_fields');
|
||||
|
||||
$creditCards = [
|
||||
1 => ['card' => 'images/credit_cards/Test-Visa-Icon.png', 'text' => 'Visa'],
|
||||
|
@ -7,8 +7,70 @@ trait PresentsInvoice
|
||||
{
|
||||
public function getInvoiceFields()
|
||||
{
|
||||
$labels = $this->getInvoiceLabels();
|
||||
if ($this->invoice_fields) {
|
||||
$fields = json_decode($this->invoice_fields, true);
|
||||
} else {
|
||||
$fields = [
|
||||
INVOICE_FIELDS_INVOICE => [
|
||||
'invoice_number',
|
||||
'po_number',
|
||||
'invoice_date',
|
||||
'due_date',
|
||||
'balance_due',
|
||||
'partial_due',
|
||||
],
|
||||
INVOICE_FIELDS_CLIENT => [
|
||||
'client_name',
|
||||
'id_number',
|
||||
'vat_number',
|
||||
'address1',
|
||||
'address2',
|
||||
'city_state_postal',
|
||||
'country',
|
||||
'email',
|
||||
],
|
||||
'company_fields1' => [
|
||||
'company_name',
|
||||
'id_number',
|
||||
'vat_number',
|
||||
'website',
|
||||
'email',
|
||||
'phone',
|
||||
|
||||
],
|
||||
'company_fields2' => [
|
||||
'address1',
|
||||
'address2',
|
||||
'city_state_postal',
|
||||
'country',
|
||||
],
|
||||
];
|
||||
|
||||
if ($this->custom_invoice_text_label1) {
|
||||
$fields[INVOICE_FIELDS_INVOICE][] = 'custom_invoice_text_label1';
|
||||
}
|
||||
if ($this->custom_invoice_text_label2) {
|
||||
$fields[INVOICE_FIELDS_INVOICE][] = 'custom_invoice_text_label2';
|
||||
}
|
||||
if ($this->custom_client_label1) {
|
||||
$fields[INVOICE_FIELDS_CLIENT][] = 'custom_client_label1';
|
||||
}
|
||||
if ($this->custom_client_label2) {
|
||||
$fields[INVOICE_FIELDS_CLIENT][] = 'custom_client_label2';
|
||||
}
|
||||
if ($this->custom_label1) {
|
||||
$fields['company_fields2'][] = 'custom_label1';
|
||||
}
|
||||
if ($this->custom_label2) {
|
||||
$fields['company_fields2'][] = 'custom_label2';
|
||||
}
|
||||
}
|
||||
|
||||
return $this->applyLabels($fields);
|
||||
}
|
||||
|
||||
public function getAllInvoiceFields()
|
||||
{
|
||||
$fields = [
|
||||
INVOICE_FIELDS_INVOICE => [
|
||||
'invoice_number',
|
||||
@ -17,15 +79,45 @@ trait PresentsInvoice
|
||||
'due_date',
|
||||
'balance_due',
|
||||
'partial_due',
|
||||
'custom_invoice_text_label1',
|
||||
'custom_invoice_text_label2',
|
||||
],
|
||||
INVOICE_FIELDS_CLIENT => [
|
||||
|
||||
'client_name',
|
||||
'id_number',
|
||||
'vat_number',
|
||||
'address1',
|
||||
'address2',
|
||||
'city_state_postal',
|
||||
'country',
|
||||
'email',
|
||||
'contact_name',
|
||||
'custom_client_label1',
|
||||
'custom_client_label2',
|
||||
],
|
||||
INVOICE_FIELDS_ACCOUNT => [
|
||||
|
||||
INVOICE_FIELDS_COMPANY => [
|
||||
'company_name',
|
||||
'id_number',
|
||||
'vat_number',
|
||||
'website',
|
||||
'email',
|
||||
'phone',
|
||||
'address1',
|
||||
'address2',
|
||||
'city_state_postal',
|
||||
'country',
|
||||
'custom_label1',
|
||||
'custom_label2',
|
||||
]
|
||||
];
|
||||
|
||||
return $this->applyLabels($fields);
|
||||
}
|
||||
|
||||
private function applyLabels($fields)
|
||||
{
|
||||
$labels = $this->getInvoiceLabels();
|
||||
|
||||
foreach ($fields as $section => $sectionFields) {
|
||||
foreach ($sectionFields as $index => $field) {
|
||||
$fields[$section][$field] = $labels[$field];
|
||||
@ -33,11 +125,8 @@ trait PresentsInvoice
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->custom_invoice_text_label1) {
|
||||
//$fields[INVOICE_FIELDS_INVOICE][] = ''
|
||||
}
|
||||
|
||||
return $fields;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -75,7 +164,6 @@ trait PresentsInvoice
|
||||
'total',
|
||||
'invoice_issued_to',
|
||||
'quote_issued_to',
|
||||
//'date',
|
||||
'rate',
|
||||
'hours',
|
||||
'balance',
|
||||
@ -85,6 +173,18 @@ trait PresentsInvoice
|
||||
'details',
|
||||
'invoice_no',
|
||||
'valid_until',
|
||||
'client_name',
|
||||
'address1',
|
||||
'address2',
|
||||
'id_number',
|
||||
'vat_number',
|
||||
'city_state_postal',
|
||||
'country',
|
||||
'email',
|
||||
'contact_name',
|
||||
'company_name',
|
||||
'website',
|
||||
'phone',
|
||||
];
|
||||
|
||||
foreach ($fields as $field) {
|
||||
@ -99,6 +199,17 @@ trait PresentsInvoice
|
||||
$data["{$field}_orig"] = $data[$field];
|
||||
}
|
||||
|
||||
foreach ([
|
||||
'custom_label1',
|
||||
'custom_label2',
|
||||
'custom_client_label1',
|
||||
'custom_client_label2',
|
||||
'custom_invoice_text_label1',
|
||||
'custom_invoice_text_label2',
|
||||
] as $field) {
|
||||
$data[$field] = $this->$field ?: trans('texts.custom_field');
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
@ -203,7 +203,7 @@ class AccountRepository
|
||||
['new_user', '/users/create'],
|
||||
['custom_fields', '/settings/invoice_settings'],
|
||||
['invoice_number', '/settings/invoice_settings'],
|
||||
['buy_now_buttons', '/settings/client_portal#buyNow']
|
||||
['buy_now_buttons', '/settings/client_portal#buyNow'],
|
||||
]);
|
||||
|
||||
$settings = array_merge(Account::$basicSettings, Account::$advancedSettings);
|
||||
|
2
public/css/built.css
vendored
2
public/css/built.css
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
12
resources/assets/css/style.css
vendored
12
resources/assets/css/style.css
vendored
@ -143,7 +143,7 @@ line-height: 20px;
|
||||
.datepicker table {font-size: 12px; border-spacing:2px;}
|
||||
.datepicker td, .datepicker th { width:30px; }
|
||||
.datepicker table tr td.active.active, .datepicker table tr td.active:hover.active {
|
||||
background-color: #2980b9;
|
||||
background-color: #337ab7;
|
||||
background-image:none;
|
||||
}
|
||||
.datepicker table tr td.today { color: #333; background-color: #edd71e !important; background-image:none; text-shadow:none;}
|
||||
@ -158,7 +158,7 @@ padding: 20px;
|
||||
}
|
||||
.modal-header {
|
||||
border-bottom: none;
|
||||
background-color: #2980b9;
|
||||
background-color: #337ab7;
|
||||
padding: 20px;
|
||||
color: #fff;
|
||||
}
|
||||
@ -252,7 +252,7 @@ margin-left: 0px;
|
||||
.btn i.glyphicon { font-size: 16px; margin-left:7px; top: 2px; }
|
||||
|
||||
.btn-primary i{
|
||||
xborder-color: #2980b9;
|
||||
xborder-color: #337ab7;
|
||||
}
|
||||
|
||||
.form-actions .btn,
|
||||
@ -394,14 +394,14 @@ font-weight: bold;
|
||||
color: #fff;
|
||||
}
|
||||
.navbar {
|
||||
xbackground-color: #2980b9 !important;
|
||||
xbackground-color: #337ab7 !important;
|
||||
background-image: none;
|
||||
background-repeat: no-repeat;
|
||||
filter: none;
|
||||
}
|
||||
|
||||
.navbar-collapse {
|
||||
xbackground-color: #2980b9;
|
||||
xbackground-color: #337ab7;
|
||||
}
|
||||
|
||||
.navbar,
|
||||
@ -910,7 +910,7 @@ div.checkbox > label {
|
||||
|
||||
.panel-heading {
|
||||
/*background-color: #e37329 !important;*/
|
||||
background-color: #34495E !important;
|
||||
background-color: #286090 !important;
|
||||
}
|
||||
|
||||
div.alert {
|
||||
|
@ -2091,6 +2091,9 @@ $LANG = array(
|
||||
'toggle_history' => 'Toggle History',
|
||||
'unassigned' => 'Unassigned',
|
||||
'task' => 'Task',
|
||||
'contact_name' => 'Contact Name',
|
||||
'city_state_postal' => 'City/State/Postal',
|
||||
'custom_field' => 'Custom Field',
|
||||
|
||||
);
|
||||
|
||||
|
@ -11,11 +11,13 @@
|
||||
<script src="{{ asset('js/lightbox.min.js') }}" type="text/javascript"></script>
|
||||
<link href="{{ asset('css/lightbox.css') }}" rel="stylesheet" type="text/css"/>
|
||||
|
||||
|
||||
@stop
|
||||
|
||||
@section('content')
|
||||
@parent
|
||||
@include('accounts.nav', ['selected' => ACCOUNT_INVOICE_DESIGN, 'advanced' => true])
|
||||
@include('accounts.partials.invoice_fields')
|
||||
|
||||
<script>
|
||||
var invoiceDesigns = {!! $invoiceDesigns !!};
|
||||
@ -129,10 +131,15 @@
|
||||
{!! Former::populateField('all_pages_header', intval($account->all_pages_header)) !!}
|
||||
{!! Former::populateField('all_pages_footer', intval($account->all_pages_footer)) !!}
|
||||
|
||||
@foreach ($invoiceLabels as $field => $value)
|
||||
@foreach ($invoiceLabels as $field => $value)
|
||||
{!! Former::populateField("labels_{$field}", $value) !!}
|
||||
@endforeach
|
||||
|
||||
<div style="display:none">
|
||||
{!! Former::text('invoice_fields')->data_bind('value: ko.mapping.toJSON(model)') !!}
|
||||
</div>
|
||||
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">{!! trans('texts.invoice_design') !!}</h3>
|
||||
@ -227,7 +234,10 @@
|
||||
<div role="tabpanel" class="tab-pane" id="invoiceFields">
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
@include('accounts.partials.invoice_fields', ['section' => INVOICE_FIELDS_INVOICE])
|
||||
@include('accounts.partials.invoice_fields_selector', ['section' => 'invoice_fields', 'fields' => INVOICE_FIELDS_INVOICE])
|
||||
@include('accounts.partials.invoice_fields_selector', ['section' => 'client_fields', 'fields' => INVOICE_FIELDS_CLIENT])
|
||||
@include('accounts.partials.invoice_fields_selector', ['section' => 'company_fields1', 'fields' => INVOICE_FIELDS_COMPANY])
|
||||
@include('accounts.partials.invoice_fields_selector', ['section' => 'company_fields2', 'fields' => INVOICE_FIELDS_COMPANY])
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,7 +1,121 @@
|
||||
<div class="col-md-4">
|
||||
<script type="text/javascript">
|
||||
|
||||
{!! Former::select()
|
||||
->placeholder(trans("texts.{$section}"))
|
||||
->options($account->getInvoiceFields()[$section]) !!}
|
||||
function ViewModel(data) {
|
||||
var self = this;
|
||||
|
||||
</div>
|
||||
self.invoice_fields = ko.observableArray();
|
||||
self.client_fields = ko.observableArray();
|
||||
self.company_fields1 = ko.observableArray();
|
||||
self.company_fields2 = ko.observableArray();
|
||||
window.field_map = [];
|
||||
|
||||
self.addField = function(section, field, label) {
|
||||
self[section].push(field);
|
||||
window.field_map[field] = label;
|
||||
}
|
||||
|
||||
self.removeInvoiceFields = function(item) {
|
||||
self.invoice_fields.remove(item);
|
||||
}
|
||||
self.removeClientFields = function(item) {
|
||||
self.client_fields.remove(item);
|
||||
}
|
||||
self.removeCompanyFields1 = function(item) {
|
||||
self.company_fields1.remove(item);
|
||||
}
|
||||
self.removeCompanyFields2 = function(item) {
|
||||
self.company_fields2.remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
function addField(section) {
|
||||
var $select = $('#' + section + '_select');
|
||||
var field = $select.val();
|
||||
var label = $select.find('option:selected').text();
|
||||
window.model.addField(section, field, label);
|
||||
$select.val(null).blur();
|
||||
}
|
||||
|
||||
$(function() {
|
||||
window.model = new ViewModel();
|
||||
|
||||
var selectedFields = {!! json_encode($account->getInvoiceFields()) !!};
|
||||
for (var section in selectedFields) {
|
||||
if ( ! selectedFields.hasOwnProperty(section)) {
|
||||
continue;
|
||||
}
|
||||
var fields = selectedFields[section];
|
||||
for (var field in fields) {
|
||||
if ( ! fields.hasOwnProperty(field)) {
|
||||
continue;
|
||||
}
|
||||
var label = fields[field];
|
||||
model.addField(section, field, label);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(selectedFields);
|
||||
|
||||
|
||||
ko.applyBindings(model);
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<style type="text/css">
|
||||
.field-list {
|
||||
width: 100%;
|
||||
margin-top: 12px;
|
||||
}
|
||||
.field-list tr {
|
||||
width: 100%;
|
||||
cursor: pointer;
|
||||
border-bottom: solid 1px #CCC;
|
||||
}
|
||||
|
||||
.field-list td {
|
||||
width: 100%;
|
||||
background-color: white;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
.field-list td i {
|
||||
float: left;
|
||||
width: 18px;
|
||||
padding-top: 2px;
|
||||
}
|
||||
|
||||
.field-list td div {
|
||||
float: left;
|
||||
width: 146px;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.field-list tr:hover .fa {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.field-list tr:hover div {
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
|
||||
.field-list .fa {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.field-list .fa-close {
|
||||
color: red;
|
||||
}
|
||||
|
||||
.field-list .fa-bars {
|
||||
position: absolute;
|
||||
right: 20px;
|
||||
color: #AAA;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
@ -0,0 +1,22 @@
|
||||
<div class="col-md-3">
|
||||
|
||||
{!! Former::select("{$section}_select")
|
||||
->placeholder(trans("texts.{$fields}"))
|
||||
->options($account->getAllInvoiceFields()[$fields])
|
||||
->onchange("addField('{$section}')")
|
||||
->raw() !!}
|
||||
|
||||
<table class="field-list">
|
||||
<tbody data-bind="sortable: { data: {{ $section }}, as: 'field' }">
|
||||
<tr>
|
||||
<td>
|
||||
<i class="fa fa-close" data-bind="click: $root.{{ Utils::toCamelCase('remove' . ucwords($section)) }}"></i>
|
||||
<div data-bind="text: window.field_map[field]"></div>
|
||||
<i class="fa fa-bars"></i>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
</div>
|
@ -12,11 +12,11 @@ body {
|
||||
}
|
||||
|
||||
.navbar {
|
||||
background-color: #2980b9 !important;
|
||||
background-color: #337ab7 !important;
|
||||
}
|
||||
|
||||
.navbar-collapse {
|
||||
background-color: #2980b9 !important;
|
||||
background-color: #337ab7 !important;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user