Added ajax extensions
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Sun, 6 Jul 2008 21:19:17 +0000 (21:19 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Sun, 6 Jul 2008 21:19:17 +0000 (21:19 +0000)
admin/view_print_transaction.php
admin/void_transaction.php
dimensions/dimension_entry.php
manufacturing/manage/bom_edit.php
manufacturing/work_order_entry.php
sales/manage/customer_branches.php

index 106d161a98eef6cf0a95be437f18c46d693b0828..da479c6ba01006fb8a7139735602193f5107ac27 100644 (file)
@@ -36,7 +36,7 @@ function viewing_controls()
 
     ref_cells(_("to #:"), 'ToTransNo');
 
-    submit_cells('ProcessSearch', _("Search"));
+    submit_cells('ProcessSearch', _("Search"), '', '', true);
 
        end_row();
     end_table(1);
@@ -121,6 +121,7 @@ function handle_search()
                        else
                                $th = array(_("#"), _("View"), _("GL"));
                }
+               div_start('transactions');
                start_table($table_style);
                table_header($th);
                $k = 0;
@@ -142,6 +143,7 @@ function handle_search()
                }
 
                end_table();
+               div_end();
        }
 }
 
@@ -151,6 +153,7 @@ if (isset($_POST['ProcessSearch']))
 {
        if (!check_valid_entries())
                unset($_POST['ProcessSearch']);
+       $Ajax->activate('transactions');
 }
 
 //----------------------------------------------------------------------------------------
index 371e3e5aacbef94df515c7d0abe8429e6c61b2be..4b5669400032cc4cca1800f5a303eaff8699bbc1 100644 (file)
@@ -35,13 +35,13 @@ function voiding_controls()
        end_table(1);
 
     if (!isset($_POST['ProcessVoiding']))
-       submit_center('ProcessVoiding', _("Void Transaction"));
+       submit_center('ProcessVoiding', _("Void Transaction"), true, '', true);
     else 
     {
        
        display_note(_("Are you sure you want to void this transaction ? This action cannot be undone."), 0, 1);
-       submit_center_first('ConfirmVoiding', _("Proceed"));
-       submit_center_last('CancelVoiding', _("Cancel"));
+       submit_center_first('ConfirmVoiding', _("Proceed"), '', true);
+       submit_center_last('CancelVoiding', _("Cancel"), '', true);
     }
 
        end_form();
@@ -123,11 +123,18 @@ if (isset($_POST['ProcessVoiding']))
 {
        if (!check_valid_entries())
                unset($_POST['ProcessVoiding']);
+       $Ajax->activate('_page_body');
 }
 
 if (isset($_POST['ConfirmVoiding']))
 {
        handle_void_transaction();
+       $Ajax->activate('_page_body');
+}
+
+if (isset($_POST['CancelVoiding']))
+{
+       $Ajax->activate('_page_body');
 }
 
 //----------------------------------------------------------------------------------------
index fb45de5a5c5efc04e11e612461670f2c6c5a49a1..bf6fe3eeb1b179e0513486c869870d3b984f7823 100644 (file)
@@ -246,16 +246,17 @@ textarea_row(_("Memo:"), 'memo_', null, 40, 5);
 
 end_table(1);
 
-submit_add_or_update_center($selected_id == -1, '', true);
-
 if ($selected_id != -1) 
 {
        echo "<br>";
-
-       submit_center_first('close', _("Close This Dimension"), _('Mark this dimension as closed'), true);
+       submit_center_first('UPDATE_ITEM', _("Update"), _('Save changes to dimension'), true);
+       submit('close', _("Close This Dimension"), true, _('Mark this dimension as closed'), true);
        submit_center_last('delete', _("Delete This Dimension"), _('Delete unused dimension'), true);
 }
-
+else
+{
+       submit_center('ADD_ITEM', _("Add"), true, '', true);
+}
 end_form();
 
 //--------------------------------------------------------------------------------------------
