Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <apex:form id="form">
- <apex:pageBlock title="Appointments Tables" id="TableDoctors">
- <apex:pageBlock >
- <apex:selectList value="{!selectedname}" size="1" multiselect="false" onChange="updateDoctors(this.value)">
- <h1>
- Select a doctor name:
- </h1>
- <apex:selectOptions value="{!selectedDocnamefields}"/>
- </apex:selectList>
- </apex:pageBlock>
- <apex:pageBlock >
- <apex:commandButton action="{!URLFOR("/apex/DoctorCreate")}" value="Add new doctor"/>
- </apex:pageBlock>
- <apex:pageBlock >
- <apex:pageBlockSection title="Working hours">
- <apex:repeat value="{!Doctors}" var="d" rows="1">
- <apex:outputField value="{!d.Doctor__r.Working_Hours_Start__c}"/>
- <apex:outputField value="{!d.Doctor__r.Working_Hours_End__c}"/>
- </apex:repeat>
- </apex:pageBlockSection>
- </apex:pageBlock>
- <apex:pageBlock >
- <apex:selectList value="{!selectedPatientname}" size="1" multiselect="false" onChange="updatePatients(this.value)">
- <h1>
- Select a Patient name:
- </h1>
- <apex:selectOptions value="{!selectedPatnamefields}" />
- </apex:selectList>
- </apex:pageBlock>
- <apex:pageBlock >
- <apex:commandButton action="{!URLFOR("/apex/PatientCreate")}" value="Add new patient"/>
- </apex:pageBlock>
- <apex:pageBlock >
- <apex:commandButton action="{!URLFOR("/apex/AppointmentCreatePage")}" value="Add new appointment"/>
- </apex:pageBlock>
- <apex:pageBlockTable value="{! doctors }" var="d" columns="5" id="TableDoctors" >
- <apex:column value="{! d.Doctor__c }" />
- <apex:column value="{! d.Doctor__r.Name }"/>
- <apex:column value="{! d.Patient__r.Name }"/>
- <apex:column value="{! d.Appointment_Date__c }"/>
- <apex:column value="{! d.Duration_in_minutes__c }"/>
- </apex:pageBlockTable>
- <apex:pageBlockButtons location="bottom">
- <apex:commandButton value="Previous" action="{!Previous}" rerender="TableDoctors" />
- <apex:commandButton value="Next" action="{!Next}" rerender="TableDoctors"/>
- </apex:pageBlockButtons>
- <apex:actionFunction name="updateDoctors" action="{!getDoctors}" rerender="TableDoctors" immediate="false">
- <apex:param name="selectedDoc" assignTo="{!selectedname}" value="" />
- </apex:actionFunction>
- </apex:pageBlock>
- </apex:form>
- public List<Appointment__c> Doctors {get;set;}
- public string selectedname{
- get{
- if(selectedname == null)
- selectedname ='Model API';
- return selectedname;
- }
- set;}
- // Getting the name of the selected patient
- Public List<Selectoption> getselectedDocnamefields(){
- List<Selectoption> Doctornamesel = new List<selectoption>();
- Doctornamesel.add(new selectOption('', '- None -'));
- 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]){
- Doctornamesel.add(new selectoption(Doc.Doctor__r.id, Doc.Doctor__r.Name));
- }
- return Doctornamesel;
- }
- // List of doctors
- public void getDoctors() {
- system.debug('SelectedName is: ' + selectedname);
- 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];
- }
- public List<Appointment__c> Patients {get;set;}
- public string selectedPatientname{
- get{
- if(selectedPatientname == null)
- selectedPatientname ='Model API';
- return selectedPatientname;
- }
- set;}
- // Getting the name of the selected patient
- Public List<Selectoption> getselectedPatnamefields(){
- List<Selectoption> Patientnamesel = new List<selectoption>();
- Patientnamesel.add(new selectOption('', '- None -'));
- for(Appointment__c Pat :[SELECT Id, Patient__r.Name FROM Appointment__c Where Doctor__r.Name!=Null]){
- Patientnamesel.add(new selectoption(Pat.Patient__r.id, Pat.Patient__r.Name));
- }
- return Patientnamesel;
- }
- // List of patient
- public void getPatients() {
- system.debug('selectedPatientname is: ' + selectedPatientname);
- Patients = [SELECT Patient__r.Name FROM Appointment__c Where Patient__c =: selectedPatientname ];
- }
- //Pagination
- integer recordLimit = 20;
- integer offSetLimit = 0;
- integer index;
- //Botton Next
- public pagereference Next(){
- index = Doctors.size() - 1;
- if(Doctors.size()>0 && Doctors.size()<index)
- system.debug('Doctors'+ Doctors.size());
- offSetLimit = offSetLimit + 20;
- return null;
- }
- //Botton Previous
- public pagereference Previous(){
- if(offSetLimit>0)
- offSetLimit = offSetLimit - 20;
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement