Commit d8feac220d95fe24247cbe71f5f9aaef0556041f

Authored by rob
1 parent 841cbf69

Finished functionality for adding new dependant documents


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1864 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/foldermanagement/viewDependantDocumentsBL.php
... ... @@ -14,12 +14,14 @@
14 14  
15 15 require_once("../../../../config/dmsDefaults.php");
16 16  
17   -if (checkSession()) {
18   - if (isset($fFolderID) && isset($fFolderCollaborationID)) {
19   - echo $fUserID;
  17 +if (checkSession()) {
  18 + echo $fTemplateDocument;
  19 + echo $fDocumentID;
  20 + if (isset($fFolderID) && isset($fFolderCollaborationID)) {
20 21 require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc");
21 22 require_once("$default->fileSystemRoot/lib/foldermanagement/FolderCollaboration.inc");
22 23 require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc");
  24 + require_once("$default->fileSystemRoot/lib/documentmanagement/DependantDocumentTemplate.inc");
23 25 require_once("$default->fileSystemRoot/presentation/Html.inc");
24 26 require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc");
25 27 require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");
... ... @@ -27,20 +29,48 @@ if (checkSession()) {
27 29 require_once("viewDependantDocumentsUI.inc");
28 30  
29 31 //folder and collaboration are selected
30   - $oFolderCollaboration = FolderCollaboration::get($fFolderCollaborationID);
31   - if ($oFolderCollaboration->hasDocumentInProcess()) {
32   - //can't add document links if a document is currently undergoing the
33   - //collaboration process
  32 + if (isset($fForStore)) {
  33 + $oDependantDocumentTemplate;
  34 + if ($fTemplateDocumentID == "-1") {
  35 + $oDependantDocumentTemplate = & new DependantDocumentTemplate($fDocumentTitle, $fUserID, $fFolderCollaborationID);
  36 + } else {
  37 + $oDependantDocumentTemplate = & new DependantDocumentTemplate($fDocumentTitle, $fUserID, $fFolderCollaborationID, $fTemplateDocumentID);
  38 + }
  39 + if (!($oDependantDocumentTemplate->create())) {
  40 + include_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
34 41  
35   - } if (isset($fForAdd)) {
36   - //we are adding a new dependant document
37   - include_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
38   - $oPatternCustom = & new PatternCustom();
39   - $oPatternCustom->setHtml(getAddPage($fFolderCollaborationID, $fFolderID, (isset($fUnitID) ? $fUnitID : -1), (isset($fDocumentTitle) ? $fDocumentTitle : "")));
40   - $main->setCentralPayload($oPatternCustom);
41   - $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID&fForStore=1");
42   - $main->setHasRequiredFields(true);
43   - $main->render();
  42 + $oPatternCustom = & new PatternCustom();
  43 + $oPatternCustom->setHtml(getViewPage($fFolderCollaborationID, $fFolderID));
  44 + $main->setCentralPayload($oPatternCustom);
  45 + $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID&fForAdd=1");
  46 + $main->setErrorMessage("An error occured attempting to store the depedant document");
  47 + $main->render();
  48 + } else {
  49 + redirect("$default->rootUrl/control.php?action=viewDependantDocument&fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID");
  50 + }
  51 + } else if (isset($fForAdd)) {
  52 + //we are adding a new dependant document
  53 + $oFolderCollaboration = FolderCollaboration::get($fFolderCollaborationID);
  54 + if ($oFolderCollaboration->hasDocumentInProcess()) {
  55 + include_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
  56 +
  57 + $oPatternCustom = & new PatternCustom();
  58 + $oPatternCustom->setHtml(getViewPage($fFolderCollaborationID, $fFolderID));
  59 + $main->setCentralPayload($oPatternCustom);
  60 + $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID&fForAdd=1");
  61 + $main->setErrorMessage("You cannot add a new depedant document as there is currently a document in this folder undergoing collaboration");
  62 + $main->render();
  63 +
  64 + } else {
  65 + include_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
  66 +
  67 + $oPatternCustom = & new PatternCustom();
  68 + $oPatternCustom->setHtml(getAddPage($fFolderCollaborationID, $fFolderID, (isset($fUnitID) ? $fUnitID : -1), (isset($fDocumentTitle) ? $fDocumentTitle : ""), (isset($fTemplateDocument) ? $fTemplateDocument : ""), (isset($fDocumentID) ? $fDocumentID : "") ));
  69 + $main->setCentralPayload($oPatternCustom);
  70 + $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID&fForStore=1");
  71 + $main->setHasRequiredFields(true);
  72 + $main->render();
  73 + }
44 74 } else {
45 75 include_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
46 76  
... ...
presentation/lookAndFeel/knowledgeTree/foldermanagement/viewDependantDocumentsUI.inc
... ... @@ -23,7 +23,7 @@ function getFolderPath($iFolderID) {
23 23  
24 24 function getDocumentLinkFolderCollaborationData($iFolderCollaborationID) {
25 25 global $default;
26   - $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 " .
  26 + $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 " .
27 27 "FROM dependant_document_template AS DDT INNER JOIN groups_folders_approval_link AS GFAL ON DDT.group_folder_approval_link_id = GFAL.id " .
28 28 "INNER JOIN users AS U ON U.id = DDT.default_user_id " .
29 29 "LEFT OUTER JOIN documents AS D ON D.id = DDT.template_document_id " .
... ... @@ -32,13 +32,13 @@ function getDocumentLinkFolderCollaborationData($iFolderCollaborationID) {
32 32 //echo $sQuery;
33 33 $aColumns = array("document_title", "username", "template_document_name","edit");
34 34 $aColumnHeaders = array("Document title", "Default creator", "Template document", "Edit");
35   - $aColumnTypes = array(1,1,1,3);
36   - $aDBColumnArray = array("id","group_folder_approval_link_id");
37   - $aQueryStringVariableNames = array("fDependantDocumentTemplateID","fFolderCollaborationID");
38   - $aLinkURLs = array(3=>"$default->rootUrl/control.php?action=linkDocFolderCollaboration");
  35 + $aColumnTypes = array(1,1,3,3);
  36 + $aDBColumnArray = array("id","group_folder_approval_link_id", "template_document_id");
  37 + $aQueryStringVariableNames = array("fDependantDocumentTemplateID","fFolderCollaborationID","fDocumentID");
  38 + $aLinkURLs = array(2=>"$default->rootUrl/control.php?action=viewDocument", 3=>"$default->rootUrl/control.php?action=linkDocFolderCollaboration");
39 39  
40 40 $oPatternTableSqlQuery = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnHeaders, "90%", $aLinkURLs, $aDBColumnArray,$aQueryStringVariableNames);
41   - $oPatternTableSqlQuery->setTableHeading("Linked Documents");
  41 + $oPatternTableSqlQuery->setTableHeading("Dependant Documents");
42 42 $oPatternTableSqlQuery->setDisplayColumnHeadings(true);
43 43 $oPatternTableSqlQuery->setEmptyTableMessage("No dependant documents");
44 44  
... ... @@ -67,7 +67,7 @@ function getEditPage() {
67 67  
68 68 }
69 69  
70   -function getAddPage($iFolderCollaborationID, $iFolderID, $iUnitID, $sDocumentTitle) {
  70 +function getAddPage($iFolderCollaborationID, $iFolderID, $iUnitID, $sDocumentTitle, $sTemplateDocument, $iDocumentID) {
71 71 global $default;
72 72 $sToRender = renderHeading("Dependant documents");
73 73 $sToRender .= getFolderPath($iFolderID);
... ... @@ -82,15 +82,26 @@ function getAddPage($iFolderCollaborationID, $iFolderID, $iUnitID, $sDocumentTit
82 82 $sToRender .= "<td>User</td><td>" . getUserDropDown($iUnitID) . "</td>\n";
83 83 $sToRender .= "</tr>\n";
84 84 $sToRender .= "<tr>\n";
85   - $sToRender .= "<td>Template document</td><td><input type=\"text\" DISABLED name=\"fTemplateDocument\" /><input type=\"button\" value=\"Browse\" onClick=\"newWindow('http://ktdev/control.php?action=templateBrowse','window2')\"></td>\n";
  85 +
  86 + //had a slight problem with netscape 4.7x - it doesn't support disabled. So I had to use
  87 + //javascript to set the onFocus attribute to blur
  88 + $bAddNetscapeScript = false;
  89 + if (! (($default->phpSniff->property("browser") == "moz") && ($default->phpSniff->property("version") <= "4.79")) ) {
  90 + //for any other browser but netscape 4.7 do this
  91 + $sToRender .= "<td>Template document</td><td><input type=\"text\" DISABLED name=\"fTemplateDocument\" value=\"$sTemplateDocument\" /><input type=\"button\" value=\"Browse\" onClick=\"newWindow('http://ktdev/control.php?action=templateBrowse','window2')\"></td>\n";
  92 + }else {
  93 + //for netscape 4.7 do this
  94 + $sToRender .= "<td>Template document</td><td><input type=\"text\" name=\"fTemplateDocument\" onblur=\"disable(document.MainForm.fTemplateDocument);\" /><input type=\"button\" value=\"Browse\" onClick=\"disable(document.MainForm.fTemplateDocument);newWindow('http://ktdev/control.php?action=templateBrowse','window2')\"></td>\n";
  95 + $bAddNetscapeScript = true;
  96 + }
86 97 $sToRender .= "</tr>\n";
87 98 $sToRender .= "<tr>\n";
88 99 $sToRender .= "<td><table><tr><td><input type=\"image\" src=\"$default->graphicsUrl/widgets/done.gif\" border=\"0\"/></td><td><a href=\"" . $default->rootUrl . "\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"/></a></td></tr></table>\n";
89 100 $sToRender .= "</tr>\n";
90 101 $sToRender .= "</table>\n";
91   - $sToRender .= "<input type=\"hidden\" name=\"fTemplateDocumentID\" value=\"\" />\n";
  102 + $sToRender .= "<input type=\"hidden\" name=\"fTemplateDocumentID\" value=\"-1\" />\n";
92 103  
93   - return $sToRender . "\n\n" . getValidationJavaScript() . "\n\n" . getBrowseJavaScript();
  104 + return $sToRender . "\n\n" . getValidationJavaScript() . "\n\n" . getBrowseJavaScript() . ($bAddNetscapeScript ? getNetscapeDisableScript() : "");
94 105 }
95 106  
96 107 function getUserDropDown($iUnitID) {
... ... @@ -133,6 +144,16 @@ function getBrowseJavaScript() {
133 144 return $sToRender;
134 145 }
135 146  
  147 +function getNetscapeDisableScript() {
  148 + $sToRender = "<script language=\"JavaScript\"><!--\n ";
  149 + $sToRender .= "function disable(elem) {\n";
  150 + $sToRender .= "\telem.onfocus=elem.blur;\n";
  151 + $sToRender .= "}\n";
  152 + $sToRender .= "//--></script>\n\n";
  153 + return $sToRender;
  154 +
  155 +}
  156 +
136 157  
137 158  
138 159  
... ...