diff --git a/presentation/lookAndFeel/knowledgeTree/administration/unitmanagement/listUnitsBL.php b/presentation/lookAndFeel/knowledgeTree/administration/unitmanagement/listUnitsBL.php
index a4be505..31c5e64 100644
--- a/presentation/lookAndFeel/knowledgeTree/administration/unitmanagement/listUnitsBL.php
+++ b/presentation/lookAndFeel/knowledgeTree/administration/unitmanagement/listUnitsBL.php
@@ -8,75 +8,21 @@
*
*/
- require_once("../../../../../config/dmsDefaults.php");
+require_once("../../../../../config/dmsDefaults.php");
+require_once("$default->fileSystemRoot/lib/users/User.inc");
+require_once("$default->fileSystemRoot/lib/security/permission.inc");
+require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");
+require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc");
+require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc");
+require_once("$default->fileSystemRoot/presentation/Html.inc");
+require_once("listUnitsUI.inc");
-if (checkSession()) {
- require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCreate.inc");
- require_once("listUnitsUI.inc");
-
- require_once("$default->fileSystemRoot/lib/orgmanagement/Organisation.inc");
- require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc");
- require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc");
- require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc");
- require_once("$default->fileSystemRoot/lib/users/User.inc");
- require_once("$default->fileSystemRoot/lib/security/permission.inc");
- require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
- require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");
- require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc");
- require_once("$default->fileSystemRoot/lib/visualpatterns/PatternBrowsableSearchResults.inc");
- require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc");
-
- require_once("$default->fileSystemRoot/presentation/Html.inc");
-
-
+if (checkSession()) {
$oPatternCustom = & new PatternCustom();
-
-if(checkSession()) {
- global $default;
-
- $oPatternCustom->addHtml(renderHeading("Current System Units")); // Create the Heading
-
- $oPatternCustom->addHtml(getFilterOptions($fOrgID));
-
- $main->setFormAction($_SERVER['PHP_SELF']);
-
- if($fOrgID != "") { // Filter Option
- $sWhereStatement = "WHERE units_organisations_link.organisation_id =$fOrgID ";
- $oOrg = Organisation::get($fOrgID);
- $oPatternCustom->addHtml("
Current Organisation filter: " . $oOrg->getName() . "
");
- } else {
- $oPatternCustom->addHtml(" ");
- }
- $sQuery = "SELECT units_lookup.id as unitID, units_lookup.name as name, " .
- "'Edit', 'Delete', 'Edit Organisations', " .
- "CASE WHEN organisations_lookup.name Is Null THEN '* No Organisation ' ELSE organisations_lookup.name END AS OrgName " .
- "FROM (units_lookup " .
- "LEFT JOIN units_organisations_link ON units_lookup.id = units_organisations_link.unit_id) " .
- "LEFT JOIN organisations_lookup ON units_organisations_link.organisation_id = organisations_lookup.id " .
- $sWhereStatement . " " .
- "ORDER BY units_lookup.name";
-
-
- $aColumns = array("name", "OrgName", "Edit", "Delete", "Edit Organisations");
- $aColumnNames = array("Unit Name", "Organisation", "Edit", "Delete", "Edit Organisations");
- $aColumnTypes = array(1,1,3,3,3);
- $aDBColumnArray = array("unitID");
- $aQueryStringVariableNames = array("fUnitID");
-
- $aHyperLinkURL = array( 2=> "$default->rootUrl/control.php?action=editUnit",
- 3=> "$default->rootUrl/control.php?action=removeUnit",
- 4=> "$default->rootUrl/control.php?action=editUnitOrg");
-
- $oSearchResults = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnNames, "100%", $aHyperLinkURL,$aDBColumnArray,$aQueryStringVariableNames);
-
- $oSearchResults->setDisplayColumnHeadings(true);
- $htmlTables = $oSearchResults->render() ;
-
- $oPatternCustom->addHtml($htmlTables);
-
- } // end of if checksession
-
+ $oPatternCustom->setHtml(getPage($fOrganisationID));
+ require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
$main->setCentralPayload($oPatternCustom);
- $main->render();
+ $main->setFormAction($_SERVER['PHP_SELF']);
+ $main->render();
}
-?>
+?>
\ No newline at end of file
diff --git a/presentation/lookAndFeel/knowledgeTree/administration/unitmanagement/listUnitsUI.inc b/presentation/lookAndFeel/knowledgeTree/administration/unitmanagement/listUnitsUI.inc
index 1212ffb..7be2074 100644
--- a/presentation/lookAndFeel/knowledgeTree/administration/unitmanagement/listUnitsUI.inc
+++ b/presentation/lookAndFeel/knowledgeTree/administration/unitmanagement/listUnitsUI.inc
@@ -8,47 +8,57 @@
*
*/
-function getSubmit() {
+function getAddUnitLink() {
global $default;
- $sToRender = " graphicsUrl/widgets/select.gif\" value=\"submit\" border=\"0\"/>\n";
- return $sToRender;
+ $sBGColor = $default->siteMap->getSectionColour("Administration", "td");
+ return "" . generateControllerLink("addUnit", "", "Add A Unit ") . "
\n";
}
-// display the listbox initially ..then just display the text
-function getOrgDisplay($fOrgID, $iSelectedValue = 0) {
+function getOrganisationDisplay($fOrganisationID) {
global $default;
-
- // if this is the system administrator, prepend group names with unit name
- $oPatternListBox = & new PatternListBox($default->owl_organisations_table, "name", "id", "fOrgID");
-
- if ($fOrgID != 0) {
- //$oPatternListBox->setSelectedValue($iSelectedValue);
- $oPatternListBox->setSelectedValue($fOrgID);
- }
-
- return $oPatternListBox->render();
+ $oPatternListBox = & new PatternListBox($default->owl_organisations_table, "name", "id", "fOrganisationID");
+ $oPatternListBox->setPostBackOnChange(true);
+ if ($fOrganisationID != 0) {
+ $oPatternListBox->setSelectedValue($fOrganisationID);
+ }
+ return "Filter By Organisation " . $oPatternListBox->render() . "
";
}
-
-function getFilterOptions($fOrgID = 0){
+function getUnits($fOrganisationID) {
global $default;
- $sToRender .= "\n";
-
- return $sToRender ;
+ $sQuery = "SELECT units_lookup.id as unitID, units_lookup.name as name, " .
+ "'Edit', 'Delete', 'Edit Organisations', " .
+ "CASE WHEN organisations_lookup.name Is Null THEN '* No Organisation ' ELSE organisations_lookup.name END AS OrgName " .
+ "FROM (units_lookup " .
+ "LEFT JOIN units_organisations_link ON units_lookup.id = units_organisations_link.unit_id) " .
+ "LEFT JOIN organisations_lookup ON units_organisations_link.organisation_id = organisations_lookup.id " .
+ ($fOrganisationID ? "WHERE units_organisations_link.organisation_id = $fOrganisationID " : "") .
+ "ORDER BY units_lookup.name";
+
+ $aColumns = array("name", "OrgName", "Edit", "Delete", "Edit Organisations");
+ $aColumnNames = array("Unit Name", "Organisation", "Edit", "Delete", "Edit Organisations");
+ $aColumnTypes = array(1,1,3,3,3);
+ $aDBColumnArray = array("unitID");
+ $aQueryStringVariableNames = array("fUnitID");
+
+ $aHyperLinkURL = array( 2=> "$default->rootUrl/control.php?action=editUnit",
+ 3=> "$default->rootUrl/control.php?action=removeUnit",
+ 4=> "$default->rootUrl/control.php?action=editUnitOrg");
+
+ $oSearchResults = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnNames, "100%", $aHyperLinkURL,$aDBColumnArray,$aQueryStringVariableNames);
+ $oSearchResults->setDisplayColumnHeadings(true);
+ return $oSearchResults->render() ;
}
+function getPage($fOrganisationID) {
+ global $default;
+ $sToRender .= renderHeading("Current System Units");
+ // add user link
+ $sToRender .= getAddUnitLink();
+ $sToRender .= getOrganisationDisplay($fOrganisationID);
+ $sToRender .= getUnits($fOrganisationID);
+ return $sToRender;
+}
?>
\ No newline at end of file