Call Us:
For basic information on plugins, please refer: Infocapture plugins
In this section we would see how to send an email notification to the entered email address if the “Send Email” checkbox is checked
You can find the xml file of the test project here:
Lets suppose we have got this test project with ID = 12
For this purpose we would need plugin_12_add_issue.php file
<?php> function hd_plugin_12_add_issue($params) { //This function is used to send an Email Notification Template //$email_address: The email id to send an Email Notification //$id: id of the Notification Template //$templates: An array which consists the template function sendMessage($email_address, $id, $templates) { $msg = new ClaMailMessage('utf-8'); $msg->SetFrom("noreply@claromentis.com"); $msg->SetTo($email_address); $msg->SetSubject($templates["subj"]["$id"]); if($templates["html"]["$id"]) { $msg->SetTxtBody(Html2Plain($templates["body"]["$id"])); $msg->SetHtmlBody($templates["body"]["$id"]); } else { $msg->SetTxtBody($templates["body"]["$id"]); } $msg->Send(); } //Creating neccessary objects while used in parsing $issue = new HDIssue(); $issue->Load($params["issue"]["id"]); $issue->GetFormData(); //Getting all Notifications from the project $project = new HDProject(); $project->Load($params["project"]["id"]); list($notif_templates, $notif_settings) = $project->GetNotifSettings(); $fbform = new FBForm(); $pid = 12; if(!$project->Load($pid)) { $errno = "Cannot load current project"; vard2($errno); exit; } $fbform = $project->getForm(); $fbform->loadFields(); $fd = $issue->GetFormData(); if ($fd) { $fd->loadAllData(); } $fd->LoadFormPrototype($form); $fd->loadAllData(); $fd->GetFieldsData(); //To fetch the values: email and send of the form $values = $params["issue"]["fields_values"]; $templates = array(); $templates["body"][0] = ""; $templates["subj"][0] = ""; $templates["html"][0] = ""; $tmpl = parse_ic_templates($params); if($values['send'] == 1) sendMessage($values['email'], "1", $tmpl); } ?>
Place the above file in folder: /httpdocs/intranet/helpdesk/plugins/
Check the checkbox to send an email notification to the entered email address.
After reporting the issue, the person with the above mention email address would receive an email notification.
Discussion