<?xml version="1.0" encoding="UTF-8"?>
<!--
	&author:DJ
	$date:2013/05/08
	$purpose:资金预约
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure>
        <a:model-query defaultWhereClause="v.code=&apos;RESERVE_STATUS&apos; and v.code_value=&apos;NOT&apos; " model="basic.sys_code_default_value" rootPath="default_reserve_status"/>
    </a:init-procedure>
    <a:view>
        <a:link id="tre510_attach_upload_link" url="${/request/@context_path}/uploadFile.lview"/>
        <script src="${/request/@context_path}/javascripts/calculate.js" type="text/javascript"/>
        <script type="text/javascript"><![CDATA[
	        function tre510_reserveDs_grid_query() {
	            $('tre510_reserveDs').query();
	        }
	        
	        function tre510_reserveDs_grid_save() {
	            var ds = $('tre510_reserveDs');
	            var records = ds.getSelected();
	            if(records.length>0)
	            {
	                ds.submitSelected();
	            }
	            else
	            {
	                Leaf.showMessage('${l:HLS.PROMPT}','${l:TRE510.CHECK_RESERVATION_PROJECT}');
	            }
                
	        }
	        
	        function onSubmitSuccess_tre510_reserveDs(ds,res)
	        {
	            tre510_reserveDs_grid_query();
	        }
	        
	        function render_tre510_reserveDs_grid(value,record,name)
	        {
	            if(name=='paid_probability')
	            {
	                if(Ext.isEmpty(value))
	                {
	                    return '';
	                }
	                return mul(value,100)+'%';
	            }
	        }
	        
	      function attach_upload_renderer(value,record,name){
	          if(!Ext.isEmpty(record.get('project_id'))){
	              return '<a href="javascript:attach_upload_win('+record.get('project_id')+')">'+'${l:TRE510.ATTACHMENT_UPLOAD}'+'</a>';
	          }
	      }
	      function attach_upload_win(project_id){
                var url = $('tre510_attach_upload_link').getUrl() + '?table_name=PRJ_PROJECT_TRE_FUNDS_RESERVATION&header_id='+project_id;
                new Leaf.Window({
                    url: url,
                    title: '${l:TRE510.ATTACHMENT_UPLOAD}',
                    id: 'tre_funds_reservation_win',
                    width: 850,
                    height: 400
                });
	      }
			
		]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_authority_list_validate.lview?document_category=PROJECT&amp;function_code=TRE510"/>
        <a:dataSets>
            <a:dataSet id="tre510_unitManagerDs" loadData="true" model="basic.exp_org_unit_manager_lov"/>
            <a:dataSet id="tre510_projectStatusDs" lookupCode="PRJ501_PRJ_STATUS"/>
            <a:dataSet id="tre510_orgDs" loadData="true" model="basic.hls_lease_organization_for_lov"/>
            <a:dataSet id="tre510_channelDs" loadData="true" model="basic.hls_lease_channel_for_lov"/>
            <a:dataSet id="tre510_divisionDs" loadData="true" model="basic.hls_division_for_lov"/>
            <a:dataSet id="tre510_reserveStatusDs" lookupCode="RESERVE_STATUS"/>
            <a:dataSet id="tre510_para_reserveDs" autoCreate="true" model="tre.tre510.tre_funds_reservation">
                <a:fields>
                    <a:field name="bp_code" autoComplete="true" lovGridHeight="350" lovHeight="500" lovService="basic.hls_bp_master_v_for_lov?bp_category=TENANT" lovWidth="500" prompt="HLS.TENANT_CODE" title="HLS.TENANT_CODE">
                        <a:mapping>
                            <a:map from="bp_code" to="bp_code"/>
                            <a:map from="bp_id" to="bp_id"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="project_number"/>
                    <a:field name="employee_id"/>
                    <a:field name="employee_name" autoComplete="true" lovGridHeight="300" lovHeight="450" lovService="basic.hls_salesman_v_for_lov" lovWidth="500" prompt="HLS.SALES_EMPLOYEE" title="PRJ501.PRJ_PROJECT.EMPLOYEE_NAME">
                        <a:mapping>
                            <a:map from="employee_id" to="employee_id"/>
                            <a:map from="name" to="employee_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="lease_organization_n" displayField="description" options="tre510_orgDs" prompt="HLS.LEASE_ORGANIZATION" returnField="lease_organization" valueField="lease_organization"/>
                    <a:field name="lease_channel_n" displayField="description" options="tre510_channelDs" prompt="HLS.LEASE_CHANNEL_NAME" returnField="lease_channel" valueField="lease_channel"/>
                    <a:field name="division_n" displayField="description" options="tre510_divisionDs" prompt="HLS.DIVISION_NAME" returnField="division" valueField="division"/>
                    <a:field name="employee_id_of_manager_n" displayField="mgr_employee_name" options="tre510_unitManagerDs" prompt="HLS.EMPLOYEE_OF_MANAGER" returnField="employee_id_of_manager" valueField="mgr_employee_id"/>
                    <a:field name="project_status"/>
                    <a:field name="project_status_desc" displayField="code_value_name" options="tre510_projectStatusDs" returnField="project_status" valueField="code_value"/>
                    <a:field name="status" defaultValue="${/model/default_reserve_status/record/@code_value}"/>
                    <a:field name="status_desc" defaultValue="${/model/default_reserve_status/record/@code_value_name}" displayField="code_value_name" options="tre510_reserveStatusDs" returnField="status" valueField="code_value"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="tre510_reserveDs" autoPageSize="true" autoQuery="true" model="tre.tre510.tre_funds_reservation" queryDataSet="tre510_para_reserveDs" selectable="true">
                <a:fields>
                    <a:field name="reserve_amount" required="true"/>
                    <a:field name="paid_date" required="true"/>
                    <!-- <a:field name="paid_probability" required="true"/> -->
                    <a:field name="description"/>
                </a:fields>
                <a:events>
                    <a:event name="submitsuccess" handler="onSubmitSuccess_tre510_reserveDs"/>
                    <a:event name="query" handler="aut_authority_list_validate_query"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="tre510_reserveDs_grid_query" text="HLS.QUERY"/>
                <a:gridButton click="tre510_reserveDs_grid_save" text="TRE510.RESERVATE_PROJECT"/>
            </a:screenTopToolbar>
            <a:form column="4" labelSeparator=" " labelWidth="100" marginWidth="30" title="HLS.QUERY_TITLE">
                <a:textField name="project_number" bindTarget="tre510_para_reserveDs"/>
                <a:textField name="project_name" bindTarget="tre510_para_reserveDs"/>
                <a:lov name="employee_name" bindTarget="tre510_para_reserveDs"/>
                <a:comboBox name="employee_id_of_manager_n" bindTarget="tre510_para_reserveDs"/>
                <a:lov name="bp_code" bindTarget="tre510_para_reserveDs">
                    <a:events>
                        <a:event name="focus" handler="function(object){on_std_focus(object,&apos;BP&apos;)}"/>
                    </a:events>
                </a:lov>
                <a:textField name="bp_name" bindTarget="tre510_para_reserveDs"/>
                <a:comboBox name="lease_organization_n" bindTarget="tre510_para_reserveDs"/>
                <a:comboBox name="division_n" bindTarget="tre510_para_reserveDs"/>
                <a:comboBox name="project_status_desc" bindTarget="tre510_para_reserveDs"/>
                <a:comboBox name="status_desc" bindTarget="tre510_para_reserveDs"/>
                <a:comboBox name="lease_channel_n" bindTarget="tre510_para_reserveDs"/>
            </a:form>
            <a:grid id="tre510_reserveDs_grid" bindTarget="tre510_reserveDs" marginHeight="250" marginWidth="30" navBar="true">
                <a:columns>
                    <a:column name="project_number" width="120"/>
                    <a:column name="project_name" showTitle="true" width="150"/>
                    <a:column name="bp_name" showTitle="true" width="150"/>
                    <a:column name="project_status_desc" width="100"/>
                    <a:column name="status_desc" width="100"/>
                    <a:column name="reserve_amount" align="right" editor="tre510_reserveDs_grid_nf" renderer="Leaf.formatMoney" width="120"/>
                    <a:column name="paid_date" editor="tre510_reserveDs_grid_dp" renderer="Leaf.formatDate" width="100"/>
                    <!-- <a:column name="paid_probability" align="right" editor="tre510_reserveDs_grid_pf" renderer="render_tre510_reserveDs_grid"/> -->
                    <a:column name="description" editor="tre510_reserveDs_grid_tf" width="200"/>
                    <a:column name="attach_upload" align="center" prompt="TRE510.ATTACHMENT_UPLOAD" renderer="attach_upload_renderer"/>
                </a:columns>
                <a:editors>
                    <a:percentField id="tre510_reserveDs_grid_pf"/>
                    <a:datePicker id="tre510_reserveDs_grid_dp"/>
                    <a:numberField id="tre510_reserveDs_grid_nf" allowFormat="true" allowNegative="false"/>
                    <a:textField id="tre510_reserveDs_grid_tf_upper" maxLength="30" typeCase="upper"/>
                    <a:textField id="tre510_reserveDs_grid_tf"/>
                    <a:comboBox id="tre510_reserveDs_grid_comb"/>
                    <a:checkBox id="tre510_reserveDs_grid_check"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>