From a73a4cac0a9e8808904c3a3de5ceb574c7f040eb Mon Sep 17 00:00:00 2001 From: michael Date: Thu, 22 May 2003 15:51:17 +0000 Subject: [PATCH] add archive settings completed --- presentation/lookAndFeel/knowledgeTree/documentmanagement/archiving/addArchiveSettingsBL.php | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------- presentation/lookAndFeel/knowledgeTree/documentmanagement/archiving/archiveSettingsUI.inc | 141 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------- 2 files changed, 188 insertions(+), 65 deletions(-) diff --git a/presentation/lookAndFeel/knowledgeTree/documentmanagement/archiving/addArchiveSettingsBL.php b/presentation/lookAndFeel/knowledgeTree/documentmanagement/archiving/addArchiveSettingsBL.php index 8ba9af4..706f6c6 100644 --- a/presentation/lookAndFeel/knowledgeTree/documentmanagement/archiving/addArchiveSettingsBL.php +++ b/presentation/lookAndFeel/knowledgeTree/documentmanagement/archiving/addArchiveSettingsBL.php @@ -2,7 +2,12 @@ require_once("../../../../../config/dmsDefaults.php"); require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); -require_once("$default->fileSystemRoot/lib/documentmanagement/ArchiveSettings.inc"); + +require_once("$default->fileSystemRoot/lib/archiving/DocumentArchiving.inc"); +require_once("$default->fileSystemRoot/lib/archiving/ArchivingUtilisationSettings.inc"); +require_once("$default->fileSystemRoot/lib/archiving/ArchivingDateSettings.inc"); +require_once("$default->fileSystemRoot/lib/archiving/TimePeriod.inc"); + require_once("$default->fileSystemRoot/lib/visualpatterns/PatternMainPage.inc"); require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc"); @@ -22,44 +27,87 @@ require_once("$default->uiDirectory/documentmanagement/archiving/archiveSettings * @package presentation.lookAndFeel.knowledgeTree.documentmanagement */ +class DocumentArchiveSettingsFactory { + function create($iDocumentID, $iArchivingTypeID, $dExpirationDate, $iDocumentTransactionID, $iTimeUnitID, $iUnits) { + global $default; + $sArchivingType = lookupName($default->owl_archiving_type_lookup_table, $iArchivingTypeID); + + // search for an existing time period id + $aTimePeriod = TimePeriod::getList("time_unit_id=$iTimeUnitID AND units=$iUnits"); + if (count($aTimePeriod) > 0) { + $iTimePeriodID = $aTimePeriod[0]->getID(); + } else { + // create it + $oTimePeriod = new TimePeriod($iTimeUnitID, $iUnits); + if ($oTimePeriod->create()) { + $iTimePeriodID = $oTimePeriod->getID(); + } else { + $default->log->error("couldn't create time period- " . arrayToString($oTimePeriod)); + return false; + } + } + + // construction strings + switch ($sArchivingType) { + case "Date" : $sSearchConstruction = "\$aArchiveSettings = ArchivingDateSettings::getList(\"expiration_date='$dExpirationDate' AND time_period_id=$iTimePeriodID\");"; + $sConstruction = "\$oArchiveSettings = new ArchivingDateSettings($dExpirationDate, $iTimePeriodID);"; + break; + case "Utilisation" : $sSearchConstruction = "\$aArchiveSettings = ArchivingUtilisationSettings::getList(\"document_transaction_id=$iDocumentTransactionID AND time_period_id=$iTimePeriodID\");"; + $sConstruction = "\$oArchiveSettings = new ArchivingUtilisationSettings($iDocumentTransactionID, $iTimePeriodID);"; + break; + } + + // search for the settings first + eval($sSearchConstruction); + if (count($aArchiveSettings) > 0) { + $iArchiveSettingsID = $aArchiveSettings[0]->getID(); + } else { + // create them + eval($sConstruction); + if ($oArchiveSettings->create()) { + $iArchiveSettingsID = $oArchiveSettings->getID(); + } else { + $default->log->error("couldn't create archive settings- " . arrayToString($oArchiveSettings)); + return false; + } + + // now link to the documents + $oDocumentArchiving = new DocumentArchiving($iDocumentID, $iArchivingTypeID, $iArchiveSettingsID); + if ($oDocumentArchiving->create()) { + return true; + } else { + $default->log->error("couldn't create document archiving - " . arrayToString($oDocumentArchiving)); + return false; + } + } + } +} + if (checkSession()) { global $default; // instantiate my content pattern $oContent = new PatternCustom(); - $default->log->info(arrayToString($_POST)); + $default->log->info(arrayToString($_REQUEST)); if ($fStore) { - // setting archiving by date - if (isset($fExpirationDate) || isset($fExpirationUnits) && isset($fExpirationDatePart)) { - if ($fExpirationDate) { - $dExpirationDate = $fExpirationDate; - } else if ($fExpirationUnits && $fExpirationDatePart) { - $dExpirationDate = date() + $fExpirationUnits*$fExpirationDatePart; - } - $oArchiveSettings = new ArchiveSettings($fDocumentID, $fExpirationDate, 0, 0); - if ($oArchiveSettings->create()) { - // created, redirect to view page - } else { - $default->log->error("addArchiveSettingsBL.php error adding archive settings:" . arrayToString($oArchiveSettings)); - } - // setting by utilisation - } else if (isset($fDocumentTransactionID) && isset($fUtilisationUnits) && isset($fUtilisationDatePart)) { - $iUtilisationThreshold = $fUtilisationUnits*$oArchiveSettings->aDateUnits[$fUtilisationDatePart]; - $oArchiveSettings = new ArchiveSettings($fDocumentID, "", $iUtilisationThreshold, $fDocumentTransactionID); - if ($oArchiveSettings->create()) { - // created, redirect to view page - redirect("$default->rootUrl/control.php?action=viewDocument&fDocumentID=$fDocumentID"); - } else { - $default->log->error("addArchiveSettingsBL.php error adding archive settings:" . arrayToString($oArchiveSettings)); - } - } else { - // all params not present, so display an error message - $oContent->setHtml(renderAddArchiveSettingsPage(null, "Please complete the form before submitting.")); - } - } else { + if (DocumentArchiveSettingsFactory::create($fDocumentID, $fArchivingTypeID, $fExpirationDate, $fDocumentTransactionID, $fTimeUnitID, $fUnits)) { + // created, redirect to view page + redirect("$default->rootUrl/control.php?action=viewDocument&fDocumentID=$fDocumentID"); + } else { + // error + $default->log->error("addArchiveSettingsBL.php error adding archive settings"); + // display form with error + $oContent->setHtml(renderAddArchiveSettingsPage(null, "The archive settings for this document could not be added")); + } + + } elseif (isset($fArchivingTypeID)) { + // the archiving type has been chosen, so display the correct form // display the edit/add page - $oContent->setHtml(renderEditArchiveSettingsPage(null)); - } + $oContent->setHtml(renderAddArchiveSettingsPage($fArchivingTypeID)); + } else { + // display the choose archiving type page + $oContent->setHtml(renderAddArchiveSettingsPage(null)); + } // build the page require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); diff --git a/presentation/lookAndFeel/knowledgeTree/documentmanagement/archiving/archiveSettingsUI.inc b/presentation/lookAndFeel/knowledgeTree/documentmanagement/archiving/archiveSettingsUI.inc index 4894e8a..e33d8a9 100644 --- a/presentation/lookAndFeel/knowledgeTree/documentmanagement/archiving/archiveSettingsUI.inc +++ b/presentation/lookAndFeel/knowledgeTree/documentmanagement/archiving/archiveSettingsUI.inc @@ -40,58 +40,113 @@ function renderErrorMessage($sErrorMessage) { return $sToRender; } + function renderDocumentTransactionListBox() { global $default; $oPatternListBox = & new PatternListBox($default->owl_transaction_types_table, "name", "id", "fDocumentTransactionID"); return $oPatternListBox->render(); } +function renderArchivingTypeListBox() { + global $default, $fArchivingTypeID; + $oPatternListBox = & new PatternListBox($default->owl_archiving_type_lookup_table, "name", "id", "fArchivingTypeID"); + $oPatternListBox->setPostBackOnChange(true); + $oPatternListBox->setSelectedValue($fArchivingTypeID); + return $oPatternListBox->render(); +} + +function renderTimeUnitsListBox($sVariableName) { + global $default; + $oPatternListBox = & new PatternListBox($default->owl_time_unit_lookup_table, "name", "id", $sVariableName); + return $oPatternListBox->render(); +} + +function renderChooseArchivingTypeForm() { + global $default, $fDocumentID; + + $sToRender = ""; + $sToRender .= ""; + $sToRender .= ""; + // hidden archive settings references + $sToRender .= "\n"; + $sToRender .= "\n"; + $sToRender .= "
Choose the archiving type for this document
Archiving Type:" . renderArchivingTypeListBox() . "
rootUrl/control.php?action=viewDocument&fDocumentID=$fDocumentID\">graphicsUrl/widgets/cancel.gif\" border=\"0\" />
"; + return $sToRender; +} + /** * Displays the edit archive settings form * * @param ArchiveSettings the archive settings to modify */ -function renderAddArchiveSettingsForm($oArchiveSettings) { +function renderAddArchiveSettingsForm($iArchivingTypeID) { global $default, $fDocumentID; - + + $sArchivingType = lookupName($default->owl_archiving_type_lookup_table, $iArchivingTypeID); + $sToRender = ""; - // TODO: form instructions - $sToRender .= ""; - $sToRender .= ""; - //$sToRender .= ""; - $sToRender .= ""; - $sToRender .= ""; - - $sToRender .= ""; - $sToRender .= ""; - - $sToRender .= ""; - $sToRender .= ""; - $sToRender .= ""; - $sToRender .= ""; - $sToRender .= ""; + // TODO: form instructions and calendar control integration + if ($sArchivingType == "Date") { + $sToRender .= ""; + $sToRender .= ""; + $sToRender .= ""; + $sToRender .= ""; + $sToRender .= ""; + $sToRender .= ""; + + $sToRender .= "\n\n\n\n"; + + + } elseif ($sArchivingType == "Utilisation") { + $sToRender .= ""; + $sToRender .= ""; + $sToRender .= ""; + + $sToRender .= "\n\n\n\n"; + } // hidden archive settings references - $sToRender .= "\n"; $sToRender .= "\n"; - + $sToRender .= "\n"; + $sToRender .= "\n"; $sToRender .= "\n"; + $sToRender .= $sJavaScript; + $sToRender .= "rootUrl/control.php?action=addDocumentArchiveSettings&fDocumentID=$fDocumentID\">graphicsUrl/widgets/cancel.gif\" border=\"0\" />\n"; $sToRender .= "
Archive By Date
Expiration Date:
graphicsUrl/calendar/calendar.gif\" name=\"imgCalendar\" width=\"34\" height=\"21\" border=\"0\" alt=\"\">
getExpirationDate() : "2003-06-06") . "\" size=\"11\">
Expiration Period:
"; - $sToRender .= "
Archive By Utilisation
Utilisation Threshold:
Document Transaction:" . renderDocumentTransactionListBox() . "
Archive By Date
Expiration Date:
graphicsUrl/calendar/calendar.gif\" name=\"imgCalendar\" width=\"34\" height=\"21\" border=\"0\" alt=\"\">
Expiration Period:
" . renderTimeUnitsListBox("fTimeUnitID") . "
Archive By Utilisation
Document Transaction:" . renderDocumentTransactionListBox() . "
Units" . renderTimeUnitsListBox("fTimeUnitID") . "
graphicsUrl/widgets/submit.gif\" border=\"0\">\n"; - $sToRender .= "rootUrl/control.php?action=viewDocument&fDocumentID=$fDocumentID\">graphicsUrl/widgets/cancel.gif\" border=\"0\" />
"; - /* - $sToRender .= "\n\n\n\n"; - */ + + return $sToRender; } @@ -116,6 +171,26 @@ function renderEditArchiveSettingsPage($oArchiveSettings, $sErrorMessage = "") { return $sToRender; } +/** + * Displays the add document archive settings page + */ +function renderAddArchiveSettingsPage($iArchivingTypeID, $sErrorMessage = "") { + global $default; + + $sToRender .= renderHeading("Add Document Archive Settings"); + if (strlen($sErrorMessage) > 0) { + $sToRender .= renderErrorMessage($sErrorMessage); + } + $sToRender .= "\n"; + if ($iArchivingTypeID) { + $sToRender .= renderAddArchiveSettingsForm($iArchivingTypeID); + } else { + $sToRender .= renderChooseArchivingTypeForm(); + } + $sToRender .= "
\n"; + return $sToRender; +} + function wrap($html) { global $default; -- libgit2 0.21.4