From da44766f38011a19d08b7051fd6712a4e3a07af6 Mon Sep 17 00:00:00 2001 From: Maxime Bourget Date: Mon, 6 May 2013 19:06:27 +0100 Subject: [PATCH] Add tooltips with comments. --- includes/order_lines.inc | 21 ++++++++++++++++-- order_lines_view.php | 47 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 62 insertions(+), 6 deletions(-) diff --git a/includes/order_lines.inc b/includes/order_lines.inc index 0238b34..b02993a 100644 --- a/includes/order_lines.inc +++ b/includes/order_lines.inc @@ -57,6 +57,22 @@ function customer_link($row) { } +function aggregate_comment($row) { + $comment = $row['order_comment'].$row['detail_comment']; + if($comment) { + $comments = array_map('trim', explode(';', $comment)); + $comments = array_filter($comments); + $first = array_shift($comments); + if(count($comments) == 0) + return $first; + else { + $tooltip = implode('
', $comments); + return "$first more $tooltip"; + } + } + return ''; +} + function input_date_details($row, $date) { $row_id = $row['id']; $name = compute_input_name($row, 'required_date'); @@ -86,7 +102,7 @@ function get_order_details_extra($customer_id) { , stk_code , quantity - qty_sent , required_date - , comment + ,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 @@ -105,7 +121,8 @@ function get_order_summary() { , sum(quantity - qty_sent) as quantity , sum((quantity - qty_sent)*unit_price*(1-discount_percent/100)) as amount , min(required_date) - , min(comment) + , group_concat(distinct comments separator ';') as order_comment + , group_concat(distinct comment separator ';') as detail_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 diff --git a/order_lines_view.php b/order_lines_view.php index 97de295..1dc9f4d 100644 --- a/order_lines_view.php +++ b/order_lines_view.php @@ -41,8 +41,16 @@ start_table(TABLESTYLE_NOBORDER); start_row(); -if(isset($_GET['customer_id']) && !isset($_POST['customer_id'])) $_POST['customer_id']=$_GET['customer_id']; -$customer_id = $_POST['customer_id']; +if(!isset($_POST['customer_id'])) { + if(isset($_GET['customer_id'])) { + $customer_id = $_GET['customer_id']; + } +else $customer_id = null; + +} +else { + $customer_id = $_POST['customer_id']; +} customer_list_cells(_("Select a customer: "), 'customer_id', $customer_id, true, true); @@ -75,11 +83,12 @@ else { 'customer id' => 'skip', _("Customer") => array('ord' => '', 'fun' => 'customer_link'), _("Branch") => array('ord' => ''), -_("Delivery Date") => array('ord' => ''), +_("Delivery Date") => array('ord' => '', 'type' => 'date'), _("Quantity") => array('ord' => ''), _("Amount") => array('ord' => '', 'type' => 'amount'), _("required date") => array('ord' => '', 'type' => 'date'), -_("comment") => array('ord' => ''), +_("Comments") => array('ord' => '', 'fun' => 'aggregate_comment'), +_("comment 2 ") => 'skip' ); } @@ -97,3 +106,33 @@ submit_center_last('Cancel', _("Cancel"), true, '', 'cancel', true); end_form(); end_page(); ?> + -- 2.30.2