mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 02:34:31 -04:00
Working on custom fields
This commit is contained in:
parent
083c13b599
commit
d525c6ac53
@ -469,6 +469,14 @@ if (! defined('APP_NAME')) {
|
||||
define('TEMPLATE_REMINDER3', 'reminder3');
|
||||
define('TEMPLATE_REMINDER4', 'reminder4');
|
||||
|
||||
define('CUSTOM_MESSAGE_DASHBOARD', 'dashboard');
|
||||
define('CUSTOM_MESSAGE_UNPAID_INVOICE', 'unpaid_invoice');
|
||||
define('CUSTOM_MESSAGE_PAID_INVOICE', 'paid_invoice');
|
||||
define('CUSTOM_MESSAGE_UNAPPROVED_QUOTE', 'unapproved_quote');
|
||||
define('CUSTOM_MESSAGE_APPROVED_QUOTE', 'approved_quote');
|
||||
define('CUSTOM_MESSAGE_UNAPPROVED_PROPOSAL', 'unapproved_proposal');
|
||||
define('CUSTOM_MESSAGE_APPROVED_PROPOSAL', 'approved_proposal');
|
||||
|
||||
define('RESET_FREQUENCY_DAILY', 1);
|
||||
define('RESET_FREQUENCY_WEEKLY', 2);
|
||||
define('RESET_FREQUENCY_MONTHLY', 3);
|
||||
|
@ -173,6 +173,7 @@ class Account extends Eloquent
|
||||
'custom_fields',
|
||||
'custom_value1',
|
||||
'custom_value2',
|
||||
'custom_messages',
|
||||
];
|
||||
|
||||
/**
|
||||
@ -273,6 +274,16 @@ class Account extends Eloquent
|
||||
'vat_number',
|
||||
];
|
||||
|
||||
public static $customMessageTypes = [
|
||||
CUSTOM_MESSAGE_DASHBOARD,
|
||||
CUSTOM_MESSAGE_UNPAID_INVOICE,
|
||||
CUSTOM_MESSAGE_PAID_INVOICE,
|
||||
CUSTOM_MESSAGE_UNAPPROVED_QUOTE,
|
||||
//CUSTOM_MESSAGE_APPROVED_QUOTE,
|
||||
CUSTOM_MESSAGE_UNAPPROVED_PROPOSAL,
|
||||
//CUSTOM_MESSAGE_APPROVED_PROPOSAL,
|
||||
];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
@ -537,6 +548,38 @@ class Account extends Eloquent
|
||||
return ! empty($labels->$field) ? $labels->$field : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*/
|
||||
public function setCustomMessagesAttribute($data)
|
||||
{
|
||||
$fields = [];
|
||||
|
||||
if (! is_array($data)) {
|
||||
$data = json_decode($data);
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
if ($value) {
|
||||
$fields[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$this->attributes['custom_messages'] = count($fields) ? json_encode($fields) : null;
|
||||
}
|
||||
|
||||
public function getCustomMessagesAttribute($value)
|
||||
{
|
||||
return json_decode($value ?: '{}');
|
||||
}
|
||||
|
||||
public function customMessage($type)
|
||||
{
|
||||
$messages = $this->custom_messages;
|
||||
|
||||
return ! empty($messages->$type) ? $messages->$type : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $gatewayId
|
||||
*
|
||||
|
@ -529,6 +529,18 @@ class Invoice extends EntityModel implements BalanceAffecting
|
||||
return $this->isType(INVOICE_TYPE_QUOTE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCustomMessageType()
|
||||
{
|
||||
if ($this->isQuote()) {
|
||||
return $this->quote_invoice_id ? CUSTOM_MESSAGE_APPROVED_QUOTE : CUSTOM_MESSAGE_UNAPPROVED_QUOTE;
|
||||
} else {
|
||||
return $this->balance > 0 ? CUSTOM_MESSAGE_UNPAID_INVOICE : CUSTOM_MESSAGE_PAID_INVOICE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
|
@ -115,6 +115,19 @@ class Proposal extends EntityModel
|
||||
|
||||
return trans('texts.proposal') . '_' . $this->invoice->invoice_number . '.' . $extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCustomMessageType()
|
||||
{
|
||||
if ($this->invoice->quote_invoice_id) {
|
||||
return CUSTOM_MESSAGE_APPROVED_PROPOSAL;
|
||||
} else {
|
||||
return CUSTOM_MESSAGE_UNAPPROVED_PROPOSAL;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Proposal::creating(function ($project) {
|
||||
|
@ -272,6 +272,7 @@ class AccountTransformer extends EntityTransformer
|
||||
'custom_invoice_taxes1' => $account->custom_invoice_taxes1,
|
||||
'custom_invoice_taxes2' => $account->custom_invoice_taxes1,
|
||||
'custom_fields' => json_encode($account->custom_fields),
|
||||
'custom_messages' => json_encode($account->custom_messages),
|
||||
'custom_invoice_label1' => $account->customLabel('invoice1'),
|
||||
'custom_invoice_label2' => $account->customLabel('invoice2'),
|
||||
'custom_client_label1' => $account->customLabel('client1'),
|
||||
|
@ -78,6 +78,10 @@ class AddMoreCustomFields extends Migration
|
||||
$table->dropColumn('custom_invoice_item_label2');
|
||||
});
|
||||
|
||||
Schema::table('accounts', function ($table) {
|
||||
$table->mediumText('custom_messages')->nullable();
|
||||
});
|
||||
|
||||
Schema::table('tasks', function ($table) {
|
||||
$table->text('custom_value1')->nullable();
|
||||
$table->text('custom_value2')->nullable();
|
||||
|
@ -2818,6 +2818,12 @@ $LANG = array(
|
||||
'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.',
|
||||
'messages' => 'Messages',
|
||||
'unpaid_invoice' => 'Unpaid Invoice',
|
||||
'paid_invoice' => 'Paid Invoice',
|
||||
'unapproved_quote' => 'Unapproved Quote',
|
||||
'unapproved_proposal' => 'Unapproved Proposal',
|
||||
|
||||
);
|
||||
|
||||
return $LANG;
|
||||
|
@ -58,6 +58,9 @@
|
||||
<li role="presentation">
|
||||
<a href="#navigation" aria-controls="navigation" role="tab" data-toggle="tab">{{ trans('texts.navigation') }}</a>
|
||||
</li>
|
||||
<li role="presentation">
|
||||
<a href="#messages" aria-controls="navigation" role="tab" data-toggle="tab">{{ trans('texts.messages') }}</a>
|
||||
</li>
|
||||
<li role="presentation">
|
||||
<a href="#custom_css" aria-controls="custom_css" role="tab" data-toggle="tab">{{ trans('texts.custom_css') }}</a>
|
||||
</li>
|
||||
@ -124,6 +127,16 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div role="tabpanel" class="tab-pane" id="messages">
|
||||
<div class="panel-body">
|
||||
|
||||
@foreach (App\Models\Account::$customMessageTypes as $type)
|
||||
{!! Former::textarea('custom_messages[' . $type . ']')
|
||||
->label($type) !!}
|
||||
@endforeach
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div role="tabpanel" class="tab-pane" id="custom_css">
|
||||
<div class="panel-body">
|
||||
|
||||
|
@ -276,6 +276,9 @@
|
||||
|
||||
<div class="container main-container">
|
||||
|
||||
@if ($message = $account->customMessage(CUSTOM_MESSAGE_DASHBOARD))
|
||||
<div class="alert alert-warning custom-message">{!! Utils::isNinja() ? HTMLUtils::sanitizeHTML($message) : $message !!}</div>
|
||||
@endif
|
||||
|
||||
<div class="row" id="main-row">
|
||||
<div class="col-md-3" id="contact-details">
|
||||
|
@ -24,6 +24,10 @@
|
||||
</script>
|
||||
|
||||
<div class="container" style="padding: 20px;">
|
||||
@if ($message = $account->customMessage($proposal->getCustomMessageType()))
|
||||
<div class="alert alert-warning custom-message">{!! Utils::isNinja() ? HTMLUtils::sanitizeHTML($message) : $message !!}</div>
|
||||
@endif
|
||||
|
||||
<div class="pull-right">
|
||||
{!! Button::normal(trans('texts.download'))->asLinkTo(url("/proposal/{$proposalInvitation->invitation_key}/download"))->large() !!}
|
||||
@if (! $proposal->invoice->isApproved())
|
||||
|
@ -152,6 +152,10 @@
|
||||
|
||||
<div class="container">
|
||||
|
||||
@if ($message = $account->customMessage($invoice->getCustomMessageType()))
|
||||
<div class="alert alert-warning custom-message">{!! Utils::isNinja() ? HTMLUtils::sanitizeHTML($message) : $message !!}</div>
|
||||
@endif
|
||||
|
||||
@if (!empty($partialView))
|
||||
@include($partialView)
|
||||
@else
|
||||
|
Loading…
x
Reference in New Issue
Block a user