Access order detials by order_id only (find the customer)
authorMaxime Bourget <bmx007@gmail.com>
Sat, 15 Jun 2013 17:56:31 +0000 (18:56 +0100)
committerMaxime Bourget <bmx007@gmail.com>
Sat, 15 Jun 2013 17:56:31 +0000 (18:56 +0100)
Doesn't update the customer list.

order_lines_view.php

index a452972c19533453eef6c19745093ff169f14019..7a74825f11cb2c342c9d64cc67099064e67e3bac 100644 (file)
@@ -63,18 +63,29 @@ start_form();
 start_table(TABLESTYLE_NOBORDER);
 start_row();
 
+$order_id = get_parameter('order_id');
+text_cells_ex(_('Order #'), 'order_id', 10, null, $order_id,
+               null, null, null, true );
 
 if(!isset($_POST['customer_id'])) {
        if(isset($_GET['customer_id'])) {
                $customer_id = $_GET['customer_id'];
                $_POST['customer_id'] = $customer_id;
        }
-else $customer_id = null;
+else {
+       $customer_id = null;
+
+}
 
 }
 else {
        $customer_id = $_POST['customer_id'];
 }
+       if($order_id) {
+               // find the customer owing the order
+               $result = db_query("SELECT debtor_no FROM ".TB_PREF."sales_orders WHERE order_no = $order_id AND trans_type =".ST_SALESORDER );
+               if($result && $row=db_fetch($result)) $customer_id= $row['debtor_no'];
+       }
 customer_list_cells(_("Select a customer: "), 'customer_id', $customer_id, true, true);
 
 if($customer_id != null) {
@@ -89,9 +100,6 @@ if($customer_id != null) {
        text_cells_ex('Filter Item', 'item_like', 50, null, $item_like,
                        null, null, null, true );
 
-       $order_id = get_parameter('order_id');
-       text_cells_ex(_('Order #'), 'order_id', 10, null, $order_id,
-                       null, null, null, true );
 }