Commit 02619b235ed5c0ad6691b14d9fb0d3832d14b659
1 parent
cafd58d5
completed archive settings pages
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1918 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
3 changed files
with
170 additions
and
161 deletions
presentation/lookAndFeel/knowledgeTree/documentmanagement/archiving/addArchiveSettingsBL.php
| ... | ... | @@ -3,10 +3,7 @@ |
| 3 | 3 | require_once("../../../../../config/dmsDefaults.php"); |
| 4 | 4 | require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); |
| 5 | 5 | |
| 6 | -require_once("$default->fileSystemRoot/lib/archiving/DocumentArchiving.inc"); | |
| 7 | -require_once("$default->fileSystemRoot/lib/archiving/ArchivingUtilisationSettings.inc"); | |
| 8 | -require_once("$default->fileSystemRoot/lib/archiving/ArchivingDateSettings.inc"); | |
| 9 | -require_once("$default->fileSystemRoot/lib/archiving/TimePeriod.inc"); | |
| 6 | +require_once("$default->fileSystemRoot/lib/archiving/DocumentArchiveSettingsFactory.inc"); | |
| 10 | 7 | |
| 11 | 8 | require_once("$default->fileSystemRoot/lib/visualpatterns/PatternMainPage.inc"); |
| 12 | 9 | require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); |
| ... | ... | @@ -27,70 +24,16 @@ require_once("$default->uiDirectory/documentmanagement/archiving/archiveSettings |
| 27 | 24 | * @package presentation.lookAndFeel.knowledgeTree.documentmanagement |
| 28 | 25 | */ |
| 29 | 26 | |
| 30 | -class DocumentArchiveSettingsFactory { | |
| 31 | - function create($iDocumentID, $iArchivingTypeID, $dExpirationDate, $iDocumentTransactionID, $iTimeUnitID, $iUnits) { | |
| 32 | - global $default; | |
| 33 | - $sArchivingType = lookupName($default->owl_archiving_type_lookup_table, $iArchivingTypeID); | |
| 34 | - | |
| 35 | - // search for an existing time period id | |
| 36 | - $aTimePeriod = TimePeriod::getList("time_unit_id=$iTimeUnitID AND units=$iUnits"); | |
| 37 | - if (count($aTimePeriod) > 0) { | |
| 38 | - $iTimePeriodID = $aTimePeriod[0]->getID(); | |
| 39 | - } else { | |
| 40 | - // create it | |
| 41 | - $oTimePeriod = new TimePeriod($iTimeUnitID, $iUnits); | |
| 42 | - if ($oTimePeriod->create()) { | |
| 43 | - $iTimePeriodID = $oTimePeriod->getID(); | |
| 44 | - } else { | |
| 45 | - $default->log->error("couldn't create time period- " . arrayToString($oTimePeriod)); | |
| 46 | - return false; | |
| 47 | - } | |
| 48 | - } | |
| 49 | - | |
| 50 | - // construction strings | |
| 51 | - switch ($sArchivingType) { | |
| 52 | - case "Date" : $sSearchConstruction = "\$aArchiveSettings = ArchivingDateSettings::getList(\"expiration_date='$dExpirationDate' AND time_period_id=$iTimePeriodID\");"; | |
| 53 | - $sConstruction = "\$oArchiveSettings = new ArchivingDateSettings($dExpirationDate, $iTimePeriodID);"; | |
| 54 | - break; | |
| 55 | - case "Utilisation" : $sSearchConstruction = "\$aArchiveSettings = ArchivingUtilisationSettings::getList(\"document_transaction_id=$iDocumentTransactionID AND time_period_id=$iTimePeriodID\");"; | |
| 56 | - $sConstruction = "\$oArchiveSettings = new ArchivingUtilisationSettings($iDocumentTransactionID, $iTimePeriodID);"; | |
| 57 | - break; | |
| 58 | - } | |
| 59 | - | |
| 60 | - // search for the settings first | |
| 61 | - eval($sSearchConstruction); | |
| 62 | - if (count($aArchiveSettings) > 0) { | |
| 63 | - $iArchiveSettingsID = $aArchiveSettings[0]->getID(); | |
| 64 | - } else { | |
| 65 | - // create them | |
| 66 | - eval($sConstruction); | |
| 67 | - if ($oArchiveSettings->create()) { | |
| 68 | - $iArchiveSettingsID = $oArchiveSettings->getID(); | |
| 69 | - } else { | |
| 70 | - $default->log->error("couldn't create archive settings- " . arrayToString($oArchiveSettings)); | |
| 71 | - return false; | |
| 72 | - } | |
| 73 | - | |
| 74 | - // now link to the documents | |
| 75 | - $oDocumentArchiving = new DocumentArchiving($iDocumentID, $iArchivingTypeID, $iArchiveSettingsID); | |
| 76 | - if ($oDocumentArchiving->create()) { | |
| 77 | - return true; | |
| 78 | - } else { | |
| 79 | - $default->log->error("couldn't create document archiving - " . arrayToString($oDocumentArchiving)); | |
| 80 | - return false; | |
| 81 | - } | |
| 82 | - } | |
| 83 | - } | |
| 84 | -} | |
| 85 | - | |
| 86 | 27 | if (checkSession()) { |
| 87 | 28 | global $default; |
| 88 | 29 | |
| 89 | 30 | // instantiate my content pattern |
| 90 | 31 | $oContent = new PatternCustom(); |
| 91 | - $default->log->info(arrayToString($_REQUEST)); | |
| 32 | + | |
| 92 | 33 | if ($fStore) { |
| 93 | - if (DocumentArchiveSettingsFactory::create($fDocumentID, $fArchivingTypeID, $fExpirationDate, $fDocumentTransactionID, $fTimeUnitID, $fUnits)) { | |
| 34 | + $oDASFactory = new DocumentArchiveSettingsFactory($fArchivingTypeID); | |
| 35 | + | |
| 36 | + if ($oDASFactory->create($fDocumentID, $fExpirationDate, $fDocumentTransactionID, $fTimeUnitID, $fUnits)) { | |
| 94 | 37 | // created, redirect to view page |
| 95 | 38 | redirect("$default->rootUrl/control.php?action=viewDocument&fDocumentID=$fDocumentID"); |
| 96 | 39 | } else { |
| ... | ... | @@ -102,10 +45,9 @@ if (checkSession()) { |
| 102 | 45 | |
| 103 | 46 | } elseif (isset($fArchivingTypeID)) { |
| 104 | 47 | // the archiving type has been chosen, so display the correct form |
| 105 | - // display the edit/add page | |
| 106 | 48 | $oContent->setHtml(renderAddArchiveSettingsPage($fArchivingTypeID)); |
| 107 | 49 | } else { |
| 108 | - // display the choose archiving type page | |
| 50 | + // display the select archiving type page | |
| 109 | 51 | $oContent->setHtml(renderAddArchiveSettingsPage(null)); |
| 110 | 52 | } |
| 111 | 53 | ... | ... |
presentation/lookAndFeel/knowledgeTree/documentmanagement/archiving/archiveSettingsUI.inc
| ... | ... | @@ -40,10 +40,12 @@ function renderErrorMessage($sErrorMessage) { |
| 40 | 40 | return $sToRender; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - | |
| 44 | -function renderDocumentTransactionListBox() { | |
| 43 | +function renderDocumentTransactionListBox($iDocumentTransactionID) { | |
| 45 | 44 | global $default; |
| 46 | 45 | $oPatternListBox = & new PatternListBox($default->owl_transaction_types_table, "name", "id", "fDocumentTransactionID"); |
| 46 | + if (isset($iDocumentTransactionID)) { | |
| 47 | + $oPatternListBox->setSelectedValue($iDocumentTransactionID); | |
| 48 | + } | |
| 47 | 49 | return $oPatternListBox->render(); |
| 48 | 50 | } |
| 49 | 51 | |
| ... | ... | @@ -55,9 +57,12 @@ function renderArchivingTypeListBox() { |
| 55 | 57 | return $oPatternListBox->render(); |
| 56 | 58 | } |
| 57 | 59 | |
| 58 | -function renderTimeUnitsListBox($sVariableName) { | |
| 60 | +function renderTimeUnitsListBox($iTimeUnitID) { | |
| 59 | 61 | global $default; |
| 60 | - $oPatternListBox = & new PatternListBox($default->owl_time_unit_lookup_table, "name", "id", $sVariableName); | |
| 62 | + $oPatternListBox = & new PatternListBox($default->owl_time_unit_lookup_table, "name", "id", "fTimeUnitID"); | |
| 63 | + if (isset($iTimeUnitID)) { | |
| 64 | + $oPatternListBox->setSelectedValue($iTimeUnitID); | |
| 65 | + } | |
| 61 | 66 | return $oPatternListBox->render(); |
| 62 | 67 | } |
| 63 | 68 | |
| ... | ... | @@ -74,99 +79,155 @@ function renderChooseArchivingTypeForm() { |
| 74 | 79 | return $sToRender; |
| 75 | 80 | } |
| 76 | 81 | |
| 82 | +function getDateArchivingJavascript() { | |
| 83 | + $sToRender .= "\n\n<script language=\"javascript\">\n<!--\n"; | |
| 84 | + $sToRender .= "function validateForm(theForm) {\n"; | |
| 85 | + $sToRender .= "\tif (isBlank(theForm.fExpirationDate) && isBlank(theForm.fUnits) && isBlank(theForm.fTimeUnitID)) {\n"; | |
| 86 | + $sToRender .= "\t\talert('You must specify an expiration date OR an expiration period');\n"; | |
| 87 | + $sToRender .= "\t\treturn false;\n"; | |
| 88 | + $sToRender .= "\t}\n"; | |
| 89 | + // if expirationDate is not blank | |
| 90 | + // and either units or unit id are not blank | |
| 91 | + $sToRender .= "\tif (!isBlank(theForm.fExpirationDate) && (!isBlank(theForm.fUnits) || !isBlank(theForm.fTimeUnitID))) {\n"; | |
| 92 | + $sToRender .= "\t\talert('You must specify EITHER an expiration date OR an expiration period');\n"; | |
| 93 | + $sToRender .= "\t\treturn false;\n"; | |
| 94 | + $sToRender .= "\t}\n"; | |
| 95 | + | |
| 96 | + $sToRender .= "\tif (!isBlank(theForm.fUnits) || !isBlank(theForm.fTimeUnitID)) {\n"; | |
| 97 | + $sToRender .= "\t\tif (!validNum(theForm.fUnits, 'Units', true) ) {\n"; | |
| 98 | + $sToRender .= "\t\t\treturn false;\n"; | |
| 99 | + $sToRender .= "\t\t}\n"; | |
| 100 | + $sToRender .= "\t\tif (!validRequired(theForm.fTimeUnitID, 'Date Unit')) {\n"; | |
| 101 | + $sToRender .= "\t\t\treturn false;\n"; | |
| 102 | + $sToRender .= "\t\t}\n"; | |
| 103 | + $sToRender .= "\t} else {\n"; | |
| 104 | + $sToRender .= "\t\tif (isBlank(theForm.fExpirationDate)) {\n"; | |
| 105 | + $sToRender .= "\t\t\tif (!validDate(theForm.fExpirationDate, 'Expiration Date', true)) {\n"; | |
| 106 | + $sToRender .= "\t\t\t\treturn false;\n"; | |
| 107 | + $sToRender .= "\t\t\t}\n"; | |
| 108 | + $sToRender .= "\t\t}\n"; | |
| 109 | + $sToRender .= "\t}\n"; | |
| 110 | + $sToRender .= "\treturn true;\n"; | |
| 111 | + $sToRender .= "}\n"; | |
| 112 | + $sToRender .= "//-->\n</script>\n\n"; | |
| 113 | + return $sToRender; | |
| 114 | +} | |
| 115 | + | |
| 116 | +function getUtilisationArchivingJavascript() { | |
| 117 | + $sToRender .= "\n\n<script language=\"javascript\">\n<!--\n"; | |
| 118 | + $sToRender .= "function validateForm(theForm) {\n"; | |
| 119 | + $sToRender .= "\tif (!validRequired(theForm.fDocumentTransactionID,'Document Transaction')) {\n"; | |
| 120 | + $sToRender .= "\t\treturn false;\n\t}\n"; | |
| 121 | + $sToRender .= "\tif (!validNum(theForm.fUnits,'Units', true)) {\n"; | |
| 122 | + $sToRender .= "\t\treturn false;\n\t}\n"; | |
| 123 | + $sToRender .= "\tif (!validRequired(theForm.fTimeUnitID,'Date Unit')) {\n"; | |
| 124 | + $sToRender .= "\t\treturn false;\n\t}\n"; | |
| 125 | + $sToRender .= "return true;\n}\n"; | |
| 126 | + $sToRender .= "//-->\n</script>\n\n"; | |
| 127 | + return $sToRender; | |
| 128 | +} | |
| 129 | + | |
| 130 | +function renderTimePeriod($sHeading, $oTimePeriod = null) { | |
| 131 | + global $default; | |
| 132 | + if (strlen($sHeading) > 0) { | |
| 133 | + $sToRender .= "<tr><td colspan=\"3\">$sHeading:</td></tr>"; | |
| 134 | + } | |
| 135 | + $sToRender .= "<tr valign=\"middle\"><td><input type=\"text\" size=\"11\" name=\"fUnits\" value=\"" . ($oTimePeriod ? $oTimePeriod->getUnits() : "") . "\">"; | |
| 136 | + $sToRender .= " " . renderTimeUnitsListBox( ($oTimePeriod ? $oTimePeriod->getTimeUnitID() : null) ); | |
| 137 | + $sToRender .= " <a href=\"javascript:void();\" onclick=\"document.MainForm.fUnits.value='';document.MainForm.fTimeUnitID.value='';\"><img src=\"$default->graphicsUrl/widgets/clear.gif\" border=\"0\"></a></td></tr>"; | |
| 138 | + return $sToRender; | |
| 139 | +} | |
| 140 | + | |
| 77 | 141 | /** |
| 78 | 142 | * Displays the edit archive settings form |
| 79 | 143 | * |
| 80 | - * @param ArchiveSettings the archive settings to modify | |
| 144 | + * @param integer the archive settings to modify, null display an add form | |
| 81 | 145 | */ |
| 82 | -function renderAddArchiveSettingsForm($iArchivingTypeID) { | |
| 146 | +function renderArchiveSettingsForm($oDocumentArchiving = null) { | |
| 83 | 147 | global $default, $fDocumentID; |
| 84 | 148 | |
| 149 | + if (is_a($oDocumentArchiving, "DocumentArchiving")) { | |
| 150 | + $sToRender .= "(in order to change the archiving type for this document, click the 'Remove' button and add new archiving settings)"; | |
| 151 | + $iArchivingTypeID = $oDocumentArchiving->getArchivingTypeID(); | |
| 152 | + } else { | |
| 153 | + $iArchivingTypeID = (integer)$oDocumentArchiving; | |
| 154 | + unset($oDocumentArchiving); | |
| 155 | + } | |
| 85 | 156 | $sArchivingType = lookupName($default->owl_archiving_type_lookup_table, $iArchivingTypeID); |
| 86 | - | |
| 87 | - $sToRender = "<table border=\"0\">"; | |
| 88 | - // TODO: form instructions and calendar control integration | |
| 89 | - if ($sArchivingType == "Date") { | |
| 90 | - $sToRender .= "<tr><th colspan=\"2\">Archive By Date</th></tr>"; | |
| 91 | - $sToRender .= "<tr><td>Expiration Date:</td></tr>"; | |
| 92 | - $sToRender .= "<tr><td><input type=\"text\" name=\"fExpirationDate\" size=\"11\"></td><td align=\"right\"><a href=\"javascript: void(0);\" onmouseover=\"if (timeoutId) clearTimeout(timeoutId);window.status='Show Calendar';return true;\" onmouseout=\"if (timeoutDelay) calendarTimeout();window.status='';\" onclick=\"g_Calendar.show(event,'MainForm.fExpirationDate', false, 'yyyy-mm-dd', new Date()); return false;\"><img src=\"$default->graphicsUrl/calendar/calendar.gif\" name=\"imgCalendar\" width=\"34\" height=\"21\" border=\"0\" alt=\"\"></a></td></tr>"; | |
| 93 | - $sToRender .= "<tr><td colspan=\"3\">Expiration Period:</td></tr>"; | |
| 94 | - $sToRender .= "<tr><td><input type=\"text\" size=\"11\" name=\"fUnits\"></td>"; | |
| 95 | - $sToRender .= "<td>" . renderTimeUnitsListBox("fTimeUnitID") . "</td></tr>"; | |
| 96 | - | |
| 97 | - $sToRender .= "\n\n<script language=\"javascript\">\n<!--\n"; | |
| 98 | - $sToRender .= "function validateForm(theForm) {\n"; | |
| 99 | - $sToRender .= "\tif (isBlank(theForm.fExpirationDate) && isBlank(theForm.fUnits) && isBlank(theForm.fTimeUnitID)) {\n"; | |
| 100 | - $sToRender .= "\t\talert('You must specify an expiration date OR an expiration period');\n"; | |
| 101 | - $sToRender .= "\t\treturn false;\n"; | |
| 102 | - $sToRender .= "\t}\n"; | |
| 103 | - | |
| 104 | - $sToRender .= "\tif (!isBlank(theForm.fUnits) || !isBlank(theForm.fTimeUnitID)) {\n"; | |
| 105 | - $sToRender .= "\t\tif (!validNum(theForm.fUnits, 'Units', true) ) {\n"; | |
| 106 | - $sToRender .= "\t\t\treturn false;\n"; | |
| 107 | - $sToRender .= "\t\t}\n"; | |
| 108 | - $sToRender .= "\t\tif (!validRequired(theForm.fTimeUnitID, 'Date Unit')) {\n"; | |
| 109 | - $sToRender .= "\t\t\treturn false;\n"; | |
| 110 | - $sToRender .= "\t\t}\n"; | |
| 111 | - $sToRender .= "\t} else {\n"; | |
| 112 | - $sToRender .= "\t\tif (isBlank(theForm.fExpirationDate)) {\n"; | |
| 113 | - $sToRender .= "\t\t\talert('Please enter a value for the \"Expiration Date\" field');\n"; | |
| 114 | - $sToRender .= "\t\t\ttheForm.fExpirationDate.focus();\n\t\treturn false;\n"; | |
| 115 | - $sToRender .= "\t\t}\n"; | |
| 116 | - $sToRender .= "\t}\n"; | |
| 117 | - $sToRender .= "\t\treturn true;\n"; | |
| 118 | - $sToRender .= "}\n"; | |
| 119 | - $sToRender .= "//-->\n</script>\n\n"; | |
| 120 | - | |
| 157 | + | |
| 158 | + $sToRender .= "<table border=\"0\">"; | |
| 159 | + // TODO: calendar control integration | |
| 160 | + switch ($sArchivingType) { | |
| 161 | + case "Date" : | |
| 162 | + | |
| 163 | + if ($oDocumentArchiving) { | |
| 164 | + // get date settings from document archiving | |
| 165 | + $oDateArchivingSettings = ArchivingDateSettings::get($oDocumentArchiving->getArchivingSettingsID()); | |
| 166 | + } | |
| 167 | + $sToRender .= "<tr><th align=\"left\" colspan=\"2\">Archive By Date</th></tr>"; | |
| 168 | + $sToRender .= "<tr><td>Expiration Date:</td></tr>"; | |
| 169 | + $sToRender .= "<tr><td valign=bottom><input type=\"text\" name=\"fExpirationDate\" size=\"11\" " . ($oDateArchivingSettings ? "value=\"" . ($oDateArchivingSettings->getExpirationDate() == "0000-00-00" ? "" : $oDateArchivingSettings->getExpirationDate()) : "") . "\">"; | |
| 170 | + $sToRender .= " <a href=\"javascript:show_calendar('MainForm.fExpirationDate',null,null,'YYYY-MM-DD');\" onmouseover=\"window.status='Date Picker';return true;\" onmouseout=\"window.status='';return true;\"><img src=\"$default->graphicsUrl/calendar/calendar.gif\" name=\"imgCalendar\" width=\"34\" height=\"21\" border=\"0\" alt=\"\"></a>"; | |
| 171 | + $sToRender .= " <a href=\"javascript:void();\" onclick=\"document.MainForm.fExpirationDate.value=''\"><img src=\"$default->graphicsUrl/widgets/clear.gif\" border=\"0\"></a></td></tr>"; | |
| 172 | + | |
| 173 | + if ($oDateArchivingSettings) { | |
| 174 | + $oTimePeriod = TimePeriod::get($oDateArchivingSettings->getTimePeriodID()); | |
| 175 | + $sToRender .= renderTimePeriod("Expires after", $oTimePeriod); | |
| 176 | + } else { | |
| 177 | + $sToRender .= renderTimePeriod("Expires after"); | |
| 178 | + } | |
| 179 | + $sToRender .= getDateArchivingJavascript(); | |
| 180 | + break; | |
| 181 | + case "Utilisation" : | |
| 182 | + if ($oDocumentArchiving) { | |
| 183 | + // get date settings from document archiving | |
| 184 | + $oUtilisationArchivingSettings = ArchivingUtilisationSettings::get($oDocumentArchiving->getArchivingSettingsID()); | |
| 185 | + $iDocumentTransactionID = $oUtilisationArchivingSettings->getDocumentTransactionID(); | |
| 186 | + } | |
| 187 | + | |
| 188 | + $sToRender .= "<tr><th align=\"left\" colspan=\"2\">Archive By Utilisation</th></tr>"; | |
| 189 | + $sToRender .= "<tr><td>Document Transaction:</td><td>" . | |
| 190 | + renderDocumentTransactionListBox($iDocumentTransactionID) . | |
| 191 | + "</td></tr>"; | |
| 121 | 192 | |
| 122 | - } elseif ($sArchivingType == "Utilisation") { | |
| 123 | - $sToRender .= "<tr><th colspan=\"2\">Archive By Utilisation</th></tr>"; | |
| 124 | - $sToRender .= "<tr><td>Document Transaction:</td><td>" . renderDocumentTransactionListBox() . "</td></tr>"; | |
| 125 | - $sToRender .= "<tr><td>Units</td><td colspan=\"2\"><input type=\"text\" size=\"11\" name=\"fUnits\">" . renderTimeUnitsListBox("fTimeUnitID") . "</td></tr>"; | |
| 126 | - | |
| 127 | - $sToRender .= "\n\n<script language=\"javascript\">\n<!--\n"; | |
| 128 | - $sToRender .= "function validateForm(theForm) {\n"; | |
| 129 | - $sToRender .= "\tif (!validRequired(theForm.fDocumentTransactionID,'Document Transaction')) {\n"; | |
| 130 | - $sToRender .= "\t\treturn false;\n\t}\n"; | |
| 131 | - $sToRender .= "\tif (!validNum(theForm.fUnits,'Units', true)) {\n"; | |
| 132 | - $sToRender .= "\t\treturn false;\n\t}\n"; | |
| 133 | - $sToRender .= "\tif (!validRequired(theForm.fTimeUnitID,'Date Unit')) {\n"; | |
| 134 | - $sToRender .= "\t\treturn false;\n\t}\n"; | |
| 135 | - $sToRender .= "return true;\n}\n"; | |
| 136 | - $sToRender .= "//-->\n</script>\n\n"; | |
| 193 | + if ($oUtilisationArchivingSettings) { | |
| 194 | + $oTimePeriod = TimePeriod::get($oUtilisationArchivingSettings->getTimePeriodID()); | |
| 195 | + $sToRender .= renderTimePeriod("Time since last transaction", $oTimePeriod); | |
| 196 | + } else { | |
| 197 | + $sToRender .= renderTimePeriod("Time since last transaction"); | |
| 198 | + } | |
| 199 | + $sToRender .= getUtilisationArchivingJavascript(); | |
| 200 | + break; | |
| 137 | 201 | } |
| 138 | 202 | |
| 139 | 203 | // hidden archive settings references |
| 140 | 204 | $sToRender .= "<input type=\"hidden\" name=\"fDocumentID\" value=\"$fDocumentID\">\n"; |
| 141 | 205 | $sToRender .= "<input type=\"hidden\" name=\"fArchivingTypeID\" value=\"$iArchivingTypeID\">\n"; |
| 142 | - $sToRender .= "<input type=\"hidden\" name=\"fStore\" value=\"1\">\n"; | |
| 143 | - $sToRender .= "<tr><td><input type=\"image\" src=\"$default->graphicsUrl/widgets/submit.gif\" border=\"0\">\n"; | |
| 144 | - $sToRender .= $sJavaScript; | |
| 145 | - $sToRender .= "<a href=\"$default->rootUrl/control.php?action=addDocumentArchiveSettings&fDocumentID=$fDocumentID\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\" /></a></td></tr>\n"; | |
| 206 | + $sToRender .= "<input type=\"hidden\" name=\"fStore\" value=\"1\">\n"; | |
| 207 | + if ($oDocumentArchiving) { | |
| 208 | + $sToRender .= "<tr><td colspan=\"2\"><input type=\"image\" src=\"$default->graphicsUrl/widgets/update.gif\" border=\"0\">\n"; | |
| 209 | + $sToRender .= "<a href=\"$default->rootUrl/control.php?action=modifyDocumentArchiveSettings&fDocumentID=$fDocumentID&fDelete=1\"><img src=\"$default->graphicsUrl/widgets/remove.gif\" border=\"0\" /></a>\n"; | |
| 210 | + } else { | |
| 211 | + $sToRender .= "<tr><td colspan=\"2\"><input type=\"image\" src=\"$default->graphicsUrl/widgets/submit.gif\" border=\"0\">\n"; | |
| 212 | + } | |
| 213 | + $sToRender .= "<a href=\"$default->rootUrl/control.php?action=viewDocument&fDocumentID=$fDocumentID\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\" /></a></td></tr>\n"; | |
| 146 | 214 | $sToRender .= "</table>"; |
| 147 | 215 | |
| 148 | - | |
| 149 | - | |
| 150 | 216 | return $sToRender; |
| 151 | 217 | } |
| 152 | 218 | |
| 153 | 219 | /** |
| 154 | 220 | * Displays the edit document archive settings page |
| 155 | 221 | */ |
| 156 | -function renderEditArchiveSettingsPage($oArchiveSettings, $sErrorMessage = "") { | |
| 222 | +function renderEditArchiveSettingsPage($oDocumentArchiving, $sErrorMessage = "") { | |
| 157 | 223 | global $default; |
| 158 | 224 | |
| 159 | - //$sToRender .= "<table width=\"600\">" . renderHeading("Edit Document Archive Settings") . "</table>"; | |
| 160 | 225 | $sToRender .= renderHeading("Edit Document Archive Settings"); |
| 161 | 226 | if (strlen($sErrorMessage) > 0) { |
| 162 | 227 | $sToRender .= renderErrorMessage($sErrorMessage); |
| 163 | 228 | } |
| 164 | 229 | $sToRender .= "<table>\n"; |
| 165 | - if ($oArchiveSettings) { | |
| 166 | - $sToRender .= renderEditArchiveSettingsForm($oArchiveSettings); | |
| 167 | - } else { | |
| 168 | - $sToRender .= renderAddArchiveSettingsForm($oArchiveSettings); | |
| 169 | - } | |
| 230 | + $sToRender .= renderArchiveSettingsForm($oDocumentArchiving); | |
| 170 | 231 | $sToRender .= "</table>\n"; |
| 171 | 232 | return $sToRender; |
| 172 | 233 | } |
| ... | ... | @@ -183,7 +244,7 @@ function renderAddArchiveSettingsPage($iArchivingTypeID, $sErrorMessage = "") { |
| 183 | 244 | } |
| 184 | 245 | $sToRender .= "<table>\n"; |
| 185 | 246 | if ($iArchivingTypeID) { |
| 186 | - $sToRender .= renderAddArchiveSettingsForm($iArchivingTypeID); | |
| 247 | + $sToRender .= renderArchiveSettingsForm($iArchivingTypeID); | |
| 187 | 248 | } else { |
| 188 | 249 | $sToRender .= renderChooseArchivingTypeForm(); |
| 189 | 250 | } | ... | ... |
presentation/lookAndFeel/knowledgeTree/documentmanagement/archiving/modifyArchiveSettingsBL.php
| ... | ... | @@ -2,7 +2,9 @@ |
| 2 | 2 | |
| 3 | 3 | require_once("../../../../../config/dmsDefaults.php"); |
| 4 | 4 | require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); |
| 5 | -require_once("$default->fileSystemRoot/lib/documentmanagement/ArchiveSettings.inc"); | |
| 5 | + | |
| 6 | +require_once("$default->fileSystemRoot/lib/archiving/DocumentArchiveSettingsFactory.inc"); | |
| 7 | + | |
| 6 | 8 | require_once("$default->fileSystemRoot/lib/visualpatterns/PatternMainPage.inc"); |
| 7 | 9 | require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); |
| 8 | 10 | require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc"); |
| ... | ... | @@ -27,34 +29,38 @@ if (checkSession()) { |
| 27 | 29 | |
| 28 | 30 | // instantiate my content pattern |
| 29 | 31 | $oContent = new PatternCustom(); |
| 32 | + $default->log->info(arrayToString($_REQUEST)); | |
| 30 | 33 | if ($fDocumentID) { |
| 31 | - $oArchiveSettings = ArchiveSettings::getFromDocumentID($fDocumentID); | |
| 32 | - if ($fStore) { | |
| 33 | - // we're updating the settings- check the parameters | |
| 34 | - if (isset($fExpirationDate) || isset($fExpirationUnits) && isset($fExpirationDatePart)) { | |
| 35 | - // setting archiving by date | |
| 36 | - // update the object | |
| 37 | - if ($fExpirationDate) { | |
| 38 | - $oArchiveSettings->setExpirationDate($fExpirationDate); | |
| 39 | - } else if ($fExpirationUnits && $fExpirationDatePart) { | |
| 40 | - $oArchiveSettings->setExpirationDate(time() + $fExpirationUnits*$oArchiveSettings->aDateUnits[$fExpirationDatePart]); | |
| 41 | - } | |
| 42 | - } else if (isset($fDocumentTransactionID) && isset($fUtilisationUnits) && isset($fUtilisationDatePart)) { | |
| 43 | - // setting by utilisation | |
| 44 | - | |
| 45 | - // update the object | |
| 46 | - $oArchiveSettings->setDocumentTransactionID($fDocumentTransactionID); | |
| 47 | - $oArchiveSettings->setUtilisationThreshold($fUtilisationUnits*$oArchiveSettings->aDateUnits[$fUtilisationDatePart]); | |
| 48 | - } else { | |
| 49 | - // all params not present, so display an error message | |
| 50 | - $oContent->setHtml(renderEditArchiveSettingsPage($oArchiveSettings, "Please complete the form before submitting.")); | |
| 51 | - } | |
| 52 | - } else { | |
| 53 | - // display the edit page | |
| 54 | - $oContent->setHtml(renderEditArchiveSettingsPage($oArchiveSettings)); | |
| 55 | - } | |
| 34 | + // retrieve the appropriate settings given the document id | |
| 35 | + $oDocumentArchiving = DocumentArchiving::getFromDocumentID($fDocumentID); | |
| 36 | + if ($oDocumentArchiving) { | |
| 37 | + if ($fStore) { | |
| 38 | + $oDASFactory = new DocumentArchiveSettingsFactory($oDocumentArchiving->getArchivingTypeID()); | |
| 39 | + | |
| 40 | + if ($oDASFactory->update($oDocumentArchiving, $fExpirationDate, $fDocumentTransactionID, $fTimeUnitID, $fUnits)) { | |
| 41 | + $default->log->info("modifyArchiveSettingsBL.php successfully updated archive settings (documentID=$fDocumentID)"); | |
| 42 | + // created, redirect to view page | |
| 43 | + redirect("$default->rootUrl/control.php?action=viewDocument&fDocumentID=$fDocumentID"); | |
| 44 | + } else { | |
| 45 | + $default->log->error("modifyArchiveSettingsBL.php error updating archive settings (documentID=$fDocumentID)"); | |
| 46 | + } | |
| 47 | + } elseif ($fDelete) { | |
| 48 | + if ($oDocumentArchiving->delete()) { | |
| 49 | + $default->log->info("modifyArchiveSettingsBL.php successfully deleted archive settings (documentID=$fDocumentID)"); | |
| 50 | + redirect("$default->rootUrl/control.php?action=viewDocument&fDocumentID=$fDocumentID"); | |
| 51 | + } else { | |
| 52 | + $default->log->error("modifyArchiveSettingsBL.php error deleting archive settings (documentID=$fDocumentID)"); | |
| 53 | + } | |
| 54 | + } else { | |
| 55 | + // display the edit page | |
| 56 | + $oContent->setHtml(renderEditArchiveSettingsPage($oDocumentArchiving)); | |
| 57 | + } | |
| 58 | + } else { | |
| 59 | + // no archiving settings for this document | |
| 60 | + $oContent->setHtml(renderEditArchiveSettingsPage(null, "No document has been selected.")); | |
| 61 | + } | |
| 56 | 62 | } else { |
| 57 | - // document id missing | |
| 63 | + // document id missing | |
| 58 | 64 | $oContent->setHtml(renderEditArchiveSettingsPage(null, "No document has been selected.")); |
| 59 | 65 | } |
| 60 | 66 | ... | ... |