From b119b85ae454cf0cab51dce950d24b85ae37f54a Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Mon, 15 Dec 2008 19:30:21 +0000 Subject: [PATCH] [0000085] Fixed session conflicts during document edition in multiply browser tabs. --- sales/credit_note_entry.php | 46 +++++++++++++++++-------------- sales/customer_credit_invoice.php | 6 +++- sales/customer_delivery.php | 17 ++++++++---- sales/customer_invoice.php | 6 +++- sales/sales_order_entry.php | 5 +++- sales/view/view_sales_order.php | 36 ++++++++++++------------ 6 files changed, 69 insertions(+), 47 deletions(-) diff --git a/sales/credit_note_entry.php b/sales/credit_note_entry.php index e64bc8cd..cab8c3dc 100644 --- a/sales/credit_note_entry.php +++ b/sales/credit_note_entry.php @@ -69,7 +69,9 @@ if (isset($_GET['AddedID'])) { hyperlink_params($_SERVER['PHP_SELF'], _("Enter Another &Credit Note"), "NewCredit=yes"); display_footer_exit(); -} +} else + check_edit_conflicts(); + //-------------------------------------------------------------------------------- function line_start_focus() { @@ -82,30 +84,33 @@ function line_start_focus() { function copy_to_cn() { - $_SESSION['Items']->Comments = $_POST['CreditText']; - $_SESSION['Items']->document_date = $_POST['OrderDate']; - $_SESSION['Items']->freight_cost = input_num('ChargeFreightCost'); - $_SESSION['Items']->Location = $_POST["Location"]; - $_SESSION['Items']->sales_type = $_POST['sales_type_id']; - $_SESSION['Items']->reference = $_POST['ref']; - $_SESSION['Items']->ship_via = $_POST['ShipperID']; - $_SESSION['Items']->dimension_id = $_POST['dimension_id']; - $_SESSION['Items']->dimension2_id = $_POST['dimension2_id']; + $cart = &$_SESSION['Items']; + $cart->Comments = $_POST['CreditText']; + $cart->document_date = $_POST['OrderDate']; + $cart->freight_cost = input_num('ChargeFreightCost'); + $cart->Location = $_POST["Location"]; + $cart->sales_type = $_POST['sales_type_id']; + $cart->reference = $_POST['ref']; + $cart->ship_via = $_POST['ShipperID']; + $cart->dimension_id = $_POST['dimension_id']; + $cart->dimension2_id = $_POST['dimension2_id']; } //----------------------------------------------------------------------------- function copy_from_cn() { - $_POST['CreditText'] = $_SESSION['Items']->Comments; - $_POST['OrderDate'] = $_SESSION['Items']->document_date; - $_POST['ChargeFreightCost'] = price_format($_SESSION['Items']->freight_cost); - $_POST['Location'] = $_SESSION['Items']->Location; - $_POST['sales_type_id'] = $_SESSION['Items']->sales_type; - $_POST['ref'] = $_SESSION['Items']->reference; - $_POST['ShipperID'] = $_SESSION['Items']->ship_via; - $_POST['dimension_id'] = $_SESSION['Items']->dimension_id; - $_POST['dimension2_id'] = $_SESSION['Items']->dimension2_id; + $cart = &$_SESSION['Items']; + $_POST['CreditText'] = $cart->Comments; + $_POST['OrderDate'] = $cart->document_date; + $_POST['ChargeFreightCost'] = price_format($cart->freight_cost); + $_POST['Location'] = $cart->Location; + $_POST['sales_type_id'] = $cart->sales_type; + $_POST['ref'] = $cart->reference; + $_POST['ShipperID'] = $cart->ship_via; + $_POST['dimension_id'] = $cart->dimension_id; + $_POST['dimension2_id'] = $cart->dimension2_id; + $_POST['cart_id'] = $cart->cart_id; } //----------------------------------------------------------------------------- @@ -245,6 +250,7 @@ if (!processing_active()) { //----------------------------------------------------------------------------- start_form(false, true); +hidden('cart_id'); $customer_error = display_credit_header($_SESSION['Items']); @@ -252,7 +258,7 @@ if ($customer_error == "") { start_table("$table_style width=80%", 10); echo ""; display_credit_items(_("Credit Note Items"), $_SESSION['Items']); - credit_options_controls(); + credit_options_controls($_SESSION['Items']); echo ""; end_table(); } else { diff --git a/sales/customer_credit_invoice.php b/sales/customer_credit_invoice.php index e46d3528..9796bbd7 100644 --- a/sales/customer_credit_invoice.php +++ b/sales/customer_credit_invoice.php @@ -63,7 +63,9 @@ if (isset($_GET['AddedID'])) { display_note(get_gl_view_str($trans_type, $credit_no, _("View the GL &Journal Entries for this Credit Note")),1); display_footer_exit(); -} +} else + check_edit_conflicts(); + //----------------------------------------------------------------------------- @@ -180,6 +182,7 @@ function copy_from_cart() $_POST['CreditDate']= $cart->document_date; $_POST['Location']= $cart->Location; $_POST['CreditText']= $cart->Comments; + $_POST['cart_id'] = $cart->cart_id; } //----------------------------------------------------------------------------- @@ -214,6 +217,7 @@ function display_credit_items() global $table_style, $table_style2; start_form(false, true); + hidden('cart_id'); start_table("$table_style2 width=80%", 5); echo ""; // outer table diff --git a/sales/customer_delivery.php b/sales/customer_delivery.php index 3c275dbb..f289be39 100644 --- a/sales/customer_delivery.php +++ b/sales/customer_delivery.php @@ -114,14 +114,17 @@ if (isset($_GET['OrderNumber']) && $_GET['OrderNumber'] > 0) { end_page(); exit; -} elseif (!check_quantities()) { - display_error(_("Selected quantity cannot be less than quantity invoiced nor more than quantity - not dispatched on sales order.")); +} else { + check_edit_conflicts(); -} elseif(!check_num('ChargeFreightCost', 0)) - display_error(_("Freight cost cannot be less than zero")); - set_focus('ChargeFreightCost'); + if (!check_quantities()) { + display_error(_("Selected quantity cannot be less than quantity invoiced nor more than quantity + not dispatched on sales order.")); + } elseif(!check_num('ChargeFreightCost', 0)) + display_error(_("Freight cost cannot be less than zero")); + set_focus('ChargeFreightCost'); +} //----------------------------------------------------------------------------- @@ -206,6 +209,7 @@ function copy_from_cart() $_POST['due_date'] = $cart->due_date; $_POST['Location'] = $cart->Location; $_POST['Comments'] = $cart->Comments; + $_POST['cart_id'] = $cart->cart_id; } //------------------------------------------------------------------------------ @@ -294,6 +298,7 @@ if (isset($_POST['Update']) || isset($_POST['_Location_update'])) { } //------------------------------------------------------------------------------ start_form(false, true); +hidden('cart_id'); start_table("$table_style2 width=80%", 5); echo ""; // outer table diff --git a/sales/customer_invoice.php b/sales/customer_invoice.php index af67283b..fed8094e 100644 --- a/sales/customer_invoice.php +++ b/sales/customer_invoice.php @@ -35,6 +35,7 @@ if (isset($_GET['ModifyInvoice'])) { page($_SESSION['page_title'], false, false, "", $js); //----------------------------------------------------------------------------- +check_edit_conflicts(); if (isset($_GET['AddedID'])) { @@ -86,7 +87,7 @@ if (isset($_GET['AddedID'])) { //----------------------------------------------------------------------------- if ( (isset($_GET['DeliveryNumber']) && ($_GET['DeliveryNumber'] > 0) ) - || isset($_GET['BatchInvoice'])) { +|| isset($_GET['BatchInvoice'])) { processing_start(); @@ -149,6 +150,7 @@ if (isset($_POST['_InvoiceDate_changed'])) { $_POST['InvoiceDate']); $Ajax->activate('due_date'); } + //----------------------------------------------------------------------------- function check_quantities() { @@ -219,6 +221,7 @@ function copy_from_cart() $_POST['InvoiceDate']= $cart->document_date; $_POST['due_date'] = $cart->due_date; $_POST['Comments']= $cart->Comments; + $_POST['cart_id'] = $cart->cart_id; } //----------------------------------------------------------------------------- @@ -322,6 +325,7 @@ $is_batch_invoice = count($_SESSION['Items']->src_docs) > 1; $is_edition = $_SESSION['Items']->trans_type == 10 && $_SESSION['Items']->trans_no != 0; start_form(false, true); +hidden('cart_id'); start_table("$table_style2 width=80%", 5); diff --git a/sales/sales_order_entry.php b/sales/sales_order_entry.php index 3ad5b199..3f1b20db 100644 --- a/sales/sales_order_entry.php +++ b/sales/sales_order_entry.php @@ -139,7 +139,8 @@ if (isset($_GET['AddedID'])) { hyperlink_params($_SERVER['PHP_SELF'], _("Enter a &New Direct Invoice"), "NewInvoice=0"); display_footer_exit(); -} +} else + check_edit_conflicts(); //----------------------------------------------------------------------------- @@ -217,6 +218,7 @@ function copy_from_cart() $_POST['dimension_id'] = $cart->dimension_id; $_POST['dimension2_id'] = $cart->dimension2_id; } + $_POST['cart_id'] = $cart->cart_id; } //-------------------------------------------------------------------------------- @@ -506,6 +508,7 @@ if ($_SESSION['Items']->trans_type == 10) { $corder = _("Commit Order Changes"); } start_form(false, true); +hidden('cart_id'); $customer_error = display_order_header($_SESSION['Items'], ($_SESSION['Items']->any_already_delivered() == 0), $idate); diff --git a/sales/view/view_sales_order.php b/sales/view/view_sales_order.php index 782c951d..dc068f70 100644 --- a/sales/view/view_sales_order.php +++ b/sales/view/view_sales_order.php @@ -18,12 +18,12 @@ page(_("View Sales Order"), true, false, "", $js); display_heading(sprintf(_("Sales Order #%d"),$_GET['trans_no'])); -if (isset($_SESSION['Items'])) +if (isset($_SESSION['View'])) { - unset ($_SESSION['Items']); + unset ($_SESSION['View']); } -$_SESSION['Items'] = new Cart(30, $_GET['trans_no'], true); +$_SESSION['View'] = new Cart(30, $_GET['trans_no'], true); start_table("$table_style2 width=95%", 5); echo ""; @@ -37,27 +37,27 @@ echo ""; echo ""; start_table("$table_style width=95%"); -label_row(_("Customer Name"), $_SESSION['Items']->customer_name, "class='tableheader2'", +label_row(_("Customer Name"), $_SESSION['View']->customer_name, "class='tableheader2'", "colspan=3"); start_row(); -label_cells(_("Customer Order Ref."), $_SESSION['Items']->cust_ref, "class='tableheader2'"); -label_cells(_("Deliver To Branch"), $_SESSION['Items']->deliver_to, "class='tableheader2'"); +label_cells(_("Customer Order Ref."), $_SESSION['View']->cust_ref, "class='tableheader2'"); +label_cells(_("Deliver To Branch"), $_SESSION['View']->deliver_to, "class='tableheader2'"); end_row(); start_row(); -label_cells(_("Ordered On"), $_SESSION['Items']->document_date, "class='tableheader2'"); -label_cells(_("Requested Delivery"), $_SESSION['Items']->due_date, "class='tableheader2'"); +label_cells(_("Ordered On"), $_SESSION['View']->document_date, "class='tableheader2'"); +label_cells(_("Requested Delivery"), $_SESSION['View']->due_date, "class='tableheader2'"); end_row(); start_row(); -label_cells(_("Order Currency"), $_SESSION['Items']->customer_currency, "class='tableheader2'"); -label_cells(_("Deliver From Location"), $_SESSION['Items']->location_name, "class='tableheader2'"); +label_cells(_("Order Currency"), $_SESSION['View']->customer_currency, "class='tableheader2'"); +label_cells(_("Deliver From Location"), $_SESSION['View']->location_name, "class='tableheader2'"); end_row(); -label_row(_("Delivery Address"), nl2br($_SESSION['Items']->delivery_address), +label_row(_("Delivery Address"), nl2br($_SESSION['View']->delivery_address), "class='tableheader2'", "colspan=3"); -label_row(_("Telephone"), $_SESSION['Items']->phone, "class='tableheader2'", "colspan=3"); -label_row(_("E-mail"), "email . "'>" . $_SESSION['Items']->email . "", +label_row(_("Telephone"), $_SESSION['View']->phone, "class='tableheader2'", "colspan=3"); +label_row(_("E-mail"), "email . "'>" . $_SESSION['View']->email . "", "class='tableheader2'", "colspan=3"); -label_row(_("Comments"), $_SESSION['Items']->Comments, "class='tableheader2'", "colspan=3"); +label_row(_("Comments"), $_SESSION['View']->Comments, "class='tableheader2'", "colspan=3"); end_table(); echo ""; @@ -175,7 +175,7 @@ table_header($th); $k = 0; //row colour counter -foreach ($_SESSION['Items']->line_items as $stock_item) { +foreach ($_SESSION['View']->line_items as $stock_item) { $line_total = round2($stock_item->quantity * $stock_item->price * (1 - $stock_item->discount_percent), user_price_dec()); @@ -195,11 +195,11 @@ foreach ($_SESSION['Items']->line_items as $stock_item) { end_row(); } -$items_total = $_SESSION['Items']->get_items_total(); +$items_total = $_SESSION['View']->get_items_total(); -$display_total = price_format($items_total + $_SESSION['Items']->freight_cost); +$display_total = price_format($items_total + $_SESSION['View']->freight_cost); -label_row(_("Shipping"), price_format($_SESSION['Items']->freight_cost), +label_row(_("Shipping"), price_format($_SESSION['View']->freight_cost), "align=right colspan=6", "nowrap align=right"); label_row(_("Total Order Value"), $display_total, "align=right colspan=6", "nowrap align=right"); -- 2.30.2