Allow re-opening of Dimensions
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Tue, 8 Sep 2009 08:43:06 +0000 (08:43 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Tue, 8 Sep 2009 08:43:06 +0000 (08:43 +0000)
CHANGELOG.txt
dimensions/dimension_entry.php
dimensions/includes/dimensions_db.inc
dimensions/inquiry/search_dimensions.php

index b3ce5ec6650ddf9594cc804c63a964ccf423bb50..7f3f62918cceb0ef34e702bfe9b0148d8b3979a0 100644 (file)
@@ -49,6 +49,10 @@ $ /applications/customers.php
   /sql/alter2.2.sql
   /sql/en_US-demo.sql
   /sql/en_US-new.sql
+! Allow re-opening of Dimensions
+$ /dimensions/dimension_entry.php
+  /dimensions/includes/dimensions_db.inc
+  /dimensions/inquiry/search_dimensions.php
   
 01-Sep-2009 Janusz Dobrowolski
 # Fixed security sections db update.
index 31f45748bbe19b646788906838f316ca2a8e636a..91904b53034a90d738630c021a69d9655ffe597d 100644 (file)
@@ -78,6 +78,16 @@ if (isset($_GET['ClosedID']))
        safe_exit();
 }
 
+//---------------------------------------------------------------------------------------
+
+if (isset($_GET['ReopenedID'])) 
+{
+       $id = $_GET['ReopenedID'];
+
+       display_notification_centered(_("The dimension has been re-opened. ") . " #$id");
+       safe_exit();
+}
+
 //-------------------------------------------------------------------------------------------------
 
 function safe_exit()
@@ -198,6 +208,13 @@ if (isset($_POST['close']))
        meta_forward($_SERVER['PHP_SELF'], "ClosedID=$selected_id");
 }
 
+if (isset($_POST['reopen'])) 
+{
+
+       // update the closed flag
+       reopen_dimension($selected_id);
+       meta_forward($_SERVER['PHP_SELF'], "ReopenedID=$selected_id");
+}
 //-------------------------------------------------------------------------------------
 
 start_form();
@@ -215,11 +232,11 @@ if ($selected_id != -1)
        }
 
        // if it's a closed dimension can't edit it
-       if ($myrow["closed"] == 1) 
-       {
-               display_error(_("This dimension is closed and cannot be edited."));
-               display_footer_exit();
-       }
+       //if ($myrow["closed"] == 1) 
+       //{
+       //      display_error(_("This dimension is closed and cannot be edited."));
+       //      display_footer_exit();
+       //}
 
        $_POST['ref'] = $myrow["reference"];
        $_POST['closed'] = $myrow["closed"];
@@ -254,11 +271,17 @@ textarea_row(_("Memo:"), 'memo_', null, 40, 5);
 
 end_table(1);
 
+if (isset($_POST['closed']) && $_POST['closed'] == 1)
+       display_note(_("This Dimension is closed."), 0, 0, "class='currentfg'");
+
 if ($selected_id != -1) 
 {
        echo "<br>";
        submit_center_first('UPDATE_ITEM', _("Update"), _('Save changes to dimension'), 'default');
-       submit('close', _("Close This Dimension"), true, _('Mark this dimension as closed'), true);
+       if ($_POST['closed'] == 1)
+               submit('reopen', _("Re-open This Dimension"), true, _('Mark this dimension as re-opened'), true);
+       else    
+               submit('close', _("Close This Dimension"), true, _('Mark this dimension as closed'), true);
        submit_center_last('delete', _("Delete This Dimension"), _('Delete unused dimension'), true);
 }
 else
index 344305a209f76adf1333767ffd5a0cb7e170b109..4013e4ebe070ca825faf4ad2449f5b0855416798 100644 (file)
@@ -142,4 +142,10 @@ function close_dimension($id)
 
 //--------------------------------------------------------------------------------------
 
+function reopen_dimension($id)
+{
+       $sql = "UPDATE ".TB_PREF."dimensions SET closed='0' WHERE id = $id";
+       db_query($sql, "could not close dimension");
+}
+
 ?>
\ No newline at end of file
index 9a5c16aebebca47e877610f041697b0c73992d80..8006a1c4f6265517bb4ce0e2bfc5566d1d57d4d5 100644 (file)
@@ -123,8 +123,10 @@ function is_overdue($row)
 
 function edit_link($row)
 {
-       return $row["closed"] ?  '' :
-               pager_link(_("Edit"),
+       //return $row["closed"] ?  '' :
+       //      pager_link(_("Edit"),
+       //              "/dimensions/dimension_entry.php?trans_no=" . $row["id"], ICON_EDIT);
+       return pager_link(_("Edit"),
                        "/dimensions/dimension_entry.php?trans_no=" . $row["id"], ICON_EDIT);
 }