Commit f92d28af77e473cb7e0d4846e120d8a44c65e9ee

Authored by rob
1 parent 7eff7015

added functionality to edit existing dependant document


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1874 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/foldermanagement/viewDependantDocumentsBL.php
... ... @@ -14,13 +14,13 @@
14 14  
15 15 require_once("../../../../config/dmsDefaults.php");
16 16  
17   -if (checkSession()) {
18   - echo $fTemplateDocument;
19   - echo $fDocumentID;
  17 +if (checkSession()) {
20 18 if (isset($fFolderID) && isset($fFolderCollaborationID)) {
21 19 require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc");
22 20 require_once("$default->fileSystemRoot/lib/foldermanagement/FolderCollaboration.inc");
23 21 require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc");
  22 + require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc");
  23 + require_once("$default->fileSystemRoot/lib/users/User.inc");
24 24 require_once("$default->fileSystemRoot/lib/documentmanagement/DependantDocumentTemplate.inc");
25 25 require_once("$default->fileSystemRoot/presentation/Html.inc");
26 26 require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc");
... ... @@ -31,7 +31,7 @@ if (checkSession()) {
31 31 //folder and collaboration are selected
32 32 if (isset($fForStore)) {
33 33 $oDependantDocumentTemplate;
34   - if ($fTemplateDocumentID == "-1") {
  34 + if ($fTemplateDocumentID == "-1") {
35 35 $oDependantDocumentTemplate = & new DependantDocumentTemplate($fDocumentTitle, $fUserID, $fFolderCollaborationID);
36 36 } else {
37 37 $oDependantDocumentTemplate = & new DependantDocumentTemplate($fDocumentTitle, $fUserID, $fFolderCollaborationID, $fTemplateDocumentID);
... ... @@ -74,25 +74,40 @@ if (checkSession()) {
74 74 } else if (isset($fForEdit)) {
75 75 $oFolderCollaboration = FolderCollaboration::get($fFolderCollaborationID);
76 76 if ($oFolderCollaboration->hasDocumentInProcess()) {
  77 + //can't edit if there is a document currently undergoing collaboration
77 78 include_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
78 79  
79 80 $oPatternCustom = & new PatternCustom();
80 81 $oPatternCustom->setHtml(getViewPage($fFolderCollaborationID, $fFolderID));
81 82 $main->setCentralPayload($oPatternCustom);
82   - $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID&fForAdd=1");
  83 + $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID&fForUpdate=1");
83 84 $main->setErrorMessage("You cannot add a new depedant document as there is currently a document in this folder undergoing collaboration");
84 85 $main->render();
85 86  
86 87 } else {
87   - include_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
  88 + include_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
88 89  
89   - /*$oPatternCustom = & new PatternCustom();
90   - $oPatternCustom->setHtml(getAddPage($fFolderCollaborationID, $fFolderID, (isset($fUnitID) ? $fUnitID : -1), (isset($fDocumentTitle) ? $fDocumentTitle : ""), (isset($fTemplateDocument) ? $fTemplateDocument : ""), (isset($fDocumentID) ? $fDocumentID : "") ));
  90 + $oDependantDocumentTemplate = DependantDocumentTemplate::get($fDependantDocumentTemplateID);
  91 + if ($oDependantDocumentTemplate->getTemplateDocumentID() >= 1) {
  92 + $oDocument = Document::get($oDependantDocumentTemplate->getTemplateDocumentID());
  93 + }
  94 +
  95 + $oPatternCustom = & new PatternCustom();
  96 + $oPatternCustom->setHtml(getEditPage($fFolderID, $fDependantDocumentTemplateID, $fFolderCollaborationID, $oDependantDocumentTemplate->getDocumentTitle(), (isset($oDocument) ? $oDocument->getName() : ""), (isset($oDocument) ? $oDependantDocumentTemplate->getTemplateDocumentID() : null), $oDependantDocumentTemplate->getDefaultUserID()));
91 97 $main->setCentralPayload($oPatternCustom);
92   - $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID&fForStore=1");
  98 + $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID&fDependantDocumentTemplateID=$fDependantDocumentTemplateID&fForUpdate=1");
93 99 $main->setHasRequiredFields(true);
94   - $main->render();*/
95   - }
  100 + $main->render();
  101 + }
  102 + } else if (isset($fForUpdate)) {
  103 + $oDependantDocumentTemplate = DependantDocumentTemplate::get($fDependantDocumentTemplateID);
  104 + $oDependantDocumentTemplate->setDefaultUserID($fUserID);
  105 + $oDependantDocumentTemplate->setDocumentTitle($fDocumentTitle);
  106 + $oDependantDocumentTemplate->setTemplateDocumentID((isset($fTemplateDocumentID) ? $fTemplateDocumentID : null));
  107 + $oDependantDocumentTemplate->update();
  108 +
  109 + redirect("$default->rootUrl/control.php?action=viewDependantDocument&fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID");
  110 +
96 111 } else {
97 112 include_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
98 113  
... ... @@ -101,7 +116,7 @@ if (checkSession()) {
101 116 $main->setCentralPayload($oPatternCustom);
102 117 $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fFolderCollaborationID=$fFolderCollaborationID&fForAdd=1");
103 118 $main->render();
104   - }
  119 + }
105 120  
106 121 }
107 122  
... ...
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, D.id AS template_document_id, DDT.group_folder_approval_link_id, 'Edit' AS edit " .
  26 + $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 " .
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 " .
... ... @@ -33,8 +33,10 @@ function getDocumentLinkFolderCollaborationData($iFolderCollaborationID) {
33 33 $aColumns = array("document_title", "username", "template_document_name","edit");
34 34 $aColumnHeaders = array("Document title", "Default creator", "Template document", "Edit");
35 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");
  36 + //$aDBColumnArray = array("id","group_folder_approval_link_id","template_document_id");
  37 + $aDBColumnArray = array("id","group_folder_approval_link_id","folder_id");
  38 + //$aQueryStringVariableNames = array("fDependantDocumentTemplateID", "fFolderCollaborationID", "fDocumentID");
  39 + $aQueryStringVariableNames = array("fDependantDocumentTemplateID","fFolderCollaborationID","fFolderID");
38 40 $aLinkURLs = array(2=>"$default->rootUrl/control.php?action=viewDocument", 3=>"$default->rootUrl/control.php?action=viewDependantDocument&fForEdit=1");
39 41  
40 42 $oPatternTableSqlQuery = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnHeaders, "90%", $aLinkURLs, $aDBColumnArray,$aQueryStringVariableNames);
... ... @@ -63,10 +65,46 @@ function getViewPage($iFolderCollaborationID, $iFolderID) {
63 65 return $sToRender;
64 66 }
65 67  
66   -function getEditPage() {
  68 +function getEditPage($iFolderID, $iDependantDocumentID, $iFolderCollaborationID, $sDocumentTitle, $sTemplateDocumentName, $iDocumentID, $iUserID) {
  69 + global $default;
  70 + $iDefaultUserUnitID = User::getUnitID($iUserID);
  71 +
  72 + $sToRender = renderHeading("Dependant documents");
  73 + $sToRender .= getFolderPath($iFolderID);
  74 + $sToRender .= "<table border=\"0\" width=\"100%\">\n";
  75 + $sToRender .= "<tr>\n";
  76 + $sToRender .= "<td>Document title</td><td><input type=\"text\" name=\"fDocumentTitle\" value=\"$sDocumentTitle\" /></td>\n";
  77 + $sToRender .= "</tr>\n";
  78 + $sToRender .= "<tr>\n";
  79 + $sToRender .= "<td>User's Unit</td><td>" . getUnitDropDown($iFolderCollaborationID, $iFolderID, $iDefaultUserUnitID) . "</td>\n";
  80 + $sToRender .= "</tr>\n";
  81 + $sToRender .= "<tr>\n";
  82 + $sToRender .= "<td>User</td><td>" . getUserDropDown($iDefaultUserUnitID, $iUserID) . "</td>\n";
  83 + $sToRender .= "</tr>\n";
  84 + $sToRender .= "<tr>\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=\"$sTemplateDocumentName\" /><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\" value=\"$sTemplateDocumentName\" 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 + }
  97 + $sToRender .= "</tr>\n";
  98 + $sToRender .= "<tr>\n";
  99 + $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";
  100 + $sToRender .= "</tr>\n";
  101 + $sToRender .= "</table>\n";
  102 + $sToRender .= "<input type=\"hidden\" name=\"fTemplateDocumentID\" value=\"-1\" />\n";
67 103  
  104 + return $sToRender . "\n\n" . getValidationJavaScript() . "\n\n" . getBrowseJavaScript() . ($bAddNetscapeScript ? getNetscapeDisableScript() : "");
68 105 }
69 106  
  107 +
70 108 function getAddPage($iFolderCollaborationID, $iFolderID, $iUnitID, $sDocumentTitle, $sTemplateDocument, $iDocumentID) {
71 109 global $default;
72 110 $sToRender = renderHeading("Dependant documents");
... ... @@ -96,7 +134,7 @@ function getAddPage($iFolderCollaborationID, $iFolderID, $iUnitID, $sDocumentTit
96 134 }
97 135 $sToRender .= "</tr>\n";
98 136 $sToRender .= "<tr>\n";
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";
  137 + $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";
100 138 $sToRender .= "</tr>\n";
101 139 $sToRender .= "</table>\n";
102 140 $sToRender .= "<input type=\"hidden\" name=\"fTemplateDocumentID\" value=\"-1\" />\n";
... ... @@ -104,23 +142,28 @@ function getAddPage($iFolderCollaborationID, $iFolderID, $iUnitID, $sDocumentTit
104 142 return $sToRender . "\n\n" . getValidationJavaScript() . "\n\n" . getBrowseJavaScript() . ($bAddNetscapeScript ? getNetscapeDisableScript() : "");
105 143 }
106 144  
107   -function getUserDropDown($iUnitID) {
  145 +function getUserDropDown($iUnitID, $iUserID = null) {
108 146 global $default;
109 147 $oPatternListBox = & new PatternListBox($default->owl_users_table, "Name", "id", "fUserID", "GUL.unit_id = $iUnitID");
110 148 $sFromClause = "INNER join users_groups_link AS UGL ON UGL.user_id = ST.id " .
111 149 "INNER JOIN groups_units_link AS GUL ON GUL.group_id = UGL.group_id ";
112 150 $oPatternListBox->setFromClause($sFromClause);
  151 + if (isset($iUserID)) {
  152 + $oPatternListBox->setSelectedValue($iUserID);
  153 + }
113 154 return $oPatternListBox->render();
114 155  
115 156  
116 157 }
117 158  
118   -function getUnitDropDown($iFolderCollaborationID, $iFolderID, $iUnitID) {
  159 +function getUnitDropDown($iFolderCollaborationID, $iFolderID, $iUnitID = null) {
119 160 global $default;
120 161 $oPatternListBox = & new PatternListBox($default->owl_units_table, "Name", "id", "fUnitID");
121 162 $oPatternListBox->setPostBackOnChange(true);
122 163 $oPatternListBox->setOnChangeAction("setActionAndSubmit('" . $_SERVER["PHP_SELF"] . "?fFolderID=$iFolderID&fFolderCollaborationID=$iFolderCollaborationID&fForAdd=1')");
123   - $oPatternListBox->setSelectedValue($iUnitID);
  164 + if (isset($iUnitID)) {
  165 + $oPatternListBox->setSelectedValue($iUnitID);
  166 + }
124 167 return $oPatternListBox->render();
125 168 }
126 169  
... ...