<?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="gld532_journal_details_query_link" url="gld_journal_detail_query.lview"/>
        <a:link id="gld_posting_link" model="gld.GLD532.gld_journal_posting" modelaction="update"/>
        <script type="text/javascript"><![CDATA[
			
        	//查询按钮
        	function gld_532_journal_query()
        	{
        		$('gld_journal_headers_result_ds').query();
        	}
        	//重置按钮
        	function gld_532_journal_reset()
        	{
        	    $('gld_journal_headers_query').reset();
        	}
        	//退出按钮
        	function gld_532_journal_exit()
        	{
        	    history.go(-1);
        	}
			//拒绝按钮
			function gld_532_journal_refused()
			{
				
			}
        	//过账按钮
        	function gld_532_journal_posting()
        	{
        	    //获取选中的行
        	    var records = $('gld_journal_headers_result_ds').getCurrentRecord();
        	    if(	records.length<1 ){
        	    	Leaf.showMessage('提示','请选择行!');
        	    	return;
        	    }
        	    if( !$('gld_journal_headers_result_ds').validate()){
        	    	return;
        	    } 
        	    var journal_header_id = records.get('journal_header_id');
        	    var journal_num = records.get('journal_num');   	   	
        	    //batch_update 代表多条数据批次更新     如果是update--则是表示更新一条数据
				//$('gld_journal_headers_result_ds').submitSelected('${/request/@context_path}/autocrud/gld.GLD531.gld_journal_posting/batch_update');
				Leaf.Masker.mask(Ext.getBody(), '正在过账..');
				Leaf.request({
                        url: $('gld_posting_link').getUrl(),
                        para: {
                            journal_header_id:journal_header_id
                        },
                        success: function(args) { //
                             Leaf.SideBar.show({
			                            	msg: '过账成功',
			                            	duration: 4000
	                        			});
                         $('gld_journal_headers_result_ds').query();   
                         Leaf.Masker.unmask(Ext.getBody());
                        },
                        scope: this
                    });
				//更新完后台数据库数据之后,重新查询相关信息
				
        	}

        	function gld_532_journal_details_link(id){
        	    var url = $('gld532_journal_details_query_link').getUrl() + '?journal_header_id=' + id;
                var win = new Leaf.Window({
                     id: 'gld532_journal_num_query_window',
                     url: url,
                     title: '凭证详细查询',
                     fullScreen: true
                 });
				  win.on('close', function() {                           
                                $('gld_journal_headers_result_ds').query();
                        }); 
        	}
        	//
        	function gld_532_renderer_journal_detail_query(value,record,name)
        	{
        	    return '<a href="javascript:gld_532_journal_details_link(' + record.get('journal_header_id') + ');">' + value + '</a>';
        	}
       	 ]]></script>
        <a:dataSets>
            <a:dataSet id="gld_532_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_532_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:field name="created_name"/>
                    <a:field name="approved_name"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="gld_journal_headers_result_ds" autoQuery="true" model="gld.GLD532.gld_journal_headers" queryDataSet="gld_journal_headers_query" selectable="true" selectionModel="single">
                <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_532_journal_exit   " text="后退"/>
                <a:toolbarButton click="gld_532_journal_query  " text="查询"/>
                <a:toolbarButton click="gld_532_journal_reset  " text="重置"/>
				<a:toolbarButton click="gld_532_journal_refused  " text="拒绝"/>
                <a:toolbarButton click="gld_532_journal_posting" 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:comboBox name="created_name" bindTarget="gld_journal_headers_query" prompt="制单人"/>
                <a:comboBox name="approved_name" 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_532_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>
    </a:view>
</a:screen>