Commit 44d3bb1511da32f4e3e81d82a2ff4803b5c00c03

Authored by michael
1 parent a4a930a3

(#2813) refactored and tidied

incorporated addUnit link


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2498 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/administration/unitmanagement/listUnitsBL.php
@@ -8,75 +8,21 @@ @@ -8,75 +8,21 @@
8 * 8 *
9 */ 9 */
10 10
11 - require_once("../../../../../config/dmsDefaults.php"); 11 +require_once("../../../../../config/dmsDefaults.php");
  12 +require_once("$default->fileSystemRoot/lib/users/User.inc");
  13 +require_once("$default->fileSystemRoot/lib/security/permission.inc");
  14 +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");
  15 +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc");
  16 +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc");
  17 +require_once("$default->fileSystemRoot/presentation/Html.inc");
  18 +require_once("listUnitsUI.inc");
12 19
13 -if (checkSession()) {  
14 - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCreate.inc");  
15 - require_once("listUnitsUI.inc");  
16 -  
17 - require_once("$default->fileSystemRoot/lib/orgmanagement/Organisation.inc");  
18 - require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc");  
19 - require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc");  
20 - require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc");  
21 - require_once("$default->fileSystemRoot/lib/users/User.inc");  
22 - require_once("$default->fileSystemRoot/lib/security/permission.inc");  
23 - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");  
24 - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");  
25 - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc");  
26 - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternBrowsableSearchResults.inc");  
27 - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc");  
28 -  
29 - require_once("$default->fileSystemRoot/presentation/Html.inc");  
30 -  
31 - 20 +if (checkSession()) {
32 $oPatternCustom = & new PatternCustom(); 21 $oPatternCustom = & new PatternCustom();
33 -  
34 -if(checkSession()) {  
35 - global $default;  
36 -  
37 - $oPatternCustom->addHtml(renderHeading("Current System Units")); // Create the Heading  
38 -  
39 - $oPatternCustom->addHtml(getFilterOptions($fOrgID));  
40 -  
41 - $main->setFormAction($_SERVER['PHP_SELF']);  
42 -  
43 - if($fOrgID != "") { // Filter Option  
44 - $sWhereStatement = "WHERE units_organisations_link.organisation_id =$fOrgID ";  
45 - $oOrg = Organisation::get($fOrgID);  
46 - $oPatternCustom->addHtml("<br><table><tr><td><b>Current Organisation filter:</b></td><td>" . $oOrg->getName() . "</td></tr></table>");  
47 - } else {  
48 - $oPatternCustom->addHtml("<br><table><tr><td><b><b>No Organisation filter</b></td></tr></table>");  
49 - }  
50 - $sQuery = "SELECT units_lookup.id as unitID, units_lookup.name as name, " .  
51 - "'Edit', 'Delete', 'Edit Organisations', " .  
52 - "CASE WHEN organisations_lookup.name Is Null THEN '<font color=darkgrey>* No Organisation</font>' ELSE organisations_lookup.name END AS OrgName " .  
53 - "FROM (units_lookup " .  
54 - "LEFT JOIN units_organisations_link ON units_lookup.id = units_organisations_link.unit_id) " .  
55 - "LEFT JOIN organisations_lookup ON units_organisations_link.organisation_id = organisations_lookup.id " .  
56 - $sWhereStatement . " " .  
57 - "ORDER BY units_lookup.name";  
58 -  
59 -  
60 - $aColumns = array("name", "OrgName", "Edit", "Delete", "Edit Organisations");  
61 - $aColumnNames = array("Unit Name", "Organisation", "Edit", "Delete", "Edit Organisations");  
62 - $aColumnTypes = array(1,1,3,3,3);  
63 - $aDBColumnArray = array("unitID");  
64 - $aQueryStringVariableNames = array("fUnitID");  
65 -  
66 - $aHyperLinkURL = array( 2=> "$default->rootUrl/control.php?action=editUnit",  
67 - 3=> "$default->rootUrl/control.php?action=removeUnit",  
68 - 4=> "$default->rootUrl/control.php?action=editUnitOrg");  
69 -  
70 - $oSearchResults = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnNames, "100%", $aHyperLinkURL,$aDBColumnArray,$aQueryStringVariableNames);  
71 -  
72 - $oSearchResults->setDisplayColumnHeadings(true);  
73 - $htmlTables = $oSearchResults->render() ;  
74 -  
75 - $oPatternCustom->addHtml($htmlTables);  
76 -  
77 - } // end of if checksession  
78 - 22 + $oPatternCustom->setHtml(getPage($fOrganisationID));
  23 + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
79 $main->setCentralPayload($oPatternCustom); 24 $main->setCentralPayload($oPatternCustom);
80 - $main->render(); 25 + $main->setFormAction($_SERVER['PHP_SELF']);
  26 + $main->render();
81 } 27 }
82 -?> 28 -?>
  29 +?>
