function selectCustomFleetday() { $maxday = date("d"); print "<form name='customfleetdayform' action='index.php?mode=maxine/index&action=importcustomfleetday' method='post'>"; maxineHeader("top"); print "<img src='" . TOPBUTTONS . "/buttonsubmit.png' onClick='customfleetdayform.submit();'>"; print "<img src='" . TOPBUTTONS . "/buttonback.png' onClick=goTo('index.php?mode=maxine/index&action=firstmenu');>"; print "</td></tr>"; print "<tr><td align='center'>"; print "<table class=TRAY width=25%>"; print "<tr><td class=TOPROW align='center'>"; print "<font class=HEADING>Day to Import</font>"; print "</td></tr>"; print "<tr><td>"; print "<select name=conf[dayselect] style='width:100%;'>"; for ($i = 1; $i <= $maxday; $i++) { print "<option>" . $i . "</option>"; } print "</select>"; print "</td></tr>"; print "</table>"; print "</td></tr>"; maxineFoot(); print "</form>"; }
function viewM3Dept() { // Preparation { if ($_POST["conf"]) { $conf = $_POST["conf"]; } // Setup $conf and attached variables { if (!$conf["present"]) { $conf["present"] = "weight"; } if ($conf["pointerdirection"]) { $pointerdir = $conf["pointerdirection"]; if ($pointerdir > 4) { $pointerdir = 1; } } else { $pointerdir = 1; } // } $deptdetails = sqlPull(array("table" => "m3_departments", "where" => "id=" . $conf["deptid"] . " AND display=1", "onerow" => "1")); $m3cats = sqlPull(array("table" => "m3_categories", "where" => "deptid=" . $conf["deptid"] . " AND deleted=0")); $catcount = count($m3cats) + 1; // Combine selections with pulled details { if ($conf["present"] == "weight") { $columnlist[0] = array("name" => "Weighted Total", "id" => 0); if ($conf["graphdisplay"][0] == null) { $conf["graphdisplay"][0] = 1; } $columncount = 2; $tdwidth = 50; } else { $columnlist = $m3cats; $count = 1; if ($columnlist) { foreach ($columnlist as $colkey => $colval) { if ($conf["graphdisplay"][$colval["id"]] == null) { $conf["graphdisplay"][$colval["id"]] = 0; } } } } if ($conf["daterange"]) { $startmonth = $conf["daterange"]["startmonth"]; $startyear = $conf["daterange"]["startyear"]; $endmonth = $conf["daterange"]["endmonth"]; $endyear = $conf["daterange"]["endyear"]; } else { $startmonth = 4; $startyear = date("Y"); if (date("m") <= 4) { $startyear--; } $endmonth = date("m") - 1; $endyear = date("Y"); if ($endmonth == 0) { $endmonth = 12; $endyear = date("Y") - 1; } } // } // Colours { $basecolours = array("006600", "990099", "9999FF", "FF944C", "900000", "999999", "33CC00", "FF00FF", "FF0000", "807700", "00E6C5", "0000FF", "338499", "FF0101", "CE7811"); $colourcount = 0; $colours[0] = "067928"; if ($m3cats) { foreach ($m3cats as $cckey => $ccval) { $colours[$ccval["id"]] = $basecolours[$colourcount]; $colourcount++; } } // } $deptscores = array(); // This compares the start and end dates for the search. If greater, it switches them around { if ($startyear > $endyear || $startyear == $endyear && $startmonth > $endmonth) { $tempyear = $startyear; $tempmonth = $startmonth; $startyear = $endyear; $startmonth = $endmonth; $endyear = $tempyear; $endmonth = $tempmonth; } // } // Cycle through months and years of range { $yearcount = $startyear; $monthcount = $startmonth; while ($yearcount <= $endyear) { // If $yearcount == $endyear, then the search ends at $endmonth, otherwise there is another year to go through // and the search must go to the last month of this year { if ($yearcount == $endyear) { $stopmonth = $endmonth + 1; } else { $stopmonth = 12; } // } while ($monthcount <= $stopmonth) { // In this loop, we must cycle through each category of the department, so that the data is pulled by category, // month and year. // Make sure $datekey has 6 digits, YYYYMM, by adding a 0 between year and month if $monthcount < 10 { if ($monthcount < 10) { $datekey = $yearcount . "0" . $monthcount; } else { $datekey = $yearcount . $monthcount; } // } // Loading Graph Keylist and Division Titles { $graphdata["meta"]["divlist"][] = $datekey; $graphdata["meta"]["divtitles"][$datekey] = date("M", mktime(0, 0, 0, $monthcount, 1, $yearcount)) . " " . $yearcount; $index[] = date("M", mktime(0, 0, 0, $monthcount, 1, $yearcount)) . " " . $yearcount; $graphkey[$datekey] = $datekey; // } $weighttotal = 0; if ($m3cats) { foreach ($m3cats as $catkey => $catval) { $m3values[$catval["id"]]["title"] = $catval["name"]; $score = sqlPull(array("table" => "m3_scores", "where" => "catid=" . $catval["id"] . " AND month=" . $monthcount . " AND year=" . $yearcount, "onerow" => "1")); // Calculate the weighting of the score { $weight = round($score["score"] * $catval["weight"] / 100, 1); $weighttotal += $weight; if ($conf["present"] == "weight") { if ($score["score"] && $catval["weight"]) { $weight = round($score["score"] * $catval["weight"] / 100, 1); } else { if ($score["score"]) { $score["score"] = 0; } } } // } // If there is no score yet, assign it a value of 0 for $graphdata so there is data, and 'No Value' for $data if (!$score["score"]) { $data[$datekey][$catval["id"]] = "No Value"; // Loading $data for spreadsheet presentation if ($conf["graphdisplay"][$catval["id"]] == 1) { $graphdata["values"][$catval["id"]][$datekey] = 0; // Loading $graphdata for graph presentation } } else { $data[$datekey][$catval["id"]] = $score["score"]; // Loading $data for spreadsheet presentation $m3values[$catval["id"]]["values"][$datekey] = $score["score"]; if ($conf["graphdisplay"][$catval["id"]] == 1) { $graphdata["values"][$catval["id"]][$datekey] = $score["score"]; // Loading $graphdata for graph presentation } } $graphdata["meta"]["keylist"][$catval["id"]] = $catval["name"]; } } $monthcount++; if ($weighttotal == 0) { $weighteddata[0][$datekey] = null; $m3values[0]["values"][$datekey] = null; } else { $weighteddata[0][$datekey] = round($weighttotal, 0); $m3values[0]["values"][$datekey] = round($weighttotal, 0); } } $yearcount++; // If, after incrementing, $yearcount is still <= $endyear, it means there is still another year of data to pull, // Hence we go back month 1 of the next year in the search. if ($yearcount <= $endyear) { $monthcount = 1; } } // } if ($conf["present"] == "weight") { $spreaddata = array(); foreach ($weighteddata[0] as $weightkey => $weightval) { $spreaddata[$weightkey][0] = round($weightval, 0); } } else { $spreaddata = $data; $columncount = $catcount; $tdwidth = floor(100 / $catcount); } $border = "border-style:none none none solid; border-width:0px 0px 0px 1px;"; // Use details to create XML for graph { $swfsrc = BASE . "/basefunctions/flashcharts/charts.swf"; $libpath = BASE . "/basefunctions/flashcharts/charts_library"; $m3values[0]["title"] = $deptdetails["name"]; $graphvalues = array(); if ($conf["present"] == "weight") { $filename = "m3deptgraph.xml"; $graphvalues[0] = $m3values[0]; } else { $filename = "m3catgraph.xml"; foreach ($conf["graphdisplay"] as $choicekey => $choiceval) { if ($choiceval == 1) { $graphvalues[$choicekey] = $m3values[$choicekey]; } } } $layout["xmin"] = 40; $layout["xmax"] = 100; generateLineGraph($filename, $layout, $graphvalues, $index, $graphkey, 1); $xmlpaths[] = BASE . "/images/flashxml/" . $filename; // } // } print "<title>Manline M3</title>"; maxineHeader("top"); print "<form id=m3form action='index.php?mode=maxine/index&action=viewm3dept' method=post>"; print "<img src='" . TOPBUTTONS . "/buttonback.png' onClick=goTo('index.php?mode=maxine/index&action=m3sys')>"; print "</td></tr>"; print "<tr><td height=5px></td></tr>"; // Selector Area { print "<input type=hidden name=conf[deptid] value=" . $conf["deptid"] . ">"; print "<input type=hidden id=pointerval name=conf[pointerdirection] value=" . $pointerdir . ">"; print "<tr><td align='center'>"; print "<table class=tray width=40%>"; print "<tr><td class=toprow align='center' colspan=3>"; print "Date Range"; print "</td></tr>"; print "<tr><td colspan=3 height=5px></td></tr>"; // Start Date { print "<tr><td width=30% align='center'>"; print "Start Date"; print "</td><td width=40% align='center'>"; print "<select name=conf[daterange][startmonth] style='width:90%'>"; for ($i = 1; $i <= 12; $i++) { print "<option " . ($startmonth == $i ? "selected" : "") . " value=" . $i . ">"; print date("F", mktime(0, 0, 0, $i, 1, 2007)) . " (" . $i . ")"; print "</option"; } print "</select>"; print "</td><td width=30% align='center'>"; print "<select name=conf[daterange][startyear] style='width:90%;'>"; for ($i = 2006; $i <= date("Y"); $i++) { print "<option " . ($startyear == $i ? "selected" : "") . ">"; print $i; print "</option>"; } print "</select>"; print "</td></tr>"; // } // End Date { print "<tr><td align='center'>"; print "End Date"; print "</td><td align='center'>"; print "<select name=conf[daterange][endmonth] style='width:90%'>"; for ($i = 1; $i <= 12; $i++) { print "<option " . ($endmonth == $i ? "selected" : "") . " value=" . $i . ">"; print date("F", mktime(0, 0, 0, $i, 1, 2007)) . " (" . $i . ")"; print "</option"; } print "</select>"; print "</td><td align='center'>"; print "<select name=conf[daterange][endyear] style='width:90%'>"; for ($i = 2006; $i <= date("Y"); $i++) { print "<option " . ($endyear == $i ? "selected" : "") . ">"; print $i; print "</option>"; } print "</select>"; print "</td></tr>"; // } print "<tr><td colspan=3 height=10px></td></tr>"; print "<tr><td align='center'>"; print "Presentation"; print "</td><td align='center'>"; print "<input type='radio' name=conf[present] value='weight' " . ($conf["present"] == "weight" ? "checked" : "") . ">"; print "Weighted Total"; print "</td><td align='center'>"; print "<input type='radio' name=conf[present] value='component' " . ($conf["present"] == "component" ? "checked" : "") . ">"; print "Components"; print "</td></tr>"; print "<tr><td colspan=3 height=10px></td></tr>"; print "<tr><td colspan=3 align='center'>"; print "<img src='" . TOPBUTTONS . "/buttonsubmit.png' onClick='m3form.submit();'>"; print "</td></tr>"; print "<tr><td colspan=3 height=5px></td></tr>"; print "</table>"; print "</td></tr>"; // } print "<tr><td height=5px></td></tr>"; // Spreadsheet { print "<input id=pointerline type=hidden value=0 name=conf[pointerline]>"; print "<input id=pointerpoint type=hidden value=0 name=conf[pointerpoint]>"; print "<tr><td align='center'>"; print "<table class=tray cellspacing=1 cellpadding=0 width=80%>"; print "<tr><td class=toprow colspan=" . $columncount . " align='center' onClick='switchGraphs();'>"; print $deptdetails["name"]; print "</td></tr>"; print "<tr>"; if ($columnlist) { print "<td width=" . $tdwidth . " align='center'>"; print "Date"; print "</td>"; foreach ($columnlist as $colkey => $colval) { if ($conf["graphdisplay"][$colval["id"]] == 1) { $colborder = "border-style: inset; border-width: 2px; border-color: " . MAXINETOP . "; cursor: pointer;"; } else { $colborder = "border-style: outset; border-width: 2px; border-color: " . MAXINETOP . "; cursor: pointer;"; } $colonclick = "onclick='changeCol(" . $colval["id"] . ");'"; print "<input type=hidden id=coltop" . $colval["id"] . " name=conf[graphdisplay][" . $colval["id"] . "] value=" . $conf["graphdisplay"][$colval["id"]] . ">"; print "<td align='center' id=coltd" . $colval["id"] . " width=" . $tdwidth . "% style='" . $colborder . "' " . $colonclick . " >"; print $colval["name"]; print "</td>"; } } print "</tr>"; $oldrow = 0; $rowcolour = MAXINEBACKALT; $maxvalue = 0; $minvalue = 100; if ($spreaddata) { foreach ($spreaddata as $rowkey => $rowval) { $count = 0; if ($rowcolour == MAXINEBACKALT) { $rowcolour = MAXINEBACK; } else { $rowcolour = MAXINEBACKALT; } print "<tr bgcolor='" . $rowcolour . "'>"; print "<td align='center'>"; print $graphdata["meta"]["divtitles"][$rowkey]; print "</td>"; foreach ($columnlist as $colkey => $colval) { // Preparation per Column { $olddata = $spreaddata[$oldrow][$colval["id"]]; $currentdata = $rowval[$colval["id"]]; $title = ""; $bgcolour = ""; $note = ""; if ($olddata == $currentdata) { $style = "style='color: black; font-family: verdana; font-size:11; height:8;'"; $title = "title='No Change'"; } else { if ($currentdata == "No Value" || $olddata == "No Value" || $oldrow == 0) { $style = "style='color: black; font-family: verdana; font-size:11; height:8;'"; $title = "title='Insufficient Data'"; } else { if ($olddata > $currentdata) { $style = "style='color: red; font-family: verdana; font-size:11; height:8; font-weight:bold'"; $title = "title='Fell by " . ($olddata - $currentdata) . "'"; $note = "-"; } else { if ($olddata < $currentdata) { $style = "style='color: green; font-family: verdana; font-size:11; height:8; font-weight:bold'"; $title = "title='Rose by " . ($currentdata - $olddata) . "'"; $note = "+"; } } } } if ($colkey == $conf["pointerline"] && $rowkey == $conf["pointerpoint"]) { $bgcolour = "bgcolor='" . $colours[$colkey] . "'"; $style = "style='color: white; font-family: verdana; font-size:11; height:8; font-weight:bold'"; } else { $note = ""; // Reset to blank in the case of tds that are not selected. } $tdonclick = "onclick='pointerline.value=" . $colkey . "; pointerpoint.value=" . $rowkey . "; m3form.submit();'"; if ($conf["graphdisplay"][$colval["id"]] == 1) { if ($maxvalue < $currentdata && $currentdata > 0) { $maxvalue = $currentdata; } if ($minvalue > $currentdata && $currentdata >= 0) { $minvalue = $currentdata; } } // } print "<td " . $title . " " . $tdonclick . " " . $bgcolour . " align='right' style='" . $border . "'>"; print $currentdata . $note; print "</td>"; $count++; } print "</tr>"; $oldrow = $rowkey; } } print "</table>"; print "</td></tr>"; // } // Graph { // Details { $showgraph = 0; $graphtop = ceil($maxvalue / 5) * 5; $graphbottom = floor($minvalue / 5) * 5; $numrows = $graphtop - $graphbottom; if ($numrows <= 10) { $numrows = $numrows / 2 + 1; $graphtop += 2; } else { if ($numrows > 25) { $numrows = $numrows / 10 + 1; $graphtop += 10; } else { $numrows = $numrows / 5 + 1; $graphtop += 5; } } if ($conf["present"] == "weight") { $graphdata["meta"]["name"] = "deptgraphweight"; $graphdata["values"] = $weighteddata; $graphdata["meta"]["keylist"] = array(0 => "Weighted Total"); //$colours[0] = "DD1111"; if ($conf["graphdisplay"][0] == 1) { $showgraph = 1; } } else { $graphdata["meta"]["name"] = "deptgraphcomponent"; foreach ($conf["graphdisplay"] as $displaykey => $displayval) { if ($displayval == 1 && $displaykey != 0) { $showgraph = 1; } } } $graphdata["meta"]["height"] = 400; $graphdata["meta"]["width"] = 700; $graphdata["meta"]["topval"] = $graphtop; $graphdata["meta"]["bottomval"] = $graphbottom; $graphdata["meta"]["rows"] = $numrows; $graphdata["meta"]["keywidth"] = 190; $graphdata["meta"]["keysperrow"] = 4; $graphdata["meta"]["title"] = "M3 for " . $deptdetails["name"]; $graphdata["meta"]["subtitle"] = date("F", mktime(0, 0, 0, $startmonth, 1, 2007)) . " " . $startyear . " - "; $graphdata["meta"]["subtitle"] .= date("F", mktime(0, 0, 0, $endmonth, 1, 2007)) . " " . $endyear; $graphdata["meta"]["colours"] = $colours; $graphdata["meta"]["onclick"] = "pointerval.value=" . ($pointerdir + 1) . "; m3form.submit();"; if ($conf["pointerline"] && $conf["pointerline"] > 0) { $graphdata["pointer"][$conf["pointerline"]] = $conf["pointerpoint"]; $graphdata["pointer"]["direction"] = $pointerdir; } // } print "<tr><td height=12px></td></tr>"; print "<tr><td align='center'>"; print "<table cellspacing=0 cellpadding=0>"; print "<tr id=oldgraphrow><td>"; if ($showgraph == 1) { drawLineGraphX($graphdata); } else { print "Insufficient data for Graph."; } print "</td></tr>"; // Flashgraph { print "<tr id=newgraphrow style='display: none'><td align='center'>"; print "<EMBED src='" . $swfsrc . "?library_path=" . $libpath . "&xml_source=" . BASE . "/images/flashxml/" . $filename . "' \n\t\t\t\t\t\tquality=high \n\t\t\t\t\t\tbgcolor=" . MAXINEBACKALT . " \n\t\t\t\t\t\tWIDTH='600' \n\t\t\t\t\t\tHEIGHT='400'\n\t\t\t\t\t\tNAME='charts' \n\t\t\t\t\t\tALIGN='' \n\t\t\t\t\t\tswLiveConnect='true' \n\t\t\t\t\t\tTYPE='application/x-shockwave-flash' \n\t\t\t\t\t\tPLUGINSPAGE='http://www.macromedia.com/go/getflashplayer'>"; print "</EMBED>"; print "</td></tr>"; // } print "</table>"; print "</td></tr>"; // } print "</form>"; maxineFoot(); // Script { print "<script type='text/javascript'>\n\t\t\t\t\tfunction changeCol(colid) {\n\t\t\t\t\tviewchoice = document.getElementById('coltop'+colid).value;\n\t\t\t\t\tif(viewchoice == 1) {\n\t\t\t\t\tdocument.getElementById('coltop'+colid).value = 0;\n\t\t\t\t\tdocument.getElementById('coltd'+colid).style.border = 'outset';\n\t\t\t\t\t} else {\n\t\t\t\t\tdocument.getElementById('coltop'+colid).value = 1;\n\t\t\t\t\tdocument.getElementById('coltd'+colid).style.border = 'inset';\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tdocument.getElementById('coltd'+colid).style.borderColor = '" . MAXINETOP . "';\n\t\t\t\t\tdocument.getElementById('coltd'+colid).style.borderWidth = '2px';\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tfunction switchGraphs() {\n\t\t\t\t\tdocument.getElementById('oldgraphrow').style.display = 'none';\n\t\t\t\t\tdocument.getElementById('newgraphrow').style.display = '';\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t</script>"; // } }
function pdfCandidateList() { // Preparation { $conf = $_POST["conf"]; $where = ""; if ($conf["searchtype"] == 1) { $where = "statusid = " . $conf["statusid"]; } else { if ($conf["searchtype"] == 2) { $where = "statusid > 0"; } else { if ($conf["searchtype"] == 3) { $where = "statusid = 0"; } else { if ($conf["searchtype"] == 4) { $where = "statusid = -1"; } else { $where = "1=1"; } } } } $where .= " AND deleted = 0"; $candidatelist = sqlPull(array("table" => "candidates", "where" => $where)); $statuslist = sqlPull(array("table" => "candidate_status", "where" => "1=1")); $spans = array(70, 70, 70, 70, 280); $header = array("Name", "ID Number", "Contact Number", "Status"); // } // PDF Creation { $pdf = new PDF("L"); $pdf->SetFont('Arial', 'B', 8); $pdf->AddPage(); $pdf->pdfHeader($header, $spans); $border = "TRBL"; foreach ($candidatelist as $candkey => $candval) { // Individual Preparation { if ($candval["statusid"] == null) { $status = -10; } else { $status = $candval["statusid"]; } $notelist = sqlPull(array("table" => "candidate_notes", "where" => "candidateid=" . $candval["id"])); // } $row = array(); $row[0] = $candval["firstname"] . " " . $candval["lastname"]; $row[1] = $candval["idno"]; $row[2] = $candval["contactno"]; if ($status == -1) { $row[3] = "Failed"; } else { if ($status == 0) { $row[3] = "Passed"; } else { if ($status > 0) { $row[3] = $statuslist[$status]["name"]; } else { $row[3] = "No Status"; } } } if ($notelist) { $row[4] = ""; $count = count($notelist); foreach ($notelist as $notekey => $noteval) { $row[4] .= date("d/M/Y", $noteval["date"]) . " - "; $row[4] .= $noteval["note"]; $count--; if ($count > 0) { $row[4] .= "\n"; } } } else { $row[4] = 0; } $pdf->pdfCandLine($row, $spans, 7, $border); } $pdf->Output(BASE . "/images/graphs/candidatespdf.pdf", "F"); // } maxineHeader("top"); print "<img src='" . TOPBUTTONS . "/buttonback.png' onClick=goTo('index.php?mode=maxine/index&action=candidatereports');>"; print "</td><tr>"; print "<tr><td align='center'>"; print "<a href='download.php?filename=candidatespdf.pdf'>Click here to download the pdf</a>"; print "</td></tr>"; maxineFoot(); }
function pageRights() { // Preparation { $code = $_GET["code"]; $groups = sqlPull(array("table" => "rights_groups", "where" => "1=1")); // } print "<form id=pagerightsform action='index.php?mode=maxine/index&action=updatepagerights' method='post'>"; maxineHeader("top"); // Buttons { print "<img src='" . TOPBUTTONS . "/buttonupdate.png' onClick='pagerightsform.submit();'>"; print "<img src='" . TOPBUTTONS . "/buttonback.png' onClick=goTo('index.php?mode=maxine/index&action=firstmenu');>"; print "</td></tr>"; // } print "<tr><td align='center'>"; print "<table class=tray width=60%>"; print "<tr><td class=toprow align='center' colspan=2>"; print "<font class=heading>" . $code . "</font>"; print "</td></tr>"; print "<tr><td align='center'>"; print "<font class=colheading>Group</font>"; print "</td><td align='center'>"; print "<font class=colheading>Access</font>"; print "</td></tr>"; print "<input type='hidden' name=conf[pagecode] value='" . $code . "'>"; $count = 0; foreach ($groups as $grpkey => $grpval) { // Individual Preparation { $pagerights = sqlPull(array("table" => "rights_pages", "where" => "pagecode LIKE '" . $code . "' AND groupid = " . $grpval["id"], "onerow" => 1)); // } print "<input type='hidden' name=conf[groups][" . $count . "][groupid] value=" . $grpval["id"] . ">"; print "<tr><td align='center' width=90%>"; print "<font class=standard>" . $grpval["name"] . "</font>"; print "</td><td align='center' width=10%>"; print "<input type='checkbox' name=conf[groups][" . $count . "][access] value=1 " . ($pagerights["level"] == 1 ? "checked" : "") . ">"; print "</td></tr>"; $count++; } print "</table>"; maxineFoot(); print "</form>"; }