<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gaoyang  
    $Date: 2013-2-5 上午10:07:29  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" trace="true">
    <a:init-procedure outputPath="/parameter">
        <a:model-query model="basic.hls_fnd_attribute_sequence" rootPath="header"/>
        <a:import-excel header_id="${/model/header/record/@header_id}" separator="," status_field="/parameter/@ImportSuccess" template_code="HLS_LEASE_ITEM_LIST" user_id="${/session/@user_id}"/>
        <a:model-query defaultWhereClause="header_id=${/model/header/record/@header_id} and TEMPLATE_CODE = &apos;HLS_LEASE_ITEM_LIST&apos;" model="basic.hls_fnd_attribute_status" rootPath="status"/>
    </a:init-procedure>
    <a:view>
        <a:link id="hls_lease_item_list_ipt_lind_id" url="${/request/@context_path}/modules/hls/HLS201/hls_lease_item_list_ipt.lsc"/>
        <a:link id="hls_lease_item_query_link_id" url="${/request/@context_path}/modules/hls/HLS201/hls_lease_item_query.lview"/>
        <script type="text/javascript"><![CDATA[
        	var li_list_type;
            function loadComplete() {
                if ('${/model/status/record/@status}' == 'NEW') {
                    var param = {};
                    var errorData = "";
                    var importFlag = true;
                    param['session_id'] = '${/parameter/@session_id}';
                    param['header_id'] = '${/model/header/record/@header_id}';
                    if (importFlag) {
                        Leaf.request({
                            url: $('hls_lease_item_list_ipt_lind_id').getUrl(),
                            para: param,
                            success: function(res) {
                                li_list_type=res.result.li_list_type;
                                $('temp_interface_ds').setQueryParameter('session_id', '${/parameter/@session_id}');
                                $('temp_interface_ds').query();
                            },
                            scope: this
                        });
                    } else {
                        errorData = errorData.substr(0, errorData.length - 1);
                        Leaf.showMessage('${l:PROMPT}', '${l:VERIFY_INFORMATION}');
                    }
                }
            }
            
            function saveBtn() {
                $('saveBtn_id').disable();
                Leaf.Masker.mask(Ext.getBody(), '${l:BEING_IMPLEMENTED}');
                Leaf.request({
                    url: '${/request/@context_path}/autocrud/hls.HLS201.hls_lease_item_list_load_data/update',
                    para: {
                        session_id: '${/parameter/@session_id}',
                        lease_item_id: '${/parameter/@lease_item_id}',
                        li_list_type:li_list_type
                    },
                    success: function() {
                        Leaf.SideBar.show({
                            msg: '${l:IMPORT_WAS_SUCCESSFUL}',
                            duration: 2000
                        });
                        backBtn();
                    },
                    error: function() {
                        $('temp_interface_ds').setQueryParameter('session_id', '${/parameter/@session_id}');
                        $('temp_interface_ds').query();
                        $('saveBtn_id').enable();
                        Leaf.Masker.unmask(Ext.getBody());
                    },
                    failure: function() {
                        $('temp_interface_ds').setQueryParameter('session_id', '${/parameter/@session_id}');
                        $('temp_interface_ds').query();
                        $('saveBtn_id').enable();
                        Leaf.Masker.unmask(Ext.getBody());
                    },
                    scope: this
                });
            }
            
            function backBtn() {
                window.location = $('hls_lease_item_query_link_id').getUrl();
            }
            function temp_interface_load(){
                if (li_list_type == 'LEASE') {
                    $('temp_interface_grid_id').hideColumn('uom');
                    $('temp_interface_grid_id').hideColumn('asset_num');
                    $('temp_interface_grid_id').hideColumn('manufacturer');
                    $('temp_interface_grid_id').hideColumn('posted_date');
                    $('temp_interface_grid_id').hideColumn('net_asset_value');
                    $('temp_interface_grid_id').hideColumn('invoice_amt');
                    $('temp_interface_grid_id').hideColumn('invoice_num');
                    $('temp_interface_grid_id').hideColumn('invoice_date');
                } else if (li_list_type == 'LEASE_BACK') {
                    $('temp_interface_grid_id').hideColumn('price');
                    $('temp_interface_grid_id').hideColumn('total_amount');
                    $('temp_interface_grid_id').hideColumn('vender');
                }
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="temp_interface_ds" fetchAll="true" model="hls.HLS201.hls_lease_item_list_temp" queryUrl="${/request/@context_path}/autocrud/hls.HLS201.hls_lease_item_list_temp/query?session_id=${/parameter/@session_id}">
                <a:events>
                    <a:event name="load" handler="temp_interface_load"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:form id="success_form" height="400" title="THE_IMPORTED_DATA" width="980">
                <a:grid id="temp_interface_grid_id" bindTarget="temp_interface_ds" height="340" navBar="true" width="980">
                    <a:toolBar>
                        <a:button type="excel"/>
                    </a:toolBar>
                    <a:columns>
                        <!-- <a:column name="seq"/>
                        <a:column name="asset_num"/>
                        <a:column name="asset_type"/>
                        <a:column name="asset_name"/>
                        <a:column name="posted_date" renderer="Leaf.formatDate"/>
                        <a:column name="specification"/>
                        <a:column name="vender"/>
                        <a:column name="manufacturer"/>
                        <a:column name="quantity"/>
                        <a:column name="uom"/>
                        <a:column name="original_asset_value" renderer="Leaf.formatMoney"/>
                        <a:column name="net_asset_value" renderer="Leaf.formatMoney"/>
                        <a:column name="accumulated_depreciation"/>
                        <a:column name="currency"/>
                        <a:column name="installation_site"/>
                        <a:column name="invoice_amt" renderer="Leaf.formatMoney"/>
                        <a:column name="invoice_amt_after_tax" renderer="Leaf.formatMoney"/>
                        <a:column name="invoice_num"/>
                        <a:column name="invoice_date" renderer="Leaf.formatDate"/> -->
                        <a:column name="seq"/>
                        <a:column name="asset_num"/>
                        <a:column name="asset_name"/>
                        <a:column name="specification"/>
                        <a:column name="manufacturer"/>
                        <a:column name="vender"/>
                        <a:column name="installation_site"/>
                        <a:column name="quantity"/>
                        <a:column name="price"/>
                        <a:column name="total_amount"/>
                        <a:column name="uom"/>
                        <a:column name="posted_date" renderer="Leaf.formatDate"/>
                        <a:column name="net_asset_value" renderer="Leaf.formatMoney"/>
                        <a:column name="invoice_amt" renderer="Leaf.formatMoney"/>
                        <a:column name="invoice_num"/>
                        <a:column name="invoice_date" renderer="Leaf.formatDate"/>
                    </a:columns>
                </a:grid>
                <a:screenTopToolbar>
                    <a:gridButton id="saveBtn_id" click="saveBtn" text="DETERMINING_IMPORT"/>
                    <a:gridButton click="backBtn" text="HAP_BACK"/>
                </a:screenTopToolbar>
            </a:form>
        </a:screenBody>
        <script type="text/javascript"><![CDATA[
	  		loadComplete();
	  	]]></script>
    </a:view>
</a:screen>
