Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 7589c136

Von Tamino Steinert vor 5 Monaten hinzugefügt

  • ID 7589c13627fe3de8b397d3dae6270f566664d3d2
  • Vorgänger 0cdb369e
  • Nachfolger 976b7115

S:C:Order: Positionskonfiguration für Wied. Rech. bearbeiten können

Unterschiede anzeigen:

SL/Controller/Order.pm
41 41
use SL::DB::Order::TypeData qw(:types);
42 42
use SL::DB::DeliveryOrder::TypeData qw(:types);
43 43
use SL::DB::Reclamation::TypeData qw(:types);
44
use SL::DB::PeriodicInvoiceItemsConfig;
44 45

  
45 46
use SL::Helper::CreatePDF qw(:all);
46 47
use SL::Helper::PrintOptions;
......
820 821
  $_[0]->render(\ !!$has_active_periodic_invoices, { type => 'text' });
821 822
}
822 823

  
824
sub action_show_periodic_invoice_items_config_dialog {
825
  my ($self) = @_;
826

  
827
  my $config = SL::DB::PeriodicInvoiceItemsConfig->new(
828
    %{$::form->{periodic_invoice_items_config}}
829
  );
830

  
831
  $self->render(
832
    'order/tabs/_edit_periodic_invoice_items_config', { layout => 0 },
833
    CONFIG => $config,
834
    ITEM_ID => $::form->{item_id},
835
  );
836
}
837

  
838
sub action_update_periodic_invoice_items_config_button {
839
  my ($self) = @_;
840

  
841
  my $config = SL::DB::PeriodicInvoiceItemsConfig->new(
842
    %{$::form->{periodic_invoice_items_config}}
843
  );
844
  my $item_id = $::form->{item_id} or die "No item id given";
845
  my $button_text = $self->get_button_text_for_periodic_invoice_items_config($config);
846

  
847
  $self->js->val("#periodic_invoice_items_config_button_$item_id", $button_text)->render();
848
}
849

  
850
sub get_button_text_for_periodic_invoice_items_config {
851
  my ($self, $config) = @_;
852

  
853
  my $button_text = t8('Periodic Invoices') . ': ';
854

  
855
  if ($config && $config->periodicity) {
856
    my %peridoicity_to_text = (
857
      p => t8("same as periodicity"),
858
      n => t8("never"),
859
      o => t8("one time"),
860
      m => t8("monthly"),
861
      q => t8("every third month"),
862
      b => t8("semiannually"),
863
      y => t8("yearly")
864
    );
865
    $button_text .= $peridoicity_to_text{$config->periodicity};
866
    $button_text .= " | ";
867
    $button_text .= $config->start_date_as_date || "_";
868
    $button_text .= " " . t8("to") . " ";
869
    $button_text .= $config->end_date_as_date || "_";
870
    if ($config->terminated) {
871
      $button_text .= " X";
872
    } elsif ($config->extend_automatically_by) {
873
      $button_text .= " +" . $config->extend_automatically_by;
874
    }
875

  
876
  } else {
877
    $button_text .= t8('standard');
878
  }
879

  
880
  return $button_text;
881
}
882

  
823 883
sub action_save_and_new_record {
824 884
  my ($self) = @_;
825 885
  my $to_type = $::form->{to_type};
......
1549 1609
    $item->parse_custom_variable_values;
1550 1610
  }
1551 1611

  
1552
  my $row_as_html = $self->p->render('order/tabs/_second_row', ITEM => $item, TYPE => $self->type);
1612
  my $row_as_html = $self->p->render(
1613
    'order/tabs/_second_row',
1614
    SELF => $self,
1615
    ITEM => $item,
1616
    ID   => $item_id,
1617
    TYPE => $self->type
1618
  );
1553 1619

  
1554 1620
  $self->js
1555 1621
    ->html('#second_row_' . $item_id, $row_as_html)
