Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 662b757f

Von Moritz Bunkus vor mehr als 13 Jahren hinzugefügt

  • ID 662b757f97c456d1a8f93f1f37ae188b945da42e
  • Vorgänger 5c5cbb9f
  • Nachfolger 3f0b42e6

Verwaltung von Zahlungsbedingungen auf Drag & Drop mit AJAX und jQuery UI Sortable umgestellt

Unterschiede anzeigen:

SL/Controller/PaymentTerm.pm
64 64
  $self->redirect_to(action => 'list');
65 65
}
66 66

  
67
sub action_move_up {
67
sub action_reorder {
68 68
  my ($self) = @_;
69
  $self->{payment_term}->move_position_up;
70
  $self->redirect_to(action => 'list');
71
}
72 69

  
73
sub action_move_down {
74
  my ($self) = @_;
75
  $self->{payment_term}->move_position_down;
76
  $self->redirect_to(action => 'list');
70
  my @ids = @{ $::form->{payment_term_id} || [] };
71
  my $result = SL::DB::PaymentTerm->new->db->do_transaction(sub {
72
    foreach my $idx (0 .. scalar(@ids) - 1) {
73
      SL::DB::PaymentTerm->new(id => $ids[$idx])->load->update_attributes(sortkey => $idx + 1);
74
    }
75
  });
76

  
77
  $self->render(type => 'js', inline => '1;');
77 78
}
78 79

  
79 80
#
templates/webpages/payment_term/list.html
1 1
[% USE HTML %][% USE T8 %][% USE L %][% USE LxERP %]
2

  
3
<script type="text/javascript" src="js/jquery-ui.js"></script>
4

  
2 5
<body>
3 6
 <div class="listtop">[% FORM.title %]</div>
4 7

  
......
11 14
   </p>
12 15

  
13 16
  [%- ELSE %]
14
   <table>
17
   <table id="payment_term_list">
18
    <thead>
15 19
    <tr class="listheading">
16
     <th align="center"><img src="image/up.png"></th>
17
     <th align="center"><img src="image/down.png"></th>
20
     <th align="center"><img src="image/updown.png" alt="[ LxERP.t8('reorder item') %]"></th>
18 21
     <th>[%- 'Description' | $T8 %]</th>
19 22
     <th>[%- 'Long Description' | $T8 %]</th>
20 23
     <th align="right">[%- 'Netto Terms' | $T8 %]</th>
21 24
     <th align="right">[%- 'Skonto Terms' | $T8 %]</th>
22 25
     <th align="right">[%- 'Skonto' | $T8 %]</th>
23 26
    </tr>
27
    </thead>
24 28

  
29
    <tbody>
25 30
    [%- FOREACH payment_term = PAYMENT_TERMS %]
26
    <tr class="listrow[% loop.count % 2 %]">
27
     <td align="center">
28
      [%- UNLESS loop.first %]
29
       <a href="[% SELF.url_for(action => 'move_up', id => payment_term.id) %]"><img src="image/up.png" border="0"></a>
30
      [%- END %]
31
     </td>
32
     <td align="center">
33
      [%- UNLESS loop.last %]
34
       <a href="[% SELF.url_for(action => 'move_down', id => payment_term.id) %]"><img src="image/down.png" border="0"></a>
35
      [%- END %]
36
     </td>
31
    <tr class="listrow[% loop.count % 2 %]" id="payment_term_id_[% payment_term.id %]">
32
     <td align="center" class="dragdrop"><img src="image/updown.png" alt="[ LxERP.t8('reorder item') %]"></td>
37 33
     <td>
38 34
      <a href="[% SELF.url_for(action => 'edit', id => payment_term.id) %]">
39 35
       [%- HTML.escape(payment_term.description) %]
......
45 41
     <td align="right">[%- HTML.escape(payment_term.percent_skonto_as_number) %] %</td>
46 42
    </tr>
47 43
    [%- END %]
44
    </tbody>
48 45
   </table>
49 46
  [%- END %]
50 47

  
......
53 50
  </p>
54 51
 </form>
55 52

  
53
 [% L.sortable_element('#payment_term_list tbody', url => 'controller.pl?action=PaymentTerm/reorder', with => 'payment_term_id') %]
54

  
56 55
</body>
57 56
</html>

Auch abrufbar als: Unified diff