X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Frp.pl;h=a7f6edeac0f756e43f88caf20409c7742d881732;hb=a19d5fb7fc372f5931d704c427ee14e1c1c1ddae;hp=e3c64b0c6aa747d5f70f372acde329cefd9930ea;hpb=e3b8d5321e86ba3ea9dbe3997e21202935f3d140;p=kivitendo-erp.git diff --git a/bin/mozilla/rp.pl b/bin/mozilla/rp.pl index e3c64b0c6..a7f6edeac 100644 --- a/bin/mozilla/rp.pl +++ b/bin/mozilla/rp.pl @@ -28,7 +28,8 @@ # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1335, USA. #====================================================================== # # module for preparing Income Statement and Balance Sheet @@ -37,13 +38,17 @@ use POSIX qw(strftime); -use SL::PE; +use SL::DB::Default; +use SL::DB::Project; +use SL::DB::Customer; use SL::RP; use SL::Iconv; +use SL::Locale::String qw(t8); +use SL::Presenter::Tag; use SL::ReportGenerator; use Data::Dumper; +use List::MoreUtils qw(any); -require "bin/mozilla/arap.pl"; require "bin/mozilla/common.pl"; require "bin/mozilla/reportgenerator.pl"; @@ -92,22 +97,21 @@ use strict; # $locale->text('Receipts') # $locale->text('Payments') # $locale->text('Project Transactions') -# $locale->text('Non-taxable Sales') -# $locale->text('Non-taxable Purchases') # $locale->text('Business evaluation') # $form->parse_html_template('rp/html_report_susa') my $rp_access_map = { - 'projects' => 'report', - 'ar_aging' => 'general_ledger', - 'ap_aging' => 'general_ledger', - 'receipts' => 'cash', - 'payments' => 'cash', - 'trial_balance' => 'report', - 'income_statement' => 'report', - 'bwa' => 'report', - 'balance_sheet' => 'report', + 'projects' => 'report', + 'ar_aging' => 'general_ledger', + 'ap_aging' => 'general_ledger', + 'receipts' => 'cash', + 'payments' => 'cash', + 'trial_balance' => 'report', + 'income_statement' => 'report', + 'erfolgsrechnung' => 'report', + 'bwa' => 'report', + 'balance_sheet' => 'report', }; sub check_rp_access { @@ -120,837 +124,103 @@ sub check_rp_access { } sub report { - $main::lxdebug->enter_sub(); + $::lxdebug->enter_sub; check_rp_access(); - my $form = $main::form; - my %myconfig = %main::myconfig; - my $locale = $main::locale; - my %title = ( - 'balance_sheet' => 'Balance Sheet', - 'income_statement' => 'Income Statement', - 'trial_balance' => 'Trial Balance', - 'ar_aging' => 'Search AR Aging', - 'ap_aging' => 'Search AP Aging', - 'tax_collected' => 'Tax collected', - 'tax_paid' => 'Tax paid', - 'nontaxable_sales' => 'Non-taxable Sales', - 'nontaxable_purchases' => 'Non-taxable Purchases', - 'receipts' => 'Receipts', - 'payments' => 'Payments', - 'projects' => 'Project Transactions', - 'bwa' => 'Business evaluation', + balance_sheet => $::locale->text('Balance Sheet'), + income_statement => $::locale->text('Income Statement'), + erfolgsrechnung => $::locale->text('Erfolgsrechnung'), + trial_balance => $::locale->text('Trial Balance'), + ar_aging => $::locale->text('Search AR Aging'), + ap_aging => $::locale->text('Search AP Aging'), + tax_collected => $::locale->text('Tax collected'), + tax_paid => $::locale->text('Tax paid'), + receipts => $::locale->text('Receipts'), + payments => $::locale->text('Payments'), + projects => $::locale->text('Project Transactions'), + bwa => $::locale->text('Business evaluation'), ); - $form->{title} = $locale->text($title{ $form->{report} }); - - my $accrual = ($main::eur) ? "" : "checked"; - my $cash = ($main::eur) ? "checked" : ""; - - my $year = (localtime)[5] + 1900; + $::form->{title} = $title{$::form->{report}}; + $::request->{layout}->add_javascripts('kivi.CustomerVendor.js'); + $::request->{layout}->add_javascripts('autocomplete_project.js'); + $::form->{fromdate} = DateTime->today->truncate(to => 'year')->to_kivitendo; + $::form->{todate} = DateTime->today->truncate(to => 'year')->add(years => 1)->add(days => -1)->to_kivitendo; # get departments - $form->all_departments(\%myconfig); - if (@{ $form->{all_departments} || [] }) { - $form->{selectdepartment} = "\n"; - map { $form->{selectdepartment} .= "$_->{description}--$_->{id}\n" } @{ $form->{all_departments} || [] }; - } - - my $department = qq| - - | . $locale->text('Department') . qq| - $form->{selectdepartment} - -| if $form->{selectdepartment}; - - $form->get_lists("projects" => { "key" => "ALL_PROJECTS", - "all" => 1 }); - - my %project_labels = (); - my @project_values = (""); - foreach my $item (@{ $form->{"ALL_PROJECTS"} }) { - push(@project_values, $item->{"id"}); - $project_labels{$item->{"id"}} = $item->{"projectnumber"}; - } - - my $projectnumber = - NTI($main::cgi->popup_menu('-name' => "project_id", - '-values' => \@project_values, - '-labels' => \%project_labels)); - - # use JavaScript Calendar or not - $form->{jsscript} = 1; - my $jsscript = ""; - my ( $name_1, $id_1, $value_1, $trigger_1, $name_2, $id_2, $value_2, $trigger_2, ); - if ($form->{report} eq "balance_sheet") { - $name_1 = "asofdate"; - $id_1 = "asofdate"; - $value_1 = "$form->{asofdate}"; - $trigger_1 = "trigger1"; - $name_2 = "compareasofdate"; - $id_2 = "compareasofdate"; - $value_2 = "$form->{compareasofdate}"; - $trigger_2 = "trigger2"; - } elsif ($form->{report} =~ /(receipts|payments)$/) { - $name_1 = "fromdate"; - $id_1 = "fromdate"; - $value_1 = "$form->{fromdate}"; - $trigger_1 = "trigger1"; - $name_2 = "todate"; - $id_2 = "todate"; - $value_2 = ""; - $trigger_2 = "trigger2"; - } elsif (($form->{report} eq "ar_aging") || ($form->{report} eq "ap_aging")) { - $name_1 = "fromdate"; - $id_1 = "fromdate"; - $value_1 = "$form->{fromdate}"; - $trigger_1 = "trigger1"; - $name_2 = "todate"; - $id_2 = "todate"; - $value_2 = ""; - $trigger_2 = "trigger2"; - - } else { - $name_1 = "fromdate"; - $id_1 = "fromdate"; - $value_1 = "$form->{fromdate}"; - $trigger_1 = "trigger1"; - $name_2 = "todate"; - $id_2 = "todate"; - $value_2 = ""; - $trigger_2 = "trigger2"; - } - - my ($button1, $button1_2, $button2, $button2_2); - my $checked; - - # with JavaScript Calendar - if ($form->{jsscript}) { - if ($name_1 eq "") { - $button1 = qq| |; - $button1_2 = qq| text('button') . qq|>|; - - #write Trigger - $jsscript = Form->write_trigger(\%myconfig, "1", "$name_2", "BR", "$trigger_2"); - } else { - $button1 = qq| |; - $button1_2 = qq| text('button') . qq|>|; - $button2 = qq| |; - $button2_2 = qq| text('button') . qq|> |; - - #write Trigger - $jsscript = Form->write_trigger(\%myconfig, "2", "$name_1", "BR", "$trigger_1", "$name_2", "BL", "$trigger_2"); - } - } else { - - # without JavaScript Calendar - if ($name_1 eq "") { - $button1 = qq||; - } else { - $button1 = qq||; - $button2 = qq||; - } - } - $form->{javascript} .= qq||; - $form->header; - my $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| - - -{script}> - - - - - - $form->{title} - - - - - - $department -|; - - if ($form->{report} eq "projects") { - print qq| - - | . $locale->text('Project') . qq| - - - - - | . $locale->text('From') . qq| - $button1 - $button1_2 - | . $locale->text('Bis') . qq| - $button2 - $button2_2 - - - - - - - - - | . $locale->text('Include in Report') . qq| - | . $locale->text('Heading') . qq| - | . $locale->text('Subtotal') . qq| - - -$jsscript -|; - } - - if ($form->{report} eq "income_statement") { - print qq| - - | . $locale->text('Project') . qq| - $projectnumber - - - - - - | . $locale->text('Customized Report') . qq| - - - | . $locale->text('Year') . qq| - - -|; - - print qq| - - | . $locale->text('Yearly') . qq| - | . $locale->text('Quarterly') . qq| - | . $locale->text('Monthly') . qq| - - - - 1. | . $locale->text('Quarter') . qq| -|; - $checked = ""; - print qq| - | . $locale->text('January') . qq| -|; - $checked = ""; - print qq| - | . $locale->text('May') . qq| - | . $locale->text('September') . qq| - - - - - 2. | . $locale->text('Quarter') . qq| - | . $locale->text('February') . qq| - | . $locale->text('June') . qq| - | . $locale->text('October') . qq| - - - - 3. | . $locale->text('Quarter') . qq| - | . $locale->text('March') . qq| - | . $locale->text('July') . qq| - | . $locale->text('November') . qq| - - - - - 4. | . $locale->text('Quarter') . qq| - | . $locale->text('April') . qq| - | . $locale->text('August') . qq| - | . $locale->text('December') . qq| - - - - - - - | . $locale->text('Free report period') . qq| - | . $locale->text('From') . qq| - $button1 - $button1_2 - | . $locale->text('Bis') . qq| - $button2 - $button2_2 - - - - - - - | . $locale->text('Method') . qq| - | . $locale->text('Accrual') . qq| - | . $locale->text('EUR') . qq| - - -$jsscript -|; - } - - if ($form->{report} eq "bwa") { - print qq| - - | . $locale->text('Project') . qq| - $projectnumber - - - - - - | . $locale->text('Customized Report') . qq| - - - | . $locale->text('Year') . qq| - - -|; - - print qq| - - | . $locale->text('Yearly') . qq| - | . $locale->text('Quarterly') . qq| - | . $locale->text('Monthly') . qq| - - - - 1. | . $locale->text('Quarter') . qq| -|; - $checked = "checked"; - print qq| - | . $locale->text('January') . qq| -|; - $checked = ""; - print qq| - | . $locale->text('May') . qq| - | . $locale->text('September') . qq| - - - - - 2. | . $locale->text('Quarter') . qq| - | . $locale->text('February') . qq| - | . $locale->text('June') . qq| - | . $locale->text('October') . qq| - - - - 3. | . $locale->text('Quarter') . qq| - | . $locale->text('March') . qq| - | . $locale->text('July') . qq| - | . $locale->text('November') . qq| - - - - - 4. | . $locale->text('Quarter') . qq| - | . $locale->text('April') . qq| - | . $locale->text('August') . qq| - | . $locale->text('December') . qq| - - - - - - - | . $locale->text('Free report period') . qq| - | . $locale->text('From') . qq| - $button1 - $button1_2 - | . $locale->text('Bis') . qq| - $button2 - $button2_2 - - - - - - - | . $locale->text('Method') . qq| - | . $locale->text('Accrual') . qq| - | . $locale->text('EUR') . qq| - - - | . $locale->text('Decimalplaces') . qq| - - - -$jsscript -|; + $::form->all_departments(\%::myconfig); + if (@{ $::form->{all_departments} || [] }) { + $::form->{selectdepartment} = "\n"; + map { $::form->{selectdepartment} .= "$_->{description}--$_->{id}\n" } @{ $::form->{all_departments} || [] }; } - if ($form->{report} eq "balance_sheet") { - print qq| - - - | . $locale->text('as at') . qq| - - $button1 - $button1_2 - - | . $locale->text('Compare to') . qq| - - $button2 - $button2_2 - - - - | . $locale->text('Decimalplaces') . qq| - - - - - - - - - - | . $locale->text('Method') . qq| - | . $locale->text('Accrual') . qq| - | . $locale->text('EUR') . qq| - - - - | . $locale->text('Include in Report') . qq| - | . $locale->text('Heading') . qq| - | . $locale->text('Subtotal') . qq| - | . $locale->text('Account Number') . qq| - - -$jsscript -|; - } - - if ($form->{report} eq "trial_balance") { - print qq| - - | . $locale->text('Project') . qq| - $projectnumber - - - - - - | . $locale->text('Customized Report') . qq| - - - | . $locale->text('Year') . qq| - - -|; - - print qq| - - | . $locale->text('Yearly') . qq| - | . $locale->text('Quarterly') . qq| - | . $locale->text('Monthly') . qq| - - - - 1. | . $locale->text('Quarter') . qq| -|; - $checked = "checked"; - print qq| - | . $locale->text('January') . qq| -|; - $checked = ""; - print qq| - | . $locale->text('May') . qq| - | . $locale->text('September') . qq| - - - - - 2. | . $locale->text('Quarter') . qq| - | . $locale->text('February') . qq| - | . $locale->text('June') . qq| - | . $locale->text('October') . qq| - - - - 3. | . $locale->text('Quarter') . qq| - | . $locale->text('March') . qq| - | . $locale->text('July') . qq| - | . $locale->text('November') . qq| - - - - - 4. | . $locale->text('Quarter') . qq| - | . $locale->text('April') . qq| - | . $locale->text('August') . qq| - | . $locale->text('December') . qq| - - - - - - - | . $locale->text('Free report period') . qq| - | . $locale->text('From') . qq| - $button1 - $button1_2 - | . $locale->text('Bis') . qq| - $button2 - $button2_2 - - - - - - - | . $locale->text('Method') . qq| - | . $locale->text('Accrual') . qq| - | . $locale->text('EUR') . qq| - - - | . $locale->text('All Accounts') . qq| - - - - | . $locale->text('Decimalplaces') . qq| - - - -$jsscript -|; - } - - if ($form->{report} =~ /^tax_/) { - $form->{db} = ($form->{report} =~ /_collected/) ? "ar" : "ap"; - - RP->get_taxaccounts(\%myconfig, \%$form); - - print qq| - - - | . $locale->text('From') . qq| - {fromdate}> - | . $locale->text('Bis') . qq| - - - - | . $locale->text('Report for') . qq| - -|; - - $checked = "checked"; - foreach my $ref (@{ $form->{taxaccounts} }) { - - print - qq|{accno} $checked> $ref->{description} + $::form->get_lists("projects" => { "key" => "ALL_PROJECTS", "all" => 1 }); - - |; + my $is_projects = $::form->{report} eq "projects"; + my $is_income_statement = $::form->{report} eq "income_statement"; + my $is_erfolgsrechnung = $::form->{report} eq "erfolgsrechnung"; + my $is_bwa = $::form->{report} eq "bwa"; + my $is_balance_sheet = $::form->{report} eq "balance_sheet"; + my $is_trial_balance = $::form->{report} eq "trial_balance"; + my $is_aging = $::form->{report} =~ /^a[rp]_aging$/; + my $is_payments = $::form->{report} =~ /(receipts|payments)$/; + my $format = 'html'; - $checked = ""; - - } - - print qq| - {db}> - - - - - - | . $locale->text('Method') . qq| - | . $locale->text('Accrual') . qq| - | . $locale->text('EUR') . qq| - - - - - - - - - | . $locale->text('Include in Report') . qq| - - - - - | . $locale->text('ID') . qq| - - | . $locale->text('Invoice') . qq| - - | . $locale->text('Date') . qq| - - - - |; - - if ($form->{db} eq 'ar') { - print $locale->text('Customer'); - } - if ($form->{db} eq 'ap') { - print $locale->text('Vendor'); - } - - print qq| - - | . $locale->text('Amount') . qq| - - | . $locale->text('Tax') . qq| - - | . $locale->text('Total') . qq| - - - - | . $locale->text('Subtotal') . qq| - - - - -|; - - } - - if ($form->{report} =~ /^nontaxable_/) { - $form->{db} = ($form->{report} =~ /_sales/) ? "ar" : "ap"; - - print qq| - - - {db}> - - {report}> - - - | . $locale->text('From') . qq| - {fromdate}> - | . $locale->text('Bis') . qq| - - - - | . $locale->text('Method') . qq| - | - . $locale->text('Accrual') . qq| - | - . $locale->text('EUR') . qq| - - - | . $locale->text('Include in Report') . qq| - - - - - | . $locale->text('ID') . qq| - - | . $locale->text('Invoice') . qq| - - | . $locale->text('Date') . qq| - - - - |; - - if ($form->{db} eq 'ar') { - print $locale->text('Customer'); - } - if ($form->{db} eq 'ap') { - print $locale->text('Vendor'); - } - - print qq| - - | . $locale->text('Amount') . qq| - - | . $locale->text('Total') . qq| - - - - | . $locale->text('Subtotal') . qq| - - - - -|; + my ($label, $nextsub, $vc); + if ($is_aging) { + my $is_sales = $::form->{report} eq 'ar_aging'; + $label = $is_sales ? $::locale->text('Customer') : $::locale->text('Vendor'); + $::form->{vc} = $is_sales ? 'customer' : 'vendor'; - } + $nextsub = "generate_$::form->{report}"; - my ($label, $nextsub, $vc); - if (($form->{report} eq "ar_aging") || ($form->{report} eq "ap_aging")) { - if ($form->{report} eq 'ar_aging') { - $label = $locale->text('Customer'); - $form->{vc} = 'customer'; - } else { - $label = $locale->text('Vendor'); - $form->{vc} = 'vendor'; - } + $vc = qq|{vc} size=35 class="initial_focus">|; - $nextsub = "generate_$form->{report}"; - - # setup vc selection - $form->all_vc(\%myconfig, $form->{vc}, - ($form->{vc} eq 'customer') ? "AR" : "AP"); - - map { $vc .= "$_->{name}--$_->{id}\n" } - @{ $form->{"all_$form->{vc}"} }; - - $vc = - ($vc) - ? qq|{vc}>\n$vc| - : qq|{vc} size=35>|; - - print qq| - - | . $locale->text($label) . qq| - $vc - - - | . $locale->text('Review of Aging list') . qq| - - - 0-30 - 30-60 - 60-90 - 90-120 - > 120 - - - - - | . $locale->text('From') . qq| - $button1 - $button1_2 - | . $locale->text('Bis') . qq| - $button2 - $button2_2 - - - - - - - - - -$jsscript -|; + $format = 'pdf'; } - # above action can be removed if there is more than one input field - my ($selection, $paymentaccounts); - if ($form->{report} =~ /(receipts|payments)$/) { - $form->{db} = ($form->{report} =~ /payments$/) ? "ap" : "ar"; + if ($is_payments) { + $::form->{db} = $::form->{report} =~ /payments$/ ? "ap" : "ar"; - RP->paymentaccounts(\%myconfig, \%$form); + RP->paymentaccounts(\%::myconfig, $::form); $selection = "\n"; - foreach my $ref (@{ $form->{PR} }) { + for my $ref (@{ $::form->{PR} }) { $paymentaccounts .= "$ref->{accno} "; $selection .= "$ref->{accno}--$ref->{description}\n"; } - - chop $paymentaccounts; - - print qq| - - - | . $locale->text('Account') . qq| - $selection - - - - - | . $locale->text('Reference') . qq| - - - - | . $locale->text('Source') . qq| - - - - | . $locale->text('Memo') . qq| - - - - | . $locale->text('From') . qq| - - $button1 - $button1_2 - - | . $locale->text('Bis') . qq| - - $button2 - $button2_2 - - - - - | . $locale->text('Include Exchangerate Difference') . qq| - - -$jsscript - - {db}> - -|; - } - print qq| - - - - - - - - - - - + setup_rp_report_action_bar(); - - - -