diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php
index 4bfeaa57b75..51b6334a2c9 100644
--- a/htdocs/takepos/index.php
+++ b/htdocs/takepos/index.php
@@ -155,6 +155,7 @@ var pageactions=0;
var place="";
var editaction="qty";
var editnumber="";
+var invoiceid=0;
/*
var app = this;
@@ -448,8 +449,8 @@ function TakeposOrderNotes() {
}
function Refresh() {
- console.log("Refresh by reloading place="+place);
- $("#poslines").load("invoice.php?place="+place, function() {
+ console.log("Refresh by reloading place="+place+" invoiceid="+invoiceid);
+ $("#poslines").load("invoice.php?place="+place+"&invoiceid="+invoiceid, function() {
//$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
});
}
diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php
index 0909f1b3cca..f31bb90bfcd 100644
--- a/htdocs/takepos/invoice.php
+++ b/htdocs/takepos/invoice.php
@@ -742,7 +742,7 @@ function DolibarrTakeposPrinting(id) {
$( document ).ready(function() {
- console.log("Set customer info and sales in header");
+ console.log("Set customer info and sales in header placeid= status=statut; ?>");
trans("Customer");
@@ -757,7 +757,14 @@ $( document ).ready(function() {
global->TAKEPOS_CAN_EDIT_IF_ALREADY_VALIDATED)) {
+ // By default, only invoices with a ref not already defined can in list of open invoice we can edit.
+ $sql .= " WHERE ref LIKE '(PROV-POS".$_SESSION["takeposterminal"]."-0%'";
+ } else {
+ // If TAKEPOS_CAN_EDIT_IF_ALREADY_VALIDATED set, we show also draft invoice that already has a reference defined
+ $sql .= " WHERE pos_source = ".$_SESSION["takeposterminal"];
+ $sql .= " AND module_source = 'takepos'";
+ }
$sql .= $db->order('datec', 'ASC');
$resql = $db->query($sql);
if ($resql) {
@@ -767,7 +774,9 @@ $( document ).ready(function() {
$num_sale = str_replace(")", "", str_replace("(PROV-POS".$_SESSION["takeposterminal"]."-", "", $obj->ref));
echo $num_sale;
if (str_replace("-", "", $num_sale) > $max_sale) $max_sale = str_replace("-", "", $num_sale);
- echo '\\\';Refresh();">';
+ echo '\\\'; invoiceid=\\\'';
+ echo $obj->rowid;
+ echo '\\\'; Refresh();">';
if ($placeid == $obj->rowid) echo "";
echo dol_print_date($db->jdate($obj->datec), '%H:%M', 'tzuser');
if ($placeid == $obj->rowid) echo "";
@@ -775,7 +784,7 @@ $( document ).ready(function() {
}
echo '$("#customerandsales").append(\'\');';
+ echo '\\\'; invoiceid=0; Refresh();">\');';
} else {
dol_print_error($db);
}