From 9105e205ff1e8a23bab342804da417cf87e7077c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Mar 2019 20:20:39 +0100 Subject: [PATCH] No more need to set scroolTop, lines are sorted with last added first --- htdocs/takepos/customers.php | 2 +- htdocs/takepos/invoice.php | 68 ++++++++++++++++++++---------------- htdocs/takepos/pay.php | 2 +- htdocs/takepos/takepos.php | 18 +++++----- 4 files changed, 49 insertions(+), 41 deletions(-) diff --git a/htdocs/takepos/customers.php b/htdocs/takepos/customers.php index 46e06365a93..05fdf5537c9 100644 --- a/htdocs/takepos/customers.php +++ b/htdocs/takepos/customers.php @@ -61,7 +61,7 @@ if ($action=="change") { ?> diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 4b6aebbe80c..3c39b7e1e4e 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -407,39 +407,47 @@ print "\n"; if ($placeid > 0) { - $tmplines = array_reverse($invoice->lines); - foreach($tmplines as $line) + if (is_array($invoice->lines) && count($invoice->lines)) { - $htmlforlines = ''; - - $htmlforlines.= 'id . '">'; - $htmlforlines.= ''; - $htmlforlines.= $line->product_label; - if ($line->product_label && $line->desc) $htmlforlines.= '
'; - if ($line->product_label != $line->desc) + $tmplines = array_reverse($invoice->lines); + foreach($tmplines as $line) { - $firstline = dolGetFirstLineOfText($line->desc); - if ($firstline != $line->desc) - { - $htmlforlines.= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc); - } - else - { - $htmlforlines.= $line->desc; - } - } - if (!empty($line->array_options['options_order_notes'])) $htmlforlines.= "
(".$line->array_options['options_order_notes'].")"; - $htmlforlines.= ''; - $htmlforlines.= '' . vatrate($line->remise_percent, true) . ''; - $htmlforlines.= '' . $line->qty . ''; - $htmlforlines.= '' . price($line->total_ttc) . ''; - $htmlforlines.= ''."\n"; + $htmlforlines = ''; + + $htmlforlines.= 'id . '">'; + $htmlforlines.= ''; + $htmlforlines.= $line->product_label; + if ($line->product_label && $line->desc) $htmlforlines.= '
'; + if ($line->product_label != $line->desc) + { + $firstline = dolGetFirstLineOfText($line->desc); + if ($firstline != $line->desc) + { + $htmlforlines.= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc); + } + else + { + $htmlforlines.= $line->desc; + } + } + if (!empty($line->array_options['options_order_notes'])) $htmlforlines.= "
(".$line->array_options['options_order_notes'].")"; + $htmlforlines.= ''; + $htmlforlines.= '' . vatrate($line->remise_percent, true) . ''; + $htmlforlines.= '' . $line->qty . ''; + $htmlforlines.= '' . price($line->total_ttc) . ''; + $htmlforlines.= ''."\n"; + + print $htmlforlines; + } + } + else + { + print ''.$langs->trans("Empty").''; - print $htmlforlines; } } diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php index fed57dcf068..3f9641b37d5 100644 --- a/htdocs/takepos/pay.php +++ b/htdocs/takepos/pay.php @@ -170,7 +170,7 @@ else print "var received=0;"; } console.log("We click on the payment mode to pay amount = "+amountpayed); parent.$("#poslines").load("invoice.php?place=&action=valid&pay="+payment+"&amount="+amountpayed+"&invoiceid="+invoiceid, function() { - parent.$("#poslines").scrollTop(parent.$("#poslines")[0].scrollHeight); + //parent.$("#poslines").scrollTop(parent.$("#poslines")[0].scrollHeight); parent.$.colorbox.close(); }); } diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index bb57baaf04d..9fa2154eaf1 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -66,9 +66,9 @@ top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); get_full_arbo('product', 0, (($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0)?$conf->global->TAKEPOS_ROOT_CATEGORY_ID:0)); -//$conf->global->TAKEPOS_ROOT_CATEGORY_ID=0; // Search root category to know its level +//$conf->global->TAKEPOS_ROOT_CATEGORY_ID=0; $levelofrootcategory=0; if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) { @@ -267,7 +267,7 @@ function ClickProduct(position) { function deleteline() { $("#poslines").load("invoice.php?action=deleteline&place="+place+"&idline="+selectedline, function() { - $('#poslines').scrollTop($('#poslines')[0].scrollHeight); + //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); }); } @@ -295,13 +295,13 @@ function TakeposOrderNotes() { function Refresh() { $("#poslines").load("invoice.php?place="+place, function() { - $('#poslines').scrollTop($('#poslines')[0].scrollHeight); + //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); }); } function Search() { $("#poslines").load("invoice.php?action=search&place="+place, function() { - $('#poslines').scrollTop($('#poslines')[0].scrollHeight); + //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); }); } @@ -334,7 +334,7 @@ function Edit(number){ if (editaction=='qty' && editnumber!=""){ $("#poslines").load("invoice.php?action=updateqty&place="+place+"&idline="+selectedline+"&number="+editnumber, function() { editnumber=""; - $('#poslines').scrollTop($('#poslines')[0].scrollHeight); + //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); $("#qty").html("trans("Qty"); ?>"); }); return; @@ -347,7 +347,7 @@ function Edit(number){ if (editaction=='p' && editnumber!=""){ $("#poslines").load("invoice.php?action=updateprice&place="+place+"&idline="+selectedline+"&number="+editnumber, function() { editnumber=""; - $('#poslines').scrollTop($('#poslines')[0].scrollHeight); + //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); $("#price").html("trans("Price"); ?>"); }); return; @@ -360,7 +360,7 @@ function Edit(number){ if (editaction=='r' && editnumber!=""){ $("#poslines").load("invoice.php?action=updatereduction&place="+place+"&idline="+selectedline+"&number="+editnumber, function() { editnumber=""; - $('#poslines').scrollTop($('#poslines')[0].scrollHeight); + //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); $("#reduction").html("trans("ReductionShort"); ?>"); }); return; @@ -395,13 +395,13 @@ function Edit(number){ function TakeposPrintingOrder(){ $("#poslines").load("invoice.php?action=order&place="+place, function() { - $('#poslines').scrollTop($('#poslines')[0].scrollHeight); + //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); }); } function TakeposPrintingTemp(){ $("#poslines").load("invoice.php?action=temp&place="+place, function() { - $('#poslines').scrollTop($('#poslines')[0].scrollHeight); + //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); }); }