[0000085] Fixed session conflicts during document edition in multiply browser tabs.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Mon, 15 Dec 2008 19:30:21 +0000 (19:30 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Mon, 15 Dec 2008 19:30:21 +0000 (19:30 +0000)
sales/credit_note_entry.php
sales/customer_credit_invoice.php
sales/customer_delivery.php
sales/customer_invoice.php
sales/sales_order_entry.php
sales/view/view_sales_order.php

index e64bc8cd1b2e70d73a139f08149695d9d403ba7b..cab8c3dc810a6a7edbf64284187fdf9878c76bcd 100644 (file)
@@ -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 "<tr><td>";
        display_credit_items(_("Credit Note Items"), $_SESSION['Items']);
-       credit_options_controls();
+       credit_options_controls($_SESSION['Items']);
        echo "</td></tr>";
        end_table();
 } else {
index e46d352814dfa22f3ae3970b1f034ed73ca569c2..9796bbd73eb190ed5def865d4581e017a0048adb 100644 (file)
@@ -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 "<tr><td>"; // outer table
index 3c275dbbf9aeeab2ce0148491699d1633209fea0..f289be39f3326093eafb48e2c06afbfa8fa58824 100644 (file)
@@ -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 "<tr><td>"; // outer table
index af67283bfcf9eb03a60046a02538d2fc11c51a92..fed8094e05337bdd8035ac7f50f1ab9964569b31 100644 (file)
@@ -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);
 
index 3ad5b1991efd2e31145491083d065e279f071c68..3f1b20dba1ce3732f53918e68411bd0d9550fc84 100644 (file)
@@ -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);
index 782c951d6db165f13f16971521ea81c25b176172..dc068f70204e4cfa44b100d6909b5afaff21d5f3 100644 (file)
@@ -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 "<tr valign=top><td>";
@@ -37,27 +37,27 @@ echo "</td></tr>";
 echo "<tr valign=top><td>";
 
 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"), "<a href='mailto:" . $_SESSION['Items']->email . "'>" . $_SESSION['Items']->email . "</a>",
+label_row(_("Telephone"), $_SESSION['View']->phone, "class='tableheader2'", "colspan=3");
+label_row(_("E-mail"), "<a href='mailto:" . $_SESSION['View']->email . "'>" . $_SESSION['View']->email . "</a>",
        "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 "</td><td valign='top'>";
@@ -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");