@@ -, +, @@ order creation/edition --- acqui/addorderiso2709.pl | 6 -- acqui/fetch_sort_dropbox.pl | 58 ++++++++++++-------- acqui/neworderempty.pl | 4 -- koha-tmpl/intranet-tmpl/prog/en/js/acq.js | 10 +++- .../prog/en/modules/acqui/addorderiso2709.tt | 28 +++++----- .../prog/en/modules/acqui/neworderempty.tt | 7 ++- 6 files changed, 63 insertions(+), 50 deletions(-) --- a/acqui/addorderiso2709.pl +++ a/acqui/addorderiso2709.pl @@ -298,10 +298,7 @@ if ($budget) { # its a mod .. } } elsif ( scalar(@$budgets) ) { $CGIsort1 = GetAuthvalueDropbox( @$budgets[0]->{'sort1_authcat'}, '' ); -} else { - $CGIsort1 = GetAuthvalueDropbox( '', '' ); } - # if CGIsort is successfully fetched, the use it # else - failback to plain input-field if ($CGIsort1) { @@ -317,10 +314,7 @@ if ($budget) { } } elsif ( scalar(@$budgets) ) { $CGIsort2 = GetAuthvalueDropbox( @$budgets[0]->{sort2_authcat}, '' ); -} else { - $CGIsort2 = GetAuthvalueDropbox( '', '' ); } - if ($CGIsort2) { $template->param( CGIsort2 => $CGIsort2 ); } else { --- a/acqui/fetch_sort_dropbox.pl +++ a/acqui/fetch_sort_dropbox.pl @@ -54,40 +54,54 @@ Sort number. 1 or 2 for the moment. my $input = new CGI; my $budget_id = $input->param('budget_id'); -my $sort_id = $input->param('sort'); +my $sort_nb = $input->param('sort'); +die "sort parameter can only be 1 or 2" unless ($sort_nb == 1 || $sort_nb == 2); my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { template_name => "acqui/ajax.tmpl", query => $input, type => "intranet", authnotrequired => 0, - flagsrequired => {editcatalogue => 'edit_catalogue'}, + flagsrequired => {acquisition => 'order_manage'}, debug => 0, } ); -my $budget = GetBudget($budget_id); -my $dropbox_values = GetAuthvalueDropbox( $budget->{'sort'.$sort_id.'_authcat'}, '' ); +my $ret_html; +my $name = 'sort'.$sort_nb; +my $authcat_field = 'sort'.$sort_nb.'_authcat'; -my @authorised_values; -my %authorised_lib; +my $budget = GetBudget($budget_id); -foreach ( @$dropbox_values) { - push @authorised_values, $_->{value}; - $authorised_lib{$_->{value}} = $_->{label}; +if ( $budget && $budget->{$authcat_field} ) { + # with custom Asort* planning values + my $dropbox_values = GetAuthvalueDropbox( $budget->{$authcat_field}, '' ); + + my @authorised_values; + my %authorised_lib; + my $default_value; + + foreach ( @$dropbox_values) { + push @authorised_values, $_->{value}; + $authorised_lib{$_->{value}} = $_->{label}; + $default_value = $_->{value} if $_->{'default'}; + } + + $ret_html = CGI::scrolling_list( + -values => \@authorised_values, + -labels => \%authorised_lib, + -default => $default_value, + -override => 1, + -size => 1, + -multiple => 0, + -name => $name, + -id => $name, + ); + +} else { + # free input + $ret_html = ''; } -my $budget_authvalue_dropbox = CGI::scrolling_list( - -values => \@authorised_values, - -labels => \%authorised_lib, - -default => $authorised_values[0], -); - - -# strip off select tags -$budget_authvalue_dropbox =~ s/^\//; -$budget_authvalue_dropbox =~ s/\<\/select\>$//; -chomp $budget_authvalue_dropbox; - -$template->param( return => $budget_authvalue_dropbox ); +$template->param( 'return' => $ret_html ); output_html_with_http_headers $input, $cookie, $template->output; --- a/acqui/neworderempty.pl +++ a/acqui/neworderempty.pl @@ -281,8 +281,6 @@ if ($budget) { # its a mod .. } } elsif(@{$budgets}){ $CGIsort1 = GetAuthvalueDropbox( @$budgets[0]->{'sort1_authcat'}, '' ); -}else{ - $CGIsort1 = GetAuthvalueDropbox( '', '' ); } # if CGIsort is successfully fetched, the use it @@ -300,8 +298,6 @@ if ($budget) { } } elsif(@{$budgets}) { $CGIsort2 = GetAuthvalueDropbox( @$budgets[0]->{sort2_authcat}, '' ); -}else{ - $CGIsort2 = GetAuthvalueDropbox( '', '' ); } if ($CGIsort2) { --- a/koha-tmpl/intranet-tmpl/prog/en/js/acq.js +++ a/koha-tmpl/intranet-tmpl/prog/en/js/acq.js @@ -744,7 +744,7 @@ function fetchSortDropbox(f) { for (i=1;i<=2;i++) { - var sort_dropbox = document.getElementById('sort'+i); + var sort_zone = document.getElementById('sort'+i+'_zone'); var url = '../acqui/fetch_sort_dropbox.pl?sort='+i+'&budget_id='+budgetId; var xmlhttp = null; @@ -764,7 +764,13 @@ for (i=1;i<=2;i++) { } }; // rc = eval ( xmlhttp.responseText ); - sort_dropbox.innerHTML = xmlhttp.responseText; + var retRootType = xmlhttp.responseXML.firstChild.nodeName; + var existingInputs = sort_zone.getElementsByTagName('input'); + if (existingInputs.length > 0 && retRootType == 'input') { + // when sort is already an input, do not override to preseve value + return; + } + sort_zone.innerHTML = xmlhttp.responseText; } } --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt @@ -188,7 +188,7 @@
  • The 2 following fields are available for your own usage. They can be useful for statistical purposes
    - + [% IF CGIsort1 %] [% END %] +
  • - - [% IF CGIsort2 %] - + [% FOREACH sort_opt IN CGIsort2 %] + [% IF sort_opt.default %] + + [% ELSE %] + + [% END %] [% END %] + + [% ELSE %] + [% END %] - - [% ELSE %] - - [% END %] +
  • --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt @@ -508,7 +508,7 @@ $(document).ready(function()
  • The 2 following fields are available for your own usage. They can be useful for statistical purposes
    - + [% IF CGIsort1 %] [% ELSE %] - [% END %] +
  • - + [% IF CGIsort2 %] [% END %] +
  • --