diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php
index 07de9e50a51..56c30b69283 100644
--- a/htdocs/takepos/ajax/ajax.php
+++ b/htdocs/takepos/ajax/ajax.php
@@ -85,10 +85,10 @@ elseif ($action == 'search' && $term != '') {
}
}
- $sql = 'SELECT rowid, ref, label, tosell, tobuy FROM '.MAIN_DB_PREFIX.'product as p';
+ $sql = 'SELECT rowid, ref, label, tosell, tobuy, barcode, price FROM '.MAIN_DB_PREFIX.'product as p';
$sql .= ' WHERE entity IN ('.getEntity('product').')';
if ($filteroncategids) {
- $sql.= ' AND rowid IN (SELECT DISTINCT fk_product FROM '.MAIN_DB_PREFIX.'categorie_product WHERE fk_categorie IN ('.$filteroncategids.'))';
+ $sql.= ' AND EXISTS (SELECT cp.fk_product FROM '.MAIN_DB_PREFIX.'categorie_product as cp WHERE cp.fk_product = p.rowid AND cp.fk_categorie IN ('.$filteroncategids.'))';
}
$sql .= ' AND tosell = 1';
$sql .= natural_search(array('ref', 'label', 'barcode'), $term);
@@ -96,8 +96,17 @@ elseif ($action == 'search' && $term != '') {
if ($resql)
{
$rows = array();
- while ($row = $db->fetch_object($resql)) {
- $rows[] = $row;
+ while ($obj = $db->fetch_object($resql)) {
+ $rows[] = array(
+ 'rowid' => $obj->rowid,
+ 'ref' => $obj->ref,
+ 'label' => $obj->label,
+ 'tosell' => $obj->tosell,
+ 'tobuy' => $obj->tobuy,
+ 'barcode' => $obj->barcode,
+ 'price' => $obj->price
+ //'price_formated' => price(price2num($obj->price, 'MU'), 1, $langs, 1, -1, -1, $conf->currency)
+ );
}
echo json_encode($rows);
}
diff --git a/htdocs/takepos/css/pos.css.php b/htdocs/takepos/css/pos.css.php
index 32b7d7b7104..b541cdd6bad 100644
--- a/htdocs/takepos/css/pos.css.php
+++ b/htdocs/takepos/css/pos.css.php
@@ -286,7 +286,7 @@ div.paymentbordline
.row1withhead{
margin: 0 auto;
width: 100%;
- height: calc(50% - 50px);
+ height: calc(45% - 50px);
padding-top: 5px;
}
@@ -299,7 +299,7 @@ div.paymentbordline
.row2withhead{
margin: 0 auto;
width: 100%;
- height: 50%;
+ height: 55%;
}
.div1{
@@ -488,6 +488,20 @@ div#moreinfo, div#infowarehouse {
padding: 0 8px 0 8px;
}
+.productprice {
+ position: absolute;
+ top: 5px;
+ right: 5px;
+ background: var(--colorbackhmenu1);
+ color: var(--colortextbackhmenu);
+ font-size: 2em;
+ padding: 5px;
+ border-radius: 2px;
+ opacity: 0.9;
+ padding-left: 8px;
+ padding-right: 8px;
+}
+
@media screen and (min-width: 892px) {
.actionbutton{
@@ -561,7 +575,7 @@ div#moreinfo, div#infowarehouse {
}
.row1withhead{
- height: calc(50% - 100px);
+ height: calc(45% - 100px);
}
diff --git a/htdocs/takepos/floors.php b/htdocs/takepos/floors.php
index 6a067a76268..260813dd3b6 100644
--- a/htdocs/takepos/floors.php
+++ b/htdocs/takepos/floors.php
@@ -47,6 +47,15 @@ $place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place
$newname = GETPOST('newname', 'alpha');
$mode = GETPOST('mode', 'alpha');
+if (empty($user->rights->takepos->run)) {
+ access_forbidden();
+}
+
+
+/*
+ * Actions
+ */
+
if ($action == "getTables")
{
$sql = "SELECT rowid, entity, label, leftpos, toppos, floor FROM ".MAIN_DB_PREFIX."takepos_floor_tables where floor=".$floor;
@@ -81,6 +90,11 @@ if ($action == "add")
$db->query("update ".MAIN_DB_PREFIX."takepos_floor_tables set label=rowid where label=''"); // No empty table names
}
+
+/*
+ * View
+ */
+
// Title
$title = 'TakePOS - Dolibarr '.DOL_VERSION;
if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $title = 'TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE;
diff --git a/htdocs/takepos/freezone.php b/htdocs/takepos/freezone.php
index e8cce00abb3..5e58910928a 100644
--- a/htdocs/takepos/freezone.php
+++ b/htdocs/takepos/freezone.php
@@ -40,6 +40,10 @@ $place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place
$idline = GETPOST('idline', 'int');
$action = GETPOST('action', 'alpha');
+if (empty($user->rights->takepos->run)) {
+ access_forbidden();
+}
+
/*
* View
diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php
index 9685e14ffd8..9615f90d539 100644
--- a/htdocs/takepos/index.php
+++ b/htdocs/takepos/index.php
@@ -263,6 +263,8 @@ function LoadProducts(position, issubcat) {
if (currentcat==val.fk_parent) {
$("#prodivdesc"+ishow).show();
$("#prodesc"+ishow).text(val.label);
+ $("#proprice"+ishow).attr("class", "hidden");
+ $("#proprice"+ishow).html("");
$("#proimg"+ishow).attr("src","genimg/index.php?query=cat&id="+val.rowid);
$("#prodiv"+ishow).data("rowid",val.rowid);
$("#prodiv"+ishow).data("iscat",1);
@@ -281,6 +283,8 @@ function LoadProducts(position, issubcat) {
if (typeof (data[idata]) == "undefined") {
$("#prodivdesc"+ishow).hide();
$("#prodesc"+ishow).text("");
+ $("#proprice"+ishow).attr("class", "hidden");
+ $("#proprice"+ishow).html("");
$("#proimg"+ishow).attr("title","");
$("#proimg"+ishow).attr("src","genimg/empty.png");
$("#prodiv"+ishow).data("rowid","");
@@ -289,9 +293,17 @@ function LoadProducts(position, issubcat) {
ishow++; //Next product to show after print data product
}
else if ((data[idata]['status']) == "1") { // Only show products with status=1 (for sell)
- var titlestring = 'transnoentities('Ref').': '); ?>'+data[idata]['ref'];
+ transnoentities('Ref').': ')."' + data[idata]['ref']";
+ $titlestring .= " + ' - ".dol_escape_js($langs->trans("Barcode").': ')."' + data[idata]['barcode']";
+ ?>
+ var titlestring = ;
$("#prodivdesc"+ishow).show();
$("#prodesc"+ishow).text(data[parseInt(idata)]['label']);
+ if (data[parseInt(idata)]['price_formated']) {
+ $("#proprice"+ishow).attr("class", "productprice");
+ $("#proprice"+ishow).html(data[parseInt(idata)]['price_formated']);
+ }
$("#proimg"+ishow).attr("title", titlestring);
$("#proimg"+ishow).attr("src", "genimg/index.php?query=pro&id="+data[idata]['id']);
$("#prodiv"+ishow).data("rowid", data[idata]['id']);
@@ -337,6 +349,8 @@ function MoreProducts(moreorless) {
if (typeof (data[idata]) == "undefined") {
$("#prodivdesc"+ishow).hide();
$("#prodesc"+ishow).text("");
+ $("#proprice"+ishow).attr("class", "");
+ $("#proprice"+ishow).html("");
$("#proimg"+ishow).attr("src","genimg/empty.png");
$("#prodiv"+ishow).data("rowid","");
ishow++; //Next product to show after print data product
@@ -345,6 +359,10 @@ function MoreProducts(moreorless) {
//Only show products with status=1 (for sell)
$("#prodivdesc"+ishow).show();
$("#prodesc"+ishow).text(data[parseInt(idata)]['label']);
+ if (data[parseInt(idata)]['price_formated']) {
+ $("#proprice"+ishow).attr("class", "productprice");
+ $("#proprice"+ishow).html(data[parseInt(idata)]['price_formated']);
+ }
$("#proimg"+ishow).attr("src","genimg/index.php?query=pro&id="+data[idata]['id']);
$("#prodiv"+ishow).data("rowid",data[idata]['id']);
$("#prodiv"+ishow).data("iscat",0);
@@ -462,7 +480,7 @@ function New() {
* return {void}
*/
function Search2(keyCodeForEnter) {
- console.log("Search2 Call ajax search to replace products");
+ console.log("Search2 Call ajax search to replace products keyCodeForEnter="+keyCodeForEnter);
var search = false;
var eventKeyCode = window.event.keyCode;
@@ -477,20 +495,37 @@ function Search2(keyCodeForEnter) {
for (i = 0; i < ; i++) {
if (typeof (data[i]) == "undefined") {
$("#prodesc" + i).text("");
+ $("#proprice" + i).attr("class", "hidden");
+ $("#proprice" + i).html("");
$("#proimg" + i).attr("src", "genimg/empty.png");
$("#prodiv" + i).data("rowid", "");
continue;
}
- var titlestring = 'transnoentities('Ref').': '); ?>' + data[i]['ref'];
+ transnoentities('Ref').': ')."' + data[i]['ref']";
+ $titlestring .= " + ' - ".dol_escape_js($langs->trans("Barcode").': ')."' + data[i]['barcode']";
+ ?>
+ var titlestring = ;
$("#prodesc" + i).text(data[i]['label']);
$("#prodivdesc" + i).show();
+ if (data[i]['price_formated']) {
+ $("#proprice" + i).attr("class", "productprice");
+ $("#proprice" + i).html(data[i]['price_formated']);
+ }
$("#proimg" + i).attr("title", titlestring);
$("#proimg" + i).attr("src", "genimg/index.php?query=pro&id=" + data[i]['rowid']);
$("#prodiv" + i).data("rowid", data[i]['rowid']);
$("#prodiv" + i).data("iscat", 0);
}
}).always(function (data) {
- if ($('#search').val().length > 0 && data.length == 1) ClickProduct(0);
+ // If there is only 1 answer
+ if ($('#search').val().length > 0 && data.length == 1) {
+ console.log($('#search').val()+' - '+data[0]['barcode']);
+ if ($('#search').val() == data[0]['barcode']) {
+ console.log("There is only 1 answer with barcode matching the search, so we add the product in basket");
+ ClickProduct(0);
+ }
+ }
});
}
}
@@ -924,15 +959,16 @@ if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
';
- echo '';
+ print '';
}
elseif ($count == ($MAXPRODUCT - 1)) {
//echo '
';
- echo '';
+ print '';
}
else
{
- echo '';
+ print '