Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision ed04f337

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

  • ID ed04f337a0e565a3d0621a10bd273298e33c7fa1
  • Vorgänger e8889e47
  • Nachfolger 46d3bb6e

Auftrags-Controller: longdescription

Unterschiede anzeigen:

SL/Controller/Order.pm
481 481
  $self->render_price_dialog($item);
482 482
}
483 483

  
484
sub action_get_item_longdescription {
485
  my $longdescription;
486

  
487
  if ($::form->{item_id}) {
488
    $longdescription = SL::DB::OrderItem->new(id => $::form->{item_id})->load->longdescription;
489
  } elsif ($::form->{parts_id}) {
490
    $longdescription = SL::DB::Part->new(id => $::form->{parts_id})->load->notes;
491
  }
492
  $_[0]->render(\ $longdescription, { type => 'text' });
493
}
494

  
495

  
484 496
sub _js_redisplay_linetotals {
485 497
  my ($self) = @_;
486 498

  
......
684 696
  my $item;
685 697
  $item = first { $_->id == $attr->{id} } @{$record->items} if $attr->{id};
686 698

  
699
  my $is_new = !$item;
700

  
687 701
  # add_custom_variables adds cvars to an orderitem with no cvars for saving, but
688 702
  # they cannot be retrieved via custom_variables until the order/orderitem is
689 703
  # saved. Adding empty custom_variables to new orderitem here solves this problem.
690 704
  $item ||= SL::DB::OrderItem->new(custom_variables => []);
705

  
691 706
  $item->assign_attributes(%$attr);
707
  $item->longdescription($item->part->notes) if $is_new && !defined $attr->{longdescription};
692 708

  
693 709
  return $item;
694 710
}
......
735 751
  $new_attr{active_price_source}    = $price_src;
736 752
  $new_attr{active_discount_source} = $discount_src;
737 753

  
754
  $new_attr{longdescription}        = $part->notes if ! defined $attr->{longdescription};
755

  
738 756
  # add_custom_variables adds cvars to an orderitem with no cvars for saving, but
739 757
  # they cannot be retrieved via custom_variables until the order/orderitem is
740 758
  # saved. Adding empty custom_variables to new orderitem here solves this problem.
......
770 788
  my ($self) = @_;
771 789

  
772 790
  foreach my $item (@{ $self->order->items }) {
773
    if ($item->id) {
774
      # load data from orderitems (db)
775
      my $db_item = SL::DB::OrderItem->new(id => $item->id)->load;
776
      $item->$_($db_item->$_) for qw(longdescription);
777
    } else {
778
      # set data from part (or other sources)
779
      $item->longdescription($item->part->notes);
780
    }
781

  
782 791
    # autovivify all cvars that are not in the form (cvars_by_config can do it).
783 792
    # workaround to pre-parse number-cvars (parse_custom_variable_values does not parse number values).
784 793
    foreach my $var (@{ $item->cvars_by_config }) {
......
863 872
                                                } } @all_objects;
864 873
  }
865 874

  
866
  $::request->{layout}->use_javascript("${_}.js")  for qw(ckeditor/ckeditor ckeditor/adapters/jquery);
875
  $::request->{layout}->use_javascript("${_}.js")  for qw(kivi.SalesPurchase ckeditor/ckeditor ckeditor/adapters/jquery);
867 876
}
868 877

  
869 878
sub _create_pdf {
templates/webpages/order/tabs/_row.html
25 25
                       confirm=LxERP.t8("Are you sure?")) %]
26 26
    </td>
27 27
    <td>
28
      [% HTML.escape(ITEM.part.partnumber) %]
28
      <div name="partnumber">[% HTML.escape(ITEM.part.partnumber) %]</div>
29 29
    </td>
30 30
    <td>
31 31
      [% L.input_tag("order.orderitems[].description",
32 32
                     ITEM.description,
33 33
                     style='width: 300px') %]
34
      [%- L.button_tag("show_longdescription_dialog(this)", LxERP.t8("L")) %]
34 35
    </td>
35 36
    <td>
36 37
      [%- L.input_tag("order.orderitems[].qty_as_number",
templates/webpages/order/tabs/basic_data.html
3 3
[%- USE LxERP %]
4 4
[%- USE L %]
5 5

  
6
[%- INCLUDE 'generic/set_longdescription.html' %]
7

  
6 8
<div id="ui-tabs-basic-data">
7 9
  <table width="100%">
8 10
    <tr valign="top">
......
560 562
  renumber_positions();
561 563
}
562 564

  
565
function show_longdescription_dialog(clicked) {
566
  var row = $(clicked).parents("tbody").first();
567
  var position = $(row).find('[name="position"]').html();
568
  var partnumber = $(row).find('[name="partnumber"]').html();
569
  var description_elt = $(row).find('[name="order.orderitems[].description"]');
570
  var description = description_elt.val();
571
  var longdescription_elt = $(row).find('[name="order.orderitems[].longdescription"]');
572
  var longdescription;
573

  
574
  if (!longdescription_elt.length) {
575
    var data = 'action=Order/get_item_longdescription';
576
    data += '&type=' + $('#type').val();
577
    data += '&item_id=' + $(row).find('[name="order.orderitems[+].id"]').val();
578
    data += '&parts_id=' + $(row).find('[name="order.orderitems[].parts_id"]').val();
579
    $.ajax({
580
      url: 'controller.pl',
581
      data: data,
582
      method: "GET",
583
      async: false,
584
      dataType: 'text',
585
      success: function(val){
586
        longdescription = val;
587
      }
588
    });
589
  } else {
590
    longdescription = longdescription_elt.val();
591
  }
592

  
593
  var params = { runningnumber: position,
594
                 partnumber: partnumber,
595
                 description: description,
596
                 default_longdescription: longdescription,
597
                 set_function: function(val){
598
                   longdescription_elt.remove();
599
                   $('<input type="hidden" name="order.orderitems[].longdescription">').insertAfter(description_elt).val(val);
600
                 }
601
               };
602

  
603
  kivi.SalesPurchase.edit_longdescription_with_params(params);
604
}
605

  
563 606
$(function(){
564 607
  $('#order_[%- cv_id %]').change(reload_cv_dependend_selections);
565 608
  [%- IF SELF.cv == 'customer' %]

Auch abrufbar als: Unified diff