From 75d784a6eb52bb298c3db637331ebbfc6563cd50 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 Nov 2022 23:23:42 +0100 Subject: [PATCH] Fix price on takepos thumb must include vat --- htdocs/product/class/product.class.php | 10 +++++-- htdocs/takepos/admin/appearance.php | 2 +- htdocs/takepos/ajax/ajax.php | 14 +++++++--- htdocs/takepos/css/pos.css.php | 38 +++++++++++++------------- htdocs/takepos/index.php | 28 +++++++++---------- 5 files changed, 51 insertions(+), 41 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index aba48b939be..ffb72bfca78 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -127,19 +127,23 @@ class Product extends CommonObject public $type = self::TYPE_PRODUCT; /** - * Selling price + * Selling price without tax * * @var float */ - public $price; // Price net + public $price; + + public $price_formated; // used by takepos/ajax/ajax.php /** - * Price with tax + * Selling price with tax * * @var float */ public $price_ttc; + public $price_ttc_formated; // used by takepos/ajax/ajax.php + /** * Minimum price net * diff --git a/htdocs/takepos/admin/appearance.php b/htdocs/takepos/admin/appearance.php index 250606703af..54ed2f642a2 100644 --- a/htdocs/takepos/admin/appearance.php +++ b/htdocs/takepos/admin/appearance.php @@ -115,7 +115,7 @@ print ''; print $langs->trans("NumberOfLinesToShow"); print ''; $array = array(1=>"1", 2=>"2", 3=>"3", 4=>"4", 5=>"5", 6=>"6"); -print $form->selectarray('TAKEPOS_LINES_TO_SHOW', $array, (empty($conf->global->TAKEPOS_LINES_TO_SHOW) ? '2' : $conf->global->TAKEPOS_LINES_TO_SHOW), 0); +print $form->selectarray('TAKEPOS_LINES_TO_SHOW', $array, getDolGlobalInt('TAKEPOS_LINES_TO_SHOW', 2), 0); print "\n"; // D'ont display category diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 671ef27ba96..db6b224466c 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -84,7 +84,10 @@ if ($action == 'getProducts') { } unset($prod->fields); unset($prod->db); - $prod->price_formated=price(price2num($prod->price, 'MU'), 1, $langs, 1, -1, -1, $conf->currency); + + $prod->price_formated = price(price2num($prod->price, 'MT'), 1, $langs, 1, -1, -1, $conf->currency); + $prod->price_ttc_formated = price(price2num($prod->price_ttc, 'MT'), 1, $langs, 1, -1, -1, $conf->currency); + $res[] = $prod; } } @@ -158,7 +161,7 @@ if ($action == 'getProducts') { if (isset($barcode_value_list['ref'])) { // search product from reference - $sql = "SELECT rowid, ref, label, tosell, tobuy, barcode, price"; + $sql = "SELECT rowid, ref, label, tosell, tobuy, barcode, price, price_ttc"; $sql .= " FROM " . $db->prefix() . "product as p"; $sql .= " WHERE entity IN (" . getEntity('product') . ")"; $sql .= " AND ref = '" . $db->escape($barcode_value_list['ref']) . "'"; @@ -207,6 +210,7 @@ if ($action == 'getProducts') { 'tobuy' => $obj->tobuy, 'barcode' => $obj->barcode, 'price' => $obj->price, + 'price_ttc' => $obj->price_ttc, 'object' => 'product', 'img' => $ig, 'qty' => $qty, @@ -223,7 +227,7 @@ if ($action == 'getProducts') { } } - $sql = 'SELECT p.rowid, p.ref, p.label, p.tosell, p.tobuy, p.barcode, p.price' ; + $sql = 'SELECT p.rowid, p.ref, p.label, p.tosell, p.tobuy, p.barcode, p.price, p.price_ttc' ; if (getDolGlobalInt('TAKEPOS_PRODUCT_IN_STOCK') == 1) { $sql .= ', ps.reel'; } @@ -299,10 +303,12 @@ if ($action == 'getProducts') { 'tobuy' => $obj->tobuy, 'barcode' => $obj->barcode, 'price' => $obj->price, + 'price_ttc' => $obj->price_ttc, 'object' => 'product', 'img' => $ig, 'qty' => 1, - 'price_formated' => price(price2num($obj->price, 'MU'), 1, $langs, 1, -1, -1, $conf->currency) + 'price_formated' => price(price2num($obj->price, 'MT'), 1, $langs, 1, -1, -1, $conf->currency), + 'price_ttc_formated' => price(price2num($obj->price_ttc, 'MT'), 1, $langs, 1, -1, -1, $conf->currency) ); // Add entries to row from hooks $parameters=array(); diff --git a/htdocs/takepos/css/pos.css.php b/htdocs/takepos/css/pos.css.php index d39b3fb0b37..ec21eea2d60 100644 --- a/htdocs/takepos/css/pos.css.php +++ b/htdocs/takepos/css/pos.css.php @@ -477,7 +477,7 @@ p.description_content{ div.description_content { display: -webkit-box; -webkit-box-orient: vertical; - -webkit-line-clamp: global->TAKEPOS_LINES_TO_SHOW; ?>; + -webkit-line-clamp: ; overflow: hidden; padding-left: 2px; padding-right: 2px; @@ -587,11 +587,11 @@ div#moreinfo, div#infowarehouse { background: var(--colorbackhmenu1); color: var(--colortextbackhmenu); font-size: 2em; - padding: 5px; + padding: 4px; border-radius: 2px; opacity: 0.9; - padding-left: 8px; - padding-right: 8px; + padding-left: 6px; + padding-right: 6px; } @@ -841,11 +841,11 @@ div#moreinfo, div#infowarehouse { padding-bottom: 2px; margin-left: 2px; } - + .div4 .wrapper.divempty, .div4 img, .div4 .wrapper:nth-last-child(1), .div4 .wrapper:nth-last-child(2), #prodiv22, #prodiv23, .catwatermark { display: none!important; } - + .tab-category { float: left; position: relative; @@ -858,7 +858,7 @@ div#moreinfo, div#infowarehouse { box-sizing: border-box; background-color: #fff; } - + .div4 .wrapper, .tab-category { width: auto; height: auto; @@ -868,7 +868,7 @@ div#moreinfo, div#infowarehouse { border: 1px solid #FFF!important; border-top: 3px solid #FFF!important; } - + .div4 .tab-category.active { border-right: 1px solid #CCC !important; border-left: 1px solid #CCC !important; @@ -890,42 +890,42 @@ div#moreinfo, div#infowarehouse { padding-top: 0px; background: -webkit-linear-gradient(top, rgba(250,250,250,0), rgba(250,250,250,0.5), rgba(250,250,250,0.95), rgba(250,250,250,1)); } - + .div5 .description .description_content { font-weight: bold; font-size: 14px; padding-left: 10px; } - + .div5 .wrapper2 { width: 100%; display: inline-flex; align-items: center; padding: 10px; } - + .div5 .wrapper2.divempty { display: none; } - + div.wrapper2 { float: none; } - + .div5 .arrow { width: auto; height: auto; display: none!important; } - + .div5 .arrow .centerinmiddle { transform: translate(0, 0); } - + .div5 .imgadd { display: flex; } - + div.wrapper2{ height:10%; } @@ -1009,12 +1009,12 @@ html { ::-webkit-scrollbar-track { - background: #f1f1f1; + background: #f1f1f1; } - + ::-webkit-scrollbar-thumb { - background: #888; + background: #888; } .topnav::-webkit-scrollbar-track{ diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index a128a0d66fd..17c4f14060c 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -367,7 +367,7 @@ function LoadProducts(position, issubcat) { ?> if (data[parseInt(idata)]['price_formated']) { $("#proprice"+ishow).attr("class", "productprice"); - $("#proprice"+ishow).html(data[parseInt(idata)]['price_formated']); + $("#proprice"+ishow).html(data[parseInt(idata)]['price_ttc_formated']); } console.log("#prodiv"+ishow+".data(rowid)="+data[idata]['id']); console.log($("#prodiv"+ishow)); @@ -449,7 +449,7 @@ function MoreProducts(moreorless) { $("#probutton"+ishow).show(); if (data[parseInt(idata)]['price_formated']) { $("#proprice"+ishow).attr("class", "productprice"); - $("#proprice"+ishow).html(data[parseInt(idata)]['price_formated']); + $("#proprice"+ishow).html(data[parseInt(idata)]['price_ttc_formated']); } $("#proimg"+ishow).attr("src","genimg/index.php?query=pro&id="+data[idata]['id']); $("#prodiv"+ishow).data("rowid",data[idata]['id']); @@ -657,7 +657,7 @@ function Search2(keyCodeForEnter, moreorless) { $("#probutton" + i).show(); if (data[i]['price_formated']) { $("#proprice" + i).attr("class", "productprice"); - $("#proprice" + i).html(data[i]['price_formated']); + $("#proprice" + i).html(data[i]['price_ttc_formated']); } $("#proimg" + i).attr("title", titlestring); if( undefined !== data[i]['img']) { @@ -939,15 +939,15 @@ $( document ).ready(function() { } } ?> - + /* For Header Scroll */ var elem1 = $("#topnav-left")[0]; var elem2 = $("#topnav-right")[0]; var checkOverflow = function() { if (scrollBars().horizontal) $("#topnav").addClass("overflow"); - else $("#topnav").removeClass("overflow"); + else $("#topnav").removeClass("overflow"); } - + var scrollBars = function(){ var container= $('#topnav')[0]; return { @@ -955,43 +955,43 @@ $( document ).ready(function() { horizontal:container.scrollWidth > container.clientWidth }; } - + $(window).resize(function(){ checkOverflow(); }); - + let resizeObserver = new ResizeObserver(() => { checkOverflow(); }); resizeObserver.observe(elem1); resizeObserver.observe(elem2); checkOverflow(); - + var pressTimer = []; var direction = 1; var step = 200; - + $(".indicator").mousedown(function(){ direction = $(this).hasClass("left") ? -1 : 1; scrollTo(); pressTimer.push(setInterval(scrollTo, 100)); }); - + $(".indicator").mouseup(function(){ pressTimer.forEach(clearInterval); }); - + $("body").mouseup(function(){ pressTimer.forEach(clearInterval); console.log("body"); }); - + function scrollTo(){ console.log("here"); var pos = $("#topnav").scrollLeft(); document.getElementById("topnav").scrollTo({ left: $("#topnav").scrollLeft() + direction * step, behavior: 'smooth' }) } - + $("#topnav").scroll(function(){ if (($("#topnav").offsetWidth + $("#topnav").scrollLeft >= $("#topnav").scrollWidth)) { console.log("end");