public with sharing class NewOrderController {
|
public Id ordId {get;set;}
|
public boolean errorflg {get;set;}
|
public String errorMessage {get;set;}
|
|
public String baseUrl { get; set; }
|
public String rtUrl { get; set; }
|
|
public String fileName { get; set; }
|
public List<OrderItem> csv_activities {get;set;}
|
|
public NewOrderController(ApexPages.StandardController controller) {
|
this();
|
}
|
|
public NewOrderController() {
|
baseUrl = URL.getSalesforceBaseUrl().toExternalForm();
|
String path = URL.getCurrentRequestUrl().getPath();
|
if (path.indexOf('/apex') > 0) {
|
baseUrl += path.substring(0,path.indexOf('/apex'));
|
} else if (path.indexOf('production/') > 0) {
|
baseUrl += '/production';
|
}
|
rtUrl = System.currentPageReference().getParameters().get('retURL');
|
if (rtUrl == null || rtUrl == 'null') {
|
rtUrl = '';
|
}
|
}
|
|
public void init () {
|
ordId = System.currentPageReference().getParameters().get('Id');
|
|
if (ordId != null) {
|
csv_activities = [select Id, OrderId, PriceBookEntry.Product2.ProductCode, PriceBookEntry.Product2.Name, Quantity, Discount__c, Set__c from OrderItem where OrderId =: ordId];
|
}
|
}
|
|
public PageReference csvExport() {
|
if (fileName == null || fileName == '') {
|
errorflg = true;
|
errorMessage = '请输入配置导出文件名。';
|
return null;
|
}
|
|
if (csv_activities.size() == 0) {
|
errorflg = true;
|
errorMessage = '合同没有产品配置。';
|
return null;
|
}
|
|
PageReference pr = page.OrderCSVExport;
|
return pr;
|
}
|
}
|