Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 013fdb49

Von Sven Schöling vor etwa 3 Jahren hinzugefügt

  • ID 013fdb495a2cac764df23c9ec0b455ffc5b9323e
  • Vorgänger a14dfdf8
  • Nachfolger 45ea642b

do: beistell und rma Lieferscheine

Unterschiede anzeigen:

bin/mozilla/do.pl
37 37
use POSIX qw(strftime);
38 38

  
39 39
use SL::DB::DeliveryOrder;
40
use SL::DB::DeliveryOrder::TypeData qw(:types);
40 41
use SL::DO;
41 42
use SL::IR;
42 43
use SL::IS;
......
56 57
# end of main
57 58

  
58 59
sub check_do_access {
59
  $main::auth->assert($main::form->{type} . '_edit');
60
  $main::auth->assert(access($main::form->{type}));
60 61
}
61 62

  
62 63
sub set_headings {
......
69 70
  my $form     = $main::form;
70 71
  my $locale   = $main::locale;
71 72

  
72
  if ($form->{type} eq 'purchase_delivery_order') {
73
    $form->{vc}    = 'vendor';
74
    $form->{title} = $action eq "edit" ? $locale->text('Edit Purchase Delivery Order') : $locale->text('Add Purchase Delivery Order');
75
  } else {
76
    $form->{vc}    = 'customer';
77
    $form->{title} = $action eq "edit" ? $locale->text('Edit Sales Delivery Order') : $locale->text('Add Sales Delivery Order');
78
  }
73
  $form->{vc} = customervendor($form->{type});
74
  $form->{title} = text($form->{type}, $action eq "edit" ? "edit" : "add");
79 75

  
80 76
  $form->{heading} = $locale->text('Delivery Order');
81 77

  
......
87 83

  
88 84
  check_do_access();
89 85

  
90
  if (($::form->{type} =~ /purchase/) && !$::instance_conf->get_allow_new_purchase_invoice) {
86
  if (($::form->{type} eq PURCHASE_DELIVERY_ORDER_TYPE) && !$::instance_conf->get_allow_new_purchase_invoice) {
91 87
    $::form->show_generic_error($::locale->text("You do not have the permissions to access this function."));
92 88
  }
93 89

  
......
336 332
        t8('Invoice'),
337 333
        submit => [ '#form', { action => "invoice" } ],
338 334
        disabled => !$::form->{id} ? t8('This record has not been saved yet.') : undef,
339
        confirm  => $::form->{delivered}                                                                         ? undef
340
                  : ($::form->{vc} eq 'customer' && $::instance_conf->get_sales_delivery_order_check_stocked)    ? t8('This record has not been stocked out. Proceed?')
341
                  : ($::form->{vc} eq 'vendor'   && $::instance_conf->get_purchase_delivery_order_check_stocked) ? t8('This record has not been stocked in. Proceed?')
342
                  :                                                                                                undef,
335
        confirm  => $::form->{delivered}                                                                                        ? undef
336
                  : transfer_direction($::form->{type}) eq 'out' && $::instance_conf->get_sales_delivery_order_check_stocked    ? t8('This record has not been stocked out. Proceed?')
337
                  : transfer_direction($::form->{type}) eq 'in'  && $::instance_conf->get_purchase_delivery_order_check_stocked ? t8('This record has not been stocked in. Proceed?')
338
                  :                                                                                                               undef,
343 339
      ],
344 340

  
345 341
      combobox => [
......
499 495
  # department leer überlebt erneuern       | i.O.
500 496
  # department nicht leer überlebt erneuern | i.O.
501 497
  # $main::lxdebug->message(0, 'ABTEILUNGS ID in form?' . $form->{department_id});
502
  print $form->parse_html_template('do/form_header');
498
  print $form->parse_html_template('do/form_header', {
499
    is_customer        => is_customer($form->{type}),
500
    transfer_direction => transfer_direction($form->{type}),
501
    vc                 => customervendor($form->{type}),
502
  });
503 503

  
504 504
  $main::lxdebug->leave_sub();
505 505
}
......
578 578
  } else {
579 579

  
580 580
    my $mode;
581
    if ($form->{type} eq 'purchase_delivery_order') {
581
    if (!is_customer($form->{type})) {
582 582
      IR->retrieve_item(\%myconfig, $form);
583 583
      $mode = 'IR';
584 584
    } else {
......
665 665
  my %myconfig = %main::myconfig;
666 666
  my $locale   = $main::locale;
667 667

  
668
  $form->{vc} = $form->{type} eq 'purchase_delivery_order' ? 'vendor' : 'customer';
668
  $form->{vc} = customervendor($form->{type});
669 669

  
670 670
  $form->get_lists("projects"       => { "key" => "ALL_PROJECTS",
671 671
                                         "all" => 1 },
......
718 718

  
719 719
  $form->{title}       = $locale->text('Delivery Orders');
720 720

  
721
  my $attachment_basename = $form->{vc} eq 'vendor' ? $locale->text('purchase_delivery_order_list') : $locale->text('sales_delivery_order_list');
721
  my $attachment_basename = text($form->{type}, 'attachment');
722 722

  
723 723
  my $report = SL::ReportGenerator->new(\%myconfig, $form);
724 724

  
......
862 862

  
863 863
  my $edit_url       = build_std_url('action=edit', 'type', 'vc');
864 864
  my $edit_order_url = ($::instance_conf->get_feature_experimental_order)
865
                     ? build_std_url('script=controller.pl', 'action=Order/edit', 'type=' . ($form->{type} eq 'sales_delivery_order' ? 'sales_order' : 'purchase_order'))
866
                     : build_std_url('script=oe.pl',         'action=edit',       'type=' . ($form->{type} eq 'sales_delivery_order' ? 'sales_order' : 'purchase_order'));
865
                     ? build_std_url('script=controller.pl', 'action=Order/edit', 'type=' . (is_customer($form->{type}) ? 'sales_order' : 'purchase_order'))
866
                     : build_std_url('script=oe.pl',         'action=edit',       'type=' . (is_customer($form->{type}) ? 'sales_order' : 'purchase_order'));
867 867

  
868 868
  my $idx            = 1;
869 869

  
......
1011 1011
  my $locale   = $main::locale;
1012 1012
  my $ret;
1013 1013

  
1014
  die "Invalid form type" unless $form->{type} =~ m/^(sales|purchase)_delivery_order$/;
1014
  SL::DB::DeliveryOrder::TypeData::validate_type($form->{type});
1015 1015

  
1016 1016
  if ($ret = DO->delete_transfers()) {
1017 1017
    # saving the history
......
1043 1043
  check_do_access();
1044 1044
  $form->mtime_ischanged('delivery_orders');
1045 1045

  
1046
  $main::auth->assert($form->{type} eq 'purchase_delivery_order' ? 'vendor_invoice_edit' : 'invoice_edit');
1046
  $main::auth->assert(!is_customer($form->{type}) ? 'vendor_invoice_edit' : 'invoice_edit');
1047 1047

  
1048 1048
  $form->get_employee();
1049 1049

  
......
1060 1060
  delete @{$form}{qw(id closed delivered)};
1061 1061

  
1062 1062
  my ($script, $buysell);
1063
  if ($form->{type} eq 'purchase_delivery_order') {
1063
  if (!is_customer($form->{type})) {
1064 1064
    $form->{title}  = $locale->text('Add Vendor Invoice');
1065 1065
    $form->{script} = 'ir.pl';
1066 1066
    $script         = "ir";
......
1103 1103

  
1104 1104
  if ($form->{ordnumber}) {
1105 1105
    require SL::DB::Order;
1106
    my $vc_id  = $form->{type} =~ /^sales/ ? 'customer_id' : 'vendor_id';
1106
    my $vc_id  = is_customer($form->{type}) ? 'customer_id' : 'vendor_id';
1107 1107
    if (my $order = SL::DB::Manager::Order->find_by(ordnumber => $form->{ordnumber}, $vc_id => $form->{"$vc_id"})) {
1108 1108
      $order->load;
1109 1109
      $form->{orddate} = $order->transdate_as_date;
......
1160 1160
  my $locale   = $main::locale;
1161 1161

  
1162 1162
  check_do_access();
1163
  $main::auth->assert($form->{type} eq 'sales_delivery_order' ? 'invoice_edit' : 'vendor_invoice_edit');
1163
  $main::auth->assert(is_customer($form->{type}) ? 'invoice_edit' : 'vendor_invoice_edit');
1164 1164

  
1165 1165
  my @do_ids = map { $form->{"trans_id_$_"} } grep { $form->{"multi_id_$_"} } (1..$form->{rowcount});
1166 1166

  
......
1194 1194
  $form->{defaultcurrency}     = $form->get_default_currency(\%myconfig);
1195 1195

  
1196 1196
  my ($script, $buysell);
1197
  if ($source_type eq 'purchase_delivery_order') {
1197
  if (!is_customer($source_type)) {
1198 1198
    $form->{title}  = $locale->text('Add Vendor Invoice');
1199 1199
    $form->{script} = 'ir.pl';
1200 1200
    $script         = "ir";
......
1295 1295

  
1296 1296
  my $all_units = AM->retrieve_all_units();
1297 1297

  
1298
  my $in_out   = $form->{type} =~ /^sales/ ? 'out' : 'in';
1298
  my $in_out   = transfer_direction($form->{type});
1299 1299
  my $sinfo    = DO->unpack_stock_information('packed' => $form->{"stock_${in_out}_${i}"});
1300 1300

  
1301 1301
  my $do_qty   = AM->sum_with_unit($::form->{"qty_$i"}, $::form->{"unit_$i"});
......
1645 1645
  SL::DB::DeliveryOrder->new(id => $form->{id})->load->update_attributes(delivered => 1);
1646 1646

  
1647 1647
  flash_later('info', $locale->text("Transfer successful"));
1648
  $form->{callback} = 'do.pl?action=edit&type=purchase_delivery_order&id=' . $form->escape($form->{id});
1648
  $form->{callback} = 'do.pl?action=edit&type=' . $form->escape($form->{type}) . '&id=' . $form->escape($form->{id});
1649 1649
  $form->redirect;
1650 1650

  
1651 1651
  $main::lxdebug->leave_sub();
......
1764 1764
  SL::DB::DeliveryOrder->new(id => $form->{id})->load->update_attributes(delivered => 1);
1765 1765

  
1766 1766
  flash_later('info', $locale->text("Transfer successful"));
1767
  $form->{callback} = 'do.pl?action=edit&type=sales_delivery_order&id=' . $form->escape($form->{id});
1767
  $form->{callback} = 'do.pl?action=edit&type=' . $form->escape($form->{type}) . '&id=' . $form->escape($form->{id});
1768 1768
  $form->redirect;
1769 1769

  
1770 1770
  $main::lxdebug->leave_sub();
......
2009 2009

  
2010 2010
  SL::DB::DeliveryOrder->new(id => $form->{id})->load->update_attributes(delivered => 1);
2011 2011

  
2012
  $form->{callback} = 'do.pl?action=edit&type=sales_delivery_order&id=' . $form->escape($form->{id}) if $params{direction} eq 'out';
2013
  $form->{callback} = 'do.pl?action=edit&type=purchase_delivery_order&id=' . $form->escape($form->{id}) if $params{direction} eq 'in';
2012
  $form->{callback} = 'do.pl?action=edit&type=' . $form->escape($form->{type}) . '&id=' . $form->escape($form->{id});
2014 2013
  $form->redirect;
2015 2014

  
2016 2015
}
......
2054 2053
    save();
2055 2054
}
2056 2055

  
2056

  
2057
## type stubs
2058
sub text {
2059
  my ($type, $string) = @_;
2060
  SL::DB::DeliveryOrder::TypeData::get3($type, "text", $string);
2061
}
2062

  
2063
sub access {
2064
  SL::DB::DeliveryOrder::TypeData::get($_[0], "right");
2065
}
2066

  
2067
sub customervendor {
2068
  SL::DB::DeliveryOrder::TypeData::get3($_[0], "properties", "customervendor");
2069
}
2070

  
2071
sub is_customer {
2072
  SL::DB::DeliveryOrder::TypeData::get3($_[0], "properties", "is_customer");
2073
}
2074

  
2075
sub transfer_direction {
2076
  SL::DB::DeliveryOrder::TypeData::get3($_[0], "properties", "transfer");
2077
}
2078

  
2057 2079
__END__
2058 2080

  
2059 2081
=pod

Auch abrufbar als: Unified diff