<apex:page lightningStylesheets="true" standardController="Event" tabStyle="Event" extensions="SimpleEventRegisterController" id="page" sidebar="true" action="{!init}">
<apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>

<apex:stylesheet value="{!URLFOR($Resource.jquerysuggestcss)}"/>
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
<apex:includeScript value="{!URLFOR($Resource.jquerysuggestjs)}"/>
<apex:includeScript value="{!URLFOR($Resource.connection20)}"/>
<apex:includeScript value="{!URLFOR($Resource.apex20)}"/>
<!-- //颜色横展 -->
<apex:stylesheet value="{!URLFOR($Resource.StyleUtilColorCss)}"/>
<!-- Add By Li Jun for PIPL 20220225 -->
<!-- deloitte-zhj 20231204 PIPL还原 -->
<!-- <apex:includeScript value="{!URLFOR($Resource.AWSService, 'AWSService.js') }" />
<apex:includeScript value="{!URLFOR($Resource.connection20)}"/> -->
<!-- Add By Li Jun for PIPL 20220225 -->
<script>
  var ros = '{!$User.State_Hospital__c}';
  var act = '病院';
  var hospitalString = '病院';
  var agentString = '販売店';
  var innerEventString = '社内活動';
  var outerEventString = '社外イベント';
  var optionsHP = {minchars:3, minwords:2, resultsClass:'visitorplace_results'};
  var options = {minchars:3, resultsClass:'visitorplace_results'};
  
  sforce.connection.sessionId = '{!$Api.Session_ID}';
  debugger;
  function setSuggestHospital() {
    try {
        j$( escapeVfId( "page:form:all:visitSettings:hospital")).unbind();
        j$( escapeVfId( "page:form:all:visitSettings:hospital")).suggest( '/apex/Xin_SearchVisitorPlace?r=' + encodeURI(ros), optionsHP);
    }
    catch (e) {
        alert( e);
    }
  }
  function setSuggestOpportunity() {
    try {
        j$( escapeVfId( "page:form:all:visitSettings:opportunity")).unbind();
        if (act == hospitalString) {
            j$( escapeVfId( "page:form:all:visitSettings:opportunity")).suggest( '/apex/Xin_SearchOpportunity?r=' + encodeURI( document.getElementById( 'page:form:all:visitSettings:hospitalId').value), {});
        } else if (act == agentString) {
            j$( escapeVfId( "page:form:all:visitSettings:opportunity")).suggest( '/apex/Xin_SearchOpportunity?r=' + encodeURI( document.getElementById( 'page:form:all:visitSettings:agentId').value), {});
        }
    }
    catch (e) {
        alert( e);
    }
  }
  function setSuggestOpportunity2() {
    try {
        j$( escapeVfId( "page:form:all:visitSettings:opportunity2")).unbind();
        if (act == hospitalString) {
            j$( escapeVfId( "page:form:all:visitSettings:opportunity2")).suggest( '/apex/Xin_SearchOpportunity?r=' + encodeURI( document.getElementById( 'page:form:all:visitSettings:hospitalId').value), {});
        } else if (act == agentString) {
            j$( escapeVfId( "page:form:all:visitSettings:opportunity2")).suggest( '/apex/Xin_SearchOpportunity?r=' + encodeURI( document.getElementById( 'page:form:all:visitSettings:agentId').value), {});
        }
    }
    catch (e) {
        alert( e);
    }
  }
  function setSuggestOpportunity3() {
    try {
        j$( escapeVfId( "page:form:all:visitSettings:opportunity3")).unbind();
        if (act == hospitalString) {
            j$( escapeVfId( "page:form:all:visitSettings:opportunity3")).suggest( '/apex/Xin_SearchOpportunity?r=' + encodeURI( document.getElementById( 'page:form:all:visitSettings:hospitalId').value), {});
        } else if (act == agentString) {
            j$( escapeVfId( "page:form:all:visitSettings:opportunity3")).suggest( '/apex/Xin_SearchOpportunity?r=' + encodeURI( document.getElementById( 'page:form:all:visitSettings:agentId').value), {});
        }
    }
    catch (e) {
        alert( e);
    }
  }
  // function setSuggestOpportunity4() {
  //   try {
  //       j$( escapeVfId( "page:form:all:visitSettings:opportunity4")).unbind();
  //       if (act == hospitalString) {
  //           j$( escapeVfId( "page:form:all:visitSettings:opportunity4")).suggest( '/apex/Xin_SearchOpportunity?r=' + encodeURI( document.getElementById( 'page:form:all:visitSettings:hospitalId').value), {});
  //       } else if (act == agentString) {
  //           j$( escapeVfId( "page:form:all:visitSettings:opportunity4")).suggest( '/apex/Xin_SearchOpportunity?r=' + encodeURI( document.getElementById( 'page:form:all:visitSettings:agentId').value), {});
  //       }
  //   }
  //   catch (e) {
  //       alert( e);
  //   }
  // }
  function setSuggestOpportunity5() {
    try {
        j$( escapeVfId( "page:form:all:visitSettings:opportunity5")).unbind();
        if (act == hospitalString) {
            j$( escapeVfId( "page:form:all:visitSettings:opportunity5")).suggest( '/apex/Xin_SearchOpportunity?r=' + encodeURI( document.getElementById( 'page:form:all:visitSettings:hospitalId').value), {});
        } else if (act == agentString) {
            j$( escapeVfId( "page:form:all:visitSettings:opportunity5")).suggest( '/apex/Xin_SearchOpportunity?r=' + encodeURI( document.getElementById( 'page:form:all:visitSettings:agentId').value), {});
        }
    }
    catch (e) {
        alert( e);
    }
  }
