<!--###### MODAL BOX Start From Here ######--> <div role="dialog" tabindex="-1" aria-labelledby="header99" class="slds-modal slds-slide-up-open slds-modal_large" style="width:100%;"> <div class="slds-modal__container"> <!-- ###### MODAL BOX HEADER Part Start From Here ######--> <div class="slds-modal__header"> </div> <!--###### MODAL BOX BODY Part Start From Here ######--> <div class="slds-modal__content slds-p-around--medium">
<div style="background-color:white;padding:10pt;border-radius:5px;"> <b>{!v.sample}</b><br/><br/> <button class="slds-button slds-button--brand" onclick="{!c.onClickCancelButton}">Click here to go back to service appointment</button> </div>
</div> <!--###### MODAL BOX FOOTER Part Start From Here ######--> <div class="slds-modal__footer"> <button class="slds-button slds-button--neutral" onclick="{!c.closeModel}" >Cancel</button> </div> </div> </div> <div class="slds-backdrop slds-backdrop--open"></div> <!--###### MODAL BOX Part END Here ######--> </aura:if> </div>
</aura:component>
Controller:
({
onload : function(component, event, helper) {
var action = component.get("c.messagemtd"); action.setParams({ woid : component.get("v.recordId") }); action.setCallback(this, function(actionResult) { var state = actionResult.getState(); if (state === "SUCCESS") { component.set("v.sample", actionResult.getReturnValue());
@AuraEnabled public static string messagemtd(String woid) { str= emailestimatePdf(woid);
if(str == 'noe') message = 'Please select a Contact in work order.'; else if(str == 'noemail') message = 'Please enter an email id in work order Contact.'; else if(str == '0') message = 'Invoice PDF is emailed successfully.' ; else if(str == 'sernotok') message = 'Sending invoice PDF failed.'; return message; }
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" controller="SampleEmailInvoiceSALightCTRL">
<aura:attribute name="sample" type="String" />
<aura:handler name="init" value="{!this}" action="{!c.onload}"/>
<aura:attribute name="isOpen" type="boolean" default="false"/>
<div class="slds-m-around--medium">
<button class="slds-button slds-button--brand" onclick="{!c.openModel}">Email Invoice</button>
<aura:if isTrue="{!v.isOpen}">
<!--###### MODAL BOX Start From Here ######-->
<div role="dialog" tabindex="-1" aria-labelledby="header99" class="slds-modal slds-slide-up-open slds-modal_large" style="width:100%;">
<div class="slds-modal__container">
<!-- ###### MODAL BOX HEADER Part Start From Here ######-->
<div class="slds-modal__header">
</div>
<!--###### MODAL BOX BODY Part Start From Here ######-->
<div class="slds-modal__content slds-p-around--medium">
<div style="background-color:white;padding:10pt;border-radius:5px;">
<b>{!v.sample}</b><br/><br/>
<button class="slds-button slds-button--brand" onclick="{!c.onClickCancelButton}">Click here to go back to service appointment</button>
</div>
</div>
<!--###### MODAL BOX FOOTER Part Start From Here ######-->
<div class="slds-modal__footer">
<button class="slds-button slds-button--neutral" onclick="{!c.closeModel}" >Cancel</button>
</div>
</div>
</div>
<div class="slds-backdrop slds-backdrop--open"></div>
<!--###### MODAL BOX Part END Here ######-->
</aura:if>
</div>
</aura:component>
Controller:
({
onload : function(component, event, helper)
{
var action = component.get("c.messagemtd");
action.setParams({
woid : component.get("v.recordId")
});
action.setCallback(this, function(actionResult) {
var state = actionResult.getState();
if (state === "SUCCESS") {
component.set("v.sample", actionResult.getReturnValue());
}
else {
console.log("Failed with state: " + state);
}
});
$A.enqueueAction(action);
},
onClickCancelButton : function(component, event, helper) {
console.log( 'onClickCancelButton' );
var recordId = component.get( 'v.recordId' );
var event = $A.get( 'e.force:navigateToSObject' );
if ( event ) {
event.setParams({
'recordId' : recordId
}).fire();
component.set("v.isOpen", false);
} else
{
}
},
openModel: function(component, event, helper) {
// for Display Model,set the "isOpen" attribute to "true"
component.set("v.isOpen", true);
},
closeModel: function(component, event, helper) {
// for Hide/Close Model,set the "isOpen" attribute to "Fasle"
component.set("v.isOpen", false);
},
gobackworkorder : function(component, event, helper)
{
var navEvt = $A.get("e.force:navigateToSObject");
navEvt.setParams({
"recordId": component.get("v.recordId"),
"slideDevName": "related"
});
navEvt.fire();
}
})
Message Part
@AuraEnabled
public static string messagemtd(String woid)
{
str= emailestimatePdf(woid);
if(str == 'noe')
message = 'Please select a Contact in work order.';
else if(str == 'noemail')
message = 'Please enter an email id in work order Contact.';
else if(str == '0')
message = 'Invoice PDF is emailed successfully.' ;
else if(str == 'sernotok')
message = 'Sending invoice PDF failed.';
return message;
}