Location: PHPKode > projects > XDB Money > money/graph_daytotal_transactions.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>Day Credits vs Debits</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");

//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; Account Reports and Utilities', '#', '', 310, 10, 2,'N',0,0,0,0,0,0,0,0,0);\n");
printf("menu[0][3] = new Item('&nbsp; Security', '#', '', 100, 10, 3,'N',0,0,0,0,0,0,0,0,0);\n");
printf("menu[0][4] = new Item('&nbsp; Help', '#', '', 60, 10, 4,'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, 294, defOver, defBack, 'itemBorder', 'itemText');\n");
if ($global_SECURITY['monthtotal_transactions']==1)
     {
     // User is allowed access
     $MenuItemNum=$MenuItemNum+1;
     printf("menu[2][$MenuItemNum] = new Item('Credit&nbsp;/&nbsp;Debits&nbsp;by&nbsp;Month', 'monthtotal_transactions.php', '', defLength, 0, 0,'N',0,0,0,0,0,0,0,700,500);\n");
     }
if ($global_SECURITY['daytotal_transactions']==1)
     {
     // User is allowed access
     $MenuItemNum=$MenuItemNum+1;
     printf("menu[2][$MenuItemNum] = new Item('Credit&nbsp;/&nbsp;Debits&nbsp;by&nbsp;Day', 'daytotal_transactions.php', '', defLength, 0, 0,'N',0,0,0,0,0,0,0,700,500);\n");
     }
if ($global_SECURITY['monthtotal_categories']==1)
     {
     // User is allowed access
     $MenuItemNum=$MenuItemNum+1;
     printf("menu[2][$MenuItemNum] = new Item('Credit&nbsp;/&nbsp;Debits&nbsp;by&nbsp;Category&nbsp;by&nbsp;Month', 'monthtotal_categories.php', '', defLength, 0, 0,'N',0,0,0,0,0,0,0,700,500);\n");
     }
if ($global_SECURITY['monthtotal_supercategories']==1)
     {
     // User is allowed access
     $MenuItemNum=$MenuItemNum+1;
     printf("menu[2][$MenuItemNum] = new Item('Credit&nbsp;/&nbsp;Debits&nbsp;by&nbsp;Super&nbsp;Category&nbsp;by&nbsp;Month', 'monthtotal_supercategories.php', '', defLength, 0, 0,'N',0,0,0,0,0,0,0,700,500);\n");
     }
if ($global_SECURITY['budget']==1)
     {
     // User is allowed access
     $MenuItemNum=$MenuItemNum+1;
     printf("menu[2][$MenuItemNum] = new Item('Budget', 'budget.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, 112, defOver, defBack, 'itemBorder', 'itemText');\n");
if ($global_SECURITY['passw_ch']==1)
     {
     // User is allowed access
     $MenuItemNum=$MenuItemNum+1;
     printf("menu[3][$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[3][$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[3][$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[3][$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[3][$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[3][$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[3][$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[4] = new Array();\n");
$MenuItemNum=0;
printf("menu[4][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[4][$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[4][$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[4][$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()\" 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-Money<br>");
printf("</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['accounts']==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=\"accounts.php\" ><p class='tabtext'>Accounts</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");
     }
if ($global_SECURITY['daytotal_transactions']==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=\"daytotal_transactions.php\" ><p class='tabtext'>Transactions</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");
     }
