function editDriver() { // Preparation { $drivers = new Drivers(); $driveractive = (bool) true; $actions = array(1 => "Warning", 2 => "Final Warning", 3 => "Dismissed"); if ($_GET["driverid"]) { $driverid = $_GET["driverid"]; $driver = $drivers->getRow(array("where" => "id=" . $driverid)); $driverbirthday = date("d", $driver["birthday"]); $driverbirthmonth = date("m", $driver["birthday"]); $driveractive = $driver["deleted"] == 0 ? true : false; } $fleetmanobj = new TableManager("users"); $fleetmanobj->setQueryColumns(array("users" => array("personid", "isfleetman", "deleted"), "profile" => array("id", "firstname", "profile.lastname", "department_id"))); $fleetmanobj->setQueryFrom(array("left join" => array(0 => array("table" => array("abbr" => "profile", "table" => "user_profiles"), "on" => "`users`.`user_profiles_id`=`profile`.`id`")))); $fleetmanobj->setOrderBy(array("column" => array("`profile`.`firstname`", "`profile`.`firstname`"), "direction" => array("DESC", "DESC"))); $fleetmanobj->setWhere("`users`.`deleted`=0 AND `users`.`isfleetman`=1"); $fleetmans = $fleetmanobj->selectMultiple(); $fleets = sqlPull(array("table" => "fleets", "where" => "deleted=0")); if ($driver["id"]) { $actionstaken = sqlPull(array("table" => "driver_actions", "where" => "driverid=" . $driver["id"], "sort" => "createddate")); } $pdpdate = date("d/m/Y", $driver["pdpdate"]); $actionimages = array(1 => BASE . "/images/iconwarn.png", 2 => BASE . "/images/iconfinalwarn.png", 3 => BASE . "/images/icondismissed.png"); // } maxineTop("Driver Form"); print "<form method=post id='driverform' name='driverform' action='index.php?mode=maxine/index&action=commitdriver'>"; // Buttons { openHeader(); maxineButton("Submit", "driverform.submit();", 2); maxineButton("Back", "goTo(\"index.php?mode=maxine/index&action=driverslist\");", 2); closeHeader(); // } print "<div class='tray' style='height:500px;'>"; if ($driver) { print "<input type=hidden name=conf[driverid] value=" . $driverid . ">"; } // Left Column { print "<div style='width:400px; float:left; margin-left:20px;'>"; // Personal Details { openSubbar(400); print "Personal Details"; closeSubbar(); print "<table class='standard content1' style='width:400px;'>"; print "<tr><td align='center' width=40%>"; print "First Name"; print "</td><td width=60%>"; print "<input name=conf[firstname] value='" . $driver["firstname"] . "' style='width:200px;'>"; print "</td></tr>"; print "<tr><td align='center'>"; print "Last Name"; print "</td><td>"; print "<input name=conf[lastname] value='" . $driver["lastname"] . "' style='width:200px;'>"; print "</td></tr>"; // Birthday { print "<tr><td align='center'>"; print "Birthday"; print "</td><td>"; // Day { print "<select id='dayselect' name='conf[birthday]' style='width:70px; color:BLACK; z-index:500;'>"; for ($day = 1; $day < 32; $day++) { print "<option " . ($driverbirthday == $day ? "selected" : "") . ">" . $day . "</option>"; } print "</select>"; // } // { print "<select id='monthselect' name='conf[birthmonth]' style='width:134px; color:BLACK;'>"; for ($month = 1; $month < 13; $month++) { print "<option value=" . $month . " " . ($driverbirthmonth == $month ? "selected" : "") . ">" . date("F", mktime(0, 0, 0, $month, 1, 2000)) . "</option>"; } print "</select>"; // } print "</td></tr>"; // } print "<tr><td align='center'>"; print "ID Number"; print "</td><td>"; print "<input name=conf[idno] value='" . $driver["idno"] . "' style='width:200px;'>"; print "</td></tr>"; print "<tr><td align='center'>"; print "Cellphone"; print "</td><td>"; print "<input name=conf[cell] value='" . $driver["cell"] . "' style='width:200px;'>"; print "</td></tr>"; print "</table>"; // } // Company Details { openSubbar(400); print "Employment Details"; closeSubbar(); print "<table class='standard content1' style='width:400px;'>"; print "<tr><td align='center' width=40%>"; print "Staff Number"; print "</td><td width=60%>"; print "<input name=conf[staffno] value='" . $driver["staffno"] . "' style='width:200px;'>"; print "</td></tr>"; // Fleet managers { print "<tr><td align='center'>"; print "Fleet Manager"; print "</td><td>"; print "<select id='fleetselect' name='conf[fleetmanid]' style='width:204px; color:BLACK;'>"; print "<option value=0>- Please Select -</option>"; if ($fleetmans) { foreach ($fleetmans as $fleetmankey => $fleetman) { print "<option value=" . $fleetman["personid"] . " " . ($driver["fleetmanid"] == $fleetman["personid"] ? "selected" : "") . ">"; print $fleetman["firstname"] . " " . $fleetman["lastname"]; print "</option>"; } } print "</select>"; print "</td></tr>"; // } // Fleet { print "<tr><td align='center'>"; print "Fleet"; print "</td><td>"; print "<select id='fleetselect' name='conf[fleetid]' style='width:204px; color:BLACK;'>"; print "<option value=0>- Please Select -</option>"; if ($fleets) { foreach ($fleets as $fleetkey => $fleetval) { print "<option value=" . $fleetval["id"] . " " . ($driver["fleetid"] == $fleetval["id"] ? "selected" : "") . ">" . $fleetval["name"] . "</option>"; } } print "</select>"; print "</td></tr>"; // } // PDP Expiry checkbox and date{ print "<tr><td align='center'>"; print "PDP Expires?"; print "</td><td align='center'>"; print "<input type='checkbox' name='conf[pdpexpires]' value='1' " . ($driver["pdpexpires"] == 1 ? "checked" : "") . " onClick='showPdpDate();'>"; print "</td></tr>"; print "<tr id='pdpdaterow' style='" . ($driver["pdpexpires"] == 0 ? "display:none;" : "") . "'><td align='center'>"; print "PDP Expiry"; print "</td><td align='center'>"; print "<input id='pdpdate' name='conf[pdpdate]' value='" . $pdpdate . "' readonly style='width:160px;'>"; print "<img src='" . BASE . "/images/calendar.png' onClick='displayDatePicker(\"conf[pdpdate]\", this, \"dmy\", \"\");'>"; print "</td></tr>"; // } print "<tr><td align='center'>"; print "Active"; print "</td><td align='center'>"; print "<input type=checkbox name='conf[active]' " . ($driveractive ? "checked" : "") . ">"; print "</td></tr>"; print "</table>"; // } print "</div>"; // } // Right Column { print "<div style='float:right; margin-right:20px; width:400px;'>"; openSubbar(400); print "Actions Taken"; closeSubbar(); print "<table class='standard' style='width:400px;'>"; if ($actionstaken) { print "<input type=hidden id='faultid' name=conf[faultid]>"; // Headings { print "<tr class='heading'><td align='center' width=10%>"; print "Ticket"; print "</td><td align='center' colspan=2 width=40%>"; print "Action"; print "</td><td align='center' width=45%>"; print "Date"; print "</td><td width=5%>"; print "</td></tr>"; // } foreach ($actionstaken as $actionkey => $actionval) { print "<tr class='content1'><td align='center'>"; print $actionval["sourceid"]; print "</td><td align='center'>"; print $actions[$actionval["action"]] . " "; print "</td><td align='LEFT'>"; print "<img src='" . $actionimages[$actionval["action"]] . "'"; print "</td><td align='center'>"; print date("d M Y", $actionval["createddate"]); print "</td><td align='center'>"; if ($actionval["source"] == 1) { print "<img src='" . BASE . "/images/note.png' onClick='editEquipFault(" . $actionval["sourceid"] . ")' >"; } print "</td></tr>"; } } else { print "<tr class='content1'><td align='center'>"; print "No Actions against driver."; print "</td></tr>"; } print "</table>"; print "</div>"; // } print "</div>"; maxineBottom(); print "</form>"; // Javascript { print "<script>\n\t\t\t\t\n\t\t\tfunction editDriverFault(faultid) {\n\t\t\t\tdocument.getElementById('faultid').value\t= faultid;\n\t\t\t\t\n\t\t\t\tdocument.getElementById('driverform').action\t= 'index.php?mode=maxine/index&action=editdriverfault';\n\t\t\t\tdocument.getElementById('driverform').submit();\n\t\t\t}\n\t\t\t\n\t\t\tfunction editEquipFault(faultid) {\n\t\t\t\tdocument.getElementById('faultid').value\t= faultid;\n\t\t\t\t\n\t\t\t\tdocument.getElementById('driverform').action\t= 'index.php?mode=maxine/index&action=editequipfault';\n\t\t\t\tdocument.getElementById('driverform').submit();\n\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\t\tfunction showPdpDate() {\n\t\t\t if(document.getElementById('pdpdaterow').style.display == '') {\n\t\t\t \tdocument.getElementById('pdpdaterow').style.display = 'none';\n\t\t\t } else {\n\t\t\t \tdocument.getElementById('pdpdaterow').style.display = '';\n\t\t\t }\n\t\t\t}\n\t\t\t</script>"; // } }
function maxineTop($title = "") { // Prep { ## User Data $mycapsSegments = new TableManager("users"); $mycapsSegments->setWhere($mycapsSegments->quoteString("`users`.`personid`=?", (int) $_SESSION["userid"])); $user = $mycapsSegments->selectSingle(); //$user = sqlPull(array("table"=>"users", "where"=>"personid=".$_SESSION["userid"], "select"=>"firstname, lastname, user_profiles_id", "onerow"=>1)); $smsaccess = testRights($_SESSION["userid"], "sms001"); ## myCAPS segment check if (isset($_SESSION["userid"]) && $_SESSION["userid"]) { $mycapsSegments = new TableManager("mycaps_segments"); $mycapsSegments->setWhere($mycapsSegments->quoteString("`mycaps_segments`.`userid`=?", (int) $_SESSION["userid"]) . $mycapsSegments->quoteString(" AND `mycaps_segments`.`finalized`=?", 0)); $segment = $mycapsSegments->selectSingle(); } ## Profile Data if ($user) { $user_profiles = new TableManager("user_profiles"); ## Test for fortune column $cols = $user_profiles->getColumns(); if (in_array("fortune", $cols) === FALSE) { $sql = (string) "ALTER TABLE `user_profiles` ADD COLUMN `fortune` TINYINT(1) NOT NULL DEFAULT 0, ADD INDEX (`fortune`);"; if ($user_profiles->runSql($sql) === FALSE) { $errors = $user_profiles->getErrors(); echo "<div class=\"error\">mySQL statement encountered an error. Last error was:<br />" . $errors[count($errors) - 1] . "</div>"; return FALSE; } } $user_profiles->setWhere($user_profiles->quoteString("`user_profiles`.`id`=?", $user["user_profiles_id"])); $profile = $user_profiles->selectSingle(); } ## Alerts $manager = new TableManager("alerts"); $manager->setWhere($manager->quoteString("`alerts`.`deleted`=?", (int) 0) . $manager->quoteString(" AND `alerts`.`time_start`<=?", strtotime(date("Y-m-d") . " 00:00")) . $manager->quoteString(" AND `alerts`.`time_end`>=?", strtotime(date("Y-m-d") . " 23:59"))); $manager->setCustomIndex("id"); $alerts = $manager->selectMultiple(); ## Theme $themes = new TableManager("themes"); $themes->setQueryColumns(array("themes" => array("*"))); $themes->setQueryFrom(array("left join" => array(0 => array("table" => array("abbr" => "user_profiles", "table" => "user_profiles"), "on" => "`themes`.`id`=`user_profiles`.`theme_id`"), 1 => array("table" => array("abbr" => "users", "table" => "users"), "on" => "`user_profiles`.`id`=`users`.`user_profiles_id`")))); $where = (string) "(ISNULL(`themes`.`deleted`)"; $where .= $themes->quoteString(" OR `themes`.`deleted`=?)", 0); if ($_SESSION["userid"]) { $where .= $themes->quoteString(" AND `users`.`personid`=?", (int) $_SESSION["userid"]); } else { $where .= $themes->quoteString(" AND `themes`.`id`=?", (int) 1); } $themes->setWhere($where); $theme = $themes->selectSingle(); $backgroundImage = (string) BASE . "images/new/themes/" . $theme["background-image"]; $_SESSION["backgroundRepeat"] = (string) BASE . "images/new/themes/" . $theme["background-repeater"]; $size = getimagesize($backgroundImage); $_SESSION["bgImageSize"] = $size; // } print "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>"; print "<html>"; // Header Info { print "<head>"; print "<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' />" . PHP_EOL; print "<link href='" . BASE . "/images/favicon.ico' rel='SHORTCUT ICON' />" . PHP_EOL; //print("<link href='".BASE."/basefunctions/scripts/manlinecss.php' rel='stylesheet' type='text/css' />"); print "<link href='" . BASE . "/basefunctions/scripts/manline.css' media='all' rel='stylesheet' type='text/css' />" . PHP_EOL; print "<script type='text/javascript' language='javascript' src='" . BASE . "/basefunctions/scripts/manline.js'></script>"; $headTitle = (string) "Maxweb"; if ($title) { $headTitle .= " - " . $title; } print "<title>" . $headTitle . "</title>" . PHP_EOL; print "</head>"; // } print "<body id=\"windowBody\" style='background-image:url(\"" . $backgroundImage . "\");'>"; //print("<form action='#' method='post'>"); // Header 1 { print "<h1>"; print "<img alt=\"Maxweb Logo\" id=\"maxwebLogo\" src='" . BASE . "/images/new/logo.png' style=\"height:58px;margin-top:2px;width:299px;\">"; print "<span style='float:right; text-align:right;'>"; $links = (array) array("Home" => array("class" => "headerA", "href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?action=home", "id" => "home"), "Documents" => array("class" => "headerA", "href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?action=viewdocuments", "id" => "Documents"), "Gallery" => array("class" => "headerA", "href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?action=viewgallery", "id" => "Gallery"), "InOut" => array("class" => "headerA", "href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?action=inoutboard", "id" => "InOut"), "Max" => array("class" => "headerA", "href" => "http://login.max.manline.co.za", "id" => "Max", "target" => "_blank"), "Zimbra" => array("class" => "headerA", "href" => "http://mail.manline.co.za", "id" => "Zimbra", "target" => "_blank")); foreach ($links as $text => $data) { echo "<a class=\"" . $data["class"] . "\" href=\"" . $data["href"] . "\" id=\"" . $data["id"] . "\" " . (isset($data["target"]) ? "target=\"" . $data["target"] . "\" " : "") . "title=\"" . $text . "\"></a>" . PHP_EOL; } print "</span>"; print "</h1>"; // } // Header 2 { $messages = (array) array(); if (isset($profile) && $profile) { if (!$profile["staffno"] || !$profile["department_id"] || !$profile["jobtitle"] || !$profile["location"]) { $messages[] = "Your profile information is incomplete."; } } if (isset($segment)) { if (date("U") > (int) $segment["enddate"] + 86400) { $messages[] = "Your CAPS is overdue"; } } if (isset($alerts) && $alerts) { foreach ($alerts as $val) { $messages[] = $val["message"]; } } ## Profile Data if ($messages) { informationBar($messages); } print "<h2>"; print "<span style='width:10px; height:51px; background-image:url(\"" . BASE . "/images/new/menubarleft.png\"); float:left;'></span>"; print "<span style='width:850px; height:36px; background-image:url(\"" . BASE . "/images/new/menubarmid.png\"); float:left; padding-top:15px;'>"; // Left Span - Quick Navigation { print "<span style='float:left; margin-top:-5px;'>"; ## Menu // $items[] = array("href"=>"http://".$_SERVER["SERVER_NAME"]."/Maxine/", "text"=>"", "title"=>""); $items = (array) array(); if ($user) { $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=mycapslist2", "text" => "myCAPS", "title" => "click to go to your CAPs"); } $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=showm3", "text" => "Public M3", "title" => "View public M3 Graphs"); $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=dockeeperfront", "text" => "Customer Documents", "title" => "View Documents required by Customers"); if ($user) { $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=m3sys", "text" => "M3", "title" => "View M3 Graphs"); $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=displaymydash", "text" => "Personal Dashboard", "title" => "Click to view your personal dashboard"); $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=greenmileinput", "text" => "Green Mile Controls", "title" => "Click to update Green Mile Details"); $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=ratescalc2", "text" => "Rates Calculator", "title" => "Click to view the rates calculator"); if ($user["isit"] || $user["ismanager"]) { $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=nineblockinput", "text" => "9 Blocker", "title" => "Click to view your 9 Blocker"); $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?action=listalerts", "text" => "Alerts", "title" => "Click to list all alerts"); $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?action=edituserpool", "text" => "User Pools", "title" => "Click to view and edit User Pools"); } $items[] = array("text" => "Faults System", "children" => array(array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=equipfaults", "text" => "Equipment Faults", "title" => "Click to view equipment faults"), array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=uflist", "text" => "Unit Faults", "title" => "Click to view unit faults"), array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=faultsys", "text" => "Fault Logging", "title" => "Log a new fault"))); $items[] = array("text" => "Personnel Tools", "children" => array(array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=learnerlist", "text" => "Learner", "title" => "Click to view a list of learners"), array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=candmenu", "text" => "Candidates", "title" => "Click to view list of candidates"), array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=driverslist", "text" => "Drivers", "title" => "Click to view list of drivers"), array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=listusers", "text" => "Users", "title" => "Click to view user list"))); $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?action=updateprofile", "text" => "Edit Your Profile", "title" => "Click to edit your profile"); } /** Cameras link affects 4 = > Jonathan Spencer 5 = > Bradley Roberts 141 = > Jerome Govender 168 = > Lwazi Ally 186 = > Ndumiso Langa */ if (in_array($_SESSION["userid"], array(4, 5, 141, 168, 186))) { $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/cameras/", "text" => "Manline CCTV", "title" => "Click to view the cameras"); } if ($_SESSION["isadmin"] || $smsaccess > 0) { $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=smssystem", "text" => "Send an SMS", "title" => "Click to use the SMS system"); } if ($_SESSION["isit"] == 1) { $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=rightscontrol", "text" => "Access Rights", "title" => "Click to set user access rights"); $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=loggingreport", "text" => "Logging Report", "title" => "Click to view the logging report"); if ($_SESSION["isadmin"]) { $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=smssystem", "text" => "Send an SMS", "title" => "Click to use the SMS system"); } $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=sandbox", "text" => "Sandbox", "title" => "Click to go to the coding sandbox"); //$items[] = array("href"=>"http://".$_SERVER["SERVER_NAME"]."/Maxine/index.php?mode=maxine/index&action=encoder", "text"=>"Text Encoder", "title"=>"Click to view the text encoder"); //$items[] = array("href"=>"http://".$_SERVER["SERVER_NAME"]."/Maxine/index.php?mode=maxine/index&action=truckfinder", "text"=>"Truck Finder", "title"=>"Click to view the truck finder"); $items[] = array("text" => "Scaffolding", "children" => array(array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=list&name=documents", "text" => "Documents", "title" => "Click to list all items"), array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=list&name=gallery", "text" => "Gallery", "title" => "Click to list all items"), array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=list&name=galleryItems", "text" => "Gallery Items", "title" => "Click to list all items"), array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=list&name=newspaper_articles", "text" => "Newspaper Articles", "title" => "Click to list all items"), array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=list&name=pages", "text" => "Pages", "title" => "Click to list all items"), array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=list&name=themes", "text" => "Themes", "title" => "Click to list all items"), array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=list&name=type", "text" => "Type", "title" => "Click to list all items"), array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?mode=maxine/index&action=list&name=user_profiles", "text" => "User Profiles", "title" => "Click to list all items"))); } /* $items[] = array("text"=>"Corporate Clothing", "children"=>array( array("href"=>"http://".$_SERVER["SERVER_NAME"]."/Maxine/documents/Ladies Clothing Catalogue.pdf", "text"=>"Ladies", "title"=>"Click to download ladies clothing catalogue"), array("href"=>"http://".$_SERVER["SERVER_NAME"]."/Maxine/documents/Mens Clothing Catalogue.pdf", "text"=>"Mens", "title"=>"Click to download mens clothing catalogue") )); */ $items[] = array("href" => "/Maxine/documents/ManlinePriceList.pdf", "text" => "Corporate Clothing", "title" => "Click to download"); $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/documents/Map to Head Office.pdf", "text" => "Map to Head office", "title" => "Click to download map to head office"); $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?action=maxexpress", "text" => "Max Express", "title" => "Click to view Max Express editions"); $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?action=viewnews", "text" => "News", "title" => "Click to view newspaper articles"); $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?action=monthlyvideos", "text" => "Monthly Videos", "title" => "Click to view Neil's monthly video updates"); $sql = (string) "SELECT * FROM `m3_departments`"; $departs = $themes->runSql($sql); $depts = (array) array(); foreach ($departs as $dept) { $depts[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?action=listdepartment&department=" . urlencode($dept["name"]), "text" => $dept["name"], "title" => "Click to view department members"); } $items[] = array("href" => "http://" . $_SERVER["SERVER_NAME"] . "/Maxine/index.php?action=listdepartment", "text" => "Staff Profiles", "title" => "Click to view all staff members", "children" => $depts); echo menu($items); print "</span>"; // } // Right Span - Login Details { print "<span style='height:34px; float:right; margin-top:-5px; vertical-align:bottom;'>"; if ($_SESSION["userid"] > 0) { print "<p class='standard' style='float:left; margin-right:10px; margin-top:8px;'>Logged in as " . $profile["firstname"] . " " . $profile["lastname"] . "</p>"; echo "<a href=\"/Maxine/?logout\" id=\"logoutbutton\"></a>" . PHP_EOL; } else { $name = ""; if ($_COOKIE["loggedname"]) { $name = $_COOKIE["loggedname"]; } print "<form id=\"loginform\" name='loginform' action='index.php?mode=maxine/index&action=loginaction' method='post'>"; print "<span style='width:16px; height:19px; background-image:url(\"" . BASE . "/images/new/loginicon.png\"); float:left; margin-top:5px;'></span>"; print "<span style='width:10px; height:25px; background-image:url(\"" . BASE . "/images/new/loginleft.png\"); float:left; margin-left:10px; margin-top:4px; '></span>"; print "<input id=\"username\" name='conf[username]' value='" . $name . "' class='loginmid' onKeyPress='submitenter(this,event);' />"; print "<span style='width:10px; height:25px; background-image:url(\"" . BASE . "/images/new/loginright.png\"); float:left; margin-top:4px; '></span>"; print "<span style='width:10px; height:25px; background-image:url(\"" . BASE . "/images/new/loginleft.png\"); float:left; margin-left:10px; margin-top:4px;'></span>"; print "<input type='password' id='passbox' name='conf[password]' class='loginmid' onKeyPress='submitenter(this,event);' />"; print "<span style='width:10px; height:25px; background-image:url(\"" . BASE . "/images/new/loginright.png\"); float:left; margin-top:4px; '></span>"; echo "<a href=\"#\" id=\"loginbutton\" onclick=\"document.getElementById('loginform').submit();\"></a>" . PHP_EOL; print "</form>"; } print "</span>"; // } print $title; print "</span>"; print "<span style='width:10px; height:51px; background-image:url(\"" . BASE . "/images/new/menubarright.png\"); float:left;'></span>"; print "</h2>"; if (isset($_SESSION["userid"]) && in_array($_SESSION["userid"], array(4, 23, 175)) || isset($profile["fortune"]) && $profile["fortune"]) { $fortune = shell_exec("fortune -s -n 100"); echo "<div style=\"height:24px;margin:-14px auto 15px;position:relative;width:850px;\">"; echo "<img alt=\"left corner\" src=\"" . BASE . "images/new/cookiebar_left.png\" style=\"height:24px;left:0px;position:absolute;top:0px;width:10px;\" />"; echo "<div style=\"background-image:url(" . BASE . "images/new/cookiebar_mid.png);font-size:0.8em;height:24px;margin:-3px auto 0px;vertical-align:top;width:830px;\">" . $fortune . "</div>"; echo "<img alt=\"right corner\" src=\"" . BASE . "images/new/cookiebar_right.png\" style=\"height:24px;position:absolute;right:0px;top:0px;width:10px;\" />"; echo "</div>"; } // } }
function listUsers() { // rightscode is 'usr001'. // Preparation { $access = testRights($_SESSION["userid"], "usr001"); $editrights = "onclick=goTo('/Maxine/?pagerights&code=usr001')"; if ($_POST["conf"]) { $conf = $_POST["conf"]; } //$userlist = sqlPull(array("table"=>"users", "where"=>"isgeneric=0", "sort"=>$sortstr)); $users = new TableManager("users"); $users->setQueryFrom(array("left join" => array(0 => array("table" => array("abbr" => "user_profiles", "table" => "user_profiles"), "on" => "`user_profiles`.`id`=`users`.`user_profiles_id`")))); $users->setQueryColumns(array("users" => array("personid", "user_profiles_id", "username", "email", "extension", "cell", "isplace", "isgeneric", "deleted"), "user_profiles" => array("firstname", "lastname", "jobtitle", "staffno", "id", "birthday", "department_id", "location", "interests", "family", "aspirations", "goals", "quote", "createDate"))); // Building the Where string { $where = "`users`.`deleted`=0 AND personid!=1"; if ($conf["search"]["firstname"]) { $where .= $users->quoteString(" AND `user_profiles`.`firstname` like ?", "%" . $conf["search"]["firstname"] . "%"); } if ($conf["search"]["lastname"]) { $where .= $users->quoteString(" AND `user_profiles`.`lastname` like ?", "%" . $conf["search"]["lastname"] . "%"); } if ($conf["search"]["position"]) { $where .= $users->quoteString(" AND `user_profiles`.`jobtitle` like ?", "%" . $conf["search"]["position"] . "%"); } if ($conf["search"]["department"]) { $where .= $users->quoteString(" AND `user_profiles`.`department_id`=?", $conf["search"]["department"]); } // } $users->setWhere($where); // Building the Sort string { if ($conf["sortvar"]) { $sort = $conf["sortvar"]; } else { $sort = "1"; } if ($sort == 1) { $users->setOrderBy(array("column" => "firstname", "direction" => "ASC")); } else { if ($sort == 2) { $users->setOrderBy(array("column" => "firstname", "direction" => "DESC")); } else { if ($sort == 5) { $users->setOrderBy(array("column" => "jobtitle", "direction" => "ASC")); } else { if ($sort == 6) { $users->setOrderBy(array("column" => "jobtitle", "direction" => "DESC")); } else { if ($sort == 7) { $users->setOrderBy(array("column" => "department_id", "direction" => "DESC")); } else { if ($sort == 8) { $users->setOrderBy(array("column" => "department_id", "direction" => "ASC")); } } } } } } // } $userlist = $users->selectMultiple(); $deptlist = sqlPull(array("table" => "m3_departments", "where" => "1=1")); $reload = "userlistform.action=\"/Maxine/?listusers\"; userlistform.submit()'"; $mouseover = "onmouseover=\"this.style.backgroundImage='url(../../images/new/mainblack.png)';this.style.color='WHITE';\" onmouseout=\"this.style.backgroundImage='';this.style.color='BLACK';\""; // } maxineTop("Users"); print "<form name='userlistform' id='userlistform' action='/Maxine/?edituser' method='post'>"; // Buttons { openHeader(); if ($_SESSION["isit"] == 1 || $access > 0) { maxineButton("Add User", "goTo(\"/Maxine/?edituser\");", 2); maxineButton("Search", "toggle(\"searchdiv\");", 2); } maxineButton("Back", "history.go(-1);", 2); closeHeader(); // } print "<div class='tray'>"; // Search { print "<div id='searchdiv' style='display:none'>"; openSubbar(400); print "Search Box"; closeSubbar(); print "<table class='standard' style='width:400px;'>"; print "<tr class='content1'><td align='center' width=40%>"; print "First Name"; print "</td><td width=60% align='left'>"; print "<input name=conf[search][firstname] value='" . $conf["search"]["firstname"] . "' style='width:200px'>"; print "</td></tr>"; print "<tr class='content1'><td align='center'>"; print "Last Name"; print "</td><td align='left'>"; print "<input name=conf[search][lastname] value='" . $conf["search"]["lastname"] . "' style='width:200px;'"; print "</td></tr>"; print "<tr class='content1'><td align='center'>"; print "Department"; print "</td><td>"; print "<select name='conf[search][dept]' id='deptselect' style='z-index:500; width:180px; color:BLACK;'>"; print "<option value=0>- Select Department -</option>"; foreach ($deptlist as $deptkey => $deptval) { print "<option value=" . $deptval["id"] . " " . ($conf["search"]["dept"] == $deptval["id"] ? "selected" : "") . ">" . $deptval["name"] . "</option>"; } print "</select>"; print "</td></tr>"; print "<tr class='content1'><td align='center' colspan=2>"; maxineButton("Submit", $reload, 2); print "</td></tr>"; print "</table>"; print "</div>"; // } if ($_SESSION["isit"] == 1 || $access > 0) { if ($userlist) { // Hidden data controls { print "<input type='hidden' id='sorttype' name='conf[sortvar]' value=" . $conf["sortvar"] . ">"; print "<input type=hidden id='useridinput' name='conf[personid]'>"; // This variable is set to the selected users id, and then submitted with the form. // } openSubbar(800); print "<span " . $editrights . ">User List</span>"; closeSubbar(); print "<table class='standard' style='width:800px; margin-bottom:25px;'>"; // Headers { print "<tr class='heading'>"; print "<td align='center' width=45% onClick='sorttype.value=" . ($sort == 1 ? "2" : "1") . "; " . $reload . ">"; print "Name"; if ($sort == 1) { print "<img src='" . BASE . "/images/downarrow.png'>"; } else { if ($sort == 2) { print "<img src='" . BASE . "/images/uparrow.png'>"; } } print "</td>"; print "<td align='center' width=30% onClick='sorttype.value=" . ($sort == 5 ? "6" : "5") . "; " . $reload . ">"; print "Position"; if ($sort == 5) { print "<img src='" . BASE . "/images/downarrow.png'>"; } else { if ($sort == 6) { print "<img src='" . BASE . "/images/uparrow.png'>"; } } print "</td>"; print "<td align='center' width=25% onClick='sorttype.value=" . ($sort == 7 ? "8" : "7") . "; " . $reload . ">"; print "Department"; if ($sort == 7) { print "<img src='" . BASE . "/images/downarrow.png'>"; } else { if ($sort == 8) { print "<img src='" . BASE . "/images/uparrow.png'>"; } } print "</td></tr>"; // } $count = 1; foreach ($userlist as $userkey => $userval) { $bday = date("d", $userval['userdates']['birthday']['date']); $bmonth = date("m", $userval['userdates']['birthday']['date']); print "<tr class='content1' style='cursor:pointer' onclick='openUser(" . $userval["personid"] . ");' " . $mouseover . "><td align='center'>"; if ($userval["isgeneric"] < 1 && $userval["isplace"] < 1) { print $userval["firstname"] . " " . $userval["lastname"] . " (" . $userval["username"] . ")"; } else { print $userval["username"]; } if ($userval["user_profiles_id"] == 0 && $userval["isgeneric"] < 1 && $userval["isplace"] < 1) { print "<img src='" . BASE . "/images/redcross.png' title='No Profile'>"; } print "</td><td align='center'>"; print $userval["jobtitle"]; print "</td><td align='center'>"; if ($userval["department_id"] == 0 && $userval["isgeneric"] < 1 && $userval["isplace"] < 1) { print "No Department"; } else { print $deptlist[$userval["department_id"]]["name"]; } print "</td></tr>"; $count++; } print "</table>"; } else { print "<tr><td align='center'>"; print "No Users meet search."; print "</td></tr>"; } } else { print "<tr><td align='center'>"; print "You do not have access to this page."; } print "</div>"; closeTrayDiv(); print "</form>"; maxineBottom(); //$onclick = "personid.value=".$userval["personid"]."; userlistform.submit();"; // Javascript { print "<script>\n\t\t\t\t\tfunction openUser(userid) {\n\t\t\t\t\t\tdocument.getElementById('useridinput').value\t= userid;\n\t\t\t\t\t\tdocument.getElementById('userlistform').submit();\n\t\t\t\t\t}\n\t\t\t\t\t</script>"; // } }