diff --git a/presentation/lookAndFeel/knowledgeTree/foldermanagement/viewDependantDocumentsBL.php b/presentation/lookAndFeel/knowledgeTree/foldermanagement/viewDependantDocumentsBL.php index f0e3947..ea5c3eb 100644 --- a/presentation/lookAndFeel/knowledgeTree/foldermanagement/viewDependantDocumentsBL.php +++ b/presentation/lookAndFeel/knowledgeTree/foldermanagement/viewDependantDocumentsBL.php @@ -14,12 +14,14 @@ require_once("../../../../config/dmsDefaults.php"); -if (checkSession()) { - if (isset($fFolderID) && isset($fFolderCollaborationID)) { - echo $fUserID; +if (checkSession()) { + echo $fTemplateDocument; + echo $fDocumentID; + 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/DependantDocumentTemplate.inc"); require_once("$default->fileSystemRoot/presentation/Html.inc"); require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc"); require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); @@ -27,20 +29,48 @@ if (checkSession()) { require_once("viewDependantDocumentsUI.inc"); //folder and collaboration are selected - $oFolderCollaboration = FolderCollaboration::get($fFolderCollaborationID); - if ($oFolderCollaboration->hasDocumentInProcess()) { - //can't add document links if a document is currently undergoing the - //collaboration process + if (isset($fForStore)) { + $oDependantDocumentTemplate; + if ($fTemplateDocumentID == "-1") { + $oDependantDocumentTemplate = & new DependantDocumentTemplate($fDocumentTitle, $fUserID, $fFolderCollaborationID); + } else { + $oDependantDocumentTemplate = & new DependantDocumentTemplate($fDocumentTitle, $fUserID, $fFolderCollaborationID, $fTemplateDocumentID); + } + if (!($oDependantDocumentTemplate->create())) { + include_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); - } if (isset($fForAdd)) { - //we are adding a new dependant document - include_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); - $oPatternCustom = & new PatternCustom(); - $oPatternCustom->setHtml(getAddPage($fFolderCollaborationID, $fFolderID, (isset($fUnitID) ? $fUnitID : -1), (isset($fDocumentTitle) ? $fDocumentTitle : ""))); - $main->setCentralPayload($oPatternCustom); - $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID&fForStore=1"); - $main->setHasRequiredFields(true); - $main->render(); + $oPatternCustom = & new PatternCustom(); + $oPatternCustom->setHtml(getViewPage($fFolderCollaborationID, $fFolderID)); + $main->setCentralPayload($oPatternCustom); + $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID&fForAdd=1"); + $main->setErrorMessage("An error occured attempting to store the depedant document"); + $main->render(); + } else { + redirect("$default->rootUrl/control.php?action=viewDependantDocument&fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID"); + } + } else if (isset($fForAdd)) { + //we are adding a new dependant document + $oFolderCollaboration = FolderCollaboration::get($fFolderCollaborationID); + if ($oFolderCollaboration->hasDocumentInProcess()) { + 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->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"); + + $oPatternCustom = & new PatternCustom(); + $oPatternCustom->setHtml(getAddPage($fFolderCollaborationID, $fFolderID, (isset($fUnitID) ? $fUnitID : -1), (isset($fDocumentTitle) ? $fDocumentTitle : ""), (isset($fTemplateDocument) ? $fTemplateDocument : ""), (isset($fDocumentID) ? $fDocumentID : "") )); + $main->setCentralPayload($oPatternCustom); + $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID&fForStore=1"); + $main->setHasRequiredFields(true); + $main->render(); + } } else { include_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); diff --git a/presentation/lookAndFeel/knowledgeTree/foldermanagement/viewDependantDocumentsUI.inc b/presentation/lookAndFeel/knowledgeTree/foldermanagement/viewDependantDocumentsUI.inc index 6103ed9..52ca016 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, DDT.group_folder_approval_link_id, 'Edit' AS edit " . + $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 " . "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 " . @@ -32,13 +32,13 @@ function getDocumentLinkFolderCollaborationData($iFolderCollaborationID) { //echo $sQuery; $aColumns = array("document_title", "username", "template_document_name","edit"); $aColumnHeaders = array("Document title", "Default creator", "Template document", "Edit"); - $aColumnTypes = array(1,1,1,3); - $aDBColumnArray = array("id","group_folder_approval_link_id"); - $aQueryStringVariableNames = array("fDependantDocumentTemplateID","fFolderCollaborationID"); - $aLinkURLs = array(3=>"$default->rootUrl/control.php?action=linkDocFolderCollaboration"); + $aColumnTypes = array(1,1,3,3); + $aDBColumnArray = array("id","group_folder_approval_link_id", "template_document_id"); + $aQueryStringVariableNames = array("fDependantDocumentTemplateID","fFolderCollaborationID","fDocumentID"); + $aLinkURLs = array(2=>"$default->rootUrl/control.php?action=viewDocument", 3=>"$default->rootUrl/control.php?action=linkDocFolderCollaboration"); $oPatternTableSqlQuery = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnHeaders, "90%", $aLinkURLs, $aDBColumnArray,$aQueryStringVariableNames); - $oPatternTableSqlQuery->setTableHeading("Linked Documents"); + $oPatternTableSqlQuery->setTableHeading("Dependant Documents"); $oPatternTableSqlQuery->setDisplayColumnHeadings(true); $oPatternTableSqlQuery->setEmptyTableMessage("No dependant documents"); @@ -67,7 +67,7 @@ function getEditPage() { } -function getAddPage($iFolderCollaborationID, $iFolderID, $iUnitID, $sDocumentTitle) { +function getAddPage($iFolderCollaborationID, $iFolderID, $iUnitID, $sDocumentTitle, $sTemplateDocument, $iDocumentID) { global $default; $sToRender = renderHeading("Dependant documents"); $sToRender .= getFolderPath($iFolderID); @@ -82,15 +82,26 @@ function getAddPage($iFolderCollaborationID, $iFolderID, $iUnitID, $sDocumentTit $sToRender .= "
| graphicsUrl/widgets/done.gif\" border=\"0\"/> | rootUrl . "\"> |