// <!-- 20230927 DBDB202308189331 -->
  function setSuggestInfrastructureProject() {
    try {
        j$( escapeVfId( "page:form:all:visitSettings:opportunity4")).unbind();
            j$( escapeVfId( "page:form:all:visitSettings:opportunity4")).suggest( '/apex/Xin_Infrastructure_Project?r=' + encodeURI( document.getElementById( 'page:form:all:visitSettings:hospitalId').value), {});

    }
    catch (e) {
        alert( e);
    }
  }
  // <!-- 20230927 DBDB202308189331 -->
  function setSuggestContract() {
      try {
        j$( escapeVfId( "page:form:all:visitSettings:contract")).unbind();
        j$( escapeVfId( "page:form:all:visitSettings:contract")).suggest( '/apex/Xin_Maintenance_Contract?r=' + encodeURI( document.getElementById( 'page:form:all:visitSettings:hospitalId').value), {});
    }
    catch (e) {
        alert( e);
    }
  }
  function setSuggestTraining() {
    j$( escapeVfId( "page:form:all:visitSettings:training")).unbind();
    j$( escapeVfId( "page:form:all:visitSettings:training")).suggest( '/apex/Xin_SearchVisitorPlace_Training?r=' + encodeURI(ros), options);
  }
  function setSuggestCampaign() {
    j$( escapeVfId( "page:form:all:visitSettings:campaign")).unbind();
    j$( escapeVfId( "page:form:all:visitSettings:campaign")).suggest( '/apex/Xin_SearchVisitorPlace_Campaign?r=' + encodeURI(ros), options);
  }
  function setSuggestAgent() {
    var today = new Date();
    var targetDate = today.getFullYear() + '/' + (today.getMonth()+1) + '/' + today.getDate();
    j$( escapeVfId( "page:form:all:visitSettings:agent")).unbind();
    j$( escapeVfId( "page:form:all:visitSettings:agent")).suggest( '/apex/Xin_SearchVisitorPlace_Sales?r=' + encodeURI(ros) + '&d=' + targetDate, optionsHP);
  }
  function resetChild_delay(htmlId) {
    setTimeout(function() {resetChild(htmlId)}, 200);
  }
  function resetChild(htmlId) {
      if (resetValue(htmlId)) {
      } else {
          // 新しい値を設定した
          j$( escapeVfId( "page:form:all:visitSettings:opportunity")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunityId")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunityHidden")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunityHiddenId")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:contract")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:contractId")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:contractHidden")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:contractHiddenId")).val("");
          
          j$( escapeVfId( "page:form:all:visitSettings:opportunity2")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunity2Id")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunity2Hidden")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunity2HiddenId")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunity3")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunity3Id")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunity3Hidden")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunity3HiddenId")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunity4")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunity4Id")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunity4Hidden")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunity4HiddenId")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunity5")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunity5Id")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunity5Hidden")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunity5HiddenId")).val("");
      }
  }

  function changeVisitToGateway() {
    var select = document.getElementById( 'page:form:all:visitSettings:activity');
    act = document.getElementById( 'page:form:all:visitSettings:activity').options.item( select.selectedIndex).value;
    if ( act == hospitalString) {
        callHospital();
    }
    else if ( act == agentString) {
        callAgent();
    }
    else if ( act == innerEventString) {
        callTraining();
    }
    else if ( act == outerEventString) {
        callCampaign();
    }
    else {
        callNone();
    }
  }
  
  function clearVisitorId(id){
    document.getElementById('page:form:all:visitSettings:' + id).value = '';
  }
  
  function checkLocation(){
    var str = 'page:form:all:visitSettings:hospital';
    var aName = j$(escapeVfId(str)).value();
    if(aName == ''){
        // 訪問場所を設定してください。
        alert('{!$Label.Error_Message16}');
        return false;
    }
    
    var strVP = 'page:form:all:visitSettings:hospitalId';
    var vl = j$(escapeVfId(strVP)).value();
    if(vl.length == 0){
        // 訪問場所が存在しません。
        alert('{!$Label.Error_Message15}');
        return false;
    }
    
    var match = sforce.apex.execute("Add_Report","checkAccountMatch",{name:aName,id:vl});
    if(match == "NG"){
        // 訪問場所IDマッチしていない
        alert('{!$Label.Error_Message15}');
        return false;
    }
    return true;
  }
  
  function searchVisitor2(val){
    if (!checkLocation()) {
        return;
    }

    var str = 'page:form:all:visitSettings:hospital';
    var strId = 'page:form:all:visitSettings:hospitalId';
    var aName = j$(escapeVfId(str)).value();
    var aId = j$(escapeVfId(strId)).value();

    var vp = aId;
    
    //j$(escapeVfId('Page:mainForm:idDayEdit:idActivities:' + index + ':idVisitorPlaceHidden')).val(aName);
    //j$(escapeVfId('Page:mainForm:idDayEdit:idActivities:' + index + ':idVisitorPlaceHiddenId')).val(aId);
    
    var strId1 = 'page:form:all:visitSettings:visitor1';
    var strHid1 = 'page:form:all:visitSettings:visitor1Id';
    var strVa1 = j$(escapeVfId('page:form:all:visitSettings:visitor1Id')).value()
    var strId2 = 'page:form:all:visitSettings:visitor2';
    var strHid2 = 'page:form:all:visitSettings:visitor2Id';
    var strVa2 = j$(escapeVfId('page:form:all:visitSettings:visitor2Id')).value();
    var strId3 = 'page:form:all:visitSettings:visitor3';
    var strHid3 = 'page:form:all:visitSettings:visitor3Id';
    var strVa3 = j$(escapeVfId('page:form:all:visitSettings:visitor3Id')).value();
    var strId4 = 'page:form:all:visitSettings:visitor4';
    var strHid4 = 'page:form:all:visitSettings:visitor4Id';
    var strVa4 = j$(escapeVfId('page:form:all:visitSettings:visitor4Id')).value();
    var strId5 = 'page:form:all:visitSettings:visitor5';
    var strHid5 = 'page:form:all:visitSettings:visitor5Id';
    var strVa5 = j$(escapeVfId('page:form:all:visitSettings:visitor5Id')).value();
    
    var urlStr = '/apex/SearchVisitor?id1=' + strId1 + '&hId1=' + strHid1 + '&idVa1=' + strVa1 + '&id2=' + strId2 + '&hId2=' + strHid2 + '&idVa2=' + strVa2 + '&id3=' + strId3 + '&hId3=' + strHid3 + '&idVa3=' + strVa3 + '&id4=' + strId4 + '&hId4=' + strHid4 + '&idVa4=' + strVa4 + '&id5=' + strId5 + '&hId5=' + strHid5 + '&idVa5=' + strVa5 + '&val=' + val + '&vp=' + vp;
    var w = window.open(urlStr,'SearchVisitor','height=820,menubar=no,');
    // 986
    w.focus();
  }
  
  function showModal() {
    //blockme();
    //showModalJs();
  }

  // 日报访问场所不允许修改 zh
  window.onload = function disabledActivityType(){
    if ({!isDisable}) {
      document.getElementById('page:form:all:visitSettings:activity').disabled = true; 
    }
    //20210609 mzy WLIG-BX3DQ5 【委托】Outlook日历和SFDC日历同步 start 
    disablePurpose();
    //20210609 mzy WLIG-BX3DQ5 【委托】Outlook日历和SFDC日历同步 end
    //20210511 zh  WLIG-BX3DQ5 【委托】Outlook日历和SFDC日历同步 start
    if({!allDisable}){
        // alert({!allDisable});
    //   j$('input').attr('disabled','disabled');
    //   j$('select').attr('disabled','disabled');
        for(var j=0;j<document.forms['page:form'].elements.length;j++) {
            setButtonDisable(document.forms['page:form'].elements[j],true);
        }
    }
    //20210511 zh  WLIG-BX3DQ5 【委托】Outlook日历和SFDC日历同步 end
  }
  function disablePurpose(){
    var vfeventId = '{!id}';
    if(vfeventId || {!isDisActivityCategory}){
        document.getElementById('page:form:all:visitSettings:activity').disabled = true;  
    }
    if( {!isDisActivityPurposeFSE} ){
       document.getElementById('page:form:all:visitSettings:purposeFSE').disabled = true;  
       //2021-09-30   mzy  锁住活动区分FSE  start
       document.getElementById('page:form:all:visitSettings:purposeTypeFSE').disabled = true;  
       //2021-09-30   mzy  锁住活动区分FSE   end
    }
    if( {!isDisActivityPurposeEscFSE} ){
       document.getElementById('page:form:all:visitSettings:purposeEscFSE').disabled = true;  
    }    
    //2021-08-10  mzy  update  SWAG-C5R6GW   询价任务新增字段  start
    if({!isOppSelect}){
      document.getElementById('page:form:all:visitSettings:opportunity').disabled = true;
      document.getElementById('page:form:all:visitSettings:opportunity2').disabled = true;
    }
    //2021-08-10  mzy  update  SWAG-C5R6GW   询价任务新增字段  end
  }

  //deloitte-zhj 20231204 PIPL还原 start
