Location: PHPKode > projects > XDB Money > money/USER_GROUPS_DE.php
<?php
include 'GLOBAL_HEADER.php';
include('./pnadodb/adodb.inc.php');       # load code common to ADODB
$conn = &ADONewConnection('mysql');    # create a connection
if($conn->PConnect('localhost',$login_username,$login_password,'xdbmoney')==false)
	{
	//	problem: could not connect - issue error message
	printf("<html>\n");
	printf("<head>\n");
	printf("<meta http-equiv=\"refresh\" content=\"0;URL=index2.html\">\n");
	printf("<link href=\"system.css\" rel=\"stylesheet\" type=\"text/css\" title=\"Website Style\">\n");
	printf("<body onload=\"document.location='index2.html'\">\n");
	printf("</head>\n");
	die("<br><br>Unknown username / password - please login again.<br>\n");
	printf("</body>\n");
	printf("</html>\n");
	}
// Include library code 

require_once("library.php");


FUNCTION OutputNormalHeader($global_SECURITY) {

printf("<html>");
printf("<head>");
printf("<title>User groups data entry</title>\n");

printf("<link href=\"system.css\" rel=\"stylesheet\" type=\"text/css\" title=\"Website Style\">\n");


//Javascript library code
printf("\n\n<SCRIPT LANGUAGE=\"JavaScript\">\n");
printf("// {{{ docs <-- this is a VIM (text editor) text fold\n");
printf("\n");
printf("/**\n");
printf(" * Popup Calendar v2.0.5\n");
printf(" *\n");
printf(" * Summary: Popup Calendar is a date selector script that can be associated with\n");
printf(" *          an image next to a text form element that requires a date. The calendar\n");
printf(" *          pops up, at which point a date can be selected, and it will close the\n");
printf(" *          calendar and pass the date down to the input field. It has customizable\n");
printf(" *          colors and full year/month navigation. It works on all browsers (Konqueror,\n");
printf(" *          IE, Netscape 4, Mozilla, Opera) and makes choosing dates in forms much more\n");
printf(" *          pleasant.\n");
printf(" *\n");
printf(" * Maintainer: Dan Allen <hide@address.com>\n");
printf(" *\n");
printf(" * License: LGPL - however, if you use this library, please post to my forum where you\n");
printf(" *          use it so that I get a chance to see my baby in action.  If you are doing\n");
printf(" *          this for commercial work perhaps you could send me a few Starbucks Coffee\n");
printf(" *          gift dollars to encourage future developement (NOT REQUIRED).  E-mail me\n");
printf(" *          for and address.\n");
printf(" *\n");
printf(" * Homepage: http://www.mojavelinux.com/forum/viewtopic.php?t=6\n");
printf(" *\n");
printf(" * Freshmeat Project: http://freshmeat.net/projects/popupcalendar/?topic_id=92\n");
printf(" *\n");
printf(" * Updated: 2002/11/22\n");
printf(" *\n");
printf(" * Supported Browsers: Mozilla (Gecko), IE 5+, Konqueror, Opera 7, Netscape 4\n");
printf(" *\n");
printf(" * Usage: \n");
printf(" * Bascially, you need to pay attention to the paths and make sure\n");
printf(" * that the function getCalendar is looking in the right place for calendar.html,\n");
printf(" * which is the parent frame of calendar_body.html.  \n");
printf(" * \n");
printf(" * The colors are configured as an associative array in the parent window.  I\n");
printf(" * haven't had a chance to document this yet, but you should be able to see what I\n");
printf(" * am going for in the calendar.js file.  All you have to do when calling\n");
printf(" * getCalendar is specify the full object to that form element, such as\n");
printf(" * \n");
printf(" * return getCalendar(document.formName.elementName);\n");
printf(" * \n");
printf(" * You will need to put killCalendar() in the body to make it go away if it is still open\n");
printf(" * when the page changes.\n");
printf("**/\n");
printf("\n");
printf("// }}}\n");
printf("// {{{ settings (Editable)\n");
printf("\n");
printf("var calendarWindow = null;\n");
printf("var calendarColors = new Array();\n");
printf("calendarColors['bgColor'] = '#BDC5D0';\n");
printf("calendarColors['borderColor'] = '#333366';\n");
printf("calendarColors['headerBgColor'] = '#143464';\n");
printf("calendarColors['headerColor'] = '#FFFFFF';\n");
printf("calendarColors['dateBgColor'] = '#8493A8';\n");
printf("calendarColors['dateColor'] = '#004080';\n");
printf("calendarColors['dateHoverBgColor'] = '#FFFFFF';\n");
printf("calendarColors['dateHoverColor'] = '#8493A8';\n");
printf("var calendarMonths = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');\n");
printf("var calendarWeekdays = new Array('S', 'M', 'T', 'W', 'T', 'F', 'S', 'S');\n");
printf("var calendarUseToday = true;\n");
printf("var calendarFormat = 'd/m/y';\n");
printf("var calendarStartMonday = true;\n");
printf("\n");
printf("// }}}\n");
printf("// {{{ getCalendar()\n");
printf("\n");
printf("function getCalendar(in_dateField) \n");
printf("{\n");
printf("    if (calendarWindow && !calendarWindow.closed) {\n");
printf("        alert('Calendar window already open.  Attempting focus...');\n");
printf("        try {\n");
printf("            calendarWindow.focus();\n");
printf("        }\n");
printf("        catch(e) {}\n");
printf("        \n");
printf("        return false;\n");
printf("    }\n");
printf("\n");
printf("    var cal_width = 415;\n");
printf("    var cal_height = 310;\n");
printf("\n");
printf("    // IE needs less space to make this thing\n");
printf("    if ((document.all) && (navigator.userAgent.indexOf(\"Konqueror\") == -1)) {\n");
printf("        cal_width = 410;\n");
printf("    }\n");
printf("\n");
printf("    calendarTarget = in_dateField;\n");
printf("    calendarWindow = window.open('scripts/calendar.html', 'dateSelectorPopup','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=0,dependent=no,width='+cal_width+',height='+cal_height);\n");
printf("\n");
printf("    return false;\n");
printf("}\n");
printf("\n");
printf("// }}}\n");
printf("// {{{ killCalendar()\n");
printf("\n");
printf("function killCalendar() \n");
printf("{\n");
printf("    if (calendarWindow && !calendarWindow.closed) {\n");
printf("        calendarWindow.close();\n");
printf("    }\n");
printf("}\n");
printf("\n");
printf("// }}}\n");
printf("// }}}\n");
printf("");
printf("/**");
printf("* Open form using given parameters -e.g. dialogue");
printf("*");
printf("**/");
printf("");
printf("function open_new_window(formURL, NewWindow, toolBar, locationBar, directoriesOption, statusBar, menuBar, scrollBars, resizeable, windowWidth, windowHeight) ");
printf("{");
printf("");
printf("var option = \"toolbar=\"+ toolBar ");
printf("            +\",location=\"+ locationBar ");
printf("	    +\",directories=\"+ directoriesOption ");
printf("	    +\",status=\"+ statusBar ");
printf("	    +\",menubar=\"+ menuBar ");
printf("	    +\",scrollbars=\" + scrollBars ");
printf("	    +\",resizable=\" + resizeable ");
printf("	    +\",width=\" + windowWidth ");
printf("	    +\",height=\"+ windowHeight;");
printf("");
printf("if (NewWindow==\"Y\")\n");
printf("   {\n");
printf("   var win2 = window.open(formURL, \"\",option);");
printf("   }\n");
printf("else\n");
printf("   {\n");
printf("   document.location=formURL\n");
printf("   }\n");
printf("}");
printf("</SCRIPT>\n");
printf("<script language=\"JavaScript\">\n");
printf("// Generic Form Validation\n");
printf("// Jacob Hage (hide@address.com)\n");
printf("\n");
printf("var checkObjects	= new Array();\n");
printf("var errors		= \"\";\n");
printf("var returnVal		= false;\n");
printf("var language		= new Array();\n");
printf("language[\"header\"]	= \"The following error(s) occured:\";\n");
printf("language[\"start\"]	= \"->\";\n");
printf("language[\"field\"]	= \" Field \";\n");
printf("language[\"require\"]	= \" is required\";\n");
printf("language[\"min\"]		= \" and must consist of at least \";\n");
printf("language[\"max\"]		= \" and must not contain more than \";\n");
printf("language[\"minmax\"]	= \" and no more than \";\n");
printf("language[\"chars\"]	= \" characters\";\n");
printf("language[\"num\"]		= \" and must contain a number\";\n");
printf("language[\"email\"]	= \" must contain a valid e-mail address\";\n");
printf("\n");
printf("\n");
printf("// -----------------------------------------------------------------------------\n");
printf("// define - Call this function in the beginning of the page. I.e. onLoad.\n");
printf("// n = name of the input field (Required)\n");
printf("// type= string, num, email (Required)\n");
printf("// min = the value must have at least [min] characters (Optional)\n");
printf("// max = the value must have maximum [max] characters (Optional)\n");
printf("// d = (Optional)\n");
printf("// -----------------------------------------------------------------------------\n");
printf("function define(n, type, HTMLname, min, max, d) {\n");
printf("var p;\n");
printf("var i;\n");
printf("var x;\n");
printf("if (!d) d = document;\n");
printf("if ((p=n.indexOf(\"?\"))>0&&parent.frames.length) {\n");
printf("d = parent.frames[n.substring(p+1)].document;\n");
printf("n = n.substring(0,p);\n");
printf("}\n");
printf("if (!(x = d[n]) && d.all) x = d.all[n];\n");
printf("for (i = 0; !x && i < d.forms.length; i++) {\n");
printf("x = d.forms[i][n];\n");
printf("}\n");
printf("for (i = 0; !x && d.layers && i < d.layers.length; i++) {\n");
printf("x = define(n, type, HTMLname, min, max, d.layers[i].document);\n");
printf("return x;       \n");
printf("}\n");
printf("eval(\"V_\"+n+\" = new formResult(x, type, HTMLname, min, max);\");\n");
printf("checkObjects[eval(checkObjects.length)] = eval(\"V_\"+n);\n");
printf("}\n");
printf("function formResult(form, type, HTMLname, min, max) {\n");
printf("this.form = form;\n");
printf("this.type = type;\n");
printf("this.HTMLname = HTMLname;\n");
printf("this.min  = min;\n");
printf("this.max  = max;\n");
printf("}\n");
printf("function validate() {\n");
printf("if (checkObjects.length > 0) {\n");
printf("errorObject = \"\";\n");
printf("for (i = 0; i < checkObjects.length; i++) {\n");
printf("validateObject = new Object();\n");
printf("validateObject.form = checkObjects[i].form;\n");
printf("validateObject.HTMLname = checkObjects[i].HTMLname;\n");
printf("validateObject.val = checkObjects[i].form.value;\n");
printf("validateObject.len = checkObjects[i].form.value.length;\n");
printf("validateObject.min = checkObjects[i].min;\n");
printf("validateObject.max = checkObjects[i].max;\n");
printf("validateObject.type = checkObjects[i].type;\n");
printf("if (validateObject.type == \"num\" || validateObject.type == \"string\") {\n");
printf("if ((validateObject.type == \"num\" && validateObject.len <= 0) || (validateObject.type == \"num\" && isNaN(validateObject.val))) { errors += language['start'] + language['field'] + validateObject.HTMLname + language['require'] + language['num'] + \"\\n\";\n");
printf("} else if (validateObject.min && validateObject.max && (validateObject.len < validateObject.min || validateObject.len > validateObject.max)) { errors += language['start'] + language['field'] + validateObject.HTMLname + language['require'] + language['min'] + validateObject.min + language['minmax'] + validateObject.max+language['chars'] + \"\\n\";\n");
printf("} else if (validateObject.min && !validateObject.max && (validateObject.len < validateObject.min)) { errors += language['start'] + language['field'] + validateObject.HTMLname + language['require'] + language['min'] + validateObject.min + language['chars'] + \"\\n\";\n");
printf("} else if (validateObject.max && !validateObject.min &&(validateObject.len > validateObject.max)) { errors += language['start'] + language['field'] + validateObject.HTMLname + language['require'] + language['max'] + validateObject.max + language['chars'] + \"\\n\";\n");
printf("} else if (!validateObject.min && !validateObject.max && validateObject.len <= 0) { errors += language['start'] + language['field'] + validateObject.HTMLname + language['require'] + \"\\n\";\n");
printf("   }\n");
printf("} else if(validateObject.type == \"email\") {\n");
printf("// Checking existense of \"@\" and \".\". \n");
printf("// Length of must >= 5 and the \".\" must \n");
printf("// not directly precede or follow the \"@\"\n");
printf("if ((validateObject.val.indexOf(\"@\") == -1) || (validateObject.val.charAt(0) == \".\") || (validateObject.val.charAt(0) == \"@\") || (validateObject.len < 6) || (validateObject.val.indexOf(\".\") == -1) || (validateObject.val.charAt(validateObject.val.indexOf(\"@\")+1) == \".\") || (validateObject.val.charAt(validateObject.val.indexOf(\"@\")-1) == \".\")) { errors += language['start'] + language['field'] + validateObject.HTMLname + language['email'] + \"\\n\"; }\n");
printf("      }\n");
printf("   }\n");
printf("}\n");
printf("if (errors) {\n");
printf("alert(language[\"header\"].concat(\"\\n\" + errors));\n");
printf("errors = \"\";\n");
printf("returnVal = false;\n");
printf("} else {\n");
printf("returnVal = true;\n");
printf("   }\n");
printf("}\n");
printf("</script>\n");
printf("\n");
printf("<SCRIPT LANGUAGE=\"JavaScript\">\n");
printf("<!-- Original:  Jacob Hage (hide@address.com) -->\n");
printf("<!-- Web Site:  http://www.hagedesign.dk -->\n");
printf("\n");
printf("<!-- This script and many more are available free online at -->\n");
printf("<!-- The JavaScript Source!! http://javascript.internet.com -->\n");
printf("\n");
printf("<!-- Begin\n");
printf("function init() {\n");
printf("define('group_description', 'string', 'Group Description',1,240);\n");
printf("}\n");
printf("//  End -->\n");
printf("</script>\n");
printf("<script language='JavaScript' type='text/javascript' src='scripts/richtext.js'></script>\n");

//Pull down menu bar code
printf("\n\n<SCRIPT LANGUAGE=\"JavaScript\">\n");
printf("<!-- Original:  Angus Turnbull -->\n");
printf("<!-- Web Site:  http://gusnz.cjb.net -->\n");
printf("\n");
printf("<!-- This script and many more are available free online at -->\n");
printf("<!-- The JavaScript Source!! http://javascript.internet.com -->\n");
printf("\n");
printf("<!-- Begin\n");
printf("var isDOM = (document.getElementById ? true : false); \n");
printf("var isIE4 = ((document.all && !isDOM) ? true : false);\n");
printf("var isNS4 = (document.layers ? true : false);\n");
printf("function getRef(id) {\n");
printf("if (isDOM) return document.getElementById(id);\n");
printf("if (isIE4) return document.all[id];\n");
printf("if (isNS4) return document.layers[id];\n");
printf("}\n");
printf("function getSty(id) {\n");
printf("return (isNS4 ? getRef(id) : getRef(id).style);\n");
printf("} \n");
printf("// Hide timeout.\n");
printf("var popTimer = 0;\n");
printf("// Array showing highlighted menu items.\n");
printf("var litNow = new Array();\n");
printf("function popOver(menuNum, itemNum) {\n");
printf("clearTimeout(popTimer);\n");
printf("hideAllBut(menuNum);\n");
printf("litNow = getTree(menuNum, itemNum);\n");
printf("changeCol(litNow, true);\n");
printf("targetNum = menu[menuNum][itemNum].target;\n");
printf("if (targetNum > 0) {\n");
printf("thisX = parseInt(menu[menuNum][0].ref.left) + parseInt(menu[menuNum][itemNum].ref.left);\n");
printf("thisY = parseInt(menu[menuNum][0].ref.top) + parseInt(menu[menuNum][itemNum].ref.top);\n");
printf("with (menu[targetNum][0].ref) {\n");
printf("left = parseInt(thisX + menu[targetNum][0].x);\n");
printf("top = parseInt(thisY + menu[targetNum][0].y);\n");
printf("visibility = 'visible';\n");
printf("      }\n");
printf("   }\n");
printf("}\n");
printf("function popOut(menuNum, itemNum) {\n");
printf("if ((menuNum == 0) && !menu[menuNum][itemNum].target)\n");
printf("hideAllBut(0)\n");
printf("else\n");
printf("popTimer = setTimeout('hideAllBut(0)', 500);\n");
printf("}\n");
printf("function getTree(menuNum, itemNum) {\n");
printf("\n");
printf("// Array index is the menu number. The contents are null (if that menu is not a parent)\n");
printf("// or the item number in that menu that is an ancestor (to light it up).\n");
printf("itemArray = new Array(menu.length);\n");
printf("\n");
printf("while(1) {\n");
printf("itemArray[menuNum] = itemNum;\n");
printf("// If we've reached the top of the hierarchy, return.\n");
printf("if (menuNum == 0) return itemArray;\n");
printf("itemNum = menu[menuNum][0].parentItem;\n");
printf("menuNum = menu[menuNum][0].parentMenu;\n");
printf("   }\n");
printf("}\n");
printf("\n");
printf("// Pass an array and a boolean to specify colour change, true = over colour.\n");
printf("function changeCol(changeArray, isOver) {\n");
printf("for (menuCount = 0; menuCount < changeArray.length; menuCount++) {\n");
printf("if (changeArray[menuCount]) {\n");
printf("newCol = isOver ? menu[menuCount][0].overCol : menu[menuCount][0].backCol;\n");
printf("// Change the colours of the div/layer background.\n");
printf("with (menu[menuCount][changeArray[menuCount]].ref) {\n");
printf("if (isNS4) bgColor = newCol;\n");
printf("else backgroundColor = newCol;\n");
printf("         }\n");
printf("      }\n");
printf("   }\n");
printf("}\n");
printf("function hideAllBut(menuNum) {\n");
printf("var keepMenus = getTree(menuNum, 1);\n");
printf("for (count = 0; count < menu.length; count++)\n");
printf("if (!keepMenus[count])\n");
printf("menu[count][0].ref.visibility = 'hidden';\n");
printf("changeCol(litNow, false);\n");
printf("}\n");
printf("\n");
printf("// *** MENU CONSTRUCTION FUNCTIONS ***\n");
printf("\n");
printf("function Menu(isVert, popInd, x, y, width, overCol, backCol, borderClass, textClass) {\n");
printf("// True or false - a vertical menu?\n");
printf("this.isVert = isVert;\n");
printf("// The popout indicator used (if any) for this menu.\n");
printf("this.popInd = popInd\n");
printf("// Position and size settings.\n");
printf("this.x = x;\n");
printf("this.y = y;\n");
printf("this.width = width;\n");
printf("// Colours of menu and items.\n");
printf("this.overCol = overCol;\n");
printf("this.backCol = backCol;\n");
printf("// The stylesheet class used for item borders and the text within items.\n");
printf("this.borderClass = borderClass;\n");
printf("this.textClass = textClass;\n");
printf("// Parent menu and item numbers, indexed later.\n");
printf("this.parentMenu = null;\n");
printf("this.parentItem = null;\n");
printf("// Reference to the object's style properties (set later).\n");
printf("this.ref = null;\n");
printf("}\n");
printf("\n");
printf("function Item(text, href, frame, length, spacing, target, NewWindow, toolBar, LocBar, DirBar, StatBar, MenuBar, ScrollBar, Resize, WindowWidth, WindowHeight ) {\n");
printf("this.text = text;\n");
printf("this.href = href;\n");
printf("this.frame = frame;\n");
printf("this.length = length;\n");
printf("this.spacing = spacing;\n");
printf("this.target = target;\n");
printf("this.NewWindow = NewWindow;\n");
printf("this.toolBar = toolBar;\n");
printf("this.LocBar = LocBar;\n");
printf("this.DirBar = DirBar;\n");
printf("this.StatBar = StatBar;\n");
printf("this.MenuBar = MenuBar;\n");
printf("this.ScrollBar = ScrollBar;\n");
printf("this.Resize = Resize;\n");
printf("this.WindowWidth = WindowWidth;\n");
printf("this.WindowHeight = WindowHeight;\n");
printf("// Reference to the object's style properties (set later).\n");
printf("this.ref = null;\n");
printf("}\n");
printf("\n");
printf("function writeMenus() {\n");
printf("if (!isDOM && !isIE4 && !isNS4) return;\n");
printf("\n");
printf("for (currMenu = 0; currMenu < menu.length; currMenu++) with (menu[currMenu][0]) {\n");
printf("// Variable for holding HTML for items and positions of next item.\n");
printf("var str = '', itemX = 0, itemY = 0;\n");
printf("\n");
printf("// Remember, items start from 1 in the array (0 is menu object itself, above).\n");
printf("// Also use properties of each item nested in the other with() for construction.\n");
printf("for (currItem = 1; currItem < menu[currMenu].length; currItem++) with (menu[currMenu][currItem]) {\n");
printf("var itemID = 'menu' + currMenu + 'item' + currItem;\n");
printf("\n");
printf("// The width and height of the menu item - dependent on orientation!\n");
printf("var w = (isVert ? width : length);\n");
printf("var h = (isVert ? length : width);\n");
printf("\n");
printf("// Create a div or layer text string with appropriate styles/properties.\n");
printf("// Thanks to Paul Maden (www.paulmaden.com) for helping debug this in IE4, apparently\n");
printf("// the width must be a miniumum of 3 for it to work in that browser.\n");
printf("if (isDOM || isIE4) {\n");
printf("str += '<div id=\"' + itemID + '\" style=\"position: absolute; left: ' + itemX + '; top: ' + itemY + '; width: ' + w + '; height: ' + h + '; visibility: inherit; ';\n");
printf("if (backCol) str += 'background: ' + backCol + '; ';\n");
printf("str += '\" ';\n");
printf("}\n");
printf("if (isNS4) {\n");
printf("str += '<layer id=\"' + itemID + '\" left=\"' + itemX + '\" top=\"' + itemY + '\" width=\"' +  w + '\" height=\"' + h + '\" visibility=\"inherit\" ';\n");
printf("if (backCol) str += 'bgcolor=\"' + backCol + '\" ';\n");
printf("}\n");
printf("if (borderClass) str += 'class=\"' + borderClass + '\" ';\n");
printf("\n");
printf("// Add mouseover handlers and finish div/layer.\n");
printf("str += 'onMouseOver=\"popOver(' + currMenu + ',' + currItem + ')\" onMouseOut=\"popOut(' + currMenu + ',' + currItem + ')\">';\n");
printf("\n");
printf("// Add contents of item (default: table with link inside).\n");
printf("// In IE/NS6+, add padding if there's a border to emulate NS4's layer padding.\n");
printf("// If a target frame is specified, also add that to the <a> tag.\n");
printf("\n");
printf("str += '<table width=\"' + (w - 8) + '\" border=\"0\" cellspacing=\"0\" cellpadding=\"' + (!isNS4 && borderClass ? 3 : 0) + '\"><tr><td align=\"left\" height=\"' + (h - 7) + '\">' + '<a class=\"' + textClass + '\" href=\"javascript:open_new_window(\'' + href + '\',\''+NewWindow+'\','+toolBar+','+LocBar+','+DirBar+','+StatBar+','+MenuBar+','+ScrollBar+','+Resize+','+WindowWidth+','+WindowHeight+') \"'+ (frame ? ' target=\"' + frame + '\">' : '>') + text + '</a></td>';\n");
printf("if (target > 0) {\n");
printf("\n");
printf("// Set target's parents to this menu item.\n");
printf("menu[target][0].parentMenu = currMenu;\n");
printf("menu[target][0].parentItem = currItem;\n");
printf("\n");
printf("// Add a popout indicator.\n");
printf("if (popInd) str += '<td class=\"' + textClass + '\" align=\"right\">' + popInd + '</td>';\n");
printf("}\n");
printf("str += '</tr></table>' + (isNS4 ? '</layer>' : '</div>');\n");
printf("if (isVert) itemY += length + spacing;\n");
printf("else itemX += length + spacing;\n");
printf("}\n");
printf("if (isDOM) {\n");
printf("var newDiv = document.createElement('div');\n");
printf("document.getElementsByTagName('body').item(0).appendChild(newDiv);\n");
printf("newDiv.innerHTML = str;\n");
printf("ref = newDiv.style;\n");
printf("ref.position = 'absolute';\n");
printf("ref.visibility = 'hidden';\n");
printf("}\n");
printf("\n");
printf("// Insert a div tag to the end of the BODY with menu HTML in place for IE4.\n");
printf("if (isIE4) {\n");
printf("document.body.insertAdjacentHTML('beforeEnd', '<div id=\"menu' + currMenu + 'div\" ' + 'style=\"position: absolute; visibility: hidden\">' + str + '</div>');\n");
printf("ref = getSty('menu' + currMenu + 'div');\n");
printf("}\n");
printf("\n");
printf("// In NS4, create a reference to a new layer and write the items to it.\n");
printf("if (isNS4) {\n");
printf("ref = new Layer(0);\n");
printf("ref.document.write(str);\n");
printf("ref.document.close();\n");
printf("}\n");
printf("\n");
printf("for (currItem = 1; currItem < menu[currMenu].length; currItem++) {\n");
printf("itemName = 'menu' + currMenu + 'item' + currItem;\n");
printf("if (isDOM || isIE4) menu[currMenu][currItem].ref = getSty(itemName);\n");
printf("if (isNS4) menu[currMenu][currItem].ref = ref.document[itemName];\n");
printf("   }\n");
printf("}\n");
printf("with(menu[0][0]) {\n");
printf("ref.left = x;\n");
printf("ref.top = y;\n");
printf("ref.visibility = 'visible';\n");
printf("   }\n");
printf("}\n");
printf("\n");
printf("// Syntaxes: *** START EDITING HERE, READ THIS SECTION CAREFULLY! ***\n");
printf("//\n");
printf("// menu[menuNumber][0] = new Menu(Vertical menu? (true/false), 'popout indicator', left, top,\n");
printf("// width, 'mouseover colour', 'background colour', 'border stylesheet', 'text stylesheet');\n");
printf("//\n");
printf("// Left and Top are measured on-the-fly relative to the top-left corner of its trigger, or\n");
printf("// for the root menu, the top-left corner of the page.\n");
printf("//\n");
printf("// menu[menuNumber][itemNumber] = new Item('Text', 'URL', 'target frame', length of menu item,\n");
printf("//  additional spacing to next menu item, number of target menu to popout);\n");
printf("//\n");
printf("// If no target menu (popout) is desired, set it to 0. Likewise, if your site does not use\n");
printf("// frames, pass an empty string as a frame target.\n");
printf("//\n");
printf("// Something that needs explaining - the Vertical Menu setup. You can see most menus below\n");
printf("// are 'true', that is they are vertical, except for the first root menu. The 'length' and\n");
printf("// 'width' of an item depends on its orientation -- length is how long the item runs for in\n");
printf("// the direction of the menu, and width is the lateral dimension of the menu. Just look at\n");
printf("// the examples and tweak the numbers, they'll make sense eventually :).\n");
printf("\n");
printf("var menu = new Array();\n");
printf("\n");
printf("// Default colours passed to most menu constructors (just passed to functions, not\n");
printf("// a global variable - makes things easier to change later in bulk).\n");
printf("var defOver = '#336699', defBack = '#003366';\n");
printf("\n");
printf("// Default 'length' of menu items - item height if menu is vertical, width if horizontal.\n");
printf("var defLength = 22;\n");
printf("\n");
printf("// Menu 0 is the special, 'root' menu from which everything else arises.\n");
printf("// A non-vertical menu with a few different colours and no popout indicator, as an example.\n");
printf("// *** MOVE ROOT MENU AROUND HERE ***  it's positioned at (5, 0) and is 17px high now.\n");
printf("// Notice how the targets are all set to nonzero values...\n");
printf("// The 'length' of each of these items is 40, and there is spacing of 10 to the next item.\n");
printf("// Most of the links are set to '#' hashes, make sure you change them to actual files.\n");
printf("menu[0] = new Array();\n");
printf("menu[0][0] = new Menu(false, '', 5, 0, 17, '#669999', '#006666', '', 'itemText');\n");
printf("menu[0][1] = new Item('&nbsp; Money Management', '#', '', 180, 10, 1,'N',0,0,0,0,0,0,0,0,0);\n");
printf("menu[0][2] = new Item('&nbsp; Security', '#', '', 100, 10, 2,'N',0,0,0,0,0,0,0,0,0);\n");
printf("menu[0][3] = new Item('&nbsp; Help', '#', '', 60, 10, 3,'N',0,0,0,0,0,0,0,0,0);\n");
printf("menu[1] = new Array();\n");
$MenuItemNum=0;
printf("menu[1][0] = new Menu(true, '&gt;', 0,22, 154, defOver, defBack, 'itemBorder', 'itemText');\n");
if ($global_SECURITY['accounts']==1)
     {
     // User is allowed access
     $MenuItemNum=$MenuItemNum+1;
     printf("menu[1][$MenuItemNum] = new Item('Accounts', 'accounts.php', '', defLength, 0, 0,'Y',0,0,0,1,1,1,1,800,600);\n");
     }
if ($global_SECURITY['super_categories']==1)
     {
     // User is allowed access
     $MenuItemNum=$MenuItemNum+1;
     printf("menu[1][$MenuItemNum] = new Item('Super&nbsp;Categories', 'super_categories.php', '', defLength, 0, 0,'N',0,0,0,0,0,0,0,700,500);\n");
     }
if ($global_SECURITY['categories']==1)
     {
     // User is allowed access
     $MenuItemNum=$MenuItemNum+1;
     printf("menu[1][$MenuItemNum] = new Item('Categories', 'categories.php', '', defLength, 0, 0,'N',0,0,0,0,0,0,0,700,500);\n");
     }
if ($global_SECURITY['scheduled_transactions']==1)
     {
     // User is allowed access
     $MenuItemNum=$MenuItemNum+1;
     printf("menu[1][$MenuItemNum] = new Item('Scheduled&nbsp;transactions', 'scheduled_transactions.php', '', defLength, 0, 0,'N',0,0,0,0,0,0,0,700,500);\n");
     }
printf("menu[2] = new Array();\n");
$MenuItemNum=0;
printf("menu[2][0] = new Menu(true, '&gt;', 0,22, 112, defOver, defBack, 'itemBorder', 'itemText');\n");
if ($global_SECURITY['passw_ch']==1)
     {
     // User is allowed access
     $MenuItemNum=$MenuItemNum+1;
     printf("menu[2][$MenuItemNum] = new Item('Change&nbsp;password', 'passw_ch.php', '', defLength, 0, 0,'N',0,0,0,0,0,0,0,0,0);\n");
     }
if ($global_SECURITY['add_user']==1)
     {
     // User is allowed access
     $MenuItemNum=$MenuItemNum+1;
     printf("menu[2][$MenuItemNum] = new Item('Add&nbsp;new&nbsp;user', 'add_user.php', '', defLength, 0, 0,'N',0,0,0,0,0,0,0,0,0);\n");
     }
if ($global_SECURITY['remove_user']==1)
     {
     // User is allowed access
     $MenuItemNum=$MenuItemNum+1;
     printf("menu[2][$MenuItemNum] = new Item('Remove&nbsp;user', 'remove_user.php', '', defLength, 0, 0,'N',0,0,0,0,0,0,0,0,0);\n");
     }
if ($global_SECURITY['USERS']==1)
     {
     // User is allowed access
     $MenuItemNum=$MenuItemNum+1;
     printf("menu[2][$MenuItemNum] = new Item('Users', 'USERS.php', '', defLength, 0, 0,'N',0,0,0,0,0,0,0,0,0);\n");
     }
if ($global_SECURITY['USER_GROUPS']==1)
     {
     // User is allowed access
     $MenuItemNum=$MenuItemNum+1;
     printf("menu[2][$MenuItemNum] = new Item('User&nbsp;Groups', 'USER_GROUPS.php', '', defLength, 0, 0,'N',0,0,0,0,0,0,0,0,0);\n");
     }
if ($global_SECURITY['USER_MEMBERSHIPS']==1)
     {
     // User is allowed access
     $MenuItemNum=$MenuItemNum+1;
     printf("menu[2][$MenuItemNum] = new Item('User&nbsp;Memberships', 'USER_MEMBERSHIPS.php', '', defLength, 0, 0,'N',0,0,0,0,0,0,0,0,0);\n");
     }
if ($global_SECURITY['USER_RESTRICTED']==1)
     {
     // User is allowed access
     $MenuItemNum=$MenuItemNum+1;
     printf("menu[2][$MenuItemNum] = new Item('Forms&nbsp;Access', 'USER_RESTRICTED.php', '', defLength, 0, 0,'N',0,0,0,0,0,0,0,0,0);\n");
     }
printf("menu[3] = new Array();\n");
$MenuItemNum=0;
printf("menu[3][0] = new Menu(true, '&gt;', 0,22, 238, defOver, defBack, 'itemBorder', 'itemText');\n");
if ($global_SECURITY['set_global_pref']==1)
     {
     // User is allowed access
     $MenuItemNum=$MenuItemNum+1;
     printf("menu[3][$MenuItemNum] = new Item('Global&nbsp;preferences&nbsp;for&nbsp;application', 'set_global_pref.php', '', defLength, 0, 0,'N',0,0,0,0,0,0,0,0,0);\n");
     }
if ($global_SECURITY['set_user_pref']==1)
     {
     // User is allowed access
     $MenuItemNum=$MenuItemNum+1;
     printf("menu[3][$MenuItemNum] = new Item('User&nbsp;preferences', 'set_user_pref.php', '', defLength, 0, 0,'N',0,0,0,0,0,0,0,0,0);\n");
     }
if ($global_SECURITY['about_form']==1)
     {
     // User is allowed access
     $MenuItemNum=$MenuItemNum+1;
     printf("menu[3][$MenuItemNum] = new Item('About', 'about_form.php', '', defLength, 0, 0,'Y',0,0,0,0,0,0,0,400,400);\n");
     }
printf("\n");
printf("\n");
printf("// *** OPTIONAL CODE FROM HERE DOWN ***\n");
printf("\n");
printf("// These two lines handle the window resize bug in NS4. See <body onResize=\"...\">.\n");
printf("// I recommend you leave this here as otherwise when you resize NS4's width menus are hidden.\n");
printf("\n");
printf("var popOldWidth = window.innerWidth;\n");
printf("nsResizeHandler = new Function('if (popOldWidth != window.innerWidth) location.reload()');\n");
printf("\n");
printf("\n");
printf("// This is a quick snippet that captures all clicks on the document and hides the menus\n");
printf("// every time you click. Use if you want.\n");
printf("\n");
printf("if (isNS4) document.captureEvents(Event.CLICK);\n");
printf("document.onclick = clickHandle;\n");
printf("\n");
printf("function clickHandle(evt)\n");
printf("{\n");
printf(" if (isNS4) document.routeEvent(evt);\n");
printf(" hideAllBut(0);\n");
printf("}\n");
printf("\n");
printf("\n");
printf("// This is just the moving command for the example.\n");
printf("\n");
printf("function moveRoot()\n");
printf("{\n");
printf(" with(menu[0][0].ref) left = ((parseInt(left) < 100) ? 100 : 5);\n");
printf("}\n");
printf("//  End -->\n");
printf("</script>\n");
printf("\n");
printf("<!-- *** IMPORTANT STYLESHEET SECTION - Change the border classes and text colours *** -->\n");
printf("<style>\n");
printf("<!--\n");
printf("\n");
printf(".itemBorder { border: 1px solid black }\n");
printf(".itemText { text-decoration: none; color: #FFFFFF; font: 12px Arial, Helvetica }\n");
printf("\n");
printf(".crazyBorder { border: 2px outset #663399 }\n");
printf(".crazyText { text-decoration: none; color: #FFCC99; font: Bold 12px Arial, Helvetica }\n");
printf("\n");
printf("-->\n");
printf("</style>\n");
printf("\n");
printf("</HEAD>\n");
printf("\n");
printf("<BODY marginwidth=\"0\" marginheight=\"0\" style=\"margin: 0\" BGCOLOR=#ffffff vlink=#0000ff onLoad=\"writeMenus(); init();\" onResize=\"if (isNS4) nsResizeHandler()\">\n");
printf("<!-- It's important that you position the menu over a background, like a table/image -->\n");
printf("<table bgcolor=\"#006666\" width=\"100%%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n");
printf("<tr><td height=\"17\"><font size=\"1\">&nbsp;</font></td></tr></table>\n");
printf("\n</head>\n");


}   // END OF OutputNormalHeader



