<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gaoyang  
    $Date: 2013-4-17 上午09:26:12  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:c="leaf.application.action" xmlns:a="http://www.leaf-framework.org/application" xmlns:p="uncertain.proc" customizationEnabled="true" trace="true">
    <a:init-procedure>
        <a:model-query defaultWhereClause="d.enabled_flag=&apos;Y&apos; and d.display_flag=&apos;Y&apos;" fetchAll="true" model="hls.HLS500.hls_fin_calc_config_ln" rootPath="calc_config_ln_path"/>
        <a:model-query defaultWhereClause="d.enabled_flag=&apos;Y&apos;" fetchAll="true" model="hls.HLS500.hls_fin_calc_config_ln" rootPath="calc_config_ln_all_path"/>
        <a:model-query fetchAll="true" model="hls.HLS500.hls_fin_calc_button" rootPath="calc_button_path"/>
        <a:model-query fetchAll="true" model="hls.HLS500.hls_fin_calculator_ln_formula" rootPath="ln_formula_path"/>
        <a:model-query defaultwhereclause="(d.layout_area_seq = &apos;L&apos;)" fetchAll="true" model="hls.HLS500.hls_parameter_value_lov_load" rootPath="ln_parameter_sql_value"/>
        <a:model-query defaultWhereClause="(t1.price_list=nvl(${/parameter/@price_list},(select h.price_list from hls_fin_calculator_hd h where h.calc_session_id = ${/parameter/@calc_session_id})))" fetchAll="true" model="hls.HLS500.hls_fin_price_list_config" rootPath="hls_price_list_path"/>
    </a:init-procedure>
    <a:view>
        <!-- <a:link id="hls_parameter_value_lov_link" url="${/request/@context_path}/modules/hls/HLS500/hls_parameter_value_lov.lview"/> -->
        <a:link id="hls_fin_calculator_price_list" url="${/request/@context_path}/modules/hls/HLS500/hls_fin_calculator_price_list.lview"/>
        <a:link id="hls_fin_calc_update" url="${/request/@context_path}/modules/hls/HLS500/hls_fin_calc_update.lsc"/>
        <a:link id="hls_fin_calc_formula_update" url="${/request/@context_path}/modules/hls/HLS500/hls_fin_calc_formula_update.lview"/>
        <a:link id="hls_fin_calc_quotation_linedetail_link_id" url="${/request/@context_path}/modules/hls/HLS500/hls_fin_calc_quotation_line.lview"/>
        <a:link id="hls_fin_calc_show_display_line_link_id" url="${/request/@context_path}/modules/hls/HLS500/hls_fin_calc_show_display_line.lview"/>
        <style><![CDATA[
        .finGrid td[dataindex=percent]{
            border-right-color:#FFF;
            background-color:#FFF;
            border-bottom-color:#FFF;
        }
		.item-options{
		    background:#ffffff;
		}
		.cell-editor{
    		border:none;
    	}
		/* .grid-ub td[dataindex=rental]{
    	    background-color:#FAFAFA
    	} */
        ]]></style>
        <script src="${/request/@context_path}/javascripts/calculate.js" type="text/javascript"/>
        <script type="text/javascript"><![CDATA[
            var formula_column_name = '';
            var formula_column_code = '';
            var formula_prompt = '';
            var formula_row = '';
            var formula_calc_line_id = '';
            var global_ln_button_code = '';
            var global_ln_save_data_first = '';
            var global_ln_action_after_button = '';
            var global_ln_javascript = '';
            var body_ln_winId = '${/parameter/@winId}',
                body_ln = body_ln_winId == '' ? Ext.getBody() : $(body_ln_winId).wrap;
            var errorColor = {
                ERROR: 'FFFF00'
            };
            
            function hls_hls500_line_save(nextStep) {
                Leaf.Masker.mask(body_ln, '${l:HLS.SAVING}');
                if (!$('hls_fin_calculator_hd_ds').validate() || !$('hls_fin_calculator_ln_ds').validate()) {
                    Leaf.Masker.unmask(body_ln);
                    return;
                }
                var record = $('hls_fin_calculator_hd_ds').getAt(0),
                    calc_session_id = '${/parameter/@calc_session_id}';
                var column_list;
                var value_list;
                var total_list = [];
                var temp_head_records = $('hls_fin_calc_config_hd_form_ds').getAll(),
                    head_formula_record = $('hls_fin_cal_hd_formula_ds').getAt(0);
                for (var m = 0;m < temp_head_records.length;m++) {
                    if (!$('temp_hd_attribute_ds').find('column_code', temp_head_records[m].get('column_code'))) {
                        $('temp_hd_attribute_ds').create(temp_head_records[m].data);
                    }
                }
                for (var name in record.data) {
                    if (name.substring(name.length - 2) != '_n') {
                        var editor_record = $('temp_hd_attribute_ds').find('column_name', name);
                        column_list = name;
                        if (record.get(name) || record.get(name) === 0) {
                            if (editor_record.get('validation_type') == 'DATEPICKER') {
                                value_list = "'" + Leaf.formatDate(record.get(name)) + "'";
                            } else if (editor_record.get('percent') == '%') {
                                value_list = "'" + div(record.get(name), 100) + "'";
                            } else {
                                value_list = "'" + record.get(name) + "'";
                            }
                        } else {
                            value_list = "''";
                        }
                        total_list.push(column_list + '=' + value_list);
                    }
                }
                total_list = total_list.join(',');
                var param = {};
                param['total_list'] = total_list;
                param['calc_session_id'] = calc_session_id;
                param['document_category'] = '${/parameter/@document_category}';
                param['document_id'] = '${/parameter/@document_id}';
                param['hd_formula'] = [];
                head_formula_record.set('_status', 'update');
                param['hd_formula'].push(head_formula_record.data);
                var line_records = $('hls_fin_calculator_ln_ds').getAll();
                var line_formula_records = $('ln_formula_ds').getAll();
                param['details'] = [];
                param['ln_formula'] = [];
                for (var j = 0;j < line_records.length;j++) {
                    var line_record = line_records[j];
                    line_record.set('calc_session_id', calc_session_id);
                    if (!line_record.isNew && !line_record.dirty) {
                        continue;
                    }
                    if (line_record.dirty) {
                        line_record.set('_status', 'update');
                    }
                    if (line_record.isNew) {
                        line_record.set('_status', 'insert');
                    }
                    param['details'].push(line_record.data);
                }
                for (var n = 0;n < line_formula_records.length;n++) {
                    var line_formula_record = line_formula_records[n];
                    line_formula_record.set('calc_session_id', calc_session_id);
                    if (line_formula_record.dirty) {
                        line_formula_record.set('_status', 'update');
                        param['ln_formula'].push(line_formula_record.data);
                    }
                }
                Leaf.request({
                    url: $('hls_fin_calc_update').getUrl(),
                    para: param,
                    success: function(res) {
                        if (typeof(nextStep) == 'function') {
                            nextStep();
                        } else {
                            var res_records = res.result.details.record;
                            for (var j = 0;j < line_records.length;j++) {
                                var line_record = line_records[j];
                                if (line_record.isNew) {
                                    for (var r = 0;r < res_records.length;r++) {
                                        var res_record = res_records[r];
                                        if (res_record.times == line_record.get('times')) {
                                            if (Ext.isEmpty(res_record.calc_line_id)) {
                                                Leaf.showMessage('${l:PROMPT}', '${l:HLS.DATA_ERROR}');
                                                return;
                                            }
                                            line_record.set('calc_line_id', res_record.calc_line_id);
                                        }
                                    }
                                }
                                line_record.isNew = false;
                                line_record.dirty = false;
                            }
            
                            function on_ln_formula_load(ds) {
                                Leaf.SideBar.show({
                                    msg: '${l:HLS.SUBMIT_SUCCESS}',
                                    duration: 2000
                                });
                                Leaf.Masker.unmask(body_ln);
                                $('ln_formula_ds').un('load', on_ln_formula_load);
                            }
                            $('ln_formula_ds').on('load', on_ln_formula_load);
                            $('ln_formula_ds').query();
                        }
                    },
                    failure: function() {
                        Leaf.Masker.unmask(body_ln);
                    },
                    error: function() {
                        Leaf.Masker.unmask(body_ln);
                    },
                    scope: this
                });
            }
            
            function hls_hls500_line_calc() {
                Leaf.Masker.mask(body_ln, '${l:HLS.CALCULATING}');
                hls_hls500_line_save(calc_line_execute);
            }
            
            function open_ln_after_save_execute() {
                if ('${/parameter/@global_flag}' == 'Y') {
                    var url = $('hls_fin_calc_quotation_linedetail_link_id').getUrl();
                    var id_num = '${/parameter/@id_num}' * 1 + 1;
                    var winId = 'global_hls_fin_calc_quotation_linedetail_link_id_id' + id_num;
                    $('${/parameter/@winId}').close();
                    Leaf.Masker.unmask(body_ln);
                    new Leaf.Window({
                        id: winId,
                        params: {
                            calc_session_id: '${/parameter/@calc_session_id}',
                            document_id: '${/parameter/@document_id}',
                            quotation_id: '${/parameter/@quotation_id}',
                            document_category: '${/parameter/@document_category}',
                            dsId: '${/parameter/@dsId}',
                            dsId1: '${/parameter/@dsId1}',
                            winId: winId,
                            winId1: '${/parameter/@winId1}',
                            global_flag: 'Y',
                            id_num: id_num
                        },
                        url: url,
                        title: '${l:HLS.FIN_CALCULATOR}',
                        fullScreen: true,
                        draggable: true
                    });
                } else {
                    window.location.href = $('hls_fin_calc_quotation_linedetail_link_id').getUrl() + '?calc_session_id=' + '${/parameter/@calc_session_id}';
                }
            }
            
            function calc_line_execute() {
                Leaf.request({
                    url: '${/request/@context_path}/autocrud/hls.HLS500.hls_fin_calculator_calc/update',
                    para: {
                        calc_session_id: '${/parameter/@calc_session_id}',
                        document_id: '${/parameter/@document_id}',
                        document_category: '${/parameter/@document_category}',
                        recreate_L_formula: recreate_L_formula,
                        quotation_id: '${/parameter/@quotation_id}'
                    },
                    success: function(res) {
                        on_calc_success_query('${/parameter/@dsId}', '${/parameter/@document_category}');
                        get_warning_message(res.result.warning_message);
                        open_ln_after_save_execute();
                    },
                    failure: function() {
                        Leaf.Masker.unmask(body_ln);
                    },
                    error: function() {
                        Leaf.Masker.unmask(body_ln);
                    },
                    scope: this
                });
            }
            
            
            function hls_formatMoney(v, p) {
                return Leaf.formatNumber(v, p);
            }
            
            function hls_formatMoney_zero_fill(v, p) {
                return Leaf.formatNumber(v, p).replace(/0*$/g, '').replace(/\.$/, '');
            }
            
            function is_false_return(value) {
                if (isNaN(value) && Ext.isDefined(value)) {
                    if (value.substring(0, 1) == '#') {
                        return false;
                    }
            
                } else {
                    return true;
                }
            }
            
            function setGridCellStyle(record, name, cls) {
                var id = 'hls_fin_calculator_hd_grid_id_' + name + '_' + record.id,
                    intervalId = setInterval(function() {
                        var div = Ext.get(id);
                        if (div) {
                            clearInterval(intervalId);
                            div.addClass(cls);
                        }
                    }, 10);
            }
            
            function wrap_render(value, record, name) {
                var editor_record = $('line_attribute_ds').find('column_name', name);
                if (editor_record.get('validation_type') == 'NUMBERFIELD' && editor_record.get('input_mode') != 'READONLY' && name != 'times' && editor_record.get('sys_grid_col_underline') == 'Y' && !Ext.isEmpty(value)) {
                    return '<u>' + seedetail_column_ln(value, record, name) + '</u>';
                } else {
                    return seedetail_column_ln(value, record, name);
                }
            }
            
            function seedetail_column_ln(value, record, name) {
                if (is_false_return(value) == false) {
                    return "<div style='background-color:#" + errorColor['ERROR'] + "'>" + value + "</div>";
                }
                var editor_record = $('line_attribute_ds').find('column_name', name);
                if (editor_record.get('validation_type') == 'NUMBERFIELD' && (value || value === 0)) {
                    if (editor_record.get('allow_format') == 'TRUE') {
                        if (editor_record.get('precision')) {
                            if (editor_record.get('zero_fill') == 'TRUE') {
                                return hls_formatMoney(value, editor_record.get('precision'));
                            } else {
                                return hls_formatMoney_zero_fill(value, editor_record.get('precision'));
                            }
                        } else {
                            return hls_formatMoney(value);
                        }
                    } else {
                        if (editor_record.get('precision') && editor_record.get('allow_decimal') == 'TRUE') {
                            if (editor_record.get('zero_fill') == 'TRUE') {
                                return parseFloat(value).toFixed(editor_record.get('precision'));
                            } else {
                                return parseFloat(value).toFixed(editor_record.get('precision')).replace(/0*$/g, '').replace(/\.$/, '');
                            }
                        } else {
                            if (editor_record.get('allow_decimal') == 'TRUE') {
                                return value;
                            } else {
                                return parseFloat(parseFloat(value).toFixed(0));
                            }
                        }
                    }
                } else if (editor_record.get('validation_type') == 'DATEPICKER') {
                    return Leaf.formatDate(value);
                } else {
                    return value;
                }
            }
            
            function do_hls500_column_name(record, name) {
                var editor_record = $('line_attribute_ds').find('column_name', name),
                    field = record.getField(name);
                if (editor_record.get('input_mode') == 'REQUIRED') {
                    field.setRequired(true);
                }
                if (editor_record.get('input_mode') == 'READONLY') {
                    field.setReadOnly(true);
                }
                if (editor_record.get('validation_type') == 'NUMBERFIELD') {
                    if (editor_record.get('allow_decimal') == 'TRUE') {
                        field.setPropertity('allowdecimals', true);
                    } else {
                        field.setPropertity('allowdecimals', false);
                    }
                    if (editor_record.get('precision') || editor_record.get('precision') == 0) {
                        field.setPropertity('decimalprecision', editor_record.get('precision'));
                    }
                    if (editor_record.get('zero_fill') == 'TRUE') {
                        field.setPropertity('allowpad', true);
                    } else {
                        field.setPropertity('allowpad', false);
                    }
                    if (field.get('readonly')) {
                        return '';
                    } else {
                        if (name == 'times' && (!record.isNew)) {
                            return '';
                        }
                        return 'hls500_ln_numberfield_id';
                    }
                } else if (editor_record.get('validation_type') == 'LOV') {
                    var documentMapping = [{
                        from: 'value_code',
                        to: name
                    }];
                    var ln_parameter_sql_value_record = $('ln_parameter_sql_value_ds').find('column_code', editor_record.get('column_code'));
                    field.setLovPara('validation_sql', ln_parameter_sql_value_record.get('validation_sql'));
                    field.setTitle(editor_record.get('prompt'));
                    field.setMapping(documentMapping);
                    field.setLovModel('hls.HLS500.hls_parameters_lov');
                    if (field.get('readonly')) {
                        return '';
                    } else {
                        return 'hls500_ln_lov_id';
                    }
                } else if (editor_record.get('validation_type') == 'TEXTFIELD') {
                    if (field.get('readonly')) {
                        return '';
                    } else {
                        return 'hls500_ln_textfield_id';
                    }
                } else if (editor_record.get('validation_type') == 'DATEPICKER') {
                    return 'hls500_ln_datepicker_id';
                } else if (editor_record.get('validation_type') == 'CHECKBOX') {
                    field.setPropertity('checkedvalue', 'Y');
                    field.setPropertity('uncheckedvalue', 'N');
                    if (field.get('readonly')) {
                        return '';
                    } else {
                        return 'hls500_ln_checkbox_id';
                    }
                } else {
                    return '';
                }
            }
            
            function hls_hls500_add() {
                $('hls_fin_calculator_ln_grid_id').showEditorByRecord($('hls_fin_calculator_ln_ds').create(0));
            }
            
            function hls_hls500_line_return() {
                if ('${/parameter/@global_flag}' == 'Y') {
                    $('${/parameter/@winId}').close();
                } else {
                    var url = $('hls_fin_calculator_price_list').getUrl();
                    window.location.href = url;
                }
            }
            
            function escapeHtml(str) {
                if (Ext.isEmpty(str) || !Ext.isString(str)) {
                    return str;
                }
                return $L.escapeHtml(str).replace(/&lt;br\/&gt;/gm, '<br/>');
            }
            
            function do_hls500_line_load(ds) {
                var lineRecords = ds.getAll();
                var attribute_records = $('line_attribute_ds').getAll();
                if (!lineRecords) {
                    return;
                }
                if ('${/model/hls_price_list_path/record/@show_column_code}' == 'Y') {
                    for (var i = 0;i < lineRecords.length;i++) {
                        var ln_formula_record = $('ln_formula_ds').find('calc_line_id', lineRecords[i].get('calc_line_id'));
                        for (var j = 0;j < attribute_records.length;j++) {
                            var column_name = attribute_records[j].get('column_name');
                            var tooltip_ln_formula = escapeHtml(appendBr(ln_formula_record.get(column_name), 60));
                            lineRecords[i].getField(column_name).setPropertity('tooltip', tooltip_ln_formula);
                        }
                    }
                }
            }
            
            function do_hls500_line_update(ds, record, name, value, old_value) {
                var formula_record = $('ln_formula_ds').find('calc_line_id', record.get('calc_line_id'));
                if (formula_record) {
                    formula_record.set(name, value);
                }
            }
            
            function hls_hls500_ln_formula_change() {
                if (!formula_column_name) {
                    Leaf.showMessage('${l:HLS.PROMPT}', '${l:HLS500.CHANGE_FORMULA_FIELD}');
                    return;
                }
                if (!formula_calc_line_id) {
                    Leaf.showConfirm('${l:HLS.PROMPT}', '${l:HLS500.CHANGE_HD_FIELD}' + formula_prompt, function() {
                        line_openWindow();
                    }, function() {
                        return;
                    }, null, null);
                } else {
                    Leaf.request({
                        url: '${/request/@context_path}/autocrud/hls.HLS500.hls_fin_calc_config_ln/query',
                        para: {
                            calc_session_id: '${/parameter/@calc_session_id}',
                            column_name: formula_column_name
                        },
                        success: function(res) {
                            formula_column_code = res.result.record.column_code;
                            Leaf.showConfirm('${l:HLS.PROMPT}', '${l:HLS500.CHANGE_LN_FIELD}' + formula_row + '${l:HLS500.LN_FIELD}' + formula_prompt, function() {
                                line_openWindow();
                            }, function() {
                                return;
                            }, null, null);
                        },
                        scope: this
                    });
                }
            
            }
            
            function hls500_ln_cellcick(grid, row, name, record) {
                var ln_formula_record = $('line_attribute_ds').find('column_name', name);
                formula_column_name = name;
                formula_column_code = '';
                formula_prompt = ln_formula_record.get('prompt');
                formula_calc_line_id = record.get('calc_line_id');
                formula_row = row;
            }
            
            function line_openWindow() {
                var url = $('hls_fin_calc_formula_update').getUrl();
                new Leaf.Window({
                    id: 'hd_formula_update_winid',
                    url: url,
                    params: {
                        calc_session_id: '${/parameter/@calc_session_id}',
                        document_id: '${/parameter/@document_id}',
                        document_category: '${/parameter/@document_category}',
                        column_name: formula_column_name,
                        column_code: formula_column_code,
                        prompt: formula_prompt,
                        calc_line_id: formula_calc_line_id,
                        winid: 'hd_formula_update_winid'
                    },
                    title: '${l:HLS500.FORMULA_UPDATE}',
                    height: 300,
                    width: 400
                });
            }
            
            function appendBr(s, max) {
                if (s) {
                    for (var i = max || 10;i < s.length;i += max + 5) {
                        s = s.substr(0, i) + '<br/>' + s.substr(i);
                    }
                    return s;
                } else {
                    return '';
                }
            }
            
            function hls500_define_ln_button(btn) {
                Leaf.Masker.mask(body_ln, '${l:HLS.EXECUTING}');
                global_ln_button_code = btn.id.substring(3);
                var button_record = $('calc_button_line_ds').find('button_code', global_ln_button_code);
                global_ln_save_data_first = button_record.get('save_data_first');
                global_ln_action_after_button = button_record.get('action_after_button');
                global_ln_javascript = button_record.get('javascript');
                if (Ext.isDefined(global_ln_javascript)) {
                    if (global_ln_save_data_first == 'Y') {
                        hls_hls500_line_save(hls500_define_ln_button_js);
                    } else {
                        hls500_define_ln_button_js();
                    }
                } else {
                    if (global_ln_save_data_first == 'Y') {
                        hls_hls500_line_save(hls500_define_ln_button_execute);
                    } else {
                        hls500_define_ln_button_execute();
                    }
                }
            }
            
            function hls500_ln_action_after_button() {
                if (global_ln_action_after_button == 'EXIT') {
                    hls_hls500_line_return();
                } else if (global_ln_action_after_button == 'QUERY') {
                    open_ln_after_save_execute();
                }
            }
            
            function hls500_define_ln_button_js() {
                // if (window.execScript) {
                // window.execScript(global_ln_javascript);
                // } else {
                eval(global_ln_javascript);
                // }
                Leaf.Masker.unmask(body_ln);
                hls500_ln_action_after_button();
            }
            
            function hls500_define_ln_button_execute() {
                Leaf.request({
                    url: '${/request/@context_path}/autocrud/hls.HLS500.hls_fin_calc_user_define_btn/update',
                    para: {
                        calc_session_id: '${/parameter/@calc_session_id}',
                        button_code: global_ln_button_code,
                        document_id: '${/parameter/@document_id}',
                        document_category: '${/parameter/@document_category}'
                    },
                    success: function(res) {
                        parent.Leaf.SideBar.show({
                            html: '<div style="background-color:#ccfbd5;position:absolute;padding:3px;border:1px solid #009900">' + res.result.return_value + '</div>',
                            duration: 5000
                        });
                        Leaf.Masker.unmask(body_ln);
                        hls500_ln_action_after_button();
                    },
                    failure: function() {
                        Leaf.Masker.unmask(body_ln);
                    },
                    error: function() {
                        Leaf.Masker.unmask(body_ln);
                    },
                    scope: this
                });
            }
            
            function hls500_ln_process(datas) {
                for (var i = 0;i < datas.length;i++) {
                    var temp = datas[i];
                    for (var name in temp.data) {
                        var temp_record = $('line_attribute_ds').find('column_name', name);
                        if (temp_record) {
                            if (temp_record.get('validation_type') == 'NUMBERFIELD') {
                                temp.data[name] = isNaN(temp.data[name]) == true ? temp.data[name] : parseFloat(parseFloat(temp.data[name]).toFixed(temp_record.get('precision')));
                            }
                        }
                    }
                }
                return datas;
            }
            
            function hls_hls500_delete() {
                $('hls_hls500_delete_line_id').disable();
                var records = $('hls_fin_calculator_ln_ds').getSelected();
                if (!records.length) {
                    Leaf.showMessage('${l:HLS.PROMPT}', '${l:HLS.SELECT_RECORD}');
                    $('hls_hls500_delete_line_id').enable();
                    return;
                }
                var saveData = [];
                for (var i = 0;i < records.length;i++) {
                    records[i].set('_status', 'delete');
                    records[i].set('document_id', '${/parameter/@document_id}');
                    records[i].set('document_category', '${/parameter/@document_category}');
                    saveData.push(records[i].data);
                }
                Leaf.request({
                    url: '${/request/@context_path}/autocrud/hls.HLS500.hls_fin_calc_delete_ln/batch_update',
                    para: saveData,
                    success: function() {
                        Leaf.SideBar.show({
                            msg: '${l:HLS.SUBMIT_SUCCESS}',
                            duration: 2000
                        });
                        $('hls_fin_calculator_ln_grid_id').clear();
                        $('hls_hls500_delete_line_id').enable();
                    },
                    failure: function() {
                        $('hls_hls500_delete_line_id').enable();
                    },
                    error: function() {
                        $('hls_hls500_delete_line_id').enable();
                    },
                    scope: this
                });
            }
            
            function hls_hls500_export() {
                $('hls_fin_calculator_ln_grid_id')._export();
            }
            
            function hd_grid_rowrenderer() {
                return 'background-color:#f3f3f3';
            }
            
            function do_hls500_line_remove(ds, record, index) {
                var formula_record = $('ln_formula_ds').find('calc_line_id', record.get('calc_line_id'));
                $('ln_formula_ds').remove(formula_record);
            }
            
            function hls_hls500_show_col_ln(btn) {
                $('hls_hls500_show_col_ln_id').disable();
                var win = new Leaf.Window({
                    id: 'show_col_window_id',
                    params: {
                        calc_session_id: '${/parameter/@calc_session_id}',
                        calc_grid_id: 'hls_fin_calculator_ln_grid_id',
                        winid: 'show_col_window_id'
                    },
                    url: $('hls_fin_calc_show_display_line_link_id').getUrl(),
                    title: btn.el.dom['innerText'],
                    width: 550,
                    height: 450
                });
                win.on('close', function() {
                    $('hls_hls500_show_col_ln_id').enable();
                });
            }
            
            function hls_hls500_line_export() {
            
               }
            
            function hls_hls500_line_import() {
            
               }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="hls_dynamiclinefields_ds" autoCreate="true">
                <a:fields>
                    <a:placeHolder id="dynamicLineFields"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="line_attribute_ds">
                <a:datas dataSource="/model/calc_config_ln_path"/>
            </a:dataSet>
            <a:dataSet id="line_field_ds">
                <a:datas dataSource="/model/calc_config_ln_all_path"/>
            </a:dataSet>
            <a:dataSet id="ln_parameter_sql_value_ds">
                <a:datas dataSource="/model/ln_parameter_sql_value"/>
            </a:dataSet>
            <a:dataSet id="ln_formula_ds" queryUrl="${/request/@context_path}/autocrud/hls.HLS500.hls_fin_calculator_ln_formula/query?calc_session_id=${/parameter/@calc_session_id}">
                <a:datas dataSource="/model/ln_formula_path"/>
            </a:dataSet>
            <a:dataSet id="calc_button_line_ds">
                <a:datas dataSource="/model/calc_button_path"/>
            </a:dataSet>
            <a:dataSet id="hls_fin_calculator_ln_ds" autoQuery="true" fetchAll="true" model="hls.HLS500.hls_fin_calculator_ln" processfunction="hls500_ln_process" queryUrl="${/request/@context_path}/autocrud/hls.HLS500.hls_fin_calculator_ln/query?calc_session_id=${/parameter/@calc_session_id}" selectable="true">
                <a:events>
                    <a:event name="load" handler="do_hls500_line_load"/>
                    <a:event name="update" handler="do_hls500_line_update"/>
                    <a:event name="remove" handler="do_hls500_line_remove"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:placeHolder id="hls500_button_ds"/>
            </a:screenTopToolbar>
            <a:form column="2" title="HLS.FIN_CALCULATOR">
                <a:grid id="hls_fin_calculator_ln_grid_id" bindTarget="hls_fin_calculator_ln_ds" marginHeight="150" marginWidth="50">
                    <a:columns>
                        <a:placeHolder id="dynamicLineColumn_id"/>
                    </a:columns>
                    <a:editors>
                        <a:numberField id="hls500_ln_numberfield_id"/>
                        <a:lov id="hls500_ln_lov_id">
                            <a:events>
                                <a:event name="focus" handler="on_object_ln_calc_focus"/>
                            </a:events>
                        </a:lov>
                        <a:textField id="hls500_ln_textfield_id"/>
                        <a:datePicker id="hls500_ln_datepicker_id"/>
                        <a:checkBox id="hls500_ln_checkbox_id"/>
                    </a:editors>
                    <a:events>
                        <a:event name="cellclick" handler="hls500_ln_cellcick"/>
                    </a:events>
                </a:grid>
                <script type="text/javascript"><![CDATA[
                    	Leaf.onReady(function(){
                    	   var records=$('line_field_ds').getAll();
                    	   if(records.length){
                    	      for(var i=0;i<records.length;i++){
                    	          var record=records[i],column_name=record.get('column_name');
                    	          if(record.get('display_flag')=='C'){
                    	          	 $('hls_fin_calculator_ln_grid_id').hideColumn(column_name);
                    	          }
                    	      }
                    	   }
                    	});
                    ]]></script>
            </a:form>
        </a:screenBody>
    </a:view>
    <a:view-config>
        <c:create-config targetId="hls500_button_ds">
            <p:loop source="/model/calc_button_path">
                <p:switch test="@button_code">
                    <p:case value="EXIT">
                        <c:process-config>
                            <a:gridButton click="hls_hls500_line_return" text="${@prompt}"/>
                        </c:process-config>
                    </p:case>
                    <p:case value="ADD_LN">
                        <c:process-config>
                            <a:gridButton id="hls_hls500_add_line_id" click="hls_hls500_add" text="${@prompt}"/>
                        </c:process-config>
                    </p:case>
                    <p:case value="DEL_LN">
                        <c:process-config>
                            <a:gridButton id="hls_hls500_delete_line_id" click="hls_hls500_delete" text="${@prompt}"/>
                        </c:process-config>
                    </p:case>
                    <p:case value="SAVE">
                        <c:process-config>
                            <a:gridButton id="hls_hls500_line_save_line_id" click="hls_hls500_line_save" text="${@prompt}"/>
                        </c:process-config>
                    </p:case>
                    <p:case value="MODF_FORMULA">
                        <c:process-config>
                            <a:gridButton id="hls_hls500_formula_line_id" click="hls_hls500_ln_formula_change" text="${@prompt}"/>
                        </c:process-config>
                    </p:case>
                    <p:case value="CALC">
                        <c:process-config>
                            <a:gridButton id="hls_hls500_line_calc_line_id" click="hls_hls500_line_calc" text="${@prompt}"/>
                        </c:process-config>
                    </p:case>
                    <p:case value="EXPORT">
                        <c:process-config>
                            <a:gridButton id="hls_hls500_export_line_id" click="hls_hls500_line_export" text="${@prompt}"/>
                        </c:process-config>
                    </p:case>
                    <p:case value="IMPORT">
                        <c:process-config>
                            <a:gridButton id="hls_hls500_import_line_id" click="hls_hls500_line_import" text="${@prompt}"/>
                        </c:process-config>
                    </p:case>
                    <p:case value="SHOW_COL">
                        <c:process-config>
                            <a:gridButton id="hls_hls500_show_col_ln_id" click="hls_hls500_show_col_ln" style="margin-top:10px;margin-left:5px" text="${@prompt}"/>
                        </c:process-config>
                    </p:case>
                    <p:case value="*">
                        <c:process-config>
                            <a:gridButton id="ln_${@button_code}" click="hls500_define_ln_button" text="${@prompt}"/>
                        </c:process-config>
                    </p:case>
                </p:switch>
            </p:loop>
        </c:create-config>
        <c:create-config targetId="dynamicLineColumn_id">
            <p:loop source="/model/calc_config_ln_path">
                <p:switch test="@show_column_code">
                    <p:case value="Y">
                        <c:process-config>
                            <a:column lock="${@lock_column}" prompt="${@column_code}" width="${@width}">
                                <a:column name="${@column_name}" align="${@alignment}" editorFunction="do_hls500_column_name" lock="${@lock_column}" prompt="${@prompt}" renderer="wrap_render" showtitle="${@sys_grid_show_title}" sortable="true" width="${@width}"/>
                            </a:column>
                        </c:process-config>
                    </p:case>
                    <p:case value="N">
                        <c:process-config>
                            <a:column name="${@column_name}" align="${@alignment}" editorFunction="do_hls500_column_name" lock="${@lock_column}" prompt="${@prompt}" renderer="wrap_render" showtitle="${@sys_grid_show_title}" sortable="true" width="${@width}"/>
                        </c:process-config>
                    </p:case>
                </p:switch>
            </p:loop>
        </c:create-config>
        <c:create-config targetId="dynamicLineFields">
            <p:loop source="/model/calc_config_ln_all_path">
                <c:process-config>
                    <a:field name="${@column_name}" defaultValue="${@default_value}" lovGridHeight="350" lovHeight="500" lovWidth="500"/>
                </c:process-config>
            </p:loop>
        </c:create-config>
    </a:view-config>
</a:screen>
