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:

SL/DO.pm
42 42
use SL::Common;
43 43
use SL::CVar;
44 44
use SL::DB::DeliveryOrder;
45
use SL::DB::DeliveryOrder::TypeData qw(:types);
45 46
use SL::DB::Status;
46 47
use SL::DBUtils;
47 48
use SL::Helper::ShippedQty;
......
90 91
       LEFT JOIN department dep ON (dord.department_id = dep.id)
91 92
|;
92 93

  
93
  push @where, ($form->{type} eq 'sales_delivery_order' ? '' : 'NOT ') . qq|COALESCE(dord.is_sales, FALSE)|;
94
  if (SL::DB::DeliveryOrder::TypeData::is_valid_type($form->{type})) {
95
    push @where, qq|dord.order_type = ?|;
96
    push @values, $form->{type};
97
  }
94 98

  
95 99
  if ($form->{department_id}) {
96 100
    push @where,  qq|dord.department_id = ?|;
......
308 312
  $form->{employee_id} = (split /--/, $form->{employee})[1] if !$form->{employee_id};
309 313
  $form->get_employee($dbh) unless ($form->{employee_id});
310 314

  
311
  my $ml = ($form->{type} eq 'sales_delivery_order') ? 1 : -1;
312

  
313 315
  my (@processed_doi, @processed_dois);
314 316

  
315 317
  if ($form->{id}) {
......
328 330
    $query = qq|SELECT nextval('id')|;
329 331
    ($form->{id}) = selectrow_query($form, $dbh, $query);
330 332

  
331
    $query = qq|INSERT INTO delivery_orders (id, donumber, employee_id, currency_id, taxzone_id) VALUES (?, '', ?, (SELECT currency_id FROM defaults LIMIT 1), ?)|;
332
    do_query($form, $dbh, $query, $form->{id}, conv_i($form->{employee_id}), $form->{taxzone_id});
333
    $query = qq|INSERT INTO delivery_orders (id, donumber, employee_id, currency_id, taxzone_id, order_type) VALUES (?, '', ?, (SELECT currency_id FROM defaults LIMIT 1), ?, ?)|;
334
    do_query($form, $dbh, $query, $form->{id}, conv_i($form->{employee_id}), $form->{taxzone_id}, $form->{type});
333 335
  }
334 336

  
335 337
  my $project_id;
......
365 367
SQL
366 368
  my $h_item_stock = prepare_query($form, $dbh, $q_item_stock);
367 369

  
368
  my $in_out       = $form->{type} =~ /^sales/ ? 'out' : 'in';
370
  my $in_out       = transfer_direction($form->{type});
369 371

  
370 372
  for my $i (1 .. $form->{rowcount}) {
371 373
    next if (!$form->{"id_$i"});
......
515 517
         shippingpoint = ?, shipvia = ?, notes = ?, intnotes = ?, closed = ?,
516 518
         delivered = ?, department_id = ?, language_id = ?, shipto_id = ?,
517 519
         globalproject_id = ?, employee_id = ?, salesman_id = ?, cp_id = ?, transaction_description = ?,
518
         is_sales = ?, taxzone_id = ?, taxincluded = ?, payment_id = ?, currency_id = (SELECT id FROM currencies WHERE name = ?),
520
         is_sales = ?, order_type = ?, taxzone_id = ?, taxincluded = ?, payment_id = ?, currency_id = (SELECT id FROM currencies WHERE name = ?),
519 521
         delivery_term_id = ?
520 522
       WHERE id = ?|;
521 523

  
......
529 531
             conv_i($form->{globalproject_id}), conv_i($form->{employee_id}),
530 532
             conv_i($form->{salesman_id}), conv_i($form->{cp_id}),
531 533
             $form->{transaction_description},
532
             $form->{type} =~ /^sales/ ? 't' : 'f',
534
             is_customer($form->{type}), SL::DB::DeliveryOrder::TypeData::validate_type($form->{type}),
533 535
             conv_i($form->{taxzone_id}), $form->{taxincluded} ? 't' : 'f', conv_i($form->{payment_id}), $form->{currency},
534 536
             conv_i($form->{delivery_term_id}),
535 537
             conv_i($form->{id}));
......
559 561
  delete $form->{convert_from_oe_ids};
560 562
  unless ($::instance_conf->get_shipped_qty_require_stock_out) {
561 563
    $self->mark_orders_if_delivered('do_id' => $form->{id},
562
                                    'type'  => $form->{type} eq 'sales_delivery_order' ? 'sales' : 'purchase');
564
                                    'type'  => customervendor($form->{type}) ? 'sales' : 'purchase');
563 565
  }
564 566

  
565 567
  $form->{saved_donumber} = $form->{donumber};
......
735 737
         dord.itime, dord.mtime,
736 738
         dord.globalproject_id, dord.delivered, dord.transaction_description,
737 739
         dord.taxzone_id, dord.taxincluded, dord.payment_id, (SELECT cu.name FROM currencies cu WHERE cu.id=dord.currency_id) AS currency,
