/** Scaffold_Forms_GalleryItems::setHtml($html = null) * @param string $html HTML form definition */ public function setHtml($html = null) { if ($html === null) { $record = self::getRecord(); if (is_object("TableManager") === false) { include_once BASE . DIRECTORY_SEPARATOR . "basefunctions" . DIRECTORY_SEPARATOR . "baseapis" . DIRECTORY_SEPARATOR . "TableManager.php"; } $tableManager = new TableManager("gallery"); $tableManager->setWhere("ISNULL(`gallery`.`deleted`)" . $tableManager->quoteString(" OR `gallery`.`deleted`=?", (int) 0)); $gallery = $tableManager->selectMultiple(); $html = (string) "<script type=\"text/javascript\" src=\"" . BASE . DIRECTORY_SEPARATOR . "basefunctions" . DIRECTORY_SEPARATOR . "scripts" . DIRECTORY_SEPARATOR . "ajax_file_upload.js\"></script>" . PHP_EOL; $html .= "<noscript><p class=\"error\">I'm sorry but you need to enable javascript for this to work correctly.</p></noscript>" . PHP_EOL; $html .= "<form encoding=\"multipart/form-data\" enctype=\"multipart/form-data\" id=\"uploaderForm\" method=\"POST\" style=\"width:750px;\">" . PHP_EOL; $html .= "<div style=\"text-align:center;\">" . PHP_EOL; $html .= "<input type=\"submit\" value=\"Save\" style=\"background-color:transparent;background-image:url(" . BASE . "images/new/button.png);border:none;height:34px;width:114px;\" />" . PHP_EOL; $html .= "</div>" . PHP_EOL; $html .= "<label for=\"gallery_id\" style=\"color:#000;\">Gallery</label>" . PHP_EOL; $html .= "<select id=\"gallery_id\" name=\"gallery_id\">" . PHP_EOL; $html .= "<option value=\"0\">Please select...</options>" . PHP_EOL; foreach ($gallery as $gall) { $html .= "<option value=\"" . $gall["id"] . "\"" . ($record && $record["gallery_id"] == $gall["id"] ? " selected=\"selected\"" : "") . ">" . $gall["name"] . "</option>" . PHP_EOL; } $html .= "</select><br class=\"clear\" />" . PHP_EOL; ### File uploader | directory uploader $html .= "<fieldset style=\"float:left;margin-right:5px;width:" . ($record ? "97%" : "450px") . ";\">"; $html .= "<legend>Upload file(s)</legend>"; /* File uploader segment */ $html .= "<label for=\"uploadFile\" style=\"color:#000;\">Choose file....</label>"; $html .= "<input id=\"uploadFile\" name=\"uploadFile\" type=\"file\" />"; $html .= "<button id=\"uploadButton\" onclick=\"return ajaxFileUpload.startUpload('uploaderForm', this);\">Upload....</button>"; /* File uploader segment */ $html .= "</fieldset>"; if (!$record) { $html .= "<fieldset style=\"float:left;margin-right:5px;width:250px;\">"; $html .= "<legend>Search a directory</legend>"; $html .= "<label for=\"directory\" style=\"color:#000;\">Directory path</label>"; $html .= "<input id=\"directory\" name=\"directory\" type=\"text\" />"; $file = (string) substr(__DIR__, 0, strrpos(__DIR__, DIRECTORY_SEPARATOR) + 1) . "pastLocations.txt"; if (is_file($file)) { $data = file($file); if ($data) { $html .= "<ul style=\"list-style-position:outside;margin-left:20px;\">"; foreach ($data as $line) { $html .= "<li onclick=\"document.getElementById('directory').value = this.firstChild.nodeValue;\" style=\"cursor:pointer;\">" . $line . "</li>"; } $html .= "</ul>"; } } $html .= "</fieldset>"; } ### End $html .= "<br style=\"clear:both;\" /><br style=\"clear:both;\" /><div style=\"text-align:center;\">" . PHP_EOL; $html .= "<input type=\"submit\" value=\"Save\" style=\"background-color:transparent;background-image:url(" . BASE . "images/new/button.png);border:none;height:34px;width:114px;\" />" . PHP_EOL; $html .= "</div>" . PHP_EOL; $html .= "</form>"; $html .= "<script type=\"text/javascript\">\n ajaxFileUpload.setReturnDataFormat({\n name:'" . ($record ? "file" : "file[]") . "'\n });\n ajaxFileUpload.setLocation(\"/Maxine/gallery/\");\n ajaxFileUpload.enableForm('uploaderForm');\n </script>"; } $this->_html = $html; }
public function setHtml($html = null) { if (is_string($html) === false) { $html = null; } if ($html === null) { $departments = new TableManager("m3_departments"); $list = $departments->selectMultiple(); $type = new TableManager("type"); $type->setWhere($type->quoteString("`type`.`parent_id`=?", 9) . $type->quoteString(" OR `type`.`parent_id`=?", 12)); $list2 = $type->selectMultiple(); $html = (string) "<div class=\"standard content1\" style=\"margin-bottom:10px;width:500px;\">"; $html .= "<div onclick=\"toggle('scaffoldSearchForm');var text = (this.firstChild.nodeValue.match(/Display*/) ? 'Hide Search Form' : 'Display Search Form');clearAllElements(this);this.appendChild(document.createTextNode(text));\" style=\"cursor:pointer;text-align:center;\">"; $html .= "Display Search Form"; $html .= "</div>"; $html .= "<form id=\"scaffoldSearchForm\" method=\"POST\" style=\"display:none;\">"; $html .= "<label for=\"name\">Name</label>"; $html .= "<input id=\"name\" name=\"name\" type=\"text\" value=\"" . ($_POST ? $_POST["name"] : "") . "\" /><br />" . PHP_EOL; $html .= "<label for=\"location\">Location</label>"; $html .= "<input id=\"location\" name=\"location\" type=\"text\" value=\"" . ($_POST ? $_POST["location"] : "") . "\" /><br />" . PHP_EOL; $html .= "<label for=\"departments_id\">Department</label>"; $html .= "<select id=\"departments_id\" name=\"departments_id\">"; $html .= "<option value=\"0\">Please select..</option>"; foreach ($list as $val) { $html .= "<option" . ($_POST && $val["id"] == $_POST["departments_id"] ? " selected=\"selected\"" : "") . " value=\"" . $val["id"] . "\">" . $val["name"] . "</option>"; } $html .= "</select><br />"; $html .= "<label for=\"type_id\">Type</label>"; $html .= "<select id=\"type_id\" name=\"type_id\">"; $html .= "<option value=\"0\">Please select..</option>"; foreach ($list2 as $val) { $html .= "<option" . ($_POST && $val["id"] == $_POST["type_id"] ? " selected=\"selected\"" : "") . " value=\"" . $val["id"] . "\">" . $val["name"] . "</option>"; } $html .= "</select><br />"; $html .= "<label for=\"deleted\">Include deleted?</label>"; $html .= "<input" . ($_POST && $_POST["deleted"] ? " checked=\"checked\"" : "") . " id=\"deleted\" name=\"deleted\" type=\"checkbox\" value=\"1\" />" . PHP_EOL; $html .= "</form>"; $html .= "</div>" . PHP_EOL; } $this->_html = $html; }
/** Scaffold_Forms_Documents::setHtml($html = null) * @param string $html HTML form definition */ public function setHtml($html = null) { if ($html === null) { $record = self::getRecord(); if (is_object("TableManager") === false) { include_once BASE . DIRECTORY_SEPARATOR . "basefunctions" . DIRECTORY_SEPARATOR . "baseapis" . DIRECTORY_SEPARATOR . "TableManager.php"; } $tableManager = new TableManager("m3_departments"); $tableManager->setWhere($tableManager->quoteString("`display`=?", 1)); $departments = $tableManager->selectMultiple(); $tableManager = new TableManager("type"); $tableManager->setWhere("ISNULL(`deleted`)"); $types = $tableManager->selectMultiple(); $html = (string) "<script type=\"text/javascript\" src=\"" . BASE . DIRECTORY_SEPARATOR . "basefunctions" . DIRECTORY_SEPARATOR . "scripts" . DIRECTORY_SEPARATOR . "ajax_file_upload.js\"></script>" . PHP_EOL; $html .= "<noscript><p class=\"error\">I'm sorry but you need to enable javascript for this to work correctly.</p></noscript>" . PHP_EOL; $html .= "<form method=\"POST\" id=\"uploaderForm\">" . PHP_EOL; $html .= "<div style=\"text-align:center;\">" . PHP_EOL; $html .= "<input type=\"submit\" value=\"Save\" style=\"background-color:transparent;background-image:url(" . BASE . "images/new/button.png);border:none;height:34px;width:114px;\" />" . PHP_EOL; $html .= "</div>" . PHP_EOL; $html .= "<label for=\"departments_id\" style=\"color:#000;\">Department</label>" . PHP_EOL; $html .= "<select id=\"departments_id\" name=\"departments_id\">" . PHP_EOL; $html .= "<option value=\"0\">Please select...</options>" . PHP_EOL; foreach ($departments as $dept) { $html .= "<option value=\"" . $dept["id"] . "\"" . ($record && $record["department_id"] == $dept["id"] ? " selected=\"selected\"" : "") . ">" . $dept["name"] . "</option>" . PHP_EOL; } $html .= "</select><br class=\"clear\" />" . PHP_EOL; $html .= "<label for=\"type_id\" style=\"color:#000;\">Document type</label>" . PHP_EOL; $html .= "<select id=\"type_id\" name=\"type_id\">" . PHP_EOL; $html .= "<option value=\"0\">Please select...</options>" . PHP_EOL; if ($types && is_array($types)) { foreach ($types as $type) { $html .= "<option value=\"" . $type["id"] . "\"" . ($record && $record["type_id"] == $type["id"] ? " selected=\"selected\"" : "") . ">" . $type["name"] . "</option>" . PHP_EOL; } } $html .= "</select><br class=\"clear\" />" . PHP_EOL; $html .= "<label for=\"name[0]\" style=\"color:#000;\">Name</label>" . PHP_EOL; $html .= "<input type=\"text\" class=\"standard\" id=\"name[0]\" name=\"name\" readonly=\"readonly\" value=\"" . ($record ? $record["name"] : "") . "\" /><br />" . PHP_EOL; $html .= "<label for=\"location_file\" style=\"color:#000;\">Location</label>" . PHP_EOL; $location = (string) "documents/"; $html .= "<input type=\"file\" id=\"location_file\" name=\"location_file\" readonly=\"readonly\" onchange=\"document.getElementById('name[0]').value = this.value.toString().substring(0, this.value.toString().lastIndexOf('.'));\" />" . PHP_EOL; $html .= "<input type=\"hidden\" name=\"location\" id=\"location\" />" . PHP_EOL; $html .= "<button onclick=\"ajaxFileUpload.doUpload('" . $location . "', 'location', 'location_file'); return false;\">Upload</button>" . PHP_EOL; $html .= "<br />" . PHP_EOL; $html .= "<div style=\"text-align:center;\">" . PHP_EOL; $html .= "<input type=\"submit\" value=\"Save\" style=\"background-color:transparent;background-image:url(" . BASE . "images/new/button.png);border:none;height:34px;width:114px;\" />" . PHP_EOL; $html .= "</div>" . PHP_EOL; $html .= "</form>" . PHP_EOL; //$html .= "<iframe id=\"targetFrame\" name=\"targetFrame\"></iframe>".PHP_EOL; $html .= "<iframe id=\"targetFrame\" name=\"targetFrame\" style=\"display:none;\"></iframe>" . PHP_EOL; $html .= "<p id=\"upload_process\" style=\"display:none;\"><img src=\"" . BASE . DIRECTORY_SEPARATOR . "images" . DIRECTORY_SEPARATOR . "loading.gif\" alt=\"Loading\" title=\"Please be patient. Uploading your file can take a bit of time\" /></p>" . PHP_EOL; } $this->_html = $html; }
/** Scaffold_Forms_Pages::setHtml($html = null) * @param string $html HTML form definition */ public function setHtml($html = null) { if ($html === null) { $record = self::getRecord(); $tableManager = new TableManager("m3_departments"); $tableManager->setWhere($tableManager->quoteString("`display`=?", 1)); $departments = $tableManager->selectMultiple(); $tableManager = new TableManager("pages"); $tableManager->setWhere($tableManager->quoteString("(ISNULL(`pages`.`deleted`) OR `pages`.`deleted`=?)", (int) 0)); $pages = $tableManager->selectMultiple(); $tableManager = new TableManager("type"); $tableManager->setWhere("ISNULL(`deleted`)"); $pagetypes = $tableManager->selectMultiple(); $html = (string) "<script type=\"text/javascript\" src=\"http://" . $_SERVER["SERVER_NAME"] . "/basefunctions/scripts/nicEdit.js\"></script>" . PHP_EOL; $html .= "<form method=\"POST\">" . PHP_EOL; $html .= "<div style=\"text-align:center;\">" . PHP_EOL; $html .= "<input type=\"submit\" value=\"Save\" style=\"background-color:transparent;background-image:url(" . BASE . "images/new/button.png);border:none;height:34px;width:114px;\" />" . PHP_EOL; $html .= "</div>" . PHP_EOL; $html .= "<label for=\"name\" style=\"color:#000;\">Name</label>" . PHP_EOL; $html .= "<input type=\"text\" id=\"name\" name=\"name\" value=\"" . ($record ? $record["name"] : "") . "\" /><br />" . PHP_EOL; $html .= "<label for=\"departments_id\" style=\"color:#000;\">Department</label>" . PHP_EOL; $html .= "<select id=\"departments_id\" name=\"departments_id\">" . PHP_EOL; $html .= "<option value=\"0\">Please select...</options>" . PHP_EOL; foreach ($departments as $dept) { $html .= "<option value=\"" . $dept["id"] . "\"" . ($record && $record["departments_id"] == $dept["id"] ? " selected=\"selected\"" : "") . ">" . $dept["name"] . "</option>" . PHP_EOL; } $html .= "</select><br class=\"clear\" />" . PHP_EOL; $html .= "<label for=\"type_id\" style=\"color:#000;\">Page type</label>" . PHP_EOL; $html .= "<select id=\"type_id\" name=\"type_id\">" . PHP_EOL; $html .= "<option value=\"0\">Please select...</options>" . PHP_EOL; foreach ($pagetypes as $type) { $html .= "<option value=\"" . $type["id"] . "\"" . ($record && $record["type_id"] == $type["id"] ? " selected=\"selected\"" : "") . ">" . $type["name"] . "</option>" . PHP_EOL; } $html .= "</select><br class=\"clear\" />" . PHP_EOL; $html .= "<label for=\"parent_id\" style=\"color:#000;\">Parent page</label>" . PHP_EOL; $html .= "<select id=\"parent_id\" name=\"parent_id\">" . PHP_EOL; $html .= "<option value=\"0\">Please select...</options>" . PHP_EOL; foreach ($pages as $page) { $html .= "<option value=\"" . $page["id"] . "\"" . ($record && $record["parent_id"] == $page["id"] ? " selected=\"selected\"" : "") . ">" . $page["name"] . "</option>" . PHP_EOL; } $html .= "</select><br class=\"clear\" />" . PHP_EOL; $html .= "<label for=\"content\" style=\"color:#000;\">Content</label><br style=\"clear:both;\" />" . PHP_EOL; $html .= "<textarea id=\"content\" name=\"content\" style=\"height:200px;width:400px;\">" . ($record ? $record["content"] : "") . "</textarea><br />" . PHP_EOL; $html .= "<div style=\"text-align:center;\">" . PHP_EOL; $html .= "<input type=\"submit\" value=\"Save\" style=\"background-color:transparent;background-image:url(" . BASE . "images/new/button.png);border:none;height:34px;width:114px;\" />" . PHP_EOL; $html .= "</div>" . PHP_EOL; $html .= "</form>" . PHP_EOL; $html .= "<iframe id=\"frameLoader\" style=\"display:none;\"> </iframe>"; $html .= "<script type=\"text/javascript\">document.getElementById('frameLoader').onload = function () {\n var content = new nicEditor({\n uploadURI: 'http://" . $_SERVER["SERVER_NAME"] . "/Maxine/scaffold/nicUpload.php',\n fullPanel: true\n }).panelInstance('content',{hasPanel : true})\n }</script>" . PHP_EOL; } $this->_html = $html; }
/** Scaffold_Forms_Documents::setHtml($html = null) * @param string $html HTML form definition */ public function setHtml($html = null) { if ($html === null) { $record = self::getRecord(); if (is_object("TableManager") === false) { include_once BASE . DIRECTORY_SEPARATOR . "basefunctions" . DIRECTORY_SEPARATOR . "baseapis" . DIRECTORY_SEPARATOR . "TableManager.php"; } $tableManager = new TableManager("m3_departments"); $departments = $tableManager->selectMultiple(); $tableManager = new TableManager("type"); $tableManager->setWhere($tableManager->quoteString("(ISNULL(`deleted`) OR `deleted`=?)", (int) 0)); $types = $tableManager->selectMultiple(); $html = (string) "<script type=\"text/javascript\" src=\"" . BASE . DIRECTORY_SEPARATOR . "basefunctions" . DIRECTORY_SEPARATOR . "scripts" . DIRECTORY_SEPARATOR . "ajax_file_upload.js\"></script>" . PHP_EOL; $html .= "<noscript><p class=\"error\">I'm sorry but you need to enable javascript for this to work correctly.</p></noscript>" . PHP_EOL; $html .= "<form encoding=\"multipart/form-data\" enctype=\"multipart/form-data\" id=\"uploaderForm\" method=\"POST\">" . PHP_EOL; $html .= "<div style=\"text-align:center;\">" . PHP_EOL; $html .= "<input type=\"submit\" value=\"Save\" style=\"background-color:transparent;background-image:url(" . BASE . "images/new/button.png);border:none;height:34px;width:114px;\" />" . PHP_EOL; $html .= "</div>" . PHP_EOL; $html .= "<label for=\"departments_id\" style=\"color:#000;\">Department</label>" . PHP_EOL; $html .= "<select id=\"departments_id\" name=\"departments_id\">" . PHP_EOL; $html .= "<option value=\"0\">Please select...</options>" . PHP_EOL; foreach ($departments as $dept) { $html .= "<option value=\"" . $dept["id"] . "\"" . ($record && $record["departments_id"] == $dept["id"] ? " selected=\"selected\"" : "") . ">" . $dept["name"] . "</option>" . PHP_EOL; } $html .= "</select><br class=\"clear\" />" . PHP_EOL; $html .= "<label for=\"type_id\" style=\"color:#000;\">Document type</label>" . PHP_EOL; $html .= "<select id=\"type_id\" name=\"type_id\">" . PHP_EOL; $html .= "<option value=\"0\">Please select...</options>" . PHP_EOL; if ($types && is_array($types)) { foreach ($types as $type) { $html .= "<option value=\"" . $type["id"] . "\"" . ($record && $record["type_id"] == $type["id"] ? " selected=\"selected\"" : "") . ">" . $type["name"] . "</option>" . PHP_EOL; } } $html .= "</select><br class=\"clear\" />" . PHP_EOL; /* File uploader segment */ $html .= "<label for=\"uploadFile\" style=\"color:#000;\">Choose file....</label>"; $html .= "<input id=\"uploadFile\" name=\"uploadFile\" type=\"file\" />"; $html .= "<button id=\"uploadButton\" onclick=\"return ajaxFileUpload.startUpload('uploaderForm', this);\">Upload....</button>"; /* File uploader segment */ $html .= "<br style=\"clear:both;\" /><div style=\"text-align:center;\">" . PHP_EOL; $html .= "<input type=\"submit\" value=\"Save\" style=\"background-color:transparent;background-image:url(" . BASE . "images/new/button.png);border:none;height:34px;width:114px;\" />" . PHP_EOL; $html .= "</div>" . PHP_EOL; $html .= "</form>" . PHP_EOL; $html .= "<script type=\"text/javascript\">\n ajaxFileUpload.setReturnDataFormat({\n name:'" . ($record ? "location" : "location[]") . "'\n });\n ajaxFileUpload.setLocation(\"/Maxine/documents/\");\n ajaxFileUpload.enableForm('uploaderForm');\n </script>"; } $this->_html = $html; }
/** displayFleetKmsTable($fleet_id, array $conf) * display a fleet kms table correctly * @param int $fleet_id * @param array $conf * @return string $html */ function displayFleetKmsTable($fleet_id, array $conf) { /* print '<pre style="color:#FFF">'; print_r($conf); print '</pre>'; */ $mtddays = getFleetBudgetDays((int) $fleet_id, NULL, NULL); $monthenddays = getFleetBudgetDays((int) $fleet_id, NULL, mktime(0, 0, 0, date("m"), date("t"), date("Y"))); $manager = new TableManager("fleet_scores"); $sql = (string) "SELECT * FROM `fleet_scores` WHERE "; $sql .= $manager->quoteString("`fleetid`=?", (int) $fleet_id); $sql .= $manager->quoteString(" AND `date`>=?", mktime(0, 0, 0, date("m"), 1, date("Y"))); $sql .= $manager->quoteString(" AND `date`<=?", mktime(0, 0, 0, date("m"), date("t"), date("Y"))); if (($results = $manager->runSql($sql)) === FALSE) { return FALSE; } $monthendbudget = (int) 0; foreach ($results as $val) { if (isset($val["budget"]) && $val["budget"] > 0) { $monthendbudget += $val["budkms"]; } } unset($results); $data = array("cd_actual" => array_key_exists("kms", $conf) ? $conf["kms"] : 0, "cd_budget" => array_key_exists("budkms", $conf) ? $conf["budkms"] : 0); $data["cd_variance"] = array_key_exists("cd_actual", $data) && array_key_exists("cd_budget", $data) ? (string) round($data["cd_actual"] - $data["cd_budget"], 0) : "-"; $data["cd_percent"] = array_key_exists("cd_actual", $data) && array_key_exists("cd_budget", $data) && $data["cd_budget"] > 0 ? (string) round($data["cd_actual"] / $data["cd_budget"] * 100, 0) : "-"; $data["mtd_actual"] = array_key_exists("totkms", $conf) && $conf["truck_count"] && $mtddays > 0 ? (string) round($conf["totkms"] / $mtddays / $conf["truck_count"], 0) : "-"; $data["mtd_budget"] = array_key_exists("totbudkms", $conf) && $conf["truck_count"] && $mtddays > 0 ? (string) round($conf["totbudkms"] / $mtddays / $conf["truck_count"], 0) : "-"; $data["mtd_variance"] = array_key_exists("mtd_actual", $data) && array_key_exists("mtd_budget", $data) ? (string) round($data["mtd_actual"] - $data["mtd_budget"], 0) : "-"; $data["mtd_percent"] = array_key_exists("mtd_actual", $data) && array_key_exists("mtd_budget", $data) && $data["mtd_budget"] > 0 ? (string) round($data["mtd_actual"] / $data["mtd_budget"] * 100, 0) : "-"; $data["mef_actual"] = array_key_exists("mtd_actual", $data) && $mtddays > 0 && $monthenddays > 0 ? (string) round($data["mtd_actual"] * $monthenddays, 0) : "-"; if (isset($monthendbudget) && $monthendbudget > 0) { $data["mef_budget"] = array_key_exists("truck_count", $conf) && $conf["truck_count"] > 0 ? (string) round($monthendbudget / $conf["truck_count"], 0) : "-"; } else { $data["mef_budget"] = array_key_exists("mtd_budget", $data) && $mtddays > 0 && $monthenddays > 0 ? (string) round($data["mtd_budget"] * $monthenddays, 0) : "-"; } $data["mef_variance"] = array_key_exists("mef_actual", $data) && array_key_exists("mef_budget", $data) ? (string) round($data["mef_actual"] - $data["mef_budget"], 0) : "-"; $data["mef_percent"] = array_key_exists("mef_actual", $data) && array_key_exists("mef_budget", $data) && $data["mef_budget"] > 0 ? (string) round($data["mef_actual"] / $data["mef_budget"] * 100, 0) : "-"; /* print '<pre style="color:#FFF">'; print_r($data); print '</pre>'; */ $vars = (string) ""; foreach ($data as $key => $val) { $vars .= $key . "=" . $val . "&"; } $vars = substr($vars, 0, -1); $object = embedObject("/images/kms_table.swf", array("FlashVars" => $vars, "height" => round(164 * $conf["factor"], 0), "name" => "kms_table", "width" => round(850 * $conf["factor"], 0)), TRUE); //return $object; return $data; }
function exportFleetScoreUpdates() { require_once BASE . 'basefunctions/baseapis/PHPExcel/php-excel.class.php'; $manager = new TableManager("fleet_scores"); $data = __sanitizeData($_GET); $where = (string) "1=1"; if (isset($data["fleet"]) && $data["fleet"]) { $where .= $manager->quoteString(" AND `fleetid`=?", (int) $data["fleet"]); } if (isset($data["start"]) && $data["start"]) { $where .= $manager->quoteString(" AND `date`>=?", (int) unixDate($data["start"])); } if (isset($data["end"]) && $data["end"]) { $where .= $manager->quoteString(" AND `date`<=?", (int) unixDate($data["end"])); } $manager->setWhere($where); $manager->setOrderBy(array("column" => "date")); $records = $manager->selectMultiple(); $rows = returnFleetTruckCount(); $xlsdata = (array) array(); $fleetdayobj = new fleetDayHandler(); $tempfleetlist = $fleetdayobj->getIncomeFleets(); $fleetlist = array(); foreach ($tempfleetlist as $tempkey => $tempval) { $fleetlist[$tempval["id"]] = $tempval; } unset($tempfleetlist); unset($fleetdayobj); $row = (array) array("Date", "Fleet", "Income budget", "Income", "Contribution budget", "Contribution", "Truck count", "Kms", "Ave. Kms per truck", "Budget Ave. Kms per truck"); $xlsdata[] = $row; foreach ($records as $val) { $row = (array) array(date("Y-m-d", $val["date"]), $fleetlist[$val["fleetid"]]["name"], $val["budget"], $val["income"], $val["budgetcontrib"], $val["contrib"], $rows[$val["fleetid"]]["count"], $val["kms"], round($val["kms"] / (isset($rows[$val["fleetid"]]) && isset($rows[$val["fleetid"]]["count"]) ? $rows[$val["fleetid"]]["count"] : 1), 2), round($val["budkms"] / (isset($rows[$val["fleetid"]]) && isset($rows[$val["fleetid"]]["count"]) ? $rows[$val["fleetid"]]["count"] : 1), 2)); $xlsdata[] = $row; } $xls = new Excel_XML('UTF-8', TRUE); $xls->addArray($xlsdata); $xls->generateXML('fleet_score_data'); }
public function __construct() { $manager = new TableManager("user_profiles"); echo "<link href=\"http://" . $_SERVER["SERVER_NAME"] . "/basefunctions/scripts/manline.css\" media=\"all\" rel=\"stylesheet\" type=\"text/css\" />" . PHP_EOL; echo "<p class=\"standard\">" . PHP_EOL; echo "Update current records to be integer based instead of string based<br />" . PHP_EOL; $list = $manager->selectMultiple(); foreach ($list as $key => $val) { if (!$val["birthday"]) { continue; } $manager->setWhere($manager->quoteString("`user_profiles`.`id`=?", $val["id"])); $data = (array) array(); $split = preg_split("/\\s/", $val["birthday"]); $data["birthday"] = mktime(0, 0, 0, date("m", strtotime("01-" . $split[1] . "-2011")), $split[0], 2011); if ($manager->update($data) === false) { echo "<span style=\"color:#F00;\" title=\"Update failed\">|</span>" . PHP_EOL; return false; } echo "<span style=\"color:#FFF;\" title=\"Update successful\">|</span>" . PHP_EOL; $manager->setWhere(""); ## TOCTOU Race condition ## } echo "<br />Update table so that the birthday column is an integer column<br />" . PHP_EOL; $sql = (string) "alter table user_profiles modify column birthday int(50) not null default '0',add index (`birthday`);"; if ($manager->runSql($sql) === false) { echo "<echo style=\"color:#FFF;\">" . PHP_EOL; print_r($manager->getErrors()); echo "</pre>" . PHP_EOL; return false; } echo "<br />Get list of users<br />" . PHP_EOL; $sql = (string) "SELECT * FROM `users` WHERE `deleted`='0'"; if (($list = $manager->runSql($sql)) === false) { echo "<echo style=\"color:#FFF;\">" . PHP_EOL; print_r($manager->getErrors()); echo "</pre>" . PHP_EOL; return false; } echo "<br />Loop through and get the userdates entry for birthday and update the user_profiles table.<br />" . PHP_EOL; foreach ($list as $key => $val) { if (!$val["user_profiles_id"]) { continue; } $sql = (string) "SELECT * FROM `userdates` WHERE `userid`='" . $val["personid"] . "' AND `datetype`='birthday' LIMIT 1"; if (($row = $manager->runSql($sql)) === false) { echo "<echo style=\"color:#FFF;\">" . PHP_EOL; print_r($manager->getErrors()); echo "</pre>" . PHP_EOL; return false; } $manager->setWhere($manager->quoteString("`user_profiles`.`id`=?", $val["user_profiles_id"])); $data = (array) array(); $birthday = date("Y-m-d", $row[0]["date"]); $split = preg_split("/\\-/", $birthday); $data["birthday"] = strtotime("1971-" . $split[1] . "-" . $split[2]); if ($manager->update($data) === false) { echo "<span style=\"color:#F00;\" title=\"Update failed\">|</span>" . PHP_EOL; return false; } echo "<span style=\"color:#FFF;\" title=\"Update successful\">|</span>" . PHP_EOL; $manager->setWhere(""); ## TOCTOU Race condition ## } echo "<br />Get any records form the user_profiles table where the birthday year isn't 1971<br />" . PHP_EOL; $manager->setWhere($manager->quoteString("DATE_FORMAT(FROM_UNIXTIME(`user_profiles`.`birthday`), '%Y')!=?", 1971)); $list = $manager->selectMultiple(); foreach ($list as $key => $val) { $manager->setWhere($manager->quoteString("`user_profiles`.`id`=?", $val["id"])); $date = date("Y-m-d", $val["birthday"]); $split = preg_split("/\\-/", $date); $data = (array) array("birthday" => strtotime("1971-" . $split[1] . "-" . $split[2])); if ($manager->update($data) === false) { echo "<span style=\"color:#F00;\" title=\"Update failed\">|</span>" . PHP_EOL; return false; } echo "<span style=\"color:#FFF;\" title=\"Update successful\">|</span>" . PHP_EOL; $manager->setWhere(""); ## TOCTOU Race condition ## } }
/** Scaffold_Forms_User_profiles::setHtml($html = null) * @param string $html HTML form definition */ public function setHtml($html = NULL) { ## Preparation $record = $this->getRecord(); if (is_object("TableManager") === false) { include_once BASE . DIRECTORY_SEPARATOR . "basefunctions" . DIRECTORY_SEPARATOR . "baseapis" . DIRECTORY_SEPARATOR . "TableManager.php"; } $tableManager = new TableManager("m3_departments"); $departments = $tableManager->selectMultiple(); $sql = (string) "SELECT * FROM `themes` WHERE (ISNULL(`deleted`) OR `deleted`=0)"; $themes = $tableManager->runSql($sql); $users = new TableManager("users"); $metaData = $users->getMetaData(); if ($record) { $users->setChildRecords(true); $users->setChildTables(array(0 => array("rights_users" => "rights_users", "where" => "`rights_users`.`userid`=?"))); $users->setWhere($users->quoteString("`users`.`user_profiles_id`=?", (int) $record["id"])); $user = $users->selectSingle(); } $sql = (string) "SELECT * FROM `rights_groups` WHERE 1=1;"; $rights_groups = $users->runSql($sql); $locations = (array) array(0 => array("name" => "Head Office"), 1 => array("name" => "Durban"), 2 => array("name" => "Empangeni"), 3 => array("name" => "East London"), 4 => array("name" => "Kokstad"), 5 => array("name" => "Pietermaritzburg"), 6 => array("name" => "Newcastle"), 7 => array("name" => "Vanderbijl Park"), 8 => array("name" => "Isando"), 9 => array("name" => "Germiston"), 10 => array("name" => "Cape Town"), 11 => array("name" => "Wilmar Depot"), 12 => array("name" => "Sasolburg"), 13 => array("name" => "Boksburg"), 14 => array("name" => "Port Elizabeth"), 15 => array("name" => "Delmas"), 16 => array("name" => "Slurry"), 17 => array("name" => "Hercules"), 18 => array("name" => "Heriotdale")); ## End if (is_string($html) === FALSE) { $html = NULL; } if ($html === NULL) { $html = (string) "<style type=\"text/css\">"; $html .= "#buttons{padding:5px 30px;text-align:right;}"; $html .= "#content{padding:10px 15px;text-align:left;}"; $html .= "#tabs{background-color:#ebf0ea;}"; $html .= "#tabImages{margin:0px auto;}"; $html .= "#userProfile{background-color:#bccdba;font:13px/1.22 Arial,Helvetica,sans-serif;margin:0px;padding:0px;width:100%;}"; $html .= ".lbl{color:#000;margin:2px 0px 19px;padding:0px;width:auto;}"; $html .= ".lblcb{color:#000;margin-bottom:15px;margin-top:0px;padding:0px;width:auto;}"; $html .= ".pc{display:inline-block;float:left;margin-right:15px;text-align:left;width:auto;}"; $html .= ".tablImages{cursor:pointer;height:39px;padding:10px 15px;width:44px;}"; $html .= ".tablImages:first-child{background-color:#FFF;}"; $html .= "input,select,textarea{background-color:#FFF;border:1px solid #999;margin:0px 0px 15px;padding:0px;width:100%;}"; $html .= "input[type=checkbox],input[type=radio]{width:auto;}"; $html .= "textarea{height:54px;}"; $html .= "</style>" . PHP_EOL; $html .= "<form enctype=\"multipart/form-data\" id=\"userProfile\" method=\"POST\">"; if (isset($user) && isset($user["personid"])) { $html .= "<input name=\"personid\" type=\"hidden\" value=\"" . $user["personid"] . "\" />"; } $html .= "<div id=\"tabs\"><span id=\"tabImages\">"; ## Mouse Events $mouse_events = (string) "onclick=\"up.mouse(this, event);\" onmouseout=\"up.mouse(this, event);\" onmouseover=\"up.mouse(this, event);\""; $html .= "<img alt=\"profile\" class=\"tablImages\" " . $mouse_events . " src=\"" . BASE . "images/new/icon-profile.png\" />"; $html .= "<img alt=\"communication\" class=\"tablImages\" " . $mouse_events . " src=\"" . BASE . "images/new/icon-communication.png\" />"; $html .= "<img alt=\"login\" class=\"tablImages\" " . $mouse_events . " src=\"" . BASE . "images/new/icon-login.png\" />"; if (isset($_SESSION["isit"]) && $_SESSION["isit"]) { $html .= "<img alt=\"flags\" class=\"tablImages\" " . $mouse_events . " src=\"" . BASE . "images/new/icon-flags.png\" />"; $html .= "<img alt=\"accessgroups\" class=\"tablImages\" " . $mouse_events . " src=\"" . BASE . "images/new/icon-accessgroups.png\" />"; } $html .= "</span></div>"; $html .= "<div id=\"content\">"; ## Profile $html .= "<div id=\"profile\">"; $html .= "<span class=\"pc\">"; ## labels $html .= "<label class=\"lbl\" for=\"staffno\">Staff Number</label><br />"; $html .= "<label class=\"lbl\" for=\"firstname\">First name</label><br />"; $html .= "<label class=\"lbl\" for=\"lastname\">Last name</label><br />"; $html .= "<label class=\"lbl\" for=\"jobtitle\">Job Title</label><br />"; $html .= "<label class=\"lbl\" for=\"department_id\" style=\"margin-bottom:21px;\">Department</label><br />"; $html .= "<label class=\"lbl\" for=\"location\">Location</label><br />"; $html .= "<label class=\"lbl\" for=\"day\" style=\"margin-bottom:21px;\">Birthday</label><br />"; if (isset($_SESSION["isit"]) && $_SESSION["isit"]) { $html .= "<label class=\"lbl\" for=\"image_file\">Image</label><br />" . PHP_EOL; } $html .= "<label class=\"lbl\" for=\"fortune\" title=\"Would you like a fortune cookie to be displayed on each page?\">Fortune</label><br />"; $html .= "<label class=\"lbl\" for=\"theme_id\">Theme</label><br />"; $html .= "</span>"; $html .= "<span class=\"pc\" style=\"margin-right:30px;text-align:left;width:32%;\">"; ## inputs $html .= "<input id=\"staffno\" name=\"staffno\" " . (isset($record) && isset($record["staffno"]) ? "readonly=\"readonly\" " : "") . " type=\"text\" value=\"" . (isset($record) && isset($record["staffno"]) ? $record["staffno"] : "") . "\">"; $html .= "<input id=\"firstname\" name=\"firstname\" type=\"text\" value=\"" . (isset($record) && isset($record["firstname"]) ? $record["firstname"] : "") . "\">"; $html .= "<input id=\"lastname\" name=\"lastname\" type=\"text\" value=\"" . (isset($record) && isset($record["lastname"]) ? $record["lastname"] : "") . "\">"; $html .= "<input id=\"jobtitle\" name=\"jobtitle\" type=\"text\" value=\"" . (isset($record) && isset($record["jobtitle"]) ? $record["jobtitle"] : "") . "\" />"; $html .= "<select id=\"department_id\" name=\"department_id\">"; $html .= "<option value=\"0\">Please select...</options>"; foreach ($departments as $dept) { $html .= "<option value=\"" . $dept["id"] . "\"" . (isset($record) && isset($record["department_id"]) && $record["department_id"] == $dept["id"] ? " selected=\"selected\"" : "") . ">" . $dept["name"] . "</option>"; } $html .= "</select>"; $html .= "<select id=\"location\" name=\"location\">"; foreach ($locations as $location) { $html .= "<option " . (isset($record) && isset($record["location"]) && $record["location"] == $location["name"] ? "selected=\"selected\" " : "") . "value=\"" . $location["name"] . "\">" . $location["name"] . "</option>"; } $html .= "</select>"; $html .= "<select id=\"day\" name=\"day\" style=\"float:left;margin-bottom:15px;margin-right:15px;width:60px;\">"; $html .= "<option value=\"0\">Day</option>"; for ($i = 1; $i < 32; $i++) { $html .= "<option " . (isset($record) && isset($record["birthday"]) && date("d", $record["birthday"]) == $i ? "selected=\"selected\" " : "") . "value=\"" . (strlen($i) == 1 ? "0" . $i : $i) . "\">" . (strlen($i) == 1 ? "0" . $i : $i) . "</option>"; } $html .= "</select>"; $html .= "<select id=\"month\" name=\"month\" style=\"float:left;width:120px;\">"; $html .= "<option value=\"0\">Month</option>"; for ($i = 1; $i < 13; $i++) { $html .= "<option " . (isset($record) && isset($record["birthday"]) && date("F", $record["birthday"]) == date("F", mktime(0, 0, 0, $i, 1, 2000)) ? "selected=\"selected\" " : "") . "value=\"" . date("m", mktime(0, 0, 0, $i, 1, 2000)) . "\">" . date("F", mktime(0, 0, 0, $i, 1, 2000)) . "</option>"; } $html .= "</select>"; if (isset($_SESSION["isit"]) && $_SESSION["isit"]) { $html .= "<input type=\"file\" id=\"image_file\" name=\"image\" size=\"15\" />"; } $html .= "<input" . (isset($record) && isset($record["fortune"]) && $record["fortune"] ? " checked=\"checked\"" : "") . " id=\"fortune\" name=\"fortune\" type=\"checkbox\" value=\"1\" /><br class=\"clear\" />"; $html .= "<input id=\"theme_id\" name=\"theme_id\" type=\"hidden\" value=\"" . (isset($record) && isset($record["theme_id"]) ? $record["theme_id"] : "") . "\" />"; $i = (int) 0; $html .= "<div>"; foreach (is_array($themes) ? $themes : array() as $theme) { $html .= "<img alt=\"theme\" onclick=\"up.resetBorders(this);document.getElementById('theme_id').value='" . $theme["id"] . "';\" src=\"" . BASE . "images/new/themes/" . $theme["background-image"] . "\" style=\"border:1px solid #" . (isset($record) && isset($record["theme_id"]) && $record["theme_id"] === $theme["id"] ? "F00" : "000") . ";cursor:pointer;height:30px;margin:5px;width:30px;\" />"; $i++; if ($i === 3) { $i = 0; $html .= "<br class=\"clear\" />"; } } $html .= "</div><br class=\"clear\" >"; $html .= "</span>"; $html .= "<span class=\"pc\">"; ## labels $html .= "<label class=\"lbl\" for=\"family\" style=\"margin-bottom:56px;\">Family</label><br class=\"clear\" />"; $html .= "<label class=\"lbl\" for=\"goals\" style=\"margin-bottom:56px;\">Goals</label><br class=\"clear\" />"; $html .= "<label class=\"lbl\" for=\"interests\" style=\"margin-bottom:56px;\">Interests</label><br class=\"clear\" />"; $html .= "<label class=\"lbl\" for=\"aspirations\" style=\"margin-bottom:56px;\">Aspirations</label><br class=\"clear\" />"; $html .= "<label class=\"lbl\" for=\"quote\" style=\"margin-bottom:56px;\">Quote</label><br class=\"clear\" />"; $html .= "</span>"; $html .= "<span class=\"pc\" style=\"width:32%;\">"; ## inputs $html .= "<textarea id=\"family\" name=\"family\">" . ($record ? $record["family"] : "") . "</textarea><br class=\"clear\" />"; $html .= "<textarea id=\"goals\" name=\"goals\">" . ($record ? $record["goals"] : "") . "</textarea><br />"; $html .= "<textarea id=\"interests\" name=\"interests\">" . ($record ? $record["interests"] : "") . "</textarea><br />"; $html .= "<textarea id=\"aspirations\" name=\"aspirations\">" . ($record ? $record["aspirations"] : "") . "</textarea><br />"; $html .= "<textarea id=\"quote\" name=\"quote\">" . ($record ? $record["quote"] : "") . "</textarea><br />"; $html .= "</span>"; $html .= "<br class=\"clear\" /></div>"; ## Communication $html .= "<div id=\"communication\" style=\"display:none;\">"; $html .= "<span class=\"pc\">"; ## labels $html .= "<label class=\"lbl\" for=\"extension\">Office extension</label><br />"; $html .= "<label class=\"lbl\" for=\"cell\">Cellphone</label>"; $html .= "</span>"; $html .= "<span class=\"pc\" style=\"margin-right:30px;width:30%;\">"; ## inputs $html .= "<input id=\"extension\" name=\"extension\" type=\"text\" value=\"" . (isset($user) && isset($user["extension"]) ? $user["extension"] : "") . "\" /><br style=\"clear:both;\" />"; $html .= "<input id=\"cell\" name=\"cell\" type=\"text\" value=\"" . (isset($user) && isset($user["cell"]) ? $user["cell"] : "") . "\" /><br />"; $html .= "</span>"; $html .= "<span class=\"pc\">"; ## labels $html .= "<label class=\"lbl\" for=\"email\">Email</label>"; $html .= "</span>"; $html .= "<span class=\"pc\" style=\"width:37.4%;\">"; ## inputs $html .= "<input id=\"email\" name=\"email\" type=\"email\" value=\"" . $user["email"] . "\" /><br />"; $html .= "</span>"; $html .= "<br class=\"clear\" /></div>"; ## Login $html .= "<div id=\"login\" style=\"display:none;\">"; $html .= "<span class=\"pc\">"; ## labels $html .= "<label class=\"lbl\" for=\"username\">Username</label>"; $html .= "</span>"; $html .= "<span class=\"pc\" style=\"margin-right:30px;width:32%;\">"; ## inputs $html .= "<input id=\"username\" name=\"username\" type=\"text\" value=\"" . (isset($user) && isset($user["username"]) ? $user["username"] : "") . "\" />"; $html .= "</span>"; $html .= "<span class=\"pc\">"; ## labels $html .= "<label class=\"lbl\" for=\"password\">Password</label><br />"; $html .= "<label class=\"lbl\" for=\"con_pass\">Confirm password</label>"; $html .= "</span>"; $html .= "<span class=\"pc\" style=\"width:29%;\">"; ## inputs $html .= "<input id=\"password\" name=\"password\" type=\"password\" /><br />"; $html .= "<input id=\"con_pass\" onblur=\"formManipulators.checkPasswordIdentical('password', 'con_pass');\" type=\"password\" />"; $html .= "</span>"; $html .= "<br class=\"clear\" /></div>"; if (isset($_SESSION["isit"]) && $_SESSION["isit"]) { ## Flags $cols = (array) array(); $i = (int) 0; foreach ($metaData as $col => $data) { if ($col == "isadmin") { continue; } if (in_array($data["Type"], array("int(1)", "tinyint(1)"))) { $cols[$i][$col] = $data; $i++; if ($i === 3) { $i = 0; } } } $html .= "<div id=\"flags\" style=\"display:none;\">"; $html .= "<span class=\"pc\">"; ## inputs foreach (is_array($cols[0]) ? $cols[0] : array() as $col => $data) { $html .= "<input" . (isset($user) && isset($user[$col]) && $user[$col] ? " checked=\"checked\"" : "") . " id=\"" . $col . "\" name=\"" . $col . "\" style=\"float:left;margin-bottom:15px;\" type=\"checkbox\" value=\"1\" /><br class=\"clear\" />"; } $html .= "</span>"; $html .= "<span class=\"pc\" style=\"width:25%;\">"; ## labels foreach (is_array($cols[0]) ? $cols[0] : array() as $col => $data) { $html .= "<label class=\"lblcb\" for=\"" . $col . "\">" . $col . "</label><br class=\"clear\" />"; } $html .= "</span>"; $html .= "<span class=\"pc\">"; ## inputs foreach (is_array($cols[1]) ? $cols[1] : array() as $col => $data) { $html .= "<input" . (isset($user) && isset($user[$col]) && $user[$col] ? " checked=\"checked\"" : "") . " id=\"" . $col . "\" name=\"" . $col . "\" style=\"float:left;margin-bottom:15px;\" type=\"checkbox\" value=\"1\" /><br class=\"clear\" />"; } $html .= "</span>"; $html .= "<span class=\"pc\" style=\"width:25%;\">"; ## labels foreach (is_array($cols[1]) ? $cols[1] : array() as $col => $data) { $html .= "<label class=\"lblcb\" for=\"" . $col . "\">" . $col . "</label><br class=\"clear\" />"; } $html .= "</span>"; $html .= "<span class=\"pc\">"; ## inputs foreach (is_array($cols[2]) ? $cols[2] : array() as $col => $data) { $html .= "<input" . (isset($user) && isset($user[$col]) && $user[$col] ? " checked=\"checked\"" : "") . " id=\"" . $col . "\" name=\"" . $col . "\" style=\"float:left;margin-bottom:15px;\" type=\"checkbox\" value=\"1\" /><br class=\"clear\" />"; } $html .= "</span>"; $html .= "<span class=\"pc\" style=\"width:25%;\">"; ## labels foreach (is_array($cols[2]) ? $cols[2] : array() as $col => $data) { $html .= "<label class=\"lblcb\" for=\"" . $col . "\">" . $col . "</label><br class=\"clear\" />"; } $html .= "</span>"; $html .= "<br class=\"clear\" /></div>"; ## Access groups $cols = (array) array(); $i = (int) 0; foreach ($rights_groups as $grp) { $cols[$i][] = $grp; $i++; if ($i === 3) { $i = 0; } } $html .= "<div id=\"accessgroups\" style=\"display:none;\">"; $html .= "<span class=\"pc\">"; ## inputs foreach (is_array($cols[0]) ? $cols[0] : array() as $key => $data) { $checked = (bool) false; if (isset($user["children"]["rights_users"]) && is_array($user["children"]["rights_users"])) { foreach ($user["children"]["rights_users"] as $right) { if ($right['groupid'] == $data["id"]) { $checked = true; break; } } } $html .= "<input" . ($checked ? " checked=\"checked\"" : "") . " id=\"" . $data["id"] . "\" name=\"group[" . $data["id"] . "]\" style=\"float:left;margin-bottom:15px;\" type=\"checkbox\" value=\"" . $data["id"] . "\" /><br class=\"clear\" />"; } $html .= "</span>"; $html .= "<span class=\"pc\" style=\"width:25%;\">"; ## labels foreach (is_array($cols[0]) ? $cols[0] : array() as $key => $data) { $html .= "<label class=\"lblcb\" for=\"" . $data["id"] . "\" title=\"" . $data["description"] . "\">" . $data["name"] . "</label><br class=\"clear\" />"; } $html .= "</span>"; $html .= "<span class=\"pc\">"; ## inputs foreach (is_array($cols[1]) ? $cols[1] : array() as $key => $data) { $checked = (bool) false; if (isset($user["children"]["rights_users"]) && is_array($user["children"]["rights_users"])) { foreach ($user["children"]["rights_users"] as $right) { if ($right['groupid'] == $data["id"]) { $checked = true; break; } } } $html .= "<input" . ($checked ? " checked=\"checked\"" : "") . " id=\"" . $data["id"] . "\" name=\"group[" . $data["id"] . "]\" style=\"float:left;margin-bottom:15px;\" type=\"checkbox\" value=\"" . $data["id"] . "\" /><br class=\"clear\" />"; } $html .= "</span>"; $html .= "<span class=\"pc\" style=\"width:25%;\">"; ## labels foreach (is_array($cols[1]) ? $cols[1] : array() as $key => $data) { $html .= "<label class=\"lblcb\" for=\"" . $data["id"] . "\" title=\"" . $data["description"] . "\">" . $data["name"] . "</label><br class=\"clear\" />"; } $html .= "</span>"; $html .= "<span class=\"pc\">"; ## inputs foreach (is_array($cols[2]) ? $cols[2] : array() as $key => $data) { $checked = (bool) false; if (isset($user["children"]["rights_users"]) && is_array($user["children"]["rights_users"])) { foreach ($user["children"]["rights_users"] as $right) { if ($right['groupid'] == $data["id"]) { $checked = true; break; } } } $html .= "<input" . ($checked ? " checked=\"checked\"" : "") . " id=\"" . $data["id"] . "\" name=\"group[" . $data["id"] . "]\" style=\"float:left;margin-bottom:15px;\" type=\"checkbox\" value=\"" . $data["id"] . "\" /><br class=\"clear\" />"; } $html .= "</span>"; $html .= "<span class=\"pc\" style=\"width:25%;\">"; ## labels foreach (is_array($cols[2]) ? $cols[2] : array() as $key => $data) { $html .= "<label class=\"lblcb\" for=\"" . $data["id"] . "\" title=\"" . $data["description"] . "\">" . $data["name"] . "</label><br class=\"clear\" />"; } $html .= "</span>"; $html .= "<br class=\"clear\" /></div>"; } $html .= "<br class=\"clear\" /></div>"; $html .= "<div id=\"buttons\">"; $html .= "<span class=\"button\" onclick=\"document.getElementById('userProfile').submit();\" style=\"height:26px;padding-top:8px;width:114px;\">Save</span>"; $html .= "<span class=\"button\" onclick=\"document.location='/';\" style=\"height:26px;padding-top:8px;width:114px;\">Cancel</span>"; $html .= "</div>"; $html .= "</form>" . PHP_EOL; $html .= "<script type=\"text/javascript\">"; $html .= "var up={};"; $html .= "up.mouse = function(e, ev) {"; $html .= "var i,p1=e.parentNode,p2=document.getElementById('content');"; $html .= "if (!ev) {var ev = window.event;} if (!ev) {return false;}"; $html .= "switch (ev.type) {"; $html .= "case 'click': "; $html .= "for (i=0;i<p1.childNodes.length;i++){p1.childNodes[i].style.backgroundColor='inherit';if (p1.childNodes[i].getAttribute('alt') == e.getAttribute('alt')) {e.setAttribute('obg', '#FFF');e.style.backgroundColor='#FFF';}} "; $html .= "for (i=0;i<p2.childNodes.length;i++) {p2.childNodes[i].style.display='none';}"; $html .= "document.getElementById(e.getAttribute('alt')).style.display='';"; $html .= "break;"; $html .= "case 'mouseout': e.style.backgroundColor=e.getAttribute('obg'); break;"; $html .= "case 'mouseover': e.setAttribute('obg', e.style.backgroundColor);e.style.backgroundColor='#FFF'; break;"; $html .= "}"; $html .= "};"; $html .= "up.resetBorders = function(e){"; $html .= "var i,p=e.parentNode;"; $html .= "for(i=0;i<p.childNodes.length;i++){p.childNodes[i].style.borderColor='#000';}"; $html .= "e.style.borderColor='#F00';"; $html .= "};"; $html .= "</script>" . PHP_EOL; //$html .= ""; } $this->_html = $html; }
/** Scaffold_Forms_User_profiles::setHtml($html = null) * @param string $html HTML form definition */ public function setHtml($html = null) { if ($html === null) { ## Preparation $record = self::getRecord(); if (is_object("TableManager") === false) { include_once BASE . DIRECTORY_SEPARATOR . "basefunctions" . DIRECTORY_SEPARATOR . "baseapis" . DIRECTORY_SEPARATOR . "TableManager.php"; } $tableManager = new TableManager("m3_departments"); $departments = $tableManager->selectMultiple(); $sql = (string) "SELECT * FROM `themes` WHERE (ISNULL(`deleted`) OR `deleted`=0)"; $themes = $tableManager->runSql($sql); $users = new TableManager("users"); $metaData = $users->getMetaData(); if ($record) { $users->setChildRecords(true); $users->setChildTables(array(0 => array("rights_users" => "rights_users", "where" => "`rights_users`.`userid`=?"))); $users->setWhere($users->quoteString("`users`.`user_profiles_id`=?", (int) $record["id"])); $user = $users->selectSingle(); } $sql = (string) "SELECT * FROM `rights_groups` WHERE 1=1;"; $rights_groups = $users->runSql($sql); ## End $html = (string) "<form enctype=\"multipart/form-data\" method=\"POST\">" . PHP_EOL; $html .= "<div style=\"width:800px;\">" . PHP_EOL; $html .= "<div style=\"text-align:center;\">" . PHP_EOL; $html .= "<input type=\"submit\" value=\"Save\" style=\"background-color:transparent;background-image:url(" . BASE . "images/new/button.png);border:none;height:34px;width:114px;\" />" . PHP_EOL; $html .= "</div>" . PHP_EOL; ## Profile details $html .= "<fieldset style=\"width:730px;\">"; $html .= "<legend>Profile details</legend>"; $html .= "<div style=\"border:none;float:left;width:49%;\">"; $html .= "<label for=\"staffno\" style=\"color:#000;width:150px;\">Staff Number</label>" . PHP_EOL; $html .= "<input id=\"staffno\" name=\"staffno\" " . ($record["staffno"] ? "readonly=\"readonly\" " : "") . "type=\"text\" value=\"" . ($record["staffno"] ? $record["staffno"] : "") . "\"><br style=\"clear:both;\" />" . PHP_EOL; $html .= "<label for=\"firstname\" style=\"color:#000;width:150px;\">First name</label>" . PHP_EOL; $html .= "<input id=\"firstname\" name=\"firstname\" type=\"text\" value=\"" . ($record["firstname"] ? $record["firstname"] : "") . "\"><br />" . PHP_EOL; $html .= "<label for=\"day\" style=\"color:#000;width:150px;\">Birthday</label>" . PHP_EOL; $html .= "<select id=\"day\" name=\"day\" style=\"float:left;margin-bottom:5px;width:50px;\">"; $html .= "<option value=\"0\">Day</option>" . PHP_EOL; for ($i = 1; $i < 32; $i++) { $html .= "<option " . ($record["birthday"] && date("d", $record["birthday"]) == $i ? "selected=\"selected\" " : "") . "value=\"" . (strlen($i) == 1 ? "0" . $i : $i) . "\">" . (strlen($i) == 1 ? "0" . $i : $i) . "</option>"; } $html .= "</select>"; $html .= "<select id=\"month\" name=\"month\" style=\"float:left;width:120px;\">"; $html .= "<option value=\"0\">Month</option>" . PHP_EOL; for ($i = 1; $i < 13; $i++) { $html .= "<option " . ($record["birthday"] && date("F", $record["birthday"]) == date("F", mktime(0, 0, 0, $i, 1, 2000)) ? "selected=\"selected\" " : "") . "value=\"" . date("m", mktime(0, 0, 0, $i, 1, 2000)) . "\">" . date("F", mktime(0, 0, 0, $i, 1, 2000)) . "</option>"; } $html .= "</select><br style=\"clear:both;\" />"; $html .= "<label for=\"department_id\" style=\"color:#000;width:150px\">Department</label>" . PHP_EOL; $html .= "<select id=\"department_id\" name=\"department_id\">" . PHP_EOL; $html .= "<option value=\"0\">Please select...</options>" . PHP_EOL; foreach ($departments as $dept) { $html .= "<option value=\"" . $dept["id"] . "\"" . ($record && $record["department_id"] == $dept["id"] ? " selected=\"selected\"" : "") . ">" . $dept["name"] . "</option>" . PHP_EOL; } $html .= "</select><br class=\"clear\" />" . PHP_EOL; $locations = (array) array(0 => array("name" => "Head Office"), 1 => array("name" => "Durban"), 2 => array("name" => "Empangeni"), 3 => array("name" => "East London"), 4 => array("name" => "Kokstad"), 5 => array("name" => "Pietermaritzburg"), 6 => array("name" => "Newcastle"), 7 => array("name" => "Vanderbijl Park"), 8 => array("name" => "Isando"), 9 => array("name" => "Germiston")); $html .= "<label for=\"location\" style=\"color:#000;width:150px;\">Location</label>" . PHP_EOL; $html .= "<select id=\"location\" name=\"location\" style=\"float:left;width:165px;\">" . PHP_EOL; foreach ($locations as $location) { $html .= "<option " . ($record["location"] && $record["location"] == $location["name"] ? "selected=\"selected\" " : "") . "value=\"" . $location["name"] . "\">" . $location["name"] . "</option>" . PHP_EOL; } $html .= "</select><br class=\"clear\" />" . PHP_EOL; $html .= "<label for=\"interests\" style=\"color:#000;\">Interests</label>" . PHP_EOL; $html .= "<textarea id=\"interests\" name=\"interests\">" . ($record ? $record["interests"] : "") . "</textarea><br />" . PHP_EOL; $html .= "<label for=\"aspirations\" style=\"color:#000;\">Aspirations</label>" . PHP_EOL; $html .= "<textarea id=\"aspirations\" name=\"aspirations\">" . ($record ? $record["aspirations"] : "") . "</textarea><br />" . PHP_EOL; $html .= "<label for=\"quote\" style=\"color:#000;\">Quote</label>" . PHP_EOL; $html .= "<textarea id=\"quote\" name=\"quote\">" . ($record ? $record["quote"] : "") . "</textarea><br />" . PHP_EOL; $html .= "</div>"; $html .= "<div style=\"border:none;float:left;width:49%;\">"; $html .= "<label for=\"image_file\" style=\"color:#000;width:150px;\">Image</label>" . PHP_EOL; $html .= "<input type=\"file\" id=\"image_file\" name=\"image\" /><br />" . PHP_EOL; $html .= "<label for=\"lastname\" style=\"color:#000;width:150px;\">Last name</label>" . PHP_EOL; $html .= "<input id=\"lastname\" name=\"lastname\" type=\"text\" value=\"" . ($record["lastname"] ? $record["lastname"] : "") . "\"><br class=\"clear\" /><br /><br />" . PHP_EOL; $html .= "<label for=\"jobtitle\" style=\"color:#000;width:150px\">Job Title</label>" . PHP_EOL; $html .= "<input type=\"text\" id=\"jobtitle\" name=\"jobtitle\" value=\"" . ($record ? $record["jobtitle"] : "") . "\" /><br />" . PHP_EOL; $html .= "<label for=\"family\" style=\"color:#000;\">Family</label>" . PHP_EOL; $html .= "<textarea id=\"family\" name=\"family\">" . ($record ? $record["family"] : "") . "</textarea><br />" . PHP_EOL; $html .= "<label for=\"goals\" style=\"color:#000;\">Goals</label>" . PHP_EOL; $html .= "<textarea id=\"goals\" name=\"goals\">" . ($record ? $record["goals"] : "") . "</textarea><br />" . PHP_EOL; $html .= "</div>"; $html .= "</fieldset>"; ## User details $html .= "<fieldset style=\"width:730px;\">"; $html .= "<legend>User details</legend>"; $html .= "<div style=\"float:left;width:49%;\">"; $html .= "<fieldset style=\"border:none;\">"; $html .= "<legend>Communication</legend>"; $html .= "<label for=\"extension\" style=\"color:#000;width:150px;\">Office extension</label>"; $html .= "<input id=\"extension\" name=\"extension\" type=\"text\" value=\"" . $user["extension"] . "\" /><br />"; $html .= "<label for=\"cell\" style=\"color:#000;width:150px;\">Cellphone</label>"; $html .= "<input id=\"cell\" name=\"cell\" type=\"text\" value=\"" . $user["cell"] . "\" /><br />"; $html .= "<label for=\"email\" style=\"color:#000;width:150px;\">Email</label>"; $html .= "<input id=\"email\" name=\"email\" type=\"email\" value=\"" . $user["email"] . "\" /><br />"; $html .= "</fieldset>"; $html .= "<fieldset style=\"border:none;\">"; $html .= "<legend>Login and Password</legend>"; if ($user) { $html .= "<input id=\"personid\" name=\"personid\" type=\"hidden\" value=\"" . $user["personid"] . "\" />"; } $html .= "<label for=\"username\" style=\"color:#000;width:150px;\">Username</label>"; $html .= "<input id=\"username\" name=\"username\"" . (isset($user) ? "" : " onblur=\"check.checkUsernameAvailability(this);\"") . " type=\"text\" value=\"" . $user["username"] . "\" /><br />"; $html .= "<label for=\"pass\" style=\"color:#000;width:150px;\">Password</label>"; $html .= "<input id=\"pass\" name=\"password\" type=\"password\" /><br />"; $html .= "<label for=\"conpass\" style=\"color:#000;width:150px;\">Confirm password</label>"; $html .= "<input id=\"conpass\" name=\"conpass\" type=\"password\" onblur=\"formManipulators.checkPasswordIdentical('pass', 'conpass')\" /><br />"; $html .= "</fieldset>"; $html .= "</div>"; $html .= "<div style=\"float:left;width:49%;\">"; $html .= "<fieldset style=\"border:none;\">"; $html .= "<legend>Flags</legend>"; if ($_SESSION["isit"]) { foreach ($metaData as $col => $data) { if ($col == "isadmin") { continue; } if (in_array($data["Type"], array("int(1)", "tinyint(1)"))) { $html .= "<input" . ($user && $user[$col] ? " checked=\"checked\"" : "") . " id=\"" . $col . "\" name=\"" . $col . "\" type=\"checkbox\" value=\"1\" />"; $html .= "<label for=\"" . $col . "\" style=\"color:#000;\">" . $col . "</label><br />"; } } } else { $html .= "Cannot set access flags. Please see IT dept. to change"; } $html .= "</fieldset>"; $html .= "<fieldset style=\"border:none;\">"; $html .= "<legend>Access Groups</legend>"; if ($_SESSION["isit"]) { foreach ($rights_groups as $grp) { $checked = (bool) false; if (isset($user["children"]["rights_users"]) && is_array($user["children"]["rights_users"])) { foreach ($user["children"]["rights_users"] as $right) { if ($right['groupid'] == $grp["id"]) { $checked = true; break; } } } $html .= "<input" . ($checked ? " checked=\"checked\"" : "") . " id=\"" . $grp["id"] . "\" name=\"group[" . $grp["id"] . "]\" type=\"checkbox\" value=\"" . $grp["id"] . "\" />"; $html .= "<label for=\"" . $grp["id"] . "\" style=\"color:#000;\">" . $grp["name"] . "</label><br />"; } } else { $html .= "Cannot set access flags. Please see IT dept. to change"; } $html .= "</fieldset>"; $html .= "</div>"; $html .= "</fieldset>"; $html .= "<div style=\"text-align:center;\">" . PHP_EOL; $html .= "<input type=\"submit\" value=\"Save\" style=\"background-color:transparent;background-image:url(" . BASE . "images/new/button.png);border:none;height:34px;width:114px;\" />" . PHP_EOL; $html .= "</div>" . PHP_EOL; $html .= "</div>" . PHP_EOL; $html .= "</form>" . PHP_EOL; //$html .= "<iframe id=\"targetFrame\" name=\"targetFrame\"></iframe>".PHP_EOL; $html .= "<iframe id=\"targetFrame\" name=\"targetFrame\" style=\"display:none;\"></iframe>" . PHP_EOL; $html .= "<script type=\"text/javascript\">" . PHP_EOL; $html .= "function selectTheme(elem) {\n\t\t for (var i=0; i<document.getElementById('profileTheme').getElementsByTagName('IMG').length;i++) {\n\t\t document.getElementById('profileTheme').getElementsByTagName('IMG')[i].style.border='none';\n\t\t } \n\t\t elem.style.border='1px solid #000';\n\t\t }" . PHP_EOL; $html .= "</script>" . PHP_EOL; } $this->_html = $html; }
function updateUserHistory($config) { if ($config["userid"]) { $data["userid"] = $config["userid"]; } if ($config["actionid"]) { $data["actionid"] = $config["actionid"]; } if ($config["comment"]) { $data["comment"] = $config["comment"]; } if ($config["fromdate"]) { $data["fromdate"] = $config["fromdate"]; } if ($config["todate"]) { $data["todate"] = $config["todate"]; } $data["date"] = date("U"); /* if($done = sqlCreate(array("table"=>"userhistory", "fields"=>$data))) { $available = sqlPull(array("table"=>"useractions", "where"=>"id=".$config["actionid"], "onerow"=>"1")); $userdata["available"] = $available["callme"]; sqlCommit(array("table"=>"users", "where"=>"personid=".$config["userid"], "fields"=>$userdata)); } */ $userhistory = new TableManager("userhistory"); $function = (string) "insert"; if ($config["id"]) { ## we are updating a record $userhistory->setWhere($userhistory->quoteString("`userhistory`.`id`=?", intval($config["id"]))); $function = "update"; } if ($userhistory->{$function}($data) === false) { throw new man_exception("Could not successfully query the database"); } $actions = new TableManager("useractions"); $actions->setWhere($actions->quoteString("`useractions`.`id`=?", $config["actionid"])); $action = $actions->selectSingle(); $users = new TableManager("users"); $users->setWhere($users->quoteString("`users`.`personid`=?", $config["userid"])); $data = (array) array("available" => $action["callme"]); $users->update($data); }
/** getFleetBudgetDays($fleet, $startDate = NULL, $stopDate = NULL) * get the number of days that fleet $fleet has a budget for * @param INT $fleet Fleet ID * @param INT $startDate when do we start * @param INT $stopDate when do we stop * @return INT number of days on success FALSE otherwise */ function getFleetBudgetDays($fleet, $startDate = NULL, $stopDate = NULL) { //: Tests if (is_int($fleet) === FALSE) { return FALSE; } if (is_int($startDate) === FALSE) { $startDate = mktime(0, 0, 0, date("m"), 1, date("Y")); } if (is_int($stopDate) === FALSE) { $stopDate = mktime(0, 0, 0, date("m"), date("d"), date("Y")); } //: End //: Function Content $manager = new TableManager("fleet_scores"); $sql = (string) "SELECT * FROM `fleet_scores` WHERE "; $sql .= $manager->quoteString("`fleetid`=?", (int) $fleet); $sql .= $manager->quoteString(" AND `date`>=?", $startDate); $sql .= $manager->quoteString(" AND `date`<=?", $stopDate); if (($results = $manager->runSql($sql)) === FALSE) { return FALSE; } $day = (int) 0; foreach ($results as $val) { if (isset($val["budget"]) && $val["budget"] > 0) { $day++; } } return $day; //: End }
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>"; // } }
/** fleetTruckLinkImporter::__construct() * Class constructor */ public function __construct() { $realPath = realpath(dirname(__FILE__)); $maxine = substr($realPath, 0, strrpos($realPath, DIRECTORY_SEPARATOR)); $rootaccess = substr($maxine, 0, strrpos($maxine, DIRECTORY_SEPARATOR) + 1); defined("BASE") || define("BASE", $rootaccess); include_once BASE . "basefunctions/baseapis/TableManager.php"; include_once BASE . "basefunctions/baseapis/FileParser/FileParser.php"; $manager = new TableManager("fleet_truck_count"); //: Do a test to see if table includes subbie_trucks field $fields = $manager->describeTable(); if (in_array('subbie_count', array_keys($fields)) === FALSE) { $sql = (string) "ALTER TABLE `fleet_truck_count` ADD COLUMN `subbie_count` INT NOT NULL DEFAULT 0;"; if ($manager->runSql($sql) === FALSE) { print "Altering table failed" . PHP_EOL; return FALSE; } } //: End $subbietrucksurl = "https://login.max.bwtsgroup.com/api_request/Report/export?report=153&responseFormat=csv"; // Max $apiurl = "https://login.max.bwtsgroup.com/api_request/Report/export?report=145&responseFormat=csv"; // Max $t24apiurl = "https://t24.max.bwtsgroup.com/api_request/Report/export?report=73&responseFormat=csv"; // T24 // $apiurl = "http://max.mobilize.biz/m4/2/api_request/Report/export?report=141&responseFormat=csv"; // Test //: Get the list of subbie trucks $fileParser = new FileParser($subbietrucksurl); $fileParser->setCurlFile("subbie_trucks.csv"); $data = $fileParser->parseFile(); $subbieTrucks = (array) array(); foreach ($data as $val) { if (array_key_exists("Trucks", $val) === FALSE) { continue; } $trucks = preg_split("/\\,/", $val["Trucks"]); if (is_array($trucks) === FALSE) { continue; } foreach ($trucks as $trucklist) { $subbieTrucks[] = $trucklist; } } //print_r($subbieTrucks); unset($data); //return FALSE; //: End $fleetDayHandler = new fleetDayHandler(); $required_fleets = $fleetDayHandler->getIncomeFleets(); $rows = (array) array(); foreach ($required_fleets as $val) { if (array_key_exists('fleets', $val)) { $count = (int) 0; $subbie_count = (int) 0; foreach ($val['fleets'] as $subfleets) { $manager->setWhere($manager->quoteString('`fleet_id`=?', $subfleets[0])); $record = $manager->selectSingle(); $count += (int) $record['count']; $subbie_count += (int) $record['subbie_count']; } $rows[] = (array) array('fleet_id' => $val['id'], 'count' => isset($count) && $count ? $count : 0, 'subbie_count' => isset($subbie_count) && $subbie_count ? $subbie_count : 0); } else { $url = $apiurl . "&Fleet=" . $val["maxid"] . "&Start%20Date=" . date("Y-m-d") . "&Stop%20Date=" . date('Y-m-d', strtotime('+1 day')); if (array_key_exists('t24', $val)) { $url = $t24apiurl . "&Fleet=" . $val["maxid"] . "&Start%20Date=" . date("Y-m-d") . "&Stop%20Date=" . date('Y-m-d', strtotime('+1 day')); } print_r('url: ' . $url . PHP_EOL); $fileParser = new FileParser($url); $fileParser->setCurlFile("fleet_truck_count_" . $val["id"] . ".csv"); $data = $fileParser->parseFile(); // print_r($data); /*if ($fleetId == 75) { //: confirm a fleet is correct print("<pre>"); print_r($data); print("</pre>"); }*/ $sub_cnt = (int) 0; foreach ($data as $row) { if (in_array($row['Truck'], $subbieTrucks)) { $sub_cnt++; } } //print($sub_cnt.PHP_EOL); $record = (array) array('fleet_id' => $val['id'], 'count' => count($data), 'subbie_count' => $sub_cnt); if (array_key_exists('t24', $val)) { $record['t24'] = (int) 1; } $rows[] = $record; } } //: Loop through and update/insert records foreach ($rows as $row) { $where = (string) $manager->quoteString('`fleet_id`=?', $row['fleet_id']); if (array_key_exists('t24', $row) && $row['t24'] === 1) { $where .= $manager->quoteString(' AND `t24`=?', $row['t24']); } $manager->setWhere($where); $record = $manager->selectSingle(); if ($record) { print_r($record); print_r($row); $nDifference = (double) $row['count'] == 0 ? 100 : ($record['count'] - $row['count']) / $row['count'] * 100; print_r('diff: ' . $nDifference . PHP_EOL); if ($nDifference > 50 || $nDifference < -50) { continue; } $manager->setWhere($manager->quoteString('`id`=?', $record['id'])); $manager->update($row); } else { $manager->insert($row); } } }
/** Maxine_Scaffold_Custom_Imports_GalleryItems::__constuct() * Class Constructor */ public function __construct() { ## Preparation $base = substr(__DIR__, 0, strrpos(__DIR__, "M")); $gallery = new TableManager("gallery"); $this->setLocation(); $this->setThumbNailer(); $this->setTableManager(); ## The Work echo "<link href=\"http://" . $_SERVER["SERVER_NAME"] . "/basefunctions/scripts/manline.css\" media=\"all\" rel=\"stylesheet\" type=\"text/css\" />" . PHP_EOL; if ($_POST) { $gallery->setWhere($gallery->quoteString("(`gallery`.`name`=?", $_POST["directory"]) . $gallery->quoteString(" OR `gallery`.`name`=?)", htmlspecialchars($_POST["directory"]))); $record = $gallery->selectSingle(); $gallery->setWhere(""); echo "<p class=\"standard\">" . PHP_EOL; $dh = dir($this->getLocation() . $_POST["directory"] . DIRECTORY_SEPARATOR); while (($entry = $dh->read()) !== false) { if (in_array($entry, array(".", ".."))) { continue; } ## Copy the file from /tmp if (file_exists($base . "Maxine" . DS . "gallery" . DS . $entry)) { unlink($base . "Maxine" . DS . "gallery" . DS . $entry); } if (copy($this->getLocation() . $_POST["directory"] . DS . $entry, $base . "Maxine" . DS . "gallery" . DS . $entry) === false) { print "Copy Failed" . PHP_EOL; return false; } $size = getimagesize($this->getLocation() . $_POST["directory"] . DS . $entry); ## Insert into the database $data = (array) array(); $data["gallery_id"] = $record["id"]; $data["file"] = "gallery" . DS . $entry; $data["name"] = substr($entry, 0, strrpos($entry, ".")); if ($size[0] > $size[1]) { $data["is_landscape"] = 1; } $this->getTableManager()->insert($data); ## Make the thumbnails $this->getThumbNailer()->setLocation($base . "Maxine" . DS . "gallery" . DS . "thumbnails" . DS); $this->getThumbNailer()->setFile($base . "Maxine" . DS . "gallery" . DS . $entry); $this->getThumbNailer()->processImage(); print "<span title=\"image uploaded: " . $entry . "\">|</span>" . PHP_EOL; ## remove the file if (file_exists($this->getLocation() . $_POST["directory"] . DS . $entry) === true) { unlink($this->getLocation() . $_POST["directory"] . DS . $entry); } } $dh->close(); rmdir($this->getLocation() . $_POST["directory"] . DS); ## remove the directory echo "<a href=\"http://" . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"] . "\">Import More...</a>" . PHP_EOL; echo "</p>" . PHP_EOL; } else { echo "<form method=\"POST\">" . PHP_EOL; $dh = dir($this->getLocation()); $i = 0; while (($entry = $dh->read()) !== false) { echo "<div class=\"column\" style=\"min-height:5px;\">" . PHP_EOL; if (in_array($entry, array(".", ".."))) { continue; } echo "<input type=\"radio\" name=\"directory\" id=\"" . $entry . "\" value=\"" . $entry . "\" />" . PHP_EOL; echo "<label for=\"" . $entry . "\">" . $entry . "</label><br />" . PHP_EOL; echo "</div>" . PHP_EOL; $i++; if ($i > 2) { echo "<br class=\"clear\" />" . PHP_EOL; $i = 0; } } echo "<br class=\"clear\" />" . PHP_EOL; $dh->close(); echo "<input type=\"submit\" value=\"Process\" />" . PHP_EOL; echo "</form>" . PHP_EOL; } }
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>"; } // } }
/** getCurrentAlerts($json_encode = FALSE) * get a list of the current system alerts * @param BOOL $json_encode do we json encode and print to screen? (called via ajax) * @return array $return on success false otherwise */ function getCurrentAlerts($json_encode = FALSE) { //: Tests if (is_bool($json_encode) === FALSE) { $json_encode = (bool) FALSE; } //: Test to see if TableManager can be referenced $declared_classes = get_declared_classes(); if (!in_array("TableManager", $declared_classes)) { include_once BASE . "/basefunctions/baseapis/TableManager.php"; } //: End //: End //: Function Content $manager = new TableManager("alerts"); $where = (string) $manager->quoteString("`alerts`.`deleted`=?", (int) 0); $where .= $manager->quoteString(" AND `alerts`.`time_start`<=?", strtotime(date("Y-m-d") . " 00:00:00")); $where .= $manager->quoteString(" AND `alerts`.`time_end`>=?", strtotime(date("Y-m-d") . " 23:59:00")); $manager->setWhere($where); $manager->setOrderBy(array("column" => "`alerts`.`time_start`", "direction" => "ASC")); if (($return = $manager->selectMultiple()) === FALSE) { return FALSE; } if ($json_encode === TRUE) { print "var ret=" . json_encode($return); return FALSE; } return $return; //: End }