Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/reminder invoice activities #3682

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion Modules/Invoice/Emails/SendPendingInvoiceMail.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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,
]);
}
Expand Down
17 changes: 17 additions & 0 deletions Modules/Invoice/Entities/InvoiceActivity.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Modules\Invoice\Entities;

use Illuminate\Database\Eloquent\Model;

class InvoiceActivity extends Model
{
protected $table = 'invoice_activities';

protected $fillable = ['invoice_id', 'type', 'subject', 'content', 'to', 'from', 'receiver_name', 'cc', 'bcc', 'created_at', 'updated_at'];

public function invoice()
{
return $this->belongsTo(Invoice::class);
}
}
1 change: 1 addition & 0 deletions Modules/Invoice/Http/Controllers/InvoiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand Down
33 changes: 25 additions & 8 deletions Modules/Invoice/Resources/views/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class="ml-2"
@endif
</a>
</td>

<td class="text-center">
{{ $invoice->sent_on->format(config('invoice.default-date-format')) }}</td>
<td
Expand All @@ -168,14 +168,31 @@ class="{{ $invoice->shouldHighlighted() ? 'font-weight-bold text-danger' : '' }}
</td>
<td class="text-center">
@if ($invoice->reminder_mail_count)
<div class="text-success">{{ __('Reminder Sent') }}</div>
<div class="text-dark font-weight-bold fz-12">{{ __('Reminder - ') . $invoice->reminder_mail_count }}</div>
<span class="c-pointer" data-toggle="tooltip" data-placement="top" title="Send Reminder">
<i class="fa fa-envelope send-reminder text-theme-red" aria-hidden="true" data-target="#invoiceReminder" data-invoice-data="{{ json_encode($invoiceData) }}" data-toggle="modal"></i>
</span>
<span class="c-pointer" data-toggle="tooltip" data-placement="top" title="Invoice Activity">
<a href="{{ route('invoice.edit', $invoice) }}"><i class="fa fa-history text-dark" aria-hidden="true"></i></a>
</span>
@elseif($invoice->shouldHighlighted())
<div class="btn btn-sm btn-primary send-reminder"
<div
class="btn py-0 fz-14 btn-sm btn-primary send-reminder"
data-invoice-data="{{ json_encode($invoiceData) }}" data-toggle="modal"
data-target="#invoiceReminder">{{ __('Reminder') }}</div>
data-target="#invoiceReminder"
>
{{ __('Reminder') }}
</div>
@else
<div> - </div>
@endif
@if ($invoice->reminder_mail_count && $invoice->shouldHighlighted())
@if (true)
<span data-toggle="tooltip" data-placement="top" title="Update on the Invoice">
<i class="fa fa-eye" aria-hidden="true"></i>
</span>
@endif
@endif
</td>
</tr>
@endforeach
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -414,7 +431,7 @@ class="{{ $invoice->shouldHighlighted() ? 'font-weight-bold text-danger' : '' }}
{{ config('constants.finance.scheduled-invoice.status.' . $invoice->currentStatus. '.title') }}
</div>
</td>
</tr>
</tr>
@endforeach
@else
<tr>
Expand All @@ -423,7 +440,7 @@ class="{{ $invoice->shouldHighlighted() ? 'font-weight-bold text-danger' : '' }}
@endif
</tbody>
</table>

@endif
</div>
@if (request()->invoice_status == 'ready' || $invoiceStatus == 'ready')
Expand All @@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateInvoiceActivities extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('invoice_activities', function (Blueprint $table) {
$table->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');
}
}
Loading