X-Git-Url: http://wagnertech.de/git?p=kivitendo-erp.git;a=blobdiff_plain;f=SL%2FController%2FSalesPurchase.pm;fp=SL%2FController%2FSalesPurchase.pm;h=ab31b8c65e88b91db239eaceddd9540ace253d29;hp=0000000000000000000000000000000000000000;hb=53593baa211863fbf66540cf1bcc36c8fb37257f;hpb=deb4d2dbb676d7d6f69dfe7815d6e0cb09bd4a44 diff --git a/SL/Controller/SalesPurchase.pm b/SL/Controller/SalesPurchase.pm new file mode 100644 index 000000000..ab31b8c65 --- /dev/null +++ b/SL/Controller/SalesPurchase.pm @@ -0,0 +1,70 @@ +package SL::Controller::SalesPurchase; + +use strict; +use parent qw(SL::Controller::Base); + +use SL::DB::PurchaseInvoice; +use Carp; + + +sub action_check_duplicate_invnumber { + my ($self) = @_; + + croak("no invnumber") unless $::form->{invnumber}; + croak("no vendor") unless $::form->{vendor_id}; + + my $exists_ap = SL::DB::Manager::PurchaseInvoice->find_by( + invnumber => $::form->{invnumber}, + vendor_id => $::form->{vendor_id}, + ); + # we are modifying a existing daily booking - allow this if + # booking conditions are not super strict + undef $exists_ap if ($::instance_conf->get_ap_changeable != 0 + && $exists_ap->gldate == DateTime->today_local); + + + $_[0]->render(\ !!$exists_ap, { type => 'text' }); +} + +1; + +=pod + +=encoding utf8 + +=head1 NAME + +SL::Controller::SalesPurchase - Controller for JS driven actions + +=head2 OVERVIEW + +Generic Controller Class for validation function + +=head1 FUNCTIONS + +=over 2 + +=item C + +Needs C and C + +Returns true if a credit record with this invnumber for this vendor +already exists. + +Example usage (js): + + $.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; + } + }); + +=back