This manual is deprecated. Please visit https://groupoffice.readthedocs.io for the latest documentation.

Difference between revisions of "Using the e-mail composer in your module"

From Group-Office Groupware and CRM Documentation
Jump to: navigation, search
Line 3: Line 3:
 
<pre>
 
<pre>
 
{
 
{
iconCls: 'bs-send-email',
+
iconCls: 'btn-compose',
 
text: GO.lang.strEmail,
 
text: GO.lang.strEmail,
 
cls: 'x-btn-text-icon',
 
cls: 'x-btn-text-icon',

Revision as of 09:27, 18 June 2010

In a lot of cases you might want to open the e-mail composer and preset it with values. For example the billing module opens the composer to send an invoice. You can do this by adding the following button:

{
	iconCls: 'btn-compose',
	text: GO.lang.strEmail,
	cls: 'x-btn-text-icon',
	handler: function(){
		if(!GO.email)
		{
			Ext.Msg.alert(GO.lang['strError'], GO.billing.lang.noEmailModule);
		}else
		{
			GO.email.showComposer({
				loadUrl: GO.settings.modules.yourmodule.url+'json.php',
				loadParams:{task:'sendmail',someparam: this.someparam},
				template_id: 0					
			});
		}

	},
	scope:this						
}

The loadUrl and loadParams configuration options will call your module's json.php so it can provide the composer with form data. passing template_id=0 will skip template selection for the pro version.

On the PHP side in json.php you should return some JSON data like this:

require_once('../../classes/mail/RFC822.class.inc'); 
$RFC822 = new RFC822();

$response['data']['body'] = '<h1>Hello world!</h1>';
$response['data']['subject']='My subject';
$response['data']['to']=$RFC822->write_address('My name', 'my@email.com');
$response['data']['cc']=$RFC822->write_address('My name', 'cc@email.com');


$tmp_file=$GO_CONFIG->tmpdir.'path/to/tempfile.pdf';
$response['data']['attachments'][] = array(
		'tmp_name'=>$tmp_file,
		'name'=>'Document.pdf',
		'size'=>filesize($tmp_file),
		'type'=>File::get_filetype_description('pdf')				
);