diff --git a/Modules/Invoice/Emails/SendPendingInvoiceMail.php b/Modules/Invoice/Emails/SendPendingInvoiceMail.php index 30feeaf0e3..2674ce9fec 100644 --- a/Modules/Invoice/Emails/SendPendingInvoiceMail.php +++ b/Modules/Invoice/Emails/SendPendingInvoiceMail.php @@ -8,6 +8,7 @@ use Illuminate\Queue\SerializesModels; use Illuminate\Support\Facades\Storage; use Modules\Invoice\Entities\Invoice; +use Modules\Invoice\Entities\InvoiceActivity; class SendPendingInvoiceMail extends Mailable { @@ -77,10 +78,23 @@ public function build() $mail->bcc($emailAddress); } + InvoiceActivity::create([ + 'invoice_id' => $this->invoice->id, + 'type' => 'mail', + 'subject' => $subject, + 'content' => $body, + 'to' => $this->email['to'], + 'from' => $this->email['from'], + 'cc' => isset($this->email['cc']) && is_array($this->email['cc']) ? implode(',', $this->email['cc']) : null, + 'bcc' => isset($this->email['bcc']) && is_array($this->email['bcc']) ? implode(',', $this->email['bcc']) : null, + 'receiver_name' => $this->email['to_name'], + ]); + return $mail->subject($subject) ->attach($invoiceFile, [ 'mime' => 'application/pdf', - ])->view('mail.plain')->with([ + ]) + ->view('mail.plain')->with([ 'body' => $body, ]); } diff --git a/Modules/Invoice/Entities/InvoiceActivity.php b/Modules/Invoice/Entities/InvoiceActivity.php new file mode 100644 index 0000000000..8f7aa6c089 --- /dev/null +++ b/Modules/Invoice/Entities/InvoiceActivity.php @@ -0,0 +1,17 @@ +belongsTo(Invoice::class); + } +} diff --git a/Modules/Invoice/Http/Controllers/InvoiceController.php b/Modules/Invoice/Http/Controllers/InvoiceController.php index 1831b38588..8077e871bd 100644 --- a/Modules/Invoice/Http/Controllers/InvoiceController.php +++ b/Modules/Invoice/Http/Controllers/InvoiceController.php @@ -175,6 +175,7 @@ public function taxReportExport(Request $request) public function sendReminderEmail(Request $request) { $invoice = Invoice::find($request->invoice_id); + $this->service->sendInvoiceReminder($invoice, $request->all()); return redirect()->back()->with('status', 'Invoice saved successfully.'); diff --git a/Modules/Invoice/Resources/views/index.blade.php b/Modules/Invoice/Resources/views/index.blade.php index 083b9ea82c..1c2dfe9be5 100644 --- a/Modules/Invoice/Resources/views/index.blade.php +++ b/Modules/Invoice/Resources/views/index.blade.php @@ -151,7 +151,7 @@ class="ml-2" @endif - + {{ $invoice->sent_on->format(config('invoice.default-date-format')) }} @if ($invoice->reminder_mail_count) -
{{ __('Reminder Sent') }}
+
{{ __('Reminder - ') . $invoice->reminder_mail_count }}
+ + + + + + @elseif($invoice->shouldHighlighted()) -
{{ __('Reminder') }}
+ data-target="#invoiceReminder" + > + {{ __('Reminder') }} + @else
-
@endif + @if ($invoice->reminder_mail_count && $invoice->shouldHighlighted()) + @if (true) + + + + @endif + @endif @endforeach @@ -284,7 +301,7 @@ class="{{ $invoice->shouldHighlighted() ? 'font-weight-bold text-danger' : '' }} @endif @php $index++; - + $currencySymbol = config('constants.currency.' . $project->client->currency . '.symbol'); if ($project->hasCustomInvoiceTemplate()) { $amount = $currencySymbol . $project->getTotalLedgerAmount($quarter); @@ -414,7 +431,7 @@ class="{{ $invoice->shouldHighlighted() ? 'font-weight-bold text-danger' : '' }} {{ config('constants.finance.scheduled-invoice.status.' . $invoice->currentStatus. '.title') }} - + @endforeach @else @@ -423,7 +440,7 @@ class="{{ $invoice->shouldHighlighted() ? 'font-weight-bold text-danger' : '' }} @endif - + @endif @if (request()->invoice_status == 'ready' || $invoiceStatus == 'ready') @@ -432,4 +449,4 @@ class="{{ $invoice->shouldHighlighted() ? 'font-weight-bold text-danger' : '' }} @if (request()->invoice_status !== 'scheduled' || $invoiceStatus !== 'scheduled') @include('invoice::modals.invoice-reminder') @endif -@endsection +@endsection \ No newline at end of file diff --git a/database/migrations/2024_07_06_183725_create_invoice_activities.php b/database/migrations/2024_07_06_183725_create_invoice_activities.php new file mode 100644 index 0000000000..bd109e28bf --- /dev/null +++ b/database/migrations/2024_07_06_183725_create_invoice_activities.php @@ -0,0 +1,40 @@ +id(); + $table->unsignedBigInteger('invoice_id'); + $table->text('type'); + $table->text('subject'); + $table->text('content'); + $table->text('to'); + $table->text('from'); + $table->text('receiver_name'); + $table->text('cc'); + $table->text('bcc'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('invoice_activities'); + } +}