Guest User

Untitled

a guest
Jun 21st, 2018
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.31 KB | None | 0 0
  1. public class contact_list_controller {
  2.  
  3. public String user_contact_EmailID ='[email protected]';
  4. public List<Contact> contacts { get; set; }
  5. public List<Case> cases{get;set;}
  6. public Case detailsCase{get;set;}
  7. public Contact contact_case {get; set;}
  8. public Case newcases {get; set;}
  9. public Case CommentCase{get;set;}
  10. public CaseComment case_comment {get; set;}
  11. public boolean displayPopup {get; set;}
  12. public boolean case_comment_popup {get; set;}
  13. public String Case_ID;
  14.  
  15. public contact_list_controller()
  16. {
  17. contact_case = new Contact();
  18. newcases = new Case();
  19. detailscase = new Case();
  20. case_comment = new CaseComment();
  21. try{
  22. contacts=[Select ID,name,phone,mobilephone,fax,email,birthdate,mailingcity,mailingstate,mailingcountry,homephone from contact where email = :user_contact_EmailID];
  23. cases=[Select casenumber ,Description,isclosed, isdeleted,priority,status,subject,type,reason,origin,CreatedDate from Case where case.contactid IN (Select ID from contact where email = :user_contact_EmailID) ORDER BY casenumber DESC limit 10];
  24. }
  25. catch (Exception ex) {
  26. System.debug(LoggingLevel.Error, 'contact_list_controller.save() Exception: ' + ex);
  27. }
  28. }
  29. //Function which save's the new case
  30. public void Save() {
  31. try{
  32. contact_case = [select Id from contact where email =:user_contact_EmailID];
  33. newcases.contactid = contact_case.Id;
  34. insert newcases;
  35. displayPopup = false;
  36. }
  37. catch (Exception ex) {
  38. System.debug(LoggingLevel.Error, 'contact_list_controller.save() Exception: ' + ex);
  39. }
  40. finally{
  41. newcases = new Case();
  42. }
  43. }
  44. // function to close the popup
  45. public void ClosePopup(){
  46. displayPopup=false;
  47. }
  48. //function to close casecomment
  49. public void Casecomment_close(){
  50. case_comment_popup = false;
  51. }
  52.  
  53. // function to show the popup
  54. public void showPopup() {
  55. displayPopup = true;
  56. }
  57.  
  58. public void case_detail(){
  59. try{
  60. Case_ID = Apexpages.currentPage().getParameters().get('myParam');
  61. detailscase=[select casenumber,Description,isclosed, isdeleted,priority,status,subject,type,reason,origin,CreatedDate from case where casenumber= :Case_ID];
  62. displayPopup = true;
  63. }
  64. catch (Exception ex) {
  65. System.debug(LoggingLevel.Error, 'contact_list_controller.save() Exception: ' + ex);
  66. }
  67. }
  68. public void casecomment(){
  69. case_comment_popup = true;
  70. }
  71. public void save_casecomment(){
  72. try{
  73. CommentCase = [Select ID,priority,origin,type,status,reason,subject,Description,isclosed from Case where casenumber= :Case_ID];
  74. if(CommentCase.ID!= null){
  75. case_comment.parentid = CommentCase.Id;
  76. insert case_comment;
  77. case_comment_popup = false;
  78. }
  79. }
  80. catch (Exception ex) {
  81. System.debug(LoggingLevel.Error, 'contact_list_controller.save() Exception: ' + ex);
  82. }
  83. finally{
  84. case_comment = new CaseComment();
  85. }
  86. }
  87. }
  88.  
  89. <apex:page showheader="false">
  90. <style>
  91. <!-- CSS for displaying detail and chat side by side -->
  92. #wr {margin: 0 auto;}
  93. #leftdetail, #rightchat { border: 1px solid white;float: left;min-height: 450px;color: white;margin-left:2%;}
  94. #leftdetail {margin-left:2%;min-width:70%;max-width:70%}
  95. #rightchat {width:25%;margin-right:2%}
  96. </style>
  97. <style type="text/css">
  98. .custPopup{
  99. background-color: white;
  100. border-width: 2px;
  101. border-style: solid;
  102. z-index: 9999;
  103. left: 50%;
  104. padding:10px;
  105. position: absolute;
  106. /* These are the 3 css properties you will need to change so the popup
  107. displays in the center of the screen. First set the width. Then set
  108. margin-left to negative half of what the width is. You can add
  109. the height property for a fixed size pop up if you want.*/
  110. width: 600px;
  111. margin-left: -250px;
  112. top:100px;
  113. }
  114. .popupBackground{
  115. background-color:black;
  116. opacity: 0.20;
  117. filter: alpha(opacity = 20);
  118. position: absolute;
  119. width: 100%;
  120. height: 100%;
  121. top: 0;
  122. left: 0;
  123. z-index: 9998;
  124. }
  125.  
  126. </style>
  127.  
  128. <div id="wr">
  129. <div id="leftdetail">
  130. <!--Tab Panel -->
  131. <c:Tabpanel >
  132. <!--Contact Tab for getting the Contact details-->
  133. <c:Tab title="Contact">
  134. <apex:pageBlock title="Contact Detail">
  135. <apex:repeat value="{!contacts}" var="contact">
  136. <table cellpadding="15">
  137. <tr>
  138. <td><apex:outputText value="Contact Name : {!contact.Name}"/> </td>
  139. </tr>
  140. <tr>
  141. <td><apex:outputText value="Phone : {!contact.phone}"/></td>
  142. <td><apex:outputText value="Email : {!contact.email}"/></td>
  143. <td><apex:outputText value="Fax : {!contact.Fax}"/> </td>
  144. </tr>
  145. <tr>
  146. <td><apex:outputText value="Mobile : {!contact.Mobilephone}"/></td>
  147. <td><apex:outputText value="Home Phone :{!contact.Homephone}"/></td>
  148. <td><apex:outputText value="Birthdate : {!contact.Birthdate}"/></td>
  149. </tr>
  150. <tr>
  151. <td><apex:outputText value="City : {!contact.MailingCity}"/></td>
  152. <td><apex:outputText value="State : {!contact.MailingState}"/></td>
  153. <td><apex:outputText value="Country : {!contact.MailingCountry}"/></td>
  154. </tr>
  155. </table>
  156. </apex:repeat>
  157. </apex:pageBlock>
  158. </c:Tab>
  159. <!--Case tab which contain the case details for the respective contact -->
  160. <c:Tab title="Cases">
  161. <apex:form >
  162. <apex:pageBlock title="Case Info">
  163. <!-- Adding New case for the respective contact-->
  164. <apex:commandButton value="New Case" action="{!showPopup}" rerender="tstpopup"/>
  165. <apex:outputPanel id="tstpopup">
  166. <apex:outputPanel styleClass="popupBackground" layout="block" rendered="{!displayPopUp}"/>
  167. <apex:outputPanel styleClass="custPopup" layout="block" rendered="{!displayPopUp}">
  168. <apex:pageBlock title="New Case">
  169. <apex:repeat value="{!contacts}" var="contact">
  170. <table cellpadding="15">
  171. <tr>
  172. <td><apex:outputText value="Contact Name : {!contact.Name}"/> </td>
  173. </tr>
  174. </table>
  175. </apex:repeat>
  176. <apex:pageBlockSection >
  177. <apex:inputField value="{!newcases.Priority}" />
  178. <apex:inputField value="{!newcases.Origin}" />
  179. <apex:inputField value="{!newcases.Type}" />
  180. <apex:inputField value="{!newcases.Status}" />
  181. <apex:inputField value="{!newcases.reason}" />
  182. <apex:inputField value="{!newcases.subject}" />
  183. </apex:PageBlockSection>
  184. <apex:PageBlockSection >
  185. <apex:inputField value="{!newcases.Description}" style="width:450px"/>
  186. </apex:pageBlockSection>
  187. </apex:pageBlock>
  188. <apex:commandButton value="Cancel" action="{!closePopup}" rerender="tstpopup"/>
  189. <!--saving the New case Detail -->
  190. <apex:CommandButton value="Save" action="{!Save}" rerender="tstpopup"/>
  191. </apex:outputPanel>
  192. </apex:outputPanel>
  193. <!-- to display the list of cases for the respective contact-->
  194. <apex:pageBlockTable value="{!cases}" var="case">
  195. <apex:column headerValue="Case Number">
  196. <!-- onclick CaseID it will display the respective case detail-->
  197. <apex:commandLink action="{!case_detail}" rerender="case_detai"> {!case.casenumber}
  198. <apex:param name="myParam" value="{!case.casenumber}"/>
  199. </apex:commandLink>
  200. <apex:outputPanel id="case_detai">
  201. <apex:outputPanel styleClass="popupBackground" layout="block" rendered="{!displayPopUp}"/>
  202. <apex:outputPanel styleClass="custPopup" layout="block" rendered="{!displayPopUp}">
  203. <apex:PageBlock title="Case detail">
  204. <apex:repeat value="{!detailscase}" var="detailscases">
  205. <apex:PageBlock title="Subject:{!detailscases.subject}" >
  206.  
  207. <table cellpadding="20">
  208. <tr>
  209. <td><apex:outputText value="Case ID : {!detailscases.casenumber}"/> </td>
  210. <td><apex:outputText value="Case Status:{!detailscases.status}"/> </td>
  211. <td><apex:outputText value="Priority :{!detailscases.priority}"/> </td>
  212. <td><apex:outputText value="Case Origin :{!detailscases.origin}"/> </td>
  213. </tr>
  214. <tr>
  215. <td><apex:outputText value="Created:{!detailscases.isclosed}"/> </td>
  216. <td><apex:outputText value="Type:{!detailscases.type}"/> </td>
  217. <td><apex:outputText value="Case Reason:{!detailscases.reason}"/></td>
  218. </tr>
  219. <tr>
  220. <td><apex:outputText value="Description: {!detailscases.Description}"/></td>
  221. </tr>
  222. </table>
  223. </apex:PageBlock>
  224. </apex:repeat>
  225. </apex:PageBlock>
  226. <!-- for cancel/close the casedetail popup-->
  227. <apex:commandButton value="Cancel" action="{!closePopup}" immediate="true" rerender="case_detai"/>
  228. <apex:commandButton value="Case Comments" action="{!casecomment}" immediate="true" rerender="case_comment"/>
  229. <apex:outputPanel id="case_comment">
  230. <apex:outputPanel styleClass="popupBackground" layout="block" rendered="{!case_comment_popup}"/>
  231. <apex:outputPanel styleClass="custPopup" layout="block" rendered="{!case_comment_popup}">
  232. <apex:pageBlock title=" Case Comment">
  233. <apex:repeat value="{!detailscase}" var="detailscases">
  234. <table>
  235. <tr>
  236. <td><apex:outputText value="case ID:{!detailscases.casenumber}"/></td>
  237. </tr>
  238. <tr>
  239. <td><apex:inputField value="{!case_comment.commentbody}" style="width:550px"/> </td>
  240. </tr>
  241. </table>
  242. <apex:commandButton value="Cancel" action="{!Casecomment_close}" rerender="case_comment"/>
  243. <apex:commandButton value="Save" action="{!save_casecomment}" rerender="case_comment"/>
  244. <apex:param name="comment_case_number" value="{!detailscases.casenumber}"/>
  245. </apex:repeat>
  246. </apex:pageBlock>
  247. </apex:outputPanel>
  248. </apex:outputPanel>
  249.  
  250. </apex:outputPanel>
  251. </apex:outputPanel>
  252. </apex:column>
  253. <apex:column value="{!case.Subject}"/>
  254. <apex:column value="{!case.type}"/>
  255. <apex:column value="{!case.status}"/>
  256. <apex:column value="{!case.priority}"/>
  257. <apex:column value="{!case.Origin}"/>
  258. <apex:column value="{!case.CreatedDate}"/>
  259. <apex:column value="{!case.isclosed}"/>
  260. <apex:column value="{!case.reason}"/>
  261. </apex:pageBlockTable>
  262. </apex:pageBlock>
  263. </apex:form>
  264. </c:Tab>
  265. <c:Tab title="Device">
  266. <apex:pageBlock title="Device Info">
  267. <apex:repeat value="{!cases}" var="case">
  268. <table cellpadding="10">
  269. </table>
  270. </apex:repeat>
  271. </apex:pageBlock>
  272. </c:Tab>
  273. <c:Tab title="Chat Detail">
  274. <apex:pageBlock title="Chat detail">
  275. </apex:pageBlock>
  276. </c:Tab>
  277. </c:Tabpanel>
  278. </div>
  279. <div id="rightchat">
  280. </div>
  281.  
  282. </div>
  283. </apex:page>
Add Comment
Please, Sign In to add comment