Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Account Budgeting controller.
- *
- * @version Jun 29 2011
- */
- public with sharing class AccountBudget {
- /* String value for the SalesCentre. */
- String SalesCentre;
- /* String value for the Account. */
- public String Account;
- /* String value for the Year. */
- String Year;
- /* String value for the Product. */
- string Product ;
- /* String value for the Item Class. */
- string ItemClass;
- /* String value for the Item Class Description. */
- string ItemClassDescription;
- /* Getter for the SalesCentre value. */
- public String getSalesCentre(){return this.SalesCentre; }
- /* Setter for the SalesCentre value. */
- public void setSalesCentre(String s){this.SalesCentre = s; }
- /* Getter for the Account value. */
- public String getAccount(){return this.Account; }
- /* Setter for the Account value. */
- public void setAccount(String s){this.Account = s;}
- /* Getter for the Year value. */
- public String getYear(){return this.Year; }
- /* Setter for the Year value. */
- public void setYear(String s){this.Year = s; }
- /* Setter for the Item Class value. */
- public void setItemClass (String itemCl) {this.ItemClass = itemCl;}
- /* Getter for the Item Class value. */
- public String getItemClass() {return this.ItemClass;}
- /* Setter for the Item Class Description value. */
- public void setItemClassDescription (String itemClDesc) {this.ItemClassDescription = itemClDesc;}
- /* Getter for the Item Class Description value. */
- public String getItemClassDescription() {return this.ItemClassDescription;}
- /* Mounts Headings. */
- public List <Heading> Headings {public get; private set;}
- public String novVal;
- public list<Account_Budgeting_2__c> acclistRO {get
- {acclistRO = new list<Account_Budgeting_2__c>([SELECT Account__c, Budget_Type__c,Apr__c, Aug__c, Dec__c, Feb__c, Jan__c, Jul__c, Jun__c, Mar__c, May__c, Nov__c, Oct__c, Sep__c, Year__c
- FROM Account_Budgeting_2__c where Year__c =:Year and Account__c =:Account and Budget_Type__c <>'Current Budget']);
- return acclistRO ;} set;}
- public list<Account_Budgeting_2__c> acclistE {get
- {acclistE = new list<Account_Budgeting_2__c>([SELECT Account__c, Budget_Type__c,Apr__c, Aug__c, Dec__c, Feb__c, Jan__c, Jul__c, Jun__c, Mar__c, May__c, Nov__c, Oct__c, Sep__c, Year__c
- FROM Account_Budgeting_2__c where Year__c =:Year and Account__c =:Account and Budget_Type__c like '%Current%' ]);
- return acclistE ;} set;}
- /* Getter which dynamically generates the categories from the Account_SalesCentre__c object. */
- public List<SelectOption> getSalesCentres() {
- List<SelectOption> optionList = new List<SelectOption>();
- /* Add a null option to force the user to make a selection. */
- optionList.add(new SelectOption('', '- None -'));
- /* Loop through the SalesCentre records creating a selectOption. */
- for (Account fc: [select name from Account where account.recordtype.name like '%Sales%Centre%' order by Name]){
- optionList.add(new SelectOption(fc.id,fc.name));
- }
- return optionList;
- }
- /* Getter which generates the options for the Accounts selectList based on the current
- value of the selected SalesCentre. If there is no value selected then only
- the null option should be returned. */
- public List<SelectOption> getAccounts() {
- List<SelectOption> optionList = new List<SelectOption>();
- /* If a SalesCentre has been selected then query for the related values. */
- if(SalesCentre!= NULL) {
- /* Loop over the related Account records for the given SalesCentre creating a selectOption */
- for (Account acc: [select name from Account acc where acc.Sales_centre__c =:SalesCentre]){
- optionList.add(new SelectOption(acc.id, acc.name));
- }
- }
- return optionList;
- }
- /*Creates the list of years. */
- public List<SelectOption> getYears() {
- List<SelectOption> optionList = new List<SelectOption>();
- //TODO! Next year
- AggregateResult[] yaersAggr = [SELECT Year__c FROM Account_Bgdt__c GROUP BY Year__c order by Year__c];
- for (AggregateResult year : yaersAggr) {
- optionList.add (new SelectOption(String.valueOf(year.get('Year__c')), String.valueOf(year.get('Year__c'))));
- }
- return optionList;
- }
- /* Getter which dynamically generates the categories from the Account_SalesCentre__c object. */
- public List<SelectOption> getItemClasses() {
- List<SelectOption> optionList = new List<SelectOption>();
- /* Add a null option to force the user to make a selection. */
- optionList.add(new SelectOption('', '- None -'));
- /* List of the sold products. */
- List<Sales_History__c> allSoldProductsList = new List<Sales_History__c>([select id, name, Item_Class__c, Item_Class_Description__c
- from Sales_History__c prod where Account__c= :Account]);
- system.debug ('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX! SalesCentreName= :' +allSoldProductsList);
- for (Sales_History__c prod: allSoldProductsList){
- optionList.add(new SelectOption(prod.Id, prod.Item_Class__c));
- }
- return optionList;
- }
- /* Getter which generates the options for the Item Class Description selectList based on the current
- value of the selected Item Class. If there is no value selected then only the null option should be returned. */
- public List<SelectOption> getItemClassDescriptions() {
- List<SelectOption> optionList = new List<SelectOption>();
- /* If a SalesCentre has been selected then query for the related values. */
- if(ItemClass != NULL) {
- /* Loop over the related Account records for the given SalesCentre creating a selectOption */
- for (Sales_History__c acc: [select id, Item_Class_Description__c from Sales_History__c acc
- where acc.Item_Class__c =:ItemClass and acc.Account__c=:Account]){
- optionList.add(new SelectOption(acc.id, acc.Item_Class_Description__c));
- system.debug ('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX! acc.Item_Class_Description__c= :' +acc.Item_Class_Description__c);
- }
- }
- return optionList;
- }
- /** "Next" action. Redirects to the budgeting page. */
- public pageReference FromOne () {
- Headings = new Heading [12];
- for (integer i = 0; i < 12; i++){
- Headings [i] = new Heading (i);
- }
- return page.AccountBudgeting_2;
- }
- /** Adds new product. */
- public pageReference addNewProduct() {
- return null;
- }
- // Heading details
- public class Heading {
- public String Month {public get; private set;}
- private List <String> MonthNames = new List <String> {'Nov', 'Dec', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct'};
- /* Constructor. */
- public Heading (integer i){
- Month= MonthNames[i];
- }
- }
- public pageReference save (){
- return null;
- }
- }
Add Comment
Please, Sign In to add comment