SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <apex:sectionHeader Title="Manage {!$ObjectType.Product2.LabelPlural}" subtitle="{!opportunity.Name}"/>
  2. <apex:messages style="color:red"/>
  3.  
  4. <style>
  5.     .search{
  6.         font-size:14pt;
  7.         margin-right: 20px;    
  8.     }
  9.     .fyi{
  10.         color:red;
  11.         font-style:italic;
  12.     }
  13.     .label{
  14.         margin-right:10px;
  15.         font-weight:bold;
  16.     }
  17. </style>
  18.  
  19. <script type='text/javascript'>
  20.  
  21.     // This script assists the search bar functionality
  22.     // It will execute a search only after the user has stopped typing for more than 1 second
  23.     // To raise the time between when the user stops typing and the search, edit the following variable:
  24.  
  25.     var waitTime = 1;
  26.  
  27.  
  28.     var countDown = waitTime+1;
  29.     var started = false;
  30.  
  31.     function resetTimer(){
  32.  
  33.         countDown=waitTime+1;
  34.  
  35.         if(started==false){
  36.             started=true;
  37.             runCountDown();
  38.         }
  39.     }
  40.  
  41.     function runCountDown(){
  42.  
  43.         countDown--;
  44.  
  45.         if(countDown<=0){
  46.             fetchResults();
  47.             started=false;
  48.         }
  49.         else{
  50.             window.setTimeout(runCountDown,1000);
  51.         }
  52.     }
  53.  
  54. </script>
  55.  
  56.  
  57. <apex:form >
  58.  
  59.     <apex:outputPanel id="mainBody">
  60.  
  61.         <apex:outputLabel styleClass="label">PriceBook: </apex:outputLabel>
  62.         <apex:outputText value="{!theBook.Name}"/>&nbsp;
  63.         <!--<apex:commandLink action="{!changePricebook}" value="change" immediate="true"/>-->
  64.         <br/>
  65.         <!-- not everyone is using multi-currency, so this section may or may not show -->
  66.         <apex:outputPanel rendered="{!multipleCurrencies}">
  67.             <apex:outputLabel styleClass="label">Currency: </apex:outputLabel>
  68.             <apex:outputText value="{!chosenCurrency}"/>
  69.             <br/>
  70.         </apex:outputPanel>
  71.         <br/>
  72.      
  73. <!-- notice we use a lot of $ObjectType merge fields... I did that because if you have changed the labels of fields or objects it will reflect your own lingo -->
  74.         <apex:pageBlock title="Selected {!$ObjectType.Product2.LabelPlural}" id="selected">
  75.  
  76.             <apex:pageblockTable value="{!shoppingCart}" var="s">
  77.  
  78.                 <apex:column >
  79.                     <apex:commandLink value="Remove" action="{!removeFromShoppingCart}" reRender="selected,searchResults" immediate="true">
  80.                         <!-- this param is how we send an argument to the controller, so it knows which row we clicked 'remove' on -->
  81.                         <apex:param value="{!s.PriceBookEntryId}" assignTo="{!toUnselect}" name="toUnselect"/>
  82.                     </apex:commandLink>
  83.                 </apex:column>
  84.  
  85.                 <apex:column headerValue="{!$ObjectType.Product2.LabelPlural}" value="{!s.PriceBookEntry.Product2.Name}"/>
  86.  
  87.                 <apex:column headerValue="{!$ObjectType.OpportunityLineItem.Fields.Quantity.Label}">
  88.                     <apex:inputField value="{!s.Quantity}" style="width:70px" required="true" onkeyup="refreshTotals();"/>
  89.                 </apex:column>
  90.  
  91.                 <apex:column headerValue="{!$ObjectType.OpportunityLineItem.Fields.UnitPrice.Label}">
  92.                     <apex:inputField value="{!s.UnitPrice}" style="width:70px" required="true" onkeyup="refreshTotals();"/>
  93.                 </apex:column>
  94.  
  95.                 <apex:column headerValue="{!$ObjectType.OpportunityLineItem.Fields.Description.Label}">
  96.                     <apex:inputField value="{!s.Description}" required="false"/>
  97.                 </apex:column>
  98.  
  99.  
  100.             </apex:pageblockTable>
  101.  
  102.  
  103.             <apex:pageBlockButtons >
  104.                 <apex:commandButton action="{!onSave}" value="Save"/>
  105.                 <apex:commandButton action="{!onCancel}" value="Cancel" immediate="true"/>
  106.             </apex:pageBlockButtons>
  107.  
  108.         </apex:pageBlock>
  109.      
  110. <apex:pageBlock >
  111.  
  112.             <apex:outputPanel styleClass="search">
  113.                 Search for {!$ObjectType.Product2.LabelPlural}:
  114.             </apex:outputPanel>
  115.  
  116.             <apex:actionRegion renderRegionOnly="false" immediate="true">
  117.  
  118.                 <apex:actionFunction name="fetchResults" action="{!updateAvailableList}" reRender="searchResults" status="searchStatus"/>
  119.  
  120.                 <!-- here we invoke the scripting to get out fancy 'no button' search bar to work -->
  121.                 <apex:inputText value="{!searchString}" onkeydown="if(event.keyCode==13){this.blur();}else{resetTimer();}" style="width:300px"/>
  122.                 &nbsp;&nbsp;
  123.                 <i>
  124.                     <!-- actionStatus component makes it easy to let the user know when a search is underway -->
  125.                     <apex:actionStatus id="searchStatus" startText="searching..." stopText=" "/>
  126.                 </i>
  127.  
  128.             </apex:actionRegion>
  129.  
  130.             <br/>
  131.             <br/>
  132.  
  133.             <apex:outputPanel id="searchResults">
  134.  
  135.                 <apex:pageBlockTable value="{!AvailableProducts}" var="a">
  136.  
  137.                     <apex:column headerValue="{!$ObjectType.Product2.Fields.Name.Label}" value="{!a.Product2.Name}" />
  138.  
  139.                     <apex:column headerValue="{!$ObjectType.Product2.Fields.Family.Label}" value="{!a.Product2.Family}"/>
  140.  
  141.                     <apex:column headerValue="{!$ObjectType.Product2.Fields.Description.Label}" value="{!a.Product2.Description}"/>
  142.  
  143.                     <apex:column >
  144.                         <!-- command button in a column... neato -->
  145.                         <apex:commandButton value="Select" action="{!addToShoppingCart}" reRender="selected,searchResults" immediate="true">
  146.                             <!-- again we use apex:param to be able to tell the controller which row we are working with -->
  147.                             <apex:param value="{!a.Id}" assignTo="{!toSelect}" name="toSelect"/>
  148.                         </apex:commandButton>
  149.                     </apex:column>
  150.  
  151.                 </apex:pageBlockTable>
  152.  
  153.                 <!-- We put up a warning if results exceed 100 rows -->
  154.                 <apex:outputPanel styleClass="fyi" rendered="{!overLimit}">
  155.                     <br/>
  156.                     Your search returned over 100 results, use a more specific search string if you do not see the desired {!$ObjectType.Product2.Label}.
  157.                     <br/>
  158.                 </apex:outputPanel>
  159.  
  160.             </apex:outputPanel>
  161.  
  162.         </apex:pageBlock>
  163.  
  164.     </apex:outputPanel>
  165.  
  166. </apex:form>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top