FUNCTION DisplayErrorMessage($V_Error_Message) {

printf("<table width='100%%' border='2'><tr><td bgcolor='red'>");
printf("<font color='white'>%s</font>",$V_Error_Message);
printf("</td></tr></table><br>");


}   // END OF DisplayErrorMessage




FUNCTION DisplayPage($conn, $global_pk, $global_context, $ParamArray,$qf, $qf_SWITCH, $HTTP_POST_VARS, $global_SECURITY, $SysPreferences) {

printf("<table border=\"1\" width=\"100%%\">");
printf("<tbody>");
printf("<tr>");
printf("<td valign=\"top\" width=\"150\" bgcolor=\"#ffffff\">");
printf("<table border=\"1\" width=\"150\">");
printf("<tbody>");
printf("<tr align=\"center\">");
printf("<td bgcolor=\"#9999ff\">");
       SideBar( &$global_SECURITY );		//	Output the sidebar menu
printf("</td>");
printf("</tr>");
printf("</tbody>");
printf("</table>");
printf("</td>");
printf("<td valign=\"top\">");
printf("<table width=\"100%%\" border=\"0\">");
printf("<tbody>");
printf("<tr>");
printf("<td>");
printf("<table width=\"100%%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" valign=\"top\">");
printf("<tbody>");
printf("<tr>");
printf("<td>");
       DisplayTabs(&$global_SECURITY);			//	Display the tabs at the top of the screen
printf("</td>");
printf("<td style=\"text-align: right;\" width=\"10%%\">");
printf("<span style=\"font-style: italic;\">");
printf("<span style=\"font-weight: bold;\">");
printf("XDB</span>");
printf("</span>");
printf("</td>");
printf("</tr>");
printf("</tbody>");
printf("</table>");
printf("  </td>");
printf("</tr>");
printf("</tbody>");
printf("</table>");
printf("<table width=\"100%%\" border=\"1\">");
printf("<tbody>");
printf("<tr>");
printf("<td>");
printf("<font size=\"1\">");
printf("<span style=\"font-family: arial,helvetica,sans-serif;\">");
printf("<table width=\"100%%\" border=\"0\">");
printf("<tbody>");
printf("<tr>");
printf("<td>");
printf("<font size=\"1\">");
printf("<span style=\"font-family: arial,helvetica,sans-serif;\">");
       OutputContext(&$conn,&$ParamArray);		//	Display the context i.e. what records have been selected so far
printf("</span>");
printf("</font>");
printf("</td>");
printf("<td style=\"text-align: right; font-family: ARIAL,HELVETICA,SANS-SERIF;\" width=\"20%%\">");
printf("<font size=\"1\">");
       printf("<a href='logout.php'>Logout</a>");		//	Display the context i.e. what records have been selected so far
printf("</font>");
printf("</td>");
printf("</tr>");
printf("</tbody>");
printf("</table>");
printf("</span>");
printf("</font>");
printf("</td>");
printf("</tr>");
printf("</tbody>");
printf("</table>");
       FormBody(&$conn, &$global_pk, &$global_context, &$ParamArray,&$qf, &$qf_SWITCH, &$HTTP_POST_VARS, &$global_SECURITY, &$SysPreferences );			//	Display the body of the page
printf("  </td>");
printf("</tr>");
printf("</tbody>");
printf("</table>");
printf("<br>");


}   // END OF DisplayPage