SL/DB/OrderItem.pm
32 32

  
33 33
__PACKAGE__->configure_acts_as_list(group_by => [qw(trans_id)]);
34 34

  
35
__PACKAGE__->before_save('_before_save_remove_empty_periodic_invoice_items_config');
36

  
37
sub _before_save_remove_empty_periodic_invoice_items_config {
38
  my ($self) = @_;
39

  
40
  if ($self->periodic_invoice_items_config
41
    && $self->periodic_invoice_items_config->periodicity eq '') {
42
    $self->periodic_invoice_items_config->delete if $self->periodic_invoice_items_config->order_item_id;
43
    $self->periodic_invoice_items_config(undef);
44
  }
45

  
46
  return 1;
47
}
48

  
49

  
35 50
sub is_price_update_available {
36 51
  my $self = shift;
37 52
  return $self->origprice > $self->part->sellprice;
js/kivi.Order.js
682 682
    return true;
683 683
  };
684 684

  
685
  ns.show_periodic_invoice_items_config_dialog = function(clicked) {
686
    if ($('#type').val() !== 'sales_order') return;
687

  
688
    let second_row = $(clicked).parents("tbody").first();
689
    let first_row = $(second_row).parents("tbody").first();
690

  
691
    let data = {
692
      type: $('#type').val(),
693
      id:   $('#id').val(),
694
      item_id: $(first_row).find('[name="orderitem_ids[+]"]').val(),
695
    };
696
    for (const value_key of [
697
        'periodicity', 'terminated', 'start_date_as_date', 'end_date_as_date',
698
        'extend_automatically_by'
699
    ]) {
700
      data[`periodic_invoice_items_config.${value_key}`] =
701
        $(second_row).find(`[name="order.orderitems[].periodic_invoice_items_config.${value_key}"]`).first().val();
702
    }
703

  
704
    kivi.popup_dialog({
705
      url:    'controller.pl?action=Order/show_periodic_invoice_items_config_dialog',
706
      data:   data,
707
      id:     'periodic_invoice_items_config_dialog',
708
      load:   kivi.reinit_widgets,
709
      dialog: {
710
        title:  kivi.t8('Edit the configuration for periodic invoice item'),
711
        width:  800,
712
        height: 650
713
      }
714
    });
715
    return true;
716
  };
717

  
718
  ns.assign_periodic_invoice_items_config = function(item_id) {
719
    let row = $(`#item_${item_id}`).parents("tbody").first();
720
    let dialog = $('#periodic_invoice_items_config_dialog');
721

  
722
    for (const value_key of [
723
        'periodicity', 'terminated', 'start_date_as_date', 'end_date_as_date',
724
        'extend_automatically_by'
725
    ]) {
726
      $(row).find(`[name="order.orderitems[].periodic_invoice_items_config.${value_key}"]`).first().val(
727
        $(dialog).find(`#periodic_invoice_items_config_${value_key}`).val()
728
      );
729
    }
730

  
731
    kivi.submit_ajax_form("controller.pl", '#periodic_invoice_items_config_from',
732
      {
733
        action: 'Order/update_periodic_invoice_items_config_button',
734
        type:    $('#type').val(),
735
        id:      $('#id').val(),
736
        item_id: item_id,
737
      }
738
    );
739

  
740
    dialog.dialog('close');
741
    return 1;
742
  }
743

  
744
  ns.delete_periodic_invoice_items_config = function(item_id) {
745
    let row = $(`#item_${item_id}`).parents("tbody").first();
746
    let dialog = $('#periodic_invoice_items_config_dialog');
747

  
748
    for (const value_key of [
749
        'periodicity', 'terminated', 'start_date_as_date', 'end_date_as_date',
750
        'extend_automatically_by'
751
    ]) {
752
      $(row).find(`[name="order.orderitems[].periodic_invoice_items_config.${value_key}"]`).first().val(null);
753
    }
754

  
755
    let data = [];
756
    data.push({name: 'action', value: 'Order/update_periodic_invoice_items_config_button'});
757
    data.push({name: 'type', value: $('#type').val()});
758
    data.push({name: 'id', value: $('#id').val()});
759
    data.push({name: 'item_id', value: item_id});
760
    $.post("controller.pl", data, kivi.eval_json_result);
761

  
762
    dialog.dialog('close');
763
    return 1;
764
  }
765

  
685 766
  ns.close_periodic_invoices_config_dialog = function() {
686 767
    $('#jq_periodic_invoices_config_dialog').dialog('close');
687 768
  };
templates/design40_webpages/order/tabs/_edit_periodic_invoice_items_config.html
1
[% USE HTML %]
2
[% USE LxERP %]
3
[% USE L %]
4

  
5
<h1>[% title %]</h1>
6

  
7
<form id="periodic_invoice_items_config_from">
8

  
9
<div class="buttons">
10
  [% L.button_tag('
11
      kivi.Order.assign_periodic_invoice_items_config("' _  ITEM_ID _ '")',
12
      LxERP.t8('Assign'))
13
      %]