//   //Add By Li Jun 20220225 for PIPL Start
  //     AWSService.sfSessionId = '{!GETSESSIONID()}';
    //     var sfIdToContactInfo = {};
    //     function preparePayloadForSearchContact(){
        //         let searchPayload = new Object();
        //         searchPayload.dataIds = contactAWSIds;
        //         searchPayload.contactName = '';
        //         return JSON.stringify(searchPayload);
    //     }
//     function searchContactAll(){
        //         let data = preparePayloadForSearchContact();
        //         let searchCallBack = function searchCallBack(result){
            //             let contacts = result.object;
            //             if(contacts == null){
                //                 return;
            //             }
//             for(var i=0;i<contacts.length;i++){
                //                 let temp = {}
                //                 temp.lastName = contacts[i].lastName?contacts[i].lastName:'';                       
                //                 if(contacts[i].sfRecordId){
                    //                     sfIdToContactInfo[contacts[i].sfRecordId] = temp;
                //                 }                    
//             }
//             console.log('AWS Result:'+JSON.stringify(sfIdToContactInfo));
            //             let v1Id = j$(escapeVfId('page:form:all:visitSettings:visitor1Id')).value();
            //             if(sfIdToContactInfo.hasOwnProperty(v1Id)){
                //                 document.getElementById("page:form:all:visitSettings:visitor1").value = sfIdToContactInfo[v1Id].lastName;
            //             }  
//             let v2Id = j$(escapeVfId('page:form:all:visitSettings:visitor2Id')).value();
            //             if(sfIdToContactInfo.hasOwnProperty(v2Id)){
                //                 document.getElementById("page:form:all:visitSettings:visitor2").value = sfIdToContactInfo[v2Id].lastName;
            //             }                        
//         };
        //         AWSService.search(staticResources.searchUrl,data,searchCallBack,staticResources.token);
    //     }
//     //Add By Li Jun 20220225 for PIPL End 
//deloitte-zhj 20231204 PIPL还原 end

    // 2021-07-29   zyh   update   start
    function OPDPlan_F(){
        var cid = document.getElementById('page:form:all:visitSettings:opportunity5111');
        var cid1 = document.getElementById('page:form:all:visitSettings:opportunity');
        var cid2 = document.getElementById('page:form:all:visitSettings:opportunity2');
        console.log(cid.checked,cid1,cid2,'<<<<<<<<<')
        if(cid1 || cid2){
            if (cid.checked == true && (!cid1.value || !cid2.value)) {
                if(!confirm("您创建的OPD计划没有关联询价，需要审批到副总裁。")){
                    return;
                }
                // alert('您创建的OPD计划没有关联询价，需要审批到副总裁。');
            }
        }
        
        // save();
    }/*
    function OPDPlan_F1(){
        var cid = document.getElementById('page:form:all:visitSettings:opportunity5111');
        var cid1 = document.getElementById('page:form:all:visitSettings:opportunity').value;
        var cid2 = document.getElementById('page:form:all:visitSettings:opportunity2').value;
        if (cid.checked == true && cid1 == '' && cid2 == '') {
            if(!confirm("您创建的OPD计划没有关联询价，需要审批到副总裁。")){
                return;
            }
            // alert('您创建的OPD计划没有关联询价，需要审批到副总裁。');
        }
        saveAndNew();
    }*/
    // 2021-07-29   zyh   update   end
