You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

334 lines
11 KiB

<!--*********************************************************************************
** The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
*
********************************************************************************/
-->
<!-- BEGIN: main -->
<script language="JavaScript" type="text/javaScript" src="include/general.js"></script>
<script language="JavaScript" type="text/javaScript">
function splitValues() {
var picklistObj=getObj("fldPickList")
var pickListContent=picklistObj.value
var pickListAry=new Array()
var i=0;
//Splitting up of Values
if (pickListContent.indexOf("\n")!=-1) {
while(pickListContent.length>0) {
if(pickListContent.indexOf("\n")!=-1) {
if (pickListContent.replace(/^\s+/g, '').replace(/\s+$/g, '').length>0) {
pickListAry[i]=pickListContent.substr(0,pickListContent.indexOf("\n")).replace(/^\s+/g, '').replace(/\s+$/g, '')
pickListContent=pickListContent.substr(pickListContent.indexOf("\n")+1,pickListContent.length)
i++
} else break;
} else {
pickListAry[i]=pickListContent.substr(0,pickListContent.length)
break;
}
}
/* while(pickListContent.indexOf("\n")!=-1) {
if (pickListContent.replace(/^\s+/g, '').replace(/\s+$/g, '').length>0) {
pickListAry[i]=pickListContent.substr(0,pickListContent.indexOf("\n")).replace(/^\s+/g, '').replace(/\s+$/g, '')
pickListContent=pickListContent.substr(pickListContent.indexOf("\n")+1,pickListContent.length)
i++
} else break;
}
*/
} else if (pickListContent.replace(/^\s+/g, '').replace(/\s+$/g, '').length>0) {
pickListAry[0]=pickListContent.replace(/^\s+/g, '').replace(/\s+$/g, '')
}
return pickListAry;
}
function validate() {
var str = getObj("fldLabel").value;
if (!emptyCheck("fldLabel","Label"))
return false
var re1=/^[a-z\d\_ ]+$/i
if (!re1.test(str))
{
alert("Special characters are not allowed in Label field")
return false;
}
if (lengthLayer.style.display=="block") {
if (!emptyCheck("fldLength","Length"))
return false
if (!intValidate("fldLength","Length"))
return false
if (!numConstComp("fldLength","Length","GT",0))
return false
if (!numConstComp("fldLength","Length","LE",255))
return false
}
if (decimalLayer.style.display=="block") {
if (getObj("fldDecimal").value.replace(/^\s+/g, '').replace(/\s+$/g, '').length>0)
if (!intValidate("fldDecimal","Decimal"))
return false
if (!numConstComp("fldDecimal","Decimal","GE",0))
return false
if (!numConstComp("fldDecimal","Decimal","LE",30))
return false
}
var picklistObj=getObj("fldPickList")
if (pickListLayer.style.display=="block") {
if (emptyCheck("fldPickList","Picklist values")) {
var pickListAry=new Array()
pickListAry=splitValues()
//Empty Check validation
for (i=0;i<pickListAry.length;i++) {
if (pickListAry[i]=="") {
alert("Picklist value cannot be empty")
picklistObj.focus()
return false
}
}
//Duplicate Values' Validation
for (i=0;i<pickListAry.length;i++) {
for (j=i+1;j<pickListAry.length;j++) {
if (pickListAry[i]==pickListAry[j]) {
alert("Duplicate Values found")
picklistObj.focus()
return false
}
}
}
return true
} else return false
}
}
</script>
<script language="JavaScript" type="text/javaScript">
var fieldValueArr=new Array('Text','Number','Percent','Currency','Date','Email','Phone','Picklist','URL','Checkbox')
var fieldTypeArr=new Array('text','number','percent','currency','date','email','phone','picklist','url','checkbox')
var currFieldIdx=0,totFieldType;
function init() {
lengthLayer=getObj("lengthdetails")
decimalLayer=getObj("decimaldetails")
pickListLayer=getObj("picklist")
totFieldType=fieldTypeArr.length-1
if (window.navigator.appName.toUpperCase()=="OPERA")
getObj("fieldLayer").scrolling="auto"
}
var focusFieldType;
function setVisible() {
if (focusFieldType==true) {
var selFieldType=fieldLayer.getObj("field"+currFieldIdx)
var height=findPosY(selFieldType)+selFieldType.offsetHeight
if (currFieldIdx==0) {
fieldLayer.document.body.scrollTop=0
} else if (height>220) {
fieldLayer.document.body.scrollTop+=height-220
} else {
fieldLayer.document.body.scrollTop-=220-height
}
if (window.navigator.appName.toUpperCase()=="OPERA") {
var newDiv=fieldLayer.document.createElement("DIV")
newDiv.style.zIndex="-1"
newDiv.style.position="absolute"
newDiv.style.top=findPosY(selFieldType)+"px"
newDiv.style.left="25px"
var newObj=fieldLayer.document.createElement("INPUT")
newObj.type="text"
fieldLayer.document.body.appendChild(newDiv)
newDiv.appendChild(newObj)
newObj.focus()
fieldLayer.document.body.removeChild(newDiv)
}
}
}
function selFieldType(id,scrollLayer,bool) {
currFieldIdx=id
var type=fieldTypeArr[id]
for (i=0;i<=totFieldType;i++) {
if (i==id) {
if (bool==true) fieldLayer.getObj("field"+i).className="fieldType sel"
else fieldLayer.getObj("field"+i).className="fieldType sel hilite"
if (scrollLayer=="yes") focusFieldType=true
else focusFieldType=false
} else fieldLayer.getObj("field"+i).className="fieldType"
}
if (type=='text') {
lengthLayer.style.display="block"
decimalLayer.style.display="none"
pickListLayer.style.display="none"
} else if (type=='date' || type=='email' || type=='phone' || type=='url' || type=='checkbox') {
lengthLayer.style.display="none"
decimalLayer.style.display="none"
pickListLayer.style.display="none"
} else if (type=='number' || type=='percent' || type=='currency') {
lengthLayer.style.display="block"
decimalLayer.style.display="block"
pickListLayer.style.display="none"
} else if (type=='picklist') {
lengthLayer.style.display="none"
decimalLayer.style.display="none"
pickListLayer.style.display="block"
}
getObj("fieldType").value = fieldValueArr[id];
}
function srchFieldType(ev) {
if (browser_ie) {
var keyCode=window.fieldLayer.event.keyCode
var currElement=window.fieldLayer.event.srcElement
if (currElement.id.indexOf("field")>=0) var doSearch=true
else var doSearch=false
window.fieldLayer.event.cancelBubble=true
} else if (browser_nn4 || browser_nn6) {
var keyCode=ev.which
var currElement=ev.target
if (currElement.type) doSearch=false
else doSearch=true
}
if (doSearch==true) {
switch (keyCode) {
case 9 : //Reset Field Type
resetFieldTypeHilite();break;
case 33 : //Page Up
case 36 : //Home
selFieldType(0);break;
case 34 : //Page Down
case 35 : //End
selFieldType(totFieldType);break;
case 38 : //Up
if (currFieldIdx!=0)
selFieldType(currFieldIdx-1);
else
selFieldType(totFieldType,"yes");
break;
case 40 : //Down
if (currFieldIdx!=totFieldType)
selFieldType(currFieldIdx+1);
else
selFieldType(0,"yes");
default : //Character Search
if (keyCode>=65 && keyCode<=90) {
var srchChar=String.fromCharCode(keyCode)
if (currFieldIdx==totFieldType) var startIdx=0
else var startIdx=currFieldIdx+1
var loop=1
for (i=startIdx;i<=totFieldType;) {
currFieldStr=fieldLayer.getObj("field"+i).innerHTML
currFieldStr=currFieldStr.replace(/^\s+/g, '').replace(/\s+$/g, '').substr(0,1)
if (currFieldStr==srchChar) {
selFieldType(i,"yes")
i++
} else if (i==totFieldType && loop<=2) {
i=0
loop++
} else i++
}
}
}
}
}
function resetFieldTypeHilite() {
fieldLayer.getObj("field"+currFieldIdx).className="fieldType sel"
}
</script>
<body onClick="resetFieldTypeHilite()">
<form action="index.php" method="post" name="addtodb" onSubmit="return validate()">
<input type="hidden" name="module" value="Settings">
<input type="hidden" name="action" value="AddCustomFieldToDB">
<div class="error"> <BR> {DUPLICATE_ERROR} </div>
<div align="right" style="width:90%"><font class="required">{APP.LBL_REQUIRED_SYMBOL}</font>{APP.NTC_REQUIRED}</div>
<table width="90%" border="0" cellspacing="0" cellpadding="0" class="formOuterBorder">
<tr>
<th class="formSecHeader"><div align="left">{MOD.LBL_PROVIDE_FIELD_INFORMATION}</div></th>
</tr>
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="margin:10">
<tr>
<td width="160">{MOD.LBL_SELECT_FIELD_TYPE}</td>
<td>{MOD.LBL_PROVIDE_FIELD_DETAILS}</td>
</tr>
<tr>
<td height="180" valign="top"><iframe name="fieldLayer" src="index.php?module=Settings&action=fieldtypes" scrolling="yes" height="170" width="150"></iframe></td>
<td valign="top"><table border="0" cellspacing="1" cellpadding="0">
<tr>
<td class="dataLabel" nowrap width="100"><font class="required">{APP.LBL_REQUIRED_SYMBOL}</font>{MOD.LBL_LABEL}</td>
<td width="150"><input type="text" name="fldLabel" value="{LABELVALUE}" style="width:100%"></td>
</tr>
</table>
<div id="lengthdetails">
<table border="0" cellspacing="1" cellpadding="0">
<tr>
<td class="dataLabel" nowrap width="100"><font class="required">{APP.LBL_REQUIRED_SYMBOL}</font>{MOD.LBL_LENGTH}</td>
<td width="150"><input type="text" name="fldLength" value="{LENGTHVALUE}" style="width:100%"></td>
</tr>
</table>
</div>
<div id="decimaldetails">
<table border="0" cellspacing="1" cellpadding="0">
<tr>
<td class="dataLabel" nowrap width="100">{MOD.LBL_DECIMAL_PLACES}</td>
<td width="150"><input type="text" name="fldDecimal" value="{DECIMALVALUE}" style="width:100%"></td>
</tr>
</table>
</div>
<div id="picklist">
<table border="0" cellspacing="1" cellpadding="0">
<tr>
<td class="dataLabel" nowrap width="100" valign="top"><font class="required">{APP.LBL_REQUIRED_SYMBOL}</font>{MOD.LBL_PICK_LIST_VALUES}</td>
<td width="150" valign="top"><textarea name="fldPickList" rows="10" style="width:100%">{PICKLISTVALUE}</textarea></td>
<td style="padding-left:10px"><img src="themes/Aqua/images/picklist_hint.gif"/></td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
<br>
<table width="90%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td> <div align="center">
<input type="submit" name="Submit" value="{APP.LBL_SAVE_BUTTON_LABEL}" class="button" >
<input type="button" name="Submit2" value="{APP.LBL_CANCEL_BUTTON_LABEL}" class="button" onclick="testing()">
</div></td>
</tr>
</table>
<input type='hidden' name="fieldType" id="fieldType" value="{FLDTYPEVALUE}">
<input type='hidden' name="fld_module" id="fld_module" value="{FLD_MODULE}">
</form>
</body><br>
<script type="text/javascript">
function testing()
{
document.location.href="index.php?module=Settings&action=CustomFieldList&fld_module="+document.addtodb.fld_module.value
}
</script>
<!-- END: main -->