index d06b84d321a6f525bfb6e6d1c0ed5f4355ec1c66..09dfd5e9039f129bf3c94b0d658e6d8bfc5430a4 100644 (file)
@@ -16,20 +16,22 @@ check_db_has_bom_stock_items(_("There are no manufactured or kit items defined i
 
 check_db_has_workcentres(_("There are no work centres defined in the system. BOMs require at least one work centre be defined."));
 
+simple_page_mode(true);
+$selected_component = $selected_id;
 //--------------------------------------------------------------------------------------------------
 
-if (isset($_GET["NewItem"]))
-{
-       $_POST['stock_id'] = $_GET["NewItem"];
-}
-if (isset($_GET['stock_id']))
-{
-       $_POST['stock_id'] = $_GET['stock_id'];
-       $selected_parent =  $_GET['stock_id'];
-}
+//if (isset($_GET["NewItem"]))
+//{
+//     $_POST['stock_id'] = $_GET["NewItem"];
+//}
+//if (isset($_GET['stock_id']))
+//{
+//     $_POST['stock_id'] = $_GET['stock_id'];
+//     $selected_parent =  $_GET['stock_id'];
+//}
 
 /* selected_parent could come from a post or a get */
-if (isset($_GET["selected_parent"]))
+/*if (isset($_GET["selected_parent"]))
 {
        $selected_parent = $_GET["selected_parent"];
 }
@@ -37,16 +39,17 @@ else if (isset($_POST["selected_parent"]))
 {
        $selected_parent = $_POST["selected_parent"];
 }
+*/
 /* selected_component could also come from a post or a get */
-if (isset($_GET["selected_component"]))
+/*if (isset($_GET["selected_component"]))
 {
        $selected_component = $_GET["selected_component"];
 }
-elseif (isset($_POST["selected_component"]))
+else
 {
-       $selected_component = $_POST["selected_component"];
+       $selected_component = get_post("selected_component", -1);
 }
-
+*/
 
 //--------------------------------------------------------------------------------------------------
 
@@ -104,8 +107,8 @@ div_start('bom');
         label_cell($myrow["WorkCentreDescription"]);
         qty_cell($myrow["quantity"], false, get_qty_dec($myrow["component"]));
         label_cell($myrow["units"]);
-        edit_link_cell(SID . "NewItem=$selected_parent&selected_component=" . $myrow["id"]);
-        delete_link_cell(SID . "delete=" . $myrow["id"]. "&stock_id=" . $_POST['stock_id']);
+               edit_button_cell("Edit".$myrow['id'], _("Edit"));
+               edit_button_cell("Delete".$myrow['id'], _("Delete"));
         end_row();
 
        } //END WHILE LIST LOOP
@@ -115,7 +118,7 @@ div_end();
 
 //--------------------------------------------------------------------------------------------------
 
-function on_submit($selected_parent, $selected_component=null)
+function on_submit($selected_parent, $selected_component=-1)
 {
        if (!check_num('quantity', 0))
        {
@@ -124,7 +127,7 @@ function on_submit($selected_parent, $selected_component=null)
                return;
        }
 
-       if (isset($selected_parent) && isset($selected_component))
+       if ($selected_component != -1)
        {
 
                $sql = "UPDATE ".TB_PREF."bom SET workcentre_added='" . $_POST['workcentre_added'] . "',
@@ -135,9 +138,10 @@ function on_submit($selected_parent, $selected_component=null)
                check_db_error("Could not update this bom component", $sql);
 
                db_query($sql,"could not update bom");
-
+               display_notification(_('Selected component has been updated'));
+               $Mode = 'RESET';
        }
-       elseif (!isset($selected_component) && isset($selected_parent))
+       else
        {
 
                /*Selected component is null cos no item selected on first time round
@@ -145,7 +149,7 @@ function on_submit($selected_parent, $selected_component=null)
                component form */
 
                //need to check not recursive bom component of itself!
-               If (!check_for_recursive_bom($selected_parent, $_POST['component']))
+               if (!check_for_recursive_bom($selected_parent, $_POST['component']))
                {
 
                        /*Now check to see that the component is not already on the bom */
@@ -164,9 +168,8 @@ function on_submit($selected_parent, $selected_component=null)
                                        . input_num('quantity') . ")";
 
                                db_query($sql,"check failed");
-
-                               //$msg = _("A new component part has been added to the bill of material for this item.");
-
+                               display_notification(_("A new component part has been added to the bill of material for this item."));
+                               $Mode = 'RESET';
                        }
                        else
                        {
@@ -184,103 +187,94 @@ function on_submit($selected_parent, $selected_component=null)
 
 //--------------------------------------------------------------------------------------------------
 
-if (isset($_GET['delete']))
+if ($Mode == 'Delete')
 {
-
-       $sql = "DELETE FROM ".TB_PREF."bom WHERE id='" . $_GET['delete']. "'";
+       $sql = "DELETE FROM ".TB_PREF."bom WHERE id='" . $selected_component. "'";
        db_query($sql,"Could not delete this bom components");
 
-       display_note(_("The component item has been deleted from this bom."));
+       display_notification(_("The component item has been deleted from this bom"));
+       $Mode = 'RESET';
+}
 
+if ($Mode == 'RESET')
+{
+       $selected_component = -1;
+       unset($_POST['quantity']);
 }
 
 //--------------------------------------------------------------------------------------------------
 
 start_form(false, true);
-//echo $msg;
 
 echo "<center>" . _("Select a manufacturable item:") . "&nbsp;";
-stock_bom_items_list('stock_id', null, false, true);
-echo "</center>";
+stock_bom_items_list('selected_parent', null, false, true);
+echo "</center><br>";
 
 end_form();
-
-if (isset($_POST['_stock_id_update']))
-       $Ajax->activate('bom');
+if (isset($_POST['_selected_parent_update']))
+       $Ajax->activate('_page_body');
 //--------------------------------------------------------------------------------------------------
 
-if (isset($_POST['stock_id']))
+if (get_post('selected_parent') != '')
 { //Parent Item selected so display bom or edit component
-       $selected_parent = $_POST['stock_id'];
-       if (isset($selected_parent) && isset($_POST['Submit'])) {
-         if(isset($selected_component))
+       $selected_parent = $_POST['selected_parent'];
+       if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM')
                on_submit($selected_parent, $selected_component);
-         else
-               on_submit($selected_parent);
-       }
        //--------------------------------------------------------------------------------------
 
+start_form();
        display_bom_items($selected_parent);
-
-       if (isset($selected_parent) && isset($selected_component))
-       {
-               hyperlink_params($_SERVER['PHP_SELF'], _("Add a new Component"), "NewItem=$selected_parent");
-       }
-
+//end_form();
        //--------------------------------------------------------------------------------------
-
-       start_form(false, true, $_SERVER['PHP_SELF'] . "?" . SID . "NewItem=" . $selected_parent);
+       echo '<br>';
+//     start_form(false, true);
 
        start_table($table_style2);
 
-       if (isset($selected_component))
+       if ($selected_component != -1)
        {
-               //editing a selected component from the link to the line item
-               $sql = "SELECT ".TB_PREF."bom.*,".TB_PREF."stock_master.description FROM ".TB_PREF."bom,".TB_PREF."stock_master
-                       WHERE id='$selected_component'
-                       AND ".TB_PREF."stock_master.stock_id=".TB_PREF."bom.component";
-
-               $result = db_query($sql, "could not get bom");
-               $myrow = db_fetch($result);
-
-               $_POST['loc_code'] = $myrow["loc_code"];
-               $_POST['workcentre_added']  = $myrow["workcentre_added"];
-               $_POST['quantity'] = number_format2($myrow["quantity"], get_qty_dec($myrow["component"]));
-
-               hidden('selected_parent', $selected_parent);
-               hidden('selected_component', $selected_component);
+               if ($Mode == 'Edit') {
+                       //editing a selected component from the link to the line item
+                       $sql = "SELECT ".TB_PREF."bom.*,".TB_PREF."stock_master.description FROM ".TB_PREF."bom,".TB_PREF."stock_master
+                               WHERE id='$selected_component'
+                               AND ".TB_PREF."stock_master.stock_id=".TB_PREF."bom.component";
+
+                       $result = db_query($sql, "could not get bom");
+                       $myrow = db_fetch($result);
+
+                       $_POST['loc_code'] = $myrow["loc_code"];
+                       $_POST['workcentre_added']  = $myrow["workcentre_added"];
+                       $_POST['quantity'] = number_format2($myrow["quantity"], get_qty_dec($myrow["component"]));
+               }
+               hidden('component', $selected_component);
                label_row(_("Component:"), $myrow["component"] . " - " . $myrow["description"]);
-
        }
        else
-       { //end of if $selected_component
-
-               hidden('selected_parent', $selected_parent);
-
+       {
                start_row();
                label_cell(_("Component:"));
 
                echo "<td>";
                stock_component_items_list('component', $selected_parent, null, false, true);
+               if (get_post('_component_update')) 
+               {
+                       $Ajax->activate('quantity');
+               }
                echo "</td>";
                end_row();
        }
+       hidden('selected_parent', $selected_parent);
 
        locations_list_row(_("Location to Draw From:"), 'loc_code', null);
        workcenter_list_row(_("Work Centre Added:"), 'workcentre_added', null);
-       $dec = get_qty_dec($_POST['component']);
-       if (!isset($_POST['quantity']))
-       {
-               $_POST['quantity'] = number_format2(1, $dec);
-       }
-       qty_row(_("Quantity:"), 'quantity', $_POST['quantity'], null, null, $dec);
+       $dec = get_qty_dec(get_post('component'));
+       $_POST['quantity'] = number_format2(input_num('quantity',1), $dec);
+       qty_row(_("Quantity:"), 'quantity', null, null, null, $dec);
 
        end_table(1);
-       submit_center('Submit', _("Add/Update"));
-
+       submit_add_or_update_center($selected_component == -1, '', true);
        end_form();
 }
-
 // ----------------------------------------------------------------------------------
 
 end_page();
index 32ba8e8c52e67610131e1395d2d841ef54037136..e6a18026d9e4907a6a2ac0cbe25f7262a325038f 100644 (file)
@@ -395,12 +395,11 @@ textarea_row(_("Memo:"), 'memo_', null, 40, 5);
 
 end_table(1);
 
-submit_add_or_update_center(!isset($selected_id), '', true);
-
 if (isset($selected_id))
 {
-       echo "<br><br><table align=center><tr>";
+       echo "<table align=center><tr>";
 
+       submit_cells('UPDATE_ITEM', _("Update"), '', _('Save changes to work order'), true);
        if (isset($_POST['released']))
        {
                submit_cells('close', _("Close This Work Order"),'','',true);
@@ -409,6 +408,10 @@ if (isset($selected_id))
 
        echo "</tr></table>";
 }
+else
+{
+       submit_center('ADD_ITEM', _("Add Workorder"), true, '', true);
+}
 
 end_form();
 end_page();
index 1478e63b94419aacd7289b1352d618cd1fb4c5c1..b3f86cfc2e5f9edf406f6b300e19bbbf02217b4d 100644 (file)
@@ -20,28 +20,24 @@ check_db_has_shippers(_("There are no shipping companies defined in the system.
 
 check_db_has_tax_groups(_("There are no tax groups defined in the system. At least one tax group is required before proceeding."));
 
+simple_page_mode(true);
 //-----------------------------------------------------------------------------------------------
 
 if (isset($_GET['debtor_no']))
 {
        $_POST['customer_id'] = strtoupper($_GET['debtor_no']);
-       $_POST['New'] = "1";
 }
+$_POST['branch_code'] = $selected_id;
 
 if (isset($_GET['SelectedBranch']))
 {
        $_POST['branch_code'] = strtoupper($_GET['SelectedBranch']);
-       unset($_POST['New']);
-}
-
-if (!isset($_GET['SelectedBranch']) && !isset($_POST['AddUpdate']))
-{
-       $_POST['New'] = "1";
+       $selected_id = $_GET['SelectedBranch'];
 }
 
 //-----------------------------------------------------------------------------------------------
 
-if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM']))
+if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') 
 {
 
        //initialise no input errors assumed initially before we test
@@ -58,8 +54,7 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM']))
        if ($input_error != 1)
        {
 
-               //if (!isset($_POST['New']))
-               if (isset($_POST['UPDATE_ITEM']))
+       if ($selected_id != -1) 
                {
                        /*SelectedBranch could also exist if submit had not been clicked this code would not run in this case cos submit is false of course see the     delete code below*/
 
@@ -83,6 +78,7 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM']))
                WHERE branch_code =".db_escape($_POST['branch_code']) . "
                AND debtor_no=".db_escape($_POST['customer_id']);
 
+                       $note =_('Selected customer branch has been updated');
                }
                else
                {
@@ -104,16 +100,18 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM']))
                                        .db_escape($_POST['br_post_address']) . ","
                                        .db_escape($_POST['disable_trans']) . ", "
                                        .db_escape($_POST['default_ship_via']) . ")";
+
+                       $note = _('New customer branch has been added');
                }
 
                //run the sql from either of the above possibilites
                db_query($sql,"The branch record could not be inserted or updated");
-
-               meta_forward($_SERVER['PHP_SELF'], "debtor_no=" . $_POST['customer_id']);
+               display_notification($note);
+               $Mode = 'RESET';
        }
 
 }
-elseif (isset($_GET['delete']))
+elseif ($Mode == 'Delete')
 {
        //the link to delete a selected record was clicked instead of the submit button
 
@@ -141,11 +139,20 @@ elseif (isset($_GET['delete']))
                {
                        $sql="DELETE FROM ".TB_PREF."cust_branch WHERE branch_code='" . $_POST['branch_code']. "' AND debtor_no='" . $_POST['customer_id']. "'";
                        db_query($sql,"could not delete branch");
-                       meta_forward($_SERVER['PHP_SELF'], "debtor_no=" . $_POST['customer_id']);
+                       display_notification(_('Selected customer branch has been deleted'));
+                       $Mode = 'RESET';
                }
        } //end ifs to test if the branch can be deleted
 }
 
+if ($Mode == 'RESET' || get_post('_customer_id_update'))
+{
+       $selected_id = -1;
+       $cust_id = $_POST['customer_id'];
+       unset($_POST);
+       $_POST['customer_id'] = $cust_id;
+       $Ajax->activate('_page_body');
+}
 start_form();
 
 echo "<center>" . _("Select a customer: ") . "&nbsp;&nbsp;";
@@ -153,6 +160,7 @@ customer_list('customer_id', null, false, true);
 echo "</center><br><br>";
 
 $num_branches = db_customer_has_branches($_POST['customer_id']);
+
 if ($num_branches)
 {
        $sql = "SELECT ".TB_PREF."debtors_master.name, ".TB_PREF."cust_branch.*, ".TB_PREF."salesman.salesman_name,
@@ -183,8 +191,8 @@ if ($num_branches)
                label_cell($myrow["fax"]);
                label_cell("<a href=mailto:" . $myrow["email"]. ">" . $myrow["email"]. "</a>");
                label_cell($myrow["tax_group_name"]);
-               edit_link_cell("debtor_no=" . $_POST['customer_id']. "&SelectedBranch=" . $myrow["branch_code"]);
-               delete_link_cell("debtor_no=" . $_POST['customer_id']. "&SelectedBranch=" . $myrow["branch_code"]. "&delete=yes");
+               edit_button_cell("Edit".$myrow["branch_code"], _("Edit"));
+               edit_button_cell("Delete".$myrow["branch_code"], _("Delete"));
                end_row();
        }
        end_table();
@@ -192,15 +200,7 @@ if ($num_branches)
 }
 else
        display_note(_("The selected customer does not have any branches. Please create at least one branch."));
-//else
-//{
-//}
-
 
-if (!isset($_POST['New']))
-{
-       hyperlink_params($_SERVER['PHP_SELF'], _("New Customer Branch"), "debtor_no=" . $_POST['customer_id']);
-}
 echo "<br>";
 start_table("$table_style2 width=60%", 5);
 echo "<tr valign=top><td>"; // outer table
@@ -208,49 +208,50 @@ echo "<tr valign=top><td>"; // outer table
 echo "<table>";
 
 
-if (!isset($_POST['New']) && $num_branches)
+if ($selected_id != -1)
 {
-
-       //editing an existing branch
-    $sql = "SELECT * FROM ".TB_PREF."cust_branch
-               WHERE branch_code='" . $_POST['branch_code'] . "'
-               AND debtor_no='" . $_POST['customer_id'] . "'";
-
-       $result = db_query($sql,"check failed");
-    $myrow = db_fetch($result);
-
-    $_POST['branch_code'] = $myrow["branch_code"];
-    $_POST['br_name']  = $myrow["br_name"];
-    $_POST['br_address']  = $myrow["br_address"];
-    $_POST['br_post_address']  = $myrow["br_post_address"];
-    $_POST['contact_name'] = $myrow["contact_name"];
-    $_POST['salesman'] =$myrow["salesman"];
-    $_POST['area'] =$myrow["area"];
-    $_POST['phone'] =$myrow["phone"];
-    $_POST['fax'] =$myrow["fax"];
-    $_POST['email'] =$myrow["email"];
-    $_POST['tax_group_id'] = $myrow["tax_group_id"];
-    $_POST['disable_trans'] = $myrow['disable_trans'];
-    $_POST['default_location'] = $myrow["default_location"];
-    $_POST['default_ship_via'] = $myrow['default_ship_via'];
-    $_POST['sales_account'] = $myrow["sales_account"];
-    $_POST['sales_discount_account'] = $myrow['sales_discount_account'];
-    $_POST['receivables_account'] = $myrow['receivables_account'];
-    $_POST['payment_discount_account'] = $myrow['payment_discount_account'];
-
+       if ($Mode == 'Edit') {
+
+               //editing an existing branch
+       $sql = "SELECT * FROM ".TB_PREF."cust_branch
+                       WHERE branch_code='" . $_POST['branch_code'] . "'
+                       AND debtor_no='" . $_POST['customer_id'] . "'";
+               $result = db_query($sql,"check failed");
+           $myrow = db_fetch($result);
+               set_focus('br_name');
+       $_POST['branch_code'] = $myrow["branch_code"];
+           $_POST['br_name']  = $myrow["br_name"];
+           $_POST['br_address']  = $myrow["br_address"];
+           $_POST['br_post_address']  = $myrow["br_post_address"];
+           $_POST['contact_name'] = $myrow["contact_name"];
+           $_POST['salesman'] =$myrow["salesman"];
+           $_POST['area'] =$myrow["area"];
+           $_POST['phone'] =$myrow["phone"];
+           $_POST['fax'] =$myrow["fax"];
+           $_POST['email'] =$myrow["email"];
+           $_POST['tax_group_id'] = $myrow["tax_group_id"];
+           $_POST['disable_trans'] = $myrow['disable_trans'];
+           $_POST['default_location'] = $myrow["default_location"];
+           $_POST['default_ship_via'] = $myrow['default_ship_via'];
+           $_POST['sales_account'] = $myrow["sales_account"];
+           $_POST['sales_discount_account'] = $myrow['sales_discount_account'];
+           $_POST['receivables_account'] = $myrow['receivables_account'];
+           $_POST['payment_discount_account'] = $myrow['payment_discount_account'];
+       }
 }
-else
+elseif ($Mode != 'ADD_ITEM')
 { //end of if $SelectedBranch only do the else when a new record is being entered
-
-       $sql = "SELECT name, address, email
-               FROM ".TB_PREF."debtors_master WHERE debtor_no = '" . $_POST['customer_id']. "'";
-       $result = db_query($sql,"check failed");
-       $myrow = db_fetch($result);
-       $_POST['br_name'] = $myrow["name"];
-       $_POST['contact_name'] = _("Main Branch");
-       $_POST['br_address'] = $_POST['br_post_address'] = $myrow["address"];
+       if(!$num_branches) {
+               $sql = "SELECT name, address, email
+                       FROM ".TB_PREF."debtors_master WHERE debtor_no = '" . $_POST['customer_id']. "'";
+               $result = db_query($sql,"check failed");
+               $myrow = db_fetch($result);
+               $_POST['br_name'] = $myrow["name"];
+               $_POST['contact_name'] = _('Main Branch');
+               $_POST['br_address'] = $_POST['br_post_address'] = $myrow["address"];
+               $_POST['email'] = $myrow['email'];
+       }
        $_POST['branch_code'] = "";
-       $_POST['email'] = $myrow['email'];
        if (!isset($_POST['sales_account']) || !isset($_POST['sales_discount_account']))
        {
                $company_record = get_company_prefs();
@@ -262,19 +263,19 @@ else
 
        }
 
-       hidden('New', 'Yes');
 }
-hidden('branch_code', $_POST['branch_code']);
+hidden('selected_id', $selected_id);
+hidden('branch_code');
 
 table_section_title(_("Name and Contact"));
 
-text_row(_("Branch Name:"), 'br_name', $_POST['br_name'], 35, 40);
-text_row(_("Contact Person:"), 'contact_name', $_POST['contact_name'], 35, 40);
+text_row(_("Branch Name:"), 'br_name', null, 35, 40);
+text_row(_("Contact Person:"), 'contact_name', null, 35, 40);
 
 text_row(_("Phone Number:"), 'phone', null, 20, 20);
 text_row(_("Fax Number:"), 'fax', null, 20, 20);
 
-text_row("<a href='Mailto:'>" . _("E-mail:") . "</a>", 'email', $_POST['email'], 35, 55);
+text_row("<a href='Mailto:'>" . _("E-mail:") . "</a>", 'email', null, 35, 55);
 
 table_section_title(_("Sales"));
 
@@ -299,26 +300,25 @@ echo"<table>";
 table_section_title(_("GL Accounts"));
 
 // 2006-06-14. Changed gl_al_accounts_list to have an optional all_option 'Use Item Sales Accounts'
-gl_all_accounts_list_row(_("Sales Account:"), 'sales_account', $_POST['sales_account'], false,
-       false, false, true);
+gl_all_accounts_list_row(_("Sales Account:"), 'sales_account', null, false,    false, false, true);
 
-gl_all_accounts_list_row(_("Sales Discount Account:"), 'sales_discount_account', $_POST['sales_discount_account']);
+gl_all_accounts_list_row(_("Sales Discount Account:"), 'sales_discount_account');
 
-gl_all_accounts_list_row(_("Accounts Receivable Account:"), 'receivables_account', $_POST['receivables_account']);
+gl_all_accounts_list_row(_("Accounts Receivable Account:"), 'receivables_account');
 
-gl_all_accounts_list_row(_("Prompt Payment Discount Account:"), 'payment_discount_account', $_POST['payment_discount_account']);
+gl_all_accounts_list_row(_("Prompt Payment Discount Account:"), 'payment_discount_account');
 
 table_section_title(_("Addresses"));
 
-textarea_row(_("Mailing Address:"), 'br_post_address',$_POST['br_post_address'], 35, 5);
+textarea_row(_("Mailing Address:"), 'br_post_address', null, 35, 5);
 
-textarea_row(_("Billing Address:"), 'br_address', $_POST['br_address'], 35, 5);
+textarea_row(_("Billing Address:"), 'br_address', null, 35, 5);
 
 end_table();
 
 end_table(1); // outer table
 
-submit_add_or_update_center(isset($_POST['New']));
+submit_add_or_update_center($selected_id == -1, '', true);
 
 end_form();