1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 07:02:34 +01:00
invoiceninja/resources/views/accounts/templates_and_reminders.blade.php

258 lines
10 KiB
PHP
Raw Normal View History

2015-10-14 16:15:39 +02:00
@extends('header')
2015-09-17 21:01:06 +02:00
@section('head')
@parent
2015-12-10 11:57:51 +01:00
@include('money_script')
2015-11-04 22:52:12 +01:00
<link href="{{ asset('css/quill.snow.css') }}" rel="stylesheet" type="text/css"/>
<script src="{{ asset('js/quill.min.js') }}" type="text/javascript"></script>
2015-09-17 21:01:06 +02:00
<style type="text/css">
textarea {
min-height: 150px !important;
}
</style>
2015-11-05 09:44:48 +01:00
<script type="text/javascript">
var editors = [];
</script>
2015-09-17 21:01:06 +02:00
@stop
@section('content')
@parent
2015-10-14 16:15:39 +02:00
@include('accounts.nav', ['selected' => ACCOUNT_TEMPLATES_AND_REMINDERS, 'advanced' => true])
2015-09-17 21:01:06 +02:00
2015-11-04 22:52:12 +01:00
2015-10-14 16:15:39 +02:00
{!! Former::vertical_open()->addClass('warn-on-exit') !!}
2015-09-17 21:01:06 +02:00
{!! Former::populate($account) !!}
@foreach ([ENTITY_INVOICE, ENTITY_QUOTE, ENTITY_PAYMENT, REMINDER1, REMINDER2, REMINDER3] as $type)
@foreach (['subject', 'template'] as $field)
{!! Former::populateField("email_{$field}_{$type}", $templates[$type][$field]) !!}
@endforeach
@endforeach
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">{!! trans('texts.email_templates') !!}</h3>
</div>
<div class="panel-body">
<div class="row">
<div role="tabpanel">
<ul class="nav nav-tabs" role="tablist" style="border: none">
<li role="presentation" class="active"><a href="#invoice" aria-controls="notes" role="tab" data-toggle="tab">{{ trans('texts.invoice_email') }}</a></li>
<li role="presentation"><a href="#quote" aria-controls="terms" role="tab" data-toggle="tab">{{ trans('texts.quote_email') }}</a></li>
<li role="presentation"><a href="#payment" aria-controls="footer" role="tab" data-toggle="tab">{{ trans('texts.payment_email') }}</a></li>
</ul>
<div class="tab-content">
@include('accounts.template', ['field' => 'invoice', 'active' => true])
@include('accounts.template', ['field' => 'quote'])
@include('accounts.template', ['field' => 'payment'])
</div>
</div>
</div>
</div>
</div>
<p>&nbsp;</p>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">{!! trans('texts.reminder_emails') !!}</h3>
</div>
<div class="panel-body">
<div class="row">
<div role="tabpanel">
<ul class="nav nav-tabs" role="tablist" style="border: none">
<li role="presentation" class="active"><a href="#reminder1" aria-controls="notes" role="tab" data-toggle="tab">{{ trans('texts.first_reminder') }}</a></li>
<li role="presentation"><a href="#reminder2" aria-controls="terms" role="tab" data-toggle="tab">{{ trans('texts.second_reminder') }}</a></li>
<li role="presentation"><a href="#reminder3" aria-controls="footer" role="tab" data-toggle="tab">{{ trans('texts.third_reminder') }}</a></li>
</ul>
<div class="tab-content">
@include('accounts.template', ['field' => 'reminder1', 'isReminder' => true, 'active' => true])
@include('accounts.template', ['field' => 'reminder2', 'isReminder' => true])
@include('accounts.template', ['field' => 'reminder3', 'isReminder' => true])
</div>
</div>
</div>
</div>
</div>
2015-12-02 14:26:06 +01:00
<div class="modal fade" id="templateHelpModal" tabindex="-1" role="dialog" aria-labelledby="templateHelpModalLabel" aria-hidden="true">
<div class="modal-dialog" style="min-width:150px">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="templateHelpModalLabel">{{ trans('texts.template_help_title') }}</h4>
</div>
<div class="modal-body">
<p>{{ trans('texts.template_help_1') }}</p>
<ul>
@foreach (\App\Ninja\Mailers\ContactMailer::$variableFields as $field)
<li>${{ $field }}</li>
@endforeach
2015-12-23 15:21:48 +01:00
@if ($account->custom_client_label1)
<li>$customClient1</li>
@endif
@if ($account->custom_client_label2)
<li>$customClient2</li>
@endif
@if ($account->custom_invoice_text_label1)
<li>$customInvoice1</li>
@endif
@if ($account->custom_invoice_text_label2)
<li>$customInvoice1</li>
@endif
2015-12-02 14:26:06 +01:00
@if (count($account->account_gateways) > 1)
@foreach (\App\Models\Gateway::$paymentTypes as $type)
@if ($account->getGatewayByType($type))
<li>${{ \App\Models\Gateway::getPaymentTypeName($type) }}Link</li>
<li>${{ \App\Models\Gateway::getPaymentTypeName($type) }}Button</li>
@endif
@endforeach
@endif
</ul>
</div>
<div class="modal-footer" style="margin-top: 0px">
<button type="button" class="btn btn-primary" data-dismiss="modal">{{ trans('texts.close') }}</button>
</div>
</div>
</div>
</div>
2015-09-17 21:01:06 +02:00
@if (Auth::user()->isPro())
<center>
{!! Button::success(trans('texts.save'))->submit()->large()->appendIcon(Icon::create('floppy-disk')) !!}
</center>
@else
<script>
$(function() {
$('form.warn-on-exit input').prop('disabled', true);
});
</script>
@endif
{!! Former::close() !!}
<script type="text/javascript">
var entityTypes = ['invoice', 'quote', 'payment', 'reminder1', 'reminder2', 'reminder3'];
var stringTypes = ['subject', 'template'];
2015-09-20 23:05:02 +02:00
var templates = {!! json_encode($defaultTemplates) !!};
2015-09-17 21:01:06 +02:00
function refreshPreview() {
for (var i=0; i<entityTypes.length; i++) {
var entityType = entityTypes[i];
for (var j=0; j<stringTypes.length; j++) {
var stringType = stringTypes[j];
var idName = '#email_' + stringType + '_' + entityType;
var value = $(idName).val();
var previewName = '#' + entityType + '_' + stringType + '_preview';
$(previewName).html(processVariables(value));
}
}
}
$(function() {
for (var i=0; i<entityTypes.length; i++) {
var entityType = entityTypes[i];
for (var j=0; j<stringTypes.length; j++) {
var stringType = stringTypes[j];
var idName = '#email_' + stringType + '_' + entityType;
$(idName).keyup(refreshPreview);
}
}
2015-09-20 23:05:02 +02:00
for (var i=1; i<=3; i++) {
$('#enable_reminder' + i).bind('click', {id: i}, function(event) {
enableReminder(event.data.id)
});
enableReminder(i);
}
2015-09-17 21:01:06 +02:00
refreshPreview();
});
2015-09-20 23:05:02 +02:00
function enableReminder(id) {
var checked = $('#enable_reminder' + id).is(':checked');
$('.enable-reminder' + id).attr('disabled', !checked)
}
function setDirectionShown(field) {
var val = $('#field_' + field).val();
if (val == {{ REMINDER_FIELD_INVOICE_DATE }}) {
$('#days_after_' + field).show();
$('#direction_' + field).hide();
} else {
$('#days_after_' + field).hide();
$('#direction_' + field).show();
}
}
2015-09-17 21:01:06 +02:00
function processVariables(str) {
if (!str) {
return '';
}
2015-12-02 14:26:06 +01:00
var keys = {!! json_encode(\App\Ninja\Mailers\ContactMailer::$variableFields) !!};
var vals = [
2015-09-17 21:01:06 +02:00
{!! json_encode($emailFooter) !!},
2015-12-21 20:57:55 +01:00
"{{ $account->getDisplayName() }}",
"{{ $account->formatDate($account->getDateTime()) }}",
"{{ $account->formatDate($account->getDateTime()) }}",
2015-09-17 21:01:06 +02:00
"Client Name",
formatMoney(100),
"Contact Name",
"First Name",
2015-09-17 21:01:06 +02:00
"0001",
2015-12-02 14:26:06 +01:00
"0001",
"{{ URL::to('/view/...') }}",
'{!! HTML::flatButton('view_invoice', '#0b4d78') !!}',
"{{ URL::to('/payment/...') }}",
'{!! HTML::flatButton('pay_now', '#36c157') !!}',
2015-09-17 21:01:06 +02:00
];
2015-12-23 15:21:48 +01:00
// Add blanks for custom values
keys.push('customClient1', 'customClient2', 'customInvoice1', 'customInvoice2');
vals.push('custom value', 'custom value', 'custom value', 'custom value');
2015-09-17 21:01:06 +02:00
// Add any available payment method links
2015-12-02 14:26:06 +01:00
@foreach (\App\Models\Gateway::$paymentTypes as $type)
{!! "keys.push('" . \App\Models\Gateway::getPaymentTypeName($type).'Link' . "');" !!}
{!! "vals.push('" . URL::to('/payment/...') . "');" !!}
{!! "keys.push('" . \App\Models\Gateway::getPaymentTypeName($type).'Button' . "');" !!}
{!! "vals.push('" . HTML::flatButton('pay_now', '#36c157') . "');" !!}
2015-09-17 21:01:06 +02:00
@endforeach
for (var i=0; i<keys.length; i++) {
var regExp = new RegExp('\\$'+keys[i], 'g');
str = str.replace(regExp, vals[i]);
}
return str;
}
function resetText(section, field) {
if (confirm('{!! trans("texts.are_you_sure") !!}')) {
var fieldName = 'email_' + section + '_' + field;
var value = templates[field][section];
$('#' + fieldName).val(value);
2016-01-10 13:37:23 +01:00
if (section == 'template') {
editors[field].setHTML(value);
}
2015-09-17 21:01:06 +02:00
refreshPreview();
}
return false;
}
</script>
@stop