Added ajax and some smaller fixes in sales module files
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Wed, 18 Jun 2008 15:09:55 +0000 (15:09 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Wed, 18 Jun 2008 15:09:55 +0000 (15:09 +0000)
14 files changed:
CHANGELOG.txt
includes/ajax.inc
includes/ui/ui_controls.inc
includes/ui/ui_input.inc
includes/ui/ui_lists.inc
js/inserts.js
js/utils.js
sales/credit_note_entry.php
sales/customer_payments.php
sales/includes/ui/sales_credit_ui.inc
sales/includes/ui/sales_order_ui.inc
sales/inquiry/customer_allocation_inquiry.php
sales/inquiry/customer_inquiry.php
sales/sales_order_entry.php

index ea6154de02e993dc74844741f83fc7c72a53c31c..0e88b44058594234ad132e9ee9a4b1ac2288c20b 100644 (file)
@@ -19,6 +19,26 @@ Legend:
 ! -> Note
 $ -> Affected files
 
+18-Jun-2008 Janusz Dobrowolski
++ Added ajax improvements
+$ /sales/credit_note_entry.php
+  /sales/customer_payments.php
+  /sales/sales_order_entry.php
+  /sales/includes/ui/sales_credit_ui.inc
+  /sales/includes/ui/sales_order_ui.inc
+  /sales/inquiry/customer_allocation_inquiry.php
+  /sales/inquiry/customer_inquiry.php
++ Added optional trigger parameter to div_start()
+$ /includes/ui/ui_controls.inc
++ Added dec attribute ajax update for amount fields 
+$ /includes/ui/ui_input.inc
++ Ajaxified stock item types and credit types lists
+$ /includes/ui/ui_lists.inc
+# Fixed onblur for amount fields, extended onchange event handling for selects
+$ /js/inserts.js
+# Fixed addAssign() js handler for nonstandard attributes
+$ /js/utils.js
+
 17-Jun-2008 Joe Hunt
 ! More files with Quantity routines needed fix due to php4 related issue.
 $ /includes/current_user.inc
@@ -95,7 +115,7 @@ $ /sales/inquiry/sales_deliveries_view.php
 ! Added text selection after focus.
 $ /js/inserts.js
   /js/utils.js
-+ Added submit_on_change option to ref input functions
++ Added submit_on_change option to ref input functions, fixed data picker
 $ /includes/ui/ui_input.inc
 # Fixed bug in non-js mode for combos type 0 (stock_items_lists).
 $ /includes/ui/ui_lists.inc
index 3ad2966e821ea4236ff6d2ae60b6119c4dd42217..c07bea6809e25896c0e194f12214d9fa55369b66 100644 (file)
@@ -118,7 +118,8 @@ class Ajax extends JsHttpRequest {
                          break;
                  }
                }
-//             display_error(htmlentities(print_r($this->aCommands, true)));
+//             display_error('Activate:'.htmlentities(print_r($this->triggers, true)));
+//             display_error('Commands :'.htmlentities(print_r($this->aCommands, true)));
            $GLOBALS['_RESULT'] = $this->aCommands;
 //         exit();
        }
index d9d1f05759994e08cb910ad7fbb22cea81e9755f..3452b0bd4725f8d8dd7bf9fed7a2146c65cc3c8c 100644 (file)
@@ -192,11 +192,11 @@ function br($num=1)
 
 $ajax_divs = array();
 
-function div_start($id='')
+function div_start($id='', $trigger=null)
 {
     global $ajax_divs;
 
-    array_push($ajax_divs, $id);
+    array_push($ajax_divs, array($id, $trigger===null ? $id : $trigger));
     echo "<div ". ($id !='' ? "id='$id'" : '').">";
     ob_start();
 }
@@ -207,8 +207,8 @@ function div_end()
 
     if (count($ajax_divs))
     {
-               $id = array_pop($ajax_divs);
-               $Ajax->addUpdate($id, $id, ob_get_flush());
+               $div = array_pop($ajax_divs);
+               $Ajax->addUpdate($div[1], $div[0], ob_get_flush());
                echo "</div>";
     }
 }
