36 |
36 |
use SL::IR;
|
37 |
37 |
use SL::AR;
|
38 |
38 |
use SL::AP;
|
39 |
|
use strict ("vars", "subs");
|
|
39 |
use strict;
|
40 |
40 |
#use warnings;
|
41 |
41 |
|
42 |
42 |
require "bin/mozilla/arap.pl";
|
... | ... | |
118 |
118 |
}
|
119 |
119 |
|
120 |
120 |
sub form_header {
|
121 |
|
$lxdebug->enter_sub();
|
|
121 |
$lxdebug->enter_sub;
|
122 |
122 |
|
123 |
123 |
$auth->assert('cash');
|
124 |
124 |
|
125 |
|
my ($vc, $vclabel, $allvc, $arap, $exchangerate);
|
126 |
|
my ($jsscript, $button1, $button2, $onload);
|
127 |
|
|
128 |
|
$vclabel = ucfirst $form->{vc};
|
129 |
|
$vclabel = $locale->text($vclabel);
|
130 |
|
|
131 |
|
if ($form->{type} eq 'receipt') {
|
132 |
|
$form->{title} = $locale->text('Receipt');
|
133 |
|
$form->{origtitle} = "Receipt";
|
134 |
|
}
|
135 |
|
if ($form->{type} eq 'check') {
|
136 |
|
$form->{title} = $locale->text('Payment');
|
137 |
|
$form->{origtitle} = "Payment";
|
138 |
|
}
|
139 |
|
|
140 |
|
# $locale->text('Customer')
|
141 |
|
# $locale->text('Vendor')
|
|
125 |
my ($vc, $arap, $exchangerate);
|
|
126 |
my ($onload);
|
142 |
127 |
|
143 |
128 |
if ($form->{ $form->{vc} } eq "") {
|
144 |
129 |
map { $form->{"addr$_"} = "" } (1 .. 4);
|
145 |
130 |
}
|
146 |
131 |
|
147 |
|
if ($form->{currency} ne $form->{defaultcurrency}) {
|
148 |
|
$form->{exchangerate} =
|
149 |
|
$form->format_amount(\%myconfig, $form->{exchangerate});
|
150 |
|
if ($form->{forex}) {
|
151 |
|
$exchangerate = qq|
|
152 |
|
<tr>
|
153 |
|
<th align=right nowrap>| . $locale->text('Exchangerate') . qq|</th>
|
154 |
|
<td colspan=3><input type=hidden name=exchangerate size=10 value=$form->{exchangerate}>$form->{exchangerate}</td>
|
155 |
|
</tr>
|
156 |
|
|;
|
157 |
|
} else {
|
158 |
|
$exchangerate = qq|
|
159 |
|
<tr>
|
160 |
|
<th align=right nowrap>| . $locale->text('Exchangerate') . qq|</th>
|
161 |
|
<td colspan=3><input name=exchangerate size=10 value=$form->{exchangerate}></td>
|
162 |
|
</tr>
|
163 |
|
|;
|
164 |
|
}
|
165 |
|
}
|
166 |
|
foreach my $item ($form->{vc}, "account", "currency", $form->{ARAP}) {
|
|
132 |
for my $item ($form->{vc}, "account", "currency", $form->{ARAP}) {
|
167 |
133 |
$form->{"select$item"} =~ s/ selected//;
|
168 |
|
$form->{"select$item"} =~
|
169 |
|
s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
|
|
134 |
$form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
|
170 |
135 |
}
|
171 |
136 |
|
172 |
137 |
$vc =
|
... | ... | |
174 |
139 |
? qq|<select name=$form->{vc}>$form->{"select$form->{vc}"}\n</select>|
|
175 |
140 |
: qq|<input name=$form->{vc} size=35 value="$form->{$form->{vc}}">|;
|
176 |
141 |
|
177 |
|
if ($form->{all_vc}) {
|
178 |
|
$allvc = "checked";
|
179 |
|
$form->{openinvoices} = "";
|
180 |
|
} else {
|
181 |
|
$allvc = "";
|
182 |
|
$form->{openinvoices} = 1;
|
183 |
|
}
|
|
142 |
$form->{openinvoices} = $form->{all_vc} ? "" : 1;
|
184 |
143 |
|
185 |
144 |
# $locale->text('AR')
|
186 |
145 |
# $locale->text('AP')
|
187 |
146 |
|
188 |
|
$form->{jsscript} = 1;
|
189 |
|
$jsscript = "";
|
190 |
|
if ($form->{jsscript}) {
|
191 |
|
|
192 |
|
# with JavaScript Calendar
|
193 |
|
$button1 = qq|
|
194 |
|
<td><input name=datepaid id=datepaid size=11 title="$myconfig{dateformat}" value="$form->{datepaid}" onBlur=\"check_right_date_format(this)\">
|
195 |
|
<input type=button name=datepaid id="trigger1" value=|
|
196 |
|
. $locale->text('button') . qq|></td>
|
197 |
|
|;
|
198 |
|
|
199 |
|
#write Trigger
|
200 |
|
$jsscript =
|
201 |
|
Form->write_trigger(\%myconfig, "1", "datepaid", "BL", "trigger1");
|
202 |
|
} else {
|
203 |
|
|
204 |
|
# without JavaScript Calendar
|
205 |
|
$button1 = qq|
|
206 |
|
<td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\"></td>|;
|
207 |
|
}
|
208 |
|
$form->{javascript} .= qq|<script type="text/javascript" src="js/common.js"></script>|;
|
209 |
147 |
$form->header;
|
210 |
148 |
|
211 |
149 |
$arap = lc $form->{ARAP};
|
212 |
150 |
$onload = qq|focus()|;
|
213 |
151 |
$onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
|
214 |
152 |
$onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
|
215 |
|
print qq|
|
216 |
|
<body onLoad="$onload">
|
217 |
|
|
218 |
|
<form method=post action=cp.pl>
|
219 |
|
|
220 |
|
<input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
|
221 |
|
<input type=hidden name=closedto value=$form->{closedto}>
|
222 |
|
<input type=hidden name=vc value=$form->{vc}>
|
223 |
|
<input type=hidden name=type value=$form->{type}>
|
224 |
|
<input type=hidden name=formname value=$form->{type}>
|
225 |
|
<input type=hidden name=queued value="$form->{queued}">
|
226 |
|
<input type=hidden name=arap value=$arap>
|
227 |
|
<input type=hidden name=ARAP value=$form->{ARAP}>
|
228 |
|
<input type=hidden name=openinvoices value=$form->{openinvoices}>
|
229 |
|
<input type=hidden name=title value="$form->{title}">
|
230 |
|
<input type=hidden name=origtitle value="$form->{origtitle}">
|
231 |
|
|
232 |
|
<table width=100%>
|
233 |
|
<tr>
|
234 |
|
<th class=listtop>$form->{title}</th>
|
235 |
|
</tr>
|
236 |
|
<tr height="5"></tr>
|
237 |
|
<tr>
|
238 |
|
<td>
|
239 |
|
<table width=100%>
|
240 |
|
<tr valign=top>
|
241 |
|
<td>
|
242 |
|
<table>
|
243 |
|
<tr>
|
244 |
|
<th align=right>$vclabel</th>
|
245 |
|
<td>$vc</td>
|
246 |
|
<input type=hidden name="select$form->{vc}" value="| . H($form->{"select$form->{vc}"}) . qq|">
|
247 |
|
<input type=hidden name="$form->{vc}_id" value="| . H($form->{"$form->{vc}_id"}) . qq|">
|
248 |
|
<input type=hidden name="old$form->{vc}" value="| . H($form->{"old$form->{vc}"}) . qq|">
|
249 |
|
</tr>
|
250 |
|
<tr>
|
251 |
|
<th align=right>| . $locale->text('Invoice Number') . qq|</th>
|
252 |
|
<td><input name="invnumber" size="35"</td>
|
253 |
|
</tr>
|
254 |
|
<tr valign=top>
|
255 |
|
<th align=right nowrap>| . $locale->text('Address') . qq|</th>
|
256 |
|
<td colspan=2>
|
257 |
|
<table>
|
258 |
|
<tr>
|
259 |
|
<td>$form->{street}</td>
|
260 |
|
</tr>
|
261 |
|
<tr>
|
262 |
|
<td>$form->{zipcode}</td>
|
263 |
|
</tr>
|
264 |
|
<tr>
|
265 |
|
<td>$form->{city}</td>
|
266 |
|
</tr>
|
267 |
|
<tr>
|
268 |
|
<td>$form->{country}</td>
|
269 |
|
</tr>
|
270 |
|
</table>
|
271 |
|
</td>
|
272 |
|
<input type=hidden name=street value="$form->{street}">
|
273 |
|
<input type=hidden name=zipcode value="$form->{zipcode}">
|
274 |
|
<input type=hidden name=city value="$form->{city}">
|
275 |
|
<input type=hidden name=country value="$form->{country}">
|
276 |
|
</tr>
|
277 |
|
<tr>
|
278 |
|
<th align=right>| . $locale->text('Memo') . qq|</th>
|
279 |
|
<td colspan=2><input name="memo" size=30 value="$form->{memo}"></td>
|
280 |
|
</tr>
|
281 |
|
</table>
|
282 |
|
</td>
|
283 |
|
<td align=right>
|
284 |
|
<table>
|
285 |
|
<tr>
|
286 |
|
<th align=right nowrap>| . $locale->text('Account') . qq|</th>
|
287 |
|
<td colspan=3><select name=account>$form->{selectaccount}</select>
|
288 |
|
<input type=hidden name=selectaccount value="$form->{selectaccount}">
|
289 |
|
</td>
|
290 |
|
</tr>
|
291 |
|
<tr>
|
292 |
|
<th align=right nowrap>| . $locale->text('Date') . qq|</th>
|
293 |
|
$button1
|
294 |
|
</tr>
|
295 |
|
<tr>
|
296 |
|
<th align=right nowrap>| . $locale->text('Currency') . qq|</th>
|
297 |
|
<td><select name=currency>$form->{selectcurrency}</select></td>
|
298 |
|
<input type=hidden name=selectcurrency value="$form->{selectcurrency}">
|
299 |
|
<input type=hidden name=oldcurrency value=$form->{oldcurrency}>
|
300 |
|
</tr>
|
301 |
|
$exchangerate
|
302 |
|
<tr>
|
303 |
|
<th align=right nowrap>| . $locale->text('Source') . qq|</th>
|
304 |
|
<td colspan=3><input name=source value="$form->{source}" size=10></td>
|
305 |
|
</tr>
|
306 |
|
<tr>
|
307 |
|
<th align="right" nowrap>| . $locale->text('Amount') . qq|</th>
|
308 |
|
<td colspan="3">| . $form->format_amount(\%myconfig, $form->{amount}, 2) . qq|</td>
|
309 |
|
</tr>
|
310 |
|
</table>
|
311 |
|
</td>
|
312 |
|
</tr>
|
313 |
|
</table>
|
314 |
|
</td>
|
315 |
|
</tr>
|
316 |
|
|
317 |
|
$jsscript
|
318 |
|
|;
|
319 |
|
|
320 |
|
if ($form->{openinvoices_other_currencies}) {
|
321 |
|
my $warning = $form->{vc} eq 'customer' ? $::locale->text('There are #1 more open invoices for this customer with other currencies.', $form->{openinvoices_other_currencies})
|
322 |
|
: $::locale->text('There are #1 more open invoices from this vendor with other currencies.', $form->{openinvoices_other_currencies});
|
323 |
|
|
324 |
|
print qq|
|
325 |
|
|
326 |
|
<input type="hidden" name="openinvoices_other_currencies" value="| . H($form->{openinvoices_other_currencies}) . qq|">
|
327 |
|
<tr>
|
328 |
|
<td><b>| . $::locale->text('Note') . qq|: $warning</b></td>
|
329 |
|
</tr>
|
330 |
|
|;
|
331 |
|
}
|
332 |
153 |
|
333 |
|
$lxdebug->leave_sub();
|
|
154 |
print $::form->parse_html_template('cp/form_header', {
|
|
155 |
is_customer => $form->{vc} eq 'customer',
|
|
156 |
is_receipt => $form->{type} eq 'receipt',
|
|
157 |
onload => $onload,
|
|
158 |
arap => $arap,
|
|
159 |
vccontent => $vc,
|
|
160 |
});
|
|
161 |
|
|
162 |
$lxdebug->leave_sub;
|
334 |
163 |
}
|
335 |
164 |
|
336 |
165 |
sub list_invoices {
|
337 |
|
$lxdebug->enter_sub();
|
338 |
|
|
339 |
|
$auth->assert('cash');
|
340 |
|
|
341 |
|
my (@column_index, %column_data, $colspan, $invoice);
|
342 |
|
my ($totalamount, $totaldue, $totalpaid);
|
343 |
|
|
344 |
|
@column_index = qw(invnumber transdate amount due checked paid);
|
345 |
|
|
346 |
|
$colspan = $#column_index + 1;
|
347 |
|
|
348 |
|
$invoice = $locale->text('Invoices');
|
349 |
|
|
350 |
|
print qq|
|
351 |
|
<input type=hidden name=column_index value="id @column_index">
|
352 |
|
<tr>
|
353 |
|
<td>
|
354 |
|
<table width=100%>
|
355 |
|
<tr>
|
356 |
|
<th class=listheading colspan=$colspan>$invoice</th>
|
357 |
|
</tr>
|
358 |
|
|;
|
359 |
|
|
360 |
|
$column_data{invnumber} =
|
361 |
|
qq|<th nowrap class=listheading>| . $locale->text('Invoice') . "</th>";
|
362 |
|
$column_data{transdate} =
|
363 |
|
qq|<th nowrap class=listheading>| . $locale->text('Date') . "</th>";
|
364 |
|
$column_data{amount} =
|
365 |
|
qq|<th nowrap class=listheading>| . $locale->text('Amount') . "</th>";
|
366 |
|
$column_data{due} =
|
367 |
|
qq|<th nowrap class=listheading>| . $locale->text('Due') . "</th>";
|
368 |
|
$column_data{paid} =
|
369 |
|
qq|<th nowrap class=listheading>| . $locale->text('Amount') . "</th>";
|
370 |
|
$column_data{checked} =
|
371 |
|
qq|<th nowrap class=listheading>| . $locale->text('Select') . "</th>";
|
372 |
|
|
373 |
|
print qq|
|
374 |
|
<tr>
|
375 |
|
|;
|
376 |
|
map { print "$column_data{$_}\n" } @column_index;
|
377 |
|
print qq|
|
378 |
|
</tr>
|
379 |
|
|;
|
380 |
|
|
381 |
|
for my $i (1 .. $form->{rowcount}) {
|
382 |
|
|
383 |
|
my $j = 0;
|
384 |
|
|
385 |
|
map {
|
386 |
|
$form->{"${_}_$i"} =
|
387 |
|
$form->parse_amount(\%myconfig, $form->{"${_}_$i"})
|
388 |
|
} qw(amount due paid);
|
389 |
|
|
390 |
|
$totalamount += $form->{"amount_$i"};
|
391 |
|
$totaldue += $form->{"due_$i"};
|
392 |
|
$totalpaid += $form->{"paid_$i"};
|
393 |
|
|
394 |
|
map {
|
395 |
|
$form->{"${_}_$i"} =
|
396 |
|
$form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2)
|
397 |
|
} qw(amount due paid);
|
398 |
|
|
399 |
|
$column_data{invnumber} = qq|<td>$form->{"invnumber_$i"}</td>
|
400 |
|
<input type=hidden name="invnumber_$i" value="$form->{"invnumber_$i"}">
|
401 |
|
<input type=hidden name="id_$i" value=$form->{"id_$i"}>|;
|
402 |
|
$column_data{transdate} = qq|<td width=15%>$form->{"transdate_$i"}</td>
|
403 |
|
<input type=hidden name="transdate_$i" value=$form->{"transdate_$i"}>|;
|
404 |
|
$column_data{amount} =
|
405 |
|
qq|<td align=right width=15%>$form->{"amount_$i"}</td>
|
406 |
|
<input type=hidden name="amount_$i" value=$form->{"amount_$i"}>|;
|
407 |
|
$column_data{due} = qq|<td align=right width=15%>$form->{"due_$i"}</td>
|
408 |
|
<input type=hidden name="due_$i" value=$form->{"due_$i"}>|;
|
409 |
|
|
410 |
|
$column_data{paid} =
|
411 |
|
qq|<td align=right width=15%><input name="paid_$i" size=10 value=$form->{"paid_$i"}></td>|;
|
412 |
|
|
413 |
|
$form->{"checked_$i"} = ($form->{"checked_$i"}) ? "checked" : "";
|
414 |
|
$column_data{checked} =
|
415 |
|
qq|<td align=center width=10%><input name="checked_$i" type=checkbox style=checkbox $form->{"checked_$i"}></td>|;
|
416 |
|
|
417 |
|
$j++;
|
418 |
|
$j %= 2;
|
419 |
|
print qq|
|
420 |
|
<tr class=listrow$j>
|
421 |
|
|;
|
422 |
|
map { print "$column_data{$_}\n" } @column_index;
|
423 |
|
print qq|
|
424 |
|
</tr>
|
425 |
|
|;
|
|
166 |
$::lxdebug->enter_sub;
|
|
167 |
$::auth->assert('cash');
|
|
168 |
|
|
169 |
my @columns = qw(amount due paid invnumber id transdate checked);
|
|
170 |
my (@invoices, %total);
|
|
171 |
for my $i (1 .. $::form->{rowcount}) {
|
|
172 |
push @invoices, +{ map { $_ => $::form->{"$_\_$i"} } @columns };
|
|
173 |
$total{$_} += $invoices[-1]{$_} = $::form->parse_amount(\%::myconfig, $invoices[-1]{$_}) for qw(amount due paid);
|
426 |
174 |
}
|
427 |
175 |
|
428 |
|
map { $column_data{$_} = "<td> </td>" } @column_index;
|
429 |
|
|
430 |
|
$column_data{amount} =
|
431 |
|
qq|<th class=listtotal align=right>|
|
432 |
|
. $form->format_amount(\%myconfig, $totalamount, 2, " ")
|
433 |
|
. qq|</th>|;
|
434 |
|
$column_data{due} =
|
435 |
|
qq|<th class=listtotal align=right>|
|
436 |
|
. $form->format_amount(\%myconfig, $totaldue, 2, " ")
|
437 |
|
. qq|</th>|;
|
438 |
|
$column_data{paid} =
|
439 |
|
qq|<th class=listtotal align=right>|
|
440 |
|
. $form->format_amount(\%myconfig, $totalpaid, 2, " ")
|
441 |
|
. qq|</th>|;
|
442 |
|
|
443 |
|
print qq|
|
444 |
|
<tr class=listtotal>
|
445 |
|
|;
|
446 |
|
map { print "$column_data{$_}\n" } @column_index;
|
447 |
|
print qq|
|
448 |
|
</tr>
|
449 |
|
</table>
|
450 |
|
</td>
|
451 |
|
</tr>
|
452 |
|
|;
|
|
176 |
print $::form->parse_html_template('cp/invoices', {
|
|
177 |
invoices => \@invoices,
|
|
178 |
totals => \%total,
|
|
179 |
});
|
453 |
180 |
|
454 |
|
$lxdebug->leave_sub();
|
|
181 |
$::lxdebug->leave_sub;
|
455 |
182 |
}
|
456 |
183 |
|
457 |
184 |
sub form_footer {
|
458 |
|
$lxdebug->enter_sub();
|
|
185 |
$::lxdebug->enter_sub;
|
|
186 |
$::auth->assert('cash');
|
459 |
187 |
|
460 |
|
$auth->assert('cash');
|
461 |
|
|
462 |
|
print qq|
|
463 |
|
<tr>
|
464 |
|
<td><hr size=3 noshade></td>
|
465 |
|
</tr>
|
466 |
|
</table>
|
467 |
|
<input type=hidden name=rowcount value=$form->{rowcount}>
|
468 |
|
|
469 |
|
<br>
|
470 |
|
<input class=submit type=submit name=action value="|
|
471 |
|
. $locale->text('Update') . qq|">
|
472 |
|
<input class=submit type=submit name=action value="|
|
473 |
|
. $locale->text('Post') . qq|">
|
474 |
|
</form>
|
|
188 |
print $::form->parse_html_template('cp/form_footer');
|
475 |
189 |
|
476 |
|
</body>
|
477 |
|
</html>
|
478 |
|
|;
|
479 |
|
|
480 |
|
$lxdebug->leave_sub();
|
|
190 |
$::lxdebug->leave_sub;
|
481 |
191 |
}
|
482 |
192 |
|
483 |
193 |
sub update {
|
... | ... | |
651 |
361 |
|
652 |
362 |
# Beim Aktualisieren wird das Konto übernommen
|
653 |
363 |
# und jetzt auch Beleg und Datum
|
654 |
|
$form->{callback} = "cp.pl?action=payment&vc=$form->{vc}&type=$form->{type}&account=$form->{account}&$form->{currency}" .
|
|
364 |
$form->{callback} = "cp.pl?action=payment&vc=$form->{vc}&type=$form->{type}&account=$form->{account}&$form->{currency}" .
|
655 |
365 |
"&datepaid=$form->{datepaid}&source=$form->{source}";
|
656 |
366 |
|
657 |
|
my $msg1 = "$form->{origtitle} posted!";
|
658 |
|
my $msg2 = "Cannot post $form->{origtitle}!";
|
|
367 |
my $msg1 = $::form->{type} eq 'receipt' ? $::locale->text("Receipt posted!") : $::locale->text("Payment posted!");
|
|
368 |
my $msg2 = $::form->{type} eq 'receipt' ? $::locale->text("Cannot post Receipt!") : $::locale->text("Cannot post Payment!");
|
659 |
369 |
|
660 |
|
# $locale->text('Payment posted!')
|
661 |
|
# $locale->text('Receipt posted!')
|
662 |
|
# $locale->text('Cannot post Payment!')
|
663 |
|
# $locale->text('Cannot post Receipt!')
|
664 |
370 |
# Die Nachrichten (Receipt posted!) werden nicht angezeigt.
|
665 |
371 |
# Entweder wieder aktivieren oder komplett rausnehmen
|
666 |
|
$form->redirect($locale->text($msg1))
|
667 |
|
if (CP->process_payment(\%myconfig, \%$form));
|
668 |
|
$form->error($locale->text($msg2));
|
|
372 |
$form->redirect($msg1) if (CP->process_payment(\%::myconfig, $::form));
|
|
373 |
$form->error($msg2);
|
669 |
374 |
|
670 |
375 |
$lxdebug->leave_sub();
|
671 |
376 |
}
|
... | ... | |
684 |
389 |
::end_of_request();
|
685 |
390 |
}
|
686 |
391 |
$form->error($locale->text('Date missing!')) unless $form->{datepaid};
|
687 |
|
my $selected_check = 1;
|
|
392 |
my $selected_check = 1;
|
688 |
393 |
for my $i (1 .. $form->{rowcount}) {
|
689 |
394 |
if ($form->{"checked_$i"}) {
|
690 |
395 |
if ($form->parse_amount(\%myconfig, $form->{"paid_$i"}, 2) <= 0) { # negativen Betrag eingegeben
|
... | ... | |
692 |
397 |
}
|
693 |
398 |
undef($selected_check);
|
694 |
399 |
# last; # ich muss doch über alle buchungen laufen, da ich noch
|
695 |
|
# die freitext-eingabe der werte prüfen will
|
|
400 |
# die freitext-eingabe der werte prüfen will
|
696 |
401 |
}
|
697 |
402 |
}
|
698 |
403 |
$form->error($locale->text('No transaction selected!')) if $selected_check;
|
cp templates.