14
  [% L.button_tag(
15
    'kivi.Order.delete_periodic_invoice_items_config("' _  ITEM_ID _ '")',
16
    LxERP.t8('Delete'), class='neutral')
17
    %]
18
</div>
19

  
20
<div class="wrapper">
21

  
22
<table class="tbl-horizontal">
23
  <caption>[% title %]</caption>
24
  <colgroup> <col class="wi-normal"><col class="wi-lightwide"> </colgroup>
25
  <tbody>
26
    <tr>
27
     <th>[% LxERP.t8('Terminated') %]</th>
28
     <td>
29
       [% L.yes_no_tag('periodic_invoice_items_config.terminated', CONFIG.terminated) %]
30
     </td>
31
    </tr>
32
    <tr>
33
     <th>[% LxERP.t8('Periodicity') %]</th>
34
     <td>
35
       [% L.select_tag("periodic_invoice_items_config.periodicity", [
36
           [ "p", LxERP.t8("same as periodicity") ],
37
           [ "n", LxERP.t8("never") ],
38
           [ "o", LxERP.t8("one time") ],
39
           [ "m", LxERP.t8("monthly") ],
40
           [ "q", LxERP.t8("every third month") ],
41
           [ "b", LxERP.t8("semiannually") ],
42
           [ "y", LxERP.t8("yearly") ]
43
         ],
44
         default=CONFIG.periodicity || 'p',
45
         ) %]
46
     </td>
47
    </tr>
48
    <tr>
49
     <th>[% LxERP.t8('Start date') %]</th>
50
     <td>[% L.date_tag("periodic_invoice_items_config.start_date_as_date", CONFIG.start_date_as_date) %]</td>
51
    </tr>
52
    <tr>
53
     <th>[% LxERP.t8('End date') %]</th>
54
     <td>[% L.date_tag("periodic_invoice_items_config.end_date_as_date", CONFIG.end_date_as_date) %]</td>
55
    </tr>
56
    <tr>
57
     <th>[% LxERP.t8('Extend automatically by n months') %]</th>
58
     <td>
59
      [% L.input_tag("periodic_invoice_items_config.extend_automatically_by", CONFIG.extend_automatically_by, type='number') %]
60
     </td>
61
    </tr>
62
  </tbody>
63
</table>
64

  
65
</div><!-- /.wrapper -->
66

  
67
</form>
templates/design40_webpages/order/tabs/_second_row.html
16 16
      [% END %]
17 17
      <b>[% 'Subtotal' | $T8 %]</b> [% L.yes_no_tag("order.orderitems[].subtotal", ITEM.subtotal) %]
18 18
      [% IF TYPE == "sales_order" %]
19
        <b>[% 'Recurring billing' | $T8 %]</b>
20
        [% L.select_tag("order.orderitems[].recurring_billing_mode", [[ 'always', LxERP.t8('always') ], [ 'once',   LxERP.t8('once')   ], [ 'never',  LxERP.t8('never')  ]], default=ITEM.recurring_billing_mode) %]
19
        <b>
20
          [% FOREACH value_key = [
21
            'periodicity', 'terminated', 'start_date_as_date', 'end_date_as_date',
22
            'extend_automatically_by', 'order_item_id'
23
            ] %]
24
            [%L.hidden_tag('order.orderitems[].periodic_invoice_items_config.' _ value_key, ITEM.periodic_invoice_items_config.$value_key) %]
25
          [% END %]
26
          [% L.button_tag('kivi.Order.show_periodic_invoice_items_config_dialog(this)',
27
            SELF.get_button_text_for_periodic_invoice_items_config(ITEM.periodic_invoice_items_config),
28
            id = 'periodic_invoice_items_config_button_' _ ID,
29
            class = 'neutral',
30
          )
31
          %]<b>
21 32
      [% END %]
22 33
      [% IF (TYPE == "sales_order_intake" || TYPE == "sales_order" || TYPE == "sales_quotation") %]
23 34
        <b>[% 'Ertrag' | $T8 %]</b>
