<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: wangguangfan2864 
    $Date: 2011-8-5 上午09:11:20  
    $Revision: 1.0  
    $Purpose: 首页提醒定义
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure/>
    <a:view package="leaf.ui.std" template="default">
        <a:link id="delete_message_link" model="db.hls_sys_homepage_message_pkg.delete_message" modelaction="batch_update"/>
        <a:link id="hls_sys_homepage_message_role_link" url="${/request/@context_path}/modules/hls_fnd/hls_sys_homepage_message_role.lview"/>
        <a:link id="hls_sys_homepage_message_user_link" url="${/request/@context_path}/modules/hls_fnd/hls_sys_homepage_message_user.lview"/>
        <div/>
        <script type="text/javascript"><![CDATA[
        	function assignUserRender(value,record, name){
        		return '<a href="javascript:openAssignUser('+record.get('message_id')+')">分配用户</a>'
        	}
        	
        	function openAssignUser(msg_id){
        		if(typeof(msg_id) != 'undefined' && !Ext.isEmpty(msg_id)){
        			new Leaf.Window({id:'hls_sys_assign_user_window', url:'hls_sys_homepage_message_user.lview'/*$('hls_sys_homepage_message_user_link').getUrl()*/+'?message_id='+ msg_id, title:'分配用户', height:400,width:500});
        		}else{
        			 Leaf.showMessage("提示信息","该数据还未保存!");
        		}
        	}
        	
        	function assignRoleRender(value,record, name){
        		return '<a href="javascript:openAssignRole('+record.get('message_id')+')">分配角色</a>'
        	}
        	
        	function openAssignRole(msg_id){
        		if(typeof(msg_id) != 'undefined' && !Ext.isEmpty(msg_id)){
        			new Leaf.Window({id:'hls_sys_assign_role_window', url:'hls_sys_homepage_message_role.lview'/*$('hls_sys_homepage_message_role_link').getUrl()*/+'?message_id='+ msg_id, title:'分配角色', height:400,width:500});
        		}else{
        			 Leaf.showMessage("提示信息","该数据还未保存!");
        		}
        	}
        	
        	function delMsg(){
        		var ds = $('hls_sys_homepage_message');
        		var record = ds.getCurrentRecord();
                var selects = ds.getSelected();
                var data = ds.getJsonData(true);
                var count = selects.length;
                for(i=0;i<data.length;i++){
                	var message_id = data[i]['message_id'];
                	if(typeof(message_id) == 'undefined'){
                		data[i]=null;
                	}
                }
              
                if(count > 0){
	        		var queryConfirm = Leaf.showConfirm('提示', '确认要删除?', function() {
			                    Leaf.request({
		                            url: '${/request/@context_path}/autocrud/db.hls_sys_homepage_message_pkg.delete_message/batch_update'/*$('delete_message_link').getUrl()*/,
		                            para:data,
		                            success: function(args) {
		                                ds.query();
		                            },
		                            scope: this
		                        });
			                }, function() {
			                    queryConfirm.close();
			         }, null, null);
			     }   
        	}
        	
        	function homepage_message_save(){
        		$('hls_sys_homepage_message').submit();
        	}
        	
        	function subsce(dataSet,ref){
        		dataSet.query();
        	}
        	
        	function equalValidator(record, name, value){
        		var equal_value = record.get('equal_value');
        		var un_equan_value = record.get('un_equan_value');
        		if(equal_value == un_equan_value){
        			return "等于和不等于的值应不相同!";
        		}
        		return true;
        	}
        ]]></script>
        <a:dataSets>
            <a:dataSet id="hls_sys_homepage_message" autoQuery="true" loadData="true" model="hls.HLS1020.hls_sys_homepage_message_for_maintain" pageSize="20" selectable="true">
                <a:fields>
                    <a:field name="company_name" lovGridHeight="340" lovHeight="460" lovService="hls_fnd.hls_fnd_companies" lovWidth="340" required="true" title="FND_COMPANIES.INFO">
                        <a:mapping>
                            <a:map from="company_id" to="company_id"/>
                            <a:map from="company_short_name" to="company_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="equal_value" required="true" validator="equalValidator"/>
                    <a:field name="un_equan_value" required="true" validator="equalValidator"/>
                    <a:field name="enabled_flag" checkedValue="Y" defaultValue="Y" required="true" unCheckedValue="N"/>
                    <a:field name="message_content" required="true"/>
                    <a:field name="condition_sql" required="true"/>
                    <a:field name="message_code" required="true"/>
                    <a:field name="message_desc" required="true"/>
                    <a:field name="sequence_no" required="true"/>
                    <a:field name="message_content_type" defaultValue="02"/>
                    <a:field name="return_condition_type" defaultValue="02"/>
                </a:fields>
                <a:events>
                    <a:event name="submitsuccess" handler="subsce"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:form height="370" title="HLS_SYS_HOMEPAGE_MESSAGE.HOMEPAGE_MESSAGE" width="760">
                <a:grid id="grid_id" bindTarget="hls_sys_homepage_message" height="370" navBar="true" style="margin-left:10px" width="731">
                    <a:toolBar>
                        <a:button type="add"/>
                        <a:button click="delMsg" icon="../../images/remove.png" text="PROMPT.DELETE"/>
                    </a:toolBar>
                    <a:columns>
                        <a:column name="company_name" editor="lovedit" prompt="HLS_SYS_HOMEPAGE_MESSAGE.COMPANY_NAME" width="150"/>
                        <a:column name="message_code" editor="txtedit" prompt="HLS_SYS_HOMEPAGE_MESSAGE.MESSAGE_CODE" sortable="true" width="60"/>
                        <a:column name="message_desc" editor="txtedit" prompt="HLS_SYS_HOMEPAGE_MESSAGE.MESSAGE_DESC" width="200"/>
                        <a:column name="sequence_no" editor="unmberedit" prompt="HLS_SYS_HOMEPAGE_MESSAGE.SEQUENCE_NO" sortable="true" width="45"/>
                        <a:column name="assign_user" align="center" prompt="HLS_SYS_HOMEPAGE_MESSAGE.ASSIGN_USER" renderer="assignUserRender"/>
                        <a:column name="assign_role" align="center" prompt="HLS_SYS_HOMEPAGE_MESSAGE.ASSIGN_ROLE" renderer="assignRoleRender"/>
                        <a:column name="enabled_flag" editor="check_edit" prompt="HLS_SYS_HOMEPAGE_MESSAGE.ENABLED_FLAG" width="50"/>
                    </a:columns>
                    <a:editors>
                        <a:numberField id="unmberedit"/>
                        <a:textField id="txtedit"/>
                        <a:checkBox id="check_edit"/>
                        <a:lov id="lovedit"/>
                    </a:editors>
                </a:grid>
            </a:form>
            <a:tabPanel id="hls_sys_homepage_message_tab" height="190" width="760">
                <a:tabs>
                    <a:tab prompt="HLS_SYS_HOMEPAGE_MESSAGE.MESSAGE_TEXT" width="80">
                        <a:hBox height="30" style="background-color:#eceded" width="758">
                            <a:radio name="message_content_type" bindTarget="hls_sys_homepage_message" prompt="" width="200">
                                <a:items>
                                    <a:item label="HLS_SYS_HOMEPAGE_MESSAGE.MESSAGE_CONTENT_TYPE_DYNAMIC_SQL" value="01"/>
                                    <a:item label="HLS_SYS_HOMEPAGE_MESSAGE.MESSAGE_CONTENT_TYPE_TEXT" value="02"/>
                                </a:items>
                            </a:radio>
                        </a:hBox>
                        <a:textArea name="message_content" bindTarget="hls_sys_homepage_message" height="100" style="margin:10px 23px" width="705"/>
                    </a:tab>
                    <a:tab prompt="HLS_SYS_HOMEPAGE_MESSAGE.SEND_CONDITION" width="80">
                        <a:hBox height="30" style="background-color:#eceded" width="758">
                            <a:radio name="return_condition_type" bindTarget="hls_sys_homepage_message" prompt="" width="200">
                                <a:items>
                                    <a:item label="HLS_SYS_HOMEPAGE_MESSAGE.RETURN_CONDITION_TYPE_FUNCTION" value="01"/>
                                    <a:item label="HLS_SYS_HOMEPAGE_MESSAGE.RETURN_CONDITION_TYPE_SQL" value="02"/>
                                </a:items>
                            </a:radio>
                            <a:hBox padding="0" width="300">
                                <a:textField name="equal_value" bindTarget="hls_sys_homepage_message" prompt="HLS_SYS_HOMEPAGE_MESSAGE.EQUAL_VALUE" width="50"/>
                                <a:textField name="un_equan_value" bindTarget="hls_sys_homepage_message" prompt="HLS_SYS_HOMEPAGE_MESSAGE.UN_EQUAL_VALUE" width="50"/>
                            </a:hBox>
                        </a:hBox>
                        <a:textArea name="condition_sql" bindTarget="hls_sys_homepage_message" height="100" style="margin:10px 23px" width="705"/>
                    </a:tab>
                </a:tabs>
            </a:tabPanel>
            <a:button click="homepage_message_save" text="HAP_SAVE"/>
        </a:screenBody>
    </a:view>
</a:screen>