1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 15:13:29 +01:00
invoiceninja/app/DataMapper/EmailTemplateDefaults.php

253 lines
7.9 KiB
PHP
Raw Normal View History

<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @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)
*
2021-06-16 08:58:16 +02:00
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\DataMapper;
use Illuminate\Support\Facades\App;
class EmailTemplateDefaults
{
public static function getDefaultTemplate($template, $locale)
{
App::setLocale($locale);
switch ($template) {
/* Template */
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;
case 'email_template_payment':
return self::emailPaymentTemplate();
break;
case 'email_template_payment_partial':
2020-10-09 13:13:33 +02:00
return self::emailPaymentPartialTemplate();
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();
case 'email_template_purchase_order':
2022-06-10 09:04:16 +02:00
return self::emailPurchaseOrderTemplate();
break;
/* Subject */
case 'email_subject_purchase_order':
return self::emailPurchaseOrderSubject();
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;
case 'email_subject_payment':
return self::emailPaymentSubject();
break;
case 'email_subject_payment_partial':
2020-10-09 13:13:33 +02:00
return self::emailPaymentPartialSubject();
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;
default:
return self::emailInvoiceTemplate();
break;
}
}
public static function emailInvoiceSubject()
{
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']);
}
public static function emailInvoiceTemplate()
{
$invoice_message = '<p>$client<br><br>'.self::transformText('invoice_message').'</p><div class="center">$view_button</div>';
return $invoice_message;
}
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;
}
public static function emailQuoteSubject()
{
return ctrans('texts.quote_subject', ['number'=>'$number', 'account'=>'$company.name']);
}
public static function emailQuoteTemplate()
{
$quote_message = '<p>$client<br><br>'.self::transformText('quote_message').'</p><div class="center">$view_button</div>';
2020-10-26 22:54:59 +01:00
return $quote_message;
}
public static function emailPaymentSubject()
{
return ctrans('texts.payment_subject');
}
public static function emailPurchaseOrderSubject()
{
2022-06-10 09:04:16 +02:00
return ctrans('texts.purchase_order_subject', ['number' => '$number', 'account' => '$account']);
}
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;
}
public static function emailPaymentTemplate()
{
$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()
{
$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()
{
$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');
}
public static function emailReminder1Subject()
{
2022-03-28 23:04:04 +02:00
return ctrans('texts.reminder_subject', ['invoice'=>'$number', 'account'=>'$company.name']);
}
public static function emailReminder1Template()
{
2022-03-18 04:07:15 +01:00
return self::emailInvoiceReminderTemplate();
}
public static function emailReminder2Subject()
{
2022-03-28 23:04:04 +02:00
return ctrans('texts.reminder_subject', ['invoice'=>'$number', 'account'=>'$company.name']);
}
public static function emailReminder2Template()
{
2022-03-18 04:07:15 +01:00
return self::emailInvoiceReminderTemplate();
}
public static function emailReminder3Subject()
{
2022-03-28 23:04:04 +02:00
return ctrans('texts.reminder_subject', ['invoice'=>'$number', 'account'=>'$company.name']);
}
public static function emailReminder3Template()
{
2022-03-18 04:07:15 +01:00
return self::emailInvoiceReminderTemplate();
}
public static function emailReminderEndlessSubject()
{
2022-03-28 23:04:04 +02:00
return ctrans('texts.reminder_subject', ['invoice'=>'$number', 'account'=>'$company.name']);
}
public static function emailReminderEndlessTemplate()
{
2022-03-18 04:07:15 +01:00
return self::emailInvoiceReminderTemplate();
}
public static function emailStatementSubject()
{
2020-10-19 12:59:58 +02:00
return '';
}
public static function emailStatementTemplate()
{
2020-10-19 12:59:58 +02:00
return '';
}
private static function transformText($string)
{
//preformat the string, removing trailing colons.
return str_replace(':', '$', rtrim(ctrans('texts.'.$string), ':'));
}
}