2019-11-22 22:10:53 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2020-01-07 01:13:47 +01:00
|
|
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-11-22 22:10:53 +01:00
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\DataMapper;
|
|
|
|
|
2020-03-25 03:50:08 +01:00
|
|
|
use Illuminate\Support\Facades\App;
|
2020-01-20 02:31:58 +01:00
|
|
|
use League\CommonMark\CommonMarkConverter;
|
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-03-25 03:50:08 +01:00
|
|
|
case 'email_template_invoice':
|
|
|
|
return self::emailInvoiceTemplate();
|
|
|
|
break;
|
|
|
|
case 'email_template_quote':
|
|
|
|
return self::emailQuoteTemplate();
|
|
|
|
break;
|
|
|
|
case 'email_template_payment':
|
|
|
|
return self::emailPaymentTemplate();
|
|
|
|
break;
|
|
|
|
case 'email_template_payment_partial':
|
|
|
|
return self::emailPaymentTemplate();
|
|
|
|
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();
|
|
|
|
break;
|
|
|
|
|
2020-03-26 04:23:57 +01:00
|
|
|
/* Subject */
|
|
|
|
|
|
|
|
case 'email_subject_invoice':
|
|
|
|
return self::emailInvoiceSubject();
|
|
|
|
break;
|
|
|
|
case 'email_subject_quote':
|
|
|
|
return self::emailQuoteSubject();
|
|
|
|
break;
|
|
|
|
case 'email_subject_payment':
|
|
|
|
return self::emailPaymentSubject();
|
|
|
|
break;
|
|
|
|
case 'email_subject_payment_partial':
|
|
|
|
return self::emailPaymentSubject();
|
|
|
|
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']);
|
2019-12-10 21:25:54 +01:00
|
|
|
//return Parsedown::instance()->line(self::transformText('invoice_subject'));
|
2019-11-22 22:10:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function emailInvoiceTemplate()
|
|
|
|
{
|
2020-01-20 02:31:58 +01:00
|
|
|
$converter = new CommonMarkConverter([
|
|
|
|
'html_input' => 'strip',
|
|
|
|
'allow_unsafe_links' => false,
|
|
|
|
]);
|
|
|
|
|
|
|
|
return $converter->convertToHtml(self::transformText('invoice_message'));
|
|
|
|
|
2019-11-22 22:10:53 +01:00
|
|
|
}
|
|
|
|
|
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-12-10 21:25:54 +01:00
|
|
|
|
|
|
|
//return Parsedown::instance()->line(self::transformText('quote_subject'));
|
2019-11-24 07:37:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function emailQuoteTemplate()
|
|
|
|
{
|
2020-01-20 02:31:58 +01:00
|
|
|
$converter = new CommonMarkConverter([
|
|
|
|
'html_input' => 'strip',
|
|
|
|
'allow_unsafe_links' => false,
|
|
|
|
]);
|
|
|
|
|
|
|
|
return $converter->convertToHtml(self::transformText('quote_message'));
|
|
|
|
//return Parsedown::instance()->line(self::transformText('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');
|
|
|
|
//return Parsedown::instance()->line(self::transformText('payment_subject'));
|
2019-11-24 07:37:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function emailPaymentTemplate()
|
|
|
|
{
|
|
|
|
return Parsedown::instance()->line(self::transformText('payment_message'));
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function emailReminder1Subject()
|
|
|
|
{
|
2019-12-16 12:34:38 +01:00
|
|
|
return ctrans('texts.reminder_subject', ['invoice'=>'$invoice.number', 'account'=>'$company.name']);
|
2019-11-24 07:37:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function emailReminder1Template()
|
|
|
|
{
|
2020-03-21 06:37:30 +01:00
|
|
|
// return Parsedown::instance()->line('First Email Reminder Text');
|
2019-11-24 07:37:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function emailReminder2Subject()
|
|
|
|
{
|
2019-12-16 12:34:38 +01:00
|
|
|
return ctrans('texts.reminder_subject', ['invoice'=>'$invoice.number', 'account'=>'$company.name']);
|
2019-12-10 21:25:54 +01:00
|
|
|
// return Parsedown::instance()->line(self::transformText('reminder_subject'));
|
2019-11-24 07:37:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function emailReminder2Template()
|
|
|
|
{
|
2020-03-21 06:37:30 +01:00
|
|
|
// return Parsedown::instance()->line('Second Email Reminder Text');
|
2019-11-24 07:37:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function emailReminder3Subject()
|
|
|
|
{
|
2019-12-16 12:34:38 +01:00
|
|
|
return ctrans('texts.reminder_subject', ['invoice'=>'$invoice.number', 'account'=>'$company.name']);
|
2019-12-10 21:25:54 +01:00
|
|
|
// return Parsedown::instance()->line(self::transformText('reminder_subject'));
|
2019-11-24 07:37:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function emailReminder3Template()
|
|
|
|
{
|
2020-03-21 06:37:30 +01:00
|
|
|
// return Parsedown::instance()->line('Third Email Reminder Text');
|
2019-11-24 07:37:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function emailReminderEndlessSubject()
|
|
|
|
{
|
2019-12-16 12:34:38 +01:00
|
|
|
return ctrans('texts.reminder_subject', ['invoice'=>'$invoice.number', 'account'=>'$company.name']);
|
2019-12-10 21:25:54 +01:00
|
|
|
// return Parsedown::instance()->line(self::transformText('reminder_subject'));
|
2019-11-24 07:37:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function emailReminderEndlessTemplate()
|
|
|
|
{
|
|
|
|
return Parsedown::instance()->line('Endless Email Reminder Text');
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function emailStatementSubject()
|
|
|
|
{
|
|
|
|
return Parsedown::instance()->line('Statement Subject needs texts record!');
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function emailStatementTemplate()
|
|
|
|
{
|
|
|
|
return Parsedown::instance()->line('Statement Templates needs texts record!');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-22 22:10:53 +01:00
|
|
|
private static function transformText($string)
|
|
|
|
{
|
|
|
|
return str_replace(":", "$", ctrans('texts.'.$string));
|
|
|
|
}
|
|
|
|
}
|