@@ -199,6 +199,13 @@ public function adjust_selection()
199199 $ this ->setTemplateName ('text_inner ' );
200200 }
201201
202+ /**
203+ * Select invoices for output
204+ *
205+ * See template: modules/common/templates/elements/select_for_output.tpl
206+ *
207+ * @return void
208+ */
202209 public function select_for_output ()
203210 {
204211
@@ -228,6 +235,28 @@ public function select_for_output()
228235 $ s_data = $ output_details ['search_defaults ' ];
229236 $ s_data ['type ' ] = $ _GET ['type ' ] = $ type ;
230237
238+ // Keep track of the email text on the session so that it
239+ // remains as the user changes page.
240+ $ _SESSION ['selected_output ' ]['emailtext ' ] = $ this ->_data ['emailtext ' ];
241+ if (empty ($ _SESSION ['selected_output ' ]['emailtext ' ])) {
242+ $ sc = new Systemcompany ();
243+ $ sc ->load (COMPANY_ID );
244+ $ replyto = [];
245+ if ($ this ->_data ['type ' ] == "statement " ) {
246+ $ replyto = $ sc ->getStatementReplyToEmailAddress (true );
247+ }
248+ if ($ this ->_data ['type ' ] == "invoice " ) {
249+ $ replyto = $ sc ->getInvoiceReplyToEmailAddress (true );
250+ }
251+ if ($ this ->_data ['type ' ] == "remittance " ) {
252+ $ replyto = $ sc ->getRemittanceReplyToEmailAddress (true );
253+ }
254+ if (!empty ($ replyto ) && $ replyto [key ($ replyto )] != "" ) {
255+ $ _SESSION ['selected_output ' ]['emailtext ' ] = $ replyto [key ($ replyto )];
256+ }
257+ }
258+ $ this ->view ->set ('emailtext ' , $ _SESSION ['selected_output ' ]['emailtext ' ]);
259+
231260 $ this ->setSearch ($ output_details ['search_do ' ], $ output_details ['search_method ' ], $ s_data , array (), TRUE );
232261 // End of search
233262
@@ -677,7 +706,10 @@ public function printAction()
677706 $ userPreferences = UserPreferences::instance (EGS_USERNAME );
678707 $ this ->view ->set ('default_printer ' , $ this ->getDefaultPrinter ());
679708
680- $ this ->view ->set ('emailtext ' , $ this ->email_signature ());
709+ // Fallback - add a default email signature
710+ if ($ this ->view ->get ('emailtext ' ) == false ) {
711+ $ this ->view ->set ('emailtext ' , $ this ->email_signature ());
712+ }
681713
682714 $ sc = new Systemcompany ();
683715 $ sc ->load (COMPANY_ID );
0 commit comments