FUNCTION SideBar( $global_SECURITY ) {

printf("<br>");
if ($global_SECURITY['accounts']==1)
     {
     // User is allowed access
     printf("<a href='accounts.php'><img src='images/kartei.gif' border=0 class='menu'><br><p class='sidebartext'>Accounts</p></a><br>");
     }
if ($global_SECURITY['super_categories']==1)
     {
     // User is allowed access
     printf("<a href='super_categories.php'><img src='images/lin_FileManager.gif' border=0 class='menu'><br><p class='sidebartext'>Super Categories</p></a><br>");
     }
if ($global_SECURITY['categories']==1)
     {
     // User is allowed access
     printf("<a href='categories.php'><img src='images/lin_Folders.gif' border=0 class='menu'><br><p class='sidebartext'>Categories</p></a><br>");
     }
if ($global_SECURITY['scheduled_transactions']==1)
     {
     // User is allowed access
     printf("<a href='scheduled_transactions.php'><img src='images/lin_karm.gif' border=0 class='menu'><br><p class='sidebartext'>Scheduled transactions</p></a><br>");
     }


}    // END OF SideBar 



FUNCTION DisplayTabs($global_SECURITY) {

printf("<table width='100%%' border='0' cellpadding='0' cellspacing='0'>\n");
printf("<tr>\n");
if ($global_SECURITY['USER_GROUPS']==1)
     {
     // User is allowed access
     printf("<td align=\"left\" width=\"1%%\">\n");
     printf("<table border='0' cellpadding='0' cellspacing='0'>\n");
     printf("<tbody>\n");
     printf("<tr>\n");
     printf("<td align=\"left\" >\n");
     printf("<img src=\"images/leftselect.gif\"></td>\n");
     printf("<td align=\"left\" height=\"0\" background=\"images/select.gif\">\n");
     printf("<a href=\"USER_GROUPS.php\" ><p class='tabtext'>User&nbsp;groups</p></a>\n");
     printf("</td>\n");
     printf("<td align=\"left\">\n");
     printf("<img src=\"images/rightselect.gif\"></td>\n");
     printf("</tr>\n");
     printf("</table>\n");
     }
printf("<td align=\"left\" width=\"100%%\">\n");
printf("&nbsp\n");
printf("</td>\n");
printf("</tr>\n");
printf("</table>\n");


}     // END OF DisplayTabs



