Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 7e4a1765

Von Bernd Bleßmann vor fast 2 Jahren hinzugefügt

  • ID 7e4a17657742a65bb69c79136a4f5b1aeb2a3712
  • Vorgänger 57657390
  • Nachfolger ec03bff2

Gültigkeitstoken in Transaction abfragen und löschen: "alte" Controller

Lieferscheine
Einkaufsrechnung
Verkaufsrechnung
Kreditorenbuchung
Debitorenbuchung
Dialogbuchung

Unterschiede anzeigen:

SL/AP.pm
44 44
use SL::DB::Draft;
45 45
use SL::DB::Order;
46 46
use SL::DB::PurchaseInvoice;
47
use SL::DB::ValidityToken;
47 48
use SL::Util qw(trim);
48 49
use SL::DB;
49 50
use Data::Dumper;
......
63 64
sub _post_transaction {
64 65
  my ($self, $myconfig, $form, $provided_dbh, %params) = @_;
65 66

  
67
  my $validity_token;
68
  if (!$form->{id}) {
69
    $validity_token = SL::DB::Manager::ValidityToken->fetch_valid_token(
70
      scope => SL::DB::ValidityToken::SCOPE_PURCHASE_INVOICE_POST(),
71
      token => $form->{form_validity_token},
72
    );
73

  
74
    die $::locale->text('The form is not valid anymore.') if !$validity_token;
75
  }
76

  
66 77
  my $payments_only = $params{payments_only};
67 78
  my $dbh = $provided_dbh || SL::DB->client->dbh;
68 79

  
......
431 442
    }
432 443
  }
433 444

  
445
  $validity_token->delete if $validity_token;
446
  delete $form->{form_validity_token};
447

  
434 448
  return 1;
435 449
}
436 450

  
SL/AR.pm
42 42
use SL::IO;
43 43
use SL::MoreCommon;
44 44
use SL::DB::Default;
45
use SL::DB::ValidityToken;
45 46
use SL::TransNumber;
46 47
use SL::Util qw(trim);
47 48
use SL::DB;
......
61 62
sub _post_transaction {
62 63
  my ($self, $myconfig, $form, $provided_dbh, %params) = @_;
63 64

  
65
  my $validity_token;
66
  if (!$form->{id}) {
67
    $validity_token = SL::DB::Manager::ValidityToken->fetch_valid_token(
68
      scope => SL::DB::ValidityToken::SCOPE_SALES_INVOICE_POST(),
69
      token => $form->{form_validity_token},
70
    );
71

  
72
    die $::locale->text('The form is not valid anymore.') if !$validity_token;
73
  }
74

  
64 75
  my $payments_only = $params{payments_only};
65 76

  
66 77
  my ($query, $sth, $null, $taxrate, $amount, $tax);
......
351 362
    }
352 363
  }
353 364

  
365
  $validity_token->delete if $validity_token;
366
  delete $form->{form_validity_token};
367

  
354 368
  return 1;
355 369
}
356 370

  
SL/DO.pm
44 44
use SL::DB::DeliveryOrder;
45 45
use SL::DB::DeliveryOrder::TypeData qw(:types is_valid_type);
46 46
use SL::DB::Status;
47
use SL::DB::ValidityToken;
47 48
use SL::DBUtils;
48 49
use SL::Helper::ShippedQty;
49 50
use SL::HTML::Restrict;
......
330 331
  my $myconfig = \%main::myconfig;
331 332
  my $form     = $main::form;
332 333

  
334
  my $validity_token;
335
  if (!$form->{id}) {
336
    $validity_token = SL::DB::Manager::ValidityToken->fetch_valid_token(
337
      scope => SL::DB::ValidityToken::SCOPE_DELIVERY_ORDER_SAVE(),
338
      token => $form->{form_validity_token},
339
    );
340

  
341
    die $::locale->text('The form is not valid anymore.') if !$validity_token;
342
  }
343

  
333 344
  my $dbh = SL::DB->client->dbh;
334 345
  my $restricter = SL::HTML::Restrict->create;
