public with sharing class DeleteEventEntryController {
|
public DeleteEventEntryController(ApexPages.StandardController controller) {
|
|
}
|
|
public PageReference init() {
|
system.debug(':::::::::::::::::::::::::::::::start to delete:::::::::::::::::::::::::');
|
PageReference rf = null;
|
String eid = System.currentPageReference().getParameters().get('id');
|
String retURL = System.currentPageReference().getParameters().get('retURL');
|
Event e = [select EventC_ID__c, WS_flg__c from Event where id = :eid];
|
//学会なら、直接削除する
|
if(e.WS_flg__c == true){
|
delete e;
|
rf = new PageReference(retURL);
|
return rf;
|
}
|
list<Event__c> ecList = [select Id, Event_ID__c, Daily_Report__c, Subject__c, StartDateTime__c, EndDateTime__c, Main_Visit_Location__c,
|
Location__c, whatId__c, Activity_Type2__c, Activity_Type2_Before__c, Daily_Report__r.Status_With_Check__c,
|
Visitor1__c, Visitor2__c, Visitor3__c, Visitor4__c, Visitor5__c,
|
Visitor1_ID__c, Visitor2_ID__c, Visitor3_ID__c, Visitor4_ID__c, Visitor5_ID__c,
|
Companion__c, Purpose__c, Purpose_Type__c, Purpose_Type2__c, Purpose_Type3__c, Purpose_Type4__c, Purpose_Type5__c,
|
Related_Opportunity1__c, Related_Opportunity2__c, Related_Opportunity3__c, Related_Opportunity4__c, Related_Opportunity5__c,
|
Related_Opportunity1_ID__c, Related_Opportunity2_ID__c, Related_Opportunity3_ID__c, Related_Opportunity4_ID__c, Related_Opportunity5_ID__c,
|
//Related_Service1__c, Related_Service2__c,
|
//Related_Service1_ID__c, Related_Service2_ID__c,
|
Description__c,
|
//Description_Review__c,
|
Hospital_Info__c, Doctor_Info__c, Technology_Treatment__c,
|
New_Query__c, Update_Query__c, Lost_Info__c, VOC__c, Meeting_Info__c, Product_Description_Id__c,
|
Maintenance_Contract_ID__c, Asset_Manual_ID__c, Rental_Apply_ID__c,
|
OPD_ID__c, NTC_ID__c, ReportAccompanied_ID__c, CityStatus_ID__c, Conflict_ID__c, Improvement_ID__c, OnCall_ID__c,
|
nextPlanDate__c, nextPlanTimePurpose__c, Activity_ID__c,
|
Minister__c, Minister_Comment__c, Manager__c, Manager_Comment__c,
|
Free_Input__c, Visitor_Place_Free__c, Mail_Send_Btn__c,
|
Lead_ID__c, Lead_Count__c//, Opportunity_ID__c, Opportunity_Count__c
|
from Event__c where id = :e.EventC_ID__c];
|
//関連event__cがあるなら
|
if(ecList.size()!=0){
|
Event__c ec = ecList[0];
|
//event__cが編集されたら、削除できない
|
if(ec.Daily_Report__r.Status_With_Check__c != 'Draft'
|
|| !String.isBlank(ec.Description__c)
|
|| !String.isBlank(ec.Visitor1__c)
|
|| !String.isBlank(ec.Visitor2__c)
|
|| !String.isBlank(ec.Visitor3__c)
|
|| !String.isBlank(ec.Visitor4__c)
|
|| !String.isBlank(ec.Visitor5__c)
|
|| !String.isBlank(ec.Visitor1_ID__c)
|
|| !String.isBlank(ec.Visitor2_ID__c)
|
|| !String.isBlank(ec.Visitor3_ID__c)
|
|| !String.isBlank(ec.Visitor4_ID__c)
|
|| !String.isBlank(ec.Visitor5_ID__c)
|
|| !String.isBlank(ec.Companion__c)
|
|| !String.isBlank(ec.Purpose__c)
|
//|| !String.isBlank(ec.Purpose_Type__c)
|
|| !String.isBlank(ec.Purpose_Type2__c)
|
|| !String.isBlank(ec.Purpose_Type3__c)
|
|| !String.isBlank(ec.Purpose_Type4__c)
|
|| !String.isBlank(ec.Purpose_Type5__c)
|
|| !String.isBlank(ec.Related_Opportunity1__c)
|
|| !String.isBlank(ec.Related_Opportunity2__c)
|
|| !String.isBlank(ec.Related_Opportunity3__c)
|
|| !String.isBlank(ec.Related_Opportunity4__c)
|
|| !String.isBlank(ec.Related_Opportunity5__c)
|
|| !String.isBlank(ec.Related_Opportunity1_ID__c)
|
|| !String.isBlank(ec.Related_Opportunity2_ID__c)
|
|| !String.isBlank(ec.Related_Opportunity3_ID__c)
|
|| !String.isBlank(ec.Related_Opportunity4_ID__c)
|
|| !String.isBlank(ec.Related_Opportunity5_ID__c)
|
//|| !String.isBlank(ec.Description_Review__c)
|
|| !String.isBlank(ec.Product_Description_Id__c)
|
|| !String.isBlank(ec.Maintenance_Contract_ID__c)
|
|| !String.isBlank(ec.Asset_Manual_ID__c)
|
|| !String.isBlank(ec.Rental_Apply_ID__c)
|
|| !String.isBlank(ec.OPD_ID__c)
|
|| !String.isBlank(ec.NTC_ID__c)
|
|| !String.isBlank(ec.Activity_ID__c)
|
|| !String.isBlank(ec.ReportAccompanied_ID__c)
|
|| !String.isBlank(ec.CityStatus_ID__c)
|
|| !String.isBlank(ec.Conflict_ID__c)
|
|| !String.isBlank(ec.Improvement_ID__c)
|
|| !String.isBlank(ec.Lead_ID__c)
|
|| ec.Lead_Count__c != null
|
|| !String.isBlank(ec.Mail_Send_Btn__c)
|
|| !String.isBlank(ec.Minister_Comment__c)
|
|| ec.nextPlanDate__c != null
|
|| !String.isBlank(ec.nextPlanTimePurpose__c)
|
|| !String.isBlank(ec.OnCall_ID__c)
|
//|| !String.isBlank(ec.Opportunity_ID__c)
|
//|| ec.Opportunity_Count__c != null
|
|| !String.isBlank(ec.Visitor_Place_Free__c)
|
){
|
rf = new PageReference('/apex/YouCantDeleteEvent?id=' + eid);
|
}
|
else{
|
delete e;
|
delete ec;
|
rf = new PageReference(retURL);
|
}
|
}else{
|
delete e;
|
rf = new PageReference(retURL);
|
}
|
//system.debug('::::::::::::::::::::::::eid'+eid);
|
return rf;
|
}
|
}
|