From: Maxime Bourget Date: Mon, 6 May 2013 16:02:39 +0000 (+0100) Subject: Add order summary X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=785e111cb505d2ddc072de77455c79ef92a13e98;p=order_line_extra.git Add order summary --- diff --git a/includes/order_lines.inc b/includes/order_lines.inc index 71eebdd..d55fba9 100644 --- a/includes/order_lines.inc +++ b/includes/order_lines.inc @@ -84,6 +84,7 @@ function get_order_details_extra($customer_id) { FROM ".TB_PREF."sales_order_details sod JOIN ".TB_PREF."sales_orders so ON (so.order_no = sod.order_no AND so.trans_type = sod.trans_type + AND so.trans_type = ".ST_SALESORDER." AND so.debtor_no = $customer_id ) WHERE quantity > qty_sent @@ -91,4 +92,25 @@ function get_order_details_extra($customer_id) { return $sql; } + +function get_order_summary() { + $sql = "SELECT debtor_ref, branch_ref + , min(delivery_date) + , sum(quantity - qty_sent) as quantity + , sum((quantity - qty_sent)*unit_price*(1-discount_percent/100)) as amount + , min(required_date) + , min(comment) + FROM ".TB_PREF."sales_order_details sod + JOIN ".TB_PREF."sales_orders so ON (so.order_no = sod.order_no + AND so.trans_type = sod.trans_type + AND so.trans_type = ".ST_SALESORDER." + ) + NATURAL JOIN ".TB_PREF."debtors_master + NATURAL JOIN ".TB_PREF."cust_branch + WHERE quantity > qty_sent AND ".ST_SALESORDER." + GROUP BY debtor_no, branch_code + "; + + return $sql; +} ?> diff --git a/order_lines_view.php b/order_lines_view.php index 34dae47..361de53 100644 --- a/order_lines_view.php +++ b/order_lines_view.php @@ -55,10 +55,8 @@ end_table(1); // Orders inquiry table // $customer_id = $_POST['customer_id']; -if(isset($customer_id)) { +if($customer_id) { $sql = get_order_details_extra($customer_id); - - $cols = array( 'detail_id' => 'skip' , _("Order #") => array('fun'=>'view_link', 'ord' => '') @@ -69,6 +67,16 @@ if(isset($customer_id)) { ); } else { + $sql = get_order_summary(); + $cols = array( +_("Customer") => array('ord' => ''), +_("Branch") => array('ord' => ''), +_("Delivery Date") => array('ord' => ''), +_("Quantity") => array('ord' => ''), +_("Amount") => array('ord' => '', 'type' => 'amount'), +_("required date") => array('ord' => '', 'type' => 'date'), +_("comment") => array('ord' => ''), + ); }