<!-- 20230619 ljh  -->
<!-- <apex:page controller="RentalApplyMultiPostponeController"  action="{!init}"  showHeader="false"   sidebar="true" id="allPage"  title="批量延期"> -->
<apex:page controller="RentalApplyMultiPostponeController"  action="{!init}"  showHeader="false"   sidebar="true" id="allPage"  title="批量延期" 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.CommonUtilJs)}"/>
    <apex:stylesheet value="{!URLFOR($Resource.StyleUtilCss)}"/><!-- 20230619 ljh lightning  -->
    <script type="text/javascript">
        //onload 的方法
        window.onload = function(){

        }
        //保存按钮
    	function searchBtnJs(){
            var checkId = '';
            //获取勾选的值
            var lawtable = document.getElementById("tableHeader_L");//获取id为tableHeader_L的table
            var rows = lawtable.rows;//获取所有行 
            if(rows != null && rows.length > 1){
                for(var i=1; i < rows.length; i++){
                    var row = rows[i].cells[0].getElementsByTagName("input")[0];
                    if(row.checked){
                        //value的值为 canCheck 证明此条申请单是可以延期的
                        if(row.value == 'canCheck' && row.id != null && row.id != ''){
                            if(checkId == ''){
                                checkId = row.id;
                            }else{
                                checkId += ','+row.id;
                            }
                        }
                    }
                }
            }
            if(checkId == ''){
                alert('至少必须勾选一个申请单。');
                return false;
            }else{
                //跳转到具体延期画面（原延期页面）
                window.open("/apex/RentalApplyExtensions?parentId="+checkId+'&entranceId={!parentId}');
            }
    	}
        //返回按钮
    	function sendBackJs(){
            senBackPage();
    	}
    	//全选
    	function checkAll(){
            var lawtable = document.getElementById("tableHeader_L");//获取id为tableHeader_L的table
            var rows = lawtable.rows;//获取所有行 
            if(rows != null && rows.length > 1){
            	//判断是需要把所有的勾选上还是全部去掉勾选
            	var trueOrfalse = rows[0].cells[0].getElementsByTagName("input")[0].checked == false?false:true;
	            for(var i=0; i < rows.length; i++){
                    //判断是否可以勾选，备品状态：取消，删除，已延期，不可以勾选
                    if(!rows[i].cells[0].getElementsByTagName("input")[0].disabled){
                        rows[i].cells[0].getElementsByTagName("input")[0].checked = trueOrfalse;
                    }
	            }
            }
        }
    </script>
    <apex:form id="allForm">
        <!-- 返回父页面 -->
        <apex:actionFunction name="senBackPage" action="{!senBackPage}" rerender="true" onComplete="unblockUI();"></apex:actionFunction>
    	<apex:pageBlock id="searchBlock" tabStyle="Report">
            <!-- 20230619 ljh start-->
    		<!-- <table style="border-bottom-width: 0px; font-size:12px;width:100%;margin-left: 40%;"> -->
            <table style="border-bottom-width: 0px; font-size:12px;margin-left: 40%;">
            <!-- 20230619 ljh end-->
                <tr>
                    <td style="width: 20%">
                        <apex:commandButton onclick="searchBtnJs();return false;"  rendered="true" value="下一步" style="width:70px;"/>
                        &nbsp;&nbsp;
                        <apex:commandButton onclick="sendBackJs();return false;"  rendered="true" value="返回" style="width:60px;"/>
                    </td>
                </tr>
            </table>
    	</apex:pageBlock>
    	<apex:pageBlock id="oppBlock1" tabStyle="Report">
    		<apex:pageblocksection title="选择延期申请单" id="edmpdDetails" rendered="true" columns="1" >
    			<apex:outputPanel rendered="{!IF(tableData.size > 0, true, false)}">
    				<table class="list" style="border-bottom-width: 0px; font-size:11px; border-spacing:0;" border="" id="tableHeader_L" >
                        <thead>
                            <tr class="headerRow" height="30px"  align="center">
                                <!--标题 -->
                                <td style="">
                                	<input  type="checkbox"  class="rowchkcls" onchange="checkAll()" />
                                </td>
                                <td style="">申请单No.</td>
                                <td style="">使用目的2</td>
                                <td style="">最新预定归还日</td>
                                <td style="">科室</td>
                                <td style="">分单理由</td>
                                <td style="">备品借出状态</td>
                            </tr>
                        </thead>
                        <tbody>
                        	<apex:variable value="{!0}" var="cnt" />
                            <apex:repeat value="{!tableData}" var="or" id="oppTable">
                            	<tr class="dataRow {!IF(MOD(cnt, 2)==0, 'odd', 'even')} {!IF(cnt==1, 'first', '')}" onmouseover="if (window.hiOn){hiOn(this);} " onmouseout="if (window.hiOff){hiOff(this);} "  onblur="if (window.hiOff){hiOff(this);}" onfocus="if (window.hiOn){hiOn(this);}" >
                            		<td align="center" style="vertical-align: inherit;width:25px;border-width: 0px 1px 1px 0px;" >
                                        <apex:outputPanel rendered="{!if( or.canCheck , 'true','false')}" > 
                                            <input type="checkbox" value="canCheck" id="{!or.rentalApplyTable.Id}" class="rowchkcls" />
                                        </apex:outputPanel>
                                        <apex:outputPanel rendered="{!if( or.canCheck , 'false','true')}" > 
                                            <input type="checkbox" value="canNotCheck" id="{!or.rentalApplyTable.Id}" class="rowchkcls" disabled="disabled" />
                                        </apex:outputPanel>
                                    </td>
                                    <td align="center" style="vertical-align: inherit;border-width: 0px 1px 1px 0px;">
                                    	<a href="/{!or.rentalApplyTable.id}" target="{!$Label.rental_link}">
											<span id="allPage:allForm:cmpid:cmpinnerid:dataBlock:oppTable_L:0:j_id109:0:j_id114">{!or.rentalApplyTable.name}</span>
										</a>
                                    </td>
                                    <td align="center" style="vertical-align: inherit;border-width: 0px 1px 1px 0px;">
                                        <apex:outputText value="{!or.rentalApplyTable.demo_purpose2__c}" />
                                    </td>
                                    <td align="center"  style="vertical-align: inherit;border-width: 0px 1px 1px 0px;">
                                        <apex:outputField value="{!or.rentalApplyTable.Return_dadeline_final__c}" />
                                    </td>
                                    <td align="center"  style="vertical-align: inherit;border-width: 0px 1px 1px 0px;">
                                        <apex:outputText value="{!or.rentalApplyTable.Account__r.Name}" />
                                    </td>
                                    <td align="center"  style="vertical-align: inherit;border-width: 0px 1px 1px 0px;">
                                        <apex:outputText value="{!or.rentalApplyTable.Split_Apply_Reason__c}" />
                                    </td>
                                    <td align="center"  style="vertical-align: inherit;border-width: 0px 1px 1px 0px;">
                                        <apex:outputText value="{!or.rentalApplyTable.RA_Status__c}" />
                                    </td>
                            	</tr>
                            <apex:variable value="{!cnt + 1}" var="cnt" />
                            </apex:repeat>
                        </tbody>
                    </table>
    			</apex:outputPanel>
                <apex:outputPanel rendered="{!IF(tableData.size > 0, false, true)}">
                    <font style="color:red;font-size: 14px;">无任何申请单满足延期</font>
                </apex:outputPanel>
    		</apex:pageblocksection>
    	</apex:pageBlock>
    </apex:form>
</apex:page>