</script>
<style>
    .visitorplace_results {
        border: 1px solid gray;
        background-color: white;
        padding: 0;
        margin: 0;
        list-style: none;
        position: absolute;
        z-index: 10000;
        display: none;
        overflow:auto;
        white-space:nowrap;
        width:400px;
        height:250px;
    }
    .visitorplace_results li {
        padding: 2px 5px 2px 0px;
        margin-left : 2px;
        color: #101010;
        text-align: left;
    }
    body .pbButton {
         text-align: left;
    }
</style>
<div class="bPageTitle">
  <div class="ptBody">
    <div class="content">
      <img src="/s.gif" alt="主页"  class="pageTitleIcon" title="主页"/>
      <h1 class="pageType">日历<span  class="titleSeparatingColon">:</span></h1>
      <h2 class="pageDescription"> 新建事件</h2>
      <div class="blank">&nbsp;</div>
    </div>
  </div>
</div>

<apex:pageMessages showDetail="false" id="msgs"/>

<apex:form id="form">

    <!-- // 2021-07-29   zyh   update   start -->
<!-- <apex:actionFunction action="{!save}" name="save" reRender="visitSettings" oncomplete="blockme();unblockUI();"/>
<apex:actionFunction action="{!saveAndNew}" name="saveAndNew" reRender="visitSettings" oncomplete="blockme();unblockUI();"/> -->
    <!-- // 2021-07-29   zyh   update   end -->
<apex:actionFunction name="callHospital" action="{!visitToHospital}" immediate="true" rerender="visitSettings"/>
<apex:actionFunction name="callAgent" action="{!visitToAgent}" immediate="true" rerender="visitSettings"/>
<apex:actionFunction name="callTraining" action="{!visitToTraining}" immediate="true" rerender="visitSettings"/>
<apex:actionFunction name="callCampaign" action="{!visitToCampaign}" immediate="true" rerender="visitSettings"/>
<apex:actionFunction name="callNone" action="{!visitToNone}" immediate="true" rerender="visitSettings"/>

