<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: DJ  
    $Date: 2013-2-26 下午2:37:49  
    $Revision: 1.0  
    $Purpose: projectQueryScreen
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure>
        <a:model-query defaultWhereClause="t1.document_type in (&apos;PRJL&apos;,&apos;PRJLB&apos;)" fetchAll="true" model="basic.hls_document_type_v_lov" rootPath="document_type_rp"/>
    </a:init-procedure>
    <a:view>
        <a:link id="pageLink_projectQueryScreen_welcome" url="${/request/@context_path}/welcome.lview"/>
        <a:link id="pageLink_projectQueryScreen_update_project" url="${/request/@context_path}/modules/prj/PRJ501/prj_project_maintain.lview"/>
        <a:link id="prj_project_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="prj_project_update_print_information_link_id" model="prj.PRJ501.prj_project_update_print_information" modelaction="update"/>
        <a:link id="prj_project_close_link_id" model="prj.PRJ501.prj_project_close" modelaction="update"/>
        <a:link id="prj_project_print_detail_link_id" url="${/request/@context_path}/modules/prj/PRJ501/prj_project_print_detail.lview"/>
        <a:link id="prj_project_update_link_id" url="${/request/@context_path}/modules/prj/PRJ500/prj_project_create_tree.lview"/>
        <a:link id="prj501_project_bp_parameter_link" url="${/request/@context_path}/modules/prj/PRJ501/prj_project_bp_parameter.lview"/>
        <script type="text/javascript"><![CDATA[
            function projectQueryScreen_forward() {
                history.go(1);
            }
            
            function projectQueryScreen_back() {
                history.go(-1);
            }
            
            function projectQueryScreen_query() {
                set_print_btn_enable();
                $('projectQueryScreen_mainDs').query();
            }
            
            function projectQueryScreen_refresh() {
                var ds = $('projectQueryScreen_mainDs');
                ds.query(ds.currentPage);
            }
            
            function projectQueryScreen_save() {
                var ds = $('projectQueryScreen_mainDs');
                if (ds.validate()) {
                    ds.submit();
                }
            }
            
            function projectQueryScreen_quit() {
                location.href = $('pageLink_projectQueryScreen_welcome').getUrl();
                parent.shMenu('show');
            }
            
            function lock_current_window() {
                Leaf.Masker.mask(document.documentElement, '${l:HLS.EXECUTING}');
            }
            
            function unlock_current_window() {
                Leaf.Masker.unmask(document.documentElement);
            }
            
            function set_print_btn_disable(){
             	//$('projectprint_id').disable();   
            }
            
            function set_print_btn_enable(){
             	//$('projectprint_id').enable();   
            }
            
            function projectQueryScreen_projectPrint() {
                lock_current_window();
                set_print_btn_disable();
                var records = $('projectQueryScreen_mainDs').getSelected();
                if (records.length != 1) {
                    Leaf.showMessage('${l:PROMPT}', '${l:HLS.SELECT_RECORD}');
                    unlock_current_window();
                    set_print_btn_enable();
                    return;
                }
                var record = records[0],
                    project_id = record.get('project_id');
                Leaf.request({
                    url: $('prj_project_update_print_information_link_id').getUrl(),
                    para: {
                        project_id: project_id
                    },
                    success: function() {
                        var url = $('prj_project_print_detail_link_id').getUrl() + '?project_id=' + project_id;
                        var form = document.createElement("form");
                        form.target = "word_export_window";
                        form.method = "post";
                        form.action = url;
                        var iframe = Ext.get('word_export_window') || new Ext.Template('<iframe id ="word_export_window" name="word_export_window" style="position:absolute;left:-10000px;top:-10000px;width:1px;height:1px;display:none"></iframe>').insertFirst(document.body, {}, true);
                        document.body.appendChild(form);
                        form.submit();
                        Ext.fly(form).remove();
                        unlock_current_window();
                    },
                    failure: function() {
                        unlock_current_window();
                        set_print_btn_enable();
                    },
                    error: function() {
                        unlock_current_window();
                        set_print_btn_enable();
                    },
                    scope: this
                });
            }
            var ajax_flag = 'N';
            
            function projectQueryScreen_projectClose() {
                lock_current_window();
                var result_ds = $('projectQueryScreen_mainDs');
                var records = result_ds.getSelected();
                if (records.length != 1) {
                    Leaf.showMessage('${l:PROMPT}', '${l:HLS.SELECT_RECORD}');
                    unlock_current_window();
                    return;
                }
                var record = records[0],
                    project_id = record.get('project_id');
                var confirm_win = Leaf.showConfirm('${l:PROMPT}', '${l:HLS.PROJECT_NUMBER}:' + record.get('project_number') + ',${l:HLS.IS_CLOSE_CONFIRM}', function() {
                    ajax_flag = 'Y';
                    Leaf.request({
                        url: $('prj_project_close_link_id').getUrl(),
                        para: {
                            project_id: project_id
                        },
                        success: function(res) {
                            parent.Leaf.SideBar.enable = true;
                            parent.Leaf.SideBar.show({
                                msg: '${l:HLS.SUBMIT_SUCCESS}',
                                duration: 2000
                            });
                            result_ds.query(result_ds.currentPage);
                            unlock_current_window();
                        },
                        error: function(res) {
                            unlock_current_window();
                        },
                        faliure: function() {
                            unlock_current_window();
                        },
                        scope: this
                    });
                }, function(res) {
                    unlock_current_window();
                });
                confirm_win.on('close', function() {
                    if (ajax_flag == 'N') {
                        unlock_current_window();
                    }
                });
            
            }
            
            function prj501_grid_update(reocrd_id, project_id, status) {
                var maintain_type = 'UPDATE';
                var record = $('projectQueryScreen_mainDs').findById(reocrd_id);
                var param = record.data;
                param['function_code'] = 'PRJ501';
                param['document_id'] = project_id;
                param['function_usage'] = 'MODIFY';
                param['maintain_type'] = maintain_type;
                param['url_title'] = '${l:HLS.PROJECT_MAITAIN}';
                hls_doc_get_layout_code('prj_project_get_layout_code_link_id', param, 'prj_project_update_link_id', 'projectQueryScreen_mainDs');
            }
            
            function prj501_project_number_render(value, record, name) {
                return '<a href="javascript:prj501_grid_update(' + record.id + ',' + record.get('project_id') + ',\'' + record.get('invoice_status') + '\');">' + value + '</a>';
            }
            
            function render_formatDate(value, record, name) {
                if (!Ext.isEmpty(value)) {
                    return value.parseDate('yyyy-mm-dd').format('yyyy-mm-dd');
                }
                return '';
            
            }
            
            function projectQueryScreen_project_parameter_update() {
                var ds = $('projectQueryScreen_mainDs');
                var record = ds.getCurrentRecord();
                var win = new Leaf.Window({
                    id: 'prj501_project_bp_parameter_window',
                    url: $('prj501_project_bp_parameter_link').getUrl(),
                    params: {
                        project_id: record.get('project_id')
                    },
                    title: '${l:HLS.PROJECT_PARAMETER_UPDATE}',
                    width: 620,
                    height: 520
                });
                win.on('close', function() {
                    ds.query(ds.currentPage);
                });
            }
        ]]></script>
        <a:screen-include screen="modules/prj/PRJ500/prj_project_get_layout_code.lview"/>
        <a:screen-include screen="modules/cont/CON500/con_contract_authority_list_validate.lview?document_category=PROJECT&amp;function_code=PRJ501"/>
        <a:dataSets>
            <a:dataSet id="employee_id_of_manager_n_ds" loadData="true" model="basic.exp_org_unit_manager_lov"/>
            <a:dataSet id="project_status_ds" lookupCode="PRJ501_PRJ_STATUS"/>
            <a:dataSet id="hls_document_type_ds">
                <a:datas dataSource="/model/document_type_rp"/>
            </a:dataSet>
            <a:dataSet id="projectQueryScreen_organizationDs" loadData="true" model="basic.hls_lease_organization_for_lov"/>
            <a:dataSet id="projectQueryScreen_channelDs" loadData="true" model="basic.hls_lease_channel_for_lov"/>
            <a:dataSet id="projectQueryScreen_divisionDs" loadData="true" model="basic.hls_division_for_lov"/>
            <a:dataSet id="projectQueryScreen_paraDs">
                <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" title="HLS.BP_TITLE">
                        <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" autoComplete="true" lovGridHeight="300" lovHeight="450" lovService="prj.PRJ501.prj_project_for_lov" lovWidth="500" title="HLS.PROJECT_NUMBER">
                        <a:mapping>
                            <a:map from="project_number" to="project_number"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="chance_number" autoComplete="true" lovGridHeight="300" lovHeight="450" lovService="prj.PRJ401.prj_chance_lov" lovWidth="500" title="HLS.LEASE_CHANCE_CODE">
                        <a:mapping>
                            <a:map from="chance_number" to="chance_number"/>
                        </a:mapping>
                    </a:field>
                    <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" title="HLS.SALES_EMPLOYEE">
                        <a:mapping>
                            <a:map from="employee_id" to="employee_id"/>
                            <a:map from="name" to="employee_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="unit_id"/>
                    <a:field name="unit_name" lovGridHeight="300" lovHeight="450" lovService="basic.exp_org_unit_name_lov" lovWidth="500" title="HLS.UNIT_NAME">
                        <a:mapping>
                            <a:map from="unit_id" to="unit_id"/>
                            <a:map from="unit_name" to="unit_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="lease_organization_n" displayField="description" options="projectQueryScreen_organizationDs" returnField="lease_organization" valueField="lease_organization"/>
                    <a:field name="lease_channel_n" displayField="description" options="projectQueryScreen_channelDs" returnField="lease_channel" valueField="lease_channel"/>
                    <a:field name="division_n" displayField="description" options="projectQueryScreen_divisionDs" returnField="division" valueField="division"/>
                    <!-- <a:field name="employee_id_of_manager_n" displayField="mgr_employee_name" options="employee_id_of_manager_n_ds" returnField="employee_id_of_manager" valueField="mgr_employee_id"/> -->
                    <!-- <a:field name="employee_id_of_manager_n" lovGridHeight="350" lovHeight="500" lovService="basic.exp_org_unit_manager_lov" lovWidth="500">
                        <a:mapping>
                            <a:map from="mgr_employee_id" to="employee_id_of_manager"/>
                            <a:map from="mgr_employee_name" to="employee_id_of_manager_n"/>
                        </a:mapping>
                    </a:field> -->
                    <a:field name="employee_id_of_manager"/>
                    <a:field name="employee_id_of_manager_n" lovGridHeight="400" lovHeight="550" lovService="prj.PRJ505.prj_project_unit_employee_lov" lovWidth="450">
                        <a:mapping>
                            <a:map from="value_code" to="employee_id_of_manager"/>
                            <a:map from="value_name" to="employee_id_of_manager_n"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="document_type_n" displayField="document_type_desc" options="hls_document_type_ds" returnField="document_type" valueField="document_type">
                        <a:mapping>
                            <a:map from="business_type" to="business_type"/>
                            <a:map from="business_type_desc" to="business_type_n"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="project_status"/>
                    <a:field name="project_status_dis" displayField="code_value_name" options="project_status_ds" returnField="project_status" valueField="code_value"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="projectQueryScreen_mainDs" autoPageSize="true" autoQuery="true" model="prj.PRJ501.prj_project_v" queryDataSet="projectQueryScreen_paraDs" selectable="true" selectionModel="single">
                <a:events>
                    <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="projectQueryScreen_back" text="HLS.BACK"/>
                <a:gridButton click="projectQueryScreen_forward" text="HLS.FORWARD"/>
                <a:gridButton click="projectQueryScreen_quit" text="HLS.EXIT"/>
                <a:gridButton click="projectQueryScreen_query" text="HLS.QUERY"/>
                <!-- <a:gridButton id="projectprint_id" click="projectQueryScreen_projectPrint" text="PRJ501.BUTTON.PRINT_PROJECT"/> -->
                <a:gridButton click="projectQueryScreen_projectClose" text="PRJ501.BUTTON.CLOSE_PROJECT"/>
                <a:gridButton click="projectQueryScreen_project_parameter_update" text="HLS.PROJECT_PARAMETER_UPDATE"/>
            </a:screenTopToolbar>
            <a:form column="4" labelSeparator=" " labelWidth="100" marginWidth="30" title="HLS.QUERY_TITLE">
                <a:lov name="bp_code" bindTarget="projectQueryScreen_paraDs" prompt="HLS.TENANT_CODE">
                    <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="projectQueryScreen_paraDs" prompt="HLS.TENANT_NAME"/>
                <a:datePicker name="creation_date_from" bindTarget="projectQueryScreen_paraDs" prompt="LCH501.QUERY_FIELD.CREATION_DATE_FROM"/>
                <a:datePicker name="creation_date_to" bindTarget="projectQueryScreen_paraDs" prompt="LCH501.QUERY_FIELD.CREATION_DATE_TO"/>
                <a:lov name="project_number" bindTarget="projectQueryScreen_paraDs" prompt="HLS.PROJECT_NUMBER">
                    <a:events>
                        <a:event name="focus" handler="function(object){on_std_focus(object,&apos;PROJECT&apos;)}"/>
                    </a:events>
                </a:lov>
                <a:textField name="project_name" bindTarget="projectQueryScreen_paraDs" prompt="HLS.PROJECT_NAME"/>
                <a:lov name="employee_name" bindTarget="projectQueryScreen_paraDs" prompt="HLS.SALES_EMPLOYEE"/>
                <a:comboBox name="lease_organization_n" bindTarget="projectQueryScreen_paraDs" prompt="HLS.LEASE_ORGANIZATION"/>
                <a:lov name="chance_number" bindTarget="projectQueryScreen_paraDs" prompt="HLS.LEASE_CHANCE_CODE">
                    <a:events>
                        <a:event name="focus" handler="function(object){on_std_focus(object,&apos;CHANCE&apos;)}"/>
                    </a:events>
                </a:lov>
                <a:lov name="employee_id_of_manager_n" bindTarget="projectQueryScreen_paraDs" prompt="HLS.EMPLOYEE_OF_MANAGER"/>
                <a:comboBox name="division_n" bindTarget="projectQueryScreen_paraDs" prompt="HLS.DIVISION_NAME"/>
                <a:comboBox name="lease_channel_n" bindTarget="projectQueryScreen_paraDs" prompt="HLS.LEASE_CHANNEL_NAME"/>
                <a:textField name="search_term_1" bindTarget="projectQueryScreen_paraDs" prompt="CON301.CON_CONTRACT_V.PRJ_SEARCH_TERM_1"/>
                <a:numberField name="search_term_2" bindTarget="projectQueryScreen_paraDs" prompt="CON301.CON_CONTRACT_V.PRJ_SEARCH_TERM_2"/>
                <a:comboBox name="document_type_n" bindTarget="projectQueryScreen_paraDs" prompt="HLS.PROJECT_TYPE"/>
                <a:comboBox name="project_status_dis" bindTarget="projectQueryScreen_paraDs" prompt="PRJ505.PROJECT_STATUS"/>
            </a:form>
            <a:grid id="projectQueryScreen_mainDs_grid" bindTarget="projectQueryScreen_mainDs" marginHeight="240" marginWidth="30" navBar="true">
                <a:columns>
                    <a:column name="project_number" prompt="PRJ501.PRJ_PROJECT.PROJECT_NO" renderer="prj501_project_number_render" width="120"/>
                    <a:column name="project_name" prompt="HLS.PROJECT_NAME" width="250"/>
                    <a:column name="bp_name" prompt="HLS.TENANT_NAME" width="180"/>
                    <a:column name="chance_number" prompt="HLS.LEASE_CHANCE_CODE" width="150"/>
                    <a:column name="document_type_desc" prompt="HLS.PROJECT_TYPE"/>
                    <a:column name="employee_id_of_manager_desc" prompt="HLS.EMPLOYEE_OF_MANAGER"/>
                    <a:column name="lease_organization_desc" prompt="HLS.LEASE_ORGANIZATION"/>
                    <a:column name="creation_date" prompt="HLS.CREATION_DATE" renderer="render_formatDate"/>
                    <a:column name="project_status_desc" prompt="HLS.PROJECT_STATUS"/>
                </a:columns>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>