3
* WelcomeEmailPage.class.php
5
* This file contains the definition for the EmailInvoicePage class
8
* @author John Diamond <jdiamond@solid-state.org>
9
* @copyright John Diamond <jdiamond@solid-state.org>
10
* @license http://www.opensource.org/licenses/gpl-license.php GNU Public License
13
// Include the Email class
14
require_once BASE_PATH ."solidworks/Email.class.php";
16
// Include the parent class
17
require_once BASE_PATH . "solidworks/Page.class.php";
19
// Include the AccountDBO
20
require_once BASE_PATH . "DBO/AccountDBO.class.php";
25
* This page takes the ID of the account to send a welcome email to.
26
* The body of the welcome email is read from a configuration file and the appropriate
27
* data is filled in with the customer's data. The user is allowed to edit
28
* the raw content of the email, the subject, and the customers email address
29
* before the email is sent.
32
* @author John Diamond <jdiamond@solid-state.org>
34
class WelcomeEmailPage extends Page
37
* Initializes the Page
39
* Loads the DBO for the account ID provided as a GET paramenter
47
// Retrieve this Account from the database
48
$dbo = load_AccountDBO( intval( $id ) );
52
// Retrieve DBO from session
53
$dbo = $this->session['account_dbo'];
58
// Could not find Account in the database
59
$this->setError( array( "type" => "DB_ACCOUNT_NOT_FOUND",
60
"args" => array( $id ) ) );
64
// Store Account DBO in session
65
$this->session['account_dbo'] = $dbo;
68
// Place values on the template
69
$this->smarty->assign( "email", $dbo->getContactEmail() );
70
$this->smarty->assign( "subject", $this->conf['welcome_subject'] );
71
$this->smarty->assign( "email_body", $this->conf['welcome_email'] );
75
* Handles actions for this Page
77
* Actions handled by this Page:
78
* email_invoice (Form)
80
function action( $action_name )
82
switch( $action_name )
87
if( isset( $this->session['welcome_email']['continue'] ) )
91
elseif( isset( $this->session['welcome_email']['cancel'] ) )
100
// No matching action, refer to base class
101
parent::action( $action_name );
107
* Return the user to the view account page
111
$this->goto( "accounts_view_account",
113
"id=" . $this->session['account_dbo']->getID() );
117
* Email the welcome message and return to the view account page
119
function send_email()
121
// Construct an Email
122
$email = new Email();
123
$email->setFrom( $this->conf['company']['email'],
124
$this->conf['company']['name'] );
125
$email->addRecipient( $this->session['welcome_email']['email'] );
126
$email->setSubject( $this->session['welcome_email']['subject'] );
127
$email->setBody( $this->session['welcome_email']['email_body'] );
130
if( !$email->send() )
132
// Error delivering invoice
133
$this->setError( array( "type" => "WELCOME_EMAIL_FAILED" ) );
134
$this->goto( "accounts_view_account",
136
"id=" . $this->session['account_dbo']->getID() );
139
// Return to view_account with a sucess message
140
$this->setMessage( array( "type" => "WELCOME_SENT" ) );
141
$this->goto( "accounts_view_account",
143
"id=" . $this->session['account_dbo']->getID() );
b'\\ No newline at end of file'