FUNCTION OutputContext($conn,$ParamArray) {


global $global_context;

$recordSet=$conn->Execute("select group_id from xdbmoney.USER_GROUPS where group_id=".$ParamArray['group_id']);
$global_context['USER_GROUPS']=$recordSet->fields[0];
unset ($recordSet);
printf("Context:\n");
if ($global_context['USER_GROUPS']=="" || $global_context['USER_GROUPS']==NULL)
{
$DoNothing=1;
}
else
{
printf("&nbsp ".$global_context['USER_GROUPS']."\n");
}
if ($global_context['USERS']=="" || $global_context['USERS']==NULL)
{
$DoNothing=1;
}
else
{
printf("&nbsp ".$global_context['USERS']."\n");
}
if ($global_context['USER_MEMBERSHIPS']=="" || $global_context['USER_MEMBERSHIPS']==NULL)
{
$DoNothing=1;
}
else
{
printf("&nbsp ".$global_context['USER_MEMBERSHIPS']."\n");
}
if ($global_context['super_categories']=="" || $global_context['super_categories']==NULL)
{
$DoNothing=1;
}
else
{
printf("&nbsp ".$global_context['super_categories']."\n");
}
if ($global_context['categories']=="" || $global_context['categories']==NULL)
{
$DoNothing=1;
}
else
{
printf("&nbsp ".$global_context['categories']."\n");
}
if ($global_context['balance_transactions']=="" || $global_context['balance_transactions']==NULL)
{
$DoNothing=1;
}
else
{
printf("&nbsp ".$global_context['balance_transactions']."\n");
}
if ($global_context['accounts']=="" || $global_context['accounts']==NULL)
{
$DoNothing=1;
}
else
{
printf("&nbsp ".$global_context['accounts']."\n");
}
if ($global_context['vw_transactions_by_month']=="" || $global_context['vw_transactions_by_month']==NULL)
{
$DoNothing=1;
}
else
{
printf("&nbsp ".$global_context['vw_transactions_by_month']."\n");
}
if ($global_context['vw_transactions_by_day']=="" || $global_context['vw_transactions_by_day']==NULL)
{
$DoNothing=1;
}
else
{
printf("&nbsp ".$global_context['vw_transactions_by_day']."\n");
}
if ($global_context['vw_total_transactions_month']=="" || $global_context['vw_total_transactions_month']==NULL)
{
$DoNothing=1;
}
else
{
printf("&nbsp ".$global_context['vw_total_transactions_month']."\n");
}
if ($global_context['vw_account_categories_by_month']=="" || $global_context['vw_account_categories_by_month']==NULL)
{
$DoNothing=1;
}
else
{
printf("&nbsp ".$global_context['vw_account_categories_by_month']."\n");
}
if ($global_context['vw_acc_supercat_by_month']=="" || $global_context['vw_acc_supercat_by_month']==NULL)
{
$DoNothing=1;
}
else
{
printf("&nbsp ".$global_context['vw_acc_supercat_by_month']."\n");
}
if ($global_context['vw_total_supercat_month']=="" || $global_context['vw_total_supercat_month']==NULL)
{
$DoNothing=1;
}
else
{
printf("&nbsp ".$global_context['vw_total_supercat_month']."\n");
}
if ($global_context['vw_total_categories_month']=="" || $global_context['vw_total_categories_month']==NULL)
{
$DoNothing=1;
}
else
{
printf("&nbsp ".$global_context['vw_total_categories_month']."\n");
}
if ($global_context['application_version']=="" || $global_context['application_version']==NULL)
{
$DoNothing=1;
}
else
{
printf("&nbsp ".$global_context['application_version']."\n");
}
if ($global_context['scheduled_transactions']=="" || $global_context['scheduled_transactions']==NULL)
{
$DoNothing=1;
}
else
{
printf("&nbsp ".$global_context['scheduled_transactions']."\n");
}
if ($global_context['USER_RESTRICTED_ACCESS']=="" || $global_context['USER_RESTRICTED_ACCESS']==NULL)
{
$DoNothing=1;
}
else
{
printf("&nbsp ".$global_context['USER_RESTRICTED_ACCESS']."\n");
}
if ($global_context['preference_registry']=="" || $global_context['preference_registry']==NULL)
{
$DoNothing=1;
}
else
{
printf("&nbsp ".$global_context['preference_registry']."\n");
}
if ($global_context['upload_temp_table']=="" || $global_context['upload_temp_table']==NULL)
{
$DoNothing=1;
}
else
{
printf("&nbsp ".$global_context['upload_temp_table']."\n");
}
if ($global_context['upload_files']=="" || $global_context['upload_files']==NULL)
{
$DoNothing=1;
}
else
{
printf("&nbsp ".$global_context['upload_files']."\n");
}
if ($global_context['budget']=="" || $global_context['budget']==NULL)
{
$DoNothing=1;
}
else
{
printf("&nbsp ".$global_context['budget']."\n");
}


}     // END OF OutputContext



