public function setHtml($html = null) { if (is_string($html) === false) { $html = null; } if ($html === null) { $gallery = new TableManager("gallery"); $list = $gallery->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=\"gallery_id\">Gallery</label>"; $html .= "<select id=\"gallery_id\" name=\"gallery_id\" style=\"width:200px;\">"; $html .= "<option value=\"0\">Please select..</option>"; foreach ($list as $val) { $html .= "<option" . ($_POST && $val["id"] == $_POST["gallery_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_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(`deleted`)"); $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 .= "<script type=\"text/javascript\" src=\"" . BASE . DIRECTORY_SEPARATOR . "basefunctions" . DIRECTORY_SEPARATOR . "scripts" . DIRECTORY_SEPARATOR . "ajax_directory_list.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\" 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; $html .= "<fieldset id=\"appendHere\">" . PHP_EOL; $html .= "<legend>Items</legend>" . PHP_EOL; ## upload a single file to the gallery $html .= "<div style=\"float:left;width:350px;\">" . PHP_EOL; $html .= "<label for=\"is_landscape\" style=\"color:#000;\">Is Landscape?</label>" . PHP_EOL; $html .= "<input" . ($record["is_landscape"] ? " checked=\"checked\"" : "") . " id=\"is_landscape\" name=\"is_landscape\" type=\"checkbox\" value=\"1\" />"; $html .= "<label for=\"name[0]\" style=\"color:#000;\">Name</label>" . PHP_EOL; $html .= "<input type=\"text\" class=\"standard\" id=\"name[0]\" name=\"name[0]\" readonly=\"readonly\" value=\"" . ($record ? $record["name"] : "") . "\" /><br />" . PHP_EOL; $html .= "<label for=\"location_file[0]\" style=\"color:#000;\">Location</label>" . PHP_EOL; $location = (string) "gallery/"; $html .= "<input type=\"file\" id=\"location_file[0]\" name=\"location_file[0]\" readonly=\"readonly\" onchange=\"document.getElementById('name[0]').value = this.value.toString().substring(0, this.value.toString().lastIndexOf('.'));\" />" . PHP_EOL; $html .= "<input type=\"hidden\" name=\"file[0]\" id=\"file[0]\" />" . PHP_EOL; $html .= "<button onclick=\"ajaxFileUpload.doUpload('" . $location . "', 'file[0]', 'location_file[0]'); return false;\">Upload</button>" . PHP_EOL; $html .= "<br />" . PHP_EOL; $html .= "</div>" . PHP_EOL; ## Use a directory path $html .= "<div style=\"border-left:1px solid #DCDCDC;float:left;padding-left:10px;text-align:left;width:350px;\">" . PHP_EOL; $html .= "<label for=\"file_path\" style=\"color:#000;\" title=\"Examples: http://www.facebook.com/images/, /var/www/pookybear etc....\">Location</label>" . PHP_EOL; $html .= "<input type=\"text\" id=\"file_path\" name=\"file_path\" /> "; $html .= "<button onclick=\"directory.doScan(document.getElementById('file_path').value, 'fileListing'); return false;\">Find Files...</button><br />" . PHP_EOL; $html .= "<label for=\"checkAll\" style=\"color:#000;\">Check All</label>"; $html .= "<input type=\"checkbox\" id=\"checkAll\" name=\"checkAll\" disabled=\"disabled\" onclick=\"directory.handleFormInputs('uploaderForm', this);\" />"; $html .= "<br />" . PHP_EOL; $html .= "<div id=\"fileListing\"></div>" . PHP_EOL; $html .= "</div>" . PHP_EOL; $html .= "</fieldset>" . 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 . "new" . DIRECTORY_SEPARATOR . "loading.png\" alt=\"Loading\" title=\"Please be patient. Uploading your file can take a bit of time\" /></p>" . PHP_EOL; } $this->_html = $html; }
/** returnFleetTruckCount() * get all fleets truck count * @return array on success false otherwise */ function returnFleetTruckCount() { require_once BASE . "/basefunctions/baseapis/TableManager.php"; $manager = new TableManager("fleet_truck_count"); $manager->setCustomIndex("fleet_id"); return $manager->selectMultiple(); }
/** 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; }
/** 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; }
public function setHtml($html = null) { if ($html === null) { $departments = new TableManager("m3_departments"); $themes = new TableManager("themes"); $list = $departments->selectMultiple(); $list2 = $themes->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=\"staffno\">Staff No.</label>"; $html .= "<input id=\"staffno\" name=\"staffno\" type=\"text\" value=\"" . ($_POST ? $_POST["staffno"] : "") . "\" /><br />" . PHP_EOL; $html .= "<label for=\"firstname\">First Name</label>"; $html .= "<input id=\"firstname\" name=\"firstname\" type=\"text\" value=\"" . ($_POST ? $_POST["firstname"] : "") . "\" /><br />" . PHP_EOL; $html .= "<label for=\"lastname\">Last Name</label>"; $html .= "<input id=\"lastname\" name=\"lastname\" type=\"text\" value=\"" . ($_POST ? $_POST["lastname"] : "") . "\" /><br />" . PHP_EOL; $html .= "<label for=\"department_id\">Department</label>"; $html .= "<select id=\"department_id\" name=\"department_id\">"; $html .= "<option value=\"0\">Please select..</option>"; foreach ($list as $val) { $html .= "<option" . ($_POST && $val["id"] == $_POST["department_id"] ? " selected=\"selected\"" : "") . " value=\"" . $val["id"] . "\">" . $val["name"] . "</option>"; } $html .= "</select><br />"; $html .= "<label for=\"jobtitle\">Position</label>"; $html .= "<input id=\"jobtitle\" name=\"jobtitle\" type=\"text\" value=\"" . ($_POST ? $_POST["jobtitle"] : "") . "\" /><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=\"theme_id\">Theme</label>"; $html .= "<select id=\"theme_id\" name=\"theme_id\">"; $html .= "<option value=\"0\">Please select..</option>"; foreach ($list2 as $val) { $html .= "<option" . ($_POST && $val["id"] == $_POST["theme_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>"; } $this->_html = $html; }
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; }
/** testUserRecordForHistory($userid) * test a user record for a userhistory record that matches today * @author Feighen Oosterbroek * @author feighen@manlinegroup.com * @param int $userid which user are we testing against * @return array result */ function testUserRecordForHistory($userid) { $manager = new TableManager("userhistory"); $manager->setWhere($manager->quoteString("`userhistory`.`userid`=?", $userid)); $manager->setOrderBy(array("column" => "`userhistory`.`date`", "direction" => "DESC")); $history = $manager->selectMultiple(); /** Explanation * one of 3 potential tests need to match * 1) today is between from and to date * 2) date added is today with no from to dates * 3) last added item to match */ $hist = (array) array(); if ($history) { $dateU = date("U"); foreach ($history as $key => $val) { if ($val["fromdate"] || $val["todate"]) { ## item 1 if ($dateU >= $val["fromdate"] && $dateU < $val["todate"]) { $hist = $val; break; } elseif ($val["todate"] == 0 && $dateU >= $val["fromdate"]) { $hist = $val; break; } elseif ($val["fromdate"] == 0 && $dateU < $val["todate"]) { $hist = $val; break; } else { $hist["actionid"] = 0; } } elseif (date("Y-m-d") == date("Y-m-d", $val["date"])) { ## item 2 $hist = $val; break; } } if (!$hist) { ## item 3 $keys = array_keys($history); $hist = $history[$keys[0]]; } } return $hist; }
function listPdpOverdues() { $pdpobj = new TableManager("drivers"); $pdpobj->setQueryColumns(array("drivers" => array("*"))); //$userobj->setCustomIndex("personid"); $pdpobj->setWhere("1=1"); $pdplist = $pdpobj->selectMultiple(); print "<pre style='font-family:verdana;font-size:13'>"; print_r($pdplist); print "</pre>"; }
function editUserForm() { $users = new Users(); // Data Prep { $isit = $_SESSION["isit"]; if ($_POST["conf"]) { $conf = $_POST["conf"]; $user = $users->getRow(array("where" => "personid=" . $conf["personid"], "children" => true)); $passtip = "If nothing is entered, password will remain the same."; } else { $passtip = "This is a compulsory field"; $user["oninout"] = 1; } if ($conf["personid"]) { $birthday = sqlPull(array("table" => "userdates", "where" => "userid=" . $conf["personid"] . " AND datetype='birthday'", "onerow" => "1")); $bday = date("d", $birthday["date"]); $bmonth = date("m", $birthday["date"]); } $depts = sqlPull(array("table" => "m3_departments", "where" => "1=1")); $rightsgroups = sqlPull(array("table" => "rights_groups", "where" => "1=1")); $profiles = new TableManager("user_profiles"); $profiles->setWhere("deleted=0"); $profiles->setOrderBy(array("column" => array("firstname", "lastname"), "direction" => array("ASC", "ASC"))); $profiles->setQueryColumns(array("user_profiles" => array("id", "firstname", "lastname"))); $profilelist = $profiles->selectMultiple(); // } maxineTop("User Form"); print "<form id='userform' name='userform' action='/Maxine/?commituser' method='post'>"; // Buttons { openHeader(); //print("<img src='".TOPBUTTONS."/buttonuserhistory.png' onClick='userform.action=\"index.php?mode=maxine/index&action=manageuserdates\"; userform.submit();'>"); maxineButton("Submit", "testDetails(); userform.submit();", 2); maxineButton("Delete", "userform.action=\"/Maxine/?deleteuser\"; userform.submit();", 2); maxineButton("Back", "goTo(\"/Maxine/?listusers\");", 2); closeHeader(); // } print "<div class='tray' style='height:600px;'>"; // Input { print "<input type=hidden name='conf[personid]' value=" . $user["personid"] . ">"; // Left Hand Side { print "<div style='width:400px; margin-left:20px; float:left;'>"; // Personal Details { openSubbar(400); print "Personal Details"; closeSubbar(); print "<table class='standard content1' style='width:400px;'>"; print "<tr><td width=30% align='center'>"; print "User Name"; print "</td><td width=70%>"; print "<input name=conf[username] value='" . $user["username"] . "' style='width: 100%; background-color: " . MAXINEBACK . "; border-width: 1px;' title='This will automatically be convered to lower case.'>"; print "</td></tr>"; /* print("<tr><td align='center'>"); print("First Name"); print("</td><td>"); print("<input name=conf[firstname] value='".$user["firstname"]."' style='width: 100%; background-color: ".MAXINEBACKALT."; border-width: 1px;'>"); print("</td></tr>"); print("<tr><td align='center'>"); print("Last Name"); print("</td><td>"); print("<input name=conf[lastname] value='".$user["lastname"]."' style='width: 100%; background-color: ".MAXINEBACK."; border-width: 1px;'>"); print("</td></tr>"); */ print "<tr><td align='center'>"; print "Position"; print "</td><td>"; print "<input name=conf[position] value='" . $user["position"] . "' style='width: 100%; background-color: " . MAXINEBACKALT . "; border-width: 1px;'>"; print "</td></tr>"; print "</table>"; // } // Contact Details { openSubbar(400); print "Contact Details"; closeSubbar(); print "<table class='standard content1' style='width:400px;'>"; print "<tr><td align='center' width=30%>"; print "Office Extension"; print "</td><td width=70%>"; print "<input name=conf[extension] value='" . $user["extension"] . "' style='width: 100%; background-color: " . MAXINEBACK . "; border-width: 1px;'>"; print "</td></tr>"; print "<tr><td align='center'>"; print "Cell Number"; print "</td><td>"; print "<input name=conf[cell] value='" . $user["cell"] . "' style='width: 100%; background-color: " . MAXINEBACKALT . "; border-width: 1px;'>"; print "</td></tr>"; print "<tr><td align='center'>"; print "Email"; print "</td><td>"; print "<input name=conf[email] value='" . $user["email"] . "' style='width: 100%; background-color: " . MAXINEBACK . "; border-width: 1px;' onblur=\"if (this.value && ((validateEmailAddress(this)) === false)) {alert('Please ensure that the email address you have entered is a valid email address.'); this.value='';}\">"; print "</td></tr>"; print "</table>"; // } // Misc { openSubbar(400); print "Miscellaneous"; closeSubbar(); print "<table class='standard content1' style='width:400px;'>"; // Password { print "<tr><td align='center' width=30%>"; print "Password"; print "</td><td width=70%>"; print "<input type=password name='conf[password]' style='width:200px; margin-top:2px;' title='" . $passtip . "'>"; print "</td></tr>"; // } // Profile { print "<tr><td align='center' width=30%>"; print "User Profile"; print "</td><td width=70%>"; print "<select name=\"conf[user_profiles_id]\">"; print "<option value=\"0\">Please select...</option>"; foreach ($profilelist as $profilekey => $profileval) { print "<option " . ($user["user_profiles_id"] == $profileval["id"] ? "selected" : "") . " value=\"" . $profileval["id"] . "\">"; print $profileval["firstname"] . " " . $profileval["lastname"]; print "</option>"; } print "</select>"; print "</td></tr>"; // } print "</table>"; // } print "</div>"; // } // Right Hand Side { print "<div style='width:400px; margin-right:20px; float:right;'>"; if ($isit == 1) { // Flags { openSubbar(400); print "Flags"; closeSubbar(); print "<table class='standard content1' style='width:400px;'>"; print "<tr><td width=70% align='center'>"; print "Allow Login"; print "</td><td width=30% align='center'>"; print "<input type=checkbox name=conf[canlogin] " . ($user["canlogin"] == 1 ? "checked" : "") . ">"; print "</td></tr>"; print "<tr><td align='center'>"; print "Show on In Out board"; print "</td><td align='center'>"; print "<input type=checkbox name=conf[oninout] " . ($user["oninout"] == 1 ? "checked" : "") . ">"; print "</td></tr>"; print "<tr><td align='center'>"; print "Manager"; print "</td><td align='center'>"; print "<input type=checkbox name=conf[ismanager] " . ($user["ismanager"] == 1 ? "checked" : "") . ">"; print "</td></tr>"; print "<tr><td align='center'>"; print "Supervisor"; print "</td><td align='center'>"; print "<input type=checkbox name=conf[issuper] " . ($user["issuper"] == 1 ? "checked" : "") . ">"; print "</td></tr>"; print "<tr><td align='center'>"; print "Fleet Manager"; print "</td><td align='center'>"; print "<input type='checkbox' name=conf[isfleetman] " . ($user["isfleetman"] == 1 ? "checked" : "") . ">"; print "</td></tr>"; print "<tr><td align='center'>"; print "IT"; print "</td><td align='center'>"; print "<input type=checkbox name=conf[isit] " . ($user["isit"] == 1 ? "checked" : "") . ">"; print "</td></tr>"; print "<tr><td align='center'>"; print "Generic User"; print "</td><td align='center'>"; print "<input type=checkbox name=conf[isgeneric] " . ($user["isgeneric"] == 1 ? "checked" : "") . ">"; print "</td></tr>"; print "<tr><td align='center'>"; print "Place"; print "</td><td align='center'>"; print "<input type=checkbox name=conf[isplace] " . ($user["isplace"] == 1 ? "checked" : "") . ">"; print "</td></tr>"; print "<tr><td align='center'>"; print "Fleets Performance"; print "</td><td align='center'>"; print "<input type='checkbox' name=conf[isfleetper] " . ($user["isfleetper"] == 1 ? "checked" : "") . ">"; print "</td></tr>"; print "<tr><td align='center'>"; print "Damages, Shortages & Incidents"; print "</td><td align='center'>"; print "<input type='checkbox' name=conf[isdamage] " . ($user["isdamage"] == 1 ? "checked" : "") . ">"; print "</td></tr>"; print "</table>"; // } // Groups { openSubbar(400); print "Access Groups"; closeSubbar(); print "<table class='standard content1' style='width:400px'>"; foreach ($rightsgroups as $grpkey => $grpval) { // Individual preparation { $userrights = null; if ($conf["personid"]) { $userrights = $user['rights_users'][$grpval['id']]; } $sel = (string) ""; if ($userrights) { $sel = 'checked="checked"'; } // } print "<tr><td align='center' width=70% title='" . $grpval["description"] . "'>"; print $grpval["name"]; print "</td><td width=30% align='center'>"; print "<input type='checkbox' name=conf[groups][" . $grpval["id"] . "] value=1 " . $sel . ">"; print "</td></tr>"; } print "</table>"; // } } else { print "Flags and Access Groups"; print "Please contact IT to change these settings"; } print "</div"; // } // } print "</div"; print "</form>"; maxineBottom(); // Javascript { print "<script type=\"text/javascript\">\n\t\t\t\t\tfunction testDetails() {return false;}\n\t\t\t\t\tfunction goThrough() {alert('20');}\n\t\t\t\t\t/** validateEmailAddress(obj)\n\t\t\t\t\t* @param obj object HTML element reference\n\t\t\t\t\t* @return true on success false otherwise\n\t\t\t\t\t*/\n\t\t\t\t\tfunction validateEmailAddress(obj) {\n\t\t\t\t\tvar val = obj.value;\n\t\t\t\t\tvar replaced = obj.value.toString().replace('/\\s/', '');\n\t\t\t\t\tif (!val || !replaced) {return false;}\n\t\t\t\t\tif (val.match(/^(.+)@([^@]+)\$/)) {return true;}\n\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\t</script>"; // } }
/** displayUserProfile($profile) * @param array $profile which profile are we displaying? */ function displayUserProfile($profile) { $departments = new TableManager("m3_departments"); $departments->setCustomIndex("id"); $alldepts = $departments->selectMultiple(); if ((!isset($profile["department"]) || !$profile["department"]) && $profile["department_id"]) { $profile["department"] = $alldepts[$profile["department_id"]]["name"]; } echo "<div class=\"userProfile\">" . PHP_EOL; if ($profile["staffno"] && $profile["location"] && date("Y-m-d", strtotime($profile["createDate"])) != "2011-02-01" && $profile["createDate"] > date("Y-m-d H:i:s", strtotime("-2 weeks"))) { echo "<img alt=\"New Staff Member\" src=\"" . BASE . "images/new/profile-new.png\" style=\"border:none;height:37px;left:5px;position:absolute;top:4px;width:38px;z-index:1;\" />"; } ## Image $staffno = $profile["staffno"]; if (strlen($staffno) < 4) { $staffno = str_pad($staffno, 4, "0", STR_PAD_LEFT); } if (file_exists(BASE . "images" . DS . "profiles" . DS . $staffno . ".jpg")) { $size = getimagesize(BASE . "images" . DS . "profiles" . DS . $staffno . ".jpg"); echo "<img alt=\"" . $profile["firstname"] . " " . $profile["lastname"] . "\" src=\"" . BASE . "images" . DS . "profiles" . DS . $staffno . ".jpg\" style=\"height:" . $size[1] . "px;width:" . $size[0] . "px;z-index:0;\" />" . PHP_EOL; } else { $size = getimagesize(BASE . "images" . DS . "profiles" . DS . "0.jpg"); echo "<img alt=\"" . $profile["firstname"] . " " . $profile["lastname"] . "\" src=\"" . BASE . "images" . DS . "profiles" . DS . "0.jpg\" style=\"height:" . $size[1] . "px;width:" . $size[0] . "px;z-index:0;\" />" . PHP_EOL; } $abbrs = (array) array("Human Resources" => "H.R", "Information Technology" => "I.T", "Isando Operations" => "Isando Ops", "Operations Distribution" => "Ops Distribution", "Operations Africa" => "Ops Africa", "Operations Freight" => "Ops Freight"); ## Data echo "<div class=\"userProfileBasicData\">" . PHP_EOL; echo "<h3>" . $profile["firstname"] . " " . $profile["lastname"] . "</h3>" . PHP_EOL; echo "<h4>" . shortenWord(urldecode($profile["jobtitle"]), 23) . "</h5><br />" . PHP_EOL; echo "<label style=\"font-weight:bold;margin-bottom:8px;margin-right:5px;width:80px;\">Department:</label><label style=\"margin-bottom:2px;width:98px;\">" . (isset($profile["department"]) ? in_array($profile["department"], array_keys($abbrs)) ? $abbrs[$profile["department"]] : $profile["department"] : "") . "</label><br class=\"clear\" />" . PHP_EOL; echo "<label style=\"font-weight:bold;margin-bottom:8px;margin-right:5px;width:80px;\">Location:</label><label style=\"margin-bottom:2px;width:98px;\">" . $profile["location"] . "</label><br class=\"clear\" />" . PHP_EOL; echo "<label style=\"font-weight:bold;margin-bottom:8px;margin-right:5px;width:80px;\">Staff No.:</label><label style=\"margin-bottom:2px;width:98px;\">" . $profile["staffno"] . "</label><br class=\"clear\" />" . PHP_EOL; echo "</div>" . PHP_EOL; ## More|Less echo "<div class=\"userProfileMoreLess\" id=\"profile_" . $profile["id"] . "\" onclick=\"events.cancelBubble(event);profiles.show(this);\">more</div>" . PHP_EOL; ## Collapsible div echo "<div class=\"userProfileMoreInformation\" id=\"profileData[" . $profile["id"] . "]\" style=\"display:none;\">" . PHP_EOL; echo "<div>" . PHP_EOL; echo "<label style=\"font-weight:bold;margin-bottom:2px;width:75px;\">Birthday:</label><label style=\"margin-bottom:2px;width:205px;\">" . date("d F", $profile["birthday"]) . "</label><br class=\"clear\" />" . PHP_EOL; if ($profile["interests"]) { echo "<label style=\"font-weight:bold;width:80px;\">Interests:</label><br /><label style=\"margin-bottom:5px;width:100%;\">" . urldecode($profile["interests"]) . "</label><br class=\"clear\" />" . PHP_EOL; } if ($profile["family"]) { echo "<label style=\"font-weight:bold;width:80px;\">Family:</label><br /><label style=\"margin-bottom:5px;width:100%;\">" . urldecode($profile["family"]) . "</label><br class=\"clear\" />" . PHP_EOL; } if ($profile["aspirations"]) { echo "<label style=\"font-weight:bold;width:80px;\">Aspirations:</label><br /><label style=\"margin-bottom:5px;width:100%;\">" . urldecode($profile["aspirations"]) . "</label><br class=\"clear\" />" . PHP_EOL; } if ($profile["goals"]) { echo "<label style=\"font-weight:bold;width:80px;\">Goal:</label><br /><label style=\"margin-bottom:5px;width:100%;\">" . urldecode($profile["goals"]) . "</label><br class=\"clear\" />" . PHP_EOL; } if ($profile["quote"]) { echo "<label style=\"font-weight:bold;width:80px;\">Quote:</label><br /><label style=\"width:100%;\">" . urldecode($profile["quote"]) . "</label><br class=\"clear\" />" . PHP_EOL; } echo "</div>" . PHP_EOL; echo "</div>" . PHP_EOL; echo "</div>" . 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>"; } // } }
/** 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; }