Added preview for email templates

This commit is contained in:
Hillel Coren 2016-05-05 19:25:26 +03:00
parent bce4395f82
commit 6971060049
5 changed files with 18 additions and 4 deletions

View File

@ -1305,7 +1305,15 @@ class AccountController extends BaseController
public function previewEmail(\App\Services\TemplateService $templateService) public function previewEmail(\App\Services\TemplateService $templateService)
{ {
$template = Input::get('template'); $template = Input::get('template');
$invoice = Invoice::scope()->first(); $invoice = Invoice::scope()
->invoices()
->withTrashed()
->first();
if ( ! $invoice) {
return trans('texts.create_invoice_for_sample');
}
$account = Auth::user()->account; $account = Auth::user()->account;
// replace the variables with sample data // replace the variables with sample data

View File

@ -228,6 +228,12 @@ class Invoice extends EntityModel implements BalanceAffecting
return $this->hasMany('App\Models\Expense','invoice_id','id')->withTrashed(); return $this->hasMany('App\Models\Expense','invoice_id','id')->withTrashed();
} }
public function scopeInvoices($query)
{
return $query->where('is_quote', '=', false)
->where('is_recurring', '=', false);
}
public function markInvitationsSent($notify = false) public function markInvitationsSent($notify = false)
{ {
foreach ($this->invitations as $invitation) { foreach ($this->invitations as $invitation) {

View File

@ -81,7 +81,7 @@
<div class="modal fade" id="templatePreviewModal" tabindex="-1" role="dialog" aria-labelledby="templatePreviewModalLabel" aria-hidden="true"> <div class="modal fade" id="templatePreviewModal" tabindex="-1" role="dialog" aria-labelledby="templatePreviewModalLabel" aria-hidden="true">
<div class="modal-dialog" style="min-width:700px"> <div class="modal-dialog" style="width:800px">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>

View File

@ -12,7 +12,7 @@
</tr> </tr>
<tr> <tr>
<td style="border-collapse: collapse;"> <td style="border-collapse: collapse;">
<table cellpadding="10" cellspacing="0" border="0" bgcolor="#F4F5F5" width="580" align="center" <table cellpadding="10" cellspacing="0" border="0" bgcolor="#F4F5F5" width="600" align="center"
class="header" style="border-top-width: 6px; border-top-color: {{ $account->primary_color ?: '#2E2B2B' }}; border-top-style: solid;"> class="header" style="border-top-width: 6px; border-top-color: {{ $account->primary_color ?: '#2E2B2B' }}; border-top-style: solid;">
<tr> <tr>
<td class="logo" width="208" style="border-collapse: collapse; vertical-align: middle;" valign="middle"> <td class="logo" width="208" style="border-collapse: collapse; vertical-align: middle;" valign="middle">

View File

@ -12,7 +12,7 @@
</tr> </tr>
<tr> <tr>
<td style="border-collapse: collapse;"> <td style="border-collapse: collapse;">
<table cellpadding="10" cellspacing="0" border="0" bgcolor="{{ $account->primary_color ?: '#2E2B2B' }}" width="580" align="center" class="header" <table cellpadding="10" cellspacing="0" border="0" bgcolor="{{ $account->primary_color ?: '#2E2B2B' }}" width="600" align="center" class="header"
style="border-bottom-width: 6px; border-bottom-color: {{ $account->primary_color ?: '#2E2B2B' }}; border-bottom-style: solid;"> style="border-bottom-width: 6px; border-bottom-color: {{ $account->primary_color ?: '#2E2B2B' }}; border-bottom-style: solid;">
<tr> <tr>
<td class="logo" width="205" style="border-collapse: collapse; vertical-align: middle; line-height: 16px;" valign="middle"> <td class="logo" width="205" style="border-collapse: collapse; vertical-align: middle; line-height: 16px;" valign="middle">