FUNCTION FormBody( $conn, $global_pk, $global_context, $ParamArray, $qf, $qf_SWITCH, $HTTP_POST_VARS, $global_SECURITY, $SysPreferences) {


// - Block start - data entry form

printf("\n<p class='top_main_title'></p>\n");
if( $ParamArray['FormAction']=='INSERT') 
   {
   $ScreenAction=sprintf("Inserting...\n");
   $m_field['group_id'] = $ParamArray['group_id'];
   $m_field['group_description'] = "";
   }
else
   {
    if( $ParamArray['FormAction']=='EDIT') 
        {
        $ScreenAction=sprintf("Editing...\n");
        }
    else 
        {
        $ScreenAction=sprintf("Viewing...\n");
       }
    if(strlen($ParamArray['group_id'])>0)
       {
       $global_pk['USER_GROUPS']=$ParamArray['group_id'];
       }
    $recordSet = $conn->Execute("select group_id,group_description from xdbmoney.USER_GROUPS   where group_id=".$global_pk['USER_GROUPS']."   order by group_id");    //group_id
   $m_field['group_id'] = $recordSet->fields['group_id'];
   //group_description
   $m_field['group_description'] = $recordSet->fields['group_description'];
   //
   $m_field[''] = $recordSet->fields[''];
   }
printf("%s<br>",$ScreenAction);
printf ("\n<form name='USER_GROUPS_DE' action='USER_GROUPS_DE.php?FormAction=COMMIT' method='post'>");
printf ("\n<table width='100%%'>");
// group_id
printf ("<input type='hidden' name='group_id' size='50' maxlength='200' value='%s'><br>",$m_field['group_id']);
// group_description
printf ("\n<tr>");
printf ("\n<td width='30%%'>");
printf ("\nGroup Description:");
printf ("\n</td>");
printf ("\n<td width='70%%'>");
if( $ParamArray['FormAction']=='EDIT' ||$ParamArray['FormAction']=='INSERT') 
    {
     printf ("<input type='text' name='group_description'  size='50'   size='240'  value='%s'>",$m_field['group_description']);
    }
ELSE
    {
     printf ("<p class=\"displayValue\">%s</>",nl2br(htmlspecialchars($m_field['group_description'])));
    }
printf ("\n</td>");
printf ("\n</tr>");
printf ("\n</table>");
if( $ParamArray['FormAction']=='EDIT' ||$ParamArray['FormAction']=='INSERT') 
    {
    if ($ParamArray['FormAction']=='INSERT')
        {
        printf ("\n<input type='submit' name='op' value='Insert' onclick='validate();return returnVal;'></form>");
        }
    else
        {
        printf ("\n<input type='submit' name='op' value='Change' onclick='validate();return returnVal;'> &nbsp");
        printf ("\n<input type='submit' name='op' value='Delete this record'></form>");
        }
    }
else
    {
if ($global_SECURITY['USER_GROUPS_DE']==1)
     {
     // User is allowed access
      printf ("<a href='./USER_GROUPS_DE.php?group_id=".$m_field['group_id']."&FormAction=EDIT'>Edit this record</a>\n");
     }
    }
printf ("\n</form>");

$conn->Close(); # optional


}      // END OF FormBody 



