]> wagnertech.de Git - mfinanz.git/blobdiff - bin/mozilla/do.pl
Banktransaction: Kontoauszug verbuchen: Sonderfall für "credit_notes"
[mfinanz.git] / bin / mozilla / do.pl
index 209d37558ff15da67afe459200dea1e9ab9da80d..6c122219559a5ce64b24508af0580857f64d1881 100644 (file)
@@ -45,7 +45,6 @@ use SL::MoreCommon qw(ary_diff restore_form save_form);
 use SL::ReportGenerator;
 use SL::WH;
 use Sort::Naturally ();
-require "bin/mozilla/arap.pl";
 require "bin/mozilla/common.pl";
 require "bin/mozilla/io.pl";
 require "bin/mozilla/reportgenerator.pl";
@@ -172,9 +171,6 @@ sub order_links {
   my $form     = $main::form;
   my %myconfig = %main::myconfig;
 
-  # get customer/vendor
-  $form->all_vc(\%myconfig, $form->{vc}, ($form->{vc} eq 'customer') ? "AR" : "AP");
-
   # retrieve order/quotation
   my $editing = $form->{id};
 
@@ -197,17 +193,6 @@ sub order_links {
   $form->restore_vars(qw(taxincluded)) if $form->{id};
   $form->restore_vars(qw(salesman_id)) if $editing;
 
-  if ($form->{"all_$form->{vc}"}) {
-    unless ($form->{"$form->{vc}_id"}) {
-      $form->{"$form->{vc}_id"} = $form->{"all_$form->{vc}"}->[0]->{id};
-    }
-  }
-
-  ($form->{ $form->{vc} })  = split /--/, $form->{ $form->{vc} };
-  $form->{"old$form->{vc}"} = qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
-
-  $form->{employee} = "$form->{employee}--$form->{employee_id}";
-
   $main::lxdebug->leave_sub();
 }
 
@@ -259,12 +244,14 @@ sub form_header {
   my $form     = $main::form;
   my %myconfig = %main::myconfig;
 
+  my $class       = "SL::DB::" . ($form->{vc} eq 'customer' ? 'Customer' : 'Vendor');
+  $form->{VC_OBJ} = $class->load_cached($form->{ $form->{vc} . '_id' });
+
   $form->{employee_id} = $form->{old_employee_id} if $form->{old_employee_id};
   $form->{salesman_id} = $form->{old_salesman_id} if $form->{old_salesman_id};
 
   my $vc = $form->{vc} eq "customer" ? "customers" : "vendors";
-  $form->get_lists($vc              => "ALL_VC",
-                   "price_factors"  => "ALL_PRICE_FACTORS",
+  $form->get_lists("price_factors"  => "ALL_PRICE_FACTORS",
                    "business_types" => "ALL_BUSINESS_TYPES",
     );
   $form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all;
@@ -302,13 +289,6 @@ sub form_header {
     ]
   ]);
 
-  map { $_->{value} = "$_->{name}--$_->{id}"        } @{ $form->{ALL_VC} };
-
-  $form->{SHOW_VC_DROP_DOWN} =  $myconfig{vclimit} > scalar @{ $form->{ALL_VC} };
-
-  $form->{oldvcname}         =  $form->{"old$form->{vc}"};
-  $form->{oldvcname}         =~ s/--.*//;
-
   my $dispatch_to_popup = '';
   if ($form->{resubmit} && ($form->{format} eq "html")) {
     $dispatch_to_popup  = "window.open('about:blank','Beleg'); document.do.target = 'Beleg';";
@@ -320,12 +300,9 @@ sub form_header {
   $::request->{layout}->add_javascripts_inline("\$(function(){$dispatch_to_popup});");
 
 
-  my $follow_up_vc                =  $form->{ $form->{vc} eq 'customer' ? 'customer' : 'vendor' };
-  $follow_up_vc                   =~ s/--\d*\s*$//;
+  $form->{follow_up_trans_info} = $form->{donumber} .'('. $form->{VC_OBJ}->name .')';
 
-  $form->{follow_up_trans_info} = $form->{donumber} .'('. $follow_up_vc .')';
-
-  $::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.SalesPurchase ckeditor/ckeditor ckeditor/adapters/jquery kivi.io autocomplete_customer autocomplete_part));
+  $::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.File kivi.MassDeliveryOrderPrint kivi.SalesPurchase ckeditor/ckeditor ckeditor/adapters/jquery kivi.io autocomplete_customer autocomplete_part));
 
   my @custom_hidden;
   push @custom_hidden, map { "shiptocvar_" . $_->name } @{ SL::DB::Manager::CustomVariableConfig->get_all(where => [ module => 'ShipTo' ]) };
