From 9319059349ac4cb8fb916b004cd3936977c26ba3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9?= Date: Thu, 20 Nov 2025 14:01:29 +0100 Subject: [PATCH 1/4] FIX: Sometimes socid = undefined --- htdocs/takepos/index.php | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index fe9c34946a4..3ae0da797c4 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -93,6 +93,8 @@ if ($conf->browser->layout == 'phone') { $MAXCATEG = (empty($conf->global->TAKEPOS_NB_MAXCATEG) ? $maxcategbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXCATEG); $MAXPRODUCT = (empty($conf->global->TAKEPOS_NB_MAXPRODUCT) ? $maxproductbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXPRODUCT); +$term = empty($_SESSION['takeposterminal']) ? 1 : $_SESSION['takeposterminal']; +$socid = getDolGlobalString('CASHDESK_ID_THIRDPARTY' . $term); /* $constforcompanyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]; $soc = new Societe($db); @@ -329,8 +331,15 @@ function LoadProducts(position, issubcat) { if (maxproduct >= 1) { limit = maxproduct-1; } + + // Get socid + let socid = jQuery('#thirdpartyid').val(); + if ((socid === undefined || socid === "") && parseInt("") > 0) { + socid = parseInt(""); + } + // Only show products for sale (tosell=1) - $.getJSON('/takepos/ajax/ajax.php?action=getProducts&token=&thirdpartyid=' + jQuery('#thirdpartyid').val() + '&category='+currentcat+'&tosell=1&limit='+limit+'&offset=0', function(data) { + $.getJSON('/takepos/ajax/ajax.php?action=getProducts&token=&thirdpartyid=' + socid + '&category='+currentcat+'&tosell=1&limit='+limit+'&offset=0', function(data) { console.log("Call ajax.php (in LoadProducts) to get Products of category "+currentcat+" then loop on result to fill image thumbs"); console.log(data); while (ishow < maxproduct) { @@ -437,8 +446,15 @@ function MoreProducts(moreorless) { limit = maxproduct-1; } var offset = * pageproducts; + + // Get socid + let socid = jQuery('#thirdpartyid').val(); + if ((socid === undefined || socid === "") && parseInt("") > 0) { + socid = parseInt(""); + } + // Only show products for sale (tosell=1) - $.getJSON('/takepos/ajax/ajax.php?action=getProducts&token=&thirdpartyid=' + jQuery('#thirdpartyid').val() + '&category='+currentcat+'&tosell=1&limit='+limit+'&offset='+offset, function(data) { + $.getJSON('/takepos/ajax/ajax.php?action=getProducts&token=&thirdpartyid=' + socid + '&category='+currentcat+'&tosell=1&limit='+limit+'&offset='+offset, function(data) { console.log("Call ajax.php (in MoreProducts) to get Products of category "+currentcat); if (typeof (data[0]) == "undefined" && moreorless=="more"){ // Return if no more pages @@ -662,7 +678,14 @@ function Search2(keyCodeForEnter, moreorless) { pageproducts = 0; jQuery(".wrapper2 .catwatermark").hide(); var nbsearchresults = 0; - $.getJSON('/takepos/ajax/ajax.php?action=search&token=&term=' + search_term + '&thirdpartyid=' + jQuery('#thirdpartyid').val() + '&search_start=' + search_start + '&search_limit=' + search_limit, function (data) { + + // Only show products for sale (tosell=1) + let socid = jQuery('#thirdpartyid').val(); + if ((socid === undefined || socid === "") && parseInt("") > 0) { + socid = parseInt(""); + } + + $.getJSON('/takepos/ajax/ajax.php?action=search&token=&term=' + search_term + '&thirdpartyid=' + socid + '&search_start=' + search_start + '&search_limit=' + search_limit, function (data) { for (i = 0; i < ; i++) { if (typeof (data[i]) == "undefined") { $("#prowatermark" + i).html(""); From 92197cb100c5cdce53b17cba22e66ec5f6516cf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9?= Date: Fri, 21 Nov 2025 16:06:09 +0100 Subject: [PATCH 2/4] FIX: php echo instead of ") > 0) { + if ((socid === undefined || socid === "") && parseInt("") > 0) { socid = parseInt(""); } @@ -449,7 +449,7 @@ function MoreProducts(moreorless) { // Get socid let socid = jQuery('#thirdpartyid').val(); - if ((socid === undefined || socid === "") && parseInt("") > 0) { + if ((socid === undefined || socid === "") && parseInt("") > 0) { socid = parseInt(""); } @@ -681,7 +681,7 @@ function Search2(keyCodeForEnter, moreorless) { // Only show products for sale (tosell=1) let socid = jQuery('#thirdpartyid').val(); - if ((socid === undefined || socid === "") && parseInt("") > 0) { + if ((socid === undefined || socid === "") && parseInt("") > 0) { socid = parseInt(""); } From 3416c6ccc03053566be5e67868de4f676123efde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9?= Date: Thu, 27 Nov 2025 10:00:43 +0100 Subject: [PATCH 3/4] FIX: getDolGlobalInt --- htdocs/takepos/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index cf999b7ecc7..bafe040f50c 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -94,7 +94,7 @@ $MAXCATEG = (empty($conf->global->TAKEPOS_NB_MAXCATEG) ? $maxcategbydefaultforth $MAXPRODUCT = (empty($conf->global->TAKEPOS_NB_MAXPRODUCT) ? $maxproductbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXPRODUCT); $term = empty($_SESSION['takeposterminal']) ? 1 : $_SESSION['takeposterminal']; -$socid = getDolGlobalString('CASHDESK_ID_THIRDPARTY' . $term); +$socid = getDolGlobalInt('CASHDESK_ID_THIRDPARTY' . $term); /* $constforcompanyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]; $soc = new Societe($db); From 2ee07bb0494bf5a95e33c6f1cfed5bbcd2271554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9?= Date: Thu, 4 Dec 2025 17:27:57 +0100 Subject: [PATCH 4/4] FIX: Remove ") > 0) { - socid = parseInt(""); + if ((socid === undefined || socid === "") && parseInt("") > 0) { + socid = parseInt(""); } // Only show products for sale (tosell=1) @@ -449,8 +449,8 @@ function MoreProducts(moreorless) { // Get socid let socid = jQuery('#thirdpartyid').val(); - if ((socid === undefined || socid === "") && parseInt("") > 0) { - socid = parseInt(""); + if ((socid === undefined || socid === "") && parseInt("") > 0) { + socid = parseInt(""); } // Only show products for sale (tosell=1) @@ -681,8 +681,8 @@ function Search2(keyCodeForEnter, moreorless) { // Only show products for sale (tosell=1) let socid = jQuery('#thirdpartyid').val(); - if ((socid === undefined || socid === "") && parseInt("") > 0) { - socid = parseInt(""); + if ((socid === undefined || socid === "") && parseInt("") > 0) { + socid = parseInt(""); } $.getJSON('/takepos/ajax/ajax.php?action=search&token=&term=' + search_term + '&thirdpartyid=' + socid + '&search_start=' + search_start + '&search_limit=' + search_limit, function (data) {