In the following example, we are going to configure an email template.
This template will be used to notify the Requester about the creation of a new operation.
Step 1 – Template Identification Fields
Fill in the template identificative fields:
- Name (ex: ‘REQUESTER – OPERATION Created’)
- Code (ex: ’email_to_requester_operation_created’)
- Status: Enabled
Step 2 – Configure the email subject line
In the scripting area ‘Subject‘ insert the following PHP code
<!-- Double underscore method check for available translations of the string passed as parameter -->
<!--
$this->getPrefix() retrieve the prefix setted in current outgoing mailbox configuration
$this->getModel() returns the current model incance in this case the service operation instance
$this->getModel()->getId() retrive the operation ID
-->
<?php echo Deep::helper('deep_email')->__('Ticket with ID')?>
<?php echo $this->getPrefix().$this->getModel()->getId()?>
<?php echo Deep::helper('deep_email')->__('sent')?>
The resulting subject will be like: “Ticket with ID TICKET#101 sent”.
Step 3 – Configure the email body
In the Body scripting area enter the following PHP code
<?php
//$this->getModel() returns the current service operation instance
$operation = $this->getModel();
//$operation->getRequesterUser() loads the requester user object if he is registered
$requesterUser = $operation->getRequesterUser();
//test if requester is a registered user
$requesterIsRegistered = $requesterUser && $requesterUser->getId();
//if requester is registered then use getDisplayUsername() that returns 'Firstname Lastname'
//if the requester is not a registered user use the value of the service operation field requester_username
$requesterUsername = $requesterIsRegistered ? $requesterUser->getDisplayUsername() : $operation->getRequesterUsername();
?>
<!-- include header template -->
<?php $this->includeTemplate("header") ?>
<!-- Start of Main Content -->
<tr style="">
<td bgcolor="#FFFFFF" align="center" style="">
<table width="100%" align="center" cellpadding="0" cellspacing="0" border="0" class="devicewidth" style="">
<tbody style="">
<!-- Start Spacer -->
<tr>
<td class="w22" width="41" style="font-size:1px; line-height:1px;"> </td>
<td class="h26" height="36" style="font-size:1px; line-height:1px;"> </td>
<td class="w22" width="41" style="font-size:1px; line-height:1px;"> </td>
</tr>
<!-- End Spacer -->
<tr style="">
<td class="w22" width="41" style="font-size:1px; line-height:1px;"> </td>
<td class="mktEditable content mktEditable content" id="edit_text_1" valign="middle"
style="font-family:Calibri, Helvetica, sans-serif; font-size:16px; color:#505050;
text-align:left; line-height:25.6px; font-weight:normal; text-transform:none;">
<p>
<br>
<?php echo Deep::helper('deep_email')->__('Dear') . ' ' . $requesterUsername ?>,
<br>
<?php $url = $operation->getPortalUrl() ?>
<?php echo Deep::helper('deep_email')->__('Ticket with ID')?>
<b style="font-weight: 700;">
<?php if($requesterIsRegistered):?>
<a href="<?php echo $url ?>"><?php echo $operation->getId()?></a>
<?php else:?>
<?php echo $operation->getId()?>
<?php endif;?>
</b> <?php echo Deep::helper('deep_email')->__('has been received by our support')?>
<br><br>
<strong><?php echo Deep::helper('deep_email')->__('Title')?></strong>:
<br>
<!-- print the operation Title -->
<?php echo $operation->getTitle()?>
<br><br>
<strong><?php echo Deep::helper('deep_email')->__('Description')?></strong>:
<br>
<!-- print the operation Description -->
<?php echo $operation->getDescription()?>
<br>
<!-- Requester -->
<strong><?php echo Deep::helper('deep_service')->__('Requester User')?></strong>:
<?php if($requesterIsRegistered):?>
<?php if($requesterUser->getAvatar()):?>
<br>
<!-- if user is regitered and has an avatar print it -->
<img src="<?php echo $requesterUser->getAvatarUrl() ?>" border="0"
style="-ms-interpolation-mode: bicubic;" width="16" />
<?php endif;?>
<?php endif;?>
<!-- print the requester username -->
<?php echo $requesterUsername ?>
<br><br>
<!-- Urgency -->
<?php if($operation->getUrgencyId()):?>
<strong><?php echo Deep::helper('deep_email')->__('Urgency')?></strong>:
<?php
//load service operation urgency list
$urgencyList = Deep::helper('deep_list')->loadList(
Deep_Service_Model_Operation::LIST_CODE_URGENCY
);
//get the corrisponding Urgency label
$urgencyValue = $urgencyList->getValue($operation->getUrgencyId()); ?>
<br>
<!-- print urgency label -->
<?php echo Deep::helper('deep_email')->__($urgencyValue->getValueLabel()); ?>
<?php endif;?>
<br><br>
</p>
</td>
<td class="w22" width="41" style="font-size:1px; line-height:1px;"> </td>
</tr>
<!-- Start Spacer -->
<tr>
<td class="w22" width="41" style="font-size:1px; line-height:1px;"> </td>
<td height="30" style="font-size:1px; line-height:1px;"> </td>
<td class="w22" width="41" style="font-size:1px; line-height:1px;"> </td>
</tr>
<!-- End Spacer -->
</tbody>
</table>
</td>
</tr>
<!-- End of Main Content -->
<?php if($requesterIsRegistered):?>
<!-- start of Button -->
<tr style="">
<td bgcolor="#FFFFFF" align="center" class="mktEditable" id="edit_cta_button" style="">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="w22" width="41" style="font-size: 1px; line-height: 1px;"> </td>
<td align="left">
<table class="button" cellpadding="0" cellspacing="0" border="0" align="left"
bgcolor="#0080ff" style="-webkit-border-radius: 4px;
-moz-border-radius: 4px; border-radius: 4px;">
<tbody>
<tr>
<td width="518" align="center" valign="middle" height="65">
<span style="color: #ffffff; text-decoration: none;">
<!-- set the operation link as button link -->
<a class="mobButton mktNoTok" href="<?php echo $url ?>"
style="font-family: Calibri, Helvetica, sans-serif;
font-size: 16px; color: #ffffff; display: block; height: 65px;
mso-line-height-rule: exactly; line-height: 65px;
font-weight: normal; text-decoration: none;
text-align: center!important;"
target="_blank" title="Link al ticket">
<?php echo Deep::helper('deep_email')->__('Go to the Ticket')?>
</a>
</span>
</td>
</tr>
</tbody>
</table>
</td>
<td class="w22" width="41" style="font-size: 1px; line-height: 1px;"> </td>
</tr>
</tbody>
</table>
</td>
</tr>
<!-- end of Button -->
<?php endif;?>
<!-- include footer template -->
<?php $this->includeTemplate("footer") ?>
The email notification body will look like the image below.
