mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Improve notifications for reminders
This commit is contained in:
parent
b93ee4468e
commit
f39766d374
@ -22,7 +22,7 @@ class InvoiceReminderWasEmailed
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public function __construct(public InvoiceInvitation $invitation, public Company $company, public array $event_vars, public int $reminder)
|
||||
public function __construct(public InvoiceInvitation $invitation, public Company $company, public array $event_vars, public string $template)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -136,7 +136,10 @@ class EmailController extends BaseController
|
||||
$mo->email_template_body = $request->input('template');
|
||||
$mo->email_template_subject = str_replace("template", "subject", $request->input('template'));
|
||||
|
||||
if ($request->has('cc_email') && $request->cc_email) {
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
if ($request->has('cc_email') && $request->cc_email && (Ninja::isSelfHost() || $user->account->isPaidHostedClient())) {
|
||||
$mo->cc[] = new Address($request->cc_email);
|
||||
}
|
||||
|
||||
@ -144,8 +147,6 @@ class EmailController extends BaseController
|
||||
if (! $invitation->contact->trashed() && $invitation->contact->email) {
|
||||
$entity_obj->service()->markSent()->save();
|
||||
|
||||
// EmailEntity::dispatch($invitation->fresh(), $invitation->company, $template, $data);
|
||||
|
||||
$mo->invitation_id = $invitation->id;
|
||||
|
||||
Email::dispatch($mo, $invitation->company);
|
||||
|
@ -92,7 +92,11 @@ class SendEmailRequest extends Request
|
||||
|
||||
/*Make sure we have all the require ingredients to send a template*/
|
||||
if (array_key_exists('entity', $input) && array_key_exists('entity_id', $input) && is_string($input['entity']) && $input['entity_id']) {
|
||||
$company = auth()->user()->company();
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
$company = $user->company();
|
||||
|
||||
$entity = $input['entity'];
|
||||
|
||||
@ -100,7 +104,7 @@ class SendEmailRequest extends Request
|
||||
$entity_obj = $entity::whereId($input['entity_id'])->withTrashed()->company()->first();
|
||||
|
||||
/* Check object, check user and company id is same as users, and check user can edit the object */
|
||||
if ($entity_obj && ($company->id == $entity_obj->company_id) && auth()->user()->can('edit', $entity_obj)) {
|
||||
if ($entity_obj && ($company->id == $entity_obj->company_id) && $user->can('edit', $entity_obj)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,8 @@ class InvoiceEmailedNotification implements ShouldQueue
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
nlog($event->template);
|
||||
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
$first_notification_sent = true;
|
||||
@ -61,6 +63,20 @@ class InvoiceEmailedNotification implements ShouldQueue
|
||||
if (($key = array_search('mail', $methods)) !== false) {
|
||||
unset($methods[$key]);
|
||||
|
||||
// $template = $event->template ?? '';
|
||||
|
||||
// if(isset($event->reminder)){
|
||||
|
||||
// $template = match($event->reminder){
|
||||
// 63 => 'reminder1',
|
||||
// 64 => 'reminder2',
|
||||
// 65 => 'reminder3',
|
||||
// 66 => 'endless_reminder',
|
||||
// default => ''
|
||||
// };
|
||||
|
||||
// }
|
||||
|
||||
$nmo = new NinjaMailerObject;
|
||||
$nmo->mailable = new NinjaMailer((new EntitySentObject($event->invitation, 'invoice', $event->template))->build());
|
||||
$nmo->company = $invoice->company;
|
||||
|
@ -136,6 +136,12 @@ class EntitySentObject
|
||||
$this->template_subject = 'texts.notification_purchase_order_sent_subject';
|
||||
$this->template_body = 'texts.notification_purchase_order_sent';
|
||||
break;
|
||||
case 'custom1':
|
||||
case 'custom2':
|
||||
case 'custom3':
|
||||
$this->template_subject = 'texts.notification_invoice_custom_sent_subject';
|
||||
$this->template_body = 'texts.notification_invoice_sent';
|
||||
break;
|
||||
default:
|
||||
$this->template_subject = 'texts.notification_invoice_sent_subject';
|
||||
$this->template_body = 'texts.notification_invoice_sent';
|
||||
|
@ -38,7 +38,8 @@ use Illuminate\Support\Str;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel exclude(array $excludeable)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel withTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel scopeExclude()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel find()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel find()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel whereIn()
|
||||
* @method \App\Models\Company company()
|
||||
* @method int companyId()
|
||||
* @method Builder|static exclude($columns)
|
||||
|
@ -801,22 +801,29 @@ class Invoice extends BaseModel
|
||||
|
||||
public function entityEmailEvent($invitation, $reminder_template, $template = '')
|
||||
{
|
||||
nlog($template);
|
||||
|
||||
switch ($reminder_template) {
|
||||
case 'invoice':
|
||||
event(new InvoiceWasEmailed($invitation, $invitation->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null), $template));
|
||||
break;
|
||||
case 'reminder1':
|
||||
event(new InvoiceReminderWasEmailed($invitation, $invitation->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null), Activity::INVOICE_REMINDER1_SENT));
|
||||
event(new InvoiceReminderWasEmailed($invitation, $invitation->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null), $template));
|
||||
break;
|
||||
case 'reminder2':
|
||||
event(new InvoiceReminderWasEmailed($invitation, $invitation->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null), Activity::INVOICE_REMINDER2_SENT));
|
||||
event(new InvoiceReminderWasEmailed($invitation, $invitation->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null), $template));
|
||||
break;
|
||||
case 'reminder3':
|
||||
event(new InvoiceReminderWasEmailed($invitation, $invitation->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null), Activity::INVOICE_REMINDER3_SENT));
|
||||
event(new InvoiceReminderWasEmailed($invitation, $invitation->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null), $template));
|
||||
break;
|
||||
case 'reminder_endless':
|
||||
case 'endless_reminder':
|
||||
event(new InvoiceReminderWasEmailed($invitation, $invitation->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null), Activity::INVOICE_REMINDER_ENDLESS_SENT));
|
||||
event(new InvoiceReminderWasEmailed($invitation, $invitation->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null), $template));
|
||||
break;
|
||||
case 'custom1':
|
||||
case 'custom2':
|
||||
case 'custom3':
|
||||
event(new InvoiceReminderWasEmailed($invitation, $invitation->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null), $template));
|
||||
break;
|
||||
default:
|
||||
// code...
|
||||
|
@ -4012,6 +4012,7 @@ $LANG = array(
|
||||
'notification_invoice_reminder1_sent_subject' => 'Reminder 1 for Invoice :invoice was sent to :client',
|
||||
'notification_invoice_reminder2_sent_subject' => 'Reminder 2 for Invoice :invoice was sent to :client',
|
||||
'notification_invoice_reminder3_sent_subject' => 'Reminder 3 for Invoice :invoice was sent to :client',
|
||||
'notification_invoice_custom_sent_subject' => 'Custom reminder for Invoice :invoice was sent to :client',
|
||||
'notification_invoice_reminder_endless_sent_subject' => 'Endless reminder for Invoice :invoice was sent to :client',
|
||||
'assigned_user' => 'Assigned User',
|
||||
'setup_steps_notice' => 'To proceed to next step, make sure you test each section.',
|
||||
|
@ -4882,7 +4882,7 @@ Lorsque les montant apparaîtront sur votre relevé, veuillez revenir sur cette
|
||||
'email_queued' => 'Courriel en file d\'attente',
|
||||
'clone_to_recurring_invoice' => 'Dupliquer en facture récurrente',
|
||||
'inventory_threshold' => 'Seuil d\'inventaire',
|
||||
'emailed_statement' => 'L\'état de compte a été mis en file d\'attente pour l\'envoi',
|
||||
'emailed_statement' => 'Le relevé a été mis en file d\'attente pour l\'envoi',
|
||||
'show_email_footer' => 'Afficher le pied de page du courriel',
|
||||
'invoice_task_hours' => 'Facturer les heures de tâches',
|
||||
'invoice_task_hours_help' => 'Ajouter ces heures aux articles de la facture',
|
||||
@ -4910,7 +4910,7 @@ Lorsque les montant apparaîtront sur votre relevé, veuillez revenir sur cette
|
||||
'all_clients' => 'Tous les clients',
|
||||
'show_aging_table' => 'Afficher la liste des impayés',
|
||||
'show_payments_table' => 'Afficher la liste des paiements',
|
||||
'email_statement' => 'Envoyer par courriel l\'état de compte',
|
||||
'email_statement' => 'Envoyer le relevé par courriel',
|
||||
'once' => 'Une fois',
|
||||
'schedules' => 'Planifications',
|
||||
'new_schedule' => 'Nouvelle planification',
|
||||
@ -5037,7 +5037,7 @@ Lorsque les montant apparaîtront sur votre relevé, veuillez revenir sur cette
|
||||
'tax_all' => 'Tout taxer',
|
||||
'tax_selected' => 'Taxe sélectionnée',
|
||||
'version' => 'version',
|
||||
'seller_subregion' => 'Sous-région du vendeur',
|
||||
'seller_subregion' => 'Province du vendeur',
|
||||
'calculate_taxes' => 'Calculer les taxes',
|
||||
'calculate_taxes_help' => 'Calcul automatique des taxes à la sauvegarde des factures',
|
||||
'link_expenses' => 'Lier les dépenses',
|
||||
|
Loading…
Reference in New Issue
Block a user