X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fgl.pl;h=fb0de34e94e94bc2a96e789b74129e53b69de362;hb=eb07c9dd23c32937527813cd0dea27a8ffe5603e;hp=5a6404d6c77d7da8ea382b7d22f51df45bdcbca2;hpb=356cd04b385336427336465b56f7b926ebfbe484;p=kivitendo-erp.git diff --git a/bin/mozilla/gl.pl b/bin/mozilla/gl.pl index 5a6404d6c..fb0de34e9 100644 --- a/bin/mozilla/gl.pl +++ b/bin/mozilla/gl.pl @@ -31,15 +31,21 @@ # #====================================================================== +use utf8; +use strict; + +use POSIX qw(strftime); +use List::Util qw(sum); + +use SL::FU; use SL::GL; +use SL::IS; use SL::PE; +use SL::ReportGenerator; -require "$form->{path}/arap.pl"; require "bin/mozilla/common.pl"; - -1; - -# end of main +require "bin/mozilla/drafts.pl"; +require "bin/mozilla/reportgenerator.pl"; # this is for our long dates # $locale->text('January') @@ -70,23 +76,23 @@ require "bin/mozilla/common.pl"; # $locale->text('Dec') sub add { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('general_ledger'); + + my $form = $main::form; + my %myconfig = %main::myconfig; + + return $main::lxdebug->leave_sub() if (load_draft_maybe()); $form->{title} = "Add"; - $form->{callback} = - "$form->{script}?action=add&path=$form->{path}&login=$form->{login}&password=$form->{password}" - unless $form->{callback}; + $form->{callback} = "gl.pl?action=add" unless $form->{callback}; # we use this only to set a default date + # yep. aber er holt hier auch schon ALL_CHARTS. Aufwand / Nutzen? jb GL->transaction(\%myconfig, \%$form); - map { - $tax .= - qq|$_->{taxdescription} | - . ($_->{rate} * 100) . qq| %| - } @{ $form->{TAX} }; - $form->{rowcount} = 2; $form->{debit} = 0; @@ -95,49 +101,50 @@ sub add { # departments $form->all_departments(\%myconfig); - if (@{ $form->{all_departments} }) { + if (@{ $form->{all_departments} || [] }) { $form->{selectdepartment} = "\n"; map { $form->{selectdepartment} .= "$_->{description}--$_->{id}\n" - } (@{ $form->{all_departments} }); + } (@{ $form->{all_departments} || [] }); } + $form->{show_details} = $myconfig{show_form_details} unless defined $form->{show_details}; + &display_form(1); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } -sub edit { - $lxdebug->enter_sub(); +sub prepare_transaction { + $main::lxdebug->enter_sub(); - GL->transaction(\%myconfig, \%$form); + $main::auth->assert('general_ledger'); + + my $form = $main::form; + my %myconfig = %main::myconfig; - map { - $tax .= - qq|$_->{taxdescription} | - . ($_->{rate} * 100) . qq| %| - } @{ $form->{TAX} }; + GL->transaction(\%myconfig, \%$form); $form->{amount} = $form->format_amount(\%myconfig, $form->{amount}, 2); # departments $form->all_departments(\%myconfig); - if (@{ $form->{all_departments} }) { + if (@{ $form->{all_departments} || [] }) { $form->{selectdepartment} = "\n"; map { $form->{selectdepartment} .= "$_->{description}--$_->{id}\n" - } (@{ $form->{all_departments} }); + } (@{ $form->{all_departments} || [] }); } my $i = 1; my $tax = 0; my $taxaccno = ""; - foreach $ref (@{ $form->{GL} }) { - $j = $i - 1; + foreach my $ref (@{ $form->{GL} }) { + my $j = $i - 1; if ($tax && ($ref->{accno} eq $taxaccno)) { $form->{"tax_$j"} = abs($ref->{amount}); $form->{"taxchart_$j"} = $ref->{id} . "--" . $ref->{taxrate}; @@ -178,766 +185,345 @@ sub edit { ($form->datetonum($form->{transdate}, \%myconfig) <= $form->datetonum($form->{closedto}, \%myconfig)); - $form->{title} = "Edit"; - - &form_header; - &display_rows; - &form_footer; - $lxdebug->leave_sub(); - + $main::lxdebug->leave_sub(); } -sub search { - $lxdebug->enter_sub(); +sub edit { + $main::lxdebug->enter_sub(); - $form->{title} = $locale->text('Buchungsjournal'); + $main::auth->assert('general_ledger'); - $form->all_departments(\%myconfig); + my $form = $main::form; + my %myconfig = %main::myconfig; - # departments - if (@{ $form->{all_departments} }) { - $form->{selectdepartment} = "\n"; + prepare_transaction(); - map { - $form->{selectdepartment} .= - "$_->{description}--$_->{id}\n" - } (@{ $form->{all_departments} }); - } + $form->{title} = "Edit"; - $department = qq| - - | . $locale->text('Department') . qq| - $form->{selectdepartment} - -| if $form->{selectdepartment}; + $form->{show_details} = $myconfig{show_form_details} unless defined $form->{show_details}; - $form->get_lists("projects" => { "key" => "ALL_PROJECTS", - "all" => 1 }); + form_header(); + display_rows(); + form_footer(); - my %project_labels = (); - my @project_values = (""); - foreach my $item (@{ $form->{"ALL_PROJECTS"} }) { - push(@project_values, $item->{"id"}); - $project_labels{$item->{"id"}} = $item->{"projectnumber"}; - } + $main::lxdebug->leave_sub(); +} - my $projectnumber = - NTI($cgi->popup_menu('-name' => "project_id", - '-values' => \@project_values, - '-labels' => \%project_labels)); - - # use JavaScript Calendar or not - $form->{jsscript} = $jscalendar; - $jsscript = ""; - if ($form->{jsscript}) { - - # with JavaScript Calendar - $button1 = qq| - - text('button') . qq|> - |; - $button2 = qq| - - text('button') . qq|> - |; - - #write Trigger - $jsscript = - Form->write_trigger(\%myconfig, "2", "datefrom", "BR", "trigger1", - "dateto", "BL", "trigger2"); - } else { - # without JavaScript Calendar - $button1 = - qq||; - $button2 = - qq||; - } +sub search { + $::lxdebug->enter_sub; + $::auth->assert('general_ledger'); - $form->header; + $::form->all_departments(\%::myconfig); + $::form->get_lists( + projects => { key => "ALL_PROJECTS", all => 1 }, + ); + $::form->{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all(query => [ deleted => 0 ]); - print qq| - + $::form->header; + print $::form->parse_html_template('gl/search', { + department_label => sub { ("$_[0]{description}--$_[0]{id}")x2 }, + employee_label => sub { "$_[0]{id}--$_[0]{name}" }, + }); -{script}> + $::lxdebug->leave_sub; +} - +sub create_subtotal_row { + $main::lxdebug->enter_sub(); - - - $form->{title} - - - - - - - | . $locale->text('Reference') . qq| - - | . $locale->text('Source') . qq| - - - $department - - | . $locale->text('Description') . qq| - - - - | . $locale->text('Notes') . qq| - - - - | . $locale->text('Project Number') . qq| - $projectnumber - - - | . $locale->text('From') . qq| - $button1 - | . $locale->text('To (time)') . qq| - $button2 - - - | . $locale->text('Include in Report') . qq| - - - - - | - . $locale->text('All') . qq| - | - . $locale->text('Asset') . qq| - | - . $locale->text('Liability') . qq| - | - . $locale->text('Revenue') . qq| - | - . $locale->text('Expense') . qq| - - - - - - - | . $locale->text('ID') . qq| - - | . $locale->text('Date') . qq| - - | . $locale->text('Reference') . qq| - - | . $locale->text('Description') . qq| - - | . $locale->text('Notes') . qq| - - - - | . $locale->text('Debit') . qq| - - | . $locale->text('Credit') . qq| - - | . $locale->text('Source') . qq| - - | . $locale->text('Account') . qq| - - | . $locale->text('GIFI') . qq| - - - - | . $locale->text('Subtotal') . qq| - - | . $locale->text('Project Number') . qq| - - - - - - - - - - - - + my ($totals, $columns, $column_alignment, $subtotal_columns, $class) = @_; -$jsscript + my $form = $main::form; + my %myconfig = %main::myconfig; - + my $row = { map { $_ => { 'data' => '', 'class' => $class, 'align' => $column_alignment->{$_}, } } @{ $columns } }; -{path}> -{login}> -{password}> + map { $row->{$_}->{data} = $form->format_amount(\%myconfig, $totals->{$_}, 2) } @{ $subtotal_columns }; - - - + map { $totals->{$_} = 0 } @{ $subtotal_columns }; - -