X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=js%2Fkivi.AP.js;h=463334ab1dab504540d20bfef270acd3b5a6fe48;hb=a5038d8dfae7d3a5ad27f1fb4f219b347bb2c91c;hp=55c164fd9ab7b567fa43c5b5e1b5a80590243462;hpb=4507456b19be280448043993939fa8657e8a046c;p=kivitendo-erp.git diff --git a/js/kivi.AP.js b/js/kivi.AP.js index 55c164fd9..463334ab1 100644 --- a/js/kivi.AP.js +++ b/js/kivi.AP.js @@ -4,7 +4,9 @@ namespace('kivi.AP', function(ns){ ns.check_fields_before_posting = function() { var errors = []; - if ($('#transdate').val() === '') + // if the element transdate exists, we have a AP form otherwise we have to check the invoice form + var invoice_date = ($('#transdate').length === 0) ? $('#transdate').val() : $('#invdate').val(); + if (invoice_date === '') errors.push(kivi.t8('Invoice Date missing!')); if ($('#duedate').val() === '') @@ -13,7 +15,7 @@ namespace('kivi.AP', function(ns){ if ($('#invnumber').val() === '') errors.push(kivi.t8('Invoice Number missing!')); - if ($('#vendor').val() === '') + if ($('#vendor_id').val() === '') errors.push(kivi.t8('Vendor missing!')); if (errors.length === 0) @@ -23,4 +25,29 @@ namespace('kivi.AP', function(ns){ return false; }; + + ns.check_duplicate_invnumber = function() { + var exists_invnumber = false; + + $.ajax({ + url: 'controller.pl', + data: { action: 'SalesPurchase/check_duplicate_invnumber', + vendor_id : $('#vendor_id').val(), + invnumber : $('#invnumber').val() + }, + method: "GET", + async: false, + dataType: 'text', + success: function(val) { + exists_invnumber = val; + } + }); + + if (exists_invnumber == 1) { + return confirm(kivi.t8('This vendor has already a booking with this invoice number, do you really want to add the same invoice number again?')); + } + + return true; + }; + });