1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 23:22:52 +01:00
invoiceninja/resources/views/invoices/email.blade.php

263 lines
11 KiB
PHP
Raw Normal View History

2017-04-21 13:06:01 +02:00
<div class="modal fade" id="emailModal" tabindex="-1" role="dialog" aria-labelledby="emailModalLabel" aria-hidden="true" style="z-index:10000">
2017-02-05 22:29:11 +01:00
<div class="modal-dialog">
2017-02-05 22:51:00 +01:00
<div class="modal-content" style="background-color: #f8f8f8">
2017-02-05 08:53:49 +01:00
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="emailModalLabel">{{ trans($invoice->isQuote() ? 'texts.email_quote' : 'texts.email_invoice') }}</h4>
2017-02-05 08:53:49 +01:00
</div>
2017-02-05 22:51:00 +01:00
<div class="container" style="width: 100%; padding-bottom: 0px !important">
2017-03-26 10:45:17 +02:00
<div class="panel panel-default">
2017-02-05 08:53:49 +01:00
<div class="panel-body">
{!! Former::plaintext('recipients')
->value('') !!}
2017-02-06 10:41:16 +01:00
@if (Utils::isPro())
{!! Former::select('template_type')
->label('template')
->onchange('loadTemplate()')
->options([
$invoice->getEntityType() => trans('texts.initial_email'),
'reminder1' => trans('texts.first_reminder'),
'reminder2' => trans('texts.second_reminder'),
'reminder3' => trans('texts.third_reminder'),
]) !!}
@endif
2017-02-05 08:53:49 +01:00
<br/>
<div role="tabpanel">
<ul class="nav nav-tabs" role="tablist" style="border: none">
<li role="presentation" class="active">
<a href="#preview" aria-controls="preview" role="tab" data-toggle="tab">{{ trans('texts.preview') }}</a>
</li>
2017-02-06 10:41:16 +01:00
@if (Utils::isPro())
<li role="presentation">
<a href="#customize" aria-controls="customize" role="tab" data-toggle="tab">
{{ trans('texts.customize') }} {!! Auth::user()->isTrial() ? '<sup>' . trans('texts.pro') . '</sup>' : '' !!}
</a>
</li>
@endif
2017-02-05 08:53:49 +01:00
<li role="presentation">
<a href="#history" aria-controls="history" role="tab" data-toggle="tab">{{ trans('texts.history') }}</a>
</li>
</ul>
</div>
<div class="tab-content">
2017-02-05 22:29:11 +01:00
<div role="tabpanel" class="tab-pane active" id="preview">
2017-02-06 10:41:16 +01:00
<div style="padding:10px 14px 0px 14px">
2017-02-05 22:29:11 +01:00
<div id="emailSubjectDiv"></div>
<br/>
<div id="emailBodyDiv"></div>
</div>
2017-02-05 08:53:49 +01:00
</div>
<div role="tabpanel" class="tab-pane" id="customize">
2017-04-21 13:06:01 +02:00
{{ Former::setOption('TwitterBootstrap3.labelWidths.large', 0) }}
{{ Former::setOption('TwitterBootstrap3.labelWidths.small', 0) }}
2017-02-05 22:29:11 +01:00
{!! Former::text('emailSubject')
->placeholder('subject')
2017-04-21 13:06:01 +02:00
->label(false)
2017-02-05 22:29:11 +01:00
->onchange('onEmailSubjectChange()')
2017-02-06 10:41:16 +01:00
->oninput('onEmailSubjectInput()')
2017-04-21 13:06:01 +02:00
->appendIcon('question-sign')
->addGroupClass('email-subject') !!}
{{ Former::setOption('TwitterBootstrap3.labelWidths.large', 4) }}
{{ Former::setOption('TwitterBootstrap3.labelWidths.small', 4) }}
2017-02-05 22:29:11 +01:00
<br/>
<div id="templateEditor" class="form-control" style="min-height:160px"></div>
2017-02-05 22:51:00 +01:00
<div style="display:none">
2017-04-21 13:06:01 +02:00
{!! Former::textarea("template[body]")->raw() !!}
{!! Former::text('template[subject]')->raw() !!}
{!! Former::text('reminder')->raw() !!}
2017-02-05 22:29:11 +01:00
</div>
@include('partials/quill_toolbar', ['name' => 'template'])
2017-02-05 08:53:49 +01:00
</div>
<div role="tabpanel" class="tab-pane" id="history">
@if (count($activities = $invoice->emailHistory()))
<table class="table table-striped data-table">
<tr>
<th>{{ trans('texts.template')}}</th>
<th>{{ trans('texts.contact')}}</th>
<th>{{ trans('texts.date')}}</th>
</tr>
@foreach ($activities as $activity)
<tr>
<td>{{ $activity->present()->notes }}</td>
<td>
<span title="{{ trans('texts.sent_by', ['user' => $activity->present()->user]) }}">
{{ $activity->contact->getDisplayName() }}
</span>
</td>
<td>
<span title="{{ $activity->present()->createdAt }}">
2017-02-06 10:41:16 +01:00
{{ $activity->present()->createdAtDate }} - {{ $activity->created_at->diffForHumans() }}
2017-02-05 08:53:49 +01:00
</span>
</td>
2017-02-06 10:41:16 +01:00
<script type="text/javascript">
@if ($activity->notes == 'reminder3')
if (!window.defaultTemplate) window.defaultTemplate = 'reminder3';
@elseif ($activity->notes == 'reminder2')
if (!window.defaultTemplate) window.defaultTemplate = 'reminder3';
@elseif ($activity->notes == 'reminder1')
if (!window.defaultTemplate) window.defaultTemplate = 'reminder2';
@else
if (!window.defaultTemplate) window.defaultTemplate = 'reminder1';
@endif
</script>
2017-02-05 08:53:49 +01:00
</tr>
@endforeach
</table>
@else
2017-02-06 10:41:16 +01:00
<center style="font-size:16px;color:#888888;padding:30px;">
2017-02-05 08:53:49 +01:00
{{ trans("texts.{$invoice->getEntityType()}_not_emailed") }}
</center>
@endif
</div>
</div>
</div>
</div>
2017-02-20 11:27:26 +01:00
<div class="modal-footer" style="margin-top: 2px; padding-right:0px">
2017-02-06 10:41:16 +01:00
<div id="defaultDiv" style="display:none" class="pull-left">
{!! Former::checkbox('save_as_default')
->text('save_as_default')
->raw() !!}
</div>
2017-02-05 08:53:49 +01:00
<button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('texts.cancel') }}</button>
<button id="sendEmailButton" type="button" class="btn btn-info" onclick="onConfirmEmailClick()">{{ trans('texts.send_email') }}</button>
2017-02-05 08:53:49 +01:00
</div>
2017-02-05 22:51:00 +01:00
</div>
2017-02-05 08:53:49 +01:00
</div>
</div>
</div>
<script type="text/javascript">
2017-02-05 13:48:26 +01:00
var emailSubjects = [];
emailSubjects['{{ $invoice->getEntityType() }}'] = "{{ $account->getEmailSubject($invoice->getEntityType()) }}";
emailSubjects['reminder1'] = "{{ $account->getEmailSubject('reminder1') }}";
emailSubjects['reminder2'] = "{{ $account->getEmailSubject('reminder2') }}";
emailSubjects['reminder3'] = "{{ $account->getEmailSubject('reminder3') }}";
var emailTemplates = [];
emailTemplates['{{ $invoice->getEntityType() }}'] = "{{ $account->getEmailTemplate($invoice->getEntityType()) }}";
emailTemplates['reminder1'] = "{{ $account->getEmailTemplate('reminder1') }}";
emailTemplates['reminder2'] = "{{ $account->getEmailTemplate('reminder2') }}";
emailTemplates['reminder3'] = "{{ $account->getEmailTemplate('reminder3') }}";
function showEmailModal() {
2017-02-05 22:29:11 +01:00
loadTemplate();
2017-02-05 13:48:26 +01:00
$('#recipients').html(getSendToEmails());
$('#emailModal').modal('show');
}
$('#emailModal').on('shown.bs.modal', function () {
$('#sendEmailButton').focus();
});
2017-02-05 22:29:11 +01:00
function loadTemplate() {
2017-02-06 10:41:16 +01:00
@if (Utils::isPro())
var templateType = $('#template_type').val();
@else
var templateType = '{{ $invoice->getEntityType() }}';
@endif
var template = dencodeEntities(emailSubjects[templateType]);
2017-02-05 22:29:11 +01:00
$("#emailSubject").val(template);
2017-02-06 10:41:16 +01:00
var template = dencodeEntities(emailTemplates[templateType]);
2017-02-05 22:29:11 +01:00
emailEditor.setHTML(template);
2017-02-06 10:41:16 +01:00
var reminder = $('#template_type').val();
2017-02-05 22:29:11 +01:00
if (reminder == '{{ $invoice->getEntityType() }}') {
reminder = '';
}
$('#reminder').val(reminder);
2017-02-06 10:41:16 +01:00
$('#defaultDiv').hide();
2017-02-05 22:29:11 +01:00
refreshPreview();
2017-02-05 13:48:26 +01:00
}
2017-02-05 22:29:11 +01:00
function refreshPreview() {
var invoice = createInvoiceModel();
invoice = calculateAmounts(invoice);
var template = $("#emailSubject").val();
$('#emailSubjectDiv').html('<b>' + renderEmailTemplate(template, invoice) + '</b>');
var template = emailEditor.getHTML();
$('#emailBodyDiv').html(renderEmailTemplate(template, invoice));
}
function dencodeEntities(s) {
2017-02-05 13:48:26 +01:00
return $("<div/>").html(s).text();
}
2017-02-06 10:41:16 +01:00
function onEmailSubjectInput() {
$('#defaultDiv').show();
NINJA.formIsChanged = true;
}
2017-02-05 22:29:11 +01:00
function onEmailSubjectChange() {
2017-02-06 10:41:16 +01:00
$("#template\\[subject\\]").val($('#emailSubject').val());
2017-02-05 22:29:11 +01:00
refreshPreview();
}
var emailEditor;
$(function() {
emailEditor = new Quill('#templateEditor', {
modules: {
'toolbar': { container: '#templateToolbar' },
'link-tooltip': true
},
theme: 'snow'
});
emailEditor.setHTML('test');
emailEditor.on('text-change', function(delta, source) {
if (source == 'api') {
return;
}
var html = emailEditor.getHTML();
2017-02-06 10:41:16 +01:00
$("#template\\[body\\]").val(html);
$('#defaultDiv').show();
2017-02-05 22:29:11 +01:00
refreshPreview();
NINJA.formIsChanged = true;
});
2017-02-06 10:41:16 +01:00
@if (Utils::isPro() && $invoice->isStandard())
2017-02-06 10:41:16 +01:00
if (window.defaultTemplate) {
$('#template_type').val(window.defaultTemplate);
}
@endif
2017-04-21 13:06:01 +02:00
$('.email-subject .input-group-addon').click(function() {
$('#templateHelpModal').modal('show');
});
2017-02-05 22:29:11 +01:00
});
2017-02-05 08:53:49 +01:00
</script>
2017-02-05 22:29:11 +01:00
<style type="text/css">
2017-02-06 11:23:23 +01:00
#emailModal #preview.tab-pane,
#emailModal #history.tab-pane {
margin-top: 20px;
max-height: 320px;
2017-02-06 10:41:16 +01:00
overflow-y:auto;
}
2017-02-06 11:58:49 +01:00
#emailModal #customize.tab-pane {
margin-top: 20px;
}
2017-02-06 11:23:23 +01:00
#templateEditor {
max-height: 300px;
}
2017-02-05 22:29:11 +01:00
@media only screen and (min-width : 767px) {
.modal-dialog {
2017-02-06 10:41:16 +01:00
width: 690px;
2017-02-05 22:29:11 +01:00
}
}
</style>