NEW Add product on key "Enter" in search bar

This commit is contained in:
VESSILLER 2020-02-24 13:57:36 +01:00
parent b55f6f8658
commit 73da62d842
4 changed files with 22 additions and 6 deletions

View File

@ -1688,6 +1688,7 @@ StockDecreaseForPointOfSaleDisabledbyBatch=Stock decrease in POS is not compatib
CashDeskYouDidNotDisableStockDecease=You did not disable stock decrease when making a sale from Point of Sale. Hence a warehouse is required.
CashDeskForceDecreaseStockLabel=Stock decrease for batch products was forced.
CashDeskForceDecreaseStockDesc=Decrease first by the oldest eatby and sellby dates.
CashDeskReaderKeyCodeForEnter=Key code for "Enter" defined in barcode reader.
##### Bookmark #####
BookmarkSetup=Bookmark module setup
BookmarkDesc=This module allows you to manage bookmarks. You can also add shortcuts to any Dolibarr pages or external web sites on your left menu.

View File

@ -1685,6 +1685,7 @@ StockDecreaseForPointOfSaleDisabledbyBatch=La décrémentation de stock depuis c
CashDeskYouDidNotDisableStockDecease=Vous n'avez pas désactivé la réduction de stock lors d'une vente depuis le Point de vente. Par conséquent, un entrepôt est nécessaire.
CashDeskForceDecreaseStockLabel=Décrémentation des stocks pour les lots a été forcé.
CashDeskForceDecreaseStockDesc=Décrémentation des lots par DLC et DLUO les plus anciennes.
CashDeskReaderKeyCodeForEnter=Code pour la touche "Entrée" du lecteur de codes à barres.
##### Bookmark #####
BookmarkSetup=Configuration du module Marque-pages
BookmarkDesc=Ce module vous permet de gérer des liens et raccourcis. Il permet aussi d'ajouter n'importe quelle page de Dolibarr ou lien web dans le menu d'accès rapide sur la gauche.

View File

@ -88,6 +88,8 @@ if (GETPOST('action', 'alpha') == 'set')
$res = dolibarr_set_const($db, "TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES".$terminaltouse, GETPOST('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS".$terminaltouse, GETPOST('TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, 'CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse, (GETPOST('CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse, 'int') > 0 ? GETPOST('CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse, 'int') : ''), 'chaine', 0, '', $conf->entity);
dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha'));
if (!$res > 0) $error++;
@ -244,6 +246,11 @@ if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter") {
print '</td></tr>';
}
print '<tr class="oddeven"><td>' . $langs->trans('CashDeskReaderKeyCodeForEnter') . '</td>';
print '<td>';
print '<input type="text" name="' . 'CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse . '" value="' . $conf->global->{'CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse} . '" />';
print '</td></tr>';
print '</table>';
print '</div>';

View File

@ -438,9 +438,15 @@ function New() {
}
}
function Search2() {
/**
* Search products
*
* @param {int} keyCodeForEnter Key code for "enter"
* return {void}
*/
function Search2(keyCodeForEnter) {
console.log("Search2 Call ajax search to replace products");
if(window.event.keyCode == 13) var key=13;
if(window.event.keyCode == keyCodeForEnter) var key=13;
pageproducts=0;
jQuery(".wrapper2 .catwatermark").hide();
$.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=search&term='+$('#search').val(), function(data) {
@ -459,8 +465,8 @@ function Search2() {
$("#prodiv"+i).data("rowid", data[i]['rowid']);
$("#prodiv"+i).data("iscat", 0);
}
}).always(function() {
if(key==13) ClickProduct(0);
}).always(function(data) {
if(key==13 && data.length==1) ClickProduct(0);
});
}
@ -649,6 +655,7 @@ $( document ).ready(function() {
<body class="bodytakepos" style="overflow: hidden;">
<?php
if ($conf->global->TAKEPOS_NUM_TERMINALS != "1" && $_SESSION["takeposterminal"] == "") print '<div id="dialog-info" title="TakePOS">'.$langs->trans('TerminalSelect').'</div>';
$keyCodeForEnter = $conf->global->{'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION['takeposterminal']} > 0 ? $conf->global->{'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION['takeposterminal']} : 13;
?>
<div class="container">
@ -667,7 +674,7 @@ if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
<a onclick="Customer();"><?php echo $langs->trans("Customer"); ?></a>
</div>
<div class="topnav-right">
<input type="text" id="search" name="search" onkeyup="Search2();" placeholder="<?php echo $langs->trans("Search"); ?>" autofocus>
<input type="text" id="search" name="search" onkeyup="Search2(<?php echo $keyCodeForEnter; ?>);" placeholder="<?php echo $langs->trans("Search"); ?>" autofocus>
<a onclick="ClearSearch();"><span class="fa fa-backspace"></span></a>
<a onclick="window.location.href='<?php echo DOL_URL_ROOT; ?>';"><span class="fas fa-sign-out-alt"></span></a>
<a onclick="window.location.href='<?php echo DOL_URL_ROOT; ?>/user/logout.php';"><span class="fas fa-user"></span></a>
@ -828,7 +835,7 @@ if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
print '<!-- Show the search input text -->'."\n";
print '<div class="margintoponly">';
print '<input type="text" id="search" name="search" onkeyup="Search2();" style="width:80%;width:calc(100% - 51px);font-size: 150%;" placeholder="'.$langs->trans("Search").'" autofocus> ';
print '<input type="text" id="search" name="search" onkeyup="Search2('.$keyCodeForEnter.');" style="width:80%;width:calc(100% - 51px);font-size: 150%;" placeholder="'.$langs->trans("Search").'" autofocus> ';
print '<a class="marginleftonly hideonsmartphone" onclick="ClearSearch();">'.img_picto('', 'searchclear').'</a>';
print '</div>';
}