# Designing New Data Type

**URL:** <https://community.open-emr.org/t/designing-new-data-type/5002>\
**Category:** OpenEMR Development\
**Created:** [April 21, 2011, 11:16am UTC](https://community.open-emr.org/t/designing-new-data-type/5002 "2011-04-21T11:16:35Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [April 21, 2011, 11:16am UTC](https://community.open-emr.org/t/designing-new-data-type/5002/1 "2011-04-21T11:16:35Z")

</div>

**[juggernautsei](https://sourceforge.net/u/juggernautsei/)** wrote on [Thursday, April 21, 2011](https://sourceforge.net/p/openemr/discussion/202506/thread/1ac74486/#e434):

Below is a snippit of code that I took from the Prescriptions section. I believe this to be the construct for the Drug lookup widget in the prescriptions add fuction. Now, I know just enough to be a little above ignorant with php coding. But I am asking for some brain storming ideas on how to take this or something like this code to build a data\_type in the layout based forms section. The over all goal is that I am building an office note for a doctor. The final output of the note will be in paragraph form. But there is a section called Impression Plan. In this section, drugs will have to be prescribed to go in the office note to be sent with the patient. He wants it all in one place instead of having to jump around the program. That is why I am trying to build this into this section. He thinks it is to much to go out of one form into Rx section add drugs then come back. This does not fit his work flow efforts. Of course later the drugs that are put in under the Impression Plan will need to populate into the patients record under prescriptions. Any ideas would be greatly appreciated

\<!- for the fancy jQuery stuff -\>  
\<script type=“text/javascript”\>  
$().ready(function() {  
&nbsp;&nbsp;&nbsp; $("#drug").autocomplete(‘library/ajax/prescription\_drugname\_lookup.php’,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; width: 200,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; scrollHeight: 100,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; selectFirst: true  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; });  
&nbsp;&nbsp;&nbsp; $("#drug").focus();  
&nbsp;&nbsp;&nbsp; $("#prescribe").submit(function() { return CheckForErrors(this) });  
&nbsp;&nbsp;&nbsp; $("#druglookup").click(function() { DoDrugLookup(this) });  
});

// pop up a drug lookup window with the value of the drug name, if we have one  
function DoDrugLookup(eObj) {  
&nbsp;&nbsp;&nbsp; drugname = “”;  
&nbsp;&nbsp;&nbsp; if ($(’#drug’).val() != “”) { drugname = $(’#drug’).val(); }  
&nbsp;&nbsp;&nbsp; drugPopup = window.open(‘controller.php?prescription&lookup&drug=’+drugname, ‘drugPopup’, ‘width=400,height=50,menubar=no,titlebar=no,left = 825,top = 400’);  
&nbsp;&nbsp;&nbsp; drugPopup.opener = self;  
&nbsp;&nbsp;&nbsp; return true;  
}

// check the form for required fields before submitting  
var CheckForErrors = function(eObj) {  
&nbsp;&nbsp;&nbsp; // REQUIRED FIELDS  
&nbsp;&nbsp;&nbsp; if (CheckRequired(‘drug’) == false) { return false; }  
&nbsp;&nbsp;&nbsp; //if (CheckRequired(‘quantity’) == false) { return false; }  
&nbsp;&nbsp;&nbsp; //if (CheckRequired(‘unit’) == false) { return false; }  
&nbsp;&nbsp;&nbsp; //if (CheckRequired(‘size’) == false) { return false; }  
&nbsp;&nbsp;&nbsp; //if (CheckRequired(‘dosage’) == false) { return false; }  
&nbsp;&nbsp;&nbsp; //if (CheckRequired(‘form’) == false) { return false; }  
&nbsp;&nbsp;&nbsp; //if (CheckRequired(‘route’) == false) { return false; }  
&nbsp;&nbsp;&nbsp; //if (CheckRequired(‘interval’) == false) { return false; }

&nbsp;&nbsp;&nbsp; return top.restoreSession();  
};

function CheckRequired(objID) {

&nbsp;&nbsp;&nbsp; // for text boxes  
&nbsp;&nbsp;&nbsp; if ($(’#’+objID).is(‘text’)) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($(’#’+objID).val() == “”) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert(“Missing a required field”);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(’#’+objID).css(“backgroundColor”, “pink”);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp; }

&nbsp;&nbsp;&nbsp; // for select boxes  
&nbsp;&nbsp;&nbsp; if ($(’#’+objID).is(‘select’)) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($(’#’+objID).val() == “0”) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert(“Missing a required field”);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(’#’+objID).css(“backgroundColor”, “pink”);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp; }

&nbsp;&nbsp;&nbsp; return true;  
}

\</script\>

Sherwin  
[www.openmedpractice.com](http://www.openmedpractice.com)

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [April 21, 2011, 12:58pm UTC](https://community.open-emr.org/t/designing-new-data-type/5002/2 "2011-04-21T12:58:02Z")

</div>

**[juggernautsei](https://sourceforge.net/u/juggernautsei/)** wrote on [Thursday, April 21, 2011](https://sourceforge.net/p/openemr/discussion/202506/thread/1ac74486/#28fe):

Below is the Edit\_Layout.php code. I am getting an error message

Fatal error: Call to undefined function x1() in C:\xampp\htdocs\east-test\interface\super\edit\_layout.php on line 51

What am I missing?

\<?php  
// Copyright (C) 2007-2009 Rod Roark \<[rod@sunsetsystems.com](mailto:rod@sunsetsystems.com)\>  
//  
// This program is free software; you can redistribute it and/or  
// modify it under the terms of the GNU General Public License  
// as published by the Free Software Foundation; either version 2  
// of the License, or (at your option) any later version.

require\_once("…/globals.php");  
require\_once("$srcdir/acl.inc");  
require\_once("$srcdir/log.inc");  
require\_once("$srcdir/formdata.inc.php");

$layouts = array(  
&nbsp; ‘DEM’ =\> xl(‘Demographics’),  
&nbsp; ‘HIS’ =\> xl(‘History’),  
&nbsp; ‘REF’ =\> xl(‘Referrals’),  
);  
if ($GLOBALS) {  
&nbsp; $layouts = xl(‘Abortion Issues’);  
&nbsp; $layouts = xl(‘Contraception Issues’);  
&nbsp; // $layouts = xl(‘SRH Visit Form’);  
}

// Include Layout Based Encounter Forms.  
$lres = sqlStatement("SELECT \* FROM list\_options " .  
&nbsp; “WHERE list\_id = ‘lbfnames’ ORDER BY seq, title”);  
while ($lrow = sqlFetchArray($lres)) {  
&nbsp; $layouts[$lrow] = $lrow;  
}

// array of the data\_types of the fields  
$datatypes = array(  
&nbsp; “1”&nbsp; =\> xl(“List box”),  
&nbsp; “2”&nbsp; =\> xl(“Textbox”),  
&nbsp; “3”&nbsp; =\> xl(“Textarea”),  
&nbsp; “4”&nbsp; =\> xl(“Text-date”),  
&nbsp; “10” =\> xl(“Providers”),  
&nbsp; “11” =\> xl(“Providers NPI”),  
&nbsp; “12” =\> xl(“Pharmacies”),  
&nbsp; “13” =\> xl(“Squads”),  
&nbsp; “14” =\> xl(“Organizations”),  
&nbsp; “15” =\> xl(“Billing codes”),  
&nbsp; “21” =\> xl(“Checkbox list”),  
&nbsp; “22” =\> xl(“Textbox list”),  
&nbsp; “23” =\> xl(“Exam results”),  
&nbsp; “24” =\> xl(“Patient allergies”),  
&nbsp; “25” =\> xl(“Checkbox w/text”),  
&nbsp; “26” =\> xl(“List box w/add”),  
&nbsp; “27” =\> xl(“Radio buttons”),  
&nbsp; “28” =\> x1(“Drug List”),  
);

function nextGroupOrder($order) {  
&nbsp; if ($order == ‘9’) $order = ‘A’;  
&nbsp; else if ($order == ‘Z’) $order = ‘a’;  
&nbsp; else $order = chr(ord($order) + 1);  
&nbsp; return $order;  
}

// Check authorization.  
$thisauth = acl\_check(‘admin’, ‘super’);  
if (!$thisauth) die(xl(‘Not authorized’));

// The layout ID identifies the layout to be edited.  
$layout\_id = empty($\_REQUEST) ? ‘’ : $\_REQUEST;

// Handle the Form actions

if ($\_POST == “save” && $layout\_id) {  
&nbsp;&nbsp;&nbsp; // If we are saving, then save.  
&nbsp;&nbsp;&nbsp; $fld = $\_POST;  
&nbsp;&nbsp;&nbsp; for ($lino = 1; isset($fld); ++$lino) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $iter = $fld;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $field\_id = formTrim($iter);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $data\_type = formTrim($iter);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // For a textarea (data type 3) max\_length has a special meaning, to  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // specify its height (in rows).&nbsp; This kludge assigns a fixed height,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // but this GUI really needs to support max\_length directly.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $max\_length = $data\_type == 3 ? 3 : 255;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($field\_id) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlStatement("UPDATE layout\_options SET " .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “title = '”&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; . formTrim($iter)&nbsp;&nbsp;&nbsp;&nbsp; . "’, " .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “group\_name = '”&nbsp;&nbsp;&nbsp; . formTrim($iter)&nbsp;&nbsp;&nbsp;&nbsp; . "’, " .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “seq = '”&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; . formTrim($iter)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; . "’, " .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “uor = '”&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; . formTrim($iter)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; . "’, " .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “fld\_length = '”&nbsp;&nbsp;&nbsp; . formTrim($iter)&nbsp;&nbsp;&nbsp; . "’, " .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "max\_length = ‘$max\_length’, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “titlecols = '”&nbsp;&nbsp;&nbsp;&nbsp; . formTrim($iter) . "’, " .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “datacols = '”&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; . formTrim($iter)&nbsp; . "’, " .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "data\_type= ‘$data\_type’, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “list\_id= '”&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; . formTrim($iter)&nbsp;&nbsp; . "’, " .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “default\_value = '” . formTrim($iter)&nbsp;&nbsp; . "’, " .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “description = '”&nbsp;&nbsp; . formTrim($iter)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; . "’ " .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “WHERE form\_id = ‘$layout\_id’ AND field\_id = ‘$field\_id’”);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp; }  
}

else if ($\_POST == “addfield” && $layout\_id) {  
&nbsp;&nbsp;&nbsp; // Add a new field to a specific group  
&nbsp;&nbsp;&nbsp; $data\_type = formTrim($\_POST);  
&nbsp;&nbsp;&nbsp; $max\_length = $data\_type == 3 ? 3 : 255;  
&nbsp;&nbsp;&nbsp; sqlStatement(“INSERT INTO layout\_options (” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " form\_id, field\_id, title, group\_name, seq, uor, fld\_length" .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “, titlecols, datacols, data\_type, default\_value, description” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ", max\_length, list\_id " .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “) VALUES ( " .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “’”&nbsp; . formTrim($\_POST&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ) . “’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “,’” . formTrim($\_POST&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ) . “’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “,’” . formTrim($\_POST&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ) . “’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “,’” . formTrim($\_POST) . “’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “,’” . formTrim($\_POST&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ) . “’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “,’” . formTrim($\_POST&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ) . “’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “,’” . formTrim($\_POST&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ) . “’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “,’” . formTrim($\_POST&nbsp;&nbsp; ) . “’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “,’” . formTrim($\_POST&nbsp;&nbsp;&nbsp; ) . “’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “,’$data\_type’”&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “,’” . formTrim($\_POST&nbsp;&nbsp;&nbsp;&nbsp; ) . “’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “,’” . formTrim($\_POST&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ) . “’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “,’$max\_length’”&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “,’” . formTrim($\_POST&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ) . “’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " )”);

&nbsp;&nbsp;&nbsp; if (substr($layout\_id,0,3) != ‘LBF’) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Add the field to the table too (this is critical)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($layout\_id == “DEM”) { $tablename = “patient\_data”; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if ($layout\_id == “HIS”) { $tablename = “history\_data”; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if ($layout\_id == “REF”) { $tablename = “transactions”; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if ($layout\_id == “SRH”) { $tablename = “lists\_ippf\_srh”; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if ($layout\_id == “CON”) { $tablename = “lists\_ippf\_con”; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if ($layout\_id == “GCA”) { $tablename = “lists\_ippf\_gcac”; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlStatement(“ALTER TABLE `” . $tablename . "` ADD “.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “`” . formTrim($_POST) . “`” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " VARCHAR( 255 )”);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newEvent(“alter\_table”, $\_SESSION, $\_SESSION,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $tablename . " ADD " . formTrim($\_POST));  
&nbsp;&nbsp;&nbsp; }  
}

else if ($\_POST == “movefields” && $layout\_id) {  
&nbsp;&nbsp;&nbsp; // Move field(s) to a new group in the layout  
&nbsp;&nbsp;&nbsp; $sqlstmt = “UPDATE layout\_options SET “.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " group\_name=’”. $\_POST.”’ “.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " WHERE “.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " form\_id = '”.$\_POST.”’ “.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " AND field\_id IN (”;  
&nbsp;&nbsp;&nbsp; $comma = “”;  
&nbsp;&nbsp;&nbsp; foreach (explode(" “, $\_POST) as $onefield) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $sqlstmt .= $comma.”’".$onefield."’";  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $comma = ", ";  
&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp; $sqlstmt .= “)”;  
&nbsp;&nbsp;&nbsp; //echo $sqlstmt;  
&nbsp;&nbsp;&nbsp; sqlStatement($sqlstmt);  
}

else if ($\_POST == “deletefields” && $layout\_id) {  
&nbsp;&nbsp;&nbsp; // Delete a field from a specific group  
&nbsp;&nbsp;&nbsp; $sqlstmt = “DELETE FROM layout\_options WHERE “.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " form\_id = '”.$\_POST.”’ “.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " AND field\_id IN (”;  
&nbsp;&nbsp;&nbsp; $comma = “”;  
&nbsp;&nbsp;&nbsp; foreach (explode(" “, $\_POST) as $onefield) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $sqlstmt .= $comma.”’".$onefield."’";  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $comma = ", ";  
&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp; $sqlstmt .= “)”;  
&nbsp;&nbsp;&nbsp; sqlStatement($sqlstmt);

&nbsp;&nbsp;&nbsp; if (substr($layout\_id,0,3) != ‘LBF’) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // drop the field from the table too (this is critical)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($layout\_id == “DEM”) { $tablename = “patient\_data”; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if ($layout\_id == “HIS”) { $tablename = “history\_data”; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if ($layout\_id == “REF”) { $tablename = “transactions”; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if ($layout\_id == “SRH”) { $tablename = “lists\_ippf\_srh”; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if ($layout\_id == “CON”) { $tablename = “lists\_ippf\_con”; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if ($layout\_id == “GCA”) { $tablename = “lists\_ippf\_gcac”; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (explode(" “, $\_POST) as $onefield) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlStatement(“ALTER TABLE `”.$tablename.”` DROP `".$onefield."`");  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newEvent(“alter\_table”, $\_SESSION, $\_SESSION, $tablename." DROP ".$onefield);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp; }  
}

else if ($\_POST == “addgroup” && $layout\_id) {  
&nbsp;&nbsp;&nbsp; // all group names are prefixed with a number indicating their display order  
&nbsp;&nbsp;&nbsp; // this new group is prefixed with the net highest number given the  
&nbsp;&nbsp;&nbsp; // layout\_id  
&nbsp;&nbsp;&nbsp; $results = sqlStatement(“select distinct(group\_name) as gname “.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " from layout\_options where “.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " form\_id = '”.$\_POST.”’”  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; );  
&nbsp;&nbsp;&nbsp; $maxnum = ‘1’;  
&nbsp;&nbsp;&nbsp; while ($result = sqlFetchArray($results)) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $tmp = substr($result, 0, 1);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($tmp \>= $maxnum) $maxnum = nextGroupOrder($tmp);  
&nbsp;&nbsp;&nbsp; }

&nbsp;&nbsp;&nbsp; $data\_type = formTrim($\_POST);  
&nbsp;&nbsp;&nbsp; $max\_length = $data\_type == 3 ? 3 : 255;

&nbsp;&nbsp;&nbsp; // add a new group to the layout, with the defined field  
&nbsp;&nbsp;&nbsp; sqlStatement(“INSERT INTO layout\_options (” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " form\_id, field\_id, title, group\_name, seq, uor, fld\_length" .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “, titlecols, datacols, data\_type, default\_value, description” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ", max\_length, list\_id " .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “) VALUES ( " .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “’”&nbsp; . formTrim($\_POST&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ) . “’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “,’” . formTrim($\_POST&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ) . “’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “,’” . formTrim($\_POST&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ) . “’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “,’” . formTrim($maxnum . $\_POST) . “’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “,’” . formTrim($\_POST&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ) . “’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “,’” . formTrim($\_POST&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ) . “’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “,’” . formTrim($\_POST&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ) . “’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “,’” . formTrim($\_POST&nbsp;&nbsp; ) . “’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “,’” . formTrim($\_POST&nbsp;&nbsp;&nbsp; ) . “’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “,’$data\_type’”&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “,’” . formTrim($\_POST&nbsp;&nbsp;&nbsp;&nbsp; ) . “’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “,’” . formTrim($\_POST&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ) . “’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “,’$max\_length’”&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “,’” . formTrim($\_POST&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ) . “’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " )”);

&nbsp;&nbsp;&nbsp; if (substr($layout\_id,0,3) != ‘LBF’) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Add the field to the table too (this is critical)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($layout\_id == “DEM”) { $tablename = “patient\_data”; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if ($layout\_id == “HIS”) { $tablename = “history\_data”; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if ($layout\_id == “REF”) { $tablename = “transactions”; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if ($layout\_id == “SRH”) { $tablename = “lists\_ippf\_srh”; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if ($layout\_id == “CON”) { $tablename = “lists\_ippf\_con”; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if ($layout\_id == “GCA”) { $tablename = “lists\_ippf\_gcac”; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlStatement(“ALTER TABLE `” . $tablename . "` ADD “.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “`” . formTrim($_POST) . “`” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " VARCHAR( 255 )”);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newEvent(“alter\_table”, $\_SESSION, $\_SESSION,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $tablename . " ADD " . formTrim($\_POST));  
&nbsp;&nbsp;&nbsp; }  
}

else if ($\_POST == “deletegroup” && $layout\_id) {  
&nbsp;&nbsp;&nbsp; // drop the fields from the related table (this is critical)  
&nbsp;&nbsp;&nbsp; if (substr($layout\_id,0,3) != ‘LBF’) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $res = sqlStatement(“SELECT field\_id FROM layout\_options WHERE " .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " form\_id = '”.$\_POST."’ “.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " AND group\_name = '”.$\_POST."’"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; );  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while ($row = sqlFetchArray($res)) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // drop the field from the table too (this is critical)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($layout\_id == “DEM”) { $tablename = “patient\_data”; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if ($layout\_id == “HIS”) { $tablename = “history\_data”; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if ($layout\_id == “REF”) { $tablename = “transactions”; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if ($layout\_id == “SRH”) { $tablename = “lists\_ippf\_srh”; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if ($layout\_id == “CON”) { $tablename = “lists\_ippf\_con”; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if ($layout\_id == “GCA”) { $tablename = “lists\_ippf\_gcac”; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlStatement(“ALTER TABLE `”.$tablename."` DROP `".$row."`");  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newEvent(“alter\_table”, $\_SESSION, $\_SESSION, $tablename." DROP ".trim($row));  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp; }

&nbsp;&nbsp;&nbsp; // Delete an entire group from the form  
&nbsp;&nbsp;&nbsp; sqlStatement(“DELETE FROM layout\_options WHERE “.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " form\_id = '”.$\_POST.”’ “.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " AND group\_name = '”.$\_POST."’"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; );  
}

else if ($\_POST == “movegroup” && $layout\_id) {  
&nbsp; $results = sqlStatement("SELECT DISTINCT(group\_name) AS gname " .  
&nbsp;&nbsp;&nbsp; "FROM layout\_options WHERE form\_id = ‘$layout\_id’ " .  
&nbsp;&nbsp;&nbsp; “ORDER BY gname”);  
&nbsp; $garray = array();  
&nbsp; $i = 0;  
&nbsp; while ($result = sqlFetchArray($results)) {  
&nbsp;&nbsp;&nbsp; if ($result == $\_POST) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($\_POST == ‘up’) { // moving up  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($i \> 0) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $garray = $garray;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $garray = $result;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $i++;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $garray = $result;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else { // moving down  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $garray = ‘’;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $garray = $result;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp; else if ($i \> 1 && $garray == ‘’) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $garray = $result;  
&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp; else {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $garray = $result;  
&nbsp;&nbsp;&nbsp; }  
&nbsp; }  
&nbsp; $nextord = ‘1’;  
&nbsp; foreach ($garray as $value) {  
&nbsp;&nbsp;&nbsp; if ($value === ‘’) continue;  
&nbsp;&nbsp;&nbsp; $newname = $nextord . substr($value, 1);  
&nbsp;&nbsp;&nbsp; sqlStatement("UPDATE layout\_options SET " .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "group\_name = ‘$newname’ WHERE " .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "form\_id = ‘$layout\_id’ AND " .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “group\_name = ‘$value’”);  
&nbsp;&nbsp;&nbsp; $nextord = nextGroupOrder($nextord);  
&nbsp; }  
}

else if ($\_POST == “renamegroup” && $layout\_id) {  
&nbsp; $currpos = substr($\_POST, 0, 1);  
&nbsp; // update the database rows  
&nbsp; sqlStatement("UPDATE layout\_options SET " .  
&nbsp;&nbsp;&nbsp; “group\_name = '” . $currpos . $\_POST . "’ ".  
&nbsp;&nbsp;&nbsp; "WHERE form\_id = ‘$layout\_id’ AND ".  
&nbsp;&nbsp;&nbsp; “group\_name = '” . $\_POST . “’”);  
}

// Get the selected form’s elements.  
if ($layout\_id) {  
&nbsp; $res = sqlStatement("SELECT \* FROM layout\_options WHERE " .  
&nbsp;&nbsp;&nbsp; “form\_id = ‘$layout\_id’ ORDER BY group\_name, seq”);  
}

// global counter for field numbers  
$fld\_line\_no = 0;

// Write one option line to the form.  
//  
function writeFieldLine($linedata) {  
&nbsp;&nbsp;&nbsp; global $fld\_line\_no;  
&nbsp;&nbsp;&nbsp; ++$fld\_line\_no;  
&nbsp;&nbsp;&nbsp; $checked = $linedata ? " checked" : “”;  
&nbsp;  
&nbsp;&nbsp;&nbsp; //echo " \<tr bgcolor=’$bgcolor’\>\n";  
&nbsp;&nbsp;&nbsp; echo " \<tr id=‘fld’ class=’".($fld\_line\_no % 2 ? ‘even’ : ‘odd’)."’\>\n";  
&nbsp;  
&nbsp;&nbsp;&nbsp; echo "&nbsp; \<td class=‘optcell’ nowrap\>";  
&nbsp;&nbsp;&nbsp; // tuck the group\_name INPUT in here  
&nbsp;&nbsp;&nbsp; echo “\<input type=‘hidden’ name=‘fld’ value=’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; htmlspecialchars($linedata, ENT\_QUOTES) . “’ class=‘optin’ /\>”;

&nbsp;&nbsp;&nbsp; echo “\<input type=‘checkbox’ class=‘selectfield’ “.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “name=’”.$linedata.”~”.$linedata."’ “.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “id=’”.$linedata.”~".$linedata."’ “.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “title=’”.htmlspecialchars(xl(‘Select field’, ENT\_QUOTES)).”’\>";

&nbsp;&nbsp;&nbsp; echo “\<input type=‘text’ name=‘fld’ id=‘fld’ value=’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; htmlspecialchars($linedata, ENT\_QUOTES) . “’ size=‘2’ maxlength=‘3’ class=‘optin’ /\>”;  
&nbsp;&nbsp;&nbsp; echo “\</td\>\n”;  
&nbsp;  
&nbsp;&nbsp;&nbsp; echo "&nbsp; \<td align=‘left’ class=‘optcell’\>";  
&nbsp;&nbsp;&nbsp; echo “\<input type=‘text’ name=‘fld’ value=’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; htmlspecialchars($linedata, ENT\_QUOTES) . “’ size=‘15’ maxlength=‘63’ class=‘optin noselect’ /\>”;  
&nbsp;&nbsp;&nbsp; /\*  
&nbsp;&nbsp;&nbsp; echo “\<input type=‘hidden’ name=‘fld’ value=’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; htmlspecialchars($linedata, ENT\_QUOTES) . “’ /\>”;  
&nbsp;&nbsp;&nbsp; echo htmlspecialchars($linedata, ENT\_QUOTES);  
&nbsp;&nbsp;&nbsp; \*/  
&nbsp;&nbsp;&nbsp; echo “\</td\>\n”;  
&nbsp;  
&nbsp;&nbsp;&nbsp; echo "&nbsp; \<td align=‘center’ class=‘optcell’\>";  
&nbsp;&nbsp;&nbsp; echo “\<input type=‘text’ id=‘fld’ name=‘fld’ value=’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; htmlspecialchars($linedata, ENT\_QUOTES) . “’ size=‘15’ maxlength=‘63’ class=‘optin’ /\>”;  
&nbsp;&nbsp;&nbsp; echo “\</td\>\n”;

&nbsp;&nbsp;&nbsp; // if not english and set to translate layout labels, then show the translation  
&nbsp;&nbsp;&nbsp; if ($GLOBALS && $\_SESSION \> 1) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo “\<td align=‘center’ class=‘translation’\>” . htmlspecialchars(xl($linedata), ENT\_QUOTES) . “\</td\>\n”;  
&nbsp;&nbsp;&nbsp; }

&nbsp;&nbsp;&nbsp; echo "&nbsp; \<td align=‘center’ class=‘optcell’\>";  
&nbsp;&nbsp;&nbsp; echo “\<select name=‘fld’ class=‘optin’\>”;  
&nbsp;&nbsp;&nbsp; foreach (array(0 =\>xl(‘Unused’), 1 =\>xl(‘Optional’), 2 =\>xl(‘Required’)) as $key =\> $value) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo “\<option value=’$key’”;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($key == $linedata) echo " selected";  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo “\>$value\</option\>\n”;  
&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp; echo “\</select\>”;  
&nbsp;&nbsp;&nbsp; echo “\</td\>\n”;  
&nbsp;  
&nbsp;&nbsp;&nbsp; echo "&nbsp; \<td align=‘center’ class=‘optcell’\>";  
&nbsp;&nbsp;&nbsp; echo “\<select name=‘fld’ id=‘fld’\>”;  
&nbsp;&nbsp;&nbsp; echo “\<option value=’’\>\</option\>”;  
&nbsp;&nbsp;&nbsp; GLOBAL $datatypes;  
&nbsp;&nbsp;&nbsp; foreach ($datatypes as $key=\>$value) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($linedata == $key)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo “\<option value=’$key’ selected\>$value\</option\>”;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo “\<option value=’$key’\>$value\</option\>”;  
&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp; echo “\</select\>”;  
&nbsp;&nbsp;&nbsp; echo "&nbsp; \</td\>";

&nbsp;&nbsp;&nbsp; echo "&nbsp; \<td align=‘center’ class=‘optcell’\>";  
&nbsp;&nbsp;&nbsp; if ($linedata == 2 || $linedata == 3 ||  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $linedata == 21 || $linedata == 22 ||  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $linedata == 23 || $linedata == 25 ||  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $linedata == 27 || $linedata == 28)  
&nbsp;&nbsp;&nbsp; {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo “\<input type=‘text’ name=‘fld’ value=’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; htmlspecialchars($linedata, ENT\_QUOTES) .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “’ size=‘1’ maxlength=‘10’ class=‘optin’ /\>”;  
&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp; else {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // all other data\_types  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo “\<input type=‘hidden’ name=‘fld’ value=’’\>”;  
&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp; echo “\</td\>\n”;

&nbsp;&nbsp;&nbsp; echo "&nbsp; \<td align=‘center’ class=‘optcell’\>";  
&nbsp;&nbsp;&nbsp; if ($linedata ==&nbsp; 1 || $linedata == 21 ||  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $linedata == 22 || $linedata == 23 ||  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $linedata == 25 || $linedata == 26 ||  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $linedata == 27 || $linedata == 28)  
&nbsp;&nbsp;&nbsp; {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo “\<input type=‘text’ name=‘fld’ value=’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; htmlspecialchars($linedata, ENT\_QUOTES) . “’”.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “size=‘6’ maxlength=‘30’ class=‘optin listid’ style=‘cursor: pointer’”.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “title=’”. xl(‘Choose list’) . “’ /\>”;  
&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp; else {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // all other data\_types  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo “\<input type=‘hidden’ name=‘fld’ value=’’\>”;  
&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp; echo “\</td\>\n”;

&nbsp;&nbsp;&nbsp; echo "&nbsp; \<td align=‘center’ class=‘optcell’\>";  
&nbsp;&nbsp;&nbsp; echo “\<input type=‘text’ name=‘fld’ value=’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; htmlspecialchars($linedata, ENT\_QUOTES) . “’ size=‘3’ maxlength=‘10’ class=‘optin’ /\>”;  
&nbsp;&nbsp;&nbsp; echo “\</td\>\n”;  
&nbsp;  
&nbsp;&nbsp;&nbsp; echo "&nbsp; \<td align=‘center’ class=‘optcell’\>";  
&nbsp;&nbsp;&nbsp; echo “\<input type=‘text’ name=‘fld’ value=’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; htmlspecialchars($linedata, ENT\_QUOTES) . “’ size=‘3’ maxlength=‘10’ class=‘optin’ /\>”;  
&nbsp;&nbsp;&nbsp; echo “\</td\>\n”;

&nbsp;&nbsp;&nbsp; echo "&nbsp; \<td align=‘center’ class=‘optcell’\>";  
&nbsp;&nbsp;&nbsp; if ($linedata == 2) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo “\<input type=‘text’ name=‘fld’ value=’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; htmlspecialchars($linedata, ENT\_QUOTES) . “’ size=‘10’ maxlength=‘63’ class=‘optin’ /\>”;  
&nbsp;&nbsp;&nbsp; } else {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo “&nbsp;”;  
&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp; echo “\</td\>\n”;  
&nbsp;  
&nbsp;&nbsp;&nbsp; echo "&nbsp; \<td align=‘center’ class=‘optcell’\>";  
&nbsp;&nbsp;&nbsp; echo “\<input type=‘text’ name=‘fld’ value=’” .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; htmlspecialchars($linedata, ENT\_QUOTES) . “’ size=‘20’ maxlength=‘63’ class=‘optin’ /\>”;  
&nbsp;&nbsp;&nbsp; echo “\</td\>\n”;

&nbsp;&nbsp;&nbsp; // if not english and showing layout labels, then show the translation of Description  
&nbsp;&nbsp;&nbsp; if ($GLOBALS && $\_SESSION \> 1) {  
&nbsp;&nbsp;&nbsp;&nbsp; echo “\<td align=‘center’ class=‘translation’\>” . htmlspecialchars(xl($linedata), ENT\_QUOTES) . “\</td\>\n”;  
&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp; echo " \</tr\>\n";  
}  
?\>  
\<html\>

\<head\>  
\<?php html\_header\_show();?\>

\<!- supporting javascript code -\>  
\<script type=“text/javascript” src="\<?php echo $GLOBALS ?\>/library/js/jquery.js"\>\</script\>

\<link rel=“stylesheet” href=’\<?php&nbsp; echo $css\_header ?\>’ type=‘text/css’\>

\<title\>\<?php&nbsp; xl(‘Layout Editor’,‘e’); ?\>\</title\>

\<style\>  
tr.head&nbsp;&nbsp; { font-size:10pt; background-color:#cccccc; }  
tr.detail { font-size:10pt; }  
td&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { font-size:10pt; }  
input&nbsp;&nbsp;&nbsp;&nbsp; { font-size:10pt; }  
a, a:visited, a:hover { color:#0000cc; }  
.optcell&nbsp; { }  
.optin&nbsp;&nbsp;&nbsp; { background: transparent; }  
.group {  
&nbsp;&nbsp;&nbsp; margin: 0pt 0pt 8pt 0pt;  
&nbsp;&nbsp;&nbsp; padding: 0;  
&nbsp;&nbsp;&nbsp; width: 100%;  
}  
.group table {  
&nbsp;&nbsp;&nbsp; border-collapse: collapse;  
&nbsp;&nbsp;&nbsp; width: 100%;  
}  
.odd td {  
&nbsp;&nbsp;&nbsp; background-color: #ddddff;  
&nbsp;&nbsp;&nbsp; padding: 3px 0px 3px 0px;  
}  
.even td {  
&nbsp;&nbsp;&nbsp; background-color: #ffdddd;  
&nbsp;&nbsp;&nbsp; padding: 3px 0px 3px 0px;  
}  
.help { cursor: help; }  
.layouts\_title { font-size: 110%; }  
.translation {  
&nbsp;&nbsp;&nbsp; color: green;  
&nbsp;&nbsp;&nbsp; font-size:10pt;  
}  
.highlight \* {  
&nbsp;&nbsp;&nbsp; border: 2px solid blue;  
&nbsp;&nbsp;&nbsp; background-color: yellow;  
&nbsp;&nbsp;&nbsp; color: black;  
}  
\</style\>

\</head\>

\<body class=“body\_top”\>

\<form method=‘post’ name=‘theform’ id=‘theform’ action=‘edit\_layout.php’\>  
\<input type=“hidden” name=“formaction” id=“formaction” value=""\>  
\<!- elements used to identify a field to delete -\>  
\<input type=“hidden” name=“deletefieldid” id=“deletefieldid” value=""\>  
\<input type=“hidden” name=“deletefieldgroup” id=“deletefieldgroup” value=""\>  
\<!- elements used to identify a group to delete -\>  
\<input type=“hidden” name=“deletegroupname” id=“deletegroupname” value=""\>  
\<!- elements used to change the group order -\>  
\<input type=“hidden” name=“movegroupname” id=“movegroupname” value=""\>  
\<input type=“hidden” name=“movedirection” id=“movedirection” value=""\>  
\<!- elements used to select more than one field -\>  
\<input type=“hidden” name=“selectedfields” id=“selectedfields” value=""\>  
\<input type=“hidden” id=“targetgroup” name=“targetgroup” value=""\>

\<p\>\<b\>\<?php xl(‘Edit layout’,‘e’); ?\>:\</b\>&nbsp;  
\<select name=‘layout\_id’ id=‘layout\_id’\>  
\<option value=’’\>- \<?php echo xl(‘Select’) ?\> -\</option\>  
\<?php  
foreach ($layouts as $key =\> $value) {  
&nbsp; echo " \<option value=’$key’";  
&nbsp; if ($key == $layout\_id) echo " selected";  
&nbsp; echo “\>$value\</option\>\n”;  
}  
?\>  
\</select\>\</p\>

\<?php if ($layout\_id) { ?\>  
\<div style=‘margin: 0 0 8pt 0;’\>  
\<input type=‘button’ class=‘addgroup’ id=‘addgroup’ value=\<?php xl(‘Add Group’,‘e’,’’’,’’’); ?\>/\>  
\</div\>  
\<?php } ?\>

\<?php  
$prevgroup = “!@#asdf1234”; // an unlikely group name  
$firstgroup = true; // flag indicates it’s the first group to be displayed  
while ($row = sqlFetchArray($res)) {  
&nbsp; if ($row != $prevgroup) {  
&nbsp;&nbsp;&nbsp; if ($firstgroup == false) { echo “\</tbody\>\</table\>\</div\>\n”; }  
&nbsp;&nbsp;&nbsp; echo “\<div id=’”.$row."’ class=‘group’\>";  
&nbsp;&nbsp;&nbsp; echo “\<div class=‘text bold layouts\_title’ style=‘position:relative; background-color: #eef’\>”;  
&nbsp;&nbsp;&nbsp; // echo preg\_replace("/^\d+/", “”, $row);  
&nbsp;&nbsp;&nbsp; echo substr($row, 1);  
&nbsp;&nbsp;&nbsp; echo “&nbsp; “;  
&nbsp;&nbsp;&nbsp; // if not english and set to translate layout labels, then show the translation of group name  
&nbsp;&nbsp;&nbsp; if ($GLOBALS && $\_SESSION \> 1) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // echo “\<span class=‘translation’\>\>\>&nbsp; " . xl(preg\_replace(”/^\d+/”, “”, $row)) . “\</span\>”;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo “\<span class=‘translation’\>\>\>&nbsp; " . xl(substr($row, 1)) . “\</span\>”;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo “&nbsp; “;  
&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp; echo “&nbsp; “;  
&nbsp;&nbsp;&nbsp; echo " \<input type=‘button’ class=‘addfield’ id='addto~”.$row.”’ value=’” . xl(‘Add Field’) . “’/\>”;  
&nbsp;&nbsp;&nbsp; echo “&nbsp; &nbsp; “;  
&nbsp;&nbsp;&nbsp; echo " \<input type=‘button’ class=‘renamegroup’ id=’”.$row.”’ value=’” . xl(‘Rename Group’) . “’/\>”;  
&nbsp;&nbsp;&nbsp; echo “&nbsp; &nbsp; “;  
&nbsp;&nbsp;&nbsp; echo " \<input type=‘button’ class=‘deletegroup’ id=’”.$row.”’ value=’” . xl(‘Delete Group’) . “’/\>”;  
&nbsp;&nbsp;&nbsp; echo “&nbsp; &nbsp; “;  
&nbsp;&nbsp;&nbsp; echo " \<input type=‘button’ class=‘movegroup’ id=’”.$row.”~up’ value=’” . xl(‘Move Up’) . “’/\>”;  
&nbsp;&nbsp;&nbsp; echo “&nbsp; &nbsp; “;  
&nbsp;&nbsp;&nbsp; echo " \<input type=‘button’ class=‘movegroup’ id=’”.$row.”~down’ value=’" . xl(‘Move Down’) . “’/\>”;  
&nbsp;&nbsp;&nbsp; echo “\</div\>”;  
&nbsp;&nbsp;&nbsp; $firstgroup = false;  
?\>

\<table\>  
\<thead\>  
\<tr class=‘head’\>  
&nbsp; \<th\>\<?php xl(‘Order’,‘e’); ?\>\</th\>  
&nbsp; \<th\>\<?php xl(‘ID’,‘e’); ?\> \<span class=“help” title=\<?php xl(‘A unique value to identify this field, not visible to the user’,‘e’,’’’,’’’); ?\> \>(?)\</span\>\</th\>  
&nbsp; \<th\>\<?php xl(‘Label’,‘e’); ?\> \<span class=“help” title=\<?php xl(‘The label that appears to the user on the form’,‘e’,’’’,’’’); ?\> \>(?)\</span\>\</th\>  
&nbsp; \<?php // if not english and showing layout label translations, then show translation header for title  
&nbsp; if ($GLOBALS && $\_SESSION \> 1) {  
&nbsp;&nbsp; echo “\<th\>” . xl(‘Translation’)."\<span class=‘help’ title=’" . xl(‘The translated label that will appear on the form in current language’) . “’\> (?)\</span\>\</th\>”;  
&nbsp; } ?\> &nbsp;  
&nbsp; \<th\>\<?php xl(‘UOR’,‘e’); ?\>\</th\>  
&nbsp; \<th\>\<?php xl(‘Data Type’,‘e’); ?\>\</th\>  
&nbsp; \<th\>\<?php xl(‘Size’,‘e’); ?\>\</th\>  
&nbsp; \<th\>\<?php xl(‘List’,‘e’); ?\>\</th\>  
&nbsp; \<th\>\<?php xl(‘Label Cols’,‘e’); ?\>\</th\>  
&nbsp; \<th\>\<?php xl(‘Data Cols’,‘e’); ?\>\</th\>  
&nbsp; \<th\>\<?php xl(‘Default Value’,‘e’); ?\>\</th\>  
&nbsp; \<th\>\<?php xl(‘Description’,‘e’); ?\>\</th\>  
&nbsp; \<?php // if not english and showing layout label translations, then show translation header for description  
&nbsp; if ($GLOBALS && $\_SESSION \> 1) {  
&nbsp;&nbsp; echo “\<th\>” . xl(‘Translation’)."\<span class=‘help’ title=’" . xl(‘The translation of description in current language’)."’\> (?)\</span\>\</th\>";  
&nbsp; } ?\>  
\</tr\>  
\</thead\>  
\<tbody\>

\<?php  
&nbsp;&nbsp;&nbsp; } // end if-group\_name

&nbsp;&nbsp;&nbsp; writeFieldLine($row);  
&nbsp;&nbsp;&nbsp; $prevgroup = $row;

} // end while loop

?\>  
\</tbody\>  
\</table\>\</div\>

\<?php if ($layout\_id) { ?\>  
\<span style=“font-size:90%”\>  
\<?php xl(‘With selected:’, ‘e’);?\>  
\<input type=‘button’ name=‘deletefields’ id=‘deletefields’ value=’\<?php xl(‘Delete’,‘e’); ?\>’ style=“font-size:90%” disabled=“disabled” /\>  
\<input type=‘button’ name=‘movefields’ id=‘movefields’ value=’\<?php xl(‘Move to…’,‘e’); ?\>’ style=“font-size:90%” disabled=“disabled” /\>  
\</span\>  
\<p\>  
\<input type=‘button’ name=‘save’ id=‘save’ value=’\<?php xl(‘Save Changes’,‘e’); ?\>’ /\>  
\</p\>  
\<?php } ?\>

\</form\>

\<!- template DIV that appears when user chooses to rename an existing group -\>  
\<div id=“renamegroupdetail” style=“border: 1px solid black; padding: 3px; display: none; visibility: hidden; background-color: lightgrey;”\>  
\<input type=“hidden” name=“renameoldgroupname” id=“renameoldgroupname” value=""\>  
\<?php xl(‘Group Name’,‘e’); ?\>: \<input type=“textbox” size=“20” maxlength=“30” name=“renamegroupname” id=“renamegroupname”\>  
\<br\>  
\<input type=“button” class=“saverenamegroup” value=\<?php xl(‘Rename Group’,‘e’,’’’,’’’); ?\>\>  
\<input type=“button” class=“cancelrenamegroup” value=\<?php xl(‘Cancel’,‘e’,’’’,’’’); ?\>\>  
\</div\>

\<!- template DIV that appears when user chooses to add a new group -\>  
\<div id=“groupdetail” style=“border: 1px solid black; padding: 3px; display: none; visibility: hidden; background-color: lightgrey;”\>  
\<span class=‘bold’\>  
\<?php xl(‘Group Name’,‘e’); ?\>: \<input type=“textbox” size=“20” maxlength=“30” name=“newgroupname” id=“newgroupname”\>  
\<br\>  
\<table style=“border-collapse: collapse; margin-top: 5px;”\>  
\<thead\>  
\<tr class=‘head’\>  
&nbsp; \<th\>\<?php xl(‘Order’,‘e’); ?\>\</th\>  
&nbsp; \<th\>\<?php xl(‘ID’,‘e’); ?\> \<span class=“help” title=\<?php xl(‘A unique value to identify this field, not visible to the user’,‘e’,’’’,’’’); ?\> \>(?)\</span\>\</th\>  
&nbsp; \<th\>\<?php xl(‘Label’,‘e’); ?\> \<span class=“help” title=\<?php xl(‘The label that appears to the user on the form’,‘e’,’’’,’’’); ?\> \>(?)\</span\>\</th\>  
&nbsp; \<th\>\<?php xl(‘UOR’,‘e’); ?\>\</th\>  
&nbsp; \<th\>\<?php xl(‘Data Type’,‘e’); ?\>\</th\>  
&nbsp; \<th\>\<?php xl(‘Size’,‘e’); ?\>\</th\>  
&nbsp; \<th\>\<?php xl(‘List’,‘e’); ?\>\</th\>  
&nbsp; \<th\>\<?php xl(‘Label Cols’,‘e’); ?\>\</th\>  
&nbsp; \<th\>\<?php xl(‘Data Cols’,‘e’); ?\>\</th\>  
&nbsp; \<th\>\<?php xl(‘Default Value’,‘e’); ?\>\</th\>  
&nbsp; \<th\>\<?php xl(‘Description’,‘e’); ?\>\</th\>  
\</tr\>  
\</thead\>  
\<tbody\>  
\<tr class=‘center’\>  
\<td \>\<input type=“textbox” name=“gnewseq” id=“gnewseq” value="" size=“2” maxlength=“3”\> \</td\>  
\<td \>\<input type=“textbox” name=“gnewid” id=“gnewid” value="" size=“10” maxlength=“20”\> \</td\>  
\<td\>\<input type=“textbox” name=“gnewtitle” id=“gnewtitle” value="" size=“20” maxlength=“63”\> \</td\>  
\<td\>  
\<select name=“gnewuor” id=“gnewuor”\>  
\<option value=“0”\>\<?php xl(‘Unused’,‘e’); ?\>\</option\>  
\<option value=“1” selected\>\<?php xl(‘Optional’,‘e’); ?\>\</option\>  
\<option value=“2”\>\<?php xl(‘Required’,‘e’); ?\>\</option\>  
\</select\>  
\</td\>  
\<td align=‘center’\>  
\<select name=‘gnewdatatype’ id=‘gnewdatatype’\>  
\<option value=’’\>\</option\>  
\<?php  
global $datatypes;  
foreach ($datatypes as $key=\>$value) {  
&nbsp;&nbsp;&nbsp; echo “\<option value=’$key’\>$value\</option\>”;  
}  
?\>  
\</select\>  
\</td\>  
\<td\>\<input type=“textbox” name=“gnewlength” id=“gnewlength” value="" size=“1” maxlength=“3”\> \</td\>  
\<td\>\<input type=“textbox” name=“gnewlistid” id=“gnewlistid” value="" size=“8” maxlength=“31” class=“listid”\> \</td\>  
\<td\>\<input type=“textbox” name=“gnewtitlecols” id=“gnewtitlecols” value="" size=“3” maxlength=“3”\> \</td\>  
\<td\>\<input type=“textbox” name=“gnewdatacols” id=“gnewdatacols” value="" size=“3” maxlength=“3”\> \</td\>  
\<td\>\<input type=“textbox” name=“gnewdefault” id=“gnewdefault” value="" size=“20” maxlength=“63”\> \</td\>  
\<td\>\<input type=“textbox” name=“gnewdesc” id=“gnewdesc” value="" size=“20” maxlength=“63”\> \</td\>  
\</tr\>  
\</tbody\>  
\</table\>  
\<br\>  
\<input type=“button” class=“savenewgroup” value=\<?php xl(‘Save New Group’,‘e’,’’’,’’’); ?\>\>  
\<input type=“button” class=“cancelnewgroup” value=\<?php xl(‘Cancel’,‘e’,’’’,’’’); ?\>\>  
\</span\>  
\</div\>

\<!- template DIV that appears when user chooses to add a new field to a group -\>  
\<div id=“fielddetail” class=“fielddetail” style=“display: none; visibility: hidden”\>  
\<input type=“hidden” name=“newfieldgroupid” id=“newfieldgroupid” value=""\>  
\<table style=“border-collapse: collapse;”\>  
\<thead\>  
&nbsp; \<tr class=‘head’\>  
&nbsp;&nbsp; \<th\>\<?php xl(‘Order’,‘e’); ?\>\</th\>  
&nbsp;&nbsp; \<th\>\<?php xl(‘ID’,‘e’); ?\> \<span class=“help” title=\<?php xl(‘A unique value to identify this field, not visible to the user’,‘e’,’’’,’’’); ?\> \>(?)\</span\>\</th\>  
&nbsp;&nbsp; \<th\>\<?php xl(‘Label’,‘e’); ?\> \<span class=“help” title=\<?php xl(‘The label that appears to the user on the form’,‘e’,’’’,’’’); ?\> \>(?)\</span\>\</th\>  
&nbsp;&nbsp; \<th\>\<?php xl(‘UOR’,‘e’); ?\>\</th\>  
&nbsp;&nbsp; \<th\>\<?php xl(‘Data Type’,‘e’); ?\>\</th\>  
&nbsp;&nbsp; \<th\>\<?php xl(‘Size’,‘e’); ?\>\</th\>  
&nbsp;&nbsp; \<th\>\<?php xl(‘List’,‘e’); ?\>\</th\>  
&nbsp;&nbsp; \<th\>\<?php xl(‘Label Cols’,‘e’); ?\>\</th\>  
&nbsp;&nbsp; \<th\>\<?php xl(‘Data Cols’,‘e’); ?\>\</th\>  
&nbsp;&nbsp; \<th\>\<?php xl(‘Default Value’,‘e’); ?\>\</th\>  
&nbsp;&nbsp; \<th\>\<?php xl(‘Description’,‘e’); ?\>\</th\>  
&nbsp; \</tr\>  
\</thead\>  
\<tbody\>  
&nbsp; \<tr class=‘center’\>  
&nbsp;&nbsp; \<td \>\<input type=“textbox” name=“newseq” id=“newseq” value="" size=“2” maxlength=“3”\> \</td\>  
&nbsp;&nbsp; \<td \>\<input type=“textbox” name=“newid” id=“newid” value="" size=“10” maxlength=“20”\> \</td\>  
&nbsp;&nbsp; \<td\>\<input type=“textbox” name=“newtitle” id=“newtitle” value="" size=“20” maxlength=“63”\> \</td\>  
&nbsp;&nbsp; \<td\>  
&nbsp;&nbsp;&nbsp; \<select name=“newuor” id=“newuor”\>  
&nbsp;&nbsp;&nbsp;&nbsp; \<option value=“0”\>\<?php xl(‘Unused’,‘e’); ?\>\</option\>  
&nbsp;&nbsp;&nbsp;&nbsp; \<option value=“1” selected\>\<?php xl(‘Optional’,‘e’); ?\>\</option\>  
&nbsp;&nbsp;&nbsp;&nbsp; \<option value=“2”\>\<?php xl(‘Required’,‘e’); ?\>\</option\>  
&nbsp;&nbsp;&nbsp; \</select\>  
&nbsp;&nbsp; \</td\>  
&nbsp;&nbsp; \<td align=‘center’\>  
&nbsp;&nbsp;&nbsp; \<select name=‘newdatatype’ id=‘newdatatype’\>  
&nbsp;&nbsp;&nbsp;&nbsp; \<option value=’’\>\</option\>  
\<?php  
global $datatypes;  
foreach ($datatypes as $key=\>$value) {  
&nbsp;&nbsp;&nbsp; echo "&nbsp;&nbsp;&nbsp;&nbsp; \<option value=’$key’\>$value\</option\>\n";  
}  
?\>  
&nbsp;&nbsp;&nbsp; \</select\>  
&nbsp;&nbsp; \</td\>  
&nbsp;&nbsp; \<td\>\<input type=“textbox” name=“newlength” id=“newlength” value="" size=“1” maxlength=“3”\> \</td\>  
&nbsp;&nbsp; \<td\>\<input type=“textbox” name=“newlistid” id=“newlistid” value="" size=“8” maxlength=“31” class=“listid”\> \</td\>  
&nbsp;&nbsp; \<td\>\<input type=“textbox” name=“newtitlecols” id=“newtitlecols” value="" size=“3” maxlength=“3”\> \</td\>  
&nbsp;&nbsp; \<td\>\<input type=“textbox” name=“newdatacols” id=“newdatacols” value="" size=“3” maxlength=“3”\> \</td\>  
&nbsp;&nbsp; \<td\>\<input type=“textbox” name=“newdefault” id=“newdefault” value="" size=“20” maxlength=“63”\> \</td\>  
&nbsp;&nbsp; \<td\>\<input type=“textbox” name=“newdesc” id=“newdesc” value="" size=“20” maxlength=“63”\> \</td\>  
&nbsp; \</tr\>  
&nbsp; \<tr\>  
&nbsp;&nbsp; \<td colspan=“9”\>  
&nbsp;&nbsp;&nbsp; \<input type=“button” class=“savenewfield” value=\<?php xl(‘Save New Field’,‘e’,’’’,’’’); ?\>\>  
&nbsp;&nbsp;&nbsp; \<input type=“button” class=“cancelnewfield” value=\<?php xl(‘Cancel’,‘e’,’’’,’’’); ?\>\>  
&nbsp;&nbsp; \</td\>  
&nbsp; \</tr\>  
\</tbody\>  
\</table\>  
\</div\>

\</body\>

\<script language=“javascript”\>

// used when selecting a list-name for a field  
var selectedfield;

// jQuery stuff to make the page a little easier to use

$(document).ready(function(){  
&nbsp;&nbsp;&nbsp; $("#save").click(function() { SaveChanges(); });  
&nbsp;&nbsp;&nbsp; $("#layout\_id").change(function() { $(’#theform’).submit(); });

&nbsp;&nbsp;&nbsp; $(".addgroup").click(function() { AddGroup(this); });  
&nbsp;&nbsp;&nbsp; $(".savenewgroup").click(function() { SaveNewGroup(this); });  
&nbsp;&nbsp;&nbsp; $(".deletegroup").click(function() { DeleteGroup(this); });  
&nbsp;&nbsp;&nbsp; $(".cancelnewgroup").click(function() { CancelNewGroup(this); });

&nbsp;&nbsp;&nbsp; $(".movegroup").click(function() { MoveGroup(this); });

&nbsp;&nbsp;&nbsp; $(".renamegroup").click(function() { RenameGroup(this); });  
&nbsp;&nbsp;&nbsp; $(".saverenamegroup").click(function() { SaveRenameGroup(this); });  
&nbsp;&nbsp;&nbsp; $(".cancelrenamegroup").click(function() { CancelRenameGroup(this); });

&nbsp;&nbsp;&nbsp; $(".addfield").click(function() { AddField(this); });  
&nbsp;&nbsp;&nbsp; $("#deletefields").click(function() { DeleteFields(this); });  
&nbsp;&nbsp;&nbsp; $(".selectfield").click(function() {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var TRparent = $(this).parent().parent();  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(TRparent).children(“td”).toggleClass(“highlight”);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // disable the delete-move buttons  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $("#deletefields").attr(“disabled”, “disabled”);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $("#movefields").attr(“disabled”, “disabled”);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(".selectfield").each(function(i) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // if any field is selected, enable the delete-move buttons  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($(this).attr(“checked”) == true) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $("#deletefields").removeAttr(“disabled”);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $("#movefields").removeAttr(“disabled”);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; });  
&nbsp;&nbsp;&nbsp; });  
&nbsp;&nbsp;&nbsp; $("#movefields").click(function() { ShowGroups(this); });  
&nbsp;&nbsp;&nbsp; $(".savenewfield").click(function() { SaveNewField(this); });  
&nbsp;&nbsp;&nbsp; $(".cancelnewfield").click(function() { CancelNewField(this); });  
&nbsp;&nbsp;&nbsp; $("#newtitle").blur(function() { if ($("#newid").val() == “”) $("#newid").val($("#newtitle").val()); });

&nbsp;&nbsp;&nbsp; $(".listid").click(function() { ShowLists(this); });

&nbsp;&nbsp;&nbsp; // special class that skips the element  
&nbsp;&nbsp;&nbsp; $(".noselect").focus(function() { $(this).blur(); });

&nbsp;&nbsp;&nbsp; // Save the changes made to the form  
&nbsp;&nbsp;&nbsp; var SaveChanges = function () {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $("#formaction").val(“save”);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $("#theform").submit();  
&nbsp;&nbsp;&nbsp; }

&nbsp;&nbsp;&nbsp; /\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/  
&nbsp;&nbsp;&nbsp; /\*\*\*\*\*\*\*\*\*\*\*\* Group functions \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/  
&nbsp;&nbsp;&nbsp; /\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

&nbsp;&nbsp;&nbsp; // display the ‘new group’ DIV  
&nbsp;&nbsp;&nbsp; var AddGroup = function(btnObj) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // show the field details DIV  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(’#groupdetail’).css(‘visibility’, ‘visible’);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(’#groupdetail’).css(‘display’, ‘block’);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(btnObj).parent().append($("#groupdetail"));  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(’#groupdetail \> #newgroupname’).focus();  
&nbsp;&nbsp;&nbsp; };

&nbsp;&nbsp;&nbsp; // save the new group to the form  
&nbsp;&nbsp;&nbsp; var SaveNewGroup = function(btnObj) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // the group name field can only have letters, numbers, spaces and underscores  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // AND it cannot start with a number  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($("#newgroupname").val() == “”) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert("\<?php xl(‘Group names cannot be blank’, ‘e’); ?\>");  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($("#newgroupname").val().match(/^(\d+|\s+)/)) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert("\<?php xl(‘Group names cannot start with numbers or spaces.’,‘e’); ?\>");  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var validname = $("#newgroupname").val().replace(//g, “\_”); // match any non-word characters and replace them  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $("#newgroupname").val(validname);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // now, check the first group field values  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // seq must be numeric and less than 999  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (! IsNumeric($("#gnewseq").val(), 0, 999)) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert("\<?php xl(‘Order must be a number between 1 and 999’,‘e’); ?\>");  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // length must be numeric and less than 999  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (! IsNumeric($("#gnewlength").val(), 0, 999)) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert("\<?php xl(‘Size must be a number between 1 and 999’,‘e’); ?\>");  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // titlecols must be numeric and less than 100  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (! IsNumeric($("#gnewtitlecols").val(), 0, 999)) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert("\<?php xl(‘LabelCols must be a number between 1 and 999’,‘e’); ?\>");  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // datacols must be numeric and less than 100  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (! IsNumeric($("#gnewdatacols").val(), 0, 999)) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert("\<?php xl(‘DataCols must be a number between 1 and 999’,‘e’); ?\>");  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // some fields cannot be blank  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($("#gnewtitle").val() == “”) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert("\<?php xl(‘Label cannot be blank’,‘e’); ?\>");  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // the id field can only have letters, numbers and underscores  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($("#gnewid").val() == “”) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert("\<?php xl(‘ID cannot be blank’, ‘e’); ?\>");  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var validid = $("#gnewid").val().replace(/(\s|\W)/g, “\_”); // match any non-word characters and replace them  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $("#gnewid").val(validid);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // similarly with the listid field  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; validid = $("#gnewlistid").val().replace(/(\s|\W)/g, “\_”);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $("#gnewlistid").val(validid);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // submit the form to add a new field to a specific group  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $("#formaction").val(“addgroup”);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $("#theform").submit();  
&nbsp;&nbsp;&nbsp; }

&nbsp;&nbsp;&nbsp; // actually delete an entire group from the database  
&nbsp;&nbsp;&nbsp; var DeleteGroup = function(btnObj) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var parts = $(btnObj).attr(“id”);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var groupname = parts.replace(/^\d+/, “”);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (confirm("\<?php xl(‘WARNING’,‘e’,’’,’ - ‘) . xl(‘This action cannot be undone.’,‘e’,’’,’\n’) . xl(‘Are you sure you wish to delete the entire group named’,‘e’,’’,’ ‘); ?\>’"+groupname+"’?")) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // submit the form to add a new field to a specific group  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $("#formaction").val(“deletegroup”);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $("#deletegroupname").val(parts);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $("#theform").submit();  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp; };

&nbsp;&nbsp;&nbsp; // just hide the new field DIV  
&nbsp;&nbsp;&nbsp; var CancelNewGroup = function(btnObj) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // hide the field details DIV  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(’#groupdetail’).css(‘visibility’, ‘hidden’);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(’#groupdetail’).css(‘display’, ‘none’);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // reset the new group values to a default  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(’#groupdetail \> #newgroupname’).val("");  
&nbsp;&nbsp;&nbsp; };

&nbsp;&nbsp;&nbsp; // display the ‘new field’ DIV  
&nbsp;&nbsp;&nbsp; var MoveGroup = function(btnObj) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var btnid = $(btnObj).attr(“id”);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var parts = btnid.split("~");  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var groupid = parts;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var direction = parts;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // submit the form to change group order  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $("#formaction").val(“movegroup”);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $("#movegroupname").val(groupid);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $("#movedirection").val(direction);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $("#theform").submit();  
&nbsp;&nbsp;&nbsp; }

&nbsp;&nbsp;&nbsp; // show the rename group DIV  
&nbsp;&nbsp;&nbsp; var RenameGroup = function(btnObj) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(’#renamegroupdetail’).css(‘visibility’, ‘visible’);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(’#renamegroupdetail’).css(‘display’, ‘block’);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(btnObj).parent().append($("#renamegroupdetail"));  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(’#renameoldgroupname’).val($(btnObj).attr(“id”));  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(’#renamegroupname’).val($(btnObj).attr(“id”).replace(/^\d+/, “”));  
&nbsp;&nbsp;&nbsp; }

&nbsp;&nbsp;&nbsp; // save the new group to the form  
&nbsp;&nbsp;&nbsp; var SaveRenameGroup = function(btnObj) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // the group name field can only have letters, numbers, spaces and underscores  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // AND it cannot start with a number  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($("#renamegroupname").val().match(/^\d+/)) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert("\<?php xl(‘Group names cannot start with numbers.’,‘e’); ?\>");  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var validname = $("#renamegroupname").val().replace(//g, “\_”); // match any non-word characters and replace them  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $("#renamegroupname").val(validname);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // submit the form to add a new field to a specific group  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $("#formaction").val(“renamegroup”);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $("#theform").submit();  
&nbsp;&nbsp;&nbsp; }

&nbsp;&nbsp;&nbsp; // just hide the new field DIV  
&nbsp;&nbsp;&nbsp; var CancelRenameGroup = function(btnObj) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // hide the field details DIV  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(’#renamegroupdetail’).css(‘visibility’, ‘hidden’);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(’#renamegroupdetail’).css(‘display’, ‘none’);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // reset the rename group values to a default  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(’#renameoldgroupname’).val("");  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(’#renamegroupname’).val("");  
&nbsp;&nbsp;&nbsp; };

&nbsp;&nbsp;&nbsp; /\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/  
&nbsp;&nbsp;&nbsp; /\*\*\*\*\*\*\*\*\*\*\*\* Field functions \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/  
&nbsp;&nbsp;&nbsp; /\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

&nbsp;&nbsp;&nbsp; // display the ‘new field’ DIV  
&nbsp;&nbsp;&nbsp; var AddField = function(btnObj) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // update the fieldgroup value to be the groupid  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var btnid = $(btnObj).attr(“id”);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var parts = btnid.split("~");  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var groupid = parts;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(’#fielddetail \> #newfieldgroupid’).attr(‘value’, groupid);  
&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // show the field details DIV  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(’#fielddetail’).css(‘visibility’, ‘visible’);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(’#fielddetail’).css(‘display’, ‘block’);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(btnObj).parent().append($("#fielddetail"));  
&nbsp;&nbsp;&nbsp; };

&nbsp;&nbsp;&nbsp; var DeleteFields = function(btnObj) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (confirm("\<?php xl(‘WARNING’,‘e’,’’,’ - ‘) . xl(‘This action cannot be undone.’,‘e’,’’,’\n’) . xl(‘Are you sure you wish to delete the selected fields?’,‘e’); ?\>")) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var delim = “”;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(".selectfield").each(function(i) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // build a list of selected field names to be moved  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($(this).attr(“checked”) == true) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var parts = this.id.split("~");  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var currval = $("#selectedfields").val();  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $("#selectedfields").val(currval+delim+parts);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; delim = " “;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; });  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // submit the form to delete the field(s)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(”#formaction").val(“deletefields”);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $("#theform").submit();  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp; };  
&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp; // save the new field to the form  
&nbsp;&nbsp;&nbsp; var SaveNewField = function(btnObj) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // check the new field values for correct formatting  
&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // seq must be numeric and less than 999  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (! IsNumeric($("#newseq").val(), 0, 999)) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert("\<?php xl(‘Order must be a number between 1 and 999’,‘e’); ?\>");  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // length must be numeric and less than 999  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (! IsNumeric($("#newlength").val(), 0, 999)) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert("\<?php xl(‘Size must be a number between 1 and 999’,‘e’); ?\>");  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // titlecols must be numeric and less than 100  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (! IsNumeric($("#newtitlecols").val(), 0, 999)) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert("\<?php xl(‘LabelCols must be a number between 1 and 999’,‘e’); ?\>");  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // datacols must be numeric and less than 100  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (! IsNumeric($("#newdatacols").val(), 0, 999)) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert("\<?php xl(‘DataCols must be a number between 1 and 999’,‘e’); ?\>");  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // some fields cannot be blank  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($("#newtitle").val() == “”) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert("\<?php xl(‘Label cannot be blank’,‘e’); ?\>");  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // the id field can only have letters, numbers and underscores  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var validid = $("#newid").val().replace(/(\s|\W)/g, “\_”); // match any non-word characters and replace them  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $("#newid").val(validid);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // similarly with the listid field  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; validid = $("#newlistid").val().replace(/(\s|\W)/g, “\_”);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $("#newlistid").val(validid);  
&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // submit the form to add a new field to a specific group  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $("#formaction").val(“addfield”);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $("#theform").submit();  
&nbsp;&nbsp;&nbsp; };  
&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp; // just hide the new field DIV  
&nbsp;&nbsp;&nbsp; var CancelNewField = function(btnObj) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // hide the field details DIV  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(’#fielddetail’).css(‘visibility’, ‘hidden’);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(’#fielddetail’).css(‘display’, ‘none’);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // reset the new field values to a default  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ResetNewFieldValues();  
&nbsp;&nbsp;&nbsp; };

&nbsp;&nbsp;&nbsp; // show the popup choice of lists  
&nbsp;&nbsp;&nbsp; var ShowLists = function(btnObj) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; window.open("./show\_lists\_popup.php", “lists”, “width=300,height=500,scrollbars=yes”);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; selectedfield = btnObj;  
&nbsp;&nbsp;&nbsp; };  
&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp; // show the popup choice of groups  
&nbsp;&nbsp;&nbsp; var ShowGroups = function(btnObj) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; window.open("./show\_groups\_popup.php?layout\_id=\<?php echo $layout\_id;?\>", “groups”, “width=300,height=300,scrollbars=yes”);  
&nbsp;&nbsp;&nbsp; };

});

function SetList(listid) { $(selectedfield).val(listid); }

/\* this is called after the user chooses a new group from the popup window  
\* it will submit the page so the selected fields can be moved into  
\* the target group  
\*/  
function MoveFields(targetgroup) {  
&nbsp;&nbsp;&nbsp; $("#targetgroup").val(targetgroup);  
&nbsp;&nbsp;&nbsp; var delim = “”;  
&nbsp;&nbsp;&nbsp; $(".selectfield").each(function(i) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // build a list of selected field names to be moved  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($(this).attr(“checked”) == true) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var parts = this.id.split("~");  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var currval = $("#selectedfields").val();  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $("#selectedfields").val(currval+delim+parts);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; delim = " “;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp; });  
&nbsp;&nbsp;&nbsp; $(”#formaction").val(“movefields”);  
&nbsp;&nbsp;&nbsp; $("#theform").submit();  
};

// set the new-field values to a default state  
function ResetNewFieldValues () {  
&nbsp;&nbsp;&nbsp; $("#newseq").val("");  
&nbsp;&nbsp;&nbsp; $("#newid").val("");  
&nbsp;&nbsp;&nbsp; $("#newtitle").val("");  
&nbsp;&nbsp;&nbsp; $("#newuor").val(1);  
&nbsp;&nbsp;&nbsp; $("#newlength").val("");  
&nbsp;&nbsp;&nbsp; $("#newdatatype").val("");  
&nbsp;&nbsp;&nbsp; $("#newlistid").val("");  
&nbsp;&nbsp;&nbsp; $("#newtitlecols").val("");  
&nbsp;&nbsp;&nbsp; $("#newdatacols").val("");  
&nbsp;&nbsp;&nbsp; $("#newdefault").val("");  
&nbsp;&nbsp;&nbsp; $("#newdesc").val("");  
}

// is value an integer and between min and max  
function IsNumeric(value, min, max) {  
&nbsp;&nbsp;&nbsp; if (value == “” || value == null) return false;  
&nbsp;&nbsp;&nbsp; if (! IsN(value) ||  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; parseInt(value) \< min ||  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; parseInt(value) \> max)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;

&nbsp;&nbsp;&nbsp; return true;  
}

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/  
/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/  
/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

// tell if num is an Integer  
function IsN(num) { return !/\D/.test(num); }  
\</script\>

\</html\>

Sherwin Gaddis  
757-328-2736  
Juggernaut Systems Express&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Open Med Practice  
[www.jse.net](http://www.jse.net)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [www.openmedpractice.com](http://www.openmedpractice.com)

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [April 21, 2011, 3:19pm UTC](https://community.open-emr.org/t/designing-new-data-type/5002/3 "2011-04-21T15:19:00Z")

</div>

**[mike-h30](https://sourceforge.net/u/mike-h30/)** wrote on [Thursday, April 21, 2011](https://sourceforge.net/p/openemr/discussion/202506/thread/1ac74486/#312f):

> The over all goal is that I am building an office note for a doctor. The final output of the note will be in paragraph form.  
> [/quote

CAMOS is the best “note building” tool in my opinion. Output can be customized any way you want in notegen.php with the use of the EZPDF class. I have customized the creation of 1 to 5 page length doctor notes to print to PDF in paragraph form with a couple of button clicks in CAMOS. In&nbsp; the past, we have actually have been denied payment due to “doctor notes not being long enough” in the opinion of insurance company personal.&nbsp; Not anymore though thanks to CAMOS.&nbsp; CAMOS also handles prescriptions although we are not using CAMOS for scripts at the moment.&nbsp; I believe CAMOS could be customized to create your doctor note, write your script, and update the medications table.&nbsp; If you haven’t looked at CAMOS, I would highly recommend it.&nbsp; Since we implemented CAMOS, documenting a patient visit takes seconds and allows our physician to focus on patient care instead of wasting time fulfilling the BS requirements of insurance companies whose staff never attended medical school yet have the audacity to dictate how a physician should practice medicine.

PS -&nbsp; Thanks Dr. Mark Leeds for creating CAMOS!!

-Mike

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [April 21, 2011, 3:28pm UTC](https://community.open-emr.org/t/designing-new-data-type/5002/4 "2011-04-21T15:28:06Z")

</div>

**[mike-h30](https://sourceforge.net/u/mike-h30/)** wrote on [Thursday, April 21, 2011](https://sourceforge.net/p/openemr/discussion/202506/thread/1ac74486/#3f4d):

Definitely need a “edit post” feature.

> The over all goal is that I am building an office note for a doctor. The final output of the note will be in paragraph form.

CAMOS is the best “note building” tool in my opinion.&nbsp; Output can be customized any way you want in notegen.php with the use of the EZPDF class.&nbsp; I have customized the creation of 1 to 5 page length doctor notes to print to PDF in paragraph form with a couple of button clicks in CAMOS.&nbsp; In&nbsp; the past, we have actually have been denied payment due to “doctor notes not being long enough” in the opinion of insurance company personal.&nbsp; Not anymore though thanks to CAMOS.&nbsp; CAMOS also handles prescriptions although we are not using CAMOS for scripts at the moment.&nbsp; I believe CAMOS could be customized to create your doctor note, write your script, and update the medications table.&nbsp; If you haven’t looked at CAMOS, I would highly recommend it.&nbsp; Since we implemented CAMOS, documenting a patient visit takes seconds and allows our physician to focus on patient care instead of wasting time fulfilling the BS requirements of insurance companies whose staff never attended medical school yet have the audacity to dictate how a physician should practice medicine.

PS -&nbsp; Thanks Dr. Mark Leeds for creating CAMOS!!

-Mike

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [April 21, 2011, 7:15pm UTC](https://community.open-emr.org/t/designing-new-data-type/5002/5 "2011-04-21T19:15:41Z")

</div>

**[yehster](https://sourceforge.net/u/yehster/)** wrote on [Thursday, April 21, 2011](https://sourceforge.net/p/openemr/discussion/202506/thread/1ac74486/#0f42):

I tried to post a response before in the forum, but something weird happened I think.  
Anyway, the error you are getting is because the function for translation is called  
xl&nbsp; (the letter x and the letter L)  
not  
x1 (the letter x and the number one)

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [April 21, 2011, 10:08pm UTC](https://community.open-emr.org/t/designing-new-data-type/5002/6 "2011-04-21T22:08:49Z")

</div>

**[juggernautsei](https://sourceforge.net/u/juggernautsei/)** wrote on [Thursday, April 21, 2011](https://sourceforge.net/p/openemr/discussion/202506/thread/1ac74486/#c5e8):

Thanks that fixed the problem with the code and got me going again.

I will look at the CAMOS and see what it does.

sherwin

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [May 30, 2011, 4:45pm UTC](https://community.open-emr.org/t/designing-new-data-type/5002/7 "2011-05-30T16:45:11Z")

</div>

**[juggernautsei](https://sourceforge.net/u/juggernautsei/)** wrote on [Monday, May 30, 2011](https://sourceforge.net/p/openemr/discussion/202506/thread/1ac74486/#4fdd):

Hi, I need help with building this new data type for the LBF in version 4 construct.

The piece of code below is from the options.inc.php file. This is the data\_type that I am trying to code.

&nbsp; // multiple-selection from list box with ability to add to it - Sherwin 2011  
&nbsp; else if ($data\_type == 34) {  
&nbsp;&nbsp;&nbsp; echo “\<select class=‘addtolistclass\_$list\_id\_esc’ name=‘form\_$field\_id\_esc’ multiple=’$multiple’ id=‘form\_$field\_id\_esc’ title=’$description’\>”;  
&nbsp;&nbsp;&nbsp; if ($showEmpty) echo “\<option value=’’\>” . htmlspecialchars( xl($empty\_title), ENT\_QUOTES) . “\</option\>”;  
&nbsp;&nbsp;&nbsp; $lres = sqlStatement(“SELECT \* FROM list\_options " .  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “WHERE list\_id = ? ORDER BY seq, title”, array($list\_id) );  
&nbsp;&nbsp;&nbsp; $got\_selected = FALSE;  
&nbsp;&nbsp;&nbsp; while ($lrow = sqlFetchArray($lres)) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $optionValue = htmlspecialchars( $lrow, ENT\_QUOTES);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo “\<option value=’$optionValue’”;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ((strlen($currvalue) == 0 && $lrow) ||  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (strlen($currvalue)&nbsp; \> 0 && $lrow == $currvalue))  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo " selected”;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $got\_selected = TRUE;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Added 5-09 by BM - Translate label if applicable  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo “\>” . htmlspecialchars( xl\_list\_label($lrow), ENT\_NOQUOTES) . “\</option\>\n”;  
&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp; if (!$got\_selected && strlen($currvalue) \> 0) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo “\<option value=’$currescaped’ selected\>\* $currescaped \*\</option\>”;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo “\</select\>”;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $fontTitle = htmlspecialchars( xl(‘Please choose a valid selection from the list.’), ENT\_NOQUOTES);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $fontText = htmlspecialchars( xl(‘Fix this’), ENT\_NOQUOTES);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo " \<font color=‘red’ title=’$fontTitle’\>$fontText!\</font\>";  
&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp; else {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo “\</select\>”;  
&nbsp;&nbsp;&nbsp; }

I am missing how to get the selected items back to the data base. I know that I need to use a FOR Each command but I don’t really know where to put it.

Could someone point me in the right direction?

Thanks!

Sherwin  
[www.openmedpractice.com](http://www.openmedpractice.com)

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [May 31, 2011, 1:31am UTC](https://community.open-emr.org/t/designing-new-data-type/5002/8 "2011-05-31T01:31:59Z")

</div>

**[tmccormi](https://sourceforge.net/u/tmccormi/)** wrote on [Tuesday, May 31, 2011](https://sourceforge.net/p/openemr/discussion/202506/thread/1ac74486/#2074):

I just had to do this for a customer, perhaps my code will help?&nbsp; [https://github.com/tmccormi/openemr/commits/LBF\_datatype\_29](https://github.com/tmccormi/openemr/commits/LBF_datatype_29)  
-Tony

> **[Medical Information Integration](http://www.mi-squared.com)**
>
> We are OpenEMR experts | HIPPA-Compliant EHR hosting, implementation & customization | Health IT & Beyond

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [May 31, 2011, 7:21pm UTC](https://community.open-emr.org/t/designing-new-data-type/5002/9 "2011-05-31T19:21:46Z")

</div>

**[juggernautsei](https://sourceforge.net/u/juggernautsei/)** wrote on [Tuesday, May 31, 2011](https://sourceforge.net/p/openemr/discussion/202506/thread/1ac74486/#6cd0):

Tony,

Thanks!&nbsp;

This will push me in a different direction. I was looking to put he foreach clause below. Defining it at the top is a better way to go. I see I have to first define a new array. Instead of just sticking in the html function. I am writing this down as I learn how to build functions and arrays. I did notice also that you said this is datatype\_29 but you have not included it in your list of data\_types yet in the edit\_layout.php file. I checked it against the orginal and only the orginal 33 are there but there is no 29. Just an observation.

Sherwin  
[www.openmedpractice.com](http://www.openmedpractice.com)

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [May 31, 2011, 7:30pm UTC](https://community.open-emr.org/t/designing-new-data-type/5002/10 "2011-05-31T19:30:30Z")

</div>

**[tmccormi](https://sourceforge.net/u/tmccormi/)** wrote on [Tuesday, May 31, 2011](https://sourceforge.net/p/openemr/discussion/202506/thread/1ac74486/#0212):

it’s there: // array of the data\_types of the fields

```
$datatypes = array(
  "1" => xl("List box"), 
  "2" => xl("Textbox"),
  "3" => xl("Textarea"),
  "4" => xl("Text-date"),
  "10" => xl("Providers"),
  "11" => xl("Providers NPI"),
  "12" => xl("Pharmacies"),
  "13" => xl("Squads"),
  "14" => xl("Organizations"),
  "15" => xl("Billing codes"),
  "21" => xl("Checkbox list"),
  "22" => xl("Textbox list"),
  "23" => xl("Exam results"),
  "24" => xl("Patient allergies"),
  "25" => xl("Checkbox w/text"),
  "26" => xl("List box w/add"),
  "27" => xl("Radio buttons"),
  "28" => xl("Lifestyle status"), // add for smoking status task
  "29" => xl("History w/Notes"), <<< ----------------------------- here
  "31" => xl("Static Text"),
  "32" => xl("Smoking Status"),
  "33" => xl("Race and Ethnicity"),
);
```

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [May 31, 2011, 8:23pm UTC](https://community.open-emr.org/t/designing-new-data-type/5002/11 "2011-05-31T20:23:22Z")

</div>

**[acmoore](https://sourceforge.net/u/acmoore/)** wrote on [Tuesday, May 31, 2011](https://sourceforge.net/p/openemr/discussion/202506/thread/1ac74486/#a65f):

Hi Tony -

I tried to look at the code that you pointed Sherwin to, but I don’t&nbsp; see in your code in github the datatype #29 that you refer to above. Here’s where I’ve looked so far:

Here’s the file off of the tip of that branch:

[https://github.com/tmccormi/openemr/blob/LBF\_datatype\_29/interface/super/edit\_layout.php](https://github.com/tmccormi/openemr/blob/LBF_datatype_29/interface/super/edit_layout.php)

It appears to me also to skip datatype #29.

This is the only commit on that branch that’s different from your master, and it doesn’t really appear relevant:  
[https://github.com/tmccormi/openemr/commit/2217e9da29b6451718f2d90d7a8447f7da9bdfba](https://github.com/tmccormi/openemr/commit/2217e9da29b6451718f2d90d7a8447f7da9bdfba)

Could you give us just a little more help to find the similar code that you’ve written, please?

Thanks for your help, Tony!

-Andy

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [May 31, 2011, 8:39pm UTC](https://community.open-emr.org/t/designing-new-data-type/5002/12 "2011-05-31T20:39:30Z")

</div>

**[tmccormi](https://sourceforge.net/u/tmccormi/)** wrote on [Tuesday, May 31, 2011](https://sourceforge.net/p/openemr/discussion/202506/thread/1ac74486/#310c):

Looks like what’s up on github is not the same as what I have in branch locally.&nbsp;&nbsp; I’ll redo the push.  
-Tony

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [May 31, 2011, 8:47pm UTC](https://community.open-emr.org/t/designing-new-data-type/5002/13 "2011-05-31T20:47:03Z")

</div>

**[tmccormi](https://sourceforge.net/u/tmccormi/)** wrote on [Tuesday, May 31, 2011](https://sourceforge.net/p/openemr/discussion/202506/thread/1ac74486/#b2d2):

Try it now.  
[https://github.com/tmccormi/openemr/commits/LBF\_datatype\_29](https://github.com/tmccormi/openemr/commits/LBF_datatype_29)  
-Tony

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [May 31, 2011, 9:05pm UTC](https://community.open-emr.org/t/designing-new-data-type/5002/14 "2011-05-31T21:05:54Z")

</div>

**[acmoore](https://sourceforge.net/u/acmoore/)** wrote on [Tuesday, May 31, 2011](https://sourceforge.net/p/openemr/discussion/202506/thread/1ac74486/#27e4):

Thanks, Tony. I see how you’re making one datatype display as several HTML elements there. That may help me out.

-Andy

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [June 1, 2011, 1:44am UTC](https://community.open-emr.org/t/designing-new-data-type/5002/15 "2011-06-01T01:44:58Z")

</div>

**[ajperezcrespo](https://sourceforge.net/u/ajperezcrespo/)** wrote on [Wednesday, June 01, 2011](https://sourceforge.net/p/openemr/discussion/202506/thread/1ac74486/#ff6f):

Hi,

&nbsp; How will this affect what happens to the history page when you move items around?&nbsp; Especially the tobacco info?  
I just tried it on the demo site.&nbsp; I moved the Relative group below Lifestyle, saved, and then moved it back.&nbsp; Now Tobacco doesnt work.

Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [June 1, 2011, 2:20am UTC](https://community.open-emr.org/t/designing-new-data-type/5002/16 "2011-06-01T02:20:26Z")

</div>

**[tmccormi](https://sourceforge.net/u/tmccormi/)** wrote on [Wednesday, June 01, 2011](https://sourceforge.net/p/openemr/discussion/202506/thread/1ac74486/#0a78):

the changes to the history\_full.php and edit\_layout.php are an example (done for a customer, not for the general release).&nbsp;&nbsp; Moving things around in the layout tool might have undesired effects.&nbsp; It is pretty limited when it comes to that.&nbsp; I usually end up resorting to direct edits in the table for anything fancy.

Some future hot programmer could make the data types be a ‘plugin’ model where you could create one and drop it into a directory without all the insane repetitious code and squirrelly if-blocks for exceptions …

-Tony

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [June 3, 2011, 3:14am UTC](https://community.open-emr.org/t/designing-new-data-type/5002/17 "2011-06-03T03:14:14Z")

</div>

**[vpsubramanian](https://sourceforge.net/u/vpsubramanian/)** wrote on [Friday, June 03, 2011](https://sourceforge.net/p/openemr/discussion/202506/thread/1ac74486/#2b13):

Hi  
I am new to openemr. I tried to make a layout based form. I got stuck in datatype. I need a LASA type data type where patient can select intensity of symptom on a line. Intensity goes from left to right on the line&nbsp; from none to maximum severity. Any help will be greatly appreciated

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [June 3, 2011, 3:15am UTC](https://community.open-emr.org/t/designing-new-data-type/5002/18 "2011-06-03T03:15:41Z")

</div>

**[vpsubramanian](https://sourceforge.net/u/vpsubramanian/)** wrote on [Friday, June 03, 2011](https://sourceforge.net/p/openemr/discussion/202506/thread/1ac74486/#7949):

Hi  
I am new to openemr. I tried to make a layout based form. I got stuck in datatype. I need a LASA type data type where patient can select intensity of symptom on a line. Intensity goes from left to right on the line&nbsp; from none to maximum severity. Any help will be greatly appreciated

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [June 3, 2011, 3:20am UTC](https://community.open-emr.org/t/designing-new-data-type/5002/19 "2011-06-03T03:20:15Z")

</div>

**[vpsubramanian](https://sourceforge.net/u/vpsubramanian/)** wrote on [Friday, June 03, 2011](https://sourceforge.net/p/openemr/discussion/202506/thread/1ac74486/#1523):

Hi  
I am new to openemr. I tried to make a layout based form. I got stuck in datatype. I need a LASA type data type where patient can select intensity of symptom on a line. Intensity goes from left to right on the line&nbsp; from none to maximum severity. Any help will be greatly appreciated

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [June 3, 2011, 3:21am UTC](https://community.open-emr.org/t/designing-new-data-type/5002/20 "2011-06-03T03:21:35Z")

</div>

**[vpsubramanian](https://sourceforge.net/u/vpsubramanian/)** wrote on [Friday, June 03, 2011](https://sourceforge.net/p/openemr/discussion/202506/thread/1ac74486/#550f):

Hi  
I am new to openemr. I tried to make a layout based form. I got stuck in datatype. I need a LASA type data type where patient can select intensity of symptom on a line. Intensity goes from left to right on the line&nbsp; from none to maximum severity. Any help will be greatly appreciated

[Next page](https://community.open-emr.org/t/designing-new-data-type/5002.md?page=2)