FUNCTION CommitData( $conn, $HTTP_POST_VARS ) {

// Check - can delete? 
if ( $HTTP_POST_VARS['op']!='Insert' && $HTTP_POST_VARS['op']!='Change')
        	{
        	$DeleteCount=0;
        	if($DeleteCount>0)
        	     {
        	     /* delete not possible - subordinate records exist */ 
        	     return "BAD";
        	     }
        	}
printf("<head>\n");
printf("<meta http-equiv=\"refresh\" content=\"0;URL=USER_GROUPS.php\">\n");
printf("<LINK REL='stylesheet' HREF='./system.css' TYPE='text/css'>\n");
printf("</head>\n");
printf("<body onload=\"document.location='USER_GROUPS.php'\">\n");
$m_field['group_id']=$HTTP_POST_VARS['group_id'];
$m_field['group_description']=$HTTP_POST_VARS['group_description'];
if ($HTTP_POST_VARS['op']=='Insert')
        {
        $result = $conn->Execute ("insert into xdbmoney.USER_GROUPS (group_id,group_description) 
    values( '0','".$m_field['group_description']."')");

        $result = $conn->Execute ("commit");

        }
else
        {
        if ($HTTP_POST_VARS['op']=='Change')
        	{

        	$result = $conn->Execute ("UPDATE xdbmoney.USER_GROUPS set 
         	group_id='".$m_field['group_id']."',
         	group_description='".$m_field['group_description']."'
        	where group_id='".$HTTP_POST_VARS['group_id']."'");
        	$result = $conn->Execute ("commit");

        	}
        else
        	{
        	$DeleteCount=0;
        	if($DeleteCount==0)
        	     {
        	     $result = $conn->Execute ("DELETE from xdbmoney.USER_GROUPS 
        	     where group_id='".$HTTP_POST_VARS['group_id']."'");
        	     $result = $conn->Execute ("commit");
        	     }
        	 else
        	     {
        	     /* delete not possible - subordinate records exist */ 
        	     }
        	}
        }


$conn->Close(); # optional
return("ok"); # Tell main form all is ok


}     // END OF CommitData



FUNCTION SideBarEnd() {


printf("</td>\n");

printf("</tr>\n");

printf("</table>\n");


}     //  END OF SideBarEnd



function RTESafe($strText) {


//returns safe code for preloading in the RTE

$tmpString = trim($strText);

//convert all types of single quotes

$tmpString = str_replace(chr(145), chr(39), $tmpString);

$tmpString = str_replace(chr(146), chr(39), $tmpString);

$tmpString = str_replace("'", "&#39;", $tmpString);

//convert all types of double quotes

$tmpString = str_replace(chr(147), chr(34), $tmpString);

$tmpString = str_replace(chr(148), chr(34), $tmpString);

//	$tmpString = str_replace("\"", "\"", $tmpString);

//replace carriage returns & line feeds

$tmpString = str_replace(chr(10), " ", $tmpString);

$tmpString = str_replace(chr(13), " ", $tmpString);

return $tmpString;

}




FUNCTION GenerateParameterSplit( $argv, $ParamArray) {

$StrPtr=0;
$StringStatus="V";
$ParamName="";
$ParamVal="";


for ( $StrPtr=0; $StrPtr <= strlen($argv[0]); $StrPtr++ )
        {


        $Char=substr($argv[0],$StrPtr,1);


        if( $StringStatus=="V" && $Char=="=" )
                {
                //      End of variable name
                $StringStatus="S";
                $StrPtr++;
                $Char=substr($argv[0],$StrPtr,1);
                }


        if( $StringStatus=="V" )
                {
                $ParamName=$ParamName.$Char;
                }


        if( $StringStatus=="S" && ( $Char=="&" || $StrPtr +1 > strlen( $argv[0] )))
                {
                //      End of parameter - add it.
                $ParamArray[$ParamName]=$ParamVal;
                $ParamName="";
                $ParamVal="";
                $StringStatus="V";
                }


        if( $StringStatus=="S" )
                {
                $ParamVal=$ParamVal.$Char;
                }


        }


}     //  END OF GenerateParameterSplit




//  Main form logic to tie all functions together.$ParamArray=array();		//	Create array to hold parameters to page
$ParamArray=$HTTP_GET_VARS;		//	Split the input parameters into array 
$ResultCode="UNUSED";

if( $ParamArray['FormAction']=='COMMIT')
	{
	$ResultCode=CommitData( &$conn, &$HTTP_POST_VARS );
	}
if( $ResultCode=="BAD" || $ResultCode=="UNUSED" )
	{

       ReadPreferences( &$conn, &$global_pk, &$global_context, &$ParamArray,&$qf, &$qf_SWITCH, &$HTTP_POST_VARS, &$global_SECURITY, &$SysPreferences);	//	Get user preferences.

       OutputNormalHeader(&$global_SECURITY);	//	Output the pull down menus etc.

       if( $ResultCode=="BAD") 

            {

            DisplayErrorMessage("Delete not possible - records are connected.");	//	Display page elements

            $ParamArray['group_id']=$HTTP_POST_VARS['group_id'];

            $ParamArray['FormAction']='VIEW';

            }

       DisplayPage(&$conn, &$global_pk, &$global_context, &$ParamArray,&$qf, &$qf_SWITCH, &$HTTP_POST_VARS, &$global_SECURITY, &$SysPreferences);   //      Display page elements
	}

?>

</div>
</html>
Return current item: XDB Money