diff --git a/presentation/lookAndFeel/knowledgeTree/foldermanagement/viewDependantDocumentsBL.php b/presentation/lookAndFeel/knowledgeTree/foldermanagement/viewDependantDocumentsBL.php
index e42d2c7..2c124a2 100644
--- a/presentation/lookAndFeel/knowledgeTree/foldermanagement/viewDependantDocumentsBL.php
+++ b/presentation/lookAndFeel/knowledgeTree/foldermanagement/viewDependantDocumentsBL.php
@@ -14,13 +14,13 @@
require_once("../../../../config/dmsDefaults.php");
-if (checkSession()) {
- echo $fTemplateDocument;
- echo $fDocumentID;
+if (checkSession()) {
if (isset($fFolderID) && isset($fFolderCollaborationID)) {
require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc");
require_once("$default->fileSystemRoot/lib/foldermanagement/FolderCollaboration.inc");
require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc");
+ require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc");
+ require_once("$default->fileSystemRoot/lib/users/User.inc");
require_once("$default->fileSystemRoot/lib/documentmanagement/DependantDocumentTemplate.inc");
require_once("$default->fileSystemRoot/presentation/Html.inc");
require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc");
@@ -31,7 +31,7 @@ if (checkSession()) {
//folder and collaboration are selected
if (isset($fForStore)) {
$oDependantDocumentTemplate;
- if ($fTemplateDocumentID == "-1") {
+ if ($fTemplateDocumentID == "-1") {
$oDependantDocumentTemplate = & new DependantDocumentTemplate($fDocumentTitle, $fUserID, $fFolderCollaborationID);
} else {
$oDependantDocumentTemplate = & new DependantDocumentTemplate($fDocumentTitle, $fUserID, $fFolderCollaborationID, $fTemplateDocumentID);
@@ -74,25 +74,40 @@ if (checkSession()) {
} else if (isset($fForEdit)) {
$oFolderCollaboration = FolderCollaboration::get($fFolderCollaborationID);
if ($oFolderCollaboration->hasDocumentInProcess()) {
+ //can't edit if there is a document currently undergoing collaboration
include_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
$oPatternCustom = & new PatternCustom();
$oPatternCustom->setHtml(getViewPage($fFolderCollaborationID, $fFolderID));
$main->setCentralPayload($oPatternCustom);
- $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID&fForAdd=1");
+ $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID&fForUpdate=1");
$main->setErrorMessage("You cannot add a new depedant document as there is currently a document in this folder undergoing collaboration");
$main->render();
} else {
- include_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
+ include_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
- /*$oPatternCustom = & new PatternCustom();
- $oPatternCustom->setHtml(getAddPage($fFolderCollaborationID, $fFolderID, (isset($fUnitID) ? $fUnitID : -1), (isset($fDocumentTitle) ? $fDocumentTitle : ""), (isset($fTemplateDocument) ? $fTemplateDocument : ""), (isset($fDocumentID) ? $fDocumentID : "") ));
+ $oDependantDocumentTemplate = DependantDocumentTemplate::get($fDependantDocumentTemplateID);
+ if ($oDependantDocumentTemplate->getTemplateDocumentID() >= 1) {
+ $oDocument = Document::get($oDependantDocumentTemplate->getTemplateDocumentID());
+ }
+
+ $oPatternCustom = & new PatternCustom();
+ $oPatternCustom->setHtml(getEditPage($fFolderID, $fDependantDocumentTemplateID, $fFolderCollaborationID, $oDependantDocumentTemplate->getDocumentTitle(), (isset($oDocument) ? $oDocument->getName() : ""), (isset($oDocument) ? $oDependantDocumentTemplate->getTemplateDocumentID() : null), $oDependantDocumentTemplate->getDefaultUserID()));
$main->setCentralPayload($oPatternCustom);
- $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID&fForStore=1");
+ $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID&fDependantDocumentTemplateID=$fDependantDocumentTemplateID&fForUpdate=1");
$main->setHasRequiredFields(true);
- $main->render();*/
- }
+ $main->render();
+ }
+ } else if (isset($fForUpdate)) {
+ $oDependantDocumentTemplate = DependantDocumentTemplate::get($fDependantDocumentTemplateID);
+ $oDependantDocumentTemplate->setDefaultUserID($fUserID);
+ $oDependantDocumentTemplate->setDocumentTitle($fDocumentTitle);
+ $oDependantDocumentTemplate->setTemplateDocumentID((isset($fTemplateDocumentID) ? $fTemplateDocumentID : null));
+ $oDependantDocumentTemplate->update();
+
+ redirect("$default->rootUrl/control.php?action=viewDependantDocument&fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID");
+
} else {
include_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
@@ -101,7 +116,7 @@ if (checkSession()) {
$main->setCentralPayload($oPatternCustom);
$main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID&fForAdd=1");
$main->render();
- }
+ }
}
diff --git a/presentation/lookAndFeel/knowledgeTree/foldermanagement/viewDependantDocumentsUI.inc b/presentation/lookAndFeel/knowledgeTree/foldermanagement/viewDependantDocumentsUI.inc
index 0e459b6..a69c95e 100644
--- a/presentation/lookAndFeel/knowledgeTree/foldermanagement/viewDependantDocumentsUI.inc
+++ b/presentation/lookAndFeel/knowledgeTree/foldermanagement/viewDependantDocumentsUI.inc
@@ -23,7 +23,7 @@ function getFolderPath($iFolderID) {
function getDocumentLinkFolderCollaborationData($iFolderCollaborationID) {
global $default;
- $sQuery = "SELECT DDT.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 " .
+ $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 " .
"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 " .
@@ -33,8 +33,10 @@ function getDocumentLinkFolderCollaborationData($iFolderCollaborationID) {
$aColumns = array("document_title", "username", "template_document_name","edit");
$aColumnHeaders = array("Document title", "Default creator", "Template document", "Edit");
$aColumnTypes = array(1,1,3,3);
- $aDBColumnArray = array("id","group_folder_approval_link_id","template_document_id");
- $aQueryStringVariableNames = array("fDependantDocumentTemplateID", "fFolderCollaborationID", "fDocumentID");
+ //$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", "fDocumentID");
+ $aQueryStringVariableNames = array("fDependantDocumentTemplateID","fFolderCollaborationID","fFolderID");
$aLinkURLs = array(2=>"$default->rootUrl/control.php?action=viewDocument", 3=>"$default->rootUrl/control.php?action=viewDependantDocument&fForEdit=1");
$oPatternTableSqlQuery = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnHeaders, "90%", $aLinkURLs, $aDBColumnArray,$aQueryStringVariableNames);
@@ -63,10 +65,46 @@ function getViewPage($iFolderCollaborationID, $iFolderID) {
return $sToRender;
}
-function getEditPage() {
+function getEditPage($iFolderID, $iDependantDocumentID, $iFolderCollaborationID, $sDocumentTitle, $sTemplateDocumentName, $iDocumentID, $iUserID) {
+ global $default;
+ $iDefaultUserUnitID = User::getUnitID($iUserID);
+
+ $sToRender = renderHeading("Dependant documents");
+ $sToRender .= getFolderPath($iFolderID);
+ $sToRender .= "
\n";
+ $sToRender .= " \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");
@@ -96,7 +134,7 @@ function getAddPage($iFolderCollaborationID, $iFolderID, $iUnitID, $sDocumentTit
}
$sToRender .= "\n";
$sToRender .= "\n";
- $sToRender .= "\n";
+ $sToRender .= " \n";
$sToRender .= " \n";
$sToRender .= "\n";
$sToRender .= " \n";
@@ -104,23 +142,28 @@ function getAddPage($iFolderCollaborationID, $iFolderID, $iUnitID, $sDocumentTit
return $sToRender . "\n\n" . getValidationJavaScript() . "\n\n" . getBrowseJavaScript() . ($bAddNetscapeScript ? getNetscapeDisableScript() : "");
}
-function getUserDropDown($iUnitID) {
+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) {
+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')");
- $oPatternListBox->setSelectedValue($iUnitID);
+ if (isset($iUnitID)) {
+ $oPatternListBox->setSelectedValue($iUnitID);
+ }
return $oPatternListBox->render();
}