Guest User

Untitled

a guest
Oct 21st, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.22 KB | None | 0 0
  1. /**
  2. * Account Budgeting controller.
  3. *
  4. * @version Jun 29 2011
  5. */
  6. public with sharing class AccountBudget {
  7.  
  8. /* String value for the SalesCentre. */
  9. String SalesCentre;
  10.  
  11. /* String value for the Account. */
  12. public String Account;
  13.  
  14. /* String value for the Year. */
  15. String Year;
  16.  
  17. /* String value for the Product. */
  18. string Product ;
  19.  
  20. /* String value for the Item Class. */
  21. string ItemClass;
  22.  
  23. /* String value for the Item Class Description. */
  24. string ItemClassDescription;
  25.  
  26. /* Getter for the SalesCentre value. */
  27. public String getSalesCentre(){return this.SalesCentre; }
  28.  
  29. /* Setter for the SalesCentre value. */
  30. public void setSalesCentre(String s){this.SalesCentre = s; }
  31.  
  32. /* Getter for the Account value. */
  33. public String getAccount(){return this.Account; }
  34.  
  35. /* Setter for the Account value. */
  36. public void setAccount(String s){this.Account = s;}
  37.  
  38. /* Getter for the Year value. */
  39. public String getYear(){return this.Year; }
  40.  
  41. /* Setter for the Year value. */
  42. public void setYear(String s){this.Year = s; }
  43.  
  44. /* Setter for the Item Class value. */
  45. public void setItemClass (String itemCl) {this.ItemClass = itemCl;}
  46.  
  47. /* Getter for the Item Class value. */
  48. public String getItemClass() {return this.ItemClass;}
  49.  
  50. /* Setter for the Item Class Description value. */
  51. public void setItemClassDescription (String itemClDesc) {this.ItemClassDescription = itemClDesc;}
  52.  
  53. /* Getter for the Item Class Description value. */
  54. public String getItemClassDescription() {return this.ItemClassDescription;}
  55.  
  56. /* Mounts Headings. */
  57. public List <Heading> Headings {public get; private set;}
  58.  
  59. public String novVal;
  60.  
  61. public list<Account_Budgeting_2__c> acclistRO {get
  62. {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
  63. FROM Account_Budgeting_2__c where Year__c =:Year and Account__c =:Account and Budget_Type__c <>'Current Budget']);
  64. return acclistRO ;} set;}
  65.  
  66. public list<Account_Budgeting_2__c> acclistE {get
  67. {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
  68. FROM Account_Budgeting_2__c where Year__c =:Year and Account__c =:Account and Budget_Type__c like '%Current%' ]);
  69. return acclistE ;} set;}
  70.  
  71. /* Getter which dynamically generates the categories from the Account_SalesCentre__c object. */
  72. public List<SelectOption> getSalesCentres() {
  73. List<SelectOption> optionList = new List<SelectOption>();
  74.  
  75. /* Add a null option to force the user to make a selection. */
  76. optionList.add(new SelectOption('', '- None -'));
  77.  
  78. /* Loop through the SalesCentre records creating a selectOption. */
  79. for (Account fc: [select name from Account where account.recordtype.name like '%Sales%Centre%' order by Name]){
  80. optionList.add(new SelectOption(fc.id,fc.name));
  81. }
  82. return optionList;
  83. }
  84.  
  85. /* Getter which generates the options for the Accounts selectList based on the current
  86. value of the selected SalesCentre. If there is no value selected then only
  87. the null option should be returned. */
  88. public List<SelectOption> getAccounts() {
  89. List<SelectOption> optionList = new List<SelectOption>();
  90.  
  91. /* If a SalesCentre has been selected then query for the related values. */
  92. if(SalesCentre!= NULL) {
  93. /* Loop over the related Account records for the given SalesCentre creating a selectOption */
  94. for (Account acc: [select name from Account acc where acc.Sales_centre__c =:SalesCentre]){
  95. optionList.add(new SelectOption(acc.id, acc.name));
  96. }
  97. }
  98. return optionList;
  99. }
  100.  
  101. /*Creates the list of years. */
  102. public List<SelectOption> getYears() {
  103. List<SelectOption> optionList = new List<SelectOption>();
  104. //TODO! Next year
  105. AggregateResult[] yaersAggr = [SELECT Year__c FROM Account_Bgdt__c GROUP BY Year__c order by Year__c];
  106. for (AggregateResult year : yaersAggr) {
  107. optionList.add (new SelectOption(String.valueOf(year.get('Year__c')), String.valueOf(year.get('Year__c'))));
  108. }
  109. return optionList;
  110. }
  111.  
  112. /* Getter which dynamically generates the categories from the Account_SalesCentre__c object. */
  113. public List<SelectOption> getItemClasses() {
  114. List<SelectOption> optionList = new List<SelectOption>();
  115.  
  116. /* Add a null option to force the user to make a selection. */
  117. optionList.add(new SelectOption('', '- None -'));
  118.  
  119. /* List of the sold products. */
  120. List<Sales_History__c> allSoldProductsList = new List<Sales_History__c>([select id, name, Item_Class__c, Item_Class_Description__c
  121. from Sales_History__c prod where Account__c= :Account]);
  122.  
  123. system.debug ('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX! SalesCentreName= :' +allSoldProductsList);
  124.  
  125. for (Sales_History__c prod: allSoldProductsList){
  126. optionList.add(new SelectOption(prod.Id, prod.Item_Class__c));
  127. }
  128.  
  129. return optionList;
  130. }
  131.  
  132. /* Getter which generates the options for the Item Class Description selectList based on the current
  133. value of the selected Item Class. If there is no value selected then only the null option should be returned. */
  134. public List<SelectOption> getItemClassDescriptions() {
  135. List<SelectOption> optionList = new List<SelectOption>();
  136.  
  137. /* If a SalesCentre has been selected then query for the related values. */
  138. if(ItemClass != NULL) {
  139. /* Loop over the related Account records for the given SalesCentre creating a selectOption */
  140. for (Sales_History__c acc: [select id, Item_Class_Description__c from Sales_History__c acc
  141. where acc.Item_Class__c =:ItemClass and acc.Account__c=:Account]){
  142. optionList.add(new SelectOption(acc.id, acc.Item_Class_Description__c));
  143. system.debug ('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX! acc.Item_Class_Description__c= :' +acc.Item_Class_Description__c);
  144. }
  145. }
  146. return optionList;
  147. }
  148.  
  149. /** "Next" action. Redirects to the budgeting page. */
  150. public pageReference FromOne () {
  151. Headings = new Heading [12];
  152. for (integer i = 0; i < 12; i++){
  153. Headings [i] = new Heading (i);
  154. }
  155.  
  156. return page.AccountBudgeting_2;
  157. }
  158.  
  159. /** Adds new product. */
  160. public pageReference addNewProduct() {
  161. return null;
  162. }
  163.  
  164. // Heading details
  165. public class Heading {
  166. public String Month {public get; private set;}
  167. private List <String> MonthNames = new List <String> {'Nov', 'Dec', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct'};
  168.  
  169. /* Constructor. */
  170. public Heading (integer i){
  171. Month= MonthNames[i];
  172. }
  173. }
  174.  
  175. public pageReference save (){
  176. return null;
  177. }
  178. }
Add Comment
Please, Sign In to add comment