<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: lpc 9874
    $Date: $
    $Revision: 1.0 $
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure>
        <a:model-query model="hls.HLS303.hls_get_import_head_id" rootPath="header"/>
        <a:import-excel header_id="${/model/header/record/@header_id}" separator="," status_field="/parameter/@ImportSuccess" template_code="BP_AGENT" user_id="${/session/@user_id}"/>
        <a:model-query defaultWhereClause="header_id=${/model/header/record/@header_id} and TEMPLATE_CODE = &apos;BP_AGENT&apos;" model="hls.HLS303.hls_import_get_status" rootPath="status"/>
    </a:init-procedure>
    <a:view>
        <a:link id="import_link" url="${/request/@context_path}/modules/hls/HLS303/bp_agent_import.lview"/>
        <a:link id="import_save_data_link" url="${/request/@context_path}/modules/hls/HLS303/bp_agent_import_save.lsc"/>
        <script type="text/javascript"><![CDATA[
            function view() {
                parent._input_window.close();
            }
            
            function loadComplete() {

                if ('${/model/status/record/@status}' == 'NEW') {
                    var param = {};
                    param['batch_id'] = '${/parameter/@batch_id}';
                    param['header_id'] = '${/model/header/record/@header_id}';
                    param['user_id'] = '${/session/@user_id}';
                    param['bp_id'] = '${/parameter/@bp_id}';
                    Leaf.request({
                        url: $('import_save_data_link').getUrl(),
                        para: param,
                        success: function() {
                            //view();
                            window.location.href = $('import_link').getUrl() + '?bp_id=' + ${/parameter/@bp_id};
                            // var win = new Leaf.Window({
                            // url: $('import_link').getUrl() + '?bp_id=' + ${/parameter/@bp_id},
                            // fullScreen: true
                            // });
                        },
                        scope: this
                    });
            
                } else {
                    Ext.get('success_form').setStyle('display', 'none');
                    Ext.get('failure_form').setStyle('visibility', 'visible');
                }
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="error_ds">
                <a:fields>
                    <a:field name="import_field_1" prompt="import_field_1"/>
                    <a:field name="import_field_2" prompt="import_field_2"/>
                    <a:field name="import_field_3" prompt="import_field_3"/>
                    <!-- <a:field name="import_field_4" prompt="import_field_4"/>
                    <a:field name="import_field_5" prompt="import_field_5"/>
                    <a:field name="import_field_6" prompt="import_field_6"/>
                    <a:field name="import_field_7" prompt="import_field_7"/>
                    <a:field name="import_field_8" prompt="import_field_8"/> -->
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:form id="failure_form" height="400" style="visibility:hidden" title="ERROR_MESSAGE" width="980">
                <a:grid bindTarget="error_ds" height="340" navBar="true" width="980">
                    <a:columns>
                        <a:column name="import_field_1"/>
                        <a:column name="import_field_2"/>
                        <a:column name="import_field_3"/>
                        <!-- <a:column name="import_field_4"/>
                        <a:column name="import_field_5"/>
                        <a:column name="import_field_6"/>
                        <a:column name="import_field_7"/>
                        <a:column name="import_field_8"/> -->
                    </a:columns>
                </a:grid>
            </a:form>
        </a:screenBody>
        <script type="text/javascript"><![CDATA[
	  		loadComplete();
	  	]]></script>
    </a:view>
</a:screen>
