Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Arquivo da página. Nome: ResumoOportunidades
- <apex:page controller="ResumoOportunidade" lightningStylesheets="true">
- <head>
- <style>
- th{
- background-color: lightblue;
- font-weight: bold;
- text-align: center;
- padding: 3px;
- }
- td{
- padding: 3px;
- }
- </style>
- </head>
- <div style="text-align: center;">
- <p style="font-weight: bold; font-size: 14pt;">Opportunity Summary</p>
- <table border="1" style="width: 100%; border: 1px black solid; border-collapse: collapse">
- <tr>
- <th></th>
- <th>Open</th>
- <th>Won</th>
- <th>Lost</th>
- <th>Total</th>
- </tr>
- <tr>
- <td style="font-weight: bold; background-color: lightsalmon"># (%)</td>
- <td>{!openCount} ({!openCountPercent}%)</td>
- <td>{!wonCount} ({!wonCountPercent}%)</td>
- <td><span style="color: red;">{!lostCount} ({!lostCountPercent}%)</span></td>
- <td>{!totalCount} ({!totalCountPercent}%)</td>
- </tr>
- <tr>
- <td style="font-weight: bold; background-color: lightsalmon">$$ (%)</td>
- <td>{!openAmount} ({!openAmountPercent}%)</td>
- <td>{!wonAmount} ({!wonAmountPercent}%)</td>
- <td><span style="color: red;">{!lostAmount} ({!lostAmountPercent}%)</span></td>
- <td>{!totalAmount} ({!totalAmountPercent}%)</td>
- </tr>
- </table>
- </div>
- </apex:page>
- //Arquivo do controller. //ResumoOportunidade
- public with sharing class ResumoOportunidade {
- public static Decimal openCount {get;set;}
- public static Decimal wonCount {get;set;}
- public static Decimal lostCount {get;set;}
- public static Decimal totalCount {get;set;}
- public static Decimal openCountPercent {get;set;}
- public static Decimal wonCountPercent {get;set;}
- public static Decimal lostCountPercent {get;set;}
- public static Decimal totalCountPercent {get;set;}
- public static Decimal openAmount {get;set;}
- public static Decimal wonAmount {get;set;}
- public static Decimal lostAmount {get;set;}
- public static Decimal totalAmount {get;set;}
- public static Decimal openAmountPercent {get;set;}
- public static Decimal wonAmountPercent {get;set;}
- public static Decimal lostAmountPercent {get;set;}
- public static Decimal totalAmountPercent {get;set;}
- public ResumoOportunidade(){
- String aId = ApexPages.currentPage().getParameters().get('id');
- List<Opportunity> openList = [SELECT Id FROM Opportunity WHERE AccountId = :aId AND isClosed=false];
- openCount = openList.size();
- List<Opportunity> wonList = [SELECT Id FROM Opportunity WHERE AccountId = :aId AND isWon = true];
- wonCount = wonList.size();
- List<Opportunity> lostList = [SELECT Id FROM Opportunity WHERE AccountId = :aId AND isClosed = true AND isWon = false];
- lostCount = lostList.size();
- List<Opportunity> totalList = [SELECT Id FROM Opportunity WHERE AccountId = :aId];
- totalCount = totalList.size();
- List<AggregateResult> openListAmount = [SELECT sum(amount) oAmount FROM Opportunity WHERE AccountId = :aId AND isClosed = false];
- openAmount = (Decimal)openListAmount[0].get('oAmount');
- openAmount = openAmount==null?0:openAmount.setScale(2);
- List<AggregateResult> wonListAmount = [SELECT sum(amount) wAmount FROM Opportunity WHERE AccountId = :aId AND isWon = true];
- wonAmount = (Decimal)wonListAmount[0].get('wAmount');
- wonAmount = wonAmount==null?0:wonAmount.setScale(2);
- List<AggregateResult> lostListAmount = [SELECT sum(amount) lAmount FROM Opportunity WHERE AccountId = :aId AND isClosed = true AND isWon = false];
- lostAmount = (Decimal)lostListAmount[0].get('lAmount');
- lostAmount = lostAmount==null?0:lostAmount.setScale(2);
- List<AggregateResult> totalListAmount = [SELECT sum(amount) tAmount FROM Opportunity WHERE AccountId = :aId];
- totalAmount = (Decimal)totalListAmount[0].get('tAmount');
- totalAmount = totalAmount==null?0:totalAmount.setScale(2);
- openAmountPercent = ((openAmount/totalAmount)*100).setScale(2);
- openAmountPercent = totalAmount==0?0:openAmountPercent;
- wonAmountPercent = ((wonAmount/totalAmount)*100).setScale(2);
- wonAmountPercent = totalAmount==0?0:wonAmountPercent;
- lostAmountPercent = ((lostAmount/totalAmount)*100).setScale(2);
- lostAmountPercent = totalAmount==0?0:lostAmountPercent;
- totalAmountPercent = ((totalAmount/totalAmount)*100).setScale(2);
- totalAmountPercent = totalAmount==0?0:totalAmountPercent;
- openCountPercent = ((openCount/totalCount)*100).setScale(2);
- wonCountPercent = ((wonCount/totalCount)*100).setScale(2);
- lostCountPercent = ((lostCount/totalCount)*100).setScale(2);
- totalCountPercent = ((totalCount/totalCount)*100).setScale(2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement