diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 6ce0dfcf88e..53f32ff48af 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -120,4 +120,13 @@ elseif ($action == 'search' && $term != '') { $object->fetch($id); $ret = $printer->sendToPrinter($object, $conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$term}, $conf->global->{'TAKEPOS_PRINTER_TO_USE'.$term}); } +} elseif ($action == 'getInvoice') { + require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; + + $object = new Facture($db); + if ($id > 0) { + $object->fetch($id); + } + + echo json_encode($object); } diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index 8d4f8f929c8..a19d421bb29 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -429,13 +429,24 @@ function Refresh() { function New() { // If we go here,it means $conf->global->TAKEPOS_BAR_RESTAURANT is not defined console.log("New with place = , js place="+place); - var r = confirm(' 0 ? $langs->transnoentitiesnoconv("ConfirmDeletionOfThisPOSSale") : $langs->transnoentitiesnoconv("ConfirmDiscardOfThisPOSSale")); ?>'); - if (r == true) { - $("#poslines").load("invoice.php?action=delete&place="+place, function() { - //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); - }); - ClearSearch(); - } + + invoiceid = $("#invoiceid").val(); + $.getJSON('/takepos/ajax/ajax.php?action=getInvoice&id='+invoiceid, function(data) { + var r; + + if (parseInt(data['paye']) === 1) { + r = true; + } else { + r = confirm(' 0 ? $langs->transnoentitiesnoconv("ConfirmDeletionOfThisPOSSale") : $langs->transnoentitiesnoconv("ConfirmDiscardOfThisPOSSale")); ?>'); + } + + if (r == true) { + $("#poslines").load("invoice.php?action=delete&place=" + place, function () { + //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); + }); + ClearSearch(); + } + }); } /**