$::form->all_departments(\%::myconfig);
$::form->get_lists(
projects => { key => "ALL_PROJECTS", all => 1 },
- employees => "ALL_EMPLOYEES",
);
+ $::form->{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all(query => [ deleted => 0 ]);
- my $onload = "focus()"
- . qq|;setupDateFormat('|. $::myconfig{dateformat} . qq|', '| . $::locale->text("Falsches Datumsformat!") . qq|')|
- . qq|;setupPoints('|. $::myconfig{numberformat} . qq|', '| . $::locale->text("wrongformat") . qq|')|;
+ my $onload = "focus()";
$::form->header;
print $::form->parse_html_template('gl/search', {
my $row_set = [ $row ];
- if (($form->{l_subtotal} eq 'Y')
+ if ( ($form->{l_subtotal} eq 'Y' && !$form->{report_generator_csv_options_for_import} )
&& (($idx == (scalar @{ $form->{GL} } - 1))
|| ($ref->{ $form->{sort} } ne $form->{GL}->[$idx + 1]->{ $form->{sort} }))) {
push @{ $row_set }, create_subtotal_row(\%subtotals, \@columns, \%column_alignment, [ qw(debit credit) ], 'listsubtotal');
$idx++;
}
- $report->add_separator();
-
# = 0 for balanced ledger
my $balanced_ledger = $totals{debit} + $totals{debit_tax} - $totals{credit} - $totals{credit_tax};
$row->{balance}->{data} = $data;
- $report->add_data($row);
+ if ( !$form->{report_generator_csv_options_for_import} ) {
+ $report->add_separator();
+ $report->add_data($row);
+ }
my $raw_bottom_info_text;
}
sub form_header {
- my ($init) = @_;
- $main::lxdebug->enter_sub();
-
- $main::auth->assert('general_ledger');
+ $::lxdebug->enter_sub;
+ $::auth->assert('general_ledger');
- my $form = $main::form;
- my %myconfig = %main::myconfig;
- my $locale = $main::locale;
+ my ($init) = @_;
- my @old_project_ids = ();
- map({ push(@old_project_ids, $form->{"project_id_$_"})
- if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
+ my @old_project_ids = grep { $_ } map{ $::form->{"project_id_$_"} } 1..$::form->{rowcount};
- $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
+ $::form->get_lists("projects" => { "key" => "ALL_PROJECTS",
"all" => 0,
"old_id" => \@old_project_ids },
"charts" => { "key" => "ALL_CHARTS",
- "transdate" => $form->{transdate} },
+ "transdate" => $::form->{transdate} },
"taxcharts" => "ALL_TAXCHARTS");
- GL->get_chart_balances('charts' => $form->{ALL_CHARTS});
-
- my $title = $form->{title};
- $form->{title} = $locale->text("$title General Ledger Transaction");
- my $readonly = ($form->{id}) ? "readonly" : "";
-
- my $show_details_checked = $form->{show_details} ? "checked" : '';
- my $ob_transaction_checked = $form->{ob_transaction} ? "checked" : '';
- my $cb_transaction_checked = $form->{cb_transaction} ? "checked" : '';
+ GL->get_chart_balances('charts' => $::form->{ALL_CHARTS});
+ my $title = $::form->{title};
+ $::form->{title} = $::locale->text("$title General Ledger Transaction");
# $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(row) {
- var accno = document.getElementById('accno_' + row);
- var taxkey = accno.options[accno.selectedIndex].value;
- var reg = /--([0-9]*)/;
- var found = reg.exec(taxkey);
- var index = found[1];
- index = parseInt(index);
- var tax = 'taxchart_' + row;
- for (var i = 0; i < document.getElementById(tax).options.length; ++i) {
- var reg2 = new RegExp("^"+ index, "");
- if (reg2.exec(document.getElementById(tax).options[i].value)) {
- document.getElementById(tax).options[i].selected = true;
- break;
- }
- }
- };
-
- function copy_debit_to_credit() {
- var txt = document.getElementsByName('debit_1')[0].value;
- document.getElementsByName('credit_2')[0].value = txt;
- };
- //-->
- </script>
- <script type="text/javascript" src="js/show_form_details.js"></script>
- <script type="text/javascript" src="js/jquery.js"></script>
-|;
+ map { $::form->{$_} =~ s/\"/"/g }
+ qw(chart taxchart);
- $form->{selectdepartment} =~ s/ selected//;
- $form->{selectdepartment} =~
- s/option>\Q$form->{department}\E/option selected>$form->{department}/;
-
- my $description;
- if ((my $rows = $form->numtextrows($form->{description}, 50)) > 1) {
- $description =
- qq|<textarea name=description rows=$rows cols=50 wrap=soft $readonly >$form->{description}</textarea>|;
- } else {
- $description =
- qq|<input name=description size=50 value="$form->{description}" $readonly>|;
- }
-
- my $taxincluded = ($form->{taxincluded}) ? "checked" : "";
-
- if ($init) {
- $taxincluded = "checked";
- }
+ $::form->{selectdepartment} =~ s/ selected//;
+ $::form->{selectdepartment} =~
+ s/option>\Q$::form->{department}\E/option selected>$::form->{department}/;
- my $department;
- $department = qq|
- <tr>
- <th align=right nowrap>| . $locale->text('Department') . qq|</th>
- <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
- <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
- </tr>
-| if $form->{selectdepartment};
if ($init) {
- $form->{fokus} = "gl.reference";
- } else {
- $form->{fokus} = qq|gl.accno_$form->{rowcount}|;
- }
-
- # use JavaScript Calendar or not
- $form->{jsscript} = 1;
- my $jsscript = "";
- my ($button1, $button2);
- if ($form->{jsscript}) {
-
- # with JavaScript Calendar
- $button1 = qq|
- <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>
- |;
-
- #write Trigger
- $jsscript =
- Form->write_trigger(\%myconfig, "1", "transdate", "BL", "trigger1");
- } else {
-
- # without JavaScript Calendar
- $button1 =
- 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} ||= "--";
-
- $jsscript .= $form->parse_html_template('gl/form_header_chart_balances_js');
-
- $form->header;
-
- print qq|
-<body onLoad="focus()">
-
-<script type="text/javascript" src="js/follow_up.js"></script>
-
-<form method=post name="gl" action=gl.pl>
-|;
-
- $form->hide_form(qw(id closedto locked storno storno_id previous_id previous_gldate));
-
- print qq|
-<input type=hidden name=title value="$title">
-
-<input type="hidden" name="follow_up_trans_id_1" value="| . H($form->{id}) . qq|">
-<input type="hidden" name="follow_up_trans_type_1" value="gl_transaction">
-<input type="hidden" name="follow_up_trans_info_1" value="| . H($form->{id}) . qq|">
-<input type="hidden" name="follow_up_rowcount" value="1">
-
-<table width=100%>
- <tr>
- <th class=listtop>$form->{title}</th>
- </tr>| .
-
- ($form->{saved_message} ? qq|
- <tr>
- <td>$form->{saved_message}</th>
- </tr>| : '') .
-
-qq|
- <tr height="5"></tr>
- <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=right>| . $locale->text('Reference') . qq|</th>
- <td><input name=reference size=20 value="$form->{reference}" $readonly></td>
- <td align=left>
- <table>
- <tr>
- <th align=right nowrap>| . $locale->text('Date') . qq|</th>
- $button1
- </tr>
- </table>
- </td>
- </tr>|;
- if ($form->{id}) {
- print qq|
- <tr>
- <th align=right>| . $locale->text('Belegnummer') . qq|</th>
- <td><input name=id size=20 value="$form->{id}" $readonly></td>
- <td align=left>
- <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 onBlur=\"check_right_date_format(this)\"></td>
- </tr>
- </table>
- </td>
- </tr>|;
- }
- print qq|
- $department|;
- if ($form->{id}) {
- print qq|
- <tr>
- <th align=right width=1%>| . $locale->text('Description') . qq|</th>
- <td width=1%>$description</td>
- <td>
- <table>
- <tr>
- <th align=left>| . $locale->text('MwSt. inkl.') . qq|</th>
- <td><input type=checkbox name=taxincluded value=1 $taxincluded></td>
- </tr>
- </table>
- </td>
- <td align=left>
- <table width=100%>
- <tr>
- <th align=right width=50%>| . $locale->text('Mitarbeiter') . qq|</th>
- <td align=left><input name=employee size=20 value="| . H($form->{employee}) . qq|" readonly></td>
- </tr>
- </table>
- </td>
- </tr>|;
+ $::form->{fokus} = "gl.reference";
+ $::form->{taxincluded} = "1";
} else {
- print qq|
- <tr>
- <th align=left width=1%>| . $locale->text('Description') . qq|</th>
- <td width=1%>$description</td>
- <td>
- <table>
- <tr>
- <th align=left>| . $locale->text('MwSt. inkl.') . qq|</th>
- <td><input type=checkbox name=taxincluded value=1 $taxincluded></td>
- </tr>
- </table>
- </td>
- </tr>|;
+ $::form->{fokus} = qq|gl.accno_$::form->{rowcount}|;
}
- print qq|
- <tr>
- <tr><td colspan=4><table><tr>
- <td>
- | . $locale->text('OB Transaction') . qq|<input type="checkbox" name="ob_transaction" value="1" $ob_transaction_checked>
- </td>
- <td>
- | . $locale->text('CB Transaction') . qq|<input type="checkbox" name="cb_transaction" value="1" $cb_transaction_checked>
- </td>
- </tr></table></td></tr>
- <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>|;
+ $::form->{previous_id} ||= "--";
+ $::form->{previous_gldate} ||= "--";
- print qq|
- <tr>
- <td colspan=4>
- <table width=100%>
- <tr class=listheading>
- <th class=listheading style="width:15%">|
- . $locale->text('Account') . qq|</th>
- <th class=listheading style="width:10%">| . $locale->text('Chart balance') . qq|</th>
- <th class=listheading style="width:10%">|
- . $locale->text('Debit') . qq|</th>
- <th class=listheading style="width:10%">|
- . $locale->text('Credit') . qq|</th>
- <th class=listheading style="width:10%">|
- . $locale->text('Tax') . qq|</th>
- <th class=listheading style="width:5%">|
- . $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>
-|;
- }
-
- print qq|
- </tr>
+ $::form->header;
+ print $::form->parse_html_template('gl/form_header', {
+ hide_title => $title,
+ });
-$jsscript
-|;
- $main::lxdebug->leave_sub();
+ $::lxdebug->leave_sub;
}
sub form_footer {
- $main::lxdebug->enter_sub();
-
- $main::auth->assert('general_ledger');
-
- my $form = $main::form;
- my %myconfig = %main::myconfig;
- my $locale = $main::locale;
- my $cgi = $::request->{cgi};
-
- my $follow_ups_block;
- if ($form->{id}) {
- my $follow_ups = FU->follow_ups('trans_id' => $form->{id});
-
- if (@{ $follow_ups} ) {
- my $num_due = sum map { $_->{due} * 1 } @{ $follow_ups };
- $follow_ups_block = qq|<p>| . $locale->text("There are #1 unfinished follow-ups of which #2 are due.", scalar @{ $follow_ups }, $num_due) . qq|</p>|;
- }
- }
-
- my ($dec) = ($form->{totaldebit} =~ /\.(\d+)/);
- $dec = length $dec;
- my $decimalplaces = ($dec > 2) ? $dec : 2;
- my $radieren = ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
-
- map {
- $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, 2, " ")
- } qw(totaldebit totalcredit);
-
- print qq|
- <tr class=listtotal>
- <th colspan="3" align=right class=listtotal> $form->{totaldebit}</th>
- <th align=right class=listtotal> $form->{totalcredit}</th>
- <td colspan=6></td>
- </tr>
- </table>
- </td>
- </tr>
-</table>
-
-<input name=callback type=hidden value="$form->{callback}">
-
-$follow_ups_block
-
-<br>
-|;
-
- my $transdate = $form->datetonum($form->{transdate}, \%myconfig);
- my $closedto = $form->datetonum($form->{closedto}, \%myconfig);
-
- if ($form->{id}) {
-
- 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
- if (!$form->{locked} && $radieren) {
- print qq|
- <input class=submit type=submit name=action value="| . $locale->text('Post') . qq|" accesskey="b">
- <input class=submit type=submit name=action value="| . $locale->text('Delete') . qq|">|;
- }
-
- print qq|
- <input class=submit type=submit name=action id=update_button value="| . $locale->text('Update') . qq|">
- <input type="button" class="submit" onclick="follow_up_window()" value="|
- . $locale->text('Follow-Up')
- . qq|"> |;
+ $::lxdebug->enter_sub;
+ $::auth->assert('general_ledger');
- } else {
- if ($form->{draft_id}) {
- my $remove_draft_checked = $form->{remove_draft} ? 'checked' : '';
- print qq|<p>\n|
- . qq| <input name="remove_draft" id="remove_draft" type="checkbox" class="checkbox" ${remove_draft_checked}>|
- . qq| <label for="remove_draft">| . $locale->text('Remove Draft') . qq|</label>\n|
- . qq|</p>\n|;
- }
+ my ($follow_ups, $follow_ups_due);
- 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|"> |
- . NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'), '-class' => 'submit'))
- . $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}])
- . $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}]);
+ if ($::form->{id}) {
+ $follow_ups = FU->follow_ups('trans_id' => $::form->{id});
+ $follow_ups_due = sum map { $_->{due} * 1 } @{ $follow_ups || [] };
}
- print "
- </form>
+ my $radieren = $::form->current_date(\%::myconfig) eq $::form->{gldate};
-</body>
-</html>
-";
- $main::lxdebug->leave_sub();
+ print $::form->parse_html_template('gl/form_footer', {
+ radieren => $radieren,
+ follow_ups => $follow_ups,
+ follow_ups_due => $follow_ups_due,
+ });
+ $::lxdebug->leave_sub;
}
sub delete {
$form->header;
print qq|
-<body>
-
<form method=post action=gl.pl>
|;