Can any one help me on this .I have created a custom visual force page on "Opportunity "object .I have conditions where i need to change the field label name and its value Based on Condition in a Visual Force page in PDF Format.Can we do this .Any Suggestion Plz.
If the product line for the product selected in opportunity items is ‘DIE’ make following changes .
unit price should change to $.01
in the item field replace with bin item code.
The Unit price value works fine.Now can we change the field name and its value in vf page.
PFA Screen Shot :
Visual Force Page :
<table >
<tr>
<td class="header-table-heading">LN</td>
<td class="header-table-heading">Item</td>
<!--<td class="header-table-heading">BinItemCode</td>-->
<td class="header-table-heading">Customer Item #<b/></td>
<td class="header-table-heading">COO</td>
<td class="header-table-heading">ECCN #</td>
<td class="header-table-heading">UOM</td>
<td class="header-table-heading">Unit Price</td>
<td class="header-table-heading">Quantity</td>
<td class="header-table-heading">Extension</td>
</tr>
<tr>
<td class="header-table-heading"></td>
<td colspan="9" style="text-align:left" class="header-table-heading">Description</td>
</tr>
<apex:repeat value="{!appointmentList}" var="line">
<apex:outputPanel layout="none" rendered="{!if(line.pick==true, true, false)}">
<tr>
<td class="header-table-data"><apex:outputText value="{!line.LineNumber}"></apex:outputText></td>
<td class="header-table-data"><apex:outputText value="{!line.productname}"></apex:outputText></td>
<!--<td class="header-table-data"><apex:outputText value="{!line.BinItemCode}"></apex:outputText></td>-->
<td class="header-table-data"></td>
<td class="header-table-data"></td>
<td class="header-table-data">8541.40.2000</td>
<td class="header-table-data">EA</td>
<!-- <td class="header-table-data">$1</td>-->
<td class="header-table-data"><apex:outputtext value="{!line.unitprice}"></apex:outputtext></td>
<td class="header-table-data"><apex:outputtext value="{!line.quantity}"></apex:outputtext></td>
<td class="header-table-data"><apex:outputText value="{!line.extension}"></apex:outputText></td>
</tr>
</table>
Apex Class :
public with sharing class InvoiceController {
List<wrapperClass> appointmentList {get;set;}
List<wrapperClass> appointmentList1 {get;set;}
public list<string> addaress{get;set;}
public string address1{get;set;}
public string address2{get;set;}
public string address3{get;set;}
public string address4{get;set;}
public string address5{get;set;}
public string address6{get;set;}
public string address7{get;set;}
public String showaddressonVf{get;set;}
public string wholeaddress{get;set;}
//Added by sumit
List<String> stringList ;
public String all{get;set;}
//------------
public InvoiceController(){
list<opportunity> op=[select id,Shipment_Info__c
from opportunity where id=:apexpages.currentpage().getparameters().get('id')];
//opportunity op=[select id,Shipment_Info__c from opportunity where id=:apexpages.currentpage().getparameters().get('id')];
//---------------------Added by sumit----------------------
stringList= new List<String>();
if(op.size()>0)
if(op[0].Shipment_Info__c!=NULL && op[0].Shipment_Info__c!=''){
List<String> stringList=(op[0].Shipment_Info__c).split(',');
for(integer i=0;i<stringList.size();i++){
all=all+stringList[i]+'<br/>';
}
all=all.remove('null');
}
//------------------------------------------------------------
}
public Id OppId{get;set;}
public InvoiceController(ApexPages.StandardController sc) {
oppId=Apexpages.currentPage().getparameters().get('Id');
}
public List<wrapperClass> getappointmentList (){
wrapperClass tempObj ;
tempObj = new wrapperClass();
List<wrapperClass> aReList = new List<wrapperClass>();
List<Opportunity> opp=[select id,Name,AccountId from Opportunity where id=:oppid limit 1];
List<opportunity> Opp1=[select id,name,CreatedDate from opportunity where id=:oppid];
//Opportunity opp1=[select id,Name,AccountId from Opportunity where id=:oppid limit 1];
//Opportunity Opp=[select id,name,CreatedDate from opportunity where id=:oppid ];
List<OpportunityLineItem> OPplineitem= [SELECT OpportunityId,Quantity,PricebookEntry.Product2.Name,Sys_total_Amount__c,LN__c,Extension__c,ListPrice
,Pick__c,Schedule_Ship_date__c,Bin_Item_Code__c ,PricebookEntry.Product2.Product_Line__c
FROM OpportunityLineItem where OpportunityId=:oppId];
system.debug('HHHHHHHHHH'+OPplineitem.size());
for(integer i=0; i < OPplineitem.size(); i++)
{
tempObj = new wrapperClass();
tempObj.productname= OPplineitem[i].PricebookEntry.Product2.Name;
tempObj.BinItemCode=OPplineitem[i].Bin_Item_Code__c;
tempObj.quantity=OPplineitem[i].Quantity;
tempObj.totalamount=OPplineitem[i].Sys_total_Amount__c;
// tempObj.productline=OPplineitem[i].PricebookEntry.Product2.Product_Line__c;
//Add a conditional statement here
if(OPplineitem[i].PricebookEntry.Product2.Product_Line__c=='DIE')
{
tempObj.unitprice=0.01;
tempobj.extension=OPplineitem[i].Quantity * tempObj.unitprice;
String productname='BinItemCode';
}
else
{
tempObj.unitprice=OPplineitem[i].ListPrice;
tempobj.extension=OPplineitem[i].Extension__c;
String productname='Item';
}
tempobj.LineNumber=OPplineitem[i].LN__c;
tempobj.Pick= OPplineitem[i].Pick__c;
tempobj.ScheduledShipDate = Opplineitem[i].schedule_ship_date__c;
if(tempobj!=null){
aReList.add(tempObj);
}
}
return aReList;
}
public List<wrapperClass> getappointmentList1 (){
wrapperClass tempObj1 ;
List<wrapperClass> aReList1 = new List<wrapperClass>();
List<Opportunity> opp=[select id,Name,AccountId,Shipment_Info__c,
Shipping_Address_Line1__c,
Shipping_Address_Line2__c,
Shipping_Address_Line3__c,
Shipping_City__c,
Shipping_State_Province__c,
Shipping_Zipcode__c,
Shipping_Country__c
from Opportunity where id=:oppid];
for(integer i=0; i < opp.size(); i++)
{
tempObj1 = new wrapperClass();
tempObj1.billingAddress= opp[i].Shipment_Info__c;
}
aReList1.add(tempObj1);
/* Below code commented by Kiranmai as Shipment Info field is split into multiple fields
//------- Added by Sumit-----------
stringList= new List<String>();
if(aReList1[0].billingAddress!=NULL && aReList1[0].billingAddress!=''){
List<String> stringList=(aReList1[0].billingAddress).split(',');
for(integer i=0;i<stringList.size();i++){
all=all+stringList[i]+'<br/>';
}
} */
all = all + opp[0].Shipping_Address_Line1__c + '<br/>';
if(opp[0].Shipping_Address_Line2__c!=NULL && opp[0].Shipping_Address_Line2__c!=''){
all = all + opp[0].Shipping_Address_Line2__c + '<br/>';
}
if(opp[0].Shipping_Address_Line3__c!=NULL && opp[0].Shipping_Address_Line3__c!=''){
all = all + opp[0].Shipping_Address_Line3__c + '<br/>';
}
if(opp[0].Shipping_City__c!=NULL && opp[0].Shipping_City__c!=''){
all = all + opp[0].Shipping_City__c + '<br/>';
}
if(opp[0].Shipping_State_Province__c!=NULL && opp[0].Shipping_State_Province__c!=''){
all = all + opp[0].Shipping_State_Province__c + '<br/>';
}
if(opp[0].Shipping_Zipcode__c!=NULL && opp[0].Shipping_Zipcode__c!=''){
all = all + opp[0].Shipping_Zipcode__c + '<br/>';
}
if(opp[0].Shipping_Country__c!=NULL && opp[0].Shipping_Country__c!=''){
all = all + opp[0].Shipping_Country__c + '<br/>';
}
/* all = all + opp[0].Shipping_City__c + ', '+opp[0].Shipping_State_Province__c + ' - ' + opp[0].Shipping_Zipcode__c + '<br/>';
all = all + opp[0].Shipping_Country__c + '<br/>';*/
all=all.remove('null');
/*-----------------------------------*/
return aReList1;
}
public class wrapperClass{
// public String Item{get;private set;}
public String productname{get;private set;}
public String BinItemCode{get;set;}
public Decimal Quantity{get;set;}
public Decimal totalamount{get;set;}
public Decimal unitprice{get;set;}
public date todaysdate{get;set;}
public decimal extension{get;set;}
public string LineNumber{get;set;}
public string billingAddress{get;set;}
public string splittedaddress{get;set;}
public string productline{get;set;}
public string wholeaddress{get;set;}
public boolean Pick{get;set;}
public date ScheduledShipDate{get;set;}
public wrapperClass(){}
}
}