apex:page
controller="custFeedback" cache="false"
sidebar="false" showheader="false">
<Table border="0">
<TR>
<TD><apex:image
value="{!URLFOR($Resource.LOGO2)}"/></TD>
<TD style="padding: 5px;border: none; font-size: 25px; color:
#532380;">Customer Feedback Survey</TD>
</TR>
</Table>
<apex:pageBlock >
<apex:form >
<apex:outputPanel rendered="{!conSet}">
<h1>Welcome {!conName}. Thanks for taking time for this
Feedback.</h1>
<p/>
</apex:outputPanel>
<apex:outputPanel rendered="{!feedbackReceived}">
<h1>Dear Sir/Madam we allready have your Feedback.</h1>
<p/>
</apex:outputPanel>
<apex:pageBlock rendered="{!feedbackNotReceived}">
<p/>
</apex:pageBlock>
<apex:pageBlock rendered="{!feedbackNotReceived}">
<h1>Service Quality:</h1>
<p/>
<apex:selectRadio value="{!strSC}" >
<apex:selectOptions value="{!feedbackOptions}"/>
</apex:selectRadio>
</apex:pageBlock>
<apex:pageBlock rendered="{!feedbackNotReceived}">
<h1>Quantity of device of callcentre agent:</h1>
<p/>
<apex:selectRadio value="{!strQC}" >
<apex:selectOptions value="{!feedbackOptions}"/>
</apex:selectRadio>
</apex:pageBlock>
<apex:pageBlock rendered="{!feedbackNotReceived}">
<h1>Time taken for replacement:</h1>
<p/>
<apex:selectRadio value="{!strTC}" >
<apex:selectOptions value="{!feedbackOptions}"/>
</apex:selectRadio>
</apex:pageBlock>
<apex:pageBlock rendered="{!feedbackNotReceived}">
<h1>Resellers Service:</h1>
<p/>
<apex:selectRadio value="{!strRC}" >
<apex:selectOptions value="{!feedbackOptions}"/>
</apex:selectRadio>
</apex:pageBlock>
<apex:pageBlock rendered="{!feedbackNotReceived}">
<h1>Satisfaction level with Refund/Replaceme:</h1>
<p/>
<apex:selectRadio value="{!strSLC}" >
<apex:selectOptions value="{!feedbackOptions}"/>
</apex:selectRadio>
</apex:pageBlock>
<apex:pageBlock rendered="{!feedbackNotReceived}">
<h1>How Can We Serve You Better:</h1>
<p/>
<apex:inputTextArea cols="100" rows="5" value="{!strSuggestion}"/>
</apex:pageBlock>
<apex:commandButton value="Submit Survey"
action="{!submitSurvey}" rerender="out"
status="status" rendered="{!feedbackNotReceived}"/>
</apex:form>
</apex:pageBlock>
<apex:outputPanel id="out">
<apex:actionstatus id="status"
startText="Submitting..." />
<h1>{!welcomeNote}</h1>
</apex:outputPanel>
</apex:page>
===================================================================
public class custFeedback {
public String strRC { get; set; }
public String strTC { get; set; }
public String strQC { get; set; }
public custFeedback() {
conId = Apexpages.currentPage().getParameters().get('id');
bookingId= Apexpages.currentPage().getParameters().get('bid');
list<Opportunity> bk = [select
id,Service_Quality_c__c,Feedback_Received__c,Customer_Suggestions_c__c from
Opportunity where id=:bookingId];
if(bk.size() > 0){
feedbackReceived = bk[0].Feedback_Received__c;
feedbackNotReceived = !bk[0].Feedback_Received__c;
}
else{
feedbackReceived = false;
feedbackNotReceived = true;
}
if(conId == null){
conId = 'none';
}
if (conId != 'none'){
list<contact> lstcon = [select
lastname, firstname from contact where id = :conId];
if(lstcon.size() > 0)
conName = lstcon[0].firstname + ' ' + lstcon[0].lastname;
else
conName = 'none';
if(conName != 'none' && conName != null &&
conName.length() > 0)
conSet = true;
else
conSet = false;
}
}
public String strSC { get; set; }
public String strSLC { get; set; }
public String strSuggestion { get; set; }
public String conId { get; set; }
public String bookingId { get; set; }
public String conName { get; set; }
public String welcomeNote { get; set; }
public boolean conSet { get; set; }
public boolean feedbackReceived { get; set; }
public boolean feedbackNotReceived { get; set; }
public PageReference submitSurvey() {
welcomeNote = 'Thanks for Participating in this Survey. Have a Great
Day';
list<Opportunity> bk = [select
id,Overall_Rating_Out_of_5__c,Customer_Not_Happy__c,Service_Quality_c__c,Feedback_Received__c,Customer_Suggestions_c__c
from Opportunity where id=:bookingId];
if(bk.size() > 0){
if(strSC != null)
bk[0].Service_Quality_c__c = strSC;
else
bk[0].Service_Quality_c__c = '3';
if(strTC != null)
bk[0].Time_taken_for_replacement__c = strTC;
else
bk[0].Time_taken_for_replacement__c = '3';
if(strRC != null)
bk[0].Resellers_Service__c = strRC;
else
bk[0].Resellers_Service__c = '3';
if(strQC != null)
bk[0].Quantity_of_device_of_callcentre_agent__c = strQC;
else
bk[0].Quantity_of_device_of_callcentre_agent__c = '3';
if(strSLC != null)
bk[0].Satisfaction_level_with_Refund_Replaceme__c= strSLC;
else
bk[0].Satisfaction_level_with_Refund_Replaceme__c= '3';
bk[0].Feedback_Received__c = true;
bk[0]. Customer_Suggestions_c__c = strSuggestion;
double dblTF =
double.valueof(bk[0].Service_Quality_c__c)+double.valueof(bk[0].Quantity_of_device_of_callcentre_agent__c)/2;
if(dblTF < 3)
bk[0].Customer_Not_Happy__c = true;
else
bk[0].Customer_Not_Happy__c = false;
bk[0].Overall_Rating_Out_of_5__c =
dblTF;
//Task tk = new Task();
update(bk);
//insert(tk);
}
return null;
}
public custFeedback(ApexPages.StandardController stdController) {
}
public List<SelectOption> getFeedbackOptions() {
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('5','Excellent'));
options.add(new SelectOption('4','Good'));
options.add(new SelectOption('3','Fair'));
options.add(new SelectOption('2','Average'));
options.add(new SelectOption('1','Poor'));
return options;
}
}
==================================================================================================
Trigger..
trigger sendFeedback on Opportunity (before
update) {
for(Opportunity b : trigger.new){
if(b.Interested_In_Feedback__c == true && b.Feedback_Received__c
== false && b.Shipment_Status__c == 'Delivered'){
Messaging.SingleEmailMessage mail = new
Messaging.SingleEmailMessage();
Contact recipient = [SELECT id,firstname from Contact where
id=:b.Customer__c];
//EmailTemplate et = [SELECT id FROM EmailTemplate WHERE developerName =
'CustomerFeedbackRequest'];
mail.setSenderDisplayName('FeedBack System');
mail.setTargetObjectId(recipient.id);
//mail.setTemplateId(et.id);
mail.setSubject('Feedback Request');
//mail.setPlainTextBody('Dear' +recipient.FirstName + ' Sir or Madam');
mail.setHtmlBody('Dear ' +recipient.FirstName +
'<p>Thank you for
your interest in providing your valueable Feedback <p> Please click the
link below <p>'+
'<a
href=http://rz-developer-edition.ap1.force.com/CustomerFeedback?id='+b.Customer__c+'&bid='+b.Id+'>FeedBack
Request Link</a>'+
'<p> Thanks And Regards
<p> Feedback Team');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
}
}
}
No comments:
Post a Comment