<apex:pageBlock title="事件编辑" mode="edit" id="all">

    <apex:pageblockSection title="日历详细信息" columns="2" collapsible="false" id="visitSettings">

        <apex:inputfield value="{!targetEvent.StartDateTime}" required="true" id="startDateTime" />
        <!--<apex:inputfield value="{!targetEvent.DurationInMinutes}" label="持续时间(分钟)" required="true" id="durationMinutes"/>-->
        <!--2021-07-22  mzy  事件页面优化--将持续时间换成结束时间 start -->
        <apex:inputfield value="{!targetEvent.EndDateTime}"   required="true" id="endDateTime"/>
        <!--2021-07-22  mzy  事件页面优化--将持续时间换成结束时间 end-->
        <apex:pageblockSectionItem />
        <apex:pageblockSectionItem />
        <!--2.1 拜访区分-->
        <apex:inputfield value="{!targetEvent.Activity_Type2__c}" onchange="changeVisitToGateway();" id="activity" required="true" />
        <!--2.2 拜访目的（FSE）/ 拜访目的(FSE外)-->
        <!-- <apex:inputfield value="{!targetEVent.Main_Visit_Location__c}" rendered="{!isHospital}" /> -->
        <apex:inputfield value="{!targetEvent.Activity_PurposeFSE__c}" required="true" rendered="{!IF(LoginUser.Job_Category__c == '销售服务', 'true', 'false')}"  id="purposeFSE" />
        <apex:inputfield value="{!targetEvent.Activity_PurposeEscFSE__c}" required="true" rendered="{!IF(LoginUser.Job_Category__c != '销售服务', 'true', 'false')}" id="purposeEscFSE" /> 
        <!--3.1 空-->
        <apex:pageblockSectionItem />
        <!--3.2 活动区分FSE/活动区分FSE外-->
         <!-- 20121-09-30 mzy 点检改善 end-->
         <apex:inputfield id="purposeTypeFSE" value="{!targetEvent.Purpose_TypeFSE__c}"  rendered="{!IF(LoginUser.Job_Category__c == '销售服务', 'true', 'false')}"  />
         <!-- 20121-09-30 mzy 点检改善 end-->
        <apex:inputfield value="{!targetEvent.Purpose_TypeEscFSE__c}" rendered="{!IF(LoginUser.Job_Category__c != '销售服务', 'true', 'false')}" />
        <!-- 10101104 zh SFDC-BUF6KM OPD被动任务是战略科室时，显示不能更改的战略科室和可更改的普通科室 start -->
        <apex:inputText label="战略科室" value="{!DepartmentName}" rendered="{!isShowDepartment}" disabled="true" style="width:97%"/>
        <apex:pageblockSectionItem rendered="{!isShowDepartment}" />
        <!-- 10101104 zh SFDC-BUF6KM OPD被动任务是战略科室时，显示不能更改的战略科室和可更改的普通科室 end -->
        <!--4.1-2整个横区域  科室/市场活动/公司工作/经销商-->
        <apex:inputText label="科室" value="{!targetEvent.Location}" rendered="{!isHospital}" id="hospital" onfocus="setSuggestHospital()" onchange="resetChild_delay('page:form:all:visitSettings:hospital');" style="width:97%" disabled="{!isDisableDepart}"/>
        <!-- // DB202312088802 hql 20231214 添加自定义主题 start -->
        <apex:pageblockSectionItem />
         <apex:inputText label="主题" value="{!subjectPerson}" id="subjectPerson" style="width:97%;"  required="false" size="50" />
         <!-- // DB202312088802 hql 20231214 添加自定义主题 end -->

        <apex:inputHidden value="{!targetEvent.whatid__c}" rendered="{!isHospital}" id="hospitalId"/>
        <apex:inputHidden value="{!targetEvent.Location}" rendered="{!isHospital}" id="hospitalHidden"/>
        <apex:inputHidden value="{!targetEvent.whatid__c}" rendered="{!isHospital}" id="hospitalHiddenId"/> 
        <apex:inputText label="经销商" value="{!targetEvent.Location}" rendered="{!isAgent}" id="agent" onfocus="setSuggestAgent()" onchange="resetValue('page:form:all:visitSettings:agent');" style="width:97%" disabled="{!IF(targetEvent.Location !='',true,false)}"/>
        <apex:inputHidden value="{!targetEvent.whatid__c}" rendered="{!isAgent}" id="agentId"/>
        <apex:inputHidden value="{!targetEvent.Location}" rendered="{!isAgent}" id="agentHidden"/>
        <apex:inputHidden value="{!targetEvent.whatid__c}" rendered="{!isAgent}" id="agentHiddenId"/>
        <apex:inputText label="公司工作" value="{!targetEvent.Location}" rendered="{!isTraining}" id="training" onfocus="setSuggestTraining()" onchange="resetValue('page:form:all:visitSettings:training');" style="width:97%" disabled="{!IF(targetEvent.Location !='',true,false)}"/>
        <apex:inputHidden value="{!targetEvent.whatid__c}" rendered="{!isTraining}" id="trainingId"/>
        <apex:inputHidden value="{!targetEvent.Location}" rendered="{!isTraining}" id="trainingHidden"/>
        <apex:inputHidden value="{!targetEvent.whatid__c}" rendered="{!isTraining}" id="trainingHiddenId"/>
        <apex:inputText label="市场活动" value="{!targetEvent.Location}" rendered="{!isCampaign}" id="campaign" onfocus="setSuggestCampaign()" onchange="resetValue('page:form:all:visitSettings:campaign');" style="width:97%" disabled="{!IF(targetEvent.Location !='',true,false)}"/>
        <apex:inputHidden value="{!targetEvent.whatid__c}" rendered="{!isCampaign}" id="campaignId"/>
        <apex:inputHidden value="{!targetEvent.Location}" rendered="{!isCampaign}" id="campaignHidden"/>
        <apex:inputHidden value="{!targetEvent.whatid__c}" rendered="{!isCampaign}" id="campaignHiddenId"/>
       
        <!--5.1 主题-->
        <apex:pageblockSectionItem rendered="{!isHospital}">
            <apex:outputLabel value="主题" for="mId" style="display:none" />
            <apex:outputPanel layout="block">
                <apex:outputPanel layout="block"/>
                <apex:inputText value="{!targetEvent.Subject}" style="width:97%;display:none"  required="false" size="50" />
            </apex:outputPanel>
        </apex:pageblockSectionItem>
        <!--5.2 OPD计划-->
        <!-- <apex:inputField label="{!$ObjectType.Event.fields.OPDPlan_Flag__c.label}" value="{!targetEvent.OPDPlan_Flag__c}" rendered="True" id="opportunity5111" onFocus="setSuggestOpportunity5();" onchange="resetValue('page:form:all:visitSettings:opportunity5');"/>
        <apex:pageblockSectionItem /> -->
        <!-- 20200922 zh SWAG-BS6BYA 样式调整 start -->

        <!-- 访问对象1 -->
              <!-- deloitte-zhj 20231204 PIPL还原 -->
              <apex:inputText label="访问对象" value="{!targetEvent.Visitor1__c}" rendered="{!isHospital}" id="visitor1" onchange="clearVisitorId('visitor1Id');" onClick="searchVisitor2(value);"/>
              <!-- Add by Li Jun for PIPL 20220303 Start -->
              <!-- <apex:inputText label="访问对象" value="{!idVisitor1PI}" rendered="{!isHospital}" id="visitor1" onchange="clearVisitorId('visitor1Id');" onClick="searchVisitor2(value);"/> -->
              <!-- Add by Li Jun for PIPL 20220303 End -->
              <apex:pageblockSectionItem />
        <!-- 访问对象2 -->
              <!-- deloitte-zhj 20231204 PIPL还原 -->
              <apex:inputText label=" " value="{!targetEvent.Visitor2__c}" rendered="{!isHospital}" id="visitor2" onchange="clearVisitorId('visitor2Id');" onClick="searchVisitor2(value);"/>
               <!-- Add by Li Jun for PIPL 20220303 Start -->
              <!-- <apex:inputText label=" " value="{!idVisitor2PI}" rendered="{!isHospital}" id="visitor2" onchange="clearVisitorId('visitor2Id');" onClick="searchVisitor2(value);"/> -->
              <!-- Add by Li Jun for PIPL 20220303 End -->
              <script>
                    //deloitte-zhj 20231204 PIPL还原
                    // console.log('Load AWS Data');
                    // searchContactAll();
              </script>
              <apex:pageblockSectionItem rendered="{!isAgent}"/>
              <!-- <apex:pageblockSectionItem /> -->
        <!-- 询价1 -->
              <apex:inputField label="{!$Label.Involved}{!$Label.Opportunity}" value="{!targetEvent.Related_Opportunity1__c}" rendered="{!isHospital || isAgent}" id="opportunity" onFocus="setSuggestOpportunity();" onchange="resetValue('page:form:all:visitSettings:opportunity');"/>
              <apex:pageblockSectionItem />
        <!-- 询价2 -->
              <!-- <apex:inputField label=" " value="{!targetEvent.Related_Opportunity2__c}" rendered="{!isHospital || isAgent}" id="opportunity2" onFocus="setSuggestOpportunity2();" onchange="resetValue('page:form:all:visitSettings:opportunity2');"/> -->
              <apex:pageblockSectionItem />
              <!-- 20230927 DBDB202308189331 -->
              <apex:pageblockSectionItem />

        <!-- 基建项目1 -->
              <apex:inputField label="基建项目" value="{!targetEvent.Related_Opportunity4__c}" rendered="{!isHospital}" id="opportunity4" onFocus="setSuggestInfrastructureProject();" onchange="resetValue('page:form:all:visitSettings:opportunity4');"/>
              <apex:pageblockSectionItem />

              <!-- 20230927 DBDB202308189331 -->
        <!-- 无询价申请理由 -->
              <apex:inputField label="{!$ObjectType.Event.fields.noOpp_Reason__c.label}" value="{!targetEvent.noOpp_Reason__c}" rendered="{!isHospital || isAgent}" id="noOppReason" />
              <!-- <apex:pageblockSectionItem /> -->
        <!--5.2 OPD计划-->
            <!--2021-12-23  mzy  备品任务 stat  只有用户拜访时可以勾选 OPD计划-->            
            <!-- 10101104 zh SFDC-BUF6KM OPD被动任务 start -->
              <!-- <apex:inputField label="{!$ObjectType.Event.fields.OPDPlan_Flag__c.label}" value="{!targetEvent.OPDPlan_Flag__c}" rendered="True" id="opportunity5111" onFocus="setSuggestOpportunity5();" onchange="resetValue('page:form:all:visitSettings:opportunity5');" /> -->
              <apex:inputField label="{!$ObjectType.Event.fields.OPDPlan_Flag__c.label}" value="{!targetEvent.OPDPlan_Flag__c}" rendered="{!!isOpdDisable && isHospital}" id="opportunity5111" onFocus="setSuggestOpportunity5();" onchange="resetValue('page:form:all:visitSettings:opportunity5');" onclick="OPDPlan_F();" />
              <apex:inputField label="{!$ObjectType.Event.fields.OPDPlan_Flag__c.label}" value="{!targetEvent.OPDPlan_Flag__c}" rendered="{!isOpdDisable && isHospital}" html-disabled="true" />
            <!-- 10101104 zh SFDC-BUF6KM OPD被动任务 end -->
            <!--2021-12-23  mzy  备品任务 end   只有用户拜访时可以勾选 OPD计划-->
              <!-- <apex:pageblockSectionItem /> -->
        <!-- 涉及的维修合同 -->
              <apex:pageblockSectionItem rendered="{!IF(isShowService,false,true)}"/>
              <apex:inputText label="{!$Label.Involved}{!$Label.Service_Agreement}" value="{!targetEvent.Related_Service1__c}" rendered="{!isShowService && isHospital}" id="contract" onFocus="setSuggestContract();" onchange="resetValue('page:form:all:visitSettings:contract');" disabled="{!isDisService}"/>
              <!-- <apex:pageblockSectionItem rendered="{!isAgent}"/>
                <apex:inputField label="{!$Label.Involved}{!$Label.Service_Agreement}" value="{!targetEvent.Related_Service1__c}" rendered="{!isHospital}" id="contract" onFocus="setSuggestContract();" onchange="resetValue('page:form:all:visitSettings:contract');"/> -->
        <!-- 20200922 zh SWAG-BS6BYA 样式调整 end -->
        <!-- 20200901 ljh add start  -->
        <!-- 计划出借的备品 -->
        <!--5.2 计划出借的备品-->
        <!-- 20200907 zh 计划出借备品 start -->
        <apex:outputPanel layout="block" style="overflow:auto;overflow-x: hidden;width: fit-content; height:185px;margin-left: 20%;" rendered="{!isHospital || isCampaign}" >
            <table>
                <tr>
                    <td align="right"><b>计划出借的备品</b></td>
                    <td width="40px"></td>
                    <td class="dataCol"><b>出借套数</b></td>
                </tr>
                <apex:repeat value="{!prods}" var="prod" id="planProducts">
                    <tr>
                        <td align="right" style="color:rgb(68, 68, 68)"> {!prod.Name} </td>
                        <th width="10px"></th>
                        <td> 
                            <apex:inputText style="width: 60px;" id="rentalQuantity" value="{!planProducts[prod.Name]}" disabled="{!isDisPlanProd}"/> 
                        </td>
                    </tr>
                </apex:repeat>
            </table>
        </apex:outputPanel>

        <!-- <apex:inputfield value="{!targetEvent.PlanLendProduct__c}" rendered="{!isHospital || isCampaign}"/>
        <apex:pageblockSectionItem rendered="{!not(isHospital || isCampaign)}"/> -->
        <!--6.1 空-->
        <apex:pageblockSectionItem />
        <!-- 6.2 出借套数展示 -->
        <!-- <apex:inputfield value="{!targetEvent.LendNum__c}" rendered="{!isHospital || isCampaign}"/>
        <apex:pageblockSectionItem rendered="{!not(isHospital || isCampaign)}"/> -->
        <!-- 20200907 zh 计划出借备品 end -->

        <!-- Visitor 1-5 -->
        <!-- 20200901 ljh 样式调整02 start-->
        <!-- 访问对象1 -->
              <!-- <apex:inputText label="访问对象" value="{!targetEvent.Visitor1__c}" rendered="{!isHospital}" id="visitor1" onchange="clearVisitorId('visitor1Id');" onClick="searchVisitor2(value);"/>
              <apex:pageblockSectionItem /> -->
        <!-- 访问对象2 -->
              <!-- <apex:inputText label=" " value="{!targetEvent.Visitor2__c}" rendered="{!isHospital}" id="visitor2" onchange="clearVisitorId('visitor2Id');" onClick="searchVisitor2(value);"/>
              <apex:pageblockSectionItem rendered="{!isAgent}"/> -->
              <!-- <apex:pageblockSectionItem /> -->
        <!-- 询价1 -->
              <!-- <apex:inputField label="{!$Label.Involved}{!$Label.Opportunity}" value="{!targetEvent.Related_Opportunity1__c}" rendered="{!isHospital || isAgent}" id="opportunity" onFocus="setSuggestOpportunity();" onchange="resetValue('page:form:all:visitSettings:opportunity');"/>
              <apex:pageblockSectionItem /> -->
        <!-- 询价2 -->
              <!-- <apex:inputField label=" " value="{!targetEvent.Related_Opportunity2__c}" rendered="{!isHospital || isAgent}" id="opportunity2" onFocus="setSuggestOpportunity2();" onchange="resetValue('page:form:all:visitSettings:opportunity2');"/>
              <apex:pageblockSectionItem /> -->
        <!-- 无询价申请理由 -->
              <!-- <apex:inputField label="{!$ObjectType.Event.fields.noOpp_Reason__c.label}" value="{!targetEvent.noOpp_Reason__c}" rendered="{!isHospital || isAgent}" id="noOppReason" /> -->
        <!-- 20200901 ljh 样式调整02 end-->
        <!-- 20200901 ljh 样式调整02原来 start-->
        <!-- Visitor 1-5 -->
        <!-- 访问对象1 -->
              <!--<apex:inputText label="访问对象" value="{!targetEvent.Visitor1__c}" rendered="{!isHospital}" id="visitor1" onchange="clearVisitorId('visitor1Id');" onClick="searchVisitor2(value);"/>
        <apex:pageblockSectionItem rendered="{!isAgent}"/>
        <apex:pageblockSectionItem rendered="{!isAgent}"/>-->
        <!-- 询价1 -->
              <!--<apex:inputField label="{!$Label.Involved}{!$Label.Opportunity}" value="{!targetEvent.Related_Opportunity1__c}" rendered="{!isHospital || isAgent}" id="opportunity" onFocus="setSuggestOpportunity();" onchange="resetValue('page:form:all:visitSettings:opportunity');"/>-->

        <!-- 访问对象2 -->
              <!--<apex:inputText label=" " value="{!targetEvent.Visitor2__c}" rendered="{!isHospital}" id="visitor2" onchange="clearVisitorId('visitor2Id');" onClick="searchVisitor2(value);"/>
        <apex:pageblockSectionItem rendered="{!isAgent}"/>-->
        <!-- 询价2 -->
              <!--<apex:inputField label=" " value="{!targetEvent.Related_Opportunity2__c}" rendered="{!isHospital || isAgent}" id="opportunity2" onFocus="setSuggestOpportunity2();" onchange="resetValue('page:form:all:visitSettings:opportunity2');"/>-->

        <!-- 访问对象3 -->
             <!-- <apex:inputText label=" " value="{!targetEvent.Visitor3__c}" rendered="{!isHospital}" id="visitor3" onchange="clearVisitorId('visitor3Id');" onClick="searchVisitor2(value);"/>
        <apex:pageblockSectionItem rendered="{!isAgent}"/>-->

        <!-- 询价3 -->
              <!--<apex:inputField label=" " value="{!targetEvent.Related_Opportunity3__c}" rendered="{!isHospital || isAgent}" id="opportunity3" onFocus="setSuggestOpportunity3();" onchange="resetValue('page:form:all:visitSettings:opportunity3');"/>
              <apex:pageblockSectionItem rendered="{!isAgent}"/>

              <apex:inputText label=" " value="{!targetEvent.Visitor4__c}" rendered="{!isHospital}" id="visitor4" onchange="clearVisitorId('visitor4Id');" onClick="searchVisitor2(value);"/>
              <apex:pageblockSectionItem rendered="{!isHospital}"/>
              <apex:inputText label=" " value="{!targetEvent.Visitor5__c}" rendered="{!isHospital}" id="visitor5" onchange="clearVisitorId('visitor5Id');" onClick="searchVisitor2(value);"/>
              <apex:pageblockSectionItem rendered="{!isHospital}"/>-->
        <!-- 20200901 ljh 样式调整02原来 end-->

        <apex:inputHidden id="visitor1Id" value="{!targetEvent.Visitor1_ID__c}" rendered="{!isHospital}"/>
        <apex:inputHidden id="visitor2Id" value="{!targetEvent.Visitor2_ID__c}" rendered="{!isHospital}"/>
        <!-- <apex:inputHidden id="visitor3Id" value="{!targetEvent.Visitor3_ID__c}" rendered="{!isHospital}"/> -->
        <!-- <apex:inputHidden id="visitor4Id" value="{!targetEvent.Visitor4_ID__c}" rendered="{!isHospital}"/> -->
        <!-- <apex:inputHidden id="visitor5Id" value="{!targetEvent.Visitor5_ID__c}" rendered="{!isHospital}"/> -->
        <!-- <apex:inputText label="访问对象" value="{!targetEvent.Visitor1__c}" rendered="{!isHospital}" id="visitor1" onchange="clearVisitorId('visitor1Id');" onClick="searchVisitor2(value);" style="width:30%"/>
        <apex:inputHidden id="visitor1Id" value="{!targetEvent.Visitor1_ID__c}" rendered="{!isHospital}"/>
        
        <apex:inputText label=" " value="{!targetEvent.Visitor2__c}" rendered="{!isHospital}" id="visitor2" onchange="clearVisitorId('visitor2Id');" onClick="searchVisitor2(value);" style="width:30%"/>
        <apex:inputHidden id="visitor2Id" value="{!targetEvent.Visitor2_ID__c}" rendered="{!isHospital}"/>
        
        <apex:inputText label=" " value="{!targetEvent.Visitor3__c}" rendered="{!isHospital}" id="visitor3" onchange="clearVisitorId('visitor3Id');" onClick="searchVisitor2(value);" style="width:30%"/>
        <apex:inputHidden id="visitor3Id" value="{!targetEvent.Visitor3_ID__c}" rendered="{!isHospital}"/> -->
        
       <!--  <apex:inputText label=" " value="{!targetEvent.Visitor4__c}" rendered="{!isHospital}" id="visitor4" onchange="clearVisitorId('visitor4Id');" onClick="searchVisitor2(value);"/>
        <apex:inputHidden id="visitor4Id" value="{!targetEvent.Visitor4_ID__c}" rendered="{!isHospital}"/>
        
        <apex:inputText label=" " value="{!targetEvent.Visitor5__c}" rendered="{!isHospital}" id="visitor5" onchange="clearVisitorId('visitor5Id');" onClick="searchVisitor2(value);"/>
        <apex:inputHidden id="visitor5Id" value="{!targetEvent.Visitor5_ID__c}" rendered="{!isHospital}"/>
         -->
          
        <!-- <apex:pageblockSectionItem rendered="{!IF(targetEvent.Activity_Type2__c == '病院', false, true)}"> -->
        <!-- <apex:inputfield value="{!targetEvent.Purpose_TypeFSE__c}"  rendered="{!IF(LoginUser.Job_Category__c == '销售服务', 'true', 'false')}"/>
        <apex:inputfield value="{!targetEvent.Purpose_TypeEscFSE__c}" rendered="{!IF(LoginUser.Job_Category__c != '销售服务', 'true', 'false')}"/>
        <apex:pageblockSectionItem /> -->
        
        <!-- <apex:pageblockSectionItem />
        <apex:pageblockSectionItem /> -->
        
        <!-- <apex:inputField label="{!$Label.Involved}{!$Label.Opportunity}" value="{!targetEvent.Related_Opportunity1__c}" rendered="{!isHospital || isAgent}" id="opportunity" onFocus="setSuggestOpportunity();" onchange="resetValue('page:form:all:visitSettings:opportunity');"/> -->
        <!-- <apex:pageblockSectionItem rendered="{!isAgent}"/>
        <apex:inputField label="{!$Label.Involved}{!$Label.Service_Agreement}" value="{!targetEvent.Related_Service1__c}" rendered="{!isHospital}" id="contract" onFocus="setSuggestContract();" onchange="resetValue('page:form:all:visitSettings:contract');"/> -->
        <!-- Opportunity2-5 -->
        <!-- <apex:inputField label=" " value="{!targetEvent.Related_Opportunity2__c}" rendered="{!isHospital || isAgent}" id="opportunity2" onFocus="setSuggestOpportunity2();" onchange="resetValue('page:form:all:visitSettings:opportunity2');"/>
        <apex:pageblockSectionItem rendered="{!isHospital || isAgent}"/>
        <apex:inputField label=" " value="{!targetEvent.Related_Opportunity3__c}" rendered="{!isHospital || isAgent}" id="opportunity3" onFocus="setSuggestOpportunity3();" onchange="resetValue('page:form:all:visitSettings:opportunity3');"/>
        <apex:pageblockSectionItem rendered="{!isHospital || isAgent}"/> -->
        <!-- <apex:inputField label=" " value="{!targetEvent.Related_Opportunity4__c}" rendered="{!isHospital || isAgent}" id="opportunity4" onFocus="setSuggestOpportunity4();" onchange="resetValue('page:form:all:visitSettings:opportunity4');"/>
        <apex:pageblockSectionItem rendered="{!isHospital || isAgent}"/>
        <apex:inputField label=" " value="{!targetEvent.Related_Opportunity5__c}" rendered="{!isHospital || isAgent}" id="opportunity5" onFocus="setSuggestOpportunity5();" onchange="resetValue('page:form:all:visitSettings:opportunity5');"/>
        <apex:pageblockSectionItem rendered="{!isHospital || isAgent}"/> -->
        
        <apex:inputHidden value="{!targetEvent.Related_Opportunity1_ID__c}" rendered="{!isHospital || isAgent}" id="opportunityId"/>
        <apex:inputHidden value="{!targetEvent.Related_Service1_ID__c}" rendered="{!isHospital}" id="contractId"/>
        <apex:inputHidden value="{!targetEvent.Related_Opportunity1__c}" rendered="{!isHospital || isAgent}" id="opportunityHidden"/>
        <apex:inputHidden value="{!targetEvent.Related_Service1__c}" rendered="{!isHospital}" id="contractHidden"/>
        <apex:inputHidden value="{!targetEvent.Related_Opportunity1_ID__c}" rendered="{!isHospital || isAgent}" id="opportunityHiddenId"/>
        <apex:inputHidden value="{!targetEvent.Related_Service1_ID__c}" rendered="{!isHospital}" id="contractHiddenId"/>
        <!-- Opportunity2-5 -->
        <apex:inputHidden value="{!targetEvent.Related_Opportunity2_ID__c}" rendered="{!isHospital || isAgent}" id="opportunity2Id"/>
        <apex:inputHidden value="{!targetEvent.Related_Opportunity2__c}" rendered="{!isHospital || isAgent}" id="opportunity2Hidden"/>
        <apex:inputHidden value="{!targetEvent.Related_Opportunity2_ID__c}" rendered="{!isHospital || isAgent}" id="opportunity2HiddenId"/>

        <!-- <apex:inputHidden value="{!targetEvent.Related_Opportunity3_ID__c}" rendered="{!isHospital || isAgent}" id="opportunity3Id"/>
        <apex:inputHidden value="{!targetEvent.Related_Opportunity3__c}" rendered="{!isHospital || isAgent}" id="opportunity3Hidden"/>
        <apex:inputHidden value="{!targetEvent.Related_Opportunity3_ID__c}" rendered="{!isHospital || isAgent}" id="opportunity3HiddenId"/> -->
        <apex:inputHidden value="{!targetEvent.Related_Opportunity4_ID__c}" rendered="{!isHospital || isAgent}" id="opportunity4Id"/>
        <apex:inputHidden value="{!targetEvent.Related_Opportunity4__c}" rendered="{!isHospital || isAgent}" id="opportunity4Hidden"/>
        <apex:inputHidden value="{!targetEvent.Related_Opportunity4_ID__c}" rendered="{!isHospital || isAgent}" id="opportunity4HiddenId"/>
        <apex:inputHidden value="{!targetEvent.Related_Opportunity5_ID__c}" rendered="{!isHospital || isAgent}" id="opportunity5Id"/>
        <apex:inputHidden value="{!targetEvent.Related_Opportunity5__c}" rendered="{!isHospital || isAgent}" id="opportunity5Hidden"/>
        <apex:inputHidden value="{!targetEvent.Related_Opportunity5_ID__c}" rendered="{!isHospital || isAgent}" id="opportunity5HiddenId"/>
    </apex:pageblockSection>
 
     <apex:pageBlockButtons >
        <apex:commandButton value="保存" rerender="all,msgs" action="{!save}" onclick=" blockme();" oncomplete="unblockUI();disablePurpose();" />
        <apex:commandButton value="保存并新建" rerender="all,msgs" action="{!saveAndNew}" onclick=" blockme(); disablePurpose();"  oncomplete="unblockUI();"/>
        <apex:commandButton value="取消" action="{!doCancel}" onclick="blockme();" oncomplete="unblockUI();" immediate="true"/>
     </apex:pageBlockButtons>
    
</apex:pageBlock>
</apex:form>

</apex:page>