public without sharing class ProductRepairQuoteController {
|
public String productId { get; set; }
|
public String flag { get; set; }
|
public String msg { get; private set; }
|
public String pId { get; set; }
|
public Boolean viewFlag { get; set; }
|
public Product2 product { get; private set; }
|
public String repairListPriceLevelA { get { return product == null ? '' : String.valueOf(product.RepairListPriceLevelA__c); } }
|
public String repairListPriceLevelB { get { return product == null ? '' : String.valueOf(product.RepairListPriceLevelB__c); } }
|
public String repairListPriceLevelC { get { return product == null ? '' : String.valueOf(product.RepairListPriceLevelC__c); } }
|
public Date partSupplyFinishDate { get { return product.PartSupplyFinishDate__c; } }
|
|
public ProductRepairQuoteController() {
|
productId = ApexPages.currentPage().getParameters().get('productid');
|
flag = ApexPages.currentPage().getParameters().get('flag');
|
}
|
|
public void init(){
|
viewFlag = true;
|
msg = '以下仅为参考报价,最终修理价格以报价单为准';
|
String usrProfileName = [select u.Profile.Name from User u where u.id = :Userinfo.getUserId()].Profile.Name;
|
//asset repair(传进来保有设备Id) product
|
List<Asset> assetList = new List<Asset>();
|
List<Product2> productList = new List<Product2>();
|
Map<String,String> adminProfileMap = new Map<String,String>();
|
Map<String,String> notadminProfileMap = new Map<String,String>();
|
List<String> adminProfileList = System.Label.profileName_adminand2F1.split(',');
|
for(Integer i = 0; i < adminProfileList.size(); i++){
|
adminProfileMap.put(adminProfileList[i], adminProfileList[i]);
|
}
|
List<String> notadminProfileList = System.Label.profileName_Notadminand2F1.split(',');
|
for(Integer i = 0; i < notadminProfileList.size(); i++){
|
notadminProfileMap.put(notadminProfileList[i], notadminProfileList[i]);
|
}
|
if(flag == 'asset'){
|
if(notadminProfileMap.containsKey(usrProfileName)){
|
assetList = [select Id,Product2Id,Product2.RepairListPriceLevelA__c,
|
Product2.RepairListPriceLevelB__c
|
from Asset
|
where Id = :productId];
|
if(assetList.size() > 0){
|
pId = assetList[0].Product2Id;
|
}else{
|
viewFlag = false;
|
msg = '';
|
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '产品不存在,请确认。'));
|
}
|
}else{
|
viewFlag = false;
|
msg = '您没有足够的权限执行所请求的操作。如果需要访问,请联系记录所有人或管理员。';
|
}
|
}
|
if(flag == 'product'){
|
if(adminProfileMap.containsKey(usrProfileName)){
|
pId = productId;
|
}else{
|
viewFlag = false;
|
msg = '您没有足够的权限执行所请求的操作。如果需要访问,请联系记录所有人或管理员。';
|
}
|
}
|
if(flag == 'productsearch'){
|
if(notadminProfileMap.containsKey(usrProfileName)){
|
List<Product2__c> product2List = [select Id,Product2__c
|
from Product2__c
|
where Id = :productId];
|
if(product2List.size() > 0){
|
pId = product2List[0].Product2__c;
|
}else{
|
viewFlag = false;
|
msg = '';
|
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '产品不存在,请确认。'));
|
}
|
}else{
|
viewFlag = false;
|
msg = '您没有足够的权限执行所请求的操作。如果需要访问,请联系记录所有人或管理员。';
|
}
|
}
|
if(viewFlag){
|
productList = [select Id,Name,RepairListPriceLevelA__c,
|
RepairListPriceLevelB__c,RepairListPriceLevelC__c,
|
PartSupplyFinishDate__c
|
from Product2
|
where Id = :pId];
|
if(productList.size() >0){
|
product = productList[0];
|
}else{
|
viewFlag = false;
|
msg = '';
|
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '产品不存在,请确认。'));
|
}
|
}
|
}
|
}
|