<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129  
    $Date: 2013-5-30 下午03:38:34  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" trace="true">
    <a:init-procedure/>
    <a:view>
        <a:link id="lease_item_list_delete_link" model="hls.HLS203.hls_lease_item_list_delete" modelaction="delete"/>
        <a:link id="hls_lease_item_list_import_handle_link" url="${/request/@context_path}/modules/hls/HLS203/hls_lease_item_list_import_handle.lview"/>
        <script type="text/javascript"><![CDATA[
            function hls_hls203_detail_back() {
                $('${/parameter/@winId}').close();
            }
            
            function hls_hls203_detail_export() {
                $('hls_lease_item_detail_grid_ds')._export();
            }
            
            function on_hls_lease_item_list_load(ds) {
                var records = ds.getAll();
                var show_flag = 'N';
                if (records.length) {
                    for (var i = 0;i < records.length;i++) {
                        var record = records[i];
                        for (var name in record.data) {
                            if (!record.get(name) && show_flag == 'N') {
                                $('hls_lease_item_detail_grid_ds').hideColumn(name);
                                show_flag = 'N';
                            } else {
                                $('hls_lease_item_detail_grid_ds').showColumn(name);
                                show_flag = 'Y';
                            }
                        }
                    }
                }
                var li_list_type = '${/parameter/@li_list_type}';
                if (li_list_type == 'LEASE') {
                    $('hls_lease_item_detail_grid_ds').hideColumn('uom');
                    $('hls_lease_item_detail_grid_ds').hideColumn('asset_num');
                    $('hls_lease_item_detail_grid_ds').hideColumn('manufacturer');
                    $('hls_lease_item_detail_grid_ds').hideColumn('posted_date');
                    $('hls_lease_item_detail_grid_ds').hideColumn('net_asset_value');
                    $('hls_lease_item_detail_grid_ds').hideColumn('invoice_amt');
                    $('hls_lease_item_detail_grid_ds').hideColumn('invoice_num');
                    $('hls_lease_item_detail_grid_ds').hideColumn('invoice_date');
                } else if (li_list_type == 'LEASE_BACK') {
                    $('hls_lease_item_detail_grid_ds').hideColumn('price');
                    $('hls_lease_item_detail_grid_ds').hideColumn('total_amount');
                    $('hls_lease_item_detail_grid_ds').hideColumn('vender');
                }
            }
            
            function hls203_delete_list(){
                Leaf.showConfirm('${l:PROMPT}', '${l:HLS.IS_REMOVE_ALL}', function() {
                    $('hls203_delete_id').disable();
                    Leaf.request({
                        url: $('lease_item_list_delete_link').getUrl(),
                        para: {
                            lease_item_id: '${/parameter/@lease_item_id}'
                        },
                        success: function() {
                            Leaf.SideBar.show({
                                msg: '${l:HLS.SUBMIT_SUCCESS}',
                                duration: 2000
                            });
                            $('hls_lease_item_detail_result_ds').query();
                            $('hls203_delete_id').enable();
                        },
                        error: function() {
                            $('hls203_delete_id').enable();
                        },
                        failure: function() {
                            $('hls203_delete_id').enable();
                        },
                        scope: this
                    });
                }, function() {
                    return;
                }, null, null);
            }
            
            function hls_hls203_detail_emport(){
                 $('hls203_emport_id').disable();
                var win=new Leaf.Window({
                    id: 'upload_handle_winId',
                    params:{
                       session_id:'${/session/@session_id}',
                       lease_item_id:'${/parameter/@lease_item_id}'
                    },
                    url: $('hls_lease_item_list_import_handle_link').getUrl(),
                    title: '${l:HLS201.HLS_LEASE_ITEM_LIST}',
                    width: 420,
                    height: 275
                });
                win.on('close', function() {
                    $('hls203_emport_id').enable();
                });           
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="hls_lease_item_detail_result_ds" autoQuery="true" model="hls.HLS203.hls_lease_item_list" pageSize="13" queryUrl="${/request/@context_path}/autocrud/hls.HLS203.hls_lease_item_list/query?lease_item_id=${/parameter/@lease_item_id}" selectable="true">
                <a:events>
                    <a:event name="load" handler="on_hls_lease_item_list_load"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:grid id="hls_lease_item_detail_grid_ds" bindTarget="hls_lease_item_detail_result_ds" height="400" navBar="true" width="850">
                <a:columns>
                    <a:column name="seq"/>
                    <a:column name="asset_num"/>
                    <a:column name="asset_name" width="200"/>
                    <a:column name="specification"/>
                    <a:column name="manufacturer"/>
                    <a:column name="vender" width="200"/>
                    <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" align="right" renderer="Leaf.formatMoney"/>
                    <a:column name="invoice_amt" align="right" 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="hls203_delete_id" click="hls203_delete_list" text="HLS.REMOVE_ALL"/>
                <a:gridButton id="hls203_emport_id" click="hls_hls203_detail_emport" text="HLS.IMPORT"/>
            </a:screenTopToolbar>
        </a:screenBody>
    </a:view>
</a:screen>