Browse Source

More log and use id to refresh/reload an invoice.

Laurent Destailleur 4 years ago
parent
commit
d46eb08083
2 changed files with 16 additions and 6 deletions
  1. 3 2
      htdocs/takepos/index.php
  2. 13 4
      htdocs/takepos/invoice.php

+ 3 - 2
htdocs/takepos/index.php

@@ -155,6 +155,7 @@ var pageactions=0;
 var place="<?php echo $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);
 	});
 }

+ 13 - 4
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=<?php echo $placeid; ?> status=<?php echo $invoice->statut; ?>");
 
     <?php
     $s = $langs->trans("Customer");
@@ -757,7 +757,14 @@ $( document ).ready(function() {
 
 	<?php
 	$sql = "SELECT rowid, datec, ref FROM ".MAIN_DB_PREFIX."facture";
-	$sql .= " WHERE ref LIKE '(PROV-POS".$_SESSION["takeposterminal"]."-0%'";
+	if (empty($conf->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 "<b>";
 			echo dol_print_date($db->jdate($obj->datec), '%H:%M', 'tzuser');
 			if ($placeid == $obj->rowid) echo "</b>";
@@ -775,7 +784,7 @@ $( document ).ready(function() {
 		}
 		echo '$("#customerandsales").append(\'<a onclick="place=\\\'0-';
 		echo $max_sale + 1;
-		echo '\\\';Refresh();"><span class="fa fa-plus-square" title="'.dol_escape_htmltag($langs->trans("StartAParallelSale")).'"></a>\');';
+		echo '\\\'; invoiceid=0; Refresh();"><span class="fa fa-plus-square" title="'.dol_escape_htmltag($langs->trans("StartAParallelSale")).'"></a>\');';
 	} else {
 		dol_print_error($db);
 	}