bulkUploadUI.inc
10.6 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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
<?php
/**
* $Id$
*
* Contains HTML information required to build the bulk upload page.
* Will be used by bulkUploadBL.php
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @version $Revision$
* @author Adam Monsen
* @package documentmanagement
*/
/**
* Displays the generic meta data fields form
*/
function getGenericMetaDataForm() {
global $default;
/*ok*/ $sQuery = "SELECT DISTINCT -1 AS document_id, DF.id AS document_field_id, DF.name AS field_name, -1 AS id " .
"FROM document_fields AS DF LEFT OUTER JOIN document_fields_link AS DFL ON DF.id = DFL.document_field_id " .
"WHERE DF.is_generic = 1 ";
$aStoreColumnNames = array("document_id", "document_field_id", "value");
$aDisplayColumnNames = array("document_id", "field_name", "value");
$aMetaDataColumnNames = array(2=>"field_name");
$aColumnsEditable = array(0,0,1);
$aColumnsVisible = array(0,1,1);
$aColumnDisplayTypes = array(1,1,4);
$aColumnDatabaseTypes = array(4,0,1);
$oPatternTableSqlQuery = & new PatternEditableTableSqlQuery($sQuery, "document_fields_link", $aStoreColumnNames, $aDisplayColumnNames, $aColumnsEditable, $aColumnsVisible, $aColumnDisplayTypes, $aColumnDatabaseTypes);
$oPatternTableSqlQuery->setTableCaption("Generic Meta Data");
$oPatternTableSqlQuery->setUniqueName("gmd");
$oPatternTableSqlQuery->setRequiredColumnNames(array("value"));
$oPatternTableSqlQuery->setMetaDataFields($aMetaDataColumnNames);
$oPatternTableSqlQuery->setEmptyTableMessage("No Generic Meta Data");
$oPatternTableSqlQuery->setRenderJavascriptValidation(false);
return $oPatternTableSqlQuery;
}
/**
* Displays the type specific meta data fields form
*/
function getTypeSpecificMetaDataForm($iFolderID, $iDocumentTypeID) {
global $default;
/*ok*/ $sQuery = array("SELECT DISTINCT -1 AS document_id, DF.id AS document_field_id, DF.name AS field_name, DTFL.is_mandatory AS is_mandatory, -1 AS id " .
"FROM document_type_fields_link AS DTFL INNER JOIN document_fields AS DF ON DTFL.field_id = DF.id " .
"LEFT OUTER JOIN document_fields_link AS DFL ON DFL.document_field_id = DTFL.field_id " .
"WHERE DF.is_generic = 0 " .
"AND DTFL.document_type_id = ?", $iDocumentTypeID);
$aStoreColumnNames = array("document_id", "document_field_id", "value");
$aDisplayColumnNames = array("document_id", "field_name", "value");
$aColumnsEditable = array(0,0,1);
$aColumnsVisible = array(0,1,1);
$aColumnDisplayTypes = array(1,1,4);
$aColumnDatabaseTypes = array(4,0,1);
$aMetaDataColumnNames = array(2=>"field_name");
$oPatternTableSqlQuery = & new PatternEditableTableSqlQuery($sQuery, "document_fields_link", $aStoreColumnNames, $aDisplayColumnNames, $aColumnsEditable, $aColumnsVisible, $aColumnDisplayTypes, $aColumnDatabaseTypes);
$oPatternTableSqlQuery->setTableCaption("Type specific meta data");
$oPatternTableSqlQuery->setEmptyTableMessage("No Type Specific Meta Data");
$oPatternTableSqlQuery->setUniqueName("tsmd");
$oPatternTableSqlQuery->setMetaDataFields($aMetaDataColumnNames);
$oPatternTableSqlQuery->setRenderJavascriptValidation(false);
return $oPatternTableSqlQuery;
}
function getMetaDataForm($iFolderID, $iDocumentTypeID) {
$oGenericPattern = getGenericMetaDataForm();
$oTypeSpecificPattern = getTypeSpecificMetaDataForm($iFolderID, $iDocumentTypeID);
$sToRender .= "<table border=\"0\" width=\"100%\">\n";
$sToRender .= "<tr><td><b>Document Meta Data<b></td></tr>\n";
$sToRender .= "<tr><td valign=\"top\">" . $oGenericPattern->render() . "</td><td valign=\"top\">" . $oTypeSpecificPattern->render() . "</td></tr>";
$sToRender .= "</table>";
// validation starts
$sToRender .= "\n\n<script language=\"javascript\">\n<!--\n";
$sToRender .= "function validateForm(theForm) {\n";
// filename
$sToRender .= "\tif (!(validRequired(theForm.fFile, 'Bulk Upload Zipfile'))) {\n";
$sToRender .= "\t\treturn false;\n\t}\n";
// metadata
$sToRender .= $oGenericPattern->getValidationJavascript();
$sToRender .= $oTypeSpecificPattern->getValidationJavascript();
$sToRender .= "return true;\n}\n";
$sToRender .= "//-->\n</script>\n\n";
return $sToRender;
}
function getDocumentType($iFolderID) {
global $default;
$sWhereClause = "FDL.folder_id = $iFolderID";
$oPatternListBox = & new PatternListBox("$default->document_types_table", "name", "id", "fDocumentTypeID",$sWhereClause);
$oPatternListBox->setIncludeDefaultValue(false);
$oPatternListBox->setFromClause("INNER JOIN $default->folder_doctypes_table AS FDL ON ST.id = FDL.document_type_id");
$oPatternListBox->setEmptyErrorMessage(_("No document types defined") . "! " . _("Please contact an Administrator"));
$sHeading = "Please select the document type:";
$sToRender = "<table><tr><td><b>$sHeading<b></td></tr><tr><td>" . $oPatternListBox->render() . "</td></tr></table>";
return $sToRender;
}
function getChooseDocumentTypePage($iFolderID) {
global $default;
$oFolder = Folder::get($iFolderID);
if (Permission::userHasFolderWritePermission($oFolder)) {
$sToRender .= getDocumentType($iFolderID);
$sActionButtons .= getCancelButton($iFolderID);
$sActionButtons .= "<input type=\"image\" src=\"" . KTHtml::getAddButton() . "\" border=\"0\"/>";
$sToRender .= "<table border=\"0\" width=\"100%\" >\n";
$sToRender .= "<tr><td>$sActionButtons</td></tr>";
$sToRender .= "</table>";
}
// display subfolders, if any
$sToRender .= getSubfolderBrowser($iFolderID, $iDocumentTypeID);
return $sToRender;
}
// display subfolders, if any
function getSubfolderBrowser($iFolderID, $iDocumentTypeID) {
$sToRender .= "<table border=\"0\" width=\"100%\">\n";
$sToRender .= "<tr>\n";
$sToRender .= "\t<td>" . renderFolderList($iFolderID, generateControllerUrl("bulkUpload", "fDocumentTypeID=$iDocumentTypeID", false)) . "<td>\n";
$sToRender .= "</tr>\n";
$sToRender .= "<tr>\n";
$sToRender .= "</tr>";
$sToRender .= "</table><br>\n";
return $sToRender;
}
function getPage($iFolderID, $iDocumentTypeID) {
global $default;
$sToRender .= renderFolderPath($iFolderID, generateControllerUrl("bulkUpload", "fDocumentTypeID=$iDocumentTypeID", false), true);
$sToRender .= "<input type=\"hidden\" name=\"fDocumentTypeID\" value=\"$iDocumentTypeID\">";
$sToRender .= "<input type=\"hidden\" name=\"fStore\" value=\"1\">";
$sToRender .= "<input type=\"hidden\" name=\"postReceived\" value=\"1\">";
$sToRender .= "<table>\n";
$sToRender .= "<tr>\n";
$sToRender .= "<td colspan=\"2\"><b>" . _("Bulk Upload Zipfile") . ": <b></td>\n";
$sToRender .= "</tr>\n";
$sToRender .= "<tr><td>File: </td><td><input type=\"file\" name=\"fFile\"></td></tr>\n";
$sToRender .= "<tr><td colspan=\"2\">(" . _("Note: file should be a ZIP file without subdirectories. Details entered below apply to ALL documents to be added.") . ")</td></tr>\n";
$sToRender .= "</table>\n";
$sToRender .= "<table><tr><td><b>" . _("Document Type") . "<b></td></tr><tr><td>" . lookupName($default->document_types_table, $iDocumentTypeID) . "</td></tr></table>";
$sToRender .= getMetaDataForm($iFolderID, $iDocumentTypeID);
// create "BACK" button (to go back to choose document type id)
$sToRender .= getBackButton($iFolderID);
// create "CANCEL" button (to go back to browsing)
$sToRender .= getCancelButton($iFolderID);
// create "SUBMIT" button (to actually do the upload)
$sToRender .= "<input type=\"image\" src=\"" . KTHtml::getSubmitButton() . "\" border=\"0\"/>";
// display subfolders, if any
$sToRender .= getSubfolderBrowser($iFolderID, $iDocumentTypeID);
return $sToRender;
}
function getStatusPage ($iFolderID, $aFileStatus) {
global $default;
$sToRender = sprintf(_("Bulk Upload completed for %s documents. <br/>"), count($aFileStatus));
if ($aFileStatus) {
$sToRender .= "<table>\n";
$sToRender .= "<tr>\n";
$sToRender .= "<th> " . _("Document") . " </th>\n";
$sToRender .= "<th> </th>\n";
$sToRender .= "<th> " . _("Status") . " </th>\n";
$sToRender .= "</tr>\n";
foreach ($aFileStatus as $sDocumentName => $sUploadStatus) {
$sToRender .= "<tr>\n";
$sToRender .= "<td> $sDocumentName </td>\n";
$sToRender .= "<td> : </td>\n";
$sToRender .= "<td> $sUploadStatus </td>\n";
$sToRender .= "</tr>\n";
}
$sToRender .= "</table>\n";
}
// create "DONE" button (to go back to browsing)
$sToRender .= getDoneButton($iFolderID);
return $sToRender;
}
function getInvalidBulkUploadErrorMsg() {
return _("You did not select a valid document to upload") . ". <br />\n" .
_("Bulk upload currently only supports .ZIP files without subdirectories") . ".<br />\n";
}
// image link ... BACK (try bulk upload again)
function getRetryUploadButton($iFolderID, $iDocumentTypeID) {
global $default;
$sQueryString = "fFolderID=$iFolderID"."&"."fDocumentTypeID=$iDocumentTypeID";
return generateControllerLink("bulkUpload", $sQueryString, "<img src=\"" . KTHtml::getBackButton() . "\" border=\"0\"/>");
}
// image link ... BACK (choose document type id again)
function getBackButton($iFolderID) {
global $default;
return generateControllerLink("bulkUpload", "fFolderID=$iFolderID", "<img src=\"" . KTHtml::getBackButton() . "\" border=\"0\"/>");
}
// image link ... DONE, return to browsing
function getDoneButton($iFolderID) {
global $default;
return generateControllerLink("browse", "fFolderID=$iFolderID", "<img src=\"" . KTHtml::getDoneButton() . "\" border=\"0\"/>");
}
// image link ... return to browsing
function getCancelButton($iFolderID) {
global $default;
return generateControllerLink("browse", "fFolderID=$iFolderID", "<img src=\"" . KTHtml::getCancelButton() . "\" border=\"0\"/>");
}
?>