New Can define nb of categories and products for pagination on TakePOS

This commit is contained in:
Laurent Destailleur 2019-03-27 19:34:13 +01:00
parent 3dbcf7a0c0
commit 579525ec48

View File

@ -40,8 +40,8 @@ $langs->loadLangs(array("bills","orders","commercial","cashdesk","receiptprinter
$categorie = new Categorie($db); $categorie = new Categorie($db);
$MAXCATEG = 16; $MAXCATEG = (empty($conf->global->TAKEPOS_NB_MAXCATEG)?16:$conf->global->TAKEPOS_NB_MAXCATEG);
$MAXPRODUCT = 32; $MAXPRODUCT = (empty($conf->global->TAKEPOS_NB_MAXPRODUCT)?32:$conf->global->TAKEPOS_NB_MAXPRODUCT);;
/* /*
@ -111,7 +111,7 @@ var place="<?php echo $place;?>";
var editaction="qty"; var editaction="qty";
var editnumber=""; var editnumber="";
function PrintCategories(first) { function PrintCategories(first) {
for (i = 0; i < 14; i++) { for (i = 0; i < <?php echo ($MAXCATEG - 2); ?>; i++) {
if (typeof (categories[parseInt(i)+parseInt(first)]) == "undefined") break; if (typeof (categories[parseInt(i)+parseInt(first)]) == "undefined") break;
$("#catdesc"+i).text(categories[parseInt(i)+parseInt(first)]['label']); $("#catdesc"+i).text(categories[parseInt(i)+parseInt(first)]['label']);
$("#catimg"+i).attr("src","genimg/index.php?query=cat&id="+categories[parseInt(i)+parseInt(first)]['rowid']); $("#catimg"+i).attr("src","genimg/index.php?query=cat&id="+categories[parseInt(i)+parseInt(first)]['rowid']);
@ -121,6 +121,7 @@ function PrintCategories(first) {
} }
function MoreCategories(moreorless) { function MoreCategories(moreorless) {
console.log("MoreCategories moreorless="+moreorless+" pagecategories="+pagecategories);
if (moreorless=="more") { if (moreorless=="more") {
$('#catimg15').animate({opacity: '0.5'}, 1); $('#catimg15').animate({opacity: '0.5'}, 1);
$('#catimg15').animate({opacity: '1'}, 100); $('#catimg15').animate({opacity: '1'}, 100);
@ -132,20 +133,20 @@ function MoreCategories(moreorless) {
if (pagecategories==0) return; //Return if no less pages if (pagecategories==0) return; //Return if no less pages
pagecategories=pagecategories-1; pagecategories=pagecategories-1;
} }
if (typeof (categories[14*pagecategories] && moreorless=="more") == "undefined"){ // Return if no more pages if (typeof (categories[<?php echo ($MAXCATEG - 2); ?> * pagecategories] && moreorless=="more") == "undefined"){ // Return if no more pages
pagecategories=pagecategories-1; pagecategories=pagecategories-1;
return; return;
} }
for (i = 0; i < 14; i++) { for (i = 0; i < <?php echo ($MAXCATEG - 2); ?>; i++) {
if (typeof (categories[i+(14*pagecategories)]) == "undefined"){ if (typeof (categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]) == "undefined") {
$("#catdesc"+i).text(""); $("#catdesc"+i).text("");
$("#catimg"+i).attr("src","genimg/empty.png"); $("#catimg"+i).attr("src","genimg/empty.png");
$("#catwatermark"+i).hide(); $("#catwatermark"+i).hide();
continue; continue;
} }
$("#catdesc"+i).text(categories[i+(14*pagecategories)]['label']); $("#catdesc"+i).text(categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]['label']);
$("#catimg"+i).attr("src","genimg/index.php?query=cat&id="+categories[i+(14*pagecategories)]['rowid']); $("#catimg"+i).attr("src","genimg/index.php?query=cat&id="+categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]['rowid']);
$("#catdiv"+i).data("rowid",categories[i+(14*pagecategories)]['rowid']); $("#catdiv"+i).data("rowid",categories[i+(<?php echo ($MAXCATEG - 2); ?> * pagecategories)]['rowid']);
$("#catwatermark"+i).show(); $("#catwatermark"+i).show();
} }
} }
@ -221,7 +222,7 @@ function MoreProducts(moreorless) {
pageproducts=pageproducts-1; pageproducts=pageproducts-1;
return; return;
} }
idata=30*pageproducts; //product data counter idata=<?php echo ($MAXPRODUCT - 2); ?> * pageproducts; //product data counter
ishow=0; //product to show counter ishow=0; //product to show counter
while (ishow < maxproduct) { while (ishow < maxproduct) {