diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index e33b27cd94..2f8bf86fe8 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -19,6 +19,7 @@ package C4::Acquisition; use strict; +use warnings; use C4::Context; use C4::Debug; use C4::Dates qw(format_date format_date_in_iso); @@ -541,6 +542,8 @@ $hashref->{'name'} is the 'name' field of the basketgroup in the aqbasketgroups $hashref->{'basketlist'} is a list reference of the 'id's of the baskets that belong to this group, +$hashref->{'billingplace'} is the 'billingplace' field of the basketgroup in the aqbasketgroups table, + $hashref->{'deliveryplace'} is the 'deliveryplace' field of the basketgroup in the aqbasketgroups table, $hashref->{'deliverycomment'} is the 'deliverycomment' field of the basketgroup in the aqbasketgroups table, @@ -559,8 +562,8 @@ sub ModBasketgroup { my $dbh = C4::Context->dbh; my $query = "UPDATE aqbasketgroups SET "; my @params; - foreach my $field (qw(name deliveryplace deliverycomment closed)) { - if ( $basketgroupinfo->{$field} ne undef) { + foreach my $field (qw(name billingplace deliveryplace deliverycomment closed)) { + if ( defined $basketgroupinfo->{$field} ) { $query .= "$field=?, "; push(@params, $basketgroupinfo->{$field}); } diff --git a/acqui/basketgroup.pl b/acqui/basketgroup.pl index bd56ace880..10eb565c7f 100755 --- a/acqui/basketgroup.pl +++ b/acqui/basketgroup.pl @@ -239,10 +239,8 @@ sub printbasketgrouppdf{ } %orders->{$basket->{basketno}}=\@ba_orders; } - print $input->header( -type => 'application/pdf', -attachment => 'basketgroup.pdf' ); - my $branch = GetBranchInfo(GetBranch($input, GetBranches())); - $branch = @$branch[0]; - my $pdf = printpdf($basketgroup, $bookseller, $baskets, $branch, \%orders, $bookseller->{gstrate} || C4::Context->preference("gist")) || die "pdf generation failed"; + print $input->header( -type => 'application/pdf', -attachment => $basketgroup->{name}.'.pdf' ); + my $pdf = printpdf($basketgroup, $bookseller, $baskets, \%orders, $bookseller->{gstrate} || C4::Context->preference("gist")) || die "pdf generation failed"; print $pdf; exit; } @@ -270,7 +268,8 @@ if ( $op eq "add" ) { } } else { my $basketgroupid = $input->param('basketgroupid'); - my $branchcode; + my $billingplace; + my $deliveryplace; if ( $basketgroupid ) { # Get the selected baskets in the basketgroup to display them my $selecteds = GetBasketsByBasketgroup($basketgroupid); @@ -286,24 +285,42 @@ if ( $op eq "add" ) { name => $basketgroup->{name}, deliverycomment => $basketgroup->{deliverycomment}, ); - $branchcode = $basketgroup->{deliveryplace}; + $billingplace = $basketgroup->{billingplace}; + $deliveryplace = $basketgroup->{deliveryplace}; } - # Build the combobox to select the delivery place + # determine default billing and delivery places depending on librarian homebranch and existing basketgroup data my $borrower = GetMember( ( 'borrowernumber' => $loggedinuser ) ); - my $branch = $branchcode || $borrower->{'branchcode'}; + my $billingplace = $billingplace || $borrower->{'branchcode'}; + my $deliveryplace = $deliveryplace || $borrower->{'branchcode'}; + my $branches = GetBranches; - my @branchloop; - foreach my $thisbranch (sort keys %$branches) { - my $selected = 1 if $thisbranch eq $branch; + + # Build the combobox to select the billing place + my @billingplaceloop; + for (sort keys %$branches) { + my $selected = 1 if $_ eq $billingplace; my %row = ( - value => $thisbranch, + value => $_, selected => $selected, - branchname => $branches->{$thisbranch}->{branchname}, + branchname => $branches->{$_}->{branchname}, ); - push @branchloop, \%row; + push @billingplaceloop, \%row; } - $template->param( branchloop => \@branchloop ); + $template->param( billingplaceloop => \@billingplaceloop ); + + # Build the combobox to select the delivery place + my @deliveryplaceloop; + for (sort keys %$branches) { + my $selected = 1 if $_ eq $deliveryplace; + my %row = ( + value => $_, + selected => $selected, + branchname => $branches->{$_}->{branchname}, + ); + push @deliveryplaceloop, \%row; + } + $template->param( deliveryplaceloop => \@deliveryplaceloop ); $template->param( booksellerid => $booksellerid ); } @@ -386,11 +403,11 @@ if ( $op eq "add" ) { # Getting parameters my $basketgroup = {}; - my @baskets = $input->param('basket'); my $basketgroupid = $input->param('basketgroupid'); my $basketgroupname = $input->param('basketgroupname'); my $booksellerid = $input->param('booksellerid'); + my $billingplace = $input->param('billingplace'); my $deliveryplace = $input->param('deliveryplace'); my $deliverycomment = $input->param('deliverycomment'); my $close = $input->param('close') ? 1 : 0; @@ -400,6 +417,7 @@ if ( $op eq "add" ) { name => $basketgroupname, id => $basketgroupid, basketlist => \@baskets, + billingplace => $billingplace, deliveryplace => $deliveryplace, deliverycomment => $deliverycomment, closed => $close, diff --git a/acqui/pdfformat/layout3pages.odt b/acqui/pdfformat/layout3pages.odt index d1071e34b7..8e9145864f 100644 Binary files a/acqui/pdfformat/layout3pages.odt and b/acqui/pdfformat/layout3pages.odt differ diff --git a/acqui/pdfformat/layout3pages.pdf b/acqui/pdfformat/layout3pages.pdf index 8e09d1bbf7..1560e781ae 100644 Binary files a/acqui/pdfformat/layout3pages.pdf and b/acqui/pdfformat/layout3pages.pdf differ diff --git a/acqui/pdfformat/layout3pages.pm b/acqui/pdfformat/layout3pages.pm index 3cb35a5f47..50f436518c 100755 --- a/acqui/pdfformat/layout3pages.pm +++ b/acqui/pdfformat/layout3pages.pm @@ -276,12 +276,13 @@ sub printbaskets { } sub printhead { - my ($pdf, $basketgroup, $bookseller, $branch) = @_; + my ($pdf, $basketgroup, $bookseller) = @_; # get library name my $libraryname = C4::Context->preference("LibraryName"); # get branch details - my $branchdetails = GetBranchDetail( $basketgroup->{'deliveryplace'} ); + my $billingdetails = GetBranchDetail( $basketgroup->{billingplace} ); + my $deliverydetails = GetBranchDetail( $basketgroup->{deliveryplace} ); # get the subject my $subject; @@ -308,50 +309,54 @@ sub printhead { $text->font( $pdf->corefont("Times", -encoding => "utf8"), 4/mm ); - # print branch infos + # print billing infos $text->translate(100/mm, ($height-86)/mm); $text->text($libraryname); $text->translate(100/mm, ($height-97)/mm); - $text->text($branch->{branchname}); + $text->text($billingdetails->{branchname}); $text->translate(100/mm, ($height-108.5)/mm); - $text->text($branch->{branchphone}); + $text->text($billingdetails->{branchphone}); $text->translate(100/mm, ($height-115.5)/mm); - $text->text($branch->{branchfax}); + $text->text($billingdetails->{branchfax}); $text->translate(100/mm, ($height-122.5)/mm); - $text->text($branch->{branchaddress1}); + $text->text($billingdetails->{branchaddress1}); $text->translate(100/mm, ($height-127.5)/mm); - $text->text($branch->{branchaddress2}); - $text->translate(100/mm, ($height-132)/mm); - $text->text($branch->{branchaddress3}); - $text->translate(100/mm, ($height-138.5)/mm); - $text->text($branch->{branchemail}); + $text->text($billingdetails->{branchaddress2}); + $text->translate(100/mm, ($height-132.5)/mm); + $text->text($billingdetails->{branchaddress3}); + $text->translate(100/mm, ($height-137.5)/mm); + $text->text(join(' ', $billingdetails->{branchzip}, $billingdetails->{branchcity}, $billingdetails->{branchcountry})); + $text->translate(100/mm, ($height-147.5)/mm); + $text->text($billingdetails->{branchemail}); # print subject $text->translate(100/mm, ($height-145.5)/mm); $text->text($subject); # print bookseller infos - $text->translate(100/mm, ($height-177)/mm); + $text->translate(100/mm, ($height-180)/mm); $text->text($bookseller->{name}); - $text->translate(100/mm, ($height-182)/mm); + $text->translate(100/mm, ($height-185)/mm); $text->text($bookseller->{postal}); - $text->translate(100/mm, ($height-187)/mm); + $text->translate(100/mm, ($height-190)/mm); $text->text($bookseller->{address1}); - $text->translate(100/mm, ($height-197)/mm); + $text->translate(100/mm, ($height-195)/mm); $text->text($bookseller->{address2}); - $text->translate(100/mm, ($height-202)/mm); + $text->translate(100/mm, ($height-200)/mm); $text->text($bookseller->{address3}); # print delivery infos $text->font( $pdf->corefont("Times-Bold", -encoding => "utf8"), 4/mm ); $text->translate(50/mm, ($height-237)/mm); - $text->text($branchdetails->{branchaddress1}); + $text->text($deliverydetails->{branchaddress1}); $text->translate(50/mm, ($height-242)/mm); - $text->text($branchdetails->{branchaddress2}); + $text->text($deliverydetails->{branchaddress2}); $text->translate(50/mm, ($height-247)/mm); - $text->text($branchdetails->{branchaddress3}); + $text->text($deliverydetails->{branchaddress3}); $text->translate(50/mm, ($height-252)/mm); - $text->text($basketgroup->{'deliverycomment'}); + $text->text(join(' ', $deliverydetails->{branchzip}, $deliverydetails->{branchcity}, $deliverydetails->{branchcountry})); + $text->translate(50/mm, ($height-262)/mm); + $text->text($basketgroup->{deliverycomment}); } sub printfooters { @@ -366,7 +371,7 @@ sub printfooters { } sub printpdf { - my ($basketgroup, $bookseller, $baskets, $branch, $orders, $GST) = @_; + my ($basketgroup, $bookseller, $baskets, $orders, $GST) = @_; # open the default PDF that will be used for base (1st page already filled) my $template = C4::Context->preference("OrderPdfTemplate"); $template = decode_base64($template); @@ -375,7 +380,7 @@ sub printpdf { -style => 'roman', } ); # start with roman numbering # fill the 1st page (basketgroup information) - printhead($pdf, $basketgroup, $bookseller, $branch); + printhead($pdf, $basketgroup, $bookseller); # fill the 2nd page (orders summary) printbaskets($pdf, $basketgroup, $baskets, $bookseller, $GST, $orders); # fill other pages (orders) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index f5215ecbdc..519fa4f4dd 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -3200,6 +3200,15 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = "3.01.00.127"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do(qq{ + ALTER TABLE aqbasketgroups ADD 'billingplace' VARCHAR(10) AFTER 'deliverycomment'; + }); + + print "Upgrade to $DBversion done (isbd updated)\n"; + SetVersion ($DBversion); +} =item DropAllForeignKeys($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tmpl index cbfad5c56f..962b799c74 100755 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tmpl @@ -207,10 +207,16 @@ fieldset.various li {

" /> +

+