Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.13 KB | None | 0 0
  1. <apex:form id="form">
  2.  
  3. <apex:pageBlock title="Appointments Tables" id="TableDoctors">
  4. <apex:pageBlock >
  5. <apex:selectList value="{!selectedname}" size="1" multiselect="false" onChange="updateDoctors(this.value)">
  6. <h1>
  7. Select a doctor name:
  8. </h1>
  9. <apex:selectOptions value="{!selectedDocnamefields}"/>
  10. </apex:selectList>
  11. </apex:pageBlock>
  12.  
  13. <apex:pageBlock >
  14. <apex:commandButton action="{!URLFOR("/apex/DoctorCreate")}" value="Add new doctor"/>
  15. </apex:pageBlock>
  16.  
  17. <apex:pageBlock >
  18. <apex:pageBlockSection title="Working hours">
  19. <apex:repeat value="{!Doctors}" var="d" rows="1">
  20. <apex:outputField value="{!d.Doctor__r.Working_Hours_Start__c}"/>
  21. <apex:outputField value="{!d.Doctor__r.Working_Hours_End__c}"/>
  22. </apex:repeat>
  23. </apex:pageBlockSection>
  24. </apex:pageBlock>
  25.  
  26. <apex:pageBlock >
  27. <apex:selectList value="{!selectedPatientname}" size="1" multiselect="false" onChange="updatePatients(this.value)">
  28. <h1>
  29. Select a Patient name:
  30. </h1>
  31. <apex:selectOptions value="{!selectedPatnamefields}" />
  32. </apex:selectList>
  33. </apex:pageBlock>
  34.  
  35. <apex:pageBlock >
  36. <apex:commandButton action="{!URLFOR("/apex/PatientCreate")}" value="Add new patient"/>
  37. </apex:pageBlock>
  38.  
  39. <apex:pageBlock >
  40. <apex:commandButton action="{!URLFOR("/apex/AppointmentCreatePage")}" value="Add new appointment"/>
  41. </apex:pageBlock>
  42.  
  43. <apex:pageBlockTable value="{! doctors }" var="d" columns="5" id="TableDoctors" >
  44.  
  45. <apex:column value="{! d.Doctor__c }" />
  46. <apex:column value="{! d.Doctor__r.Name }"/>
  47. <apex:column value="{! d.Patient__r.Name }"/>
  48. <apex:column value="{! d.Appointment_Date__c }"/>
  49. <apex:column value="{! d.Duration_in_minutes__c }"/>
  50.  
  51. </apex:pageBlockTable>
  52.  
  53. <apex:pageBlockButtons location="bottom">
  54. <apex:commandButton value="Previous" action="{!Previous}" rerender="TableDoctors" />
  55. <apex:commandButton value="Next" action="{!Next}" rerender="TableDoctors"/>
  56. </apex:pageBlockButtons>
  57.  
  58. <apex:actionFunction name="updateDoctors" action="{!getDoctors}" rerender="TableDoctors" immediate="false">
  59. <apex:param name="selectedDoc" assignTo="{!selectedname}" value="" />
  60. </apex:actionFunction>
  61.  
  62. </apex:pageBlock>
  63.  
  64. </apex:form>
  65.  
  66. public List<Appointment__c> Doctors {get;set;}
  67. public string selectedname{
  68.  
  69. get{
  70. if(selectedname == null)
  71. selectedname ='Model API';
  72. return selectedname;
  73. }
  74. set;}
  75.  
  76. // Getting the name of the selected patient
  77.  
  78. Public List<Selectoption> getselectedDocnamefields(){
  79. List<Selectoption> Doctornamesel = new List<selectoption>();
  80. Doctornamesel.add(new selectOption('', '- None -'));
  81. for(Appointment__c Doc :[SELECT Id, Doctor__r.Name, Doctor__r.Working_Hours_Start__c, Doctor__r.Working_Hours_End__c, Patient__r.Name, Appointment_Date__c, Duration_in_minutes__c FROM Appointment__c Where Doctor__r.Name!=Null]){
  82. Doctornamesel.add(new selectoption(Doc.Doctor__r.id, Doc.Doctor__r.Name));
  83. }
  84. return Doctornamesel;
  85. }
  86.  
  87. // List of doctors
  88.  
  89. public void getDoctors() {
  90.  
  91. system.debug('SelectedName is: ' + selectedname);
  92. Doctors = [SELECT Doctor__r.Name, Doctor__r.Working_Hours_Start__c, Doctor__r.Working_Hours_End__c, Patient__r.Name, Appointment_Date__c, Duration_in_minutes__c FROM Appointment__c Where Doctor__c =: selectedname Limit :recordLimit OFFSET :offSetLimit];
  93.  
  94. }
  95.  
  96.  
  97. public List<Appointment__c> Patients {get;set;}
  98. public string selectedPatientname{
  99.  
  100. get{
  101. if(selectedPatientname == null)
  102. selectedPatientname ='Model API';
  103. return selectedPatientname;
  104. }
  105. set;}
  106.  
  107.  
  108. // Getting the name of the selected patient
  109.  
  110. Public List<Selectoption> getselectedPatnamefields(){
  111. List<Selectoption> Patientnamesel = new List<selectoption>();
  112. Patientnamesel.add(new selectOption('', '- None -'));
  113. for(Appointment__c Pat :[SELECT Id, Patient__r.Name FROM Appointment__c Where Doctor__r.Name!=Null]){
  114. Patientnamesel.add(new selectoption(Pat.Patient__r.id, Pat.Patient__r.Name));
  115. }
  116. return Patientnamesel;
  117. }
  118.  
  119.  
  120. // List of patient
  121.  
  122. public void getPatients() {
  123.  
  124. system.debug('selectedPatientname is: ' + selectedPatientname);
  125. Patients = [SELECT Patient__r.Name FROM Appointment__c Where Patient__c =: selectedPatientname ];
  126.  
  127. }
  128.  
  129. //Pagination
  130.  
  131.  
  132. integer recordLimit = 20;
  133. integer offSetLimit = 0;
  134. integer index;
  135.  
  136. //Botton Next
  137.  
  138. public pagereference Next(){
  139. index = Doctors.size() - 1;
  140. if(Doctors.size()>0 && Doctors.size()<index)
  141. system.debug('Doctors'+ Doctors.size());
  142. offSetLimit = offSetLimit + 20;
  143. return null;
  144. }
  145.  
  146. //Botton Previous
  147. public pagereference Previous(){
  148. if(offSetLimit>0)
  149. offSetLimit = offSetLimit - 20;
  150. return null;
  151. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement