Created
June 26, 2013 01:04
-
-
Save mxalix258/5863899 to your computer and use it in GitHub Desktop.
Replace "New" page with visualforce page with apex extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<apex:page standardController="Leave_Request__c" extensions="vacationdays" showHeader="true" sidebar="true"> | |
<apex:form > | |
<apex:sectionHeader subtitle="New Leave Request" title="Leave Request Edit"/> | |
<apex:pageBlock title="Leave Request Edit" mode="edit" > | |
<apex:pageBlockButtons > | |
<apex:commandButton value="Save" action="{!save}"/> | |
<apex:commandButton value="Cancel" action="{!cancel}"/> | |
</apex:pageBlockButtons> | |
<apex:pageBlockSection title="Information" > | |
<apex:outputField label="Owner" value="{!UserInfo.Name}"/> | |
<apex:inputField value="{!Leave_Request__c.Manager__c}"/> | |
<apex:inputField value="{!Leave_Request__c.Dates_of_Requested_Leave__c}" required="true"/> | |
<apex:inputField value="{!Leave_Request__c.Status__c}" required="true"/> | |
<apex:inputField value="{!Leave_Request__c.Type__c}" required="true"/> | |
<apex:outputField label="Total Vacation Days Allowed" value=" {!UserInfo.Yearly_Vacation_Days__c}"/> | |
<apex:inputField value="{!Leave_Request__c.Total_Days_Off__c}" required="true"/> | |
<apex:outputField label="Remaining Vacation Days" value=" {!UserInfo.Vacation_Days__c}"/> | |
<apex:inputField value="{!Leave_Request__c.Comments__c}"/> | |
</apex:pageBlockSection> | |
</apex:pageBlock> | |
</apex:form> | |
</apex:page> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class vacationdays { | |
Public User CurrentUser {get;set;} | |
public vacationdays(ApexPages.StandardController controller) { | |
} | |
public User getUserInfo(){ | |
String userid = UserInfo.getUserId(); | |
CurrentUser = [SELECT ID, Name, FirstName, LastName, Vacation_Days__c, Yearly_Vacation_Days__c FROM User WHERE Id =:userid]; | |
return CurrentUser; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@isTest | |
private class vacationdaysTEST{ | |
private static testMethod void vacationdaysTEST(){ | |
Leave_Request__c lr = new Leave_Request__c(); | |
ApexPages.StandardController sc = new ApexPages.StandardController(lr); | |
vacationdays controller = new vacationdays(sc); | |
controller.getUserInfo(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment