Commit 32fddb2cca8a55c23ffafad0d1bb43e57a8d74f7

Authored by Neil Blakey-Milner
1 parent c605578e

Add edit unit, even though it currently can't be used due to inability

to rename folders.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4822 c91229c3-7414-0410-bfa2-8a42b809f60b
plugins/ktcore/admin/unitManagement.php
@@ -47,7 +47,7 @@ class KTUnitAdminDispatcher extends KTAdminDispatcher { @@ -47,7 +47,7 @@ class KTUnitAdminDispatcher extends KTAdminDispatcher {
47 47
48 $this->oPage->setTitle(_("Add a new unit")); 48 $this->oPage->setTitle(_("Add a new unit"));
49 49
50 - $edit_fields = array(); 50 + $add_fields = array();
51 $add_fields[] = new KTStringWidget(_('Unit Name'),_('A short name for the unit. e.g. <strong>Accounting</strong>.'), 'unit_name', null, $this->oPage, true); 51 $add_fields[] = new KTStringWidget(_('Unit Name'),_('A short name for the unit. e.g. <strong>Accounting</strong>.'), 'unit_name', null, $this->oPage, true);
52 52
53 $collection = new DocumentCollection(); 53 $collection = new DocumentCollection();
@@ -107,6 +107,33 @@ class KTUnitAdminDispatcher extends KTAdminDispatcher { @@ -107,6 +107,33 @@ class KTUnitAdminDispatcher extends KTAdminDispatcher {
107 )); 107 ));
108 return $this->successRedirectToMain('Unit created'); 108 return $this->successRedirectToMain('Unit created');
109 } 109 }
  110 +
  111 + function do_editUnit() {
  112 + $oUnit =& $this->oValidator->validateUnit($_REQUEST['unit_id']);
  113 +
  114 + $fields = array();
  115 + $fields[] = new KTStringWidget(_('Unit Name'),_('A short name for the unit. e.g. <strong>Accounting</strong>.'), 'unit_name', $oUnit->getName(), $this->oPage, true);
  116 +
  117 + $oTemplate =& $this->oValidator->validateTemplate('ktcore/principals/editunit');
  118 + $aTemplateData = array(
  119 + "context" => $this,
  120 + "edit_unit" => $oUnit,
  121 + "edit_fields" => $fields,
  122 + );
  123 + return $oTemplate->render($aTemplateData);
  124 + }
  125 +
  126 + function do_saveUnit() {
  127 + $oUnit =& $this->oValidator->validateUnit($_REQUEST['unit_id']);
  128 + $sName =& $this->oValidator->validateString($_REQUEST['unit_name']);
  129 + $oUnit->setName($sName);
  130 + $res = $oUnit->update();
  131 + if (($res == false) || (PEAR::isError($res))) {
  132 + return $this->errorRedirectToMain(_('Failed to set unit details.'));
  133 + }
  134 + $this->successRedirectToMain(_("Unit details updated"));
  135 +
  136 + }
110 } 137 }
111 138
112 class KTUnitTitleColumn extends TitleColumn { 139 class KTUnitTitleColumn extends TitleColumn {