From 88a2b73ae7695338c9d58ae928d6d329d78e3928 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josep=20Llu=C3=ADs?= Date: Fri, 11 Jan 2019 20:09:38 +0100 Subject: [PATCH] FIX: only show products with status for sell On TakePos, only show products with status=1 (for sell) --- htdocs/takepos/takepos.php | 51 ++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index 415a81af79b..a8e9dfcd390 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -1,5 +1,6 @@ + * Copyright (C) 2019 Josep LluĂ­s Amador * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -114,16 +115,23 @@ function LoadProducts(position){ if (currentcat=="") return; pageproducts=0; $.getJSON('./ajax.php?action=getProducts&category='+currentcat, function(data) { - for (i = 0; i < 30; i++) { - if (typeof (data[i]) == "undefined"){ - $("#prodesc"+i).text(""); - $("#proimg"+i).attr("src",""); - $("#prodiv"+i).data("rowid",""); - continue; + idata=0; //product data counter + ishow=0; //product to show counter + while (idata < 30) { + if (typeof (data[idata]) == "undefined") { + $("#prodesc"+ishow).text(""); + $("#proimg"+ishow).attr("src",""); + $("#prodiv"+ishow).data("rowid",""); + ishow++; //Next product to show after print data product } - $("#prodesc"+i).text(data[parseInt(i)]['label']); - $("#proimg"+i).attr("src","genimg/?query=pro&w=55&h=50&id="+data[i]['id']); - $("#prodiv"+i).data("rowid",data[i]['id']); + else if ((data[idata]['status']) == "1") { + //Only show products with status=1 (for sell) + $("#prodesc"+ishow).text(data[parseInt(idata)]['label']); + $("#proimg"+ishow).attr("src","genimg/?query=pro&w=55&h=50&id="+data[idata]['id']); + $("#prodiv"+ishow).data("rowid",data[idata]['id']); + ishow++; //Next product to show after print data product + } + idata++; //Next data everytime } }); } @@ -145,16 +153,23 @@ function MoreProducts(moreorless){ pageproducts=pageproducts-1; return; } - for (i = 0; i < 30; i++) { - if (typeof (data[i+(30*pageproducts)]) == "undefined"){ - $("#prodesc"+i).text(""); - $("#proimg"+i).attr("src",""); - $("#prodiv"+i).data("rowid",""); - continue; + idata=30*pageproducts; //product data counter + ishow=0; //product to show counter + while (idata < 30) { + if (typeof (data[idata]) == "undefined") { + $("#prodesc"+ishow).text(""); + $("#proimg"+ishow).attr("src",""); + $("#prodiv"+ishow).data("rowid",""); + ishow++; //Next product to show after print data product } - $("#prodesc"+i).text(data[parseInt(i+(30*pageproducts))]['label']); - $("#proimg"+i).attr("src","genimg/?query=pro&w=55&h=50&id="+data[i+(30*pageproducts)]['id']); - $("#prodiv"+i).data("rowid",data[i+(30*pageproducts)]['id']); + else if ((data[idata]['status']) == "1") { + //Only show products with status=1 (for sell) + $("#prodesc"+ishow).text(data[parseInt(idata)]['label']); + $("#proimg"+ishow).attr("src","genimg/?query=pro&w=55&h=50&id="+data[idata]['id']); + $("#prodiv"+ishow).data("rowid",data[idata]['id']); + ishow++; //Next product to show after print data product + } + idata++; //Next data everytime } }); }