From 032543e8bebfaf5ed19f8a8bad793893af497862 Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Mon, 15 Dec 2008 19:28:25 +0000 Subject: [PATCH] Code cleanup. --- purchasing/view/view_po.php | 5 ----- sales/includes/cart_class.inc | 3 ++- sales/includes/sales_ui.inc | 14 ++++++++++++++ sales/includes/ui/sales_credit_ui.inc | 8 ++++---- sales/includes/ui/sales_order_ui.inc | 4 ++-- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/purchasing/view/view_po.php b/purchasing/view/view_po.php index 144192df..c572cf59 100644 --- a/purchasing/view/view_po.php +++ b/purchasing/view/view_po.php @@ -21,11 +21,6 @@ if (!isset($_GET['trans_no'])) display_heading(_("Purchase Order") . " #" . $_GET['trans_no']); -if (isset($_SESSION['Items'])) -{ - unset ($_SESSION['Items']); -} - $purchase_order = new purch_order; read_po($_GET['trans_no'], $purchase_order); diff --git a/sales/includes/cart_class.inc b/sales/includes/cart_class.inc index 96faeb1c..eafcd102 100644 --- a/sales/includes/cart_class.inc +++ b/sales/includes/cart_class.inc @@ -17,7 +17,7 @@ class cart var $trans_type; // invoice, order, delivery note ... var $trans_no = array();// array (num1=>ver1,..) or 0 for new var $so_type = 0; // for sales order: simple=0 template=1 - + var $cart_id; // used to detect multi-tab edition conflits var $line_items; //array of objects of class line_details var $src_docs = array(); // array of arrays(num1=>ver1,...) or 0 for no src @@ -77,6 +77,7 @@ class cart $this->dimension_id = 0; $this->dimension2_id = 0; $this->read($type, $trans_no, $view ); + $this->cart_id = uniqid(''); } //------------------------------------------------------------------------- diff --git a/sales/includes/sales_ui.inc b/sales/includes/sales_ui.inc index 64045bb1..56e4746e 100644 --- a/sales/includes/sales_ui.inc +++ b/sales/includes/sales_ui.inc @@ -27,5 +27,19 @@ function processing_active() { return (isset($_SESSION['Processing']) && $_SESSION['Processing']==$_SERVER['PHP_SELF']); } +/* + Check if the cart was not destroyed during opening the edition page in + another browser tab. +*/ +function check_edit_conflicts($cartname='Items') +{ + global $Ajax; + + if (isset($_POST['cart_id']) && $_POST['cart_id'] != $_SESSION[$cartname]->cart_id) { + display_error(_('This edit session has been abandoned by opening sales document in another browser tab. You cannot edit more than one sales document at once.')); + $Ajax->activate('_page_body'); + display_footer_exit(); + } +} ?> \ No newline at end of file diff --git a/sales/includes/ui/sales_credit_ui.inc b/sales/includes/ui/sales_credit_ui.inc index 303a7e0f..24f3beb4 100644 --- a/sales/includes/ui/sales_credit_ui.inc +++ b/sales/includes/ui/sales_credit_ui.inc @@ -81,7 +81,7 @@ function display_credit_header(&$order) if (!isset($_POST['ref'])) $_POST['ref'] = references::get_next(11); - if ($_SESSION['Items']->trans_no==0) + if ($order->trans_no==0) ref_row(_("Reference").':', 'ref'); else label_row(_("Reference").':', $_POST['ref'] ); @@ -225,7 +225,7 @@ function display_credit_items($title, &$order) $taxes = $order->get_taxes($_POST['ChargeFreightCost']); - $tax_total = display_edit_tax_items($taxes, 6, $_SESSION['Items']->tax_included); + $tax_total = display_edit_tax_items($taxes, 6, $order->tax_included); $display_total = price_format(($subtotal + $_POST['ChargeFreightCost'] + $tax_total)); @@ -305,7 +305,7 @@ function credit_edit_item_controls(&$order, $rowcounter, $line_no=-1) //--------------------------------------------------------------------------------- -function credit_options_controls() +function credit_options_controls($credit) { global $table_style2, $Ajax; echo "
"; @@ -323,7 +323,7 @@ if (isset($_POST['_CreditType_update'])) /*if the credit note is a return of goods then need to know which location to receive them into */ if (!isset($_POST['Location'])) - $_POST['Location'] = $_SESSION['Items']->Location; + $_POST['Location'] = $credit->Location; locations_list_row(_("Items Returned to Location"), 'Location', $_POST['Location']); } else diff --git a/sales/includes/ui/sales_order_ui.inc b/sales/includes/ui/sales_order_ui.inc index a1122708..ab81e5f4 100644 --- a/sales/includes/ui/sales_order_ui.inc +++ b/sales/includes/ui/sales_order_ui.inc @@ -307,7 +307,7 @@ function display_order_header(&$order, $editable, $date_text, $display_tax_group } // changed branch } - if ($_SESSION['Items']->trans_type!=30) { + if ($order->trans_type != 30) { ref_cells(_("Reference").':', 'ref', _('Reference number unique for this document type'), null, ''); } @@ -403,7 +403,7 @@ function display_order_header(&$order, $editable, $date_text, $display_tax_group if ($display_tax_group) { label_row(_("Tax Group:"), $order->tax_group_name); - hidden('tax_group_id', $_SESSION['Items']->tax_group_id); + hidden('tax_group_id', $order->tax_group_id); } end_outer_table(1); // outer table -- 2.30.2