<apex:page standardcontroller="Instruct_report__c" extensions="InstructReportController" sidebar="false"  id="allPage" action="{!init}" title="{!IF(Instruct_report!=null, Instruct_report.Name, '带教报告')}" lightningStylesheets="true" >

    <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
    <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
    <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
    <apex:includeScript value="{!URLFOR($Resource.apex20)}"/>
    <!-- <apex:includeScript value="{!URLFOR($Resource.OpportunityPCLJs)}"/> -->
    <!-- 20220222 PI改造 by Bright--start -->
    <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" />
    <apex:includeScript value="{!URLFOR($Resource.connection20)}"/>
    <!-- 20220222 PI改造 by Bright--end -->
    
    <style type="text/css">
        [aws-api] {
            position: relative;
        }
        [aws-api] .decrypt{position: absolute;top: 0;left: 100%;display: none;text-align: left;
            padding-left: 5px;}
        [aws-api]:hover .decrypt{display: block;width: 100px}
    </style>
    <script type="text/javascript">
        
        function init() {
        }
        // 20220222 PI改造 by Bright--start
        AWSService.sfSessionId = '{!GETSESSIONID()}';
        var staticResource = JSON.parse('{!staticResource}');
        var aws_data = {};

        function Decrypt(dataIds){
            let Foo = function(){
                for (const id of dataIds) {
                    if (aws_data.hasOwnProperty(id)) {
                        let d = aws_data[id];
                        let $e =j$("[aws-id='"+d.dataId+ "']");
                        $e.find(".decrypt").html(d[$e.attr("aws-api")]);
                    }
                }
            }
            let ids = [];
            for (const id of dataIds) {
                if (!aws_data.hasOwnProperty(id)) {
                    ids.push(id);
                }
            }
            if (ids.length > 0) {
                blockme();
                AWSService.search(staticResource.searchUrl,JSON.stringify({
                    "dataIds":ids
                }),function(data){
                    unblockUI();
                    if(data.object && data.object.length > 0){
                        
                        for(let d of data.object){
                            if(d.dataId){
                                aws_data[d.dataId] = d;
                            }
                        }
                        Foo();
                    }
                },staticResource.token);
            }else{
                Foo();
            }
        }

        function DecryptAll(){
            let dataIds = [];
            j$("[aws-id]").each((i,e)=>{
                let v = j$(e).attr('aws-id');
                if (v) {
                    dataIds.push(v);
                }
            });
            Decrypt(dataIds);
        }

        j$(function(){
            DecryptAll();
            
        })
        // 20220222 PI改造 by Bright--end

        function checkAll(checker) {
             var cnt = j$(escapeVfId('allPage:allForm:allBlock:'+checker.alt+':memberCnt')).val();
             for (var i = 0; i < cnt; i++) {
                //alert('allPage:allForm:allBlock:InstructedStaff:theTable_content:0:rec_checkBox');
                //alert('allPage:allForm:allBlock:'+checker.id+':theTable_content:' + i + ':rec_checkBox');
                document.getElementById('allPage:allForm:allBlock:'+checker.alt+':theTable_content:' + i + ':rec_checkBox').checked = checker.checked;
            }
        }
    </script>
    <body onload="init()">
    <apex:form id="allForm">

        <apex:pageBlock title="{!IF(Instruct_report!=null && Instruct_report.Name !=null, Instruct_report.Name, '带教报告')}" id="allBlock">
            <apex:pageBlockButtons id="blocktop" >
                <apex:commandButton action="{!EditRecord}" style="float:center;" onclick="blockme();" oncomplete="unblockUI();"  rendered="{!Inputdisabled}"  disabled="{!If((Instruct_report.Status__c = '草案中' || Instruct_report.Status__c = '不批准')
                && not(IsServiceDesignDep) , false, true)}" rerender="allForm" value="编辑"/>
                <apex:commandButton action="{!save}" style="float:center;" onclick="blockme();" oncomplete="unblockUI();" rerender="allForm" disabled="{!Inputdisabled}" value="保存"/>
                <apex:commandButton action="{!EditRecord}" style="float:center;" onclick="blockme();" oncomplete="unblockUI();"   rendered="{!Not(Inputdisabled)}" rerender="allForm" value="取消"/>
                <apex:commandButton action="{!submit}" style="float:center;" onclick="blockme();" oncomplete="unblockUI();" disabled="{!If(Instruct_report.Status__c = '草案中' && not(IsServiceDesignDep) , false, true)}" rerender="allForm" value="保存并提交审批"/> 
                
                 <apex:commandButton action="{!cancel}" style="float:right;" onclick="blockme();" oncomplete="unblockUI();" rerender="allForm" value="不保存（返回）"/>
                <apex:commandButton action="{!saveAndCancel}" onclick="blockme();" oncomplete="unblockUI();" style="float:right;" disabled="{!Inputdisabled}" rerender="allForm" value="保存（返回）"/>
            </apex:pageBlockButtons>
            <apex:pageMessages id="pageMessages1"></apex:pageMessages>
            <apex:pageBlockSection id="BasicInformation" title="基本信息" columns="2" >
                <apex:inputField id="instructStaff"  rendered="{!Not(Inputdisabled)}" label="带教人 :" value="{!Instruct_report.Instruct_Staff__c}"/>
                <apex:outputField id="instructStaff_Output"  rendered="{!Inputdisabled}" label="带教人 :" value="{!Instruct_report.Instruct_Staff__c}"/>                
                <apex:outputText id="ReportCode" label="报告编码:" value="{!Instruct_report.Report_Code__c}"/>
                <apex:outputText id="InstructedStaffNumber" label="被带教人数 :" value="{!Instruct_report.Instructed_staff_number__c}"/>
                <apex:outputText id="Stage" label="审批状态:" value="{!Instruct_report.Status__c}"/>
                <apex:outputField id="ReportDate" label="报告日期:" value="{!Instruct_report.ReportDate__c}"/>
                <apex:outputfield id="teachingDate" label="带教日期:" value="{!Instruct_report.teachingDate__c}"/>
            </apex:pageBlockSection>
        <apex:pageblocksection columns="1" title="带教人员" id="InstructedStaff">
            <apex:outputPanel >
            <DIV style="OVERFLOW-Y: hidden; OVERFLOW-X:auto;width:1260px">
            <!-- <div> -->
                <table id="theTable_header"    style ="width:3500px;text-align: center;"   styleClass="list">
                    <thead>
                        <tr>
                            <th style="width:1%"><input alt='InstructedStaff' type='checkbox' id = 'allPage:allForm:allBlock:InstructedStaff:theTable_header:rec_checkBox' onClick="checkAll(this)"/></th>
                            <!-- 带教日期 -->
                            <td style ="width: 6%" scope="col">带教日期</td>
                            <!-- 带教人 -->
                            <td style ="width: 2%" scope="col">带教人</td>
                            <!-- 被带教人 -->
                            <td style ="width: 2%" scope="col">被带教人</td>
                            <!-- 客户名 -->
                            <td style ="width: 7%;" scope="col">客户名</td>
                            <!-- 带教地点 -->
                            <td style ="width: 11%" scope="col">带教地点</td>
                            <!-- 带教地点（其他） -->
                            <td style ="width: 7%" scope="col">带教地点(其它)</td>
                            <!-- 设备类别 -->
                            <td style ="width: 18%" scope="col">类别</td>
                            <!-- 具体型号 -->
                            <td style ="width: 5%" scope="col">具体型号</td>
                            <!-- 带教内容 -->
                            <td style ="width: 14%" scope="col">带教内容</td>
                            <!-- 带教内容（其他） -->
                            <td style ="width: 5%" scope="col">具体内容</td>
                            <!-- 带教时长 -->
                            <td style ="width: 4%" scope="col">带教时长(H)</td>
                            <!-- 带教者意见建议 -->
                            <td style ="width: 4%" scope="col">带教者意见建议</td>
                            <!-- 被带教者反馈 -->
                            <td style ="width: 4%" scope="col">被带教者反馈</td>
                            <!-- 备注 -->
                            <td style ="width: 5%" scope="col">备注</td>
                             <!-- 确认人职位 -->
                            <td style ="width: 3%" scope="col">确认人职位 </td>
                             <!-- 确认人姓名 -->
                            <td style ="width: 3%" scope="col">确认人姓名</td>
                        </tr>
                    </thead>
                </table>
                <!-- <div id="InstructedStaff:tablediv" style="overflow:auto;width:1800px; height:200px"> -->
                <div id="InstructedStaff:tablediv" style="OVERFLOW-X: hidden; OVERFLOW-Y:auto;width:3500px; height:200px">
                    <input type="hidden" id="allPage:allForm:allBlock:InstructedStaff:memberCnt" value="{!CheckedCnt}" />
                    <apex:dataTable value="{!checkedISList}" var="checkedIS" id="theTable_content" border="0" 
                    style="width:3500px;border-bottom-width: 0px; font-size:11px; border-spacing:0;" styleClass="list">
                        <apex:column style="width: 1%">
                             <apex:inputCheckbox id="rec_checkBox" value="{!checkedIS.rec_checkBox}"/>
                        </apex:column>
                        <!-- 带教日期 -->
                        <apex:column style="width: 6%">
                            <apex:inputField rendered="{!Not(Inputdisabled)}"  style="resize:vertical;width: 44%" id="Instruct_Date__c" value="{!checkedIS.IS.Instruct_Date__c}"/>

                            <apex:outputField rendered="{!Inputdisabled}" style="resize:vertical;width: 95%" id="Instruct_Date__output" value="{!checkedIS.IS.Instruct_Date__c}"/>
                        </apex:column>
                        <!-- 带教人 -->
                        <apex:column style="width: 2%">
                        <apex:outputField value="{!Instruct_report.Instruct_Staff__c}" />
                        </apex:column>
                        <!-- 被带教人 -->
                        <apex:column style="width: 2%">
                        <apex:outputLink html-aws-api="lastName" html-aws-id="{!checkedIS.IS.ContactID__r.AWS_Data_Id__c}" style="resize:vertical;width: 95%" id="Name" value="/{!checkedIS.CamMem.Contact_ID__c}" target="LINK_{!checkedIS.CamMem.Contact_ID__c}">
                            <!-- 20220222 PI改造 by Bright--start -->
                            <span class="encrypt">{!checkedIS.IS.Name}</span>
                            <span class="decrypt"></span>
                            <!-- 20220222 PI改造 by Bright--end -->
                        </apex:outputLink>
                        </apex:column>
                        <!-- 客户名 -->
                        <!-- 增加无效科室红色提醒 精琢技术 wql 2021/02/04 start -->
                        <apex:column style="width: 7%;">
                            <apex:variable value="Society" var="Society" rendered="{!IF(checkedIS.IS.Is_Active_Formula__c == '无效' || checkedIS.CamMem.Is_Active_Formula__c == '无效' ,true,false)}">
                                    <apex:inputHidden id="ProductActive" value="{!checkedIS.IS.Is_Active_Formula__c}"/>
                                    <div id= "Department1Div" style="background-color: red;">
                                        <apex:outputField id="Department1" value="{!checkedIS.IS.Department__c}" />
                                    </div>
                            </apex:variable>
                            <apex:variable value="Society" var="Society" rendered="{!IF(checkedIS.IS.Is_Active_Formula__c == '无效' || checkedIS.CamMem.Is_Active_Formula__c == '无效' ,false,true)}">
                                    <apex:inputHidden id="ProductActive1" value="{!checkedIS.IS.Is_Active_Formula__c}"/>
                                    <apex:outputField id="Department1" value="{!checkedIS.IS.Department__c}" />
                                    
                            </apex:variable>
                        </apex:column>
                        <!-- <apex:column style="width: 7%">
                            <apex:outputField id="Department1" value="{!checkedIS.IS.Department__c}" />
                        </apex:column> -->
                        <!-- 增加无效科室红色提醒 精琢技术 wql 2021/02/04 end -->
                        <!-- 带教地点 -->
                        <apex:column style="width: 11%">
                        <apex:inputField rendered="{!Not(Inputdisabled)}" style="resize:vertical;width: 95%" id="Instruct_place__c" value="{!checkedIS.IS.Instruct_place__c}"/>
                        <apex:outputField rendered="{!Inputdisabled}" style="resize:vertical;width: 95%" id="Instruct_place__output" value="{!checkedIS.IS.Instruct_place__c}"/>
                        </apex:column>
                        <!-- <apex:column style="width: 15%">
                        <apex:inputField rendered="{!Not(Inputdisabled)}" style="resize:vertical;width: 95%" id="Instruct_place_Test__c" value="{!checkedIS.IS.Instruct_place_Test__c}"/>
                        <apex:outputField rendered="{!Inputdisabled}" style="resize:vertical;width: 95%" id="Instruct_place__output" value="{!checkedIS.IS.Instruct_place_Test__c}"/>
                        </apex:column> -->
                        <!-- 带教地点(其他) -->
                        <apex:column style="width: 7%">
                        <apex:inputTextarea disabled="{!Inputdisabled}" rows="3" style="resize:vertical;width: 95%" id="Instruct_place_other__c" value="{!checkedIS.IS.Instruct_place_other__c}"/>
                        </apex:column>
                        <!-- 设备类别 -->
                        <apex:column style="width: 18%">
                        <apex:inputField rendered="{!Not(Inputdisabled)}" style="resize:vertical;width: 95%" id="Equipment_category__c" value="{!checkedIS.IS.Equipment_category__c}"/>
                        <apex:outputField rendered="{!Inputdisabled}" style="resize:vertical;width: 95%" id="Equipment_category__c__output" value="{!checkedIS.IS.Equipment_category__c}"/>
                        </apex:column>
                        <!-- 具体型号 -->
                        <apex:column style="width: 5%">
                        <apex:inputTextarea disabled="{!Inputdisabled}" rows="3" style="resize:vertical;width: 95%" id="Specific_model__c" value="{!checkedIS.IS.Specific_model__c}"/>
                        </apex:column>
                        <!-- 带教内容 -->
                        <apex:column style="width: 14%">
                            <apex:inputField rendered="{!Not(Inputdisabled)}" style="resize:vertical;width: 95%" id="Instruct_content__c" value="{!checkedIS.IS.Instruct_content__c}"/>
                            <apex:outputField rendered="{!Inputdisabled}" style="resize:vertical;width: 95%" id="Instruct_content__output" value="{!checkedIS.IS.Instruct_content__c}"/>
                        </apex:column>
                        <!-- 带教内容（其他） -->
                        <apex:column style="width: 5%">
                            <apex:inputTextarea disabled="{!Inputdisabled}" rows="3" style="resize:vertical;width: 95%" id="Instruct_content_other__c" value="{!checkedIS.IS.Instruct_content_other__c}"/>
                        </apex:column>
                        <!-- 带教时长 -->
                        <apex:column style="width: 4%">
                            <apex:inputField rendered="{!Not(Inputdisabled)}" style="resize:vertical;width: 95%" id="Instruct_time__c" value="{!checkedIS.IS.Instruct_time__c}"/>
                            <apex:outputField rendered="{!Inputdisabled}" style="resize:vertical;width: 95%" id="Instruct_time__output" value="{!checkedIS.IS.Instruct_time__c}"/>
                        </apex:column>
                        <!-- 带教者意见建议-->
                        <apex:column style="width: 4%">
                            <apex:inputTextarea disabled="{!Inputdisabled}"  rows="3" style="resize:vertical;width: 95%" id="Instruct_staff_feedback__c" value="{!checkedIS.IS.Instruct_staff_feedback__c}"/>
                        </apex:column>
                        <!-- 被带教者反馈 -->
                        <apex:column style="width: 4%">
                            <apex:inputTextarea disabled="{!Inputdisabled}" rows="3" style="resize:vertical;width: 95%" id="Instructed_staff_feedback__c" value="{!checkedIS.IS.Instructed_staff_feedback__c}"/>
                        </apex:column>
                        <!-- 备注 -->
                        <apex:column style="width: 5%">
                        <apex:inputTextarea disabled="{!Inputdisabled}" rows="3" style="resize:vertical;width: 95%" id="Instruct_remarks__c" value="{!checkedIS.IS.Instruct_remarks__c}"/>
                        </apex:column>
                          <!-- 确认人职位 -->
                        <apex:column style="width: 3%">
                            <apex:inputField rendered="{!Not(Inputdisabled)}" style="resize:vertical;width: 95%" id="Verifier__c" value="{!checkedIS.IS.Verifier__c}"/>
                            <apex:outputField rendered="{!Inputdisabled}" style="resize:vertical;width: 95%" id="Verifier__output" value="{!checkedIS.IS.Verifier__c}"/>
                        </apex:column>
                          <!-- 确认人姓名 -->
                        <apex:column style="width: 3%">
                        <apex:inputTextarea disabled="{!Inputdisabled}" rows="3" style="resize:vertical;width: 95%" id="VerifierName__c" value="{!checkedIS.IS.VerifierName__c}"/>
                        </apex:column>

                        
                    </apex:dataTable>
                </div>
            </div>
            </apex:outputPanel>
        </apex:pageblocksection>



        <apex:pageblocksection rendered="{!Not(Inputdisabled)}"  columns="1" title="参会名单" id="Campaign_members">
            <apex:outputPanel id="sumPanel">
                <table style="width:100%;">
                    <tr>
                        <td>
                            <apex:commandButton value="刷新选中的参会人员"  action="{!exchangeInstructedstaff}" onclick="blockme();" oncomplete="unblockUI();DecryptAll();" rerender="allPage:allForm:allBlock:InstructedStaff,allPage:allForm:allBlock:Campaign_members" />
                        </td>
                    </tr>
                </table>
            </apex:outputPanel>
            <br/>
            <apex:outputPanel >
                <table id="theTable_header"    style ="width: 98.5%;"   styleClass="list">
                    <thead>
                        <tr>
                            <th style="width:3%"><input alt='Campaign_members' type='checkbox' id = 'InstructReportallPage:allForm:allBlock:Campaign_members:theTable_header:rec_checkBox' onClick="checkAll(this)"/></th>
                            <td style ="width: 25%;text-align: center;" scope="col">医院科室</td>
                            <td style ="width: 10%" scope="col">姓名</td>
                            <td style ="width: 10%" scope="col">本部</td>
                            <td style ="width: 10%" scope="col">省</td>
                            <td style ="width: 10%" scope="col">市</td>
                        </tr>
                    </thead>
                </table>
                <div id="Campaign_members:tablediv" style="overflow:auto; width:100%; height:200px">
                    <input type="hidden" id="allPage:allForm:allBlock:Campaign_members:memberCnt" value="{!unCheckedCnt}" />
                    <apex:dataTable value="{!uncheckedISList}" var="uncheckedIS" id="theTable_content" border="0" 
                    style="width:99%;border-bottom-width: 0px; font-size:11px; border-spacing:0;" styleClass="list">
                        <apex:column style="width: 1%">
                             <apex:inputCheckbox id="rec_checkBox" value="{!uncheckedIS.rec_checkBox}"/>
                        </apex:column>
                        <!-- LJPH-BVNBMM start 显示当前联系人所在科室-->
                        <apex:column style="width: 25%">
                            <apex:outputField id="Department" value="{!uncheckedIS.CamMem.Contact_ID__r.AccountId}" />
                         <!-- LJPH-BVNBMM end -->

                        </apex:column>
                        <apex:column style="width: 10%">
                        <!-- LJPH-BVNBMM 显示当前联系人名称- start -->
                        <apex:outputLink html-aws-api="lastName" html-aws-id="{!uncheckedIS.CamMem.Contact_ID__r.AWS_Data_Id__c}" style="resize:vertical;width: 95%" id="Name" value="/{!uncheckedIS.CamMem.Contact_ID__c}" target="LINK_{!uncheckedIS.CamMem.Contact_ID__c}">
                        <!-- 20220222 PI改造 by Bright--start -->
                        <span class="encrypt">{!uncheckedIS.CamMem.ContactName__c}</span>
                        <span class="decrypt"></span>
                        <!-- 20220222 PI改造 by Bright--end -->
                        </apex:outputLink>
                        </apex:column>
                        <!-- LJPH-BVNBMM end -->
                        <apex:column style="width: 10%">
                            <apex:outputtext style="resize:vertical;width: 95%" id="Salesdept" value="{!uncheckedIS.CamMem.dept__c}"/>
                        </apex:column>
                        <apex:column style="width: 10%">
                            <apex:outputtext style="resize:vertical;width: 95%" id="State" value="{!uncheckedIS.CamMem.State__c}"/>
                        </apex:column>
                        <apex:column style="width: 10%">
                            <apex:outputtext style="resize:vertical;width: 95%" id="City" value="{!uncheckedIS.CamMem.City__c}"/>
                        </apex:column>
                    </apex:dataTable>
                </div>
            </apex:outputPanel>
 
        </apex:pageblocksection>

       <!--  <apex:pageblocksection columns="1" title="信息确认" id="Information_Confirm">
            <apex:inputField id="Verifier" rendered="{!Not(Inputdisabled)}" label="确认人职位 :" value="{!Instruct_report.Verifier__c}"/>
            <apex:outputField id="Verifier_Output" rendered="{!Inputdisabled}" label="确认人职位 :" value="{!Instruct_report.Verifier__c}"/>
            <apex:inputField id="VerifierName" rendered="{!Not(Inputdisabled)}" label="确认人姓名 :" value="{!Instruct_report.VerifierName__c}"/>
            <apex:outputField id="VerifierName_Output" rendered="{!Inputdisabled}" label="确认人姓名 :" value="{!Instruct_report.VerifierName__c}"/> -->
           <!--  <apex:inputField id="VerifierNumber" rendered="{!Not(Inputdisabled)}" label="确认人电话 :" value="{!Instruct_report.VerifierNumber__c}"/>
            <apex:outputField id="VerifierNumber_Output" rendered="{!Inputdisabled}" label="确认人电话 :" value="{!Instruct_report.VerifierNumber__c}"/>  -->
       <!--  </apex:pageblocksection> -->
            <apex:pageMessages id="pageMessages2"></apex:pageMessages>
        </apex:pageBlock>

    </apex:form>
     
    </body>
</apex:page>