#======================================================================
use SL::GL;
+use SL::IS;
use SL::PE;
-require "$form->{path}/arap.pl";
+require "bin/mozilla/arap.pl";
require "bin/mozilla/common.pl";
1;
$form->{title} = "Add";
$form->{callback} =
- "$form->{script}?action=add&path=$form->{path}&login=$form->{login}&password=$form->{password}"
+ "$form->{script}?action=add&login=$form->{login}&password=$form->{password}"
unless $form->{callback};
# we use this only to set a default date
} (@{ $form->{all_departments} });
}
+ $form->{show_details} = $myconfig{show_form_details} unless defined $form->{show_details};
+
&display_form(1);
$lxdebug->leave_sub();
}
-sub edit {
+sub prepare_transaction {
$lxdebug->enter_sub();
GL->transaction(\%myconfig, \%$form);
($form->datetonum($form->{transdate}, \%myconfig) <=
$form->datetonum($form->{closedto}, \%myconfig));
+ $lxdebug->leave_sub();
+}
+
+sub edit {
+ $lxdebug->enter_sub();
+
+ prepare_transaction();
+
$form->{title} = "Edit";
- &form_header;
- &display_rows;
- &form_footer;
- $lxdebug->leave_sub();
+ $form->{show_details} = $myconfig{show_form_details} unless defined $form->{show_details};
+
+ form_header();
+ display_rows();
+ form_footer();
+ $lxdebug->leave_sub();
}
+
sub search {
$lxdebug->enter_sub();
'-labels' => \%project_labels));
# use JavaScript Calendar or not
- $form->{jsscript} = $jscalendar;
+ $form->{jsscript} = 1;
$jsscript = "";
if ($form->{jsscript}) {
# with JavaScript Calendar
$button1 = qq|
- <td><input name=datefrom id=datefrom size=11 title="$myconfig{dateformat}">
+ <td><input name=datefrom id=datefrom size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">
<input type=button name=datefrom id="trigger1" value=|
. $locale->text('button') . qq|></td>
|;
$button2 = qq|
- <td><input name=dateto id=dateto size=11 title="$myconfig{dateformat}">
+ <td><input name=dateto id=dateto size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">
<input type=button name=dateto id="trigger2" value=|
. $locale->text('button') . qq|></td>
|;
# without JavaScript Calendar
$button1 =
- qq|<td><input name=datefrom id=datefrom size=11 title="$myconfig{dateformat}"></td>|;
+ qq|<td><input name=datefrom id=datefrom size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\"></td>|;
$button2 =
- qq|<td><input name=dateto id=dateto size=11 title="$myconfig{dateformat}"></td>|;
+ qq|<td><input name=dateto id=dateto size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\"></td>|;
}
-
+ $form->{javascript} .= qq|<script type="text/javascript" src="js/common.js"></script>|;
$form->header;
-
+ $onload = qq|focus()|;
+ $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
+ $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
print qq|
-<body>
+<body onLoad="$onload">
<form method=post action=$form->{script}>
<input type=hidden name=nextsub value=generate_report>
-<input type=hidden name=path value=$form->{path}>
<input type=hidden name=login value=$form->{login}>
<input type=hidden name=password value=$form->{password}>
GL->all_transactions(\%myconfig, \%$form);
$callback =
- "$form->{script}?action=generate_report&path=$form->{path}&login=$form->{login}&password=$form->{password}";
+ "$form->{script}?action=generate_report&login=$form->{login}&password=$form->{password}";
$href = $callback;
$column_data{id} = "<td align=right> $ref->{id} </td>";
$column_data{transdate} = "<td align=center>$transdate</td>";
$column_data{reference} =
- "<td align=center><a href=$ref->{module}.pl?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{reference}</td>";
+ "<td align=center><a href=$ref->{module}.pl?action=edit&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{reference}</td>";
$column_data{description} = "<td align=center>$ref->{description} </td>";
$column_data{source} = "<td align=center>$ref->{source} </td>";
$column_data{notes} = "<td align=center>$ref->{notes} </td>";
<input name=callback type=hidden value="$form->{callback}">
-<input type=hidden name=path value=$form->{path}>
<input type=hidden name=login value=$form->{login}>
<input type=hidden name=password value=$form->{password}>
my ($init) = @_;
$lxdebug->enter_sub();
+ $form->{debit_1} = 0 if !$form->{"debit_1"};
$form->{totaldebit} = 0;
$form->{totalcredit} = 0;
if ($init) {
$korrektur =
- qq|<td><input type="checkbox" name="korrektur_$i" value="1"</td>|;
+ qq|<td><input type="checkbox" name="korrektur_$i" value="1"></td>|;
if ($form->{transfer}) {
$fx_transaction = qq|
<td><input name="fx_transaction_$i" class=checkbox type=checkbox value=1></td>
'-labels' => \%project_labels,
'-default' => $form->{"project_id_$i"} ));
+ my $copy2credit = 'onkeyup="copy_debit_to_credit()"' if $i == 1;
+
print qq|<tr valign=top>
$accno
$fx_transaction
- <td><input name="debit_$i" size=8 value="$form->{"debit_$i"}" accesskey=$i $debitreadonly></td>
+ <td><input name="debit_$i" size="8" value="$form->{"debit_$i"}" accesskey=$i $copy2credit $debitreadonly></td>
<td><input name="credit_$i" size=8 value="$form->{"credit_$i"}" $creditreadonly></td>
<td><input name="tax_$i" size=6 value="$form->{"tax_$i"}"></td>
$korrektur
- $tax
+ $tax|;
+
+ if ($form->{show_details}) {
+ print qq|
$source
$memo
<td>$projectnumber</td>
+|;
+ }
+ print qq|
</tr>
-
- |;
+|;
}
$form->hide_form(qw(rowcount selectaccno));
$form->{title} = $locale->text("$title General Ledger Transaction");
$readonly = ($form->{id}) ? "readonly" : "";
+ $show_details_checked = "checked" if $form->{show_details};
+
# $locale->text('Add General Ledger Transaction')
# $locale->text('Edit General Ledger Transaction')
map { $form->{$_} =~ s/\"/"/g }
qw(reference description chart taxchart);
+
$form->{javascript} = qq|<script type="text/javascript">
<!--
function setTaxkey(accno, row) {
}
}
};
+
+ function copy_debit_to_credit() {
+ var txt = document.getElementsByName('debit_1')[0].value;
+ document.getElementsByName('credit_2')[0].value = txt;
+ };
+
//-->
</script>|;
+ $form->{javascript} .= qq|<script type="text/javascript" src="js/show_form_details.js"></script>|;
$form->{selectdepartment} =~ s/ selected//;
$form->{selectdepartment} =~
}
# use JavaScript Calendar or not
- $form->{jsscript} = $jscalendar;
+ $form->{jsscript} = 1;
$jsscript = "";
if ($form->{jsscript}) {
# with JavaScript Calendar
$button1 = qq|
- <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value="$form->{transdate}" $readonly>
+ <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value="$form->{transdate}" $readonly onBlur=\"check_right_date_format(this)\">
<input type=button name=transdate id="trigger1" value=|
. $locale->text('button') . qq|></td>
|;
# without JavaScript Calendar
$button1 =
- qq|<td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value="$form->{transdate}" $readonly></td>|;
+ qq|<td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value="$form->{transdate}" $readonly onBlur=\"check_right_date_format(this)\"></td>|;
}
+ $form->{previous_id} ||= "--";
+ $form->{previous_gldate} ||= "--";
+
$form->header;
print qq|
<body onLoad="fokus()">
<form method=post name="gl" action=$form->{script}>
+|;
-<input name=id type=hidden value=$form->{id}>
+ $form->hide_form(qw(id closedto locked storno storno_id previous_id previous_gldate));
-<input type=hidden name=closedto value=$form->{closedto}>
-<input type=hidden name=locked value=$form->{locked}>
+ print qq|
<input type=hidden name=title value="$title">
<tr>
<td>
<table width=100%>
+ <tr>
+ <td colspan="6" align="left">|
+ . $locale->text("Previous transnumber text")
+ . " $form->{previous_id} "
+ . $locale->text("Previous transdate text")
+ . " $form->{previous_gldate}"
+ . qq|</td>
+ </tr>
<tr>
- <th align=left>| . $locale->text('Reference') . qq|</th>
+ <th align=right>| . $locale->text('Reference') . qq|</th>
<td><input name=reference size=20 value="$form->{reference}" $readonly></td>
<td align=left>
<table>
<table>
<tr>
<th align=right width=50%>| . $locale->text('Buchungsdatum') . qq|</th>
- <td align=left><input name=gldate size=11 title="$myconfig{dateformat}" value=$form->{gldate} $readonly></td>
+ <td align=left><input name=gldate size=11 title="$myconfig{dateformat}" value=$form->{gldate} $readonly onBlur=\"check_right_date_format(this)\"></td>
</tr>
</table>
</td>
if ($form->{id}) {
print qq|
<tr>
- <th align=left width=1%>| . $locale->text('Description') . qq|</th>
+ <th align=right width=1%>| . $locale->text('Description') . qq|</th>
<td width=1%>$description</td>
<td>
<table>
<table width=100%>
<tr>
<th align=right width=50%>| . $locale->text('Mitarbeiter') . qq|</th>
- <td align=left><input name=employee size=11 value=$form->{employee} $readonly></td>
+ <td align=left><input name=employee size=20 value="| . H($form->{employee}) . qq|" readonly></td>
</tr>
</table>
</td>
</td>
</tr>|;
}
+
+ print qq|<tr>
+ <td width="1%" align="right" nowrap>| . $locale->text('Show details') . qq|</td>
+ <td width="1%"><input type="checkbox" onclick="show_form_details();" name="show_details" value="1" $show_details_checked></td>
+ </tr>|;
+
print qq|
<tr>
<td colspan=4>
<th class=listheading style="width:5%">|
. $locale->text('Korrektur') . qq|</th>
<th class=listheading style="width:10%">|
- . $locale->text('Taxkey') . qq|</th>
- <th class=listheading style="width:20%">|
- . $locale->text('Source') . qq|</th>
+ . $locale->text('Taxkey') . qq|</th>|;
+
+ if ($form->{show_details}) {
+ print qq|
+ <th class=listheading style="width:20%">| . $locale->text('Source') . qq|</th>
<th class=listheading style="width:20%">| . $locale->text('Memo') . qq|</th>
- <th class=listheading style="width:20%">|
- . $locale->text('Project Number') . qq|</th>
+ <th class=listheading style="width:20%">| . $locale->text('Project Number') . qq|</th>
+|;
+ }
+
+ print qq|
</tr>
$jsscript
</tr>
</table>
-<input type=hidden name=path value=$form->{path}>
<input type=hidden name=login value=$form->{login}>
<input type=hidden name=password value=$form->{password}>
if ($form->{id}) {
- print qq|<input class=submit type=submit name=action value="|
- . $locale->text('Storno') . qq|">|;
+ if (!$form->{storno}) {
+ print qq|<input class=submit type=submit name=action value="|
+ . $locale->text('Storno') . qq|">|;
+ }
# Löschen und Ändern von Buchungen nicht mehr möglich (GoB) nur am selben Tag möglich
# }
} else {
if ($transdate > $closedto) {
- print qq|<input class=submit type=submit name=action value="|
+ print qq|<input class=submit type=submit name=action id=update_button value="|
. $locale->text('Update') . qq|">
<input class=submit type=submit name=action value="|
. $locale->text('Post') . qq|">|;
if (GL->delete_transaction(\%myconfig, \%$form)){
# saving the history
if(!exists $form->{addition} && $form->{id} ne "") {
+ $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
$form->{addition} = "DELETED";
$form->save_history($form->dbconnect(\%myconfig));
}
sub post {
$lxdebug->enter_sub();
+ $form->{title} = $locale->text("$form->{title} General Ledger Transaction");
+
# check if there is something in reference and date
$form->isblank("reference", $locale->text('Reference missing!'));
$form->isblank("transdate", $locale->text('Transaction Date missing!'));
my @flds =
qw(accno debit credit projectnumber fx_transaction source memo tax taxchart);
- if ($form->{storno}) {
- for my $i (1 .. $form->{rowcount}) {
- unless (($form->{"debit_$i"} eq "") && ($form->{"credit_$i"} eq "")) {
- if ($form->{"debit_$i"} ne "") {
- $form->{"credit_$i"} = $form->{"debit_$i"};
- $form->{"debit_$i"} = "";
- } elsif ($form->{"credit_$i"} ne "") {
- $form->{"debit_$i"} = $form->{"credit_$i"};
- $form->{"credit_$i"} = "";
- }
- }
- }
- }
for my $i (1 .. $form->{rowcount}) {
undef($form->{callback});
# saving the history
if(!exists $form->{addition} && $form->{id} ne "") {
+ $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
$form->{addition} = "SAVED";
$form->{what_done} = $locale->text("Buchungsnummer") . " = " . $form->{id};
$form->save_history($form->dbconnect(\%myconfig));
}
# /saving the history
- $form->redirect("Buchung gespeichert. Buchungsnummer = " . $form->{id});
+
+ $form->{callback} = build_std_url("action=add", "show_details");
+ $form->redirect($form->{callback});
+
$lxdebug->leave_sub();
}
sub storno {
$lxdebug->enter_sub();
- $form->{id} = 0;
- $form->{storno} = 1;
+ if (IS->has_storno(\%myconfig, $form, 'gl')) {
+ $form->{title} = $locale->text("Cancel General Ledger Transaction");
+ $form->error($locale->text("Transaction has already been cancelled!"));
+ }
+
+ my %keep_keys = map { $_, 1 } qw(login password id stylesheet);
+ map { delete $form->{$_} unless $keep_keys{$_} } keys %{ $form };
+
+ prepare_transaction();
+
+ for my $i (1 .. $form->{rowcount}) {
+ for (qw(debit credit tax)) {
+ $form->{"${_}_$i"} =
+ ($form->{"${_}_$i"})
+ ? $form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2)
+ : "";
+ }
+ }
+
+ $form->{storno} = 1;
+ $form->{storno_id} = $form->{id};
+ $form->{id} = 0;
+
+ $form->{reference} = "Storno-" . $form->{reference};
+ $form->{description} = "Storno-" . $form->{description};
+
+ for my $i (1 .. $form->{rowcount}) {
+ next if (($form->{"debit_$i"} eq "") && ($form->{"credit_$i"} eq ""));
+
+ if ($form->{"debit_$i"} ne "") {
+ $form->{"credit_$i"} = $form->{"debit_$i"};
+ $form->{"debit_$i"} = "";
+
+ } else {
+ $form->{"debit_$i"} = $form->{"credit_$i"};
+ $form->{"credit_$i"} = "";
+ }
+ }
+
+ post();
+
# saving the history
if(!exists $form->{addition} && $form->{id} ne "") {
+ $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
$form->{addition} = "STORNO";
$form->save_history($form->dbconnect(\%myconfig));
}
# /saving the history
- &post;
+
$lxdebug->leave_sub();
}