Add tooltips with comments.
authorMaxime Bourget <bmx007@gmail.com>
Mon, 6 May 2013 18:06:27 +0000 (19:06 +0100)
committerMaxime Bourget <bmx007@gmail.com>
Mon, 6 May 2013 19:05:32 +0000 (20:05 +0100)
includes/order_lines.inc
order_lines_view.php

index 0238b343fb71813b067077a36e52803849b88e17..b02993a2274c31449ad08404d442badaec0bd232 100644 (file)
@@ -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('<br>', $comments);
+                       return "$first <span class='before-tooltip'>more</span><span class='tooltip'>&nbsp$tooltip</span>";
+               }
+       }
+       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
index 97de2957538365988ad3bc7a38be3da78035beba..1dc9f4d732dcb72b53763f7b5c352dc3ae1295a2 100644 (file)
@@ -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();
 ?>
+<style>
+span.tooltip{ display:none;}
+span.tooltip {
+      position: absolute;
+      width: 200px;
+      color: rgb(113, 157, 171);
+      background: rgb(255, 255, 255);
+      border: 1px solid rgb(113, 157, 171);
+}
+.toto {
+      height: 20px;
+      line-height: 20px;
+      padding: 10px;
+      font-size: 14px;
+      text-align: center;
+      border: 4px solid rgb(255, 255, 255);
+      border-radius: 5px;
+      text-shadow: rgba(0, 0, 0, 0.1) 1px 1px 1px;
+      box-shadow: rgba(0, 0, 0, 0.1) 1px 1px 2px 0px;
+}
+
+:hover + span.tooltip, span.tooltip:hover {
+       display: inline;
+}
+span.before-tooltip {
+       color: #800;
+       font-style: italic;
+}
+
+</style>