Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision da6943d4

Von Sven Schöling vor etwa 13 Jahren hinzugefügt

  • ID da6943d46ec5b1aee6e69f928ac6f1417166e5ce
  • Vorgänger 89834c12
  • Nachfolger 590bb235

rc.pl display_form in template ausgelagert.

Warnung: Muss nochmal gut durchgetestet werden.

Unterschiede anzeigen:

bin/mozilla/rc.pl
75 75
}
76 76

  
77 77
sub display_form {
78
  $main::lxdebug->enter_sub();
79

  
80
  my $form     = $main::form;
81
  my %myconfig = %main::myconfig;
82
  my $locale   = $main::locale;
83

  
84
  $main::auth->assert('cash');
85

  
86
  my @column_index = qw(cleared transdate source name credit debit balance);
87
  my %column_header;
88
  $column_header{cleared} = "<th>&nbsp;</th>";
89
  $column_header{source}  =
90
    "<th class=listheading>" . $locale->text('Source') . "</a></th>";
91
  $column_header{name} =
92
    "<th class=listheading>" . $locale->text('Description') . "</a></th>";
93
  $column_header{transdate} =
94
    "<th class=listheading>" . $locale->text('Date') . "</a></th>";
95

  
96
  if ($form->{category} eq 'A') {
97
    $column_header{debit} =
98
      "<th class=listheading>" . $locale->text('Deposit') . "</a></th>";
99
    $column_header{credit} =
100
      "<th class=listheading>" . $locale->text('Payment') . "</a></th>";
101
  } else {
102
    $column_header{debit} =
103
      "<th class=listheading>" . $locale->text('Decrease') . "</a></th>";
104
    $column_header{credit} =
105
      "<th class=listheading>" . $locale->text('Increase') . "</a></th>";
106
  }
107

  
108
  $column_header{balance} =
109
    "<th class=listheading>" . $locale->text('Balance') . "</a></th>";
110

  
111
  my $option;
112
  if ($form->{fromdate}) {
113
    $option .= "\n<br>" if ($option);
114
    $option .=
115
        $locale->text('From') . "&nbsp;"
116
      . $locale->date(\%myconfig, $form->{fromdate}, 0);
117
  }
118
  if ($form->{todate}) {
119
    $option .= "\n<br>" if ($option);
120
    $option .=
121
        $locale->text('Until') . "&nbsp;"
122
      . $locale->date(\%myconfig, $form->{todate}, 0);
123
  }
124

  
125
  $form->{title} = "$form->{accno}--$form->{account}";
126

  
127
  $form->header;
128

  
129
  print qq|
130
<body>
131

  
132
<form method=post action=$form->{script}>
133

  
134
<table width=100%>
135
  <tr>
136
    <th class=listtop>$form->{title}</th>
137
  </tr>
138
  <tr height="5"></tr>
139
  <tr>
140
    <td>$option</td>
141
  </tr>
142
  <tr>
143
    <td>
144
      <table width=100%>
145
        <tr class=listheading>
146
|;
147

  
148
  map { print "\n$column_header{$_}" } @column_index;
149

  
150
  print qq|
151
        </tr>
152
|;
153

  
154
  my $ml = ($form->{category} eq 'A') ? -1 : 1;
155
  $form->{beginningbalance} *= $ml;
156
  my $balance        = $form->{beginningbalance};
157
  my $clearedbalance = $balance;
158
  my $i              = 0;
159
  my $id             = 0;
160

  
161
  my %column_data;
162
  map { $column_data{$_} = "<td>&nbsp;</td>" }
163
    qw(cleared transdate source name debit credit);
164
  $column_data{balance} =
165
    "<td align=right>"
166
    . $form->format_amount(\%myconfig, $balance, 2, 0) . "</td>";
167
  my $j = 0;
168
  print qq|
169
        <tr class=listrow$j>
170
|;
171

  
172
  map { print "\n$column_data{$_}" } @column_index;
173

  
174
  print qq|
175
        </tr>
176
|;
177

  
178
  my $cleared;
179
  my $totaldebits;
180
  my $totalcredits;
181
  my $fx_transaction;
182
  my $fx;
183
  foreach my $ref (@{ $form->{PR} }) {
184

  
185
    $balance += $ref->{amount} * $ml;
186
    $cleared += $ref->{amount} * $ml if $ref->{cleared};
187

  
188
    $column_data{name}   = "<td>$ref->{name}&nbsp;</td>";
189
    $column_data{source} = qq|<td>$ref->{source}&nbsp;</a>
190
    </td>|;
191
    $column_data{transdate} = "<td>$ref->{transdate}&nbsp;</td>";
192

  
193
    $column_data{debit}  = "<td>&nbsp;</td>";
194
    $column_data{credit} = "<td>&nbsp;</td>";
195

  
196
    if ($ref->{amount} < 0) {
197
      $totaldebits += $ref->{amount} * -1;
198
      $column_data{debit} =
199
          "<td align=right>"
200
        . $form->format_amount(\%myconfig, $ref->{amount} * -1, 2, "&nbsp;")
201
        . "</td>";
202
    } else {
203
      $totalcredits += $ref->{amount};
204
      $column_data{credit} =
205
          "<td align=right>"
206
        . $form->format_amount(\%myconfig, $ref->{amount}, 2, "&nbsp;")
207
        . "</td>";
208
    }
209

  
210
    $column_data{balance} =
211
      "<td align=right>"
212
      . $form->format_amount(\%myconfig, $balance, 2, 0) . "</td>";
213

  
214
    if ($ref->{fx_transaction}) {
215
      $i++ unless $id == $ref->{id};
216
      $fx_transaction = 1;
217
      $fx += $ref->{amount} * $ml;
218
      $column_data{cleared} = qq|<td align=center>&nbsp;
219
      <input type=hidden name="fxoid_$i" value=$ref->{oid}>
220
      </td>|;
221
    } else {
222
      $i++ unless ($fx_transaction && $id == $ref->{id});
223
      $fx_transaction = 0;
224
      $column_data{cleared} = qq|<td>
225
      <input name="cleared_$i" type=checkbox class=checkbox value=1 $ref->{cleared}>
226
      <input type=hidden name="oid_$i" value=$ref->{oid}>
227
      </td>|;
228
    }
229
    $id = $ref->{id};
230

  
231
    $j++;
232
    $j %= 2;
233
    print qq|
234
        <tr class=listrow$j>
235
|;
236

  
237
    map { print "\n$column_data{$_}" } @column_index;
238

  
239
    print qq|
240
        </tr>
241
|;
78
  $::lxdebug->enter_sub;
79
  $::auth->assert('cash');
242 80

  
81
  my @options;
82
  push @options, $::locale->text('From') . " " . $::locale->date(\%::myconfig, $::form->{fromdate}, 0) if $::form->{fromdate};
83
  push @options, $::locale->text('Until') . " " . $::locale->date(\%::myconfig, $::form->{todate}, 0) if $::form->{todate};
84

  
85
  my $ml = ($::form->{category} eq 'A') ? -1 : 1;
86
  my $beginningbalance = $::form->{beginningbalance} * $ml;
87
  my $clearedbalance   =
88
  my $balance          = $beginningbalance;
89
  my $i                = 0;
90
  my $last_id          = 0;
91
  my ($last_fx, @rows, $cleared, $totaldebits, $totalcredits, $fx);
92

  
93
  for my $ref (@{ $::form->{PR} }) {
94
    $balance      += $ref->{amount} * $ml;
95
    $cleared      += $ref->{amount} * $ml if $ref->{cleared};
96
    $totaldebits  += $ref->{amount} * -1  if $ref->{amount} < 0;
97
    $totalcredits += $ref->{amount}       if $ref->{amount} >= 0;
98
    $fx           += $ref->{amount} * $ml if $ref->{fx_transaction};
99
    $i++                                  if (!$ref->{fx_transaction} && !$last_fx) || $last_id != $ref->{id};
100
    $last_fx       = $ref->{fx_transaction};
101
    $last_id       = $ref->{id};
102

  
103
    push @rows, { %$ref, balance => $balance, i => $i };
243 104
  }
244 105

  
245
  # print totals
246
  map { $column_data{$_} = "<td>&nbsp;</td>" } @column_index;
247

  
248
  $column_data{debit} =
249
    "<th class=listtotal align=right>"
250
    . $form->format_amount(\%myconfig, $totaldebits, 2, "&nbsp;") . "</th>";
251
  $column_data{credit} =
252
    "<th class=listtotal align=right>"
253
    . $form->format_amount(\%myconfig, $totalcredits, 2, "&nbsp;") . "</th>";
254

  
255
  print qq|
256
        <tr class=listtotal>
257
|;
258

  
259
  map { print "\n$column_data{$_}" } @column_index;
260

  
261
  $form->{statementbalance} =
262
    $form->parse_amount(\%myconfig, $form->{statementbalance});
263
  my $difference =
264
    $form->format_amount(\%myconfig,
265
                        $form->{statementbalance} - $clearedbalance - $cleared,
266
                        2, 0);
267

  
268
  $form->{statementbalance} =
269
    $form->format_amount(\%myconfig, $form->{statementbalance}, 2, 0);
270

  
271
  $clearedbalance = $form->format_amount(\%myconfig, $clearedbalance, 2, 0);
272

  
273
  my $exchdiff;
274
  if ($fx) {
275
    $fx       = $form->format_amount(\%myconfig, $fx, 2, 0);
276
    $exchdiff = qq|
277
          <th align=right nowrap>| . $locale->text('Exchangerate Difference') . qq|</th>
278
          <td width=10%></td>
279
          <td align=right>$fx</td>
280
|;
281
  }
106
  my $statementbalance = $::form->parse_amount(\%::myconfig, $::form->{statementbalance});
107
  my $difference       = $statementbalance - $clearedbalance - $cleared;
282 108

  
283
  print qq|
284
        </tr>
285
      </table>
286
    </td>
287
  </tr>
288
  <tr>
289
    <td>
290
      <table width=100%>
291
        <tr valign=top>
292
          <td>
293
            <table>
294
              <tr>
295
                <th align=right nowrap>| . $locale->text('Cleared Balance') . qq|</th>
296
                <td width=10%></td>
297
                <td align=right>$clearedbalance</td>
298
              </tr>
299
              <tr>
300
                $exchdiff
301
              </tr>
302
            </table>
303
          </td>
304
          <td align=right>
305
            <table>
306
              <tr>
307
                <th align=right nowrap>| . $locale->text('Statement Balance') . qq|</th>
308
                <td width=10%></td>
309
                <td align=right><input name=statementbalance size=11 value=$form->{statementbalance}></td>
310
              </tr>
311
              <tr>
312
                <th align=right nowrap>| . $locale->text('Difference') . qq|</th>
313
                <td width=10%></td>
314
                <td align=right><input name=null size=11 value=$difference></td>
315
                <input type=hidden name=difference value=$difference>
316
              </tr>
317
            </table>
318
          </td>
319
        </tr>
320
      </table>
321
    </td>
322
  </tr>
323
  <tr>
324
    <td><hr size=3 noshade></td>
325
  </tr>
326
</table>
327

  
328
<input type=hidden name=rowcount value=$i>
329
<input type=hidden name=accno value=$form->{accno}>
330
<input type=hidden name=account value="$form->{account}">
331

  
332
<input type=hidden name=fromdate value=$form->{fromdate}>
333
<input type=hidden name=todate value=$form->{todate}>
334

  
335
<br>
336
<input type=submit class=submit name=action value="|
337
    . $locale->text('Update') . qq|">
338
<input type=submit class=submit name=action value="|
339
    . $locale->text('Select all') . qq|">
340
<input type=submit class=submit name=action value="|
341
    . $locale->text('Done') . qq|">
342

  
343
</form>
344

  
345
</body>
346
</html>
347
|;
109
  $::form->header;
110
  print $::form->parse_html_template('rc/step2', {
111
    is_asset         => $::form->{category} eq 'A',
112
    option           => \@options,
113
    DATA             => \@rows,
114
    total            => {
115
      credit => $totalcredits,
116
      debit  => $totaldebits,
117
    },
118
    balance          => {
119
      beginning => $beginningbalance,
120
      cleared   => $clearedbalance,
121
      statement => $statementbalance,
122
    },
123
    difference       => $difference,
124
    rowcount         => $i,
125
    fx               => $fx,
126
  });
348 127

  
349
  $main::lxdebug->leave_sub();
128
  $::lxdebug->leave_sub;
350 129
}
351 130

  
352 131
sub update {
templates/webpages/rc/step2.html
1
[%- USE HTML  %]
2
[%- USE L  %]
3
[%- USE T8 %]
4
[%- USE LxERP  %]
5
<body>
6

  
7
<h1>[% accno | html %]--[% account | html %]</h1>
8

  
9
<p>[% FOREACH row IN option %][% row %][% ', ' UNLESS loop.last %][% END %]</p>
10

  
11
<form method=post action="[% script %]">
12

  
13
<table width=100%>
14
  <tr class=listheading>
15
   <th>&nbsp;</th>
16
   <th>[% 'Date' | $T8 %]</th>
17
   <th>[% 'Source' | $T8 %]</th>
18
   <th>[% 'Description' | $T8 %]</th>
19
[%- IF is_asset %]
20
   <th>[% 'Deposit' | $T8 %]</th>
21
   <th>[% 'Payment' | $T8 %]</th>
22
[%- ELSE %]
23
   <th>[% 'Decrease' | $T8 %]</th>
24
   <th>[% 'Increase' | $T8 %]</th>
25
[%- END %]
26
   <th>[% 'Balance' | $T8 %]</th>
27
  </tr>
28
  <tr class="listrow[% row.j %]">
29
   <td></td>
30
   <td></td>
31
   <td></td>
32
   <td></td>
33
   <td class='numeric'></td>
34
   <td class='numeric'></td>
35
   <td class='numeric'>[% LxERP.format_amount(balance.beginning, 2, 0) %]</td>
36
  </tr>
37
[% FOREACH row = DATA %]
38
  <tr class="listrow[% loop.count % 2 %]">
39
   <td>
40
[%- IF row.fx_transaction %]
41
     [% L.hidden_tag('fxoid_' _ row.i, row.oid) %]
42
[%- ELSE %]
43
     [% L.checkbox_tag('cleared_' _ row.i, checked=row.cleared) %]
44
     [% L.hidden_tag('oid_' _ row.i, row.oid) %]
45
[%- END %]
46
   </td>
47
   <td>[% row.transdate %]</td>
48
   <td>[% row.source %]</td>
49
   <td>[% row.name %]</td>
50
   <td class='numeric'>[% LxERP.format_amount(row.amount, 2)  IF row.amount > 0 %]</td>
51
   <td class='numeric'>[% LxERP.format_amount(row.amount * -1, 2) IF row.amount < 0 %]</td>
52
   <td class='numeric'>[% LxERP.format_amount(row.balance, 2, 0) %]</td>
53
  </tr>
54
[% END %]
55
  <tr class=listtotal>
56
   <td></td>
57
   <td></td>
58
   <td></td>
59
   <td></td>
60
   <td class='numeric'>[% LxERP.format_amount(total.credit, 2, 0) %]</td>
61
   <td class='numeric'>[% LxERP.format_amount(total.debit, 2, 0) %]</td>
62
   <td class='numeric'></td>
63
  </tr>
64
</table>
65

  
66
      <table width=100%>
67
        <tr valign=top>
68
          <td>
69
            <table>
70
              <tr>
71
                <th align=right nowrap>[% 'Cleared Balance' | $T8 %]</th>
72
                <td width=10%></td>
73
                <td align=right>[% LxERP.format_amount(balance.cleared, 2, 0) %]</td>
74
              </tr>
75
              <tr>
76
[%- IF fx %]
77
                <th align=right nowrap>[% 'Exchangerate Difference' | $T8 %]</th>
78
                <td width=10%></td>
79
                <td align=right>[% LxERP.format_amount(fx, 2, 0) %]</td>
80
[%- END %]
81
              </tr>
82
            </table>
83
          </td>
84
          <td align=right>
85
            <table>
86
              <tr>
87
                <th align=right nowrap>[% 'Statement Balance' | $T8 %]</th>
88
                <td width=10%></td>
89
                <td align=right><input name="statementbalance" size=11 value="[% LxERP.format_amount(balance.statement, 2, 0) %]"></td>
90
              </tr>
91
              <tr>
92
                <th align=right nowrap>[% 'Difference' | $T8 %]</th>
93
                <td width=10%></td>
94
                <td align=right><input name=null size=11 value="[% LxERP.format_amount(difference, 2, 0) %]"></td>
95
                <input type=hidden name=difference value="[% LxERP.format_amount(difference, 2, 0) %]">
96
              </tr>
97
            </table>
98
          </td>
99
        </tr>
100
      </table>
101

  
102
<hr size=3 noshade>
103
<br>
104

  
105
<input type=hidden name=rowcount value="[% rowcount %]">
106
<input type=hidden name=accno value="[% accno %]">
107
<input type=hidden name=account value="[% account %]">
108

  
109
<input type=hidden name=fromdate value="[% fromdate %]">
110
<input type=hidden name=todate value="[% todate %]">
111

  
112
<br>
113
<input type=submit class=submit name=action value="[% 'Update' | $T8 %]">
114
<input type=submit class=submit name=action value="[% 'Select all' | $T8 %]">
115
<input type=submit class=submit name=action value="[% 'Done' | $T8 %]">
116

  
117
</form>
118

  
119
</body>
120
</html>

Auch abrufbar als: Unified diff