private function saveEmailTemplates()
{
if (Auth::user()->account->hasFeature(FEATURE_EMAIL_TEMPLATES_REMINDERS)) {
$account = Auth::user()->account;
foreach ([ENTITY_INVOICE, ENTITY_QUOTE, ENTITY_PAYMENT, REMINDER1, REMINDER2, REMINDER3] as $type) {
$subjectField = "email_subject_{$type}";
$subject = Input::get($subjectField, $account->getEmailSubject($type));
$account->{$subjectField} = $subject == $account->getDefaultEmailSubject($type) ? null : $subject;
$bodyField = "email_template_{$type}";
$body = Input::get($bodyField, $account->getEmailTemplate($type));
$account->{$bodyField} = $body == $account->getDefaultEmailTemplate($type) ? null : $body;
}
foreach ([REMINDER1, REMINDER2, REMINDER3] as $type) {
$enableField = "enable_{$type}";
$account->{$enableField} = Input::get($enableField) ? true : false;
if ($account->{$enableField}) {
$account->{"num_days_{$type}"} = Input::get("num_days_{$type}");
$account->{"field_{$type}"} = Input::get("field_{$type}");
$account->{"direction_{$type}"} = Input::get("field_{$type}") == REMINDER_FIELD_INVOICE_DATE ? REMINDER_DIRECTION_AFTER : Input::get("direction_{$type}");
}
}
$account->save();
Session::flash('message', trans('texts.updated_settings'));
}
return Redirect::to('settings/' . ACCOUNT_TEMPLATES_AND_REMINDERS);
}