if ($global_SECURITY['graph_daytotal_transactions']==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("<p class='tabtext'>Graph</p>\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;

$global_context['vw_transactions_by_day']="";
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) {

//// PRE-FORM CODE:
$Running_Total=0;
//// end of PRE-FORM CODE
// - Block start - graph form

$recordSet = $conn->Execute("select concat( account_id,'_',date_format(transaction_date,'%Y%m%d')) as prime_key, 
account_id,date_format(transaction_date,'%Y%m%d') as transaction_day_order , 
date_format(transaction_date,'%d %b %Y') as transaction_day_display , round(sum(transaction_credits)*100)/100 as total_credits, 
round(sum(transaction_debits)*100)/100 as total_debits from xdbmoney.balance_transactions  group by concat( account_id,'_',date_format(transaction_date,'%Y%m%d')) ,account_id,date_format(transaction_date,'%Y%m%d'),date_format(transaction_date,'%d %b %Y') order by date_format(transaction_date,'%Y%m%d')"); 
printf("<table width='100%%' border=1 bgcolor='#CCCCCC'>\n");

printf("<tr>\n");

printf ("<td>\n");

require_once("xdbgraph.php");


$Graph = new xdbgraph;
$Graph->xdbgraph_graphic_size(600,400);         //      800x400 actual graphic size
$Graph->xdbgraph_start_image();                         //      Start to create image
$Graph->xdbgraph_graph_title("Month Credits vs Debits");       //      Set titles
$Graph->xdbgraph_xaxis_title("Month");
$Graph->xdbgraph_yaxis_title("Totals");
$Graph->xdbgraph_set_ygrid_color(200, 200, 200);        //      Grey grid color
// $Graph->xdbgraph_set_xgrid_color(200, 200, 200);        //
$Graph->xdbgraph_set_display_values (1);                //      Show labels
$Graph->xdbgraph_set_display_xaxis_labels(0);           //      Show labels
$XVal=0;
$SetArray = array();
$SetTypes = array();
$SetArray["total_credits"] = array();
$SetTypes["total_credits"] = "LINE";
$SetArray["total_debits"] = array();
$SetTypes["total_debits"] = "LINE";
$SetArray["CALCULATED_FIELD"] = array();
$SetTypes["CALCULATED_FIELD"] = "LINE";
$SetTypes["PARAMETERS_CUSTOM_XAXIS_TITLES"]=1;
$SetTypes["PARAMETERS_CUSTOM_YAXIS_TITLES"]=0;
$SetTypes["XAXIS_TITLES"]=array();

while (!$recordSet->EOF) {
$Running_Total=$Running_Total+$recordSet->fields['total_credits']-$recordSet->fields['total_debits'];
     $SetTypes["XAXIS_TITLES"][] = $recordSet->fields['transaction_day_display'];
     $YVal=$recordSet->fields['total_credits'];
     $SetArray["total_credits"][] = new xdbdata ( $XVal, $YVal, "", $YVal);
     $YVal=$recordSet->fields['total_debits'];
     $SetArray["total_debits"][] = new xdbdata ( $XVal, $YVal, "", $YVal);
     $YVal=$Running_Total;
     $SetArray["CALCULATED_FIELD"][] = new xdbdata ( $XVal, $YVal, "", $YVal);
        $XVal=$XVal+10;
        $recordSet->MoveNext();
}

$Graph->xdbgraph_plot_sets( $SetArray, $SetTypes );
$Graph->xdbgraph_render_image();
$filename=$Graph->xdbgraph_create_file();
printf("<br><img src='%s'>",$filename);
        printf ("</td>\n");
        printf ("</tr>\n");
printf("</table>\n");
$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=super_categories.php\">\n");
printf("<LINK REL='stylesheet' HREF='./system.css' TYPE='text/css'>\n");
printf("</head>\n");
printf("<body onload=\"document.location='super_categories.php'\">\n");
$m_field['transaction_day_display']=$HTTP_POST_VARS['transaction_day_display'];
$m_field['total_credits']=$HTTP_POST_VARS['total_credits'];
$m_field['total_debits']=$HTTP_POST_VARS['total_debits'];
$m_field['CALCULATED_FIELD']=$HTTP_POST_VARS['CALCULATED_FIELD'];
if ($HTTP_POST_VARS['op']=='Insert')
        {
        $result = $conn->Execute ("insert into xdbmoney.vw_transactions_by_day (transaction_day_display,total_credits,total_debits,CALCULATED_FIELD) 
    values( '0','".$m_field['total_credits']."','".$m_field['total_debits']."','".$m_field['CALCULATED_FIELD']."')");

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

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

        	$result = $conn->Execute ("UPDATE xdbmoney.vw_transactions_by_day set 
         	transaction_day_display='".$m_field['transaction_day_display']."',
         	total_credits='".$m_field['total_credits']."',
         	total_debits='".$m_field['total_debits']."',
         	CALCULATED_FIELD='".$m_field['CALCULATED_FIELD']."'
        	where prime_key='".$HTTP_POST_VARS['prime_key']."'");
        	$result = $conn->Execute ("commit");

        	}
        else
        	{
        	$DeleteCount=0;
        	if($DeleteCount==0)
        	     {
        	     $result = $conn->Execute ("DELETE from xdbmoney.vw_transactions_by_day 
        	     where prime_key='".$HTTP_POST_VARS['prime_key']."'");
        	     $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['prime_key']=$HTTP_POST_VARS['prime_key'];

            $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