<?xml version="1.0"?>
<dynaForm type="xmlform" sqlConnection="" deleteRow="0" menu="departments/departments_Options" filterForm="groups/groups_Search" width="95%" enableTemplate="1">
  <title type="title" colWidth="200" showInTable="0">
    <en><![CDATA[Department Information]]></en>
  </title>
  <DEP_UID type="hidden" size="40" showInTable="0">
</DEP_UID>
  <DEPO_TITLE type="text" colWidth="200" size="30" maxlength="64" required="1">
    <en><![CDATA[Name]]></en>
  </DEPO_TITLE>
  <DEP_STATUS type="dropdown" colWidth="150" align="center">
    <en><![CDATA[Status]]><option name="ACTIVE"><![CDATA[Active]]></option><option name="INACTIVE"><![CDATA[Inactive]]></option></en>
  </DEP_STATUS>
  <DEP_MANAGER type="dropdown" mode="edit" colWidth="150" align="center">
SELECT USR_UID, USR_USERNAME from USERS where DEP_UID =  "@#DEP_UID"
  <en><![CDATA[Manager/Supervisor]]></en>
</DEP_MANAGER>
  <button type="button" onclick="validateLocalFields(this.form);" showInTable="0">
    <en><![CDATA[Save]]></en>
  </button>
  <JS type="javascript" replacetags="1">
  var sGroupname;
  sGroupname = document.forms[0].elements['form[DEPO_TITLE]'].value;
     
var verifyDptoname = function()
{
  document.forms[0].elements['form[DEPO_TITLE]'].disabled = true;
  document.forms[0].elements['form[button]'].disabled = true;    
  var oRPC = new leimnud.module.rpc.xmlhttp({
    url    :'departments_Ajax',
    async  : false,
    method :'POST',
    args   :'action=verifyDptoname&amp;sOriginalGroupname=' + sGroupname + '&amp;sGroupname=' + encodeURIComponent(this.value)});
  oRPC.make();
  var sResponse = oRPC.xmlhttp.responseText; 
  document.forms[0].elements['form[DEPO_TITLE]'].disabled = false;
  if (sResponse == '1')
  {
    new leimnud.module.app.alert().make({
	    label: G_STRINGS.ID_MSJ_DEPTO
  	});
    document.forms[0].elements['form[DEPO_TITLE]'].focus();
  }
  else
  {
    document.forms[0].elements['form[button]'].disabled = false;
  }
};
  
var validateLocalFields = function(oForm)
{ oAux1 = oForm.elements['form[DEPO_TITLE]'];
	if (oAux1.value == '')
	{
		new leimnud.module.app.alert().make({
	    label:G_STRINGS.DBCONNECTIONS_ALERT
  	});
		oAux1.focus();
		bContinue = false;
		return false;
	}
     else{
		savedeptomain(oForm);
     }

}

leimnud.event.add(document.forms[0].elements['form[DEPO_TITLE]'],'change',verifyDptoname);  
</JS>
</dynaForm>