index 753fc3d94745b8190a02a05f4b4e6d101e77b3a5..613f53b3fe2924ec4b1315c73e946f139ec7c85d 100644 (file)
@@ -440,6 +440,7 @@ function amount_cells_ex($label, $name, $size, $max=null, $init=null, $params=nu
 
        echo "</td>\n";
        $Ajax->addUpdate($name, $name, $_POST[$name]);
+       $Ajax->addAssign($name, $name, 'dec', $dec);
 }
 
 
index e46fe645993dbf01ef29eacb2b98d8445ccebc69..375498d0f2bc9a367d3bda4921dcbb64ee2f6050 100644 (file)
@@ -94,9 +94,11 @@ $opts = array(               // default options
 
        $rel = "rel='$search_box'"; // set relation to list
    if ($opts['search_submit']) {
-
        if (isset($_POST[$search_submit])) {
-               $Ajax->activate($name);
+               if (!$opts['async'])
+                       $Ajax->activate('_page_body');
+               else
+                       $Ajax->activate($name);
        }
        if ($txt == '') {
                if ($spec_option === false)
@@ -699,7 +701,8 @@ function stock_item_types_list_row($label, $name, $selected_id, $enabled=true)
                echo "<td>$label</td>\n";
        echo "<td>";
        if ($enabled)
-               $sel = "<select name='$name' onchange='this.form.submit();'>\n";
+               $sel = "<select name='$name' onchange='JsHttpRequest.request(\"_{$name}_update\", this.form);'>\n";
+               
        else
                $sel =  "<select disabled name='$name'>\n";
        if ($selected_id == null)
@@ -1794,7 +1797,7 @@ function credit_type_list_cells($label, $name, $selected, $submit_on_change=fals
                label_cell($label);
        echo "<td><select name='$name'";
        if ($submit_on_change)
-               echo " onchange='this.form.submit();'>";        // FIX ajax
+               echo " onchange='JsHttpRequest.request(\"_{$name}_update\", this.form);'>";
        else
                echo ">";
        echo "<option " . ($selected == 'Return'?" selected ":"") . " value='Return'>" . _("Items Returned to Inventory Location"). "</option>\n";
index b535cd03a361e5841450bf7147785c5213c3a975..33bff885f6bd22d0f6ed166aa2e68ca4f166ecc3 100644 (file)
@@ -74,15 +74,15 @@ function _set_combo_input(e) {
                                }
                          }
                        }
-                 };
-         e.onkeydown = function(ev) { 
+               };
+       e.onkeydown = function(ev) { 
                        ev = ev||window.event;
                        key = ev.keyCode||ev.which;
                        if(key == 13) {
                          this.blur();
                          return false;
                        }
-                 }
+               }
 }
 
 function _update_box(s) {
@@ -99,9 +99,15 @@ function _update_box(s) {
 }
 
 function _set_combo_select(e) {
+               // When combo position is changed via js (eg from searchbox)
+               // no onchange event is generated. To ensure proper change 
+               // signaling we must track selectedIndex in onblur handler.
+               e.setAttribute('_last', e.selectedIndex);
                e.onblur = function() {
                        if(this.className=='combo')
                            _update_box(this);
+                       if (this.selectedIndex != this.getAttribute('_last'))
+                               this.onchange();
                }
                e.onchange = function() {
                        var s = this;
@@ -155,14 +161,14 @@ var inserts = {
        'input.ajaxsubmit,input.editbutton,input.navibutton': 
        function(e) {
            e.onclick = function() {
-               JsHttpRequest.request(this);
-               return false;
+                       JsHttpRequest.request(this);
+                       return false;
            }
        },
     '.amount': function(e) {
                if(e.onblur==undefined) {
-                 var dec = e.getAttribute("dec");
                  e.onblur = function() {
+                       var dec = this.getAttribute("dec");
                        price_format(this.name, get_amount(this.name), dec);
                  };
                }
index a2dc4ba1783f2744cf49e2bfd5ede4ed05f07ff3..5dbbcbf96c7cfc42b5494c32db685f313e84bf2a 100644 (file)
@@ -26,7 +26,6 @@
                        values[trigger] = 1;
                // this is to avoid caching problems
                values['_random'] = Math.random()*1234567;
-
         JsHttpRequest.query(
             'POST '+url, // backend
                values,
@@ -45,7 +44,7 @@
                        // seek element by id if there is no elemnt with given name
                          objElement = document.getElementsByName(id)[0] || document.getElementById(id);
                  if(cmd=='as') {
-                                 eval("objElement."+property+"=data;");
+                                 eval("objElement.setAttribute('"+property+"',"+data+");");
                          } else if(cmd=='up') {
 //                             if(!objElement) debug('No element "'+id+'"');
                            if (objElement.tagName == 'INPUT' || objElement.tagName == 'TEXTAREA')
index 1946aca1e339a6728e548e8db38f8e039b5dedf1..2b7ded83236daa577c6924951679893b429f9086 100644 (file)
@@ -57,7 +57,9 @@ if (isset($_GET['AddedID'])) {
 //--------------------------------------------------------------------------------
 
 function line_start_focus() {
-  set_focus(get_company_pref('no_supplier_list') ? 'stock_id_edit' : 'StockID2');
+  global $Ajax;
+  $Ajax->activate('items_table');
+  set_focus('_stock_id_edit');
 }
 
 //-----------------------------------------------------------------------------
@@ -93,6 +95,7 @@ function handle_new_credit($trans_no)
        processing_start();
        $_SESSION['Items'] = new Cart(11,$trans_no);
        copy_from_cn();
+    line_start_focus();
 }
 
 //-----------------------------------------------------------------------------
@@ -135,6 +138,7 @@ if (isset($_POST['ProcessCredit']) && can_process()) {
                display_note(_("For credit notes created to write off the stock, a general ledger account is required to be selected."), 1, 0);
                display_note(_("Please select an account to write the cost of the stock off to, then click on Process again."), 1, 0);
                exit;
+               
        }
        if (!isset($_POST['WriteOffGLCode'])) {
                $_POST['WriteOffGLCode'] = 0;
index de86600d802e644e54bbb13bc11ff25f732437bb..c93db3a1a704ae1a20da8336d48ef718764194e0 100644 (file)
@@ -99,7 +99,10 @@ if (isset($_POST['AddPaymentItem'])) {
                unset($_POST['AddPaymentItem']);
        }
 }
-
+if (isset($_POST['_customer_id_button'])) {
+//     unset($_POST['branch_id']);
+       $Ajax->activate('branch_id');
+}
 //----------------------------------------------------------------------------------------------
 
 if (isset($_POST['AddPaymentItem'])) {
@@ -148,7 +151,6 @@ function display_item_form()
                }
        }
        customer_list_row(_("From Customer:"), 'customer_id', null, false, true);
-
        if (db_customer_has_branches($_POST['customer_id'])) {
                customer_branches_list_row(_("Branch:"), $_POST['customer_id'], 'BranchID', null, false, true, true);
        } else {
@@ -202,7 +204,7 @@ function display_item_form()
 
                echo"<br>";
 
-               submit_center('AddPaymentItem', _("Add Payment"));
+               submit_center('AddPaymentItem', _("Add Payment"), true, '', true);
        }
 
        echo "<br>";
index 3267bb4343c029d6d1e2a76d9b89a5ad53dbf643..fe1e1dbe3d30d434d4d2cccee568a2f6b9ef3c24 100644 (file)
@@ -6,31 +6,35 @@ include_once($path_to_root . "/includes/ui.inc");
 
 function display_credit_header(&$order)
 {
-       global $table_style;
+       global $table_style, $Ajax;
        start_table("width=80% $table_style");
        echo "<tr><td valign=top>"; // outer table
        echo "<table>";
 
        $customer_error = "";
+       $change_prices = 0;
 
     if (!isset($_POST['customer_id']) && (get_global_customer() != reserved_words::get_all()))
        $_POST['customer_id'] = get_global_customer();
 
        customer_list_row(_("Customer:"), 'customer_id', null, false, true);
 
-       if ($order->customer_id != $_POST['customer_id'] || $order->sales_type != $_POST['sales_type_id'])
+       if ($order->customer_id != $_POST['customer_id'] /*|| $order->sales_type != $_POST['sales_type_id']*/)
        {
                // customer has changed
 
                // delete all the order items - drastic but necessary because of
                // change of currency, sales type, etc
-               $order->clear_items();
+//             $order->clear_items();
 
                // clear the branch selection
-               unset($_POST['branch_id']);
+//             unset($_POST['branch_id']);
+                       $_POST['branch_id'] = '';
+                       $Ajax->activate('branch_id');
        }
 
-       customer_branches_list_row(_("Branch:"), $_POST['customer_id'], 'branch_id', null, false, true, true);
+       customer_branches_list_row(_("Branch:"), $_POST['customer_id'], 
+         'branch_id', null, false, true, true);
 
        //if (($_SESSION['credit_items']->order_no == 0) ||
        //      ($order->customer_id != $_POST['customer_id']) ||
@@ -38,8 +42,32 @@ function display_credit_header(&$order)
        //      $customer_error = get_customer_details_to_order($order, $_POST['customer_id'], $_POST['branch_id']);
        if (($order->customer_id != $_POST['customer_id']) ||
                ($order->Branch != $_POST['branch_id']))
-               $customer_error = get_customer_details_to_order($order, $_POST['customer_id'], $_POST['branch_id']);
-
+         {
+
+                               $old_order = (PHP_VERSION<5) ? $order : clone( $order );
+                               $customer_error = get_customer_details_to_order($order, $_POST['customer_id'], $_POST['branch_id']);
+
+                               $_POST['Location'] = $order->Location;
+                               $_POST['deliver_to'] = $order->deliver_to;
+                               $_POST['delivery_address'] = $order->delivery_address;
+                               $_POST['phone'] = $order->phone;
+                               $Ajax->activate('Location');
+                               $Ajax->activate('deliver_to');
+                               $Ajax->activate('phone');
+                               $Ajax->activate('delivery_address');
+                               // change prices if necessary
+                               // what about discount in template case?
+                               if ($old_order->customer_currency != $order->customer_currency) {
+                                   $change_prices = 1;
+                               }
+                               if ($old_order->sales_type != $order->sales_type) {
+                               //  || $old_order->default_discount!=$order->default_discount
+                                       $_POST['sales_type'] = $order->sales_type;
+                                   $Ajax->activate('sales_type_id');
+                                   $change_prices = 1;
+                               }
+                               unset($old_order);
+         }
        set_global_customer($_POST['customer_id']);
 
        if (!isset($_POST['ref']))
@@ -70,6 +98,24 @@ function display_credit_header(&$order)
     if (!isset($_POST['sales_type_id']))
        $_POST['sales_type_id'] = $order->sales_type;
     sales_types_list_row(_("Sales Type"), 'sales_type_id', $_POST['sales_type_id'], true);
+       
+       if ($order->sales_type != $_POST['sales_type_id']) {
+               $myrow = get_sales_type($_POST['sales_type_id']);
+               $order->set_sales_type($myrow['id'], $myrow['sales_type'],
+               $myrow['tax_included'], $myrow['factor']);
+               $Ajax->activate('sales_type_id');
+               $change_prices = 1;
+       }
+
+       if ($change_prices != 0) {
+               foreach ($order->line_items as $line_no=>$item) {
+                       $line = &$order->line_items[$line_no];
+                       $line->price = get_price($line->stock_id, $order->customer_currency,
+                               $order->sales_type, $order->price_factor, $order->document_date);
+               //              $line->discount_percent = $order->default_discount;
+               }
+           $Ajax->activate('items_table');
+       }
 
        label_row(_("Customer Discount:"), ($order->default_discount * 100) . "%");
        echo "</table>";
@@ -83,9 +129,6 @@ function display_credit_header(&$order)
 
        date_row(_("Date:"), 'OrderDate');
 
-//     if (!isset($_POST['tax_group_id']) || $_POST['tax_group_id'] == "")
-//             $_POST['tax_group_id'] = $order->tax_group_id;
-//    tax_groups_list_row(_("Tax Group:"), 'tax_group_id', null, true);
     shippers_list_row(_("Shipping Company:"), 'ShipperID', $order->ship_via);
 
        echo "</table>";
@@ -104,6 +147,7 @@ function display_credit_items($title, &$order)
     global $table_style, $path_to_root;
 
     display_heading($title);
+    div_start('items_table');
     start_table("$table_style width=90%");
     $th = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Unit"),
        _("Price"), _("Discount %"), _("Total"),'');
@@ -135,8 +179,10 @@ function display_credit_items($title, &$order)
            amount_cell($line->discount_percent * 100);
            amount_cell($line_total);
 
-           edit_button_cell("Edit$line_no", _('Edit'));
-           edit_button_cell("Delete$line_no", _('Delete'));
+           edit_button_cell("Edit$line_no", _('Edit'),
+                               _('Edit document line'));
+           edit_button_cell("Delete$line_no", _('Delete'),
+                               _('Remove line from document'));
 
            end_row();
         }
@@ -169,18 +215,19 @@ function display_credit_items($title, &$order)
     label_row(_("Credit Note Total"), $display_total, "colspan=6 align=right","class='amount'", 2);
 
     end_table();
+    div_end();
 }
 
 //---------------------------------------------------------------------------------
 
 function credit_edit_item_controls(&$order, $rowcounter, $line_no=-1)
 {
+       global $Ajax;
        alt_table_row_color($rowcounter);
        $id = find_submit('Edit');
 
        if ($line_no!=-1 && $line_no == $id)
        {
-
                $_POST['stock_id'] = $order->line_items[$id]->stock_id;
                $_POST['qty'] = qty_format($order->line_items[$id]->qty_dispatched, $_POST['stock_id'], $dec);
                $_POST['price'] = price_format($order->line_items[$id]->price);
@@ -189,14 +236,20 @@ function credit_edit_item_controls(&$order, $rowcounter, $line_no=-1)
                hidden('stock_id', $_POST['stock_id']);
                label_cell($_POST['stock_id']);
                label_cell($order->line_items[$id]->item_description, "nowrap");
+           $Ajax->activate('items_table');
        }
        else
        {
                stock_items_list_cells(null,'stock_id', null, false, true);
+               if(isset($_POST['_stock_id_update'])) {
+                           $Ajax->activate('price');
+                           $Ajax->activate('qty');
+                           $Ajax->activate('units');
+                           $Ajax->activate('line_total');
+               }
                $item_info = get_item_edit_info($_POST['stock_id']);
 
                $_POST['units'] = $item_info["units"];
-
                $_POST['qty'] = qty_format(0, $_POST['stock_id'], $dec);
                $_POST['price'] = price_format(get_price($_POST['stock_id'], $order->customer_currency,
                    $order->sales_type, $order->price_factor, $order->document_date));
@@ -205,11 +258,8 @@ function credit_edit_item_controls(&$order, $rowcounter, $line_no=-1)
                $_POST['Disc'] = percent_format($order->default_discount * 100);
        }
 
-
        qty_cells(null, 'qty', $_POST['qty'], null, null, $dec);
-//     if ($order->trans_no!=0) {
-//             amount_cell($line_no==-1 ? 0 :$order->line_items[$line_no]->qty_done);
-//     }
+
        label_cell($_POST['units']);
        amount_cells(null, 'price',  null);
        small_amount_cells(null, 'Disc', percent_format(0), null, null, user_percent_dec());
@@ -218,14 +268,17 @@ function credit_edit_item_controls(&$order, $rowcounter, $line_no=-1)
 
        if ($id!=-1)
        {
-               edit_button_cell('UpdateItem', _("Update"));
-               edit_button_cell('CancelItemChanges', _("Cancel"));
+               edit_button_cell('UpdateItem', _("Update"),
+                               _('Confirm changes'));
+               edit_button_cell('CancelItemChanges', _("Cancel"),
+                               _('Cancel changes'));
                hidden('line_no', $line_no);
                set_focus('qty');
        }
        else
        {
-               submit_cells('AddItem', _("Add Item"), "colspan=2");
+               submit_cells('AddItem', _("Add Item"), "colspan=2",
+                   _('Add new item to document'), true);
        }
 
        end_row();
@@ -236,8 +289,13 @@ function credit_edit_item_controls(&$order, $rowcounter, $line_no=-1)
 
 function credit_options_controls()
 {
-       global $table_style2;
+       global $table_style2, $Ajax;
        echo "<br>";
+
+if (isset($_POST['_CreditType_update']))
+       $Ajax->activate('options');
+
+ div_start('options');
        start_table("$table_style2");
 
        credit_type_list_row(_("Credit Note Type"), 'CreditType', null, true);
@@ -249,7 +307,6 @@ function credit_options_controls()
                if (!isset($_POST['Location']))
                        $_POST['Location'] = $_SESSION['Items']->Location;
                locations_list_row(_("Items Returned to Location"), 'Location', $_POST['Location']);
-
        }
        else
        {
@@ -259,6 +316,7 @@ function credit_options_controls()
 
        textarea_row(_("Memo"), "CreditText", null, 51, 3);
        echo "</table>";
+ div_end();
 }
 
 
index fa628d91331ce7ce3d26c85379fbeb14f40fc6a5..f836a020875cde6338b5b6abe9e8b93ea2f9df2f 100644 (file)
@@ -331,6 +331,7 @@ function sales_order_item_controls(&$order, &$rowcounter, $line_no=-1)
                if(isset($_POST['_stock_id_update'])) {
                            $Ajax->activate('price');
                            $Ajax->activate('units');
+                           $Ajax->activate('qty');
                            $Ajax->activate('line_total');
                }
 
@@ -371,7 +372,6 @@ function sales_order_item_controls(&$order, &$rowcounter, $line_no=-1)
                                _('Cancel changes'));
                hidden('LineNo', $line_no);
                set_focus('qty');
-               $Ajax->addFocus(true, 'qty');
        }
        else
        {
index 700bb18557f4dc46bdc972b41aeee90ac31ceb6a..2770fb22bf5357f21be8a18d323b5656fce5441c 100644 (file)
@@ -38,7 +38,7 @@ cust_allocations_list_cells(_("Type:"), 'filterType', null);
 
 check_cells(" " . _("show settled:"), 'showSettled', null);
 
-submit_cells('Refresh Inquiry', _("Search"));
+submit_cells('RefreshInquiry', _("Search"),'',_('Refresh Inquiry'), true);
 
 set_global_customer($_POST['customer_id']);
 
@@ -116,16 +116,19 @@ function get_transactions()
 
 $result = get_transactions();
 
-if (db_num_rows($result) == 0)
+//------------------------------------------------------------------------------------------------
+if(get_post('RefreshInquiry')) 
 {
-       display_note(_("The selected customer has no transactions for the given dates."), 1, 1);
-       end_page();
-       exit;
+       $Ajax->activate('doc_tbl');
 }
-
 //------------------------------------------------------------------------------------------------
+div_start('doc_tbl');
+if (db_num_rows($result) == 0)
+{
+       display_note(_("The selected customer has no transactions for the given dates."), 1, 1);
+} else {
 
-start_table("$table_style width='80%'");
+       start_table("$table_style width='80%'");
 
 if ($_POST['customer_id'] == reserved_words::get_all())
        $th = array(_("Type"), _("Number"), _("Reference"), _("Order"), _("Date"), _("Due Date"),
@@ -214,11 +217,11 @@ while ($myrow = db_fetch($result))
 //end of page full new headings if
 }
 //end of while loop
-
 end_table(1);
 if ($over_due)
        display_note(_("Marked items are overdue."), 0, 1, "class='overduefg'");
-
+}
+div_end();
 end_page();
 
 ?>
index 1bffa40be39e8708c78e22e24109bbc8982ca99e..0524673d93c670a375ffb82abb604693fe8a2568 100644 (file)
@@ -41,7 +41,7 @@ if (!isset($_POST['filterType']))
 
 cust_allocations_list_cells(null, 'filterType', $_POST['filterType'], true);
 
-submit_cells('Refresh Inquiry', _("Search"));
+submit_cells('RefreshInquiry', _("Search"),'',_('Refresh Inquiry'), true);
 end_row();
 end_table();
 
@@ -146,44 +146,51 @@ function get_transactions()
 }
 
 //------------------------------------------------------------------------------------------------
+
+div_start('totals_tbl');
 if ($_POST['customer_id'] != "" && $_POST['customer_id'] != reserved_words::get_all())
 {
        $customer_record = get_customer_details($_POST['customer_id']);
     display_customer_summary($customer_record);
     echo "<br>";
 }
-
+div_end();
 //------------------------------------------------------------------------------------------------
 
 $result = get_transactions();
 
-if (db_num_rows($result) == 0)
+//------------------------------------------------------------------------------------------------
+if(get_post('RefreshInquiry')) 
 {
-       display_note(_("The selected customer has no transactions for the given dates."), 0, 2);
-       end_page();
-       exit;
+       $Ajax->activate('trans_tbl');
+       $Ajax->activate('totals_tbl');
 }
-
 //------------------------------------------------------------------------------------------------
-
 print_hidden_script(10);
-start_table("$table_style width='80%'");
+
+div_start('trans_tbl');
+if (db_num_rows($result) == 0)
+{
+       display_note(_("The selected customer has no transactions for the given dates."), 0, 2);
+} else {
+
+       start_table("$table_style width='80%'");
 
        $th = array(_("Type"), _("#"), _("Order"), _("Reference"), _("Date"), _("Due Date"),
                _("Customer"), _("Branch"), _("Currency"), _("Debit"), _("Credit"), "", "","","");
 
-if ($_POST['customer_id'] != reserved_words::get_all()) {
-  unset($th[6], $th[8]);
-}
+       if ($_POST['customer_id'] != reserved_words::get_all()) {
+         unset($th[6], $th[8]);
+       }
 
-table_header($th);
+       table_header($th);
 
 
-$j = 1;
-$k = 0; //row colour counter
-$over_due = false;
-while ($myrow = db_fetch($result))
-{
+       $j = 1;
+       $k = 0; //row colour counter
+       $over_due = false;
+       while ($myrow = db_fetch($result))
+       {
 
        if ($myrow['OverDue'] == 1)
        {
@@ -269,19 +276,20 @@ while ($myrow = db_fetch($result))
                label_cell('');
        end_row();
 
-       $j++;
-       if ($j == 12)
-       {
-               $j = 1;
-               table_header($th);
-       } //end of page full new headings if
-} //end of transaction while loop
-
-end_table(1);
+               $j++;
+               if ($j == 12)
+               {
+                       $j = 1;
+                       table_header($th);
+               } //end of page full new headings if
+       } //end of transaction while loop
 
-if ($over_due)
-       display_note(_("Marked items are overdue."), 0, 1, "class='overduefg'");
+       end_table(1);
 
+       if ($over_due)
+               display_note(_("Marked items are overdue."), 0, 1, "class='overduefg'");
+}
+div_end();
 end_page();
 
 ?>
index 9aa99e2045ff3b2011d73b9e5f2470dce6e85f00..4d85035946d618611016c262871251a0f653d610 100644 (file)
@@ -16,7 +16,6 @@ include_once($path_to_root . "/sales/includes/ui/sales_order_ui.inc");
 include_once($path_to_root . "/sales/includes/sales_db.inc");
 include_once($path_to_root . "/sales/includes/db/sales_types_db.inc");
 include_once($path_to_root . "/reporting/includes/reporting.inc");
-
 $js = '';
 
 if ($use_popup_windows) {
@@ -189,7 +188,6 @@ function line_start_focus() {
   global       $Ajax;
 
   $Ajax->activate('items_table');
-  $Ajax->addFocus(true, '_stock_id_edit');
   set_focus('_stock_id_edit');
 }
 //--------------------------------------------------------------------------------
@@ -417,8 +415,6 @@ if (isset($_POST['CancelItemChanges']) || isset($_POST['UpdateItem'])) {
        line_start_focus();
 }
 
-if (isset($_POST['_customer_id_update']))
-    set_focus('branch_id');
 //--------------------------------------------------------------------------------
 check_db_has_stock_items(_("There are no inventory items defined in the system."));