738
         dord.delivery_term_id, dord.itime::DATE AS insertdate
740
         dord.delivery_term_id, dord.itime::DATE AS insertdate, dord.order_type as type
739 741
       FROM delivery_orders dord
740 742
       JOIN ${vc} cv ON (dord.${vc}_id = cv.id)
741 743
       LEFT JOIN employee e ON (dord.employee_id = e.id)
......
849 851
  }
850 852

  
851 853
  if ($mode eq 'single') {
852
    my $in_out = $form->{type} =~ /^sales/ ? 'out' : 'in';
854
    my $in_out = transfer_direction($form->{type});
853 855

  
854 856
    $query =
855 857
      qq|SELECT id as delivery_order_items_stock_id, qty, unit, bin_id,
......
939 941
                           (SELECT description FROM warehouse WHERE id = ?) AS warehouse|;
940 942
  my $h_bin_wh = prepare_query($form, $dbh, $q_bin_wh);
941 943

  
942
  my $in_out   = $form->{type} =~ /^sales/ ? 'out' : 'in';
944
  my $in_out   = transfer_direction($form->{type});
943 945

  
944 946
  my $num_si   = 0;
945 947

  
......
1265 1267

  
1266 1268
  if ($::instance_conf->get_shipped_qty_require_stock_out) {
1267 1269
    $self->mark_orders_if_delivered('do_id' => $form->{id},
1268
                                    'type'  => $form->{type} eq 'sales_delivery_order' ? 'sales' : 'purchase');
1270
                                    'type'  => is_customer($form->{type}) ? 'sales' : 'purchase');
1269 1271
  }
1270 1272

  
1271 1273
  $main::lxdebug->leave_sub();
......
1291 1293
  return $delivered ? 1 : 0;
1292 1294
}
1293 1295

  
1296
sub customervendor {
1297
  SL::DB::DeliveryOrder::TypeData::get3($_[0], "properties", "customervendor");
1298
}
1299

  
1300
sub is_customer {
1301
  SL::DB::DeliveryOrder::TypeData::get3($_[0], "properties", "is_customer");
1302
}
1303

  
1304
sub transfer_direction {
1305
  SL::DB::DeliveryOrder::TypeData::get3($_[0], "properties", "transfer");
1306
}
1307

  
1294 1308
1;
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
bin/mozilla/io.pl
150 150
  my $show_marge         = (!$is_purchase || $is_invoice || $is_credit_note) && !$is_delivery_order;
151 151

  
152 152
  if ($is_delivery_order) {
153
    if ($form->{type} eq 'sales_delivery_order') {
153
    if (transfer_direction($form->{type}) eq 'out') {
154 154
      $stock_in_out_title = $locale->text('Release From Stock');
155 155
      $stock_in_out       = 'out';
156 156
    } else {
......
1881 1881
    purchase_invoice        => 'InvoiceItem',
1882 1882
    purchase_delivery_order => 'DeliveryOrderItem',
1883 1883
    sales_delivery_order    => 'DeliveryOrderItem',
1884
    supplier_delivery_order => 'DeliveryOrderItem',
1885
    rma_delivery_order      => 'DeliveryOrderItem',
1884 1886
  }->{$::form->{type}};
1885 1887

  
1886 1888
  return unless $class;
......
1955 1957
    request_quotation       => 'Order',
1956 1958
    purchase_delivery_order => 'DeliveryOrder',
1957 1959
    sales_delivery_order    => 'DeliveryOrder',
1960
    supplier_delivery_order => 'DeliveryOrder',
1961
    rma_delivery_order      => 'DeliveryOrder',
1958 1962
  }->{$::form->{type}};
1959 1963

  
1960 1964
  if ($::form->{type} =~ /invoice|credit_note/) {
templates/webpages/do/form_header.html
39 39
  }
40 40
 </style>
41 41

  
42
 [%- IF vc == 'customer' %]
43
 [%- SET is_customer = '1' %]
44
 [%- ELSE %]
45
 [%- SET vc = 'vendor' %]
46
 [%- SET is_customer = '0' %]
47
 [%- END %]
48 42
 [%- SET vc_id = vc _ "_id" %]
49 43
 [%- IF delivered %]
50 44
 [%- SET DISABLED = ' disabled' %]
......
233 227
       <tr>
234 228
        <td colspan="2" align="center">
235 229
         [%- IF delivered %]
236
          [%- IF is_customer %]
230
          [%- IF transfer_direction == 'out' %]
237 231
          [% 'transferred out' | $T8 %]
238 232
          [%- ELSE %]
239 233
          [% 'transferred in' | $T8 %]
240 234
          [%- END %]
241 235
         [%- ELSE %]
242
          [%- IF is_customer %]
236
          [%- IF transfer_direction == 'out' %]
243 237
          [% 'not transferred out yet' | $T8 %]
244 238
          [%- ELSE %]
245 239
          [% 'not transferred in yet' | $T8 %]

Auch abrufbar als: Unified diff