Location: PHPKode > projects > SimpleHRM > simplehrm-1.0-beta1/simplehrm-1.0-beta1/templates/default/admin/setting/add_msg_main.tpl.html
{assign var=lang_code value=$util->get_values_from_config('LANGUAGE')}
{literal}
<script type="text/javascript" language="javascript">
	$(document).ready(function() {
		var sel="{/literal}{$sm.row.lang_code}{literal}";
		if(!sel)
			sel="{/literal}{$lang_code.English}{literal}";
		$('#tab'+sel).addClass('active');
		var hide_div = "{/literal}{$sm.row.id_message}{literal}";
		if(hide_div) {
			$('#key_name').removeAttr('onblur');
			$('#key_value').focus();
		}
	});
	

	function chk_dup_key(){
		var msg_key = $('#key_name').val();
		if(msg_key) {
			var url = "##LBL_ADMIN_SITE_URL##index.php";
			$.post(url,{"page":"setting","choice":"check_duplicate_key",ce : 0,"msg_key":msg_key},function(res){
				//alert(res);return false;
				var err=res.split('::');
				if(err[0]=='err'){
					$('#key_name').val('');
					$('#key_name').focus('');
					var msg = {/literal}"{$smarty.const.MESSAGE_DUP_KEY_EN}"{literal};
					showmsg('',msg);					
				}else {
					$('#key_name').attr('readonly','readonly');
					$('#ref_kn').show();
					$('#key_name_hid').val(msg_key);
				}
			});
		}	
	}
	
	function ref_kn(){
		$('#key_name').val('');
		$('#key_name').focus();
		$('#key_name').attr('readonly','');
		$('#key_name_hid').val('');
		$("#tab"+$('#olddiv').val()).removeClass('active');
		$('#olddiv').val('en');
		$('#lang_code').val('en');
		$('#key_value').val('');
		$('#ref_kn').hide();
	}

	function getcontent(lang_code,lang) {
		//alert(lang_code);
		$('#tab'+lang_code).addClass('active');
		$("#tab"+$('#olddiv').val()).removeClass('active');
		var key_name = $('#key_name').val();
		var url = "##LBL_ADMIN_SITE_URL##index.php";
		$.post(url,{"page":"setting","choice":"add_msg",ce:0,lang_code:lang_code,key_name:key_name,chk:1},function(res){
			$('#olddiv').val(lang_code);
			$('#msg_add_tpl').html(res).show(1000);
			$('#key_name_hid').val(key_name);
		});
		
	}
</script>
{/literal}
<div id="error_dup" align="center" style="display:none" class="error"></div>
<!--<div id="out_div" class="box box-75 altbox">-->
<div id="out_div" class="box altbox" style="width:600px">
	<div class="boxin">
		<div class="header"><h3>{if !$sm.row}Add{else}Edit{/if} Message</h3></div>
		{if !$sm.row}
			<div style="margin-left:17px"><font color="Red"><br/>Use module name as prefix of Message Key e.g, if module is user then prefix is user_</font></div>
		{/if}
		<form class="basic">
			<div class="inner-form">				
				<dl>
					<dt><label for="key_name">Message Key :</label></dt>
					<dd>
						<input class="txt" type="text" id="key_name" name="msg[key_name]" onblur="chk_dup_key();" {if $sm.row} value="{$sm.row.key_name}" readonly="readonly"{/if} />
						<span id="ref_kn" style="display:none;"><a href="javascript:void(0);" onclick="ref_kn();">Refresh</a></span>
					</dd>
				</dl>
			</div>
		</form>
	</div>
</div><br/>
<!--<div class="box box-75 altbox">-->
<div class="box altbox" style="width:600px">
	<div class="boxin">
		<div class="header" id="language_type"><h3>&nbsp;</h3>
			<ul class="tabs">
				{foreach key=key item=item from=$sm.language}
				    {if !$sm.lang_code.$key}
					<li><a href="javascript:void(0)" id="tab{$item}" onclick="getcontent('{$item}','');">{$key}</a></li>
				    {else}
					<li><a href="javascript:void(0)" id="tab{$item}" onclick="getcontent('{$item}','{$sm.lang_code.$key}');">{$key}</a></li>
				    {/if}
				{/foreach}
			</ul>  
		</div>
		<input type="hidden" name="olddiv" value="{$sm.language.English}" id="olddiv" />
		<div id="msg_add_tpl">{include file="admin/setting/add_msg_new"}</div>
	</div>
</div>
{literal}
<script type="text/javascript">
	function insert_msg(obj) {
		var msg_key = $('#key_name').val();
		if(msg_key) {
			var x = validate_msg();
			if(x) {
				var formelement=$('#add_msg_form').serialize();
				var url = "##LBL_ADMIN_SITE_URL##index.php/page-setting-choice-";
				var ch = $('#choice').val();
				url = url + ch+"?"+formelement;
				$.post(url,{ce : 0},function(res){
					//alert(res);return false;
					if(res !='0'){
						if(ch=='insert_msg') {
							showmsg('','Message value inserted successfuly');
							$('#id_message').val(res);
							$('#choice').val('update_msg');
							$(obj).attr("value","Update");
							$('#ref_kn').hide();
						}else {
							showmsg('','Message value updated successfuly');
						}
					}
				});
			}
		}else {
			showmsg('','Please insert a message key');
			$('#key_name').focus();
			return false;
		}
	}
	
	function validate_msg(){
		var key_value = $('#key_value').val();
		if(key_value!='') {
			return true;
		}else {
			showmsg('','Please insert a message value');
			$('#key_value').focus();
			return false;
		}		
	}
</script>
{/literal}
Return current item: SimpleHRM