mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-14 07:02:34 +01:00
allow cancellation under specific conditions
This commit is contained in:
parent
b25f79f4e1
commit
08b317f7b8
@ -61,27 +61,28 @@ class RecurringInvoiceController extends Controller
|
|||||||
|
|
||||||
public function requestCancellation(Request $request, RecurringInvoice $recurring_invoice)
|
public function requestCancellation(Request $request, RecurringInvoice $recurring_invoice)
|
||||||
{
|
{
|
||||||
//todo double check the user is able to request a cancellation
|
if (is_null($recurring_invoice->subscription_id) || optional($recurring_invoice->subscription)->allow_cancellation) {
|
||||||
//can add locale specific by chaining ->locale();
|
$nmo = new NinjaMailerObject;
|
||||||
|
$nmo->mailable = (new NinjaMailer((new ClientContactRequestCancellationObject($recurring_invoice, auth()->user()))->build()));
|
||||||
|
$nmo->company = $recurring_invoice->company;
|
||||||
|
$nmo->settings = $recurring_invoice->company->settings;
|
||||||
|
|
||||||
$nmo = new NinjaMailerObject;
|
$notifiable_users = $this->filterUsersByPermissions($recurring_invoice->company->company_users, $recurring_invoice, ['recurring_cancellation']);
|
||||||
$nmo->mailable = (new NinjaMailer((new ClientContactRequestCancellationObject($recurring_invoice, auth()->user()))->build()));
|
|
||||||
$nmo->company = $recurring_invoice->company;
|
|
||||||
$nmo->settings = $recurring_invoice->company->settings;
|
|
||||||
|
|
||||||
$notifiable_users = $this->filterUsersByPermissions($recurring_invoice->company->company_users, $recurring_invoice, ['recurring_cancellation']);
|
$notifiable_users->each(function ($company_user) use($nmo){
|
||||||
|
|
||||||
$notifiable_users->each(function ($company_user) use($nmo){
|
$nmo->to_user = $company_user->user;
|
||||||
|
NinjaMailerJob::dispatch($nmo);
|
||||||
|
|
||||||
$nmo->to_user = $company_user->user;
|
});
|
||||||
NinjaMailerJob::dispatch($nmo);
|
|
||||||
|
|
||||||
});
|
//$recurring_invoice->user->notify(new ClientContactRequestCancellation($recurring_invoice, auth()->user()));
|
||||||
|
|
||||||
//$recurring_invoice->user->notify(new ClientContactRequestCancellation($recurring_invoice, auth()->user()));
|
return $this->render('recurring_invoices.cancellation.index', [
|
||||||
|
'invoice' => $recurring_invoice,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->render('recurring_invoices.cancellation.index', [
|
return back();
|
||||||
'invoice' => $recurring_invoice,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -468,4 +468,9 @@ class RecurringInvoice extends BaseModel
|
|||||||
{
|
{
|
||||||
return new RecurringService($this);
|
return new RecurringService($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function subscription(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Subscription::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,31 +55,35 @@
|
|||||||
{{ \App\Utils\Number::formatMoney($invoice->amount, $invoice->client) }}
|
{{ \App\Utils\Number::formatMoney($invoice->amount, $invoice->client) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="bg-white shadow sm:rounded-lg mb-4 mt-4">
|
@if(is_null($invoice->subscription_id) || optional($invoice->subscription)->allow_cancellation)
|
||||||
<div class="px-4 py-5 sm:p-6">
|
<div class="bg-white shadow sm:rounded-lg mb-4 mt-4">
|
||||||
<div class="sm:flex sm:items-start sm:justify-between">
|
<div class="px-4 py-5 sm:p-6">
|
||||||
<div>
|
<div class="sm:flex sm:items-start sm:justify-between">
|
||||||
<h3 class="text-lg leading-6 font-medium text-gray-900">
|
<div>
|
||||||
{{ ctrans('texts.cancellation') }}
|
<h3 class="text-lg leading-6 font-medium text-gray-900">
|
||||||
</h3>
|
{{ ctrans('texts.cancellation') }}
|
||||||
<div class="mt-2 max-w-xl text-sm leading-5 text-gray-500">
|
</h3>
|
||||||
<p translate>
|
<div class="mt-2 max-w-xl text-sm leading-5 text-gray-500">
|
||||||
{{ ctrans('texts.about_cancellation') }}
|
<p translate>
|
||||||
</p>
|
{{ ctrans('texts.about_cancellation') }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="mt-5 sm:mt-0 sm:ml-6 sm:flex-shrink-0 sm:flex sm:items-center">
|
||||||
<div class="mt-5 sm:mt-0 sm:ml-6 sm:flex-shrink-0 sm:flex sm:items-center">
|
<div class="inline-flex rounded-md shadow-sm" x-data="{ open: false }">
|
||||||
<div class="inline-flex rounded-md shadow-sm" x-data="{ open: false }">
|
<button class="button button-danger" translate @click="open = true">Request Cancellation
|
||||||
<button class="button button-danger" translate @click="open = true">Request Cancellation
|
</button>
|
||||||
</button>
|
@include('portal.ninja2020.recurring_invoices.includes.modals.cancellation')
|
||||||
@include('portal.ninja2020.recurring_invoices.includes.modals.cancellation')
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
@endif
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
Loading…
Reference in New Issue
Block a user