[0000947] Fixed unneeded input fields reset after input error in Customers.
[fa-stable.git] / sales / inquiry / sales_orders_view.php
index 53de2699fbf05f87d8ee84d2084972640247423c..27892adbcec1384e10c012b4d61777dc6d852106 100644 (file)
@@ -194,26 +194,18 @@ if (isset($_POST['Update']) && isset($_POST['last'])) {
                        change_tpl_flag($id);
 }
 
+$show_dates = !in_array($_POST['order_view_mode'], array('OutstandingOnly', 'InvoiceTemplates', 'DeliveryTemplates'));
 //---------------------------------------------------------------------------------------------
 //     Order range form
 //
-if (get_post('_OrderNumber_changed')) // enable/disable selection controls
+if (get_post('_OrderNumber_changed') || get_post('_OrderReference_changed')) // enable/disable selection controls
 {
-       $disable = get_post('OrderNumber') !== '';
+       $disable = get_post('OrderNumber') !== '' || get_post('OrderReference') !== '';
 
-       if ($_POST['order_view_mode']!='DeliveryTemplates' 
-               && $_POST['order_view_mode']!='InvoiceTemplates') {
+       if ($show_dates) {
                        $Ajax->addDisable(true, 'OrdersAfterDate', $disable);
                        $Ajax->addDisable(true, 'OrdersToDate', $disable);
        }
-       $Ajax->addDisable(true, 'StockLocation', $disable);
-       $Ajax->addDisable(true, '_SelectStockFromList_edit', $disable);
-       $Ajax->addDisable(true, 'SelectStockFromList', $disable);
-
-       if ($disable) {
-               $Ajax->addFocus(true, 'OrderNumber');
-       } else
-               $Ajax->addFocus(true, 'OrdersAfterDate');
 
        $Ajax->activate('orders_tbl');
 }
@@ -223,21 +215,23 @@ start_form();
 start_table(TABLESTYLE_NOBORDER);
 start_row();
 ref_cells(_("#:"), 'OrderNumber', '',null, '', true);
-if ($_POST['order_view_mode'] != 'DeliveryTemplates' && $_POST['order_view_mode'] != 'InvoiceTemplates')
+ref_cells(_("Ref"), 'OrderReference', '',null, '', true);
+if ($show_dates)
 {
-       ref_cells(_("Ref"), 'OrderReference', '',null, '', true);
        date_cells(_("from:"), 'OrdersAfterDate', '', null, -30);
        date_cells(_("to:"), 'OrdersToDate', '', null, 1);
 }
 locations_list_cells(_("Location:"), 'StockLocation', null, true);
-end_row();
-end_table();
 
-start_table(TABLESTYLE_NOBORDER);
-start_row();
+if($show_dates) {
+       end_row();
+       end_table();
 
+       start_table(TABLESTYLE_NOBORDER);
+       start_row();
+}
 stock_items_list_cells(_("Item:"), 'SelectStockFromList', null, true);
-
+customer_list_cells(_("Select a customer: "), 'customer_id', null, true);\r
 if ($trans_type == ST_SALESQUOTE)
        check_cells(_("Show All:"), 'show_all');
 
@@ -251,7 +245,8 @@ end_table(1);
 //---------------------------------------------------------------------------------------------
 //     Orders inquiry table
 //
-$sql = get_sql_for_sales_orders_view($selected_customer, $trans_type);
+$sql = get_sql_for_sales_orders_view($selected_customer, $trans_type, $_POST['OrderNumber'], $_POST['order_view_mode'],
+       @$selected_stock_item, @$_POST['OrdersAfterDate'], @$_POST['OrdersToDate'], @$_POST['OrderReference'], $_POST['StockLocation'], $_POST['customer_id']);\r
 
 if ($trans_type == ST_SALESORDER)
        $cols = array(
@@ -281,9 +276,11 @@ else
                'Type' => 'skip',
                _("Currency") => array('align'=>'center')
        );
-if ($_POST['order_view_mode'] == 'OutstandingOnly') {
-       //array_substitute($cols, 3, 1, _("Cust Order Ref"));
-       array_append($cols, array(array('insert'=>true, 'fun'=>'dispatch_link')));
+if ($_POST['order_view_mode'] == 'OutstandingOnly') {\r
+       //array_substitute($cols, 3, 1, _("Cust Order Ref"));\r
+       array_append($cols, array(\r
+               array('insert'=>true, 'fun'=>'dispatch_link'),\r
+               array('insert'=>true, 'fun'=>'edit_link')));\r
 
 } elseif ($_POST['order_view_mode'] == 'InvoiceTemplates') {
        array_substitute($cols, 3, 1, _("Description"));