<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: MUMU  
    $Date: 2013-09-13 下午5:01:56  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure>
        <a:model-query defaultWhereClause="(document_category = &apos;GLD_JE&apos; and enabled_flag = &apos;Y&apos;)" fetchAll="true" model="gld.GLD531.hls_document_type_combo" queryOrderBy="document_type desc" rootPath="gld_531_category_code_list"/>
    </a:init-procedure>
    <a:view>
        <a:link id="gld531_journal_query_link" model="gld.GLD531.gld_journal_headers"/>
        <a:link id="gld531_journal_approved_link" model="gld.GLD531.gld_journal_approved" modelaction="update"/>
        <a:link id="gld531_journal_reject_link" model="gld.GLD531.gld_journal_reject" modelaction="update"/>
        <a:link id="gld310_journal_details_query_link" url="gld_journal_detail_query.lview"/>
        <script type="text/javascript"><![CDATA[
        	//查询按钮
        	function gld_531_journal_query()
        	{
        		$('gld_journal_headers_result_ds').query();
        	}
        	//重置按钮
        	function gld_531_journal_reset()
        	{
        	    $('gld_journal_headers_result_ds').reset();
        	}
        	//退出按钮
        	function gld_531_journal_exit()
        	{
        	    history.go(-1);
        	}
        	//拒绝按钮
        	function gld_531_journal_reject()
        	{
        	    //获取选中的行
        	    var records = $('gld_journal_headers_result_ds').getSelected();
        	    if(	records.length<1 ){
        	    	Leaf.showMessage('提示','请选择行!');
        	    	return;
        	    }
        	    if( !$('gld_journal_headers_result_ds').validate()){
        	    	return;
        	    }
				//batch_update 代表多条数据批次更新     如果是update--则是表示更新一条数据
				$('gld_journal_headers_result_ds').submitSelected('${/request/@context_path}/autocrud/gld.GLD531.gld_journal_reject/batch_update');
				//更新完后台数据库数据之后,重新查询相关信息
				$('gld_journal_headers_result_ds').query();
        	}
        	//审核按钮
        	function gld_531_journal_approved()
        	{
        	    //获取选中的行
        	    var records = $('gld_journal_headers_result_ds').getSelected();
        	    if(	records.length<1 ){
        	    	Leaf.showMessage('提示','请选择行!');
        	    	return;
        	    }
        	    if( !$('gld_journal_headers_result_ds').validate()){
        	    	return;
        	    }
        	    //batch_update 代表多条数据批次更新     如果是update--则是表示更新一条数据
				$('gld_journal_headers_result_ds').submitSelected('${/request/@context_path}/autocrud/gld.GLD531.gld_journal_approved/batch_update');
				Leaf.SideBar.show({
			                            	msg: '审核成功',
			                            	duration: 4000
	                        			});
				//更新完后台数据库数据之后,重新查询相关信息
				$('gld_journal_headers_result_ds').query();
        	}
        	
        	function gld_531_journal_details_link(id){
        	    var url = $('gld310_journal_details_query_link').getUrl() + '?journal_header_id=' + id;
                var win = new Leaf.Window({
                     id: 'gld531_journal_num_query_window',
                     url: url,
                     title: '凭证详细查询',
                     fullScreen: true
                 });
				 win.on('close', function() {                           
                                $('gld_journal_headers_result_ds').query();
                        }); 
        	}
        	//
        	function gld_531_renderer_journal_detail_query(value,record,name)
        	{
        	    return '<a href="javascript:gld_531_journal_details_link(' + record.get('journal_header_id') + ');">' + value + '</a>';
        	}
       	 ]]></script>
        <a:dataSets>
            <a:dataSet id="gld_531_category_code_ds">
                <a:datas dataSource="/model/gld_531_category_code_list"/>
            </a:dataSet>
            <a:dataSet id="gld_status_ds" lookupCode="GLD_JE_STATUS"/>
            <a:dataSet id="gld_journal_headers_query">
                <a:fields>
                    <a:field name="journal_num"/>
                    <a:field name="category_code_desc" displayField="description" options="gld_531_category_code_ds" returnField="category_code" valueField="document_type"/>
                    <a:field name="journal_date_from"/>
                    <a:field name="journal_date_to"/>
                    <a:field name="total_amount_dr_from"/>
                    <a:field name="total_amount_dr_to"/>
                    <a:field name="period_name"/>
                    <a:field name="period_year"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="gld_journal_headers_result_ds" autoQuery="true" model="gld.GLD531.gld_journal_headers" queryDataSet="gld_journal_headers_query" selectable="true">
                <a:fields>
                    <a:field name="journal_header_id"/>
                    <a:field name="journal_num" readOnly="true"/>
                    <a:field name="journal_date" readOnly="true"/>
                    <a:field name="category_code_desc" readOnly="true"/>
                    <a:field name="currency_code_desc" readOnly="true"/>
                    <a:field name="total_amount_dr" readOnly="true"/>
                    <a:field name="total_amount_cr" readOnly="true"/>
                    <a:field name="description" readOnly="true"/>
                    <a:field name="status_desc" displayField="code_value_name" options="gld_status_ds" returnField="status" valueField="code_value"/>
                    <a:field name="status" readOnly="true"/>
                    <a:field name="created_name" readOnly="true"/>
                    <a:field name="approved_name" readOnly="true"/>
                </a:fields>
                <!-- <a:events>
                    <a:event name="submitsuccess" handler="gld5020_gld_journal_audit_query_submitsuccess"/>
                    <a:event name="submitfailed" handler="gld5020_gld_journal_audit_query_submitfailed"/>
                </a:events> -->
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
				<a:toolbarButton click="gld_531_journal_exit   " text="后退"/>
                <a:toolbarButton click="gld_531_journal_query   " text="查询"/>
                <a:toolbarButton click="gld_531_journal_reset   " text="重置"/>
                
                <a:toolbarButton click="gld_531_journal_reject  " text="拒绝"/>
                <a:toolbarButton click="gld_531_journal_approved" text="审核"/>
            </a:screenTopToolbar>
            <a:form column="4" labelSeparator=" " labelWidth="100" marginWidth="30" title="HAP_QUERY_TITLE">
                <a:comboBox name="category_code_desc" bindTarget="gld_journal_headers_query" prompt="凭证类型"/>
                <a:textField name="journal_num" bindTarget="gld_journal_headers_query" prompt="凭证编号" typeCase="upper"/>
                <a:numberField name="total_amount_dr_from" allowFormat="true" bindTarget="gld_journal_headers_query" prompt="金额从"/>
                <a:numberField name="total_amount_dr_to" allowFormat="true" bindTarget="gld_journal_headers_query" prompt="金额至"/>
                <a:datePicker name="journal_date_from" bindTarget="gld_journal_headers_query" prompt="日期从"/>
                <a:datePicker name="journal_date_to" bindTarget="gld_journal_headers_query" prompt="至日期"/>
                <a:textField name="period_name" bindTarget="gld_journal_headers_query" prompt="会计期名称"/>
                <a:textField name="period_year" bindTarget="gld_journal_headers_query" prompt="会计期年度"/>
            </a:form>
            <a:grid id="gld_journal_headers_grid" bindTarget="gld_journal_headers_result_ds" marginHeight="265" marginWidth="30" navBar="true">
                <a:columns>
                    <a:column name="journal_num" prompt="凭证编号" renderer="gld_531_renderer_journal_detail_query" width="120"/>
                    <a:column name="journal_date" prompt="凭证日期" renderer="Leaf.formatDate" width="90"/>
                    <a:column name="category_code_desc" prompt="凭证类型" width="80"/>
                    <a:column name="currency_code_desc" prompt="币种" width="80"/>
                    <a:column name="total_amount_dr" align="right" prompt="借方原币金额" renderer="Leaf.formatMoney" width="90"/>
                    <a:column name="total_amount_cr" align="right" prompt="贷方原币金额" renderer="Leaf.formatMoney" width="90"/>
                    <a:column name="description" prompt="摘要" width="90"/>
                    <a:column name="status_desc" prompt="状态" width="80"/>
                    <a:column name="created_name" prompt="制单人" width="90"/>
                    <a:column name="approved_name" prompt="审核人" width="90"/>
                </a:columns>
            </a:grid>
        </a:screenBody>
        <!-- <script type="text/javascript"><![CDATA[
        	Leaf.onReady(function(){
        	    $('gld5020_journal_headers_ds').setQueryParameter('journal_header_id','${/parameter/@journal_header_id}');
        	    $('gld5020_journal_details_ds').setQueryParameter('journal_header_id','${/parameter/@journal_header_id}');
        	    $('gld5020_journal_headers_ds').query();
        	    $('gld5020_journal_details_ds').query();
        	});
        ]]></script> -->
    </a:view>
</a:screen>