335 346

  
......
606 617

  
607 618
  Common::webdav_folder($form);
608 619

  
620
  $validity_token->delete if $validity_token;
621
  delete $form->{form_validity_token};
622

  
609 623
  $main::lxdebug->leave_sub();
610 624

  
611 625
  return 1;
SL/GL.pm
46 46
use SL::DBUtils;
47 47
use SL::DB::Chart;
48 48
use SL::DB::Draft;
49
use SL::DB::ValidityToken;
49 50
use SL::Util qw(trim);
50 51
use SL::DB;
51 52

  
......
77 78
  my ($self, $myconfig, $form) = @_;
78 79
  $main::lxdebug->enter_sub();
79 80

  
81
  my $validity_token;
82
  if (!$form->{id}) {
83
    $validity_token = SL::DB::Manager::ValidityToken->fetch_valid_token(
84
      scope => SL::DB::ValidityToken::SCOPE_GL_TRANSACTION_POST(),
85
      token => $form->{form_validity_token},
86
    );
87

  
88
    die $::locale->text('The form is not valid anymore.') if !$validity_token;
89
  }
90

  
80 91
  my ($debit, $credit) = (0, 0);
81 92
  my $project_id;
82 93

  
......
213 224
    }
214 225
  }
215 226

  
227
  $validity_token->delete if $validity_token;
228
  delete $form->{form_validity_token};
229

  
216 230
  return 1;
217 231
}
218 232

  
SL/IR.pm
51 51
use SL::DB::Default;
52 52
use SL::DB::TaxZone;
53 53
use SL::DB::MakeModel;
54
use SL::DB::ValidityToken;
54 55
use SL::DB;
55 56
use SL::Presenter::Part qw(type_abbreviation classification_abbreviation);
56 57
use List::Util qw(min);
......
73 74
sub _post_invoice {
74 75
  my ($self, $myconfig, $form, $provided_dbh, %params) = @_;
75 76

  
77
  my $validity_token;
78
  if (!$form->{id}) {
79
    $validity_token = SL::DB::Manager::ValidityToken->fetch_valid_token(
80
      scope => SL::DB::ValidityToken::SCOPE_PURCHASE_INVOICE_POST(),
81
      token => $form->{form_validity_token},
82
    );
83

  
84
    die $::locale->text('The form is not valid anymore.') if !$validity_token;
85
  }
86

  
76 87
  my $payments_only = $params{payments_only};
77 88
  my $dbh = $provided_dbh || SL::DB->client->dbh;
78 89
  my $restricter = SL::HTML::Restrict->create;
......
854 865
    }
855 866
  }
856 867

  
868
  $validity_token->delete if $validity_token;
869
  delete $form->{form_validity_token};
870

  
857 871
  return 1;
858 872
}
859 873

  
SL/IS.pm
61 61
use SL::DB::Draft;
62 62
use SL::DB::Tax;
63 63
use SL::DB::TaxZone;
64
use SL::DB::ValidityToken;
64 65
use SL::TransNumber;
65 66
use SL::DB;
66 67
use SL::Presenter::Part qw(type_abbreviation classification_abbreviation);
......
761 762
sub _post_invoice {
762 763
  my ($self, $myconfig, $form, $provided_dbh, %params) = @_;
763 764

  
765
  my $validity_token;
766
  if (!$form->{id}) {
767
    $validity_token = SL::DB::Manager::ValidityToken->fetch_valid_token(
768
      scope => SL::DB::ValidityToken::SCOPE_SALES_INVOICE_POST(),
769
      token => $form->{form_validity_token},
770
    );
771

  
772
    die $::locale->text('The form is not valid anymore.') if !$validity_token;
773
  }
774

  
764 775
  my $payments_only = $params{payments_only};
765 776
  my $dbh = $provided_dbh || SL::DB->client->dbh;
766 777
  my $restricter = SL::HTML::Restrict->create;
......
1681 1692
    $shop->connector->set_orderstatus($shop_order->shop_trans_id, "completed");
1682 1693
  }
