Attach invoice documents to payment emails

This commit is contained in:
David Bomba 2022-12-15 16:55:47 +11:00
parent bbcf2b3459
commit a24a051004
2 changed files with 34 additions and 35 deletions

View File

@ -96,11 +96,13 @@ class PaymentEmailEngine extends BaseEmailEngine
$this->setAttachments([['file' => base64_encode($pdf), 'name' => $invoice->numberFormatter().'.pdf']]); $this->setAttachments([['file' => base64_encode($pdf), 'name' => $invoice->numberFormatter().'.pdf']]);
foreach ($invoice->documents as $document) {
$this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, ]]);
}
}); });
// foreach ($this->payment->documents as $document) {
// $this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, ]]);
// }
} }
return $this; return $this;

View File

@ -8,28 +8,27 @@
</h1> </h1>
</div> </div>
@if(isset($invoice))
<div class="flex items-center mt-4 text-sm">
<form action="{{ route('client.payments.process', ['hash' => $hash, 'sidebar' => 'hidden']) }}"
method="post"
id="payment-method-form">
@csrf
@if(isset($invoice)) @if($invoice instanceof \App\Models\Invoice)
<div class="flex items-center mt-4 text-sm"> <input type="hidden" name="invoices[]" value="{{ $invoice->hashed_id }}">
<form action="{{ route('client.payments.process', ['hash' => $hash, 'sidebar' => 'hidden']) }}" <input type="hidden" name="payable_invoices[0][amount]"
method="post" value="{{ $invoice->partial > 0 ? \App\Utils\Number::formatValue($invoice->partial, $invoice->client->currency()) : \App\Utils\Number::formatValue($invoice->balance, $invoice->client->currency()) }}">
id="payment-method-form"> <input type="hidden" name="payable_invoices[0][invoice_id]"
@csrf value="{{ $invoice->hashed_id }}">
@endif
@if($invoice instanceof \App\Models\Invoice) <input type="hidden" name="action" value="payment">
<input type="hidden" name="invoices[]" value="{{ $invoice->hashed_id }}"> <input type="hidden" name="company_gateway_id" value="{{ $company_gateway_id }}"/>
<input type="hidden" name="payable_invoices[0][amount]" <input type="hidden" name="payment_method_id" value="{{ $payment_method_id }}"/>
value="{{ $invoice->partial > 0 ? \App\Utils\Number::formatValue($invoice->partial, $invoice->client->currency()) : \App\Utils\Number::formatValue($invoice->balance, $invoice->client->currency()) }}"> </form>
<input type="hidden" name="payable_invoices[0][invoice_id]" </div>
value="{{ $invoice->hashed_id }}"> @endif
@endif
<input type="hidden" name="action" value="payment">
<input type="hidden" name="company_gateway_id" value="{{ $company_gateway_id }}"/>
<input type="hidden" name="payment_method_id" value="{{ $payment_method_id }}"/>
</form>
</div>
@endif
<form wire:submit.prevent="submit"> <form wire:submit.prevent="submit">
<!-- Recurring Plan Products--> <!-- Recurring Plan Products-->
@ -65,7 +64,6 @@
@endfor @endfor
</select> </select>
</div> </div>
@endif @endif
</div> </div>
@error("data.{$index}.recurring_qty") @error("data.{$index}.recurring_qty")
@ -83,7 +81,7 @@
@foreach($products as $product) @foreach($products as $product)
<li class="flex py-6"> <li class="flex py-6">
@if(filter_var($product->custom_value1, FILTER_VALIDATE_URL)) @if(filter_var($product->custom_value1, FILTER_VALIDATE_URL))
<div class="h-24 w-24 flex-shrink-0 overflow-hidden rounded-md border border-gray-200"> <div class="h-24 w-24 flex-shrink-0 overflow-hidden rounded-md border border-gray-200 mr-2">
<img src="{{$product->custom_value1}}" alt="" class="h-full w-full object-cover object-center"> <img src="{{$product->custom_value1}}" alt="" class="h-full w-full object-cover object-center">
</div> </div>
@endif @endif
@ -121,18 +119,17 @@
@if(!empty($subscription->optional_recurring_product_ids)) @if(!empty($subscription->optional_recurring_product_ids))
@foreach($optional_recurring_products as $index => $product) @foreach($optional_recurring_products as $index => $product)
<li class="flex py-6"> <li class="flex py-6">
@if(filter_var($product->custom_value1, FILTER_VALIDATE_URL)) @if(filter_var($product->custom_value1, FILTER_VALIDATE_URL))
<div class="h-24 w-24 flex-shrink-0 overflow-hidden rounded-md border border-gray-200"> <div class="h-24 w-24 flex-shrink-0 overflow-hidden rounded-md border border-gray-200 mr-2">
<img src="{{$product->custom_value1}}" alt="" class="h-full w-full object-cover object-center"> <img src="{{$product->custom_value1}}" alt="" class="h-full w-full object-cover object-center">
</div> </div>
@endif @endif
<div class="ml-0 flex flex-1 flex-col"> <div class="ml-0 flex flex-1 flex-col">
<div> <div>
<div class="flex justify-between text-base font-medium text-gray-900"> <div class="flex justify-between text-base font-medium text-gray-900">
<h3>{!! nl2br($product->notes) !!}</h3> <h3>{!! nl2br($product->notes) !!}</h3>
<p class="ml-0">{{ \App\Utils\Number::formatMoney($product->price, $subscription->company) }} </p> <p class="ml-0">{{ \App\Utils\Number::formatMoney($product->price, $subscription->company) }} / {{ App\Models\RecurringInvoice::frequencyForKey($subscription->frequency_id) }}</p>
</div> </div>
</div> </div>
<div class="flex justify-between text-sm mt-1"> <div class="flex justify-between text-sm mt-1">
@if(is_numeric($product->custom_value2)) @if(is_numeric($product->custom_value2))
@ -149,7 +146,7 @@
@endif @endif
> >
<option value="0" selected="selected">0</option> <option value="0" selected="selected">0</option>
@for ($i = 1; $i <= ($subscription->use_inventory_management ? min($product->in_stock_quantity,$product->custom_value2) : $product->custom_value2); $i++) @for ($i = 1; $i <= ($subscription->use_inventory_management ? min($product->in_stock_quantity, max(100,$product->custom_value2)) : max(100,$product->custom_value2)); $i++)
<option value="{{$i}}">{{$i}}</option> <option value="{{$i}}">{{$i}}</option>
@endfor @endfor
</select> </select>
@ -164,7 +161,7 @@
@foreach($optional_products as $index => $product) @foreach($optional_products as $index => $product)
<li class="flex py-6"> <li class="flex py-6">
@if(filter_var($product->custom_value1, FILTER_VALIDATE_URL)) @if(filter_var($product->custom_value1, FILTER_VALIDATE_URL))
<div class="h-24 w-24 flex-shrink-0 overflow-hidden rounded-md border border-gray-200"> <div class="h-24 w-24 flex-shrink-0 overflow-hidden rounded-md border border-gray-200 mr-2">
<img src="{{$product->custom_value1}}" alt="" class="h-full w-full object-cover object-center"> <img src="{{$product->custom_value1}}" alt="" class="h-full w-full object-cover object-center">
</div> </div>
@endif @endif
@ -187,7 +184,7 @@
@endif @endif
<select wire:model.debounce.300ms="data.{{ $index }}.optional_qty" class="rounded-md border-gray-300 shadow-sm sm:text-sm"> <select wire:model.debounce.300ms="data.{{ $index }}.optional_qty" class="rounded-md border-gray-300 shadow-sm sm:text-sm">
<option value="0" selected="selected">0</option> <option value="0" selected="selected">0</option>
@for ($i = 1; $i <= ($subscription->use_inventory_management ? min($product->in_stock_quantity,$product->custom_value2) : $product->custom_value2); $i++) @for ($i = 1; $i <= ($subscription->use_inventory_management ? min($product->in_stock_quantity, min(100,$product->custom_value2)) : min(100,$product->custom_value2)); $i++)
<option value="{{$i}}">{{$i}}</option> <option value="{{$i}}">{{$i}}</option>
@endfor @endfor
</select> </select>