From: Thomas Heck Date: Thu, 20 Dec 2012 10:21:30 +0000 (+0100) Subject: HTML-Code aus bin/ap.pl/form_header in ein eigenes Template übertragen X-Git-Tag: release-3.1.0beta1~763 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=46231fcc086ac26ad9d3ee56ff6fcbc141e435bd;p=kivitendo-erp.git HTML-Code aus bin/ap.pl/form_header in ein eigenes Template übertragen --- diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl index 3bbe8dcb9..7829d7451 100644 --- a/bin/mozilla/ap.pl +++ b/bin/mozilla/ap.pl @@ -192,115 +192,54 @@ sub form_header { $main::auth->assert('general_ledger'); - my $title = $form->{title}; - $form->{title} = $locale->text("$title Accounts Payables Transaction"); - - $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : ""; + $form->{title_} = $form->{title}; + $form->{title} = $locale->text($form->{title} .' Accounts Payables Transaction'); # type=submit $locale->text('Add Accounts Payables Transaction') # type=submit $locale->text('Edit Accounts Payables Transaction') - $form->{javascript} = qq||; - # show history button - $form->{javascript} .= qq||; - #/show hhistory button - # set option selected foreach my $item (qw(vendor currency department)) { my $to_replace = H($form->{$item}); $form->{"select$item"} =~ s/ selected//; $form->{"select$item"} =~ s/>\Q${to_replace}\E/ selected>${to_replace}/; } - my $readonly = ($form->{id}) ? "readonly" : ""; + my $readonly = $form->{id} ? "readonly" : ""; $form->{radier} = ($::instance_conf->get_ap_changeable == 2) ? ($form->current_date(\%myconfig) eq $form->{gldate}) : ($::instance_conf->get_ap_changeable == 1); - $readonly = ($form->{radier}) ? "" : $readonly; + $readonly = $form->{radier} ? "" : $readonly; - $form->{forex} = $form->check_exchangerate( \%myconfig, $form->{currency}, $form->{transdate}, 'sell'); - $form->{exchangerate} = $form->{forex} if $form->{forex}; + $form->{readonly} = $readonly; + + $form->{forex} = $form->check_exchangerate( \%myconfig, $form->{currency}, $form->{transdate}, 'sell'); + if ( $form->{forex} ) { + $form->{exchangerate} = $form->{forex}; + } # format amounts $form->{exchangerate} = $form->{exchangerate} ? $form->format_amount(\%myconfig, $form->{exchangerate}) : ''; $form->{creditlimit} = $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0"); $form->{creditremaining} = $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0"); - my $exchangerate = qq| -{forex}> -|; - if ($form->{defaultcurrency} && ($form->{currency} ne $form->{defaultcurrency})) { - if ($form->{forex}) { - $exchangerate .= qq| - - | . $locale->text('Exchangerate') . qq| - {exchangerate}>$form->{exchangerate} - -|; - } else { - $exchangerate .= qq| - | . $locale->text('Exchangerate') . qq| - {exchangerate}> -|; - } - } - - my $taxincluded = ""; - - $taxincluded = qq| - - {taxincluded}> - | - . $locale->text('Tax Included') . qq| - -|; - my $rows; if (($rows = $form->numtextrows($form->{notes}, 50)) < 2) { $rows = 2; } - my $notes = - qq||; - my $intnotes = qq||; - - my $department; - $department = qq| - - | . $locale->text('Department') . qq| - - - - -| if $form->{selectdepartment}; - - my $n = ($form->{creditremaining} =~ /-/) ? "0" : "1"; - - my $vendor = - ($form->{selectvendor}) - ? qq|| - : qq||; + $form->{textarea_rows} = $rows; + + $form->{creditremaining_plus} = ($form->{creditremaining} =~ /-/) ? "0" : "1"; my @old_project_ids = (); - map({ push(@old_project_ids, $form->{"project_id_$_"}) - if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"})); + map( + { + if ($form->{"project_id_$_"}) { + push(@old_project_ids, $form->{"project_id_$_"}); + } + } + (1..$form->{"rowcount"}) + ); $form->get_lists("projects" => { "key" => "ALL_PROJECTS", "all" => 0, @@ -310,14 +249,16 @@ sub form_header { "taxcharts" => { "key" => "ALL_TAXCHARTS", "module" => "AP" },); - map({ $_->{link_split} = [ split(/:/, $_->{link}) ]; } - @{ $form->{ALL_CHARTS} }); + map( + { $_->{link_split} = [ split(/:/, $_->{link}) ]; } + @{ $form->{ALL_CHARTS} } + ); my %project_labels = (); my @project_values = (""); foreach my $item (@{ $form->{"ALL_PROJECTS"} }) { - push(@project_values, $item->{"id"}); - $project_labels{$item->{"id"}} = $item->{"projectnumber"}; + push(@project_values, $item->{id}); + $project_labels{$item->{id}} = $item->{projectnumber}; } my (%AP_amount_labels, @AP_amount_values); @@ -359,36 +300,7 @@ sub form_header { $taxcharts{$item->{id}} = $item; } - # use JavaScript Calendar or not $form->{jsscript} = 1; - my $jsscript = ""; - my ($button1, $button2); - if ($form->{jsscript}) { - - # with JavaScript Calendar - $button1 = qq| - - text('button') . qq|> - |; - $button2 = qq| - - text('button') . qq|> - |; - - #write Trigger - $jsscript = - Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1", - "duedate", "BL", "trigger2"); - } else { - - # without JavaScript Calendar - $button1 = - qq||; - $button2 = - qq||; - } my $follow_up_vc = $form->{vendor}; $follow_up_vc =~ s/--.*?//; @@ -398,128 +310,18 @@ sub form_header { $form->{javascript} .= qq||; $form->{javascript} .= qq||; - my $globalprojectnumber = + $form->{globalprojectnumber} = NTI($cgi->popup_menu('-name' => "globalproject_id", '-values' => \@project_values, '-labels' => \%project_labels, '-default' => $form->{"globalproject_id"} )); $form->header; - print qq| -
{script}> - -{id}> -{sort}> -{closedto}> -{locked}> - - - - - - - -| . ($form->{saved_message} ? qq|

$form->{saved_message}

| : "") . qq| - - - - - - - - - - - - -$jsscript - {rowcount}> - - - - - - - - - - - - -
$form->{title}
- - - - - -
- - - - - - - - - - - - - - - - - {defaultcurrency}> - {fxgain_accno}> - {fxloss_accno}> - $exchangerate - - $department - $taxincluded -
| . $locale->text('Vendor') . qq|$vendor
- - - - - - - {creditlimit}> - {creditremaining}> - -
| . $locale->text('Credit Limit') . qq|$form->{creditlimit}| . $locale->text('Remaining') . qq|$form->{creditremaining}
-
| . $locale->text('Currency') . qq|
-
- - - - - - - - - - - - $button1 - - - - $button2 - - - - - -
| . $locale->text('Invoice Number') . qq|
| . $locale->text('Order Number') . qq|
| . $locale->text('Invoice Date') . qq|
| . $locale->text('Due Date') . qq|
| . $locale->text('Project Number') . qq|$globalprojectnumber
-
-
- - - - - - - - -|; - - my $amount = $locale->text('Amount'); - my $project = $locale->text('Project'); for my $i (1 .. $form->{rowcount}) { # format amounts - $form->{"amount_$i"} = - $form->format_amount(\%myconfig, $form->{"amount_$i"}, 2); + $form->{"amount_$i"} = $form->format_amount(\%myconfig, $form->{"amount_$i"}, 2); $form->{"tax_$i"} = $form->format_amount(\%myconfig, $form->{"tax_$i"}, 2); my $selected_accno_full; @@ -540,7 +342,7 @@ $jsscript $selected_taxchart = $taxchart_init unless ($form->{"taxchart_$i"}); - my $selectAP_amount = + $form->{'selectAP_amount_'. $i} = NTI($cgi->popup_menu('-name' => "AP_amount_$i", '-id' => "AP_amount_$i", '-style' => 'width:400px', @@ -551,124 +353,39 @@ $jsscript . $cgi->hidden('-name' => "previous_AP_amount_$i", '-default' => $selected_accno_full); - my $tax = qq||; + '-default' => $selected_taxchart)); - my $projectnumber = + $form->{'select_projectnumber_'. $i} = NTI($cgi->popup_menu('-name' => "project_id_$i", '-values' => \@project_values, '-labels' => \%project_labels, '-default' => ($i==$form->{rowcount})? $form->{globalproject_id} : $form->{"project_id_$i"} )); - - print qq| - - - - - $tax - - -|; - $amount = ""; - $project = ""; } - my $taxlabel = - ($form->{taxincluded}) - ? $locale->text('Tax Included') - : $locale->text('Tax'); $form->{invtotal_unformatted} = $form->{invtotal}; $form->{invtotal} = $form->format_amount(\%myconfig, $form->{invtotal}, 2); - my $APselected = + $form->{APselected} = NTI($cgi->popup_menu('-name' => "APselected", '-id' => "APselected", '-style' => 'width:400px', '-values' => \@AP_values, '-labels' => \%AP_labels, '-default' => $form->{APselected})); - print qq| - - - - - - - - {oldinvtotal}> - {oldtotalpaid}> - - - - - - - -
| . $locale->text('Account') . qq|| . $locale->text('Amount') . qq|| . $locale->text('Tax') . qq|| . $locale->text('Taxkey') . qq|| . $locale->text('Project') . qq|
| . + $form->{'select_tax_'. $i} = NTI($cgi->popup_menu('-name' => "taxchart_$i", '-id' => "taxchart_$i", '-style' => 'width:200px', '-values' => \@taxchart_values, '-labels' => \%taxchart_labels, - '-default' => $selected_taxchart)) - . qq|
$selectAP_amount{"amount_$i"}>$form->{"tax_$i"}$projectnumber
-
-
${APselected}$form->{invtotal}
-
- - - - - - - - -
| . $locale->text('Notes') . qq|$notes| . $locale->text('Notes for vendor') . qq|$intnotes
-
- - - - -|; - my @column_index; - if ($form->{defaultcurrency} && ($form->{currency} eq $form->{defaultcurrency})) { - @column_index = qw(datepaid source memo paid AP_paid paid_project_id); - } else { - @column_index = qw(datepaid source memo paid exchangerate AP_paid paid_project_id); - } - - my %column_data; - $column_data{datepaid} = ""; - $column_data{paid} = ""; - $column_data{exchangerate} = ""; - $column_data{AP_paid} = ""; - $column_data{source} = ""; - $column_data{memo} = ""; - $column_data{paid_project_id} = ""; - - print " - -"; - map { print "$column_data{$_}\n" } @column_index; - print " - -"; - - my @triggers = (); $form->{totalpaid} = 0; - $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"}); + if ( $form->{'paid_'. $form->{paidaccounts}} ) { + $form->{paidaccounts}++; + } for my $i (1 .. $form->{paidaccounts}) { - print " - -"; - my $selectAP_paid = + $form->{'selectAP_paid_'. $i} = NTI($cgi->popup_menu('-name' => "AP_paid_$i", '-id' => "AP_paid_$i", '-values' => \@AP_paid_values, @@ -679,8 +396,7 @@ $jsscript # format amounts if ($form->{"paid_$i"}) { - $form->{"paid_$i"} = - $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2); + $form->{"paid_$i"} = $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2); } if ($form->{"exchangerate_$i"} == 0) { $form->{"exchangerate_$i"} = ""; @@ -689,8 +405,6 @@ $jsscript $form->format_amount(\%myconfig, $form->{"exchangerate_$i"}); } - print qq|{"acc_trans_id_$i"}>\n|; - print qq|{"gldate_$i"}>\n|; my $changeable = 1; if (SL::DB::Default->get->payments_changeable == 0) { # never @@ -701,127 +415,22 @@ $jsscript $changeable = (($form->{"gldate_$i"} eq '') || $form->current_date(\%myconfig) eq $form->{"gldate_$i"}); } - $exchangerate = qq| |; - if ($form->{defaultcurrency} && ($form->{currency} ne $form->{defaultcurrency})) { - if ($form->{"forex_$i"}) { - $exchangerate = - qq|{"exchangerate_$i"}>$form->{"exchangerate_$i"}|; - } else { - if ($changeable) { - $exchangerate = - qq|{"exchangerate_$i"}>|; - } else { - $exchangerate = - qq|{"exchangerate_$i"}>$form->{"exchangerate_$i"}|; - } - } - } - - $exchangerate .= qq| -{"forex_$i"}> -|; - - my $datepaid; - if ($changeable) { - $datepaid = qq||; - } else { - $datepaid = qq||. - qq|{"datepaid_$i"}>|; - } + $form->{'paidaccount_changeable_'. $i} = $changeable; - my $paid; - if ($changeable) { - $paid = qq||; + if ( $changeable ) { + $form->{'selectpaid_project_id_'. $i} = + NTI($cgi->popup_menu('-name' => "paid_project_id_$i", + '-values' => \@project_values, + '-labels' => \%project_labels, + '-default' => $form->{"paid_project_id_$i"})); } else { - $paid = qq||. - qq|{"paid_$i"}>|; - } - - my $source; - if ($changeable) { - $source = qq||; - } else { - $source = qq||. - qq|{"source_$i"}>|; - } - - my $memo; - if ($changeable) { - $memo = qq||; - } else { - $memo = qq||. - qq|{"memo_$i"}>|; - } - - my $AP_paid; - if ($changeable) { - $AP_paid = qq||; - } else { - $AP_paid = qq||. - qq|{"AP_paid_$i"}>|; - } - - my $paid_project_id; - if ($changeable) { - $paid_project_id = - qq||; - } else { - my $projectnumber = $project_labels{$form->{"paid_project_id_$i"}}; - $paid_project_id = qq||. - qq|{"paid_project_id_$i"}>|; - } - - $column_data{"paid_$i"} = $paid; - $column_data{"AP_paid_$i"} = $AP_paid; - $column_data{"exchangerate_$i"} = qq||; - $column_data{"datepaid_$i"} = $datepaid; - $column_data{"source_$i"} = $source; - $column_data{"memo_$i"} = $memo; - $column_data{"paid_project_id_$i"} = $paid_project_id; - - map { print qq|$column_data{"${_}_$i"}\n| } @column_index; - - print " - -"; - if ($changeable) { - push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i"); + $form->{'labelpaid_project_id_'. $i} = $project_labels{$form->{'paid_project_id_'. $i}}; } } - my $paid_missing = $form->{invtotal_unformatted} - $form->{totalpaid}; + $form->{paid_missing} = $form->{invtotal_unformatted} - $form->{totalpaid}; - print qq| - - - - - - - - - - - - -| . $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) . - qq| - {paidaccounts}> - -
| . $locale->text('Payments') . qq|
" . $locale->text('Date') . "" . $locale->text('Amount') . "" . $locale->text('Exch') . "" . $locale->text('Account') . "" . $locale->text('Source') . "" . $locale->text('Memo') . "" . $locale->text('Project Number') . "
- $form->{"datepaid_$i"}$form->{"paid_$i"}$form->{"source_$i"}$form->{"memo_$i"}${selectAP_paid}$form->{"AP_paid_$i"}| - . NTI($cgi->popup_menu('-name' => "paid_project_id_$i", - '-values' => \@project_values, - '-labels' => \%project_labels, - '-default' => $form->{"paid_project_id_$i"} )) - . qq|$projectnumber$exchangerate
| . $locale->text('Total') . qq|| . H($form->format_amount(\%myconfig, $form->{totalpaid}, 2)) . qq|
| . $locale->text('Missing amount') . qq|| . H($form->format_amount(\%myconfig, $paid_missing, 2)) . qq|
-

