Add protection to avoid change on a non draft invoice.
This commit is contained in:
Laurent Destailleur 2019-08-27 15:39:35 +02:00
parent 478b1fea25
commit 7165389f6c
2 changed files with 12 additions and 6 deletions

View File

@ -138,7 +138,9 @@ if ($action == 'valid' && $user->rights->facture->creer)
if (! empty($conf->stock->enabled) && $conf->global->{'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]} != "1")
{
$invoice->validate($user, '', $conf->global->{'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]});
$constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"];
dol_syslog("Validate invoice with stock change into warehouse id ".$constantforkey);
$invoice->validate($user, '', $conf->global->$cosntantforkey);
}
else
{
@ -259,10 +261,13 @@ if ($action == "deleteline") {
}
if ($action == "delete") {
if ($placeid > 0) { //If invoice exists
// $placeid is the invoice id (it differs from place) and is defined if the place is set and the ref of invoice is '(PROV-POS'.$_SESSION["takeposterminal"].'-'.$place.')', so the fetch at begining of page works.
if ($placeid > 0) {
$result = $invoice->fetch($placeid);
if ($result > 0)
if ($result > 0 && $invoice->statut == Facture::STATUS_DRAFT)
{
// We delete the lines
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "facturedet where fk_facture='".$placeid."'";
$resql = $db->query($sql);

View File

@ -391,8 +391,9 @@ function Refresh() {
}
function New() {
console.log("New");
var r = confirm('<?php echo $langs->trans("ConfirmDeletionOfThisPOSSale"); ?>');
// If we go here,it means $conf->global->TAKEPOS_BAR_RESTAURANT is not defined
console.log("New with place = <?php echo $place; ?>, js place="+place);
var r = confirm('<?php echo ($place > 0 ? $langs->trans("ConfirmDeletionOfThisPOSSale") : $langs->trans("ConfirmDiscardOfThisPOSSale")); ?>');
if (r == true) {
$("#poslines").load("invoice.php?action=delete&place="+place, function() {
//$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
@ -651,7 +652,7 @@ if (empty($conf->global->TAKEPOS_BAR_RESTAURANT))
else
{
// BAR RESTAURANT specific menu
$menus[$r++]=array('title'=>'<span class="fa fa-layer-group paddingrightonly"></span><div class="trunc">'.$langs->trans("Floors").'</div>', 'action'=>'Floors();');
$menus[$r++]=array('title'=>'<span class="fa fa-layer-group paddingrightonly"></span><div class="trunc">'.$langs->trans("Place").'</div>', 'action'=>'Floors();');
}
$menus[$r++]=array('title'=>'<span class="far fa-building paddingrightonly"></span><div class="trunc">'.$langs->trans("Customer").'</div>', 'action'=>'Customer();');