<apex:page Controller="SaleOrderController" showHeader="true" tabStyle="SaleAndDelivery__tab" sidebar="true" action="{!init}" id="allPage">
<apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
<apex:includeScript value="{!URLFOR($Resource.CommonUtilJs)}"/>
<script>
function saveJs() {
    blockme();
    ProSale();
}
function searchProductJs() {
    blockme();
    SearchPro();
}
function SaveE(){
    blockme();
    ProdElivery();
}

function SaveP(){
    blockme();
    ProSale();
}

window.sfdcPage.appendToOnloadQueue(function() { calonLoad() });

</script>
<apex:form id="allForm">
        <apex:actionFunction name="SearchPro" action="{!SearchPro}" rerender="ConsumableorderdetailsSection,ConsumableorderdetailsSection1, message" onComplete="unblockUI();">
        </apex:actionFunction>
        <apex:actionFunction name="ProSale" action="{!ProSale}" rerender="ConsumableorderdetailsSection,ConsumableorderdetailsSection1, message" onComplete="unblockUI();">
        </apex:actionFunction>
         <apex:actionFunction name="ProdElivery" action="{!ProdElivery}" rerender="ConsumableorderdetailsSection,ConsumableorderdetailsSection1, message" onComplete="unblockUI();">
        </apex:actionFunction>
        <apex:outputPanel id="allPanel">
            <apex:pageBlock title="出货管理" id="allBlock">
             <apex:pageBlockButtons >
                    <apex:commandButton onclick="SaveP();"  value="销售" rerender="dummy" style="width: 150px;" rendered="{!IF(coc.Summons_Order_type__c='销售',true,false)}"/>
                    <apex:commandButton onclick="SaveE();"  value="出货" rerender="dummy" style="width: 150px;" rendered="{!IF(coc.Summons_Order_type__c='销售',false,true)}"/>
                </apex:pageBlockButtons>
                 <apex:outputPanel id="message">
                    <apex:pageMessages />
                 </apex:outputPanel>
            <apex:pageBlock rendered="{!IF(ESetId !='', true, false)}" title="出库单信息">
                    <table>
                    <colgroup>
                            <col width="120px"/>
                            <col width="130px"/>
                            <col width="100px"/>
                            <col width="120px"/>
                            <col width="120px"/>
                            <col width="120px"/>
                            <col width="120px"/>
                            <col width="120px"/>

                                    <col width="150px"/>
                        </colgroup>
                        <tr>
                            <td align="right">出库单号：</td>
                            <td align="left"><apex:outputField value="{!coc.Name}" style="width:100px"/></td>
                            <td align="right">客户名：</td>
                            <td align="left"><apex:outputField value="{!coc.ShipmentAccount__c}" style="width:100px"/></td>
                             <td align="right">科室：</td>
                            <td align="left"><apex:outputField value="{!coc.Order_ForCustomerText__c}" style="width:100px"/></td>
                            <td align="right">目的：</td>
                            <td align="left"><apex:outputField id="OrderDircteion"  value="{!coc.SummonsForDirction__c}" style="width:100px"/></td>
                        </tr>
                    </table>
                </apex:pageBlock>

                <apex:pageBlock title="BarCode录入" rendered="{!IF(coc.Arrive_Order__c = null,true,false)}">
                    <table>
                        <colgroup>
                            <col width="160px"/>
                            <col width="100px"/>
                            <col width="10px"/>
                            <col width="150px"/>
                            <col width="100px"/>
                            <col width="10px"/>
                            <col width="90px"/>
                            <col width="100px"/>
                            <col width="10px"/>
                            <col width="85px"/>
                            <col width="100px"/>
                            <col width="10px"/>
                            <col width="70px"/>
                            <col width="100px"/>
                        </colgroup>
                        <tr>
                            <td align="right">BarCode号</td>
                            <td><apex:inputTextarea id="BarCodeArea" onchange="PraseBarCode(this.value)" value="{!barcode}" style="width:400px"/></td>
                            <td/>
                            <td align="right"></td>
                            <td><apex:commandButton value="确认" style="width: 150px;" onclick="searchProductJs(); return false;" /></td>
                            <td/>
                        </tr>
                        <tr>
                            <td></td>
                        </tr>
                    </table>
                </apex:pageBlock>

                <apex:pageBlock title="出货明细" id="ConsumableorderdetailsSection">
                    <table class="list" border="0" cellpadding="0" cellspacing="0">
                        <tr class="headerRow">
                            <th>消耗品订单</th>
                            <th>{!$ObjectType.Consumable_order_details2__c.fields.name.label}</th>
                            <th>单位</th>
                            <th>消耗品名称</th>
                            <th>发货日期</th>
                            <th>BarCode</th>
                            <th>使用期限</th>
                            <th>出货数量</th>
                        </tr>
                        <apex:repeat value="{!ConsumableorderdetailsRecords}" var="records" id="ConsumableorderdetailsTable">
                        <tr class="dataRow">
                            <td class="dataCell"><apex:outputField id="consumablesCount1" value="{!records.orderdetails2.Consumable_order_minor__c}"/></td>
                            <td class="dataCell"><apex:outputLink value="/{!records.orderdetails2.id}" target="LINK_{!records.orderdetails2.id}"><apex:outputField id="consumablesCount" value="{!records.orderdetails2.name}"/></apex:outputLink></td>
                            <td class="dataCell"><apex:outputField value="{!records.orderdetails2.Box_Piece__c}"/></td>
                            <td class="dataCell"><apex:outputField value="{!records.Prod.name}"/></td>
                            <td class="dataCell"><apex:outputField value="{!records.orderdetails2.Deliver_date__c}"/></td>
                            <td class="dataCell"><apex:outputField value="{!records.orderdetails2.Bar_Code__c}"/></td>
                            <td class="dataCell"><apex:outputField value="{!records.orderdetails2.Sterilization_limit__c}"/></td>
                            <td class="dataCell">
                                <apex:outputText value="{!records.outboundCount}" rendered="{!IF(records.orderdetails2.Box_Piece__c='盒',true,false)}"/>
                                <apex:inputText value="{!records.outboundCount}" rendered="{!IF(records.orderdetails2.Box_Piece__c='个',true,false)}"/></td>
                        </tr>
                        </apex:repeat>
                    </table>

                </apex:pageBlock>

                <apex:pageBlock title="出货错误明细">
                <apex:pageblocksection columns="1" id="ConsumableorderdetailsSection1">
                    <apex:pageblocktable value="{!ConsumableorderdetailsRecordserror}" var="records" id="ConsumableorderdetailsTable1">
                         <apex:column width="80">
                             <apex:facet name="header">消耗品订单</apex:facet>
                             <apex:outputField id="consumablesCount11" value="{!records.orderdetails2.Consumable_order_minor__c}"/>
                         </apex:column>
                         <apex:column width="80">
                             <apex:facet name="header">{!$ObjectType.Consumable_order_details2__c.fields.name.label}</apex:facet>
                             <apex:outputField id="consumablesCount1" value="{!records.orderdetails2.name}"/>
                             <apex:inputHidden id="oldConsumableCount1" value="{!records.oldConsumableCount}"/>
                         </apex:column>
                         <apex:column width="80">
                             <apex:facet name="header">消耗品名称</apex:facet>
                             <apex:outputField value="{!records.Prod.name}"/>
                         </apex:column>
                          <apex:column width="80">
                             <apex:facet name="header">单位</apex:facet>
                             <apex:outputField value="{!records.orderdetails2.Box_Piece__c}" />
                         </apex:column>
                          <apex:column width="80">
                             <apex:facet name="header">BarCode</apex:facet>
                             <apex:outputField value="{!records.orderdetails2.Bar_Code__c}"/>
                         </apex:column>
                          <apex:column width="80">
                             <apex:facet name="header">使用期限</apex:facet>
                             <apex:outputField value="{!records.orderdetails2.Sterilization_limit__c}"/>
                         </apex:column>
                         <apex:column width="80">
                             <apex:facet name="header">错误原因</apex:facet>
                             <apex:outputText value="{!records.ErrorReason}" />
                         </apex:column>
                    </apex:pageblocktable>
                    <script>
                        setDisabled();
                    </script>
                </apex:pageblocksection>
            </apex:pageBlock>
            </apex:pageBlock>
        </apex:outputPanel>
    </apex:form>
</apex:page>