viewDependantDocumentsUI.inc
11.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<?php
function renderHeading($sHeading) {
global $default;
$sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"])));
$sColor = $default->siteMap->getSectionColour($sSectionName, "th");
$sToRender = "<table border=\"0\" width=\"600\">\n";
$sToRender .= "<tr align=\"left\"><th class=\"sectionHeading\" bgcolor=\"$sColor\">$sHeading</th></tr>\n";
$sToRender .= "<tr/>\n";
$sToRender .= "<tr/>\n";
$sToRender .= "</table>\n";
return $sToRender;
}
function getFolderPath($iFolderID) {
global $default;
$sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"])));
$sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td");
$sFolderPathLink = displayFolderPathLink(Folder::getFolderPathAsArray($iFolderID), Folder::getFolderPathNamesAsArray($iFolderID), "$default->rootUrl/control.php?action=browse");
return "<table border=\"0\" width = 100%><tr><td bgcolor=\"$sTDBGColour\">$sFolderPathLink</td></tr></table>\n";
}
function getDocumentLinkFolderCollaborationData($iFolderCollaborationID) {
global $default;
$sQuery = "SELECT DDT.id, GFAL.folder_id AS folder_id, U.name AS username, DDT.document_title, D.name AS template_document_name, D.id AS template_document_id, DDT.group_folder_approval_link_id, 'Edit' AS edit, 'Delete' AS del " .
"FROM dependant_document_template AS DDT INNER JOIN groups_folders_approval_link AS GFAL ON DDT.group_folder_approval_link_id = GFAL.id " .
"INNER JOIN users AS U ON U.id = DDT.default_user_id " .
"LEFT OUTER JOIN documents AS D ON D.id = DDT.template_document_id " .
"WHERE DDT.group_folder_approval_link_id = $iFolderCollaborationID";
//echo $sQuery;
$aColumns = array("document_title", "username", "template_document_name","edit", "del");
$aColumnHeaders = array("Document title", "Default creator", "Template document");
$aColumnTypes = array(1,1,3,3,3);
//$aDBColumnArray = array("id","group_folder_approval_link_id","template_document_id");
$aDBColumnArray = array("id","group_folder_approval_link_id","folder_id");
//$aQueryStringVariableNames = array("fDependantDocumentTemplateID", "fFolderCollaborationID", "fTargetDocumentID");
$aQueryStringVariableNames = array("fDependantDocumentTemplateID","fFolderCollaborationID","fFolderID");
$aLinkURLs = array(2=>"$default->rootUrl/control.php?action=viewDocument", 3=>"$default->rootUrl/control.php?action=viewDependantDocument&fForEdit=1", 4=>"$default->rootUrl/control.php?action=deleteDependantDocument");
$oPatternTableSqlQuery = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnHeaders, "90%", $aLinkURLs, $aDBColumnArray,$aQueryStringVariableNames);
$oPatternTableSqlQuery->setTableHeading("Dependant Documents");
$oPatternTableSqlQuery->setDisplayColumnHeadings(true);
$oPatternTableSqlQuery->setEmptyTableMessage("No dependant documents");
return $oPatternTableSqlQuery->render();
}
function getViewPage($iFolderCollaborationID, $iFolderID) {
global $default;
$sToRender = renderHeading("Dependant documents");
$sToRender .= getFolderPath($iFolderID);
$sToRender .= "<table border=\"0\" width=\"100%\">\n";
$sToRender .= "<tr>\n";
$sToRender .= "<td>" . getDocumentLinkFolderCollaborationData($iFolderCollaborationID) . "</td>\n";
$sToRender .= "</tr>\n";
$sToRender .= "<tr>\n";
$sToRender .= "<td><table><tr><td><input type=\"image\" src=\"$default->graphicsUrl/widgets/add.gif\" border=\"0\"/></td><td></td></tr></table>\n";
$sToRender .= "</tr>\n";
$sToRender .= "</table>\n";
return $sToRender;
}
function getEditPage($iFolderID, $iDependantDocumentID, $iFolderCollaborationID, $sDocumentTitle, $sTemplateDocumentName, $iDocumentID, $iUserID) {
global $default;
$iDefaultUserUnitID = User::getUnitID($iUserID);
$sToRender = renderHeading("Dependant documents");
$sToRender .= getFolderPath($iFolderID);
$sToRender .= "<table border=\"0\" width=\"100%\">\n";
$sToRender .= "<tr>\n";
$sToRender .= "<td>Document title</td><td><input type=\"text\" name=\"fDocumentTitle\" value=\"$sDocumentTitle\" /></td>\n";
$sToRender .= "</tr>\n";
$sToRender .= "<tr>\n";
$sToRender .= "<td>User's Unit</td><td>" . getUnitDropDown($iFolderCollaborationID, $iFolderID, $iDefaultUserUnitID) . "</td>\n";
$sToRender .= "</tr>\n";
$sToRender .= "<tr>\n";
$sToRender .= "<td>User</td><td>" . getUserDropDown($iDefaultUserUnitID, $iUserID) . "</td>\n";
$sToRender .= "</tr>\n";
$sToRender .= "<tr>\n";
//had a slight problem with netscape 4.7x - it doesn't support disabled. So I had to use
//javascript to set the onFocus attribute to blur
$bAddNetscapeScript = false;
if (! (($default->phpSniff->property("browser") == "moz") && ($default->phpSniff->property("version") <= "4.79")) ) {
//for any other browser but netscape 4.7 do this
$sToRender .= "<td>Template document</td><td><input type=\"text\" DISABLED name=\"fTargetDocument\" value=\"$sTemplateDocumentName\" /><input type=\"button\" value=\"Browse\" onClick=\"newWindow('http://ktdev/control.php?action=templateBrowse','window2')\"></td>\n";
}else {
//for netscape 4.7 do this
$sToRender .= "<td>Template document</td><td><input type=\"text\" value=\"$sTemplateDocumentName\" name=\"fTargetDocument\" onblur=\"disable(document.MainForm.fTargetDocument);\" /><input type=\"button\" value=\"Browse\" onClick=\"disable(document.MainForm.fTargetDocument);newWindow('http://ktdev/control.php?action=templateBrowse','window2')\"></td>\n";
$bAddNetscapeScript = true;
}
$sToRender .= "</tr>\n";
$sToRender .= "<tr>\n";
$sToRender .= "<td><table><tr><td><input type=\"image\" src=\"$default->graphicsUrl/widgets/update.gif\" border=\"0\"/></td><td><a href=\"" . $default->rootUrl . "/control.php?action=viewDependantDocument&fFolderID=$iFolderID&fFolderCollaborationID=$iFolderCollaborationID\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"/></a></td></tr></table>\n";
$sToRender .= "</tr>\n";
$sToRender .= "</table>\n";
$sToRender .= "<input type=\"hidden\" name=\"fTargetDocumentID\" value=\"-1\" />\n";
return $sToRender . "\n\n" . getValidationJavaScript() . "\n\n" . getBrowseJavaScript() . ($bAddNetscapeScript ? getNetscapeDisableScript() : "");
}
function getAddPage($iFolderCollaborationID, $iFolderID, $iUnitID, $sDocumentTitle, $sTemplateDocument, $iDocumentID) {
global $default;
$sToRender = renderHeading("Dependant documents");
$sToRender .= getFolderPath($iFolderID);
$sToRender .= "<table border=\"0\" width=\"100%\">\n";
$sToRender .= "<tr>\n";
$sToRender .= "<td>Document title</td><td><input type=\"text\" name=\"fDocumentTitle\" value=\"$sDocumentTitle\" /></td>\n";
$sToRender .= "</tr>\n";
$sToRender .= "<tr>\n";
$sToRender .= "<td>User's Unit</td><td>" . getUnitDropDown($iFolderCollaborationID, $iFolderID, $iUnitID) . "</td>\n";
$sToRender .= "</tr>\n";
$sToRender .= "<tr>\n";
$sToRender .= "<td>User</td><td>" . getUserDropDown($iUnitID) . "</td>\n";
$sToRender .= "</tr>\n";
$sToRender .= "<tr>\n";
//had a slight problem with netscape 4.7x - it doesn't support disabled. So I had to use
//javascript to set the onFocus attribute to blur
$bAddNetscapeScript = false;
if (! (($default->phpSniff->property("browser") == "moz") && ($default->phpSniff->property("version") <= "4.79")) ) {
//for any other browser but netscape 4.7 do this
//$sToRender .= "<td>Template document</td><td><input type=\"text\" DISABLED name=\"fTargetDocument\" value=\"$sTemplateDocument\" /><input type=\"button\" value=\"Browse\" onClick=\"newWindow('http://ktdev/control.php?action=templateBrowse','window2')\"></td>\n";
$sToRender .= "<td>Template document</td><td><input type=\"text\" DISABLED name=\"fTargetDocument\" value=\"$sTemplateDocument\" /><input type=\"button\" value=\"Browse\" onClick=\"newWindow('$default->rootUrl/control.php?action=templateBrowse','window2')\"></td>\n";
}else {
//for netscape 4.7 do this
//$sToRender .= "<td>Template document</td><td><input type=\"text\" name=\"fTargetDocument\" onblur=\"disable(document.MainForm.fTargetDocument);\" /><input type=\"button\" value=\"Browse\" onClick=\"disable(document.MainForm.fTargetDocument);newWindow('http://ktdev/control.php?action=templateBrowse','window2')\"></td>\n";
$sToRender .= "<td>Template document</td><td><input type=\"text\" name=\"fTargetDocument\" onblur=\"disable(document.MainForm.fTargetDocument);\" /><input type=\"button\" value=\"Browse\" onClick=\"disable(document.MainForm.fTargetDocument);newWindow('$default->rootUrl/control.php?action=templateBrowse','window2')\"></td>\n";
$bAddNetscapeScript = true;
}
$sToRender .= "</tr>\n";
$sToRender .= "<tr>\n";
$sToRender .= "<td><table><tr><td><input type=\"image\" src=\"$default->graphicsUrl/widgets/done.gif\" border=\"0\"/></td><td><a href=\"" . $default->rootUrl . "/control.php?action=viewDependantDocument&fFolderID=$iFolderID&fFolderCollaborationID=$iFolderCollaborationID\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"/></a></td></tr></table>\n";
$sToRender .= "</tr>\n";
$sToRender .= "</table>\n";
$sToRender .= "<input type=\"hidden\" name=\"fTargetDocumentID\" value=\"-1\" />\n";
return $sToRender . "\n\n" . getValidationJavaScript() . "\n\n" . getBrowseJavaScript() . ($bAddNetscapeScript ? getNetscapeDisableScript() : "");
}
function getUserDropDown($iUnitID, $iUserID = null) {
global $default;
$oPatternListBox = & new PatternListBox($default->owl_users_table, "Name", "id", "fUserID", "GUL.unit_id = $iUnitID");
$sFromClause = "INNER join users_groups_link AS UGL ON UGL.user_id = ST.id " .
"INNER JOIN groups_units_link AS GUL ON GUL.group_id = UGL.group_id ";
$oPatternListBox->setFromClause($sFromClause);
if (isset($iUserID)) {
$oPatternListBox->setSelectedValue($iUserID);
}
return $oPatternListBox->render();
}
function getUnitDropDown($iFolderCollaborationID, $iFolderID, $iUnitID = null) {
global $default;
$oPatternListBox = & new PatternListBox($default->owl_units_table, "Name", "id", "fUnitID");
$oPatternListBox->setPostBackOnChange(true);
$oPatternListBox->setOnChangeAction("setActionAndSubmit('" . $_SERVER["PHP_SELF"] . "?fFolderID=$iFolderID&fFolderCollaborationID=$iFolderCollaborationID&fForAdd=1')");
if (isset($iUnitID)) {
$oPatternListBox->setSelectedValue($iUnitID);
}
return $oPatternListBox->render();
}
function getValidationJavaScript() {
$sToRender .= "\n\n<script language=\"javascript\">\n<!--\n";
$sToRender .= "function validateForm(theForm) {\n";
$sToRender .= "\tif (!(validRequired(theForm.fDocumentTitle,'Document title') && validRequired(theForm.fUserID,'User'))) {\n";
$sToRender .= "\t\treturn false;\n\t}\n";
$sToRender .= "return true;\n}\n";
$sToRender .= "//-->\n</script>\n\n";
return $sToRender;
}
function getBrowseJavaScript() {
$sToRender = "<script language=\"JavaScript\"><!--\n ";
$sToRender .= "function newWindow(file,window) {\n ";
$sToRender .= "\tmsgWindow=open(file,window,'resizable=yes,scrollbars=yes, width=400,height=600');\n ";
$sToRender .= "\tif (msgWindow.opener == null) msgWindow.opener = self; \n ";
$sToRender .= "}\n";
$sToRender .= "//--></script>\n";
return $sToRender;
}
function getNetscapeDisableScript() {
$sToRender = "<script language=\"JavaScript\"><!--\n ";
$sToRender .= "function disable(elem) {\n";
$sToRender .= "\telem.onfocus=elem.blur;\n";
$sToRender .= "}\n";
$sToRender .= "//--></script>\n\n";
return $sToRender;
}
?>