public with sharing class BidAnnounceIframeController {
|
private String recordId;
|
public String iframe { get; private set; }
|
|
public BidAnnounceIframeController(ApexPages.StandardController stdController) {
|
recordId = stdController.getId();
|
}
|
|
public void init() {
|
Bid_Announcement__c bid = [select Id, Web_URL__c, Web_URL_ModifiedDate__c from Bid_Announcement__c where Id = :recordId];
|
List<Attachment> attList = [select Id, LastModifiedDate from Attachment where ParentId = :recordId order by LastModifiedDate desc limit 1];
|
Attachment att = null;
|
if (attList.size() > 0) {
|
att = attList[0];
|
}
|
|
if (bid.Web_URL__c != null) {
|
// 中标通知书URL更新时间 と 最新Attachmentの時間と比較、新しいものを適用
|
if (att != null) {
|
if (bid.Web_URL_ModifiedDate__c < att.LastModifiedDate) {
|
iframe = '/servlet/servlet.FileDownload?file=' + att.Id;
|
} else {
|
iframe = bid.Web_URL__c;
|
}
|
}
|
// 中标通知书URLを適用
|
else {
|
iframe = bid.Web_URL__c;
|
}
|
} else {
|
// Attachmentを適用
|
if (att != null) {
|
iframe = '/servlet/servlet.FileDownload?file=' + att.Id;
|
}
|
}
|
}
|
}
|