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
|
|
|
|
*
|
2022-04-27 05:20:41 +02:00
|
|
|
* @copyright Copyright (c) 2022. 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
|
|
|
|
{
|
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();
|
|
|
|
break;
|
|
|
|
case 'email_template_quote':
|
|
|
|
return self::emailQuoteTemplate();
|
|
|
|
break;
|
2020-10-15 23:55:24 +02:00
|
|
|
case 'email_template_credit':
|
|
|
|
return self::emailCreditTemplate();
|
|
|
|
break;
|
2020-03-25 03:50:08 +01:00
|
|
|
case 'email_template_payment':
|
|
|
|
return self::emailPaymentTemplate();
|
|
|
|
break;
|
|
|
|
case 'email_template_payment_partial':
|
2020-10-09 13:13:33 +02:00
|
|
|
return self::emailPaymentPartialTemplate();
|
2020-03-25 03:50:08 +01:00
|
|
|
break;
|
|
|
|
case 'email_template_statement':
|
|
|
|
return self::emailStatementTemplate();
|
|
|
|
break;
|
|
|
|
case 'email_template_reminder1':
|
|
|
|
return self::emailReminder1Template();
|
|
|
|
break;
|
|
|
|
case 'email_template_reminder2':
|
|
|
|
return self::emailReminder2Template();
|
|
|
|
break;
|
|
|
|
case 'email_template_reminder3':
|
|
|
|
return self::emailReminder3Template();
|
|
|
|
break;
|
|
|
|
case 'email_template_reminder_endless':
|
|
|
|
return self::emailReminderEndlessTemplate();
|
|
|
|
break;
|
|
|
|
case 'email_template_custom1':
|
|
|
|
return self::emailInvoiceTemplate();
|
|
|
|
break;
|
|
|
|
case 'email_template_custom2':
|
|
|
|
return self::emailInvoiceTemplate();
|
|
|
|
break;
|
|
|
|
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();
|
2020-03-25 03:50:08 +01:00
|
|
|
break;
|
|
|
|
|
2020-03-26 04:23:57 +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();
|
|
|
|
break;
|
|
|
|
case 'email_subject_quote':
|
|
|
|
return self::emailQuoteSubject();
|
|
|
|
break;
|
2020-10-15 23:55:24 +02:00
|
|
|
case 'email_subject_credit':
|
|
|
|
return self::emailCreditSubject();
|
|
|
|
break;
|
2020-03-26 04:23:57 +01:00
|
|
|
case 'email_subject_payment':
|
|
|
|
return self::emailPaymentSubject();
|
|
|
|
break;
|
|
|
|
case 'email_subject_payment_partial':
|
2020-10-09 13:13:33 +02:00
|
|
|
return self::emailPaymentPartialSubject();
|
2020-03-26 04:23:57 +01:00
|
|
|
break;
|
|
|
|
case 'email_subject_statement':
|
|
|
|
return self::emailStatementSubject();
|
|
|
|
break;
|
|
|
|
case 'email_subject_reminder1':
|
|
|
|
return self::emailReminder1Subject();
|
|
|
|
break;
|
|
|
|
case 'email_subject_reminder2':
|
|
|
|
return self::emailReminder2Subject();
|
|
|
|
break;
|
|
|
|
case 'email_subject_reminder3':
|
|
|
|
return self::emailReminder3Subject();
|
|
|
|
break;
|
|
|
|
case 'email_subject_reminder_endless':
|
|
|
|
return self::emailReminderEndlessSubject();
|
|
|
|
break;
|
|
|
|
case 'email_subject_custom1':
|
|
|
|
return self::emailInvoiceSubject();
|
|
|
|
break;
|
|
|
|
case 'email_subject_custom2':
|
|
|
|
return self::emailInvoiceSubject();
|
|
|
|
break;
|
|
|
|
case 'email_subject_custom3':
|
|
|
|
return self::emailInvoiceSubject();
|
|
|
|
break;
|
|
|
|
|
2020-03-25 03:50:08 +01:00
|
|
|
default:
|
|
|
|
return self::emailInvoiceTemplate();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-22 22:10:53 +01:00
|
|
|
public static function emailInvoiceSubject()
|
|
|
|
{
|
2019-12-16 12:34:38 +01:00
|
|
|
return ctrans('texts.invoice_subject', ['number'=>'$number', 'account'=>'$company.name']);
|
2020-10-15 23:55:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function emailCreditSubject()
|
|
|
|
{
|
|
|
|
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()
|
|
|
|
{
|
2019-12-16 12:34:38 +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()
|
|
|
|
{
|
2022-03-28 23:04:04 +02: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()
|
|
|
|
{
|
2022-03-28 23:04:04 +02: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()
|
|
|
|
{
|
2022-03-28 23:04:04 +02: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()
|
|
|
|
{
|
2022-03-28 23:04:04 +02: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 03:28:46 +01:00
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|