<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gaoyang  
    $Date: 2013-4-2 上午10:30:59  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" trace="true">
    <a:init-procedure>
        <a:model-query defaultWhereClause="(t1.enabled_flag=&apos;Y&apos;)" fetchAll="true" model="basic.hls_lease_item_type_v_for_lov" rootPath="lease_item_type"/>
        <a:model-query fetchAll="true" model="basic.fnd_uom_codes_vl_for_lov" rootPath="uom_codes"/>
        <a:model-query fetchAll="true" model="gld.gld_currency_vl" rootPath="currency"/>
        <a:model-query fetchAll="true" model="basic.hls_division_for_lov" rootPath="lease_division"/>
        <a:model-query defaultWhereClause="(t1.enabled_flag=&apos;Y&apos;)" fetchAll="true" model="basic.hls_abc_class_v_for_lov" rootPath="abc_class"/>
        <a:model-query defaultWhereClause="(t1.enabled_flag=&apos;Y&apos; and t1.authority_usage=&apos;LEASE_ITEM&apos;)" fetchAll="true" model="aut.AUT005.aut_authority_group" rootPath="lease_item_group"/>
        <a:model-query model="basic.hls_fnd_companies_vl" rootPath="default_value"/>
        <a:model-query defaultWhereClause="(t1.enabled_flag=&apos;Y&apos; and t1.lease_object_type = &apos;LEASE_PRODUCT&apos;)" fetchAll="true" model="fnd.FND401.fnd_authorization_group" rootPath="fnd_authorization_group"/>
    </a:init-procedure>
    <a:view>
        <a:link id="hls_lease_item_update_id" url="${/request/@context_path}/modules/hls/HLS201/hls_lease_item_update.lview"/>
        <a:link id="hls_lease_item_success_query_id" url="${/request/@context_path}/modules/hls/HLS201/hls_lease_item_query.lview"/>
        <script type="text/javascript"><![CDATA[
            function do_hls201_new_save() {
                var body=$('hls_lease_item_create_winId').wrap;
                $('hls201_new_save_id').disable();
                Leaf.Masker.mask(body, '${l:BEING_IMPLEMENTED}');
                if (!$('lease_item_add_sys_ds').validate()) {
                    $('hls201_new_save_id').enable();
                    Leaf.Masker.unmask(body);
                    return;
                }
                var sys_record = $('lease_item_add_sys_ds').getAt('0');
                var company_record = $('lease_item_add_company_ds').getAt('0');
                sys_record.set('_status', 'insert');
                sys_record.set('division', company_record.get('division'));
                sys_record.set('abc_class', company_record.get('abc_class'));
                sys_record.set('lease_item_group', company_record.get('lease_item_group'));
                sys_record.set('company_enabled_flag', company_record.get('company_enabled_flag'));
                var saveData = [];
                saveData.push(sys_record.data);
                Leaf.request({
                    url: '${/request/@context_path}/autocrud/hls.HLS201.hls_lease_item_save/batch_update',
                    para: saveData,
                    success: function(res) {
                        	Leaf.SideBar.show({
	                    		msg:'${l:HLS.SUBMIT_SUCCESS}',
	                    		duration:2000
							});
                            var url = $('hls_lease_item_update_id').getUrl() + '?lease_item_id=' + res.result.lease_item_id;
                            $('hls_lease_item_result_ds').query();
                            Leaf.Masker.unmask(body);
                            $('hls_lease_item_create_winId').close();
                            new Leaf.Window({
                                url: url,
                                title: '${l:HLS_LEASE_ITEM.LEASE_ITEM_UPDATE}',
                                id: 'hls_lease_item_update_success',
                                width: 1000,
                                height: 540
                            });
                    },
                    error: function() {
                        $('hls201_new_save_id').enable();
                        Leaf.Masker.unmask(body);
                    },
                    failure: function() {
                        $('hls201_new_save_id').enable();
                        Leaf.Masker.unmask(body);
                    },
                    scope: this
                });
            }
            
            function do_hls201_new_back() {
                window.location = $('hls_lease_item_success_query_id').getUrl();
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="lease_item_type_ds">
                <a:datas dataSource="/model/lease_item_type"/>
            </a:dataSet>
            <a:dataSet id="uom_name_ds">
                <a:datas dataSource="/model/uom_codes"/>
            </a:dataSet>
            <a:dataSet id="currency_ds">
                <a:datas dataSource="/model/currency"/>
            </a:dataSet>
            <a:dataSet id="lease_division_ds">
                <a:datas dataSource="/model/lease_division"/>
            </a:dataSet>
            <a:dataSet id="abc_class_ds">
                <a:datas dataSource="/model/abc_class"/>
            </a:dataSet>
            <a:dataSet id="lease_item_group_ds">
                <a:datas dataSource="/model/lease_item_group"/>
            </a:dataSet>
            <a:dataSet id="fnd_authorization_group_ds">
                <a:datas dataSource="/model/fnd_authorization_group"/>
            </a:dataSet>
            <a:dataSet id="lease_item_add_sys_ds" autoCreate="true">
                <a:fields>
                    <a:field name="lease_item_type_desc" displayField="description" options="lease_item_type_ds" required="true" returnField="lease_item_type" valueField="lease_item_type"/>
                    <a:field name="lease_item_type"/>
                    <a:field name="lease_item_code" readOnly="true"/>
                    <a:field name="short_name"/>
                    <a:field name="full_name"/>
                    <a:field name="serial_number"/>
                    <a:field name="pattern"/>
                    <a:field name="vender_name"/>
                    <a:field name="manufacturer_name"/>
                    <a:field name="specification"/>
                    <a:field name="manufacturing_date"/>
                    <a:field name="uom_name" displayField="description_text" options="uom_name_ds" returnField="uom" valueField="uom_code"/>
                    <a:field name="uom"/>
                    <a:field name="currency_name" displayField="currency_name" options="currency_ds" returnField="currency" valueField="currency_code"/>
                    <a:field name="price"/>
                    <a:field name="quantity"/>
                    <a:field name="original_asset_value"/>
                    <a:field name="net_asset_value"/>
                    <a:field name="accumulated_depreciation"/>
                    <a:field name="detention"/>
                    <a:field name="installation_site"/>
                    <a:field name="fixed_assets_site"/>
                    <a:field name="description"/>
                    <a:field name="enabled_flag" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="lease_item_add_company_ds" autoCreate="true">
                <a:fields>
                    <a:field name="company_code" defaultValue="${/model/default_value/record/@company_code}" readOnly="true"/>
                    <a:field name="company_name" defaultValue="${/model/default_value/record/@company_short_name}" readOnly="true"/>
                    <a:field name="company_enabled_flag" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                    <a:field name="division_display" displayField="description" options="lease_division_ds" returnField="division" valueField="division"/>
                    <a:field name="division"/>
                    <a:field name="abc_class_display" displayField="description" options="abc_class_ds" returnField="abc_class" valueField="abc_class"/>
                    <a:field name="abc_class"/>
                    <a:field name="lease_item_group_display" displayField="description" options="lease_item_group_ds" returnField="lease_item_group" valueField="lease_item_group"/>
                    <a:field name="lease_item_group"/>
                    <a:field name="authorization_group_display" displayField="description" options="fnd_authorization_group_ds" returnField="authorization_group" valueField="authorization_group"/>
                    <a:field name="authorization_group"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:form title="HLS_LEASE_ITEM.BASIC_INFORMATION" width="900">
                <a:box column="3" labelWidth="100">
                    <a:comboBox name="lease_item_type_desc" bindTarget="lease_item_add_sys_ds" prompt="HLS.LEASE_ITEM_TYPE"/>
                    <a:textField name="lease_item_code" bindTarget="lease_item_add_sys_ds" prompt="HLS.LEASE_ITEM_CODE"/>
                    <a:textField name="short_name" bindTarget="lease_item_add_sys_ds" prompt="HLS_LEASE_ITEM.SHORT_NAME"/>
                </a:box>
                <a:box column="3" labelWidth="100">
                    <a:textField name="full_name" bindTarget="lease_item_add_sys_ds" prompt="HLS_LEASE_ITEM.FULL_NAME"/>
                    <a:textField name="serial_number" bindTarget="lease_item_add_sys_ds" prompt="HLS_LEASE_ITEM.SERIAL_NUMBER"/>
                    <a:textField name="search_term" bindTarget="lease_item_add_sys_ds" prompt="HLS_LEASE_ITEM.SEARCH_TERM" typeCase="upper"/>
                </a:box>
                <a:box column="3" labelWidth="100">
                    <a:textField name="specification" bindTarget="lease_item_add_sys_ds" prompt="HLS.SPECIFICATION"/>
                    <a:textField name="pattern" bindTarget="lease_item_add_sys_ds" prompt="HLS.PATTERN"/>
                    <a:comboBox name="currency_name" bindTarget="lease_item_add_sys_ds" prompt="HLS.CURRENCY"/>
                </a:box>
                <a:box column="3" labelWidth="100">
                    <a:numberField name="price" allowDecimals="true" allowFormat="true" allowNegative="false" bindTarget="lease_item_add_sys_ds" decimalPrecision="2" prompt="HLS.AMOUNT"/>
                    <a:numberField name="quantity" allowDecimals="true" allowFormat="true" allowNegative="false" bindTarget="lease_item_add_sys_ds" decimalPrecision="2" prompt="HLS.PRIMARY_QUANTITY"/>
                    <a:comboBox name="uom_name" bindTarget="lease_item_add_sys_ds" prompt="HLS.UOM"/>
                </a:box>
                <a:box column="3" labelWidth="100">
                    <a:numberField name="original_asset_value" allowDecimals="true" allowFormat="true" allowNegative="false" bindTarget="lease_item_add_sys_ds" decimalPrecision="2" prompt="HLS_LEASE_ITEM.ORIGINAL_ASSET_VALUE"/>
                    <a:numberField name="accumulated_depreciation" allowDecimals="true" allowFormat="true" allowNegative="false" bindTarget="lease_item_add_sys_ds" decimalPrecision="2" prompt="HLS_LEASE_ITEM.ACCUMULATED_DEPRECIATION"/>
                    <a:numberField name="net_asset_value" allowDecimals="true" allowFormat="true" allowNegative="false" bindTarget="lease_item_add_sys_ds" decimalPrecision="2" prompt="HLS_LEASE_ITEM.NET_ASSET_VALUE"/>
                </a:box>
                <a:box column="3" labelWidth="100">
                    <a:numberField name="detention" allowDecimals="true" allowFormat="true" allowNegative="false" bindTarget="lease_item_add_sys_ds" decimalPrecision="2" prompt="HLS_LEASE_ITEM.DETENTION"/>
                    <a:numberField name="manufacturing_date" allowDecimals="false" allowNegative="false" bindTarget="lease_item_add_sys_ds" prompt="HLS_LEASE_ITEM.MANUFACTURING_DATE"/>
                    <a:textField name="manufacturer_name" bindTarget="lease_item_add_sys_ds" prompt="HLS_LEASE_ITEM.MANUFACTURER_NAME"/>
                </a:box>
                <a:box column="3" labelWidth="100">
                    <a:textField name="fixed_assets_site" bindTarget="lease_item_add_sys_ds" prompt="HLS_LEASE_ITEM.FIXED_ASSETS_SITE"/>
                    <a:textField name="installation_site" bindTarget="lease_item_add_sys_ds" prompt="HLS_LEASE_ITEM.INSTALLATION_SITE"/>
                    <a:textField name="vender_name" bindTarget="lease_item_add_sys_ds" prompt="HLS.VENDER"/>
                    <!-- <a:checkBox name="enabled_flag" bindTarget="lease_item_add_sys_ds" prompt="HLS.ENABLED_FLAG"/> -->
                </a:box>
                <a:box column="3" labelWidth="100">
                    <a:textField name="description" bindTarget="lease_item_add_sys_ds" prompt="HLS_LEASE_ITEM.DESCRIPTION" width="610"/>
                </a:box>
            </a:form>
            <a:form title="HLS_LEASE_ITEM.COMPANY_INFORMATION" width="900">
                <a:box column="3" labelWidth="100">
                    <a:textField name="company_code" bindTarget="lease_item_add_company_ds" prompt="HLS.COMPANY_CODE"/>
                    <a:textField name="company_name" bindTarget="lease_item_add_company_ds" prompt="HLS.COMPANY_NAME"/>
                    <a:comboBox name="division_display" bindTarget="lease_item_add_company_ds" prompt="HLS.DIVISION"/>
                </a:box>
                <a:box column="3" labelWidth="100">
                    <a:comboBox name="abc_class_display" bindTarget="lease_item_add_company_ds" prompt="HLS.ABC_CLASS"/>
                    <a:comboBox name="lease_item_group_display" bindTarget="lease_item_add_company_ds" prompt="HLS.LEASE_ITEM_GROUP"/>
                    <a:comboBox name="authorization_group_display" bindTarget="lease_item_add_company_ds" prompt="AUT_AUTHORITY_GROUP.AUTHORITY_GROUP"/>
                </a:box>
                <a:box>
                    <a:checkBox name="company_enabled_flag" bindTarget="lease_item_add_company_ds" prompt="HLS.ENABLED_FLAG"/>
                </a:box>
            </a:form>
            <a:hBox>
                <a:screenTopToolbar>
                    <a:gridButton id="hls201_new_save_id" click="do_hls201_new_save" text="HLS.SAVE"/>
                    <a:gridButton click="do_hls201_new_back" text="HLS.BACK"/>
                </a:screenTopToolbar>
            </a:hBox>
        </a:screenBody>
    </a:view>
</a:screen>
