/QA - Devry - CRA/src/classes/EnglishProController.cls

https://bitbucket.org/allanoricil/qa-fase-2 · Visual Basic for Applications · 186 lines · 152 code · 34 blank · 0 comment · 18 complexity · a7933a2cb05eb3df079d10fa7efa49c9 MD5 · raw file

  1. public with sharing class EnglishProController{
  2. public string selectedOferta { get; set; }
  3. public string selectedCampus { get; set; }
  4. public string selectedSelectionProcess { get; set; }
  5. public List<SelectOption> options { get; set; }
  6. public List<SelectOption> programsItems { get; set; }
  7. // the soql without the order and limit
  8. private String soql {get;set;}
  9. private Boolean dadosCand {get;set;}
  10. public Opportunity newOpportunity{get;set;}
  11. // the collection of Accounts to display
  12. public List<Account> accounts {get;set;}
  13. public List<opportunity> opp {get;set;}
  14. public EnglishProController(){
  15. newOpportunity = new Opportunity();
  16. getprocessosSeletivos();
  17. getOfertas();
  18. }
  19. /* public Boolean getDadosCand() {
  20. return dadosCand;
  21. }
  22. */
  23. public PageReference runSearch() {
  24. String cpf = Apexpages.currentPage().getParameters().get('cpf');
  25. soql = 'select id, Name,CPF_2__c, Cidade__c, Estado__c, PersonBirthdate, PersonMobilePhone, PersonEmail from account where account.CPF_2__c = \'' + cpf + '\' limit 1';
  26. runQuery();
  27. return null;
  28. }
  29. /*
  30. public PageReference createLad() {
  31. if(String.valueOf(accounts[0].CPF_2__c) != null)
  32. {
  33. insert New Lead(lastname = String.valueOf(accounts[0].name),
  34. IES_de_interesse__c = ' ',
  35. Status = 'Não inscrito',
  36. Phone = String.valueOf(accounts[0].PersonMobilePhone),
  37. Cidade__c = String.valueOf(accounts[0].Cidade__c),
  38. Estado__c = String.valueOf(accounts[0].Estado__c),
  39. CPF__c = String.valueOf(accounts[0].CPF_2__c));
  40. }
  41. return null;
  42. }
  43. */
  44. public PageReference limparForm() {
  45. PageReference newpage = new PageReference(System.currentPageReference().getURL());
  46. newpage.setRedirect(true);
  47. return newpage;
  48. }
  49. public void getprocessosSeletivos(){
  50. options = new List<SelectOption>();
  51. options.add(new SelectOption('','Selecionar uma Opção'));
  52. String selectedCampus = apexpages.currentpage().getparameters().get('parmSelectedCampus');
  53. List<Processo_seletivo__c> lstProcess = [SELECT p.Id,p.Institui_o_n__c,p.name, p.Campus__c,
  54. p.Periodo_Letivo__c,p.Data_de_encerramento__c, Nome_do_Campus__c
  55. FROM Processo_seletivo__c p
  56. WHERE p.Institui_o_n__c = :selectedCampus and
  57. p.Periodo_Letivo__c != null and
  58. p.Formul_rio_Salesforce__c = true and
  59. p.Ativo__c = true and
  60. p.Inscri_o__c = true and
  61. p.Data_de_encerramento__c >= :system.today() and
  62. p.Name like '%english%'
  63. ORDER BY p.Campus__c ASC];
  64. for (Processo_seletivo__c proc : lstProcess) {
  65. String nome = proc.Name;
  66. String campus = proc.Nome_do_Campus__c;
  67. String institution = proc.Institui_o_n__c;
  68. String session = proc.Data_de_encerramento__c.format();
  69. options.add(new SelectOption(proc.Id,nome+' - '+ campus));
  70. }
  71. }
  72. public List<SelectOption> getCampus(){
  73. List<SelectOption> Campus = new List<SelectOption>();
  74. Campus.add(new SelectOption('','Selecionar uma Opção'));
  75. List<Institui_o__c> lstCampus = [SELECT c.Id,c.Name
  76. FROM Institui_o__c c
  77. ORDER BY c.Name ASC];
  78. for (Institui_o__c ies : lstCampus) {
  79. String nome = ies.Name;
  80. Campus.add(new SelectOption(ies.id,nome));
  81. }
  82. return Campus;
  83. }
  84. public void getOfertas(){
  85. programsItems = new List<SelectOption>();
  86. programsItems.add(new SelectOption('','Selecionar uma Opção'));
  87. String selectedProcess = apexpages.currentpage().getparameters().get('parmSelectedProcessoSeletivo');
  88. if(selectedProcess != null && selectedProcess != ''){
  89. List<Oferta__c> lstOffers = [Select o.Id, o.Name From Oferta__c o where o.Processo_seletivo__c = :selectedProcess and Formul_rio_Salesforce__c = true];
  90. for(Oferta__c o : lstOffers){
  91. programsItems.add(new SelectOption(o.Id, o.Name));
  92. }
  93. }
  94. }
  95. public Pagereference OnchangeCampus(){
  96. getprocessosSeletivos();
  97. return null;
  98. }
  99. public Pagereference OnchangeSelectionProcess(){
  100. getOfertas();
  101. return null;
  102. }
  103. public PageReference OnchangeOferta() {
  104. return null;
  105. }
  106. public PageReference salvar() {
  107. try{
  108. // newOpportunity.Processo_seletivo__c = 'a06K0000004IzQp';
  109. // newOpportunity.oferta__c = 'a0LK0000003e0Bt';
  110. if(selectedSelectionProcess != null && selectedSelectionProcess != '')
  111. {
  112. newOpportunity.Processo_seletivo__c = selectedSelectionProcess;
  113. }
  114. if(selectedOferta != null && selectedOferta != '')
  115. {
  116. newOpportunity.oferta__c = selectedOferta;
  117. newOpportunity.Name = 'opp_Name';
  118. newOpportunity.StageName = 'Inscrito';
  119. newOpportunity.CloseDate = date.today();
  120. }
  121. insert newOpportunity;
  122. Integer counter = [ Select count() from opportunity Where Processo_seletivo__c = :selectedSelectionProcess And oferta__c = :selectedOferta];
  123. Integer counter2 = [ Select count() from opportunity Where Processo_seletivo__c = :selectedSelectionProcess];
  124. // String Oppname = [ Select Nome_do_Candidato__c from opportunity Where id = newOpportunity.id];
  125. ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM, 'Dados Salvos com Sucesso!'));
  126. //ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM, 'Seu número de inscrição é ' + counter2 + '.' ));
  127. ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM, 'Parabéns! Você é o ' + counter + '° inscrito para esse curso.'));
  128. newOpportunity.Posi_o_de_Inscri_o_Curso__c = String.valueOf(counter);
  129. // newOpportunity.Name = Oppname;
  130. upsert newOpportunity;
  131. newOpportunity = new Opportunity();
  132. getCampus();
  133. getprocessosSeletivos();
  134. getOfertas();
  135. } catch (Exception ex) {
  136. ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, ex.getMessage()));
  137. }
  138. return null;
  139. }
  140. public void runQuery() {
  141. try {
  142. opp = Database.query(soql);
  143. } catch (Exception e) {
  144. soql = '1';
  145. ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Dados Não Encontrados'));
  146. }
  147. }
  148. public String debugSoql {
  149. get { return soql;}
  150. set;
  151. }
  152. }