{$ADMIN_HEADER}
{literal}
<script language="JavaScript">
var DHTML = (document.getElementById || document.all || document.layers);
function showLayer(name,visibility)
{
if (!DHTML) return;
if (name)
{
var x = getObj(name);
x.display = visibility ? '' : 'none';
}
}
function getObj(name)
{
if (document.getElementById)
{
return document.getElementById(name).style;
}
else if (document.all)
{
return document.all[name].style;
}
else if (document.layers)
{
return document.layers[name];
}
else return false;
}
function setSelected(value)
{
document.getElementById('hdnSelectedItem').value = value;
}
</script>
{/literal}
{if $IsEdit neq ''}
<body onload="switch_layers('{$data[0].displaytype|default:"text"}');FillValidationOptions(document.getElementById('ddlValidateFunction'),'{$data[0].displaytype}');">
{else}
<body onload="switch_layers('{$data[0].displaytype|default:"text"}');">
{/if}
<div id="content" class="setdiv">
<div id="full-contentdiv">
<div class="righttop">
<h2 align="center">
{if $IsEdit neq ''}
Edit Field
{assign var="action" value="update"}
{else}
Add New Field
{assign var="action" value="insert"}
{/if}
</h2>
</div>
<div class="whole-page clear">
<form name="frmAddField" id="frmAddField" action="admin_fields_m.php?action={$action}" method="post">
<div class="formformat">
<center>
<table border="0" cellpadding="0" cellspacing="0" style="width:600px">
<input type="hidden" id="hiddID" name="hiddID" value="{$data[0].id}">
<input name="save" value="1" type="hidden">
<input name="event" value="add" type="hidden">
<tr>
<td class="right-side-text"><label>
Field Name <label class="star">*</label>
</label>
</td>
<td class="left-side-text">
<input type="text" class="txtcss" id="txtFieldName" name="txtFieldName" maxlength="25" value="{$data[0].name}">
</td>
</tr>
<tr>
<td class="right-side-text"><label>
Field Title <label class="star">*</label>
</label>
</td>
<td class="left-side-text">
<input type="text" class="txtcss" id="txtFieldTitle" name="txtFieldTitle" maxlength="45" value="{$data[0].label}">
</td>
</tr>
<tr>
<td class="right-side-text"><label>
Field Description <label class="star">*</label><br/>
<div class="FieldLabelNote">Display description on sign up and profile screen for customer.</div>
</label>
</td>
<td class="left-side-text">
<textarea id="txtFieldDescription" class="txtareacss" name="txtFieldDescription" rows="2" cols="35">{$data[0].description}</textarea>
{*<input type="text" id="txtFieldDescription" name="txtFieldDescription" maxlength="100">*}
</td>
</tr>
<!--
<tr>
<td class="right-side-text"><label>
SQL Field Type <label class="star">*</label><br/>
<div class="FieldLabelNote">if you are unsure, choose first type (string)</div>
</label>
</td>
<td class="left-side-text">
<select id="ddlSQLFieldType" name="ddlSQLFieldType" class="selectcss">
<option value="" label="Select">Select</option>
<option value="VARCHAR(255)" label="String ( VARCHAR(255) )" {if $data[0].datatype eq 'VARCHAR(255)'} selected {/if}>String ( VARCHAR(255) )</option>
<option value="BLOB" label="Blob (unlimited length string/data" {if $data[0].datatype eq 'BLOB'} selected {/if}>Blob (unlimited length string/data</option>
<option value="INT" label="Integer field (only numbers)" {if $data[0].datatype eq 'INT'} selected {/if}>Integer field (only numbers)</option>
<option value="DECIMAL(12,2)" label="Numeric field (DECIMAL(12,2))" {if $data[0].datatype eq 'DECIMAL(12,2)'} selected {/if}>Numeric field (DECIMAL(12,2))</option>
</select>
</td>
</tr>
-->
<tr>
<td class="right-side-text"><label>
Display Type <label class="star">*</label>
</label>
</td>
<td class="left-side-text">
<input class="chkcss" type="radio" id="rdDisplayType" name="rdDisplayType" value="text" {if $data[0].displaytype eq 'text'} checked {/if} checked onclick="switch_layers(this.value);FillValidationOptions(document.getElementById('ddlValidateFunction'),this.value);setSelected(this.value);">Text<br/>
<input class="chkcss" type="radio" id="rdDisplayType" name="rdDisplayType" value="select" {if $data[0].displaytype eq 'select'} checked {/if} onclick="switch_layers(this.value);FillValidationOptions(document.getElementById('ddlValidateFunction'),this.value);setSelected(this.value);">Select (single value)<br/>
<input class="chkcss" type="radio" id="rdDisplayType" name="rdDisplayType" value="multi_select" {if $data[0].displaytype eq 'multi_select'} checked {/if} onclick="switch_layers(this.value);FillValidationOptions(document.getElementById('ddlValidateFunction'),this.value);setSelected(this.value);">Select (multiple values)<br/>
<input class="chkcss" type="radio" id="rdDisplayType" name="rdDisplayType" value="textarea" {if $data[0].displaytype eq 'textarea'} checked {/if} onclick="switch_layers(this.value);FillValidationOptions(document.getElementById('ddlValidateFunction'),this.value);setSelected(this.value);">TextArea <br/>
<input class="chkcss" type="radio" id="rdDisplayType" name="rdDisplayType" value="radio" {if $data[0].displaytype eq 'radio'} checked {/if} onclick="switch_layers(this.value);FillValidationOptions(document.getElementById('ddlValidateFunction'),this.value);setSelected(this.value);">RadioButtons <br/>
<input class="chkcss" type="radio" id="rdDisplayType" name="rdDisplayType" value="checkbox" {if $data[0].displaytype eq 'checkbox'} checked {/if} onclick="switch_layers(this.value);FillValidationOptions(document.getElementById('ddlValidateFunction'),this.value);setSelected(this.value);">CheckBoxes <br/>
<input class="chkcss" type="radio" id="rdDisplayType" name="rdDisplayType" value="checkbox(checked)"{if $data[0].displaytype eq 'checkbox(checked)'} checked {/if} onclick="switch_layers(this.value);FillValidationOptions(document.getElementById('ddlValidateFunction'),this.value);setSelected(this.value);">CheckBox(checked) <br/>
<input class="chkcss" type="radio" id="rdDisplayType" name="rdDisplayType" value="checkbox(unchecked)"{if $data[0].displaytype eq 'checkbox(unchecked)'} checked {/if} onclick="switch_layers(this.value);FillValidationOptions(document.getElementById('ddlValidateFunction'),this.value);setSelected(this.value);">CheckBox(unchecked) <br/>
<input class="chkcss" type="radio" id="rdDisplayType" name="rdDisplayType" value="label"{if $data[0].displaytype eq 'label'} checked {/if} onclick="switch_layers(this.value);FillValidationOptions(document.getElementById('ddlValidateFunction'),this.value);setSelected(this.value);">Label <br/>
</td>
</tr>
<tr id="values" style="display: none;">
<td class="right-side-text">
<label>Field Values <label class="star">*</label></label>
<div class="FieldLabelNote">
This list displays pipe-separated<br>
list of field keys (internal values),<br>
values (human-readable) and<br>
default value indicators<br>
(1-default value, 0-not default value)<br>
For example, the following lines will<br>
create country list, where USA<br>
is selected by default:<br>
USA|United States|1<br>
UK|United Kingdom|0<br>
CA|Canada|0<br>
</div>
</td>
<td class="left-side-text">
<textarea name="values" class="txtareacss" cols="40" rows="10">{$value|default:''}</textarea>
</td>
</tr>
<tr id="size" style="display: none;">
<td class="right-side-text">
<label>Size of Input Field <label class="star">*</label></label>
</td>
<td class="left-side-text">
<input name="size" size="6" type="text" class="txtcss" value="{$size|default:20}" >
</td>
</tr>
<tr id="textarea_size" style="">
<td class="right-side-text">
<label>Size of Textarea Field <label class="star">*</label></label>
</td>
<td class="left-side-text">
Columns: <input name="cols" value="{$cols|default:20}" class="txtcss" size="6" type="text"><br>
Rows: <input name="rows" value="{$rows|default:5}" class="txtcss" size="6" type="text">
</td>
</tr>
<tr id="text_default" style="">
<td class="right-side-text">
<label>Default Value for Field </label>
</td>
<td class="left-side-text">
<input name="default" class="txtcss" size="40" type="text" value="{$data[0].defaultvalue|default:' '}">
</td>
</tr>
<tr>
<td class="right-side-text"><label>
Display in Signup Form?
</label>
</td>
<td class="left-side-text">
<select size="1" class="selectcss" id="ddlDisplaySignup" name="ddlDisplaySignup" style="width:195px">
<option value="" selected>Select</option>
<option value="0" {if $data[0].signupformvisibility eq '0'} selected {/if}>Don't display</option>
<option value="1" {if $data[0].signupformvisibility eq 1} selected {/if}>Display and allow editing</option>
</select>
<!-- <select style="display:none" size="1" class="selectcss" id="ddlDisplayProfile" name="ddlDisplayProfile">
<option value="0" selected>Don't display</option>
<option value="" selected>Select</option>
<option value="0" {if $data[0].profileformvisibility eq '0'} selected {/if}>Don't display</option>
<option value="1" {if $data[0].profileformvisibility eq 1} selected {/if}>Display and allow editing</option>
<option value="2" {if $data[0].profileformvisibility eq 2} selected {/if}>Display only, editing is not allowed</option>
</select> -->
</td>
</tr>
<tr>
<td class="right-side-text"><label>
Display in Edit Profile Form?
</label>
</td>
<td class="left-side-text">
<select style="" size="1" class="selectcss" id="ddlDisplayProfile" name="ddlDisplayProfile">
<option value="" selected>Select</option>
<option value="0" {if $data[0].profileformvisibility eq '0'} selected {/if}>Don't display</option>
<option value="1" {if $data[0].profileformvisibility eq 1} selected {/if}>Display and allow editing</option>
<option value="2" {if $data[0].profileformvisibility eq 2} selected {/if}>Display only, editing is not allowed</option>
</select>
</td>
</tr>
<tr>
<td class="right-side-text"><label>
Sort Order <label class="star">*</label>
<div class="FieldLabelNote">Additional fields displayed in sort order given here. I.E the sort order 1 display 1st and sort order 2 display next.</div>
</label>
</td>
<td class="left-side-text">
<input type="text" class="txtcss" id="txtSortOrder" name="txtSortOrder" maxlength="3" size="6" value="{$data[0].sortorder}">
</td>
</tr>
<tr>
<td class="right-side-text"><label>
Validation Function <label class="star">*</label><br/>
<div class="FieldLabelNote">Select if validation is required for entered value</div>
</label>
</td>
<td class="left-side-text">
<select size="1" class="selectcss" id="ddlValidateFunction" name="ddlValidateFunction">
<option value="" selected>Select</option>
<option value="none" label="No validation" {if $data[0].validationfurnction eq 'none'} selected {/if}>No validation</option>
<option value="require" label="Required value" {if $data[0].validationfurnction eq 'require'} selected {/if}>Required value</option>
<option value="integer" label="Integer value" {if $data[0].validationfurnction eq 'integer'} selected {/if}>Integer value</option>
<option value="email" label="Email value" {if $data[0].validationfurnction eq 'email'} selected {/if}>Email value</option>
<option value="require_integer" label="Required value+Integer Value" {if $data[0].validationfurnction eq 'require_integer'} selected {/if}>Required value + Integer Value</option>
<option value="require_email" label="Required value+Email Value" {if $data[0].validationfurnction eq 'require_email'} selected {/if}>Required value + Email Value</option>
</select>
</td>
</tr>
<tr>
<td/>
<td class="buttontd">
<input type="submit" class="btncss" name="submit" {if $IsEdit eq 'yes'}value="Save"{else}value="Submit"{/if}>
<input type="button" class="btncss" name="btnBack" value="Cancel" onclick="window.history.go(-1);">
</td>
</tr>
<input type="hidden" id="hdnSelectedItem" name="hdnSelectedItem" {if $IsEdit neq ''}value="{$data[0].displaytype}"{else}value="text"{/if}>
</table>
</center>
</div>
{literal}
<script language="JavaScript" type="text/javascript">
//You should create the validator only after the definition of the HTML form
var frmvalidator = new Validator("frmAddField");
frmvalidator.EnableMsgsTogether();
//frmvalidator.EnableOnPageErrorDisplaySingleBox();
frmvalidator.addValidation("txtFieldName","req","Please enter Field Name.");
frmvalidator.addValidation("txtFieldName","maxlen=25", "Maximum length for Field Name is 25 character.");
frmvalidator.addValidation("txtFieldName","alpha","Enter only characters in Field Name.");
frmvalidator.addValidation("txtFieldTitle","req","Please enter Field Title.");
frmvalidator.addValidation("txtFieldTitle","maxlen=45","Maximum length for Field Title is 45 character.");
frmvalidator.addValidation("txtFieldTitle","alpha_s","Enter only characters in Field Title.");
frmvalidator.addValidation("txtFieldDescription","req","Please enter Field Description.");
frmvalidator.addValidation("txtFieldDescription","maxlen=100","Maximum length for Field Description is 100 character.");
//frmvalidator.addValidation("ddlSQLFieldType","dontselect=''","Please select SQL field type.");
// frmvalidator.addValidation("txtFieldProperty","req","Please enter Field Size.");
// frmvalidator.addValidation("txtFieldProperty","maxlen=20", "Maximum length for Field Size is 20 digits.");
// frmvalidator.addValidation("txtFieldProperty","num","Enter only digits in Field Size.");
/*-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_*/
frmvalidator.addValidation("values","req","Please enter Field Values.","document.getElementById('hdnSelectedItem').value == 'select' || document.getElementById('hdnSelectedItem').value == 'multi_select' || document.getElementById('hdnSelectedItem').value == 'radio' || document.getElementById('hdnSelectedItem').value == 'checkbox'");
frmvalidator.addValidation("values","maxlen=500","Maximum length for Field Values is 500 character.","document.getElementById('hdnSelectedItem').value == 'select' || document.getElementById('hdnSelectedItem').value == 'multi_select' || document.getElementById('hdnSelectedItem').value == 'radio' || document.getElementById('hdnSelectedItem').value == 'checkbox'");
frmvalidator.addValidation("cols","req","Please enter Textarea Columns.","document.getElementById('hdnSelectedItem').value == 'textarea'");
frmvalidator.addValidation("cols","num","Invalid Textarea Columns enter.","document.getElementById('hdnSelectedItem').value == 'textarea'");
frmvalidator.addValidation("rows","req","Please enter Textarea Rows.","document.getElementById('hdnSelectedItem').value == 'textarea'");
frmvalidator.addValidation("rows","num","Invalid Textarea Rows enter.","document.getElementById('hdnSelectedItem').value == 'textarea'");
frmvalidator.addValidation("size","req","Please enter Field Size.","document.getElementById('hdnSelectedItem').value == 'text' || document.getElementById('hdnSelectedItem').value == 'select' || document.getElementById('hdnSelectedItem').value == 'multi_select'");
frmvalidator.addValidation("size","num","Invalid Field Size enter.","document.getElementById('hdnSelectedItem').value == 'text' || document.getElementById('hdnSelectedItem').value == 'select' || document.getElementById('hdnSelectedItem').value == 'multi_select'");
//frmvalidator.addValidation("default","req","Please enter Field Default Values.","document.getElementById('hdnSelectedItem').value == 'text' || document.getElementById('hdnSelectedItem').value == 'textarea' || document.getElementById('hdnSelectedItem').value == 'checkbox(checked)' || document.getElementById('hdnSelectedItem').value == 'checkbox(unchecked)' || document.getElementById('hdnSelectedItem').value == 'label'");
/*-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_*/
// frmvalidator.addValidation("txtDefaultValue","req","Please enter Field Default value.");
frmvalidator.addValidation("ddlDisplaySignup","dontselect=''","Please select \"Display in Signup Form\".");
frmvalidator.addValidation("ddlDisplayProfile","dontselect=''","Please select \"Display in edit profile form\".");
frmvalidator.addValidation("txtSortOrder","req","Please enter Sort Order size.");
frmvalidator.addValidation("txtSortOrder","maxlen=3", "Max length for Sort Order is 3 digits only.");
frmvalidator.addValidation("txtSortOrder","num","Enter only digits in Sort Order.");
/*
if(document.getElementById('text_default').style.dislpay != 'none')
{
alert('here txt_def');
frmvalidator.addValidation("size","req","Please enter Field size.");
frmvalidator.addValidation("size","num","Please enter digits in Field size.");
frmvalidator.addValidation("default","req","Please enter Field Default value.");
// frmvalidator.addValidation("default",);
}
if(document.getElementById('values').style.dislpay != 'none')
{
alert('here values');
frmvalidator.addValidation("values","req","Please enter Field values.");
//frmvalidator.addValidation("values","num","Please enter digits in Field size.");
frmvalidator.addValidation("size","req","Please enter Field size.");
frmvalidator.addValidation("size","num","Please enter digits in Field size.");
}
*/
frmvalidator.addValidation("ddlValidateFunction","dontselect=''","Please select Validate Function.");
</script>
<script language="JavaScript">
function switch_layers(type){
switch (type){
case 'text':
showLayer('values', 0);
showLayer('size', 1);
showLayer('textarea_size', 0);
showLayer('text_default', 1);
//back_sql_types();
break;
case 'textarea':
showLayer('values', 0);
showLayer('size', 0);
showLayer('textarea_size', 1);
showLayer('text_default', 1);
break;
case 'multi_select':
case 'select':
showLayer('values', 1);
showLayer('size', 1);
showLayer('textarea_size', 0);
showLayer('text_default', 0);
break;
case 'checkbox':
case 'radio':
showLayer('values', 1);
showLayer('size', 0);
showLayer('textarea_size', 0);
showLayer('text_default', 0);
break;
case 'checkbox(unchecked)':
case 'checkbox(checked)':
showLayer('size', 0);
showLayer('values', 0);
showLayer('text_default', 1);
showLayer('textarea_size', 0);
break;
case 'label':
showLayer('size', 0);
showLayer('values', 0);
// showLayer('text_default', 0);
showLayer('textarea_size', 0);
break;
}
}
frm = document.frmAddField[0];
elem = document.getElementById("rdDisplayType");
for (i=0;i<elem.length;i++)
if (elem[i].checked) {
showLayer('sql_type_l', elem[i].value);
}
function FillValidationOptions(source, displayType)
{
var validationfunction ='{/literal}{$data[0].validationfurnction}{literal}';
source.length=0;
//1
var option = document.createElement('OPTION');
option.text = 'select';
option.value = '';
source.options.add(option);
if(displayType=='label')
{
// 2
option = document.createElement('OPTION');
option.text = 'No validation';
option.value = 'none';
option.label = 'No validation';
if(validationfunction=='none')
{
option.selected = true;
}
source.options.add(option);
}
else if(displayType=='checkbox' || displayType=='checkbox(checked)' || displayType=='checkbox(unchecked)' || displayType=='radio' || displayType=='select' || displayType=='multi_select')
{
//2
option = document.createElement('OPTION');
option.text = 'No validation';
option.value = 'none';
option.label = 'No validation';
if(validationfunction=='none')
{
option.selected = true;
}
source.options.add(option);
//3
option = document.createElement('OPTION');
option.text = 'Required value';
option.value = 'require';
option.label = 'Required value';
if(validationfunction=='require')
{
option.selected = true;
}
source.options.add(option);
}
else
{
//2
option = document.createElement('OPTION');
option.text = 'No validation';
option.value = 'none';
option.label = 'No validation';
if(validationfunction=='none')
{
option.selected = true;
}
source.options.add(option);
//3
option = document.createElement('OPTION');
option.text = 'Required value';
option.value = 'require';
option.label = 'Required value';
if(validationfunction=='require')
{
option.selected = true;
}
source.options.add(option);
//4
option = document.createElement('OPTION');
option.text = 'Integer value';
option.value = 'integer';
option.label = 'Integer value';
if(validationfunction=='integer')
{
option.selected = true;
}
source.options.add(option);
//5
option = document.createElement('OPTION');
option.text = 'Email value';
option.value = 'email';
option.label = 'Email value';
if(validationfunction=='email')
{
option.selected = true;
}
source.options.add(option);
//6
option = document.createElement('OPTION');
option.text = 'Required value + Integer Value';
option.value = 'require_integer';
option.label = 'Required value + Integer Value';
if(validationfunction=='require_integer')
{
option.selected = true;
}
source.options.add(option);
//7
option = document.createElement('OPTION');
option.text = 'Required value + Email Value';
option.value = 'require_email';
option.label = 'Required value + Email Value';
if(validationfunction=='require_email')
{
option.selected = true;
}
source.options.add(option);
}
}
//FillValidationOptions(document.getElementById('ddlValidateFunction'));
function RemoveValidationOptions(source, options)
{
var arrOptions = options.split(',');
for(i=0;i<arrOptions.length;i++)
{
source.remove(i);
}
}
</script>
{/literal}
</form>
</div>
</div>
</div></body>
{$ADMIN_FOOTER}