1683 1694

  
1695
  $validity_token->delete if $validity_token;
1696
  delete $form->{form_validity_token};
1697

  
1684 1698
  return 1;
1685 1699
}
1686 1700

  
bin/mozilla/ap.pl
814 814
  $main::auth->assert('ap_transactions');
815 815
  $form->mtime_ischanged('ap');
816 816

  
817
  my $validity_token;
818
  if (!$form->{id}) {
819
    $validity_token = SL::DB::Manager::ValidityToken->fetch_valid_token(
820
      scope => SL::DB::ValidityToken::SCOPE_PURCHASE_INVOICE_POST(),
821
      token => $form->{form_validity_token},
822
    );
823

  
824
    $form->error($::locale->text('The form is not valid anymore.')) if !$validity_token;
825
  }
826

  
827 817
  my ($inline) = @_;
828 818

  
829 819
  # check if there is a vendor, invoice, due date and invnumber
......
905 895
  $form->{id} = 0 if $form->{postasnew};
906 896

  
907 897
  if (AP->post_transaction(\%myconfig, \%$form)) {
908
    $validity_token->delete if $validity_token;
909
    delete $form->{form_validity_token};
910

  
911 898
    # create webdav folder
912 899
    if ($::instance_conf->get_webdav) {
913 900
      SL::Webdav->new(type     => 'accounts_payable',
bin/mozilla/ar.pl
779 779

  
780 780
  $form->mtime_ischanged('ar');
781 781

  
782
  my $validity_token;
783
  if (!$form->{id}) {
784
    $validity_token = SL::DB::Manager::ValidityToken->fetch_valid_token(
785
      scope => SL::DB::ValidityToken::SCOPE_SALES_INVOICE_POST(),
786
      token => $form->{form_validity_token},
787
    );
788

  
789
    $form->error($::locale->text('The form is not valid anymore.')) if !$validity_token;
790
  }
791

  
792 782
  my ($datepaid);
793 783

  
794 784
  # check if there is an invoice number, invoice and due date
......
854 844
  $form->{id} = 0 if $form->{postasnew};
855 845
  $form->error($locale->text('Cannot post transaction!')) unless AR->post_transaction(\%myconfig, \%$form);
856 846

  
857
  $validity_token->delete if $validity_token;
858
  delete $form->{form_validity_token};
859

  
860 847
  # saving the history
861 848
  if(!exists $form->{addition} && $form->{id} ne "") {
862 849
    $form->{snumbers}  = "invnumber_$form->{invnumber}";
bin/mozilla/do.pl
991 991

  
992 992
  $form->mtime_ischanged('delivery_orders');
993 993

  
994
  my $validity_token;
995
  if (!$form->{id}) {
996
    $validity_token = SL::DB::Manager::ValidityToken->fetch_valid_token(
997
      scope => SL::DB::ValidityToken::SCOPE_DELIVERY_ORDER_SAVE(),
998
      token => $form->{form_validity_token},
999
    );
1000

  
1001
    $form->error($::locale->text('The form is not valid anymore.')) if !$validity_token;
1002
  }
1003

  
1004 994
  $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
1005 995

  
1006 996
  $form->isblank("transdate", $locale->text('Delivery Order Date missing!'));
......
1039 1029
    $::dispatcher->end_request;
1040 1030
  }
1041 1031

  
1042
  $form->{id} = 0 if $form->{saveasnew};
1032
  if ($form->{saveasnew}) {
1033
    $form->{id}                  = 0;
1034
    $form->{form_validity_token} = SL::DB::ValidityToken->create(scope => SL::DB::ValidityToken::SCOPE_DELIVERY_ORDER_SAVE())->token;
1035
  }
1036

  
1043 1037
  # we rely on converted_from_orderitems, if the workflow is used
1044 1038
  # be sure that at least one position is linked to the original orderitem
1045 1039
  if ($form->{convert_from_oe_ids}) {
......
1056 1050
  }
1057 1051
  DO->save();
1058 1052

  
1059
  $validity_token->delete if $validity_token;
1060
  delete $form->{form_validity_token};
1061

  
1062 1053
  # saving the history
1063 1054
  if(!exists $form->{addition}) {
1064 1055
    $form->{snumbers} = qq|donumber_| . $form->{donumber};
bin/mozilla/gl.pl
1456 1456
  my $form     = $main::form;
1457 1457
  my $locale   = $main::locale;
1458 1458

  
1459
  my $validity_token;
1460
  if (!$form->{id}) {
1461
    $validity_token = SL::DB::Manager::ValidityToken->fetch_valid_token(
1462
      scope => SL::DB::ValidityToken::SCOPE_GL_TRANSACTION_POST(),
1463
      token => $form->{form_validity_token},
1464
    );
1465

  
1466
    $form->error($::locale->text('The form is not valid anymore.')) if !$validity_token;
1467
  }
1468

  
1469 1459
  if ($::myconfig{mandatory_departments} && !$form->{department_id}) {
1470 1460
    $form->error($locale->text('You have to specify a department.'));
1471 1461
  }
......
1475 1465

  
1476 1466
  post_transaction();
1477 1467

  
1478
  # If we get here, the transaction is posted.
1479
  $validity_token->delete if $validity_token;
1480
  delete $form->{form_validity_token};
1481

  
1482 1468
  if ($::instance_conf->get_webdav) {
1483 1469
    SL::Webdav->new(type     => 'general_ledger',
1484 1470
                    number   => $form->{id},
bin/mozilla/ir.pl
954 954

  
955 955
  $form->mtime_ischanged('ap');
956 956

  
957
  my $validity_token;
958
  if (!$form->{id}) {
959
    $validity_token = SL::DB::Manager::ValidityToken->fetch_valid_token(
960
      scope => SL::DB::ValidityToken::SCOPE_PURCHASE_INVOICE_POST(),
961
      token => $form->{form_validity_token},
962
    );
963

  
964
    $form->error($::locale->text('The form is not valid anymore.')) if !$validity_token;
965
  }
966

  
967 957
  $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
968 958

  
969 959
  $form->isblank("invdate",   $locale->text('Invoice Date missing!'));
......
1035 1025

  
1036 1026
  relink_accounts();
1037 1027
  if (IR->post_invoice(\%myconfig, \%$form)){
1038

  
1039
    $validity_token->delete if $validity_token;
1040
    delete $form->{form_validity_token};
1041

  
1042 1028
    # saving the history
1043 1029
    if(!exists $form->{addition} && $form->{id} ne "") {
1044 1030
      $form->{snumbers}  = qq|invnumber_| . $form->{invnumber};
bin/mozilla/is.pl
1063 1063
  $main::auth->assert('invoice_edit');
1064 1064
  $form->mtime_ischanged('ar');
1065 1065

  
1066
  my $validity_token;
1067
  if (!$form->{id}) {
1068
    $validity_token = SL::DB::Manager::ValidityToken->fetch_valid_token(
1069
      scope => SL::DB::ValidityToken::SCOPE_SALES_INVOICE_POST(),
1070
      token => $form->{form_validity_token},
1071
    );
1072

  
1073
    $form->error($::locale->text('The form is not valid anymore.')) if !$validity_token;
1074
  }
1075

  
1076 1066
  $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
1077 1067
  $form->isblank("invdate",  $locale->text('Invoice Date missing!'));
1078 1068
  $form->isblank("customer_id", $locale->text('Customer missing!'));
......
1205 1195
    }
1206 1196
  }
1207 1197

  
1208
  $validity_token->delete if $validity_token;
1209
  delete $form->{form_validity_token};
1210

  
1211 1198
  if(!exists $form->{addition}) {
1212 1199
    $form->{snumbers}  =  'invnumber' .'_'. $form->{invnumber}; # ($form->{type} eq 'credit_note' ? 'cnnumber' : 'invnumber') .'_'. $form->{invnumber};
1213 1200
    $form->{what_done} = 'invoice';

Auch abrufbar als: Unified diff