templates/webpages/order/tabs/_edit_periodic_invoice_items_config.html
1
[% USE HTML %]
2
[% USE LxERP %]
3
[% USE L %]
4

  
5
<h1>[% title %]</h1>
6

  
7
<form id="periodic_invoice_items_config_from">
8

  
9
<div class="buttons">
10
  [% L.button_tag('
11
      kivi.Order.assign_periodic_invoice_items_config("' _  ITEM_ID _ '")',
12
      LxERP.t8('Assign'))
13
      %]
14
  [% L.button_tag(
15
    'kivi.Order.delete_periodic_invoice_items_config("' _  ITEM_ID _ '")',
16
    LxERP.t8('Delete'), class='neutral')
17
    %]
18
</div>
19

  
20
<table>
21
  <caption>[% title %]</caption>
22
  <tbody>
23
    <tr>
24
     <th>[% LxERP.t8('Terminated') %]</th>
25
     <td>
26
       [% L.yes_no_tag('periodic_invoice_items_config.terminated', CONFIG.terminated) %]
27
     </td>
28
    </tr>
29
    <tr>
30
     <th>[% LxERP.t8('Periodicity') %]</th>
31
     <td>
32
       [% L.select_tag("periodic_invoice_items_config.periodicity", [
33
           [ "p", LxERP.t8("same as periodicity") ],
34
           [ "n", LxERP.t8("never") ],
35
           [ "o", LxERP.t8("one time") ],
36
           [ "m", LxERP.t8("monthly") ],
37
           [ "q", LxERP.t8("every third month") ],
38
           [ "b", LxERP.t8("semiannually") ],
39
           [ "y", LxERP.t8("yearly") ]
40
         ],
41
         default=CONFIG.periodicity || 'p',
42
         ) %]
43
     </td>
44
    </tr>
45
    <tr>
46
     <th>[% LxERP.t8('Start date') %]</th>
47
     <td>[% L.date_tag("periodic_invoice_items_config.start_date_as_date", CONFIG.start_date_as_date) %]</td>
48
    </tr>
49
    <tr>
50
     <th>[% LxERP.t8('End date') %]</th>
51
     <td>[% L.date_tag("periodic_invoice_items_config.end_date_as_date", CONFIG.end_date_as_date) %]</td>
52
    </tr>
53
    <tr>
54
     <th>[% LxERP.t8('Extend automatically by n months') %]</th>
55
     <td>
56
      [% L.input_tag("periodic_invoice_items_config.extend_automatically_by", CONFIG.extend_automatically_by, type='number') %]
57
     </td>
58
    </tr>
59
  </tbody>
60
</table>
61

  
62
</form>
templates/webpages/order/tabs/_second_row.html
19 19
    <b>[%- 'Subtotal' | $T8 %]</b>&nbsp;
20 20
    [% L.yes_no_tag("order.orderitems[].subtotal", ITEM.subtotal) %]&nbsp;
21 21
    [%- IF TYPE == "sales_order" %]
22
      <b>[%- 'Recurring billing' | $T8 %]</b>&nbsp;
23
      [% L.select_tag("order.orderitems[].recurring_billing_mode", [[ 'always', LxERP.t8('always') ], [ 'once',   LxERP.t8('once')   ], [ 'never',  LxERP.t8('never')  ]], default=ITEM.recurring_billing_mode) %]&nbsp;
22
      <b>
23
        [% FOREACH value_key = [
24
          'periodicity', 'terminated', 'start_date_as_date', 'end_date_as_date',
25
          'extend_automatically_by', 'order_item_id'
26
          ] %]
27
          [%L.hidden_tag('order.orderitems[].periodic_invoice_items_config.' _ value_key, ITEM.periodic_invoice_items_config.$value_key) %]
28
        [% END %]
29
        [% L.button_tag('kivi.Order.show_periodic_invoice_items_config_dialog(this)',
30
          SELF.get_button_text_for_periodic_invoice_items_config(ITEM.periodic_invoice_items_config),
31
          id = 'periodic_invoice_items_config_button_' _ ID,
32
          class = 'neutral',
33
        )
34
        %]<b>
24 35
    [%- END %]
25 36
    [%- IF (TYPE == "sales_order_intake" || TYPE == "sales_order" || TYPE == "sales_quotation") %]
26 37
      <b>[%- 'Ertrag' | $T8 %]</b>&nbsp;

Auch abrufbar als: Unified diff