83 \ No newline at end of file 30 \ No newline at end of file
presentation/lookAndFeel/knowledgeTree/administration/unitmanagement/listUnitsUI.inc
@@ -8,47 +8,57 @@ @@ -8,47 +8,57 @@
8 * 8 *
9 */ 9 */
10 10
11 -function getSubmit() { 11 +function getAddUnitLink() {
12 global $default; 12 global $default;
13 - $sToRender = "<input type=\"image\" src =\"$default->graphicsUrl/widgets/select.gif\" value=\"submit\" border=\"0\"/>\n";  
14 - return $sToRender; 13 + $sBGColor = $default->siteMap->getSectionColour("Administration", "td");
  14 + return "<table width=\"100%\"><tr><td bgcolor=\"$sBGColor\">" . generateControllerLink("addUnit", "", "<font color=\"#ffffff\">Add A Unit</font>") . "</td></tr></table>\n";
15 } 15 }
16 16
17 -// display the listbox initially ..then just display the text  
18 -function getOrgDisplay($fOrgID, $iSelectedValue = 0) { 17 +function getOrganisationDisplay($fOrganisationID) {
19 global $default; 18 global $default;
20 -  
21 - // if this is the system administrator, prepend group names with unit name  
22 - $oPatternListBox = & new PatternListBox($default->owl_organisations_table, "name", "id", "fOrgID");  
23 -  
24 - if ($fOrgID != 0) {  
25 - //$oPatternListBox->setSelectedValue($iSelectedValue);  
26 - $oPatternListBox->setSelectedValue($fOrgID);  
27 - }  
28 -  
29 - return $oPatternListBox->render(); 19 + $oPatternListBox = & new PatternListBox($default->owl_organisations_table, "name", "id", "fOrganisationID");
  20 + $oPatternListBox->setPostBackOnChange(true);
  21 + if ($fOrganisationID != 0) {
  22 + $oPatternListBox->setSelectedValue($fOrganisationID);
  23 + }
  24 + return "<table><tr><td><b>Filter By Organisation </b></td><td>" . $oPatternListBox->render() . "</td></tr></table>";
30 } 25 }
31 26
32 -  
33 -function getFilterOptions($fOrgID = 0){ 27 +function getUnits($fOrganisationID) {
34 global $default; 28 global $default;
35 29
36 - $sToRender .= "<table>\n";  
37 - $sToRender .= "<tr>\n";  
38 - $sToRender .= "<td>\n";  
39 - $sToRender .= "<b>Filter by Organisation</b>";  
40 - $sToRender .= "</td>\n";  
41 - $sToRender .= "<td>\n";  
42 - $sToRender .= getOrgDisplay($fOrgID);  
43 - $sToRender .= "</td>\n";  
44 - $sToRender .= "<td>\n";  
45 - $sToRender .= "<input type=\"image\" src =\"$default->graphicsUrl/widgets/select.gif\" value=\"submit\" border=\"0\"/>\n";  
46 - $sToRender .= "</td>\n";  
47 - $sToRender .= "</tr>\n";  
48 - $sToRender .= "</table>\n";  
49 -  
50 - return $sToRender ; 30 + $sQuery = "SELECT units_lookup.id as unitID, units_lookup.name as name, " .
  31 + "'Edit', 'Delete', 'Edit Organisations', " .
  32 + "CASE WHEN organisations_lookup.name Is Null THEN '<font color=darkgrey>* No Organisation</font>' ELSE organisations_lookup.name END AS OrgName " .
  33 + "FROM (units_lookup " .
  34 + "LEFT JOIN units_organisations_link ON units_lookup.id = units_organisations_link.unit_id) " .
  35 + "LEFT JOIN organisations_lookup ON units_organisations_link.organisation_id = organisations_lookup.id " .
  36 + ($fOrganisationID ? "WHERE units_organisations_link.organisation_id = $fOrganisationID " : "") .
  37 + "ORDER BY units_lookup.name";
  38 +
  39 + $aColumns = array("name", "OrgName", "Edit", "Delete", "Edit Organisations");
  40 + $aColumnNames = array("Unit Name", "Organisation", "Edit", "Delete", "Edit Organisations");
  41 + $aColumnTypes = array(1,1,3,3,3);
  42 + $aDBColumnArray = array("unitID");
  43 + $aQueryStringVariableNames = array("fUnitID");
  44 +
  45 + $aHyperLinkURL = array( 2=> "$default->rootUrl/control.php?action=editUnit",
  46 + 3=> "$default->rootUrl/control.php?action=removeUnit",
  47 + 4=> "$default->rootUrl/control.php?action=editUnitOrg");
  48 +
  49 + $oSearchResults = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnNames, "100%", $aHyperLinkURL,$aDBColumnArray,$aQueryStringVariableNames);
  50 + $oSearchResults->setDisplayColumnHeadings(true);
  51 + return $oSearchResults->render() ;
51 } 52 }
52 53
  54 +function getPage($fOrganisationID) {
  55 + global $default;
  56 + $sToRender .= renderHeading("Current System Units");
53 57
  58 + // add user link
  59 + $sToRender .= getAddUnitLink();
  60 + $sToRender .= getOrganisationDisplay($fOrganisationID);
  61 + $sToRender .= getUnits($fOrganisationID);
  62 + return $sToRender;
  63 +}
54 ?> 64 ?>
55 \ No newline at end of file 65 \ No newline at end of file