<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gaoyang  
    $Date: 2013-10-15 上午10:23:55  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" trace="true">
    <a:init-procedure/>
    <a:view>
        <script type="text/javascript"><![CDATA[
            function content_and_notarize_witness_return() {
                $('${/parameter/@lovid}').win.close();
            }
            
            function content_and_notarize_witness_lock_win() {
                Leaf.Masker.mask(Ext.get(document.documentElement), '${l:HLS.SAVING}');
            }
            
            function content_and_notarize_witness_unlock_win() {
                Leaf.Masker.unmask(Ext.get(document.documentElement));
            }
            
            function content_and_notarize_witness_save() {
                content_and_notarize_witness_lock_win();
                var ds=$('con_content_and_notarize_witness_result_ds');
                ds.setSubmitParameter('contract_id','${/parameter/@contract_id}');
                ds.submit();
            }
            
            function content_and_notarize_witness_query() {
                $('con_content_and_notarize_witness_result_ds').query();
            }
            
            function content_and_notarize_witness_new() {
                $('con_content_and_notarize_witness_grid_id').showEditorByRecord($('con_content_and_notarize_witness_result_ds').create());
            }
            
            function content_and_notarize_witness_remove() {
                content_and_notarize_witness_lock_win();
                var ds = $('con_content_and_notarize_witness_result_ds'),
                    records = ds.getSelected();
                if (!records.length) {
                    Leaf.showMessage('${l:PROMPT}', '${l:HLS.SELECT_RECORD}');
                    content_and_notarize_witness_unlock_win();
                    return;
                }
                ds.setSubmitParameter('contract_id','${/parameter/@contract_id}');
                ds.remove(records);
            }
            
            function on_content_and_notarize_witness_remove() {
                content_and_notarize_witness_unlock_win();
            }
            
            function on_content_and_notarize_witness_submitsuccess(res) {
                content_and_notarize_witness_unlock_win();
                var records = $('con_content_and_notarize_witness_result_ds').getAll(),
                    all_name = [];
                for (var i = 0;i < records.length;i++) {
                    var record = records[i];
                    all_name.push(record.get('employee_name'));
                }
                all_name.join(',');
                var parent_record = $('con_contract_content_sign_information_ds').getCurrentRecord();
                parent_record.set('employee_id_witness_name', all_name);
                content_and_notarize_witness_return();
            }
            
            function on_content_and_notarize_witness_submitfailed(res) {
                content_and_notarize_witness_unlock_win();
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="con_content_and_notarize_witness_query_ds" autoCreate="true">
                <a:fields>
                    <a:field name="content_id" defaultValue="${/parameter/@content_id}"/>
                    <a:field name="employee_code" lovGridHeight="350" lovHeight="500" lovService="basic.hls_exp_employees_for_lov" lovWidth="500" title="CON506.EMPLOYEE_ID_WITNESS_NAME">
                        <a:mapping>
                            <a:map from="employee_id" to="employee_id"/>
                            <a:map from="employee_code" to="employee_code"/>
                            <a:map from="name" to="employee_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="employee_id"/>
                    <a:field name="employee_name" readOnly="true"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="con_content_and_notarize_witness_result_ds" autoQuery="true" model="cont.CON506.con_contract_cont_witness" queryDataSet="con_content_and_notarize_witness_query_ds" selectable="true" submitUrl="${/request/@context_path}/modules/cont/CON506/con_content_and_notarize_witness_save.lsc">
                <a:fields>
                    <a:field name="employee_code" lovGridHeight="350" lovHeight="500" lovService="cont.CON506.con_content_and_notarize_query" lovWidth="500" required="true" title="CON506.EMPLOYEE_ID_WITNESS_NAME">
                        <a:mapping>
                            <a:map from="employee_id" to="employee_id"/>
                            <a:map from="employee_code" to="employee_code"/>
                            <a:map from="name" to="employee_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="employee_name"/>
                    <a:field name="content_id" defaultValue="${/parameter/@content_id}"/>
                </a:fields>
                <a:events>
                    <a:event name="submitsuccess" handler="on_content_and_notarize_witness_submitsuccess"/>
                    <a:event name="submitfailed" handler="on_content_and_notarize_witness_submitfailed"/>
                    <a:event name="remove" handler="on_content_and_notarize_witness_remove"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:gridButton click="content_and_notarize_witness_return" text="HLS.RETURN"/>
                <a:gridButton click="content_and_notarize_witness_query" text="HLS.QUERY"/>
                <a:gridButton click="content_and_notarize_witness_new" text="HLS.NEW"/>
                <a:gridButton click="content_and_notarize_witness_remove" text="HLS.REMOVE"/>
                <a:gridButton click="content_and_notarize_witness_save" text="HLS.SAVE"/>
            </a:screenTopToolbar>
            <a:form column="2" title="CON506.EMPLOYEE_ID_WITNESS_NAME">
                <a:lov name="employee_code" bindTarget="con_content_and_notarize_witness_query_ds" prompt="HLS.EMPLOYEE_CODE"/>
                <a:textField name="employee_name" bindTarget="con_content_and_notarize_witness_query_ds" prompt="HLS.EMPLOYEE_NAME"/>
            </a:form>
            <a:grid id="con_content_and_notarize_witness_grid_id" bindTarget="con_content_and_notarize_witness_result_ds" height="350" width="466">
                <a:columns>
                    <a:column name="employee_code" editor="witness_grid_lov_id" prompt="HLS.EMPLOYEE_CODE" width="200"/>
                    <a:column name="employee_name" prompt="HLS.EMPLOYEE_NAME" width="200"/>
                </a:columns>
                <a:editors>
                    <a:lov id="witness_grid_lov_id"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>