-|; + print $form->parse_html_template('ap/form_header'); $main::lxdebug->leave_sub(); } diff --git a/templates/webpages/ap/form_header.html b/templates/webpages/ap/form_header.html new file mode 100644 index 000000000..5218a4a9c --- /dev/null +++ b/templates/webpages/ap/form_header.html @@ -0,0 +1,359 @@ +[%- USE L %] +[%- USE HTML %] +[%- USE T8 %] +[%- USE LxERP %] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[% FOREACH i IN [1..paidaccounts] %] + [% temp = "acc_trans_id_"_ i %] + + + [% temp = "gldate_"_ i %] + +[% END %] + +

[% title | html %]

+ +[% IF ( saved_message ) %] +

[% saved_message | html %]

+[% END %] + + + + + + + + + + + + + + + + + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + [% IF ( defaultcurrency && (currency != defaultcurrency) ) %] + + [% IF ( forex ) %] + + [% ELSE %] + + [% END %] + [% END %] + + + + [% IF ( selectdepartment ) %] + + + + + [% END %] + + + + + +
[% 'Vendor' | $T8 %] + [% IF ( selectvendor ) %] + + [% ELSE %] + + [% END %] + +
+ + + + + + + +
[% 'Credit Limit' | $T8 %][% creditlimit %][% 'Remaining' | $T8 %][% creditremaining %]
+
[% 'Currency' | $T8 %][% 'Exchangerate' | $T8 %][% exchangerate %]
[% 'Department' | $T8 %] + +
[% 'Tax Included' | $T8 %]
+
+ + + + + + + + + + + + + + + + + + + + + +
[% 'Invoice Number' | $T8 %]
[% 'Order Number' | $T8 %]
[% 'Invoice Date' | $T8 %][% L.date_tag('transdate', transdate) %]
[% 'Due Date' | $T8 %][% L.date_tag('duedate', duedate) %]
[% 'Project Number' | $T8 %][% globalprojectnumber %]
+
+
+ + + + + + + + + + [% FOREACH i IN [1..rowcount] %] + + + + + + + + [% END %] + + + + + + + + + +
[% 'Account' | $T8 %][% 'Amount' | $T8 %][% 'Tax' | $T8 %][% 'Taxkey' | $T8 %][% 'Project' | $T8 %]
+ [% temp = "selectAP_amount_"_ i %][% $temp %] + + + + + [% temp = "tax_"_ i %][% $temp %] + + [% temp = "select_tax_"_ i %][% $temp %] + + [% temp = "select_projectnumber_"_ i %][% $temp %] +
+
+
[% APselected %][% invtotal %]
+
+ + + + + + + + +
[% 'Notes' | $T8 %] + + [% 'Notes for vendor' | $T8 %] + +
+
+ + + + + + + + + + + [% IF ( !defaultcurrency || (currency != defaultcurrency) ) %] + + [% END %] + + + + + [% FOREACH i IN [1..paidaccounts] %] + [% temp = "paidaccount_changeable_"_ i %] + [% changeable = $temp %] + + + [% temp = "datepaid_"_ i %] + + + [% temp = "source_"_ i %] + + + [% temp = "memo_"_ i %] + + + [% temp = "paid_"_ i %] + + + [% IF ( !defaultcurrency || (currency != defaultcurrency) ) %] + + [% END %] + + [% temp = "AP_paid_"_ i %] + + + [% temp = "paid_project_id_"_ i %] + + + [% END %] + + + + + + + + + + + + + +
[% 'Payments' | $T8 %]
[% 'Date' | $T8 %][% 'Source' | $T8 %][% 'Memo' | $T8 %][% 'Amount' | $T8 %][% 'Exch' | $T8 %][% 'Account' | $T8 %][% 'Project Number' | $T8 %]
+ [% IF( changeable ) %] + [% L.date_tag(temp, $temp) %] + [% ELSE %] + [% $temp %] + |; + [% END %] + + [% IF( changeable ) %] + + [% ELSE %] + [% $temp %] + + [% END %] + + [% IF( changeable ) %] + + [% ELSE %] + [% $temp %] + + [% END %] + + [% IF( changeable ) %] + + [% ELSE %] + [% $temp %] + + [% END %] + + [% temp = "exchangerate_"_ i %] + [% temp_forex = "forex_"_ i %] + + [% IF( $temp_forex || !changeable ) %] + [% $temp %] + + [% ELSE %] + + [% END %] + + + + [% IF( changeable ) %] + [% temp = "select"_ temp %] + [% $temp %] + [% ELSE %] + [% $temp %] + + [% END %] + + [% IF( changeable ) %] + [% temp = "select"_ temp %] + [% $temp %] + [% ELSE %] + + [% temp = "label"_ temp %] + [% $temp %] + [% END %] +
[% 'Total' | $T8 %][% LxERP.format_amount(totalpaid, 2) | html %]
[% 'Missing amount' | $T8 %][% LxERP.format_amount(paid_missing, 2) | html %]
+