Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 454df69e

Von Moritz Bunkus vor mehr als 16 Jahren hinzugefügt

  • ID 454df69edeb9bfe5a1a9c06c2788d1e1175470db
  • Vorgänger 556a2137
  • Nachfolger c9696e31

Erstellen von Rechnungen aus mehreren Lieferscheinen heraus.

Unterschiede anzeigen:

bin/mozilla/do.pl
156 156

  
157 157
  my $editing = $form->{id};
158 158

  
159
  DO->retrieve();
159
  DO->retrieve('vc'  => $form->{vc},
160
               'ids' => $form->{id});
160 161

  
161 162
  $payment_id  = $form->{payment_id}  if ($form->{payment_id});
162 163
  $language_id = $form->{language_id} if ($form->{language_id});
......
415 416
  $form->{rowcount} = scalar @{ $form->{DO} };
416 417

  
417 418
  my @columns = qw(
418
    transdate
419
    ids                     transdate
419 420
    id                      donumber
420 421
    ordnumber
421 422
    name                    employee
......
460 461

  
461 462
  $form->{"l_type"} = "Y";
462 463
  map { $column_defs{$_}->{visible} = $form->{"l_${_}"} ? 1 : 0 } @columns;
463
  $column_defs{ids}->{visible} = $allow_multiple_orders ? 'HTML' : 0;
464

  
465
  $column_defs{ids}->{visible} = 'HTML';
464 466

  
465 467
  $report->set_columns(%column_defs);
466 468
  $report->set_column_order(@columns);
......
508 510
    push @options, $locale->text('Not delivered');
509 511
  }
510 512

  
511
  $report->set_options('top_info_text'       => join("\n", @options),
512
                       'output_format'       => 'HTML',
513
                       'title'               => $form->{title},
514
                       'attachment_basename' => $attachment_basename . strftime('_%Y%m%d', localtime time),
513
  $report->set_options('top_info_text'        => join("\n", @options),
514
                       'raw_top_info_text'    => $form->parse_html_template('do/orders_top'),
515
                       'raw_bottom_info_text' => $form->parse_html_template('do/orders_bottom'),
516
                       'output_format'        => 'HTML',
517
                       'title'                => $form->{title},
518
                       'attachment_basename'  => $attachment_basename . strftime('_%Y%m%d', localtime time),
515 519
    );
516 520
  $report->set_options_from_form();
517 521

  
......
524 528
  my $edit_url       = build_std_url('action=edit', 'type', 'vc');
525 529
  my $edit_order_url = build_std_url('script=oe.pl', 'type=' . ($form->{type} eq 'sales_delivery_order' ? 'sales_order' : 'purchase_order'), 'action=edit');
526 530

  
531
  my $idx            = 1;
532

  
527 533
  foreach $dord (@{ $form->{DO} }) {
528 534
    $dord->{open}      = $dord->{closed}    ? $locale->text('No')  : $locale->text('Yes');
529 535
    $dord->{delivered} = $dord->{delivered} ? $locale->text('Yes') : $locale->text('No');
530 536

  
531 537
    my $row = { map { $_ => { 'data' => $dord->{$_} } } @columns };
532 538

  
539
    $row->{ids}  = {
540
      'raw_data' =>   $cgi->hidden('-name' => "trans_id_${idx}", '-value' => $dord->{id})
541
                    . $cgi->checkbox('-name' => "multi_id_${idx}", '-value' => 1, '-label' => ''),
542
      'valign'   => 'center',
543
      'align'    => 'center',
544
    };
545

  
533 546
    $row->{donumber}->{link}  = $edit_url       . "&id=" . E($dord->{id})      . "&callback=${callback}";
534 547
    $row->{ordnumber}->{link} = $edit_order_url . "&id=" . E($dord->{oe_id})   . "&callback=${callback}";
535 548

  
536 549
    $report->add_data($row);
550

  
551
    $idx++;
537 552
  }
538 553

  
539 554
  $report->generate_with_headers();
......
704 719
  $lxdebug->leave_sub();
705 720
}
706 721

  
722
sub invoice_multi {
723
  $lxdebug->enter_sub();
724

  
725
  check_do_access();
726
  $auth->assert($form->{type} eq 'sales_delivery_order' ? 'invoice_edit' : 'vendor_invoice_edit');
727

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

  
730
  if (!scalar @do_ids) {
731
    $form->show_generic_error($locale->text('You have not selected any delivery order.'), 'back_button' => 1);
732
  }
733

  
734
  map { delete $form->{$_} } grep { m/^(?:trans|multi)_id_\d+/ } keys %{ $form };
735

  
736
  if (!DO->retrieve('vc' => $form->{vc}, 'ids' => \@do_ids)) {
737
    $form->show_generic_error($form->{vc} eq 'customer' ?
738
                              $locale->text('You cannot create an invoice for delivery orders for different customers.') :
739
                              $locale->text('You cannot create an invoice for delivery orders from different vendors.'),
740
                              'back_button' => 1);
741
  }
742

  
743
  $form->{deliverydate}    = $form->{transdate};
744
  $form->{transdate}       = $form->current_date(\%myconfig);
745
  $form->{duedate}         = $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
746
  $form->{type}            = "invoice";
747
  $form->{closed}          = 0;
748
  $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
749

  
750
  my $buysell;
751
  if ($form->{type} eq 'purchase_delivery_order') {
752
    $form->{title}  = $locale->text('Add Vendor Invoice');
753
    $form->{script} = 'ir.pl';
754
    $script         = "ir";
755
    $buysell        = 'sell';
756

  
757
  } else {
758
    $form->{title}  = $locale->text('Add Sales Invoice');
759
    $form->{script} = 'is.pl';
760
    $script         = "is";
761
    $buysell        = 'buy';
762
  }
763

  
764
  map { delete $form->{$_} } qw(id subject message cc bcc printed emailed queued);
765

  
766
  $form->{rowcount} = 0;
767
  foreach my $ref (@{ $form->{form_details} }) {
768
    $form->{rowcount}++;
769
    map { $form->{"${_}_$form->{rowcount}"} = $ref->{$_} } keys %{ $ref };
770
    map { $form->{"${_}_$form->{rowcount}"} = $form->format_amount(\%myconfig, $ref->{$_}) } qw(qty sellprice discount lastcost);
771
  }
772
  delete $form->{form_details};
773

  
774
  $locale = new Locale "$myconfig{countrycode}", "$script";
775

  
776
  require "bin/mozilla/$form->{script}";
777

  
778
  invoice_links();
779
  prepare_invoice();
780
  display_form();
781

  
782
  $lxdebug->leave_sub();
783
}
784

  
707 785
sub save_as_new {
708 786
  $lxdebug->enter_sub();
709 787

  

Auch abrufbar als: Unified diff