2019-11-22 22:10:53 +01:00
|
|
|
<?php
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2019-11-22 22:10:53 +01:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2023-01-28 23:21:40 +01:00
|
|
|
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-11-22 22:10:53 +01:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2019-11-22 22:10:53 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\DataMapper;
|
|
|
|
|
2020-03-25 03:50:08 +01:00
|
|
|
use Illuminate\Support\Facades\App;
|
2019-11-22 22:10:53 +01:00
|
|
|
|
|
|
|
class EmailTemplateDefaults
|
|
|
|
{
|
2023-12-17 00:16:02 +01:00
|
|
|
public array $templates = [
|
|
|
|
'email_template_invoice',
|
|
|
|
'email_template_quote',
|
|
|
|
'email_template_credit',
|
|
|
|
'email_template_payment',
|
|
|
|
'email_template_payment_partial',
|
|
|
|
'email_template_statement',
|
|
|
|
'email_template_reminder1',
|
|
|
|
'email_template_reminder2',
|
|
|
|
'email_template_reminder3',
|
|
|
|
'email_template_reminder_endless',
|
|
|
|
'email_template_custom1',
|
|
|
|
'email_template_custom2',
|
|
|
|
'email_template_custom3',
|
|
|
|
'email_template_purchase_order',
|
|
|
|
];
|
|
|
|
|
2020-03-25 03:50:08 +01:00
|
|
|
public static function getDefaultTemplate($template, $locale)
|
|
|
|
{
|
|
|
|
App::setLocale($locale);
|
|
|
|
|
|
|
|
switch ($template) {
|
2020-03-26 04:23:57 +01:00
|
|
|
/* Template */
|
2020-09-06 11:38:10 +02:00
|
|
|
|
2020-03-25 03:50:08 +01:00
|
|
|
case 'email_template_invoice':
|
|
|
|
return self::emailInvoiceTemplate();
|
|
|
|
case 'email_template_quote':
|
|
|
|
return self::emailQuoteTemplate();
|
2020-10-15 23:55:24 +02:00
|
|
|
case 'email_template_credit':
|
|
|
|
return self::emailCreditTemplate();
|
2020-03-25 03:50:08 +01:00
|
|
|
case 'email_template_payment':
|
|
|
|
return self::emailPaymentTemplate();
|
|
|
|
case 'email_template_payment_partial':
|
2020-10-09 13:13:33 +02:00
|
|
|
return self::emailPaymentPartialTemplate();
|
2020-03-25 03:50:08 +01:00
|
|
|
case 'email_template_statement':
|
|
|
|
return self::emailStatementTemplate();
|
|
|
|
case 'email_template_reminder1':
|
|
|
|
return self::emailReminder1Template();
|
|
|
|
case 'email_template_reminder2':
|
|
|
|
return self::emailReminder2Template();
|
|
|
|
case 'email_template_reminder3':
|
|
|
|
return self::emailReminder3Template();
|
|
|
|
case 'email_template_reminder_endless':
|
|
|
|
return self::emailReminderEndlessTemplate();
|
|
|
|
case 'email_template_custom1':
|
|
|
|
return self::emailInvoiceTemplate();
|
|
|
|
case 'email_template_custom2':
|
|
|
|
return self::emailInvoiceTemplate();
|
|
|
|
case 'email_template_custom3':
|
|
|
|
return self::emailInvoiceTemplate();
|
2022-06-09 09:45:19 +02:00
|
|
|
case 'email_template_purchase_order':
|
2022-06-10 09:04:16 +02:00
|
|
|
return self::emailPurchaseOrderTemplate();
|
2023-02-16 02:36:09 +01:00
|
|
|
/* Subject */
|
2022-06-09 09:45:19 +02:00
|
|
|
case 'email_subject_purchase_order':
|
|
|
|
return self::emailPurchaseOrderSubject();
|
2020-03-26 04:23:57 +01:00
|
|
|
case 'email_subject_invoice':
|
|
|
|
return self::emailInvoiceSubject();
|
2024-01-14 05:05:00 +01:00
|
|
|
|
2020-03-26 04:23:57 +01:00
|
|
|
case 'email_subject_quote':
|
|
|
|
return self::emailQuoteSubject();
|
2024-01-14 05:05:00 +01:00
|
|
|
|
2020-10-15 23:55:24 +02:00
|
|
|
case 'email_subject_credit':
|
|
|
|
return self::emailCreditSubject();
|
2024-01-14 05:05:00 +01:00
|
|
|
|
2020-03-26 04:23:57 +01:00
|
|
|
case 'email_subject_payment':
|
|
|
|
return self::emailPaymentSubject();
|
2024-01-14 05:05:00 +01:00
|
|
|
|
2020-03-26 04:23:57 +01:00
|
|
|
case 'email_subject_payment_partial':
|
2020-10-09 13:13:33 +02:00
|
|
|
return self::emailPaymentPartialSubject();
|
2024-01-14 05:05:00 +01:00
|
|
|
|
2020-03-26 04:23:57 +01:00
|
|
|
case 'email_subject_statement':
|
|
|
|
return self::emailStatementSubject();
|
2024-01-14 05:05:00 +01:00
|
|
|
|
2020-03-26 04:23:57 +01:00
|
|
|
case 'email_subject_reminder1':
|
|
|
|
return self::emailReminder1Subject();
|
2024-01-14 05:05:00 +01:00
|
|
|
|
2020-03-26 04:23:57 +01:00
|
|
|
case 'email_subject_reminder2':
|
|
|
|
return self::emailReminder2Subject();
|
2024-01-14 05:05:00 +01:00
|
|
|
|
2020-03-26 04:23:57 +01:00
|
|
|
case 'email_subject_reminder3':
|
|
|
|
return self::emailReminder3Subject();
|
2024-01-14 05:05:00 +01:00
|
|
|
|
2020-03-26 04:23:57 +01:00
|
|
|
case 'email_subject_reminder_endless':
|
|
|
|
return self::emailReminderEndlessSubject();
|
2024-01-14 05:05:00 +01:00
|
|
|
|
2020-03-26 04:23:57 +01:00
|
|
|
case 'email_subject_custom1':
|
|
|
|
return self::emailInvoiceSubject();
|
2024-01-14 05:05:00 +01:00
|
|
|
|
2020-03-26 04:23:57 +01:00
|
|
|
case 'email_subject_custom2':
|
|
|
|
return self::emailInvoiceSubject();
|
2024-01-14 05:05:00 +01:00
|
|
|
|
2020-03-26 04:23:57 +01:00
|
|
|
case 'email_subject_custom3':
|
|
|
|
return self::emailInvoiceSubject();
|
2024-01-14 05:05:00 +01:00
|
|
|
|
2023-11-24 06:10:10 +01:00
|
|
|
case 'email_vendor_notification_subject':
|
|
|
|
return self::emailVendorNotificationSubject();
|
|
|
|
|
|
|
|
case 'email_vendor_notification_body':
|
|
|
|
return self::emailVendorNotificationBody();
|
2020-03-26 04:23:57 +01:00
|
|
|
|
2020-03-25 03:50:08 +01:00
|
|
|
default:
|
|
|
|
return self::emailInvoiceTemplate();
|
2024-01-14 05:05:00 +01:00
|
|
|
|
2020-03-25 03:50:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-24 06:10:10 +01:00
|
|
|
public static function emailVendorNotificationSubject()
|
|
|
|
{
|
|
|
|
return self::transformText('vendor_notification_subject');
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function emailVendorNotificationBody()
|
|
|
|
{
|
|
|
|
return self::transformText('vendor_notification_body');
|
|
|
|
}
|
|
|
|
|
2019-11-22 22:10:53 +01:00
|
|
|
public static function emailInvoiceSubject()
|
|
|
|
{
|
2024-01-14 05:05:00 +01:00
|
|
|
return ctrans('texts.invoice_subject', ['number' => '$number', 'account' => '$company.name']);
|
2020-10-15 23:55:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function emailCreditSubject()
|
|
|
|
{
|
2024-01-14 05:05:00 +01:00
|
|
|
return ctrans('texts.credit_subject', ['number' => '$number', 'account' => '$company.name']);
|
2019-11-22 22:10:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function emailInvoiceTemplate()
|
|
|
|
{
|
2022-03-11 12:30:29 +01:00
|
|
|
$invoice_message = '<p>$client<br><br>'.self::transformText('invoice_message').'</p><div class="center">$view_button</div>';
|
2020-09-06 11:38:10 +02:00
|
|
|
|
2020-08-02 11:59:32 +02:00
|
|
|
return $invoice_message;
|
2019-11-22 22:10:53 +01:00
|
|
|
}
|
|
|
|
|
2022-03-16 08:50:34 +01:00
|
|
|
public static function emailInvoiceReminderTemplate()
|
|
|
|
{
|
|
|
|
$invoice_message = '<p>$client<br><br>'.self::transformText('reminder_message').'</p><div class="center">$view_button</div>';
|
|
|
|
|
|
|
|
return $invoice_message;
|
|
|
|
}
|
|
|
|
|
2019-11-24 07:37:53 +01:00
|
|
|
public static function emailQuoteSubject()
|
|
|
|
{
|
2024-01-14 05:05:00 +01:00
|
|
|
return ctrans('texts.quote_subject', ['number' => '$number', 'account' => '$company.name']);
|
2019-11-24 07:37:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function emailQuoteTemplate()
|
|
|
|
{
|
2022-03-11 12:30:29 +01:00
|
|
|
$quote_message = '<p>$client<br><br>'.self::transformText('quote_message').'</p><div class="center">$view_button</div>';
|
2020-01-20 02:31:58 +01:00
|
|
|
|
2020-10-26 22:54:59 +01:00
|
|
|
return $quote_message;
|
2019-11-24 07:37:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function emailPaymentSubject()
|
|
|
|
{
|
2019-12-10 21:25:54 +01:00
|
|
|
return ctrans('texts.payment_subject');
|
2019-11-24 07:37:53 +01:00
|
|
|
}
|
|
|
|
|
2022-06-09 09:45:19 +02:00
|
|
|
public static function emailPurchaseOrderSubject()
|
|
|
|
{
|
2022-06-10 09:04:16 +02:00
|
|
|
return ctrans('texts.purchase_order_subject', ['number' => '$number', 'account' => '$account']);
|
2022-06-09 09:45:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function emailPurchaseOrderTemplate()
|
|
|
|
{
|
|
|
|
$purchase_order_message = '<p>$vendor<br><br>'.self::transformText('purchase_order_message').'</p><div class="center">$view_button</div>';
|
|
|
|
|
|
|
|
return $purchase_order_message;
|
|
|
|
}
|
|
|
|
|
2019-11-24 07:37:53 +01:00
|
|
|
public static function emailPaymentTemplate()
|
|
|
|
{
|
2022-03-11 12:30:29 +01:00
|
|
|
$payment_message = '<p>$client<br><br>'.self::transformText('payment_message').'<br><br>$invoices</p><div class="center">$view_button</div>';
|
2020-10-30 07:54:25 +01:00
|
|
|
|
|
|
|
return $payment_message;
|
2020-10-09 13:13:33 +02:00
|
|
|
}
|
|
|
|
|
2020-10-15 23:55:24 +02:00
|
|
|
public static function emailCreditTemplate()
|
|
|
|
{
|
2022-03-11 12:30:29 +01:00
|
|
|
$credit_message = '<p>$client<br><br>'.self::transformText('credit_message').'</p><div class="center">$view_button</div>';
|
2020-10-15 23:55:24 +02:00
|
|
|
|
2020-10-26 22:54:59 +01:00
|
|
|
return $credit_message;
|
2020-10-15 23:55:24 +02:00
|
|
|
}
|
|
|
|
|
2020-10-09 22:31:24 +02:00
|
|
|
public static function emailPaymentPartialTemplate()
|
|
|
|
{
|
2022-03-11 12:30:29 +01:00
|
|
|
$payment_message = '<p>$client<br><br>'.self::transformText('payment_message').'<br><br>$invoices</p><div class="center">$view_button</div>';
|
2020-10-30 07:54:25 +01:00
|
|
|
|
|
|
|
return $payment_message;
|
2020-10-09 22:31:24 +02:00
|
|
|
}
|
|
|
|
|
2020-10-09 13:13:33 +02:00
|
|
|
public static function emailPaymentPartialSubject()
|
|
|
|
{
|
|
|
|
return ctrans('texts.payment_subject');
|
2019-11-24 07:37:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function emailReminder1Subject()
|
|
|
|
{
|
2024-01-14 05:05:00 +01:00
|
|
|
return ctrans('texts.reminder_subject', ['invoice' => '$number', 'account' => '$company.name']);
|
2019-11-24 07:37:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function emailReminder1Template()
|
|
|
|
{
|
2022-03-18 04:07:15 +01:00
|
|
|
return self::emailInvoiceReminderTemplate();
|
2019-11-24 07:37:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function emailReminder2Subject()
|
|
|
|
{
|
2024-01-14 05:05:00 +01:00
|
|
|
return ctrans('texts.reminder_subject', ['invoice' => '$number', 'account' => '$company.name']);
|
2019-11-24 07:37:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function emailReminder2Template()
|
|
|
|
{
|
2022-03-18 04:07:15 +01:00
|
|
|
return self::emailInvoiceReminderTemplate();
|
2019-11-24 07:37:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function emailReminder3Subject()
|
|
|
|
{
|
2024-01-14 05:05:00 +01:00
|
|
|
return ctrans('texts.reminder_subject', ['invoice' => '$number', 'account' => '$company.name']);
|
2019-11-24 07:37:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function emailReminder3Template()
|
|
|
|
{
|
2022-03-18 04:07:15 +01:00
|
|
|
return self::emailInvoiceReminderTemplate();
|
2019-11-24 07:37:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function emailReminderEndlessSubject()
|
|
|
|
{
|
2024-01-14 05:05:00 +01:00
|
|
|
return ctrans('texts.reminder_subject', ['invoice' => '$number', 'account' => '$company.name']);
|
2019-11-24 07:37:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function emailReminderEndlessTemplate()
|
|
|
|
{
|
2022-03-18 04:07:15 +01:00
|
|
|
return self::emailInvoiceReminderTemplate();
|
2019-11-24 07:37:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function emailStatementSubject()
|
|
|
|
{
|
2023-01-15 03:28:46 +01:00
|
|
|
return ctrans('texts.your_statement');
|
2019-11-24 07:37:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function emailStatementTemplate()
|
|
|
|
{
|
2023-01-15 04:44:23 +01:00
|
|
|
$statement_message = '<p>$client<br><br>'.self::transformText('client_statement_body').'<br></p>';
|
2023-01-15 03:28:46 +01:00
|
|
|
|
|
|
|
return $statement_message;
|
|
|
|
|
|
|
|
// return ctrans('texts.client_statement_body', ['start_date' => '$start_date', 'end_date' => '$end_date']);
|
2019-11-24 07:37:53 +01:00
|
|
|
}
|
|
|
|
|
2019-11-22 22:10:53 +01:00
|
|
|
private static function transformText($string)
|
|
|
|
{
|
2021-01-12 21:40:49 +01:00
|
|
|
//preformat the string, removing trailing colons.
|
|
|
|
|
2022-06-21 11:57:17 +02:00
|
|
|
return str_replace(':', '$', rtrim(ctrans('texts.'.$string), ':'));
|
2019-11-22 22:10:53 +01:00
|
|
|
}
|
|
|
|
}
|