@@ -383,7 +360,14 @@ sub update_delivery_order {
   my $payment_id;
   $payment_id = $form->{payment_id} if $form->{payment_id};
 
-  check_name($form->{vc});
+  my $vc = $form->{vc};
+  if (($form->{"previous_${vc}_id"} || $form->{"${vc}_id"}) != $form->{"${vc}_id"}) {
+    $::form->{salesman_id} = SL::DB::Manager::Employee->current->id if exists $::form->{salesman_id};
+
+    IS->get_customer(\%myconfig, $form) if $vc eq 'customer';
+    IR->get_vendor(\%myconfig, $form)   if $vc eq 'vendor';
+  }
+
   $form->{discount} =  $form->{"$form->{vc}_discount"} if defined $form->{"$form->{vc}_discount"};
   # Problem: Wenn man ohne Erneuern einen Kunden/Lieferanten
   # wechselt, wird der entsprechende Kunden/ Lieferantenrabatt
@@ -523,6 +507,7 @@ sub orders {
   my $locale   = $main::locale;
   my $cgi      = $::request->{cgi};
 
+  $::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.MassDeliveryOrderPrint));
   ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) = split(/--/, $form->{ $form->{vc} });
 
   report_generator_set_default_sort('transdate', 1);
@@ -560,7 +545,7 @@ sub orders {
   my $href = build_std_url('action=orders', grep { $form->{$_} } @hidden_variables);
 
   my %column_defs = (
-    'ids'                     => { 'text' => '', },
+    'ids'                     => { 'text' => '<input type="checkbox" id="multi_all" value="1">', 'align' => 'center' },
     'transdate'               => { 'text' => $locale->text('Delivery Order Date'), },
     'reqdate'                 => { 'text' => $locale->text('Reqdate'), },
     'id'                      => { 'text' => $locale->text('ID'), },
@@ -658,9 +643,15 @@ sub orders {
     push @options, $locale->text('Not delivered');
   }
 
+  my $pr = SL::DB::Manager::Printer->find_by(
+      printer_description => $::locale->text("sales_delivery_order_printer"));
+  if ($pr ) {
+      $form->{printer_id} = $pr->id;
+  }
+
   $report->set_options('top_info_text'        => join("\n", @options),
                        'raw_top_info_text'    => $form->parse_html_template('do/orders_top'),
-                       'raw_bottom_info_text' => $form->parse_html_template('do/orders_bottom'),
+                       'raw_bottom_info_text' => $form->parse_html_template('do/orders_bottom', { print_options => print_options(inline => 1,hide_language_id => 1) }),
                        'output_format'        => 'HTML',
                        'title'                => $form->{title},
                        'attachment_basename'  => $attachment_basename . strftime('_%Y%m%d', localtime time),
@@ -685,9 +676,10 @@ sub orders {
 
     my $row = { map { $_ => { 'data' => $dord->{$_} } } @columns };
 
+    my $ord_id = $dord->{id};
     $row->{ids}  = {
-      'raw_data' =>   $cgi->hidden('-name' => "trans_id_${idx}", '-value' => $dord->{id})
-                    . $cgi->checkbox('-name' => "multi_id_${idx}", '-value' => 1, '-label' => ''),
+      'raw_data' =>   $cgi->hidden('-name' => "trans_id_${idx}", '-value' => $ord_id)
+                    . $cgi->checkbox('-name' => "multi_id_${idx}",' id' => "multi_id_id_".$ord_id, '-value' => 1, '-label' => ''),
       'valign'   => 'center',
       'align'    => 'center',
     };
@@ -725,7 +717,7 @@ sub save {
   $form->{donumber} =~ s/\s*$//g;
 
   my $msg = ucfirst $form->{vc};
-  $form->isblank($form->{vc}, $locale->text($msg . " missing!"));
+  $form->isblank($form->{vc} . "_id", $locale->text($msg . " missing!"));
 
   # $locale->text('Customer missing!');
   # $locale->text('Vendor missing!');
@@ -734,7 +726,13 @@ sub save {
   validate_items();
 
   # if the name changed get new values
-  if (check_name($form->{vc})) {
+  my $vc = $form->{vc};
+  if (($form->{"previous_${vc}_id"} || $form->{"${vc}_id"}) != $form->{"${vc}_id"}) {
+    $::form->{salesman_id} = SL::DB::Manager::Employee->current->id if exists $::form->{salesman_id};
+
+    IS->get_customer(\%myconfig, $form) if $vc eq 'customer';
+    IR->get_vendor(\%myconfig, $form)   if $vc eq 'vendor';
+
     update();
     $::dispatcher->end_request;
   }
@@ -1829,7 +1827,6 @@ __END__
 
 do.pl - Script for all calls to delivery order
 
-
 =head1 FUNCTIONS
 
 =over 2