From a1a8945c2f88849f581f456f4bf04cef456d7b67 Mon Sep 17 00:00:00 2001 From: Matthias Meusburger Date: Mon, 28 Mar 2011 13:39:46 +0200 Subject: [PATCH] Bug 5970: Adds the ability to use a free delivery address for basket When editing a basket group, user can choose a library for delivery place, or enter address of his choice in a text field. Signed-off-by: Katrin Fischer Will send a follow-up for missing change in kohastructure.sql Signed-off-by: Chris Cormack --- C4/Acquisition.pm | 2 +- acqui/basketgroup.pl | 50 +++++++++++-------- acqui/pdfformat/layout2pages.pm | 25 +++++++--- acqui/pdfformat/layout3pages.pm | 25 +++++++--- installer/data/mysql/updatedatabase.pl | 7 +++ .../prog/en/modules/acqui/basketgroup.tmpl | 3 ++ 6 files changed, 75 insertions(+), 37 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 95a0ad5e4d..747450293f 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -568,7 +568,7 @@ sub ModBasketgroup { my $dbh = C4::Context->dbh; my $query = "UPDATE aqbasketgroups SET "; my @params; - foreach my $field (qw(name billingplace deliveryplace deliverycomment closed)) { + foreach my $field (qw(name billingplace deliveryplace freedeliveryplace deliverycomment closed)) { if ( defined $basketgroupinfo->{$field} ) { $query .= "$field=?, "; push(@params, $basketgroupinfo->{$field}); diff --git a/acqui/basketgroup.pl b/acqui/basketgroup.pl index 2a35f3a264..457b61606d 100755 --- a/acqui/basketgroup.pl +++ b/acqui/basketgroup.pl @@ -273,6 +273,7 @@ if ( $op eq "add" ) { my $basketgroupid = $input->param('basketgroupid'); my $billingplace; my $deliveryplace; + my $freedeliveryplace; if ( $basketgroupid ) { # Get the selected baskets in the basketgroup to display them my $selecteds = GetBasketsByBasketgroup($basketgroupid); @@ -287,9 +288,11 @@ if ( $op eq "add" ) { $template->param( name => $basketgroup->{name}, deliverycomment => $basketgroup->{deliverycomment}, + freedeliveryplace => $basketgroup->{freedeliveryplace}, ); $billingplace = $basketgroup->{billingplace}; $deliveryplace = $basketgroup->{deliveryplace}; + $freedeliveryplace = $basketgroup->{freedeliveryplace}; } # determine default billing and delivery places depending on librarian homebranch and existing basketgroup data @@ -405,25 +408,27 @@ if ( $op eq "add" ) { } elsif ( $op eq 'attachbasket') { # 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; + 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 $freedeliveryplace = $input->param('freedeliveryplace'); + my $deliverycomment = $input->param('deliverycomment'); + my $close = $input->param('close') ? 1 : 0; # If we got a basketgroupname, we create a basketgroup if ($basketgroupid) { $basketgroup = { - name => $basketgroupname, - id => $basketgroupid, - basketlist => \@baskets, - billingplace => $billingplace, - deliveryplace => $deliveryplace, - deliverycomment => $deliverycomment, - closed => $close, + name => $basketgroupname, + id => $basketgroupid, + basketlist => \@baskets, + billingplace => $billingplace, + deliveryplace => $deliveryplace, + freedeliveryplace => $freedeliveryplace, + deliverycomment => $deliverycomment, + closed => $close, }; ModBasketgroup($basketgroup); if($close){ @@ -431,12 +436,13 @@ if ( $op eq "add" ) { } }else{ $basketgroup = { - name => $basketgroupname, - booksellerid => $booksellerid, - basketlist => \@baskets, - deliveryplace => $deliveryplace, - deliverycomment => $deliverycomment, - closed => $close, + name => $basketgroupname, + booksellerid => $booksellerid, + basketlist => \@baskets, + deliveryplace => $deliveryplace, + freedeliveryplace => $freedeliveryplace, + deliverycomment => $deliverycomment, + closed => $close, }; $basketgroupid = NewBasketgroup($basketgroup); } diff --git a/acqui/pdfformat/layout2pages.pm b/acqui/pdfformat/layout2pages.pm index 768fdec74d..148394a9c6 100755 --- a/acqui/pdfformat/layout2pages.pm +++ b/acqui/pdfformat/layout2pages.pm @@ -146,6 +146,7 @@ sub printhead { # get branch details my $billingdetails = GetBranchDetail( $basketgroup->{billingplace} ); my $deliverydetails = GetBranchDetail( $basketgroup->{deliveryplace} ); + my $freedeliveryplace = $basketgroup->{freedeliveryplace}; # get the subject my $subject; @@ -211,13 +212,23 @@ sub printhead { # print delivery infos $text->font( $pdf->corefont("Times-Bold", -encoding => "utf8"), 4/mm ); $text->translate(50/mm, ($height-237)/mm); - $text->text($deliverydetails->{branchaddress1}); - $text->translate(50/mm, ($height-242)/mm); - $text->text($deliverydetails->{branchaddress2}); - $text->translate(50/mm, ($height-247)/mm); - $text->text($deliverydetails->{branchaddress3}); - $text->translate(50/mm, ($height-252)/mm); - $text->text(join(' ', $deliverydetails->{branchzip}, $deliverydetails->{branchcity}, $deliverydetails->{branchcountry})); + if ($freedeliveryplace) { + my $start = 242; + my @fdp = split('\n', $freedeliveryplace); + foreach (@fdp) { + $text->text($_); + $text->translate( 50 / mm, ( $height - $start ) / mm ); + $start += 5; + } + } else { + $text->text( $deliverydetails->{branchaddress1} ); + $text->translate( 50 / mm, ( $height - 242 ) / mm ); + $text->text( $deliverydetails->{branchaddress2} ); + $text->translate( 50 / mm, ( $height - 247 ) / mm ); + $text->text( $deliverydetails->{branchaddress3} ); + $text->translate( 50 / mm, ( $height - 252 ) / mm ); + $text->text( join( ' ', $deliverydetails->{branchzip}, $deliverydetails->{branchcity}, $deliverydetails->{branchcountry} ) ); + } $text->translate(50/mm, ($height-262)/mm); $text->text($basketgroup->{deliverycomment}); } diff --git a/acqui/pdfformat/layout3pages.pm b/acqui/pdfformat/layout3pages.pm index f081b5605c..7dab18fc39 100755 --- a/acqui/pdfformat/layout3pages.pm +++ b/acqui/pdfformat/layout3pages.pm @@ -283,6 +283,7 @@ sub printhead { # get branch details my $billingdetails = GetBranchDetail( $basketgroup->{billingplace} ); my $deliverydetails = GetBranchDetail( $basketgroup->{deliveryplace} ); + my $freedeliveryplace = $basketgroup->{freedeliveryplace}; # get the subject my $subject; @@ -348,13 +349,23 @@ sub printhead { # print delivery infos $text->font( $pdf->corefont("Times-Bold", -encoding => "utf8"), 4/mm ); $text->translate(50/mm, ($height-237)/mm); - $text->text($deliverydetails->{branchaddress1}); - $text->translate(50/mm, ($height-242)/mm); - $text->text($deliverydetails->{branchaddress2}); - $text->translate(50/mm, ($height-247)/mm); - $text->text($deliverydetails->{branchaddress3}); - $text->translate(50/mm, ($height-252)/mm); - $text->text(join(' ', $deliverydetails->{branchzip}, $deliverydetails->{branchcity}, $deliverydetails->{branchcountry})); + if ($freedeliveryplace) { + my $start = 242; + my @fdp = split('\n', $freedeliveryplace); + foreach (@fdp) { + $text->text($_); + $text->translate( 50 / mm, ( $height - $start ) / mm ); + $start += 5; + } + } else { + $text->text($deliverydetails->{branchaddress1}); + $text->translate(50/mm, ($height-242)/mm); + $text->text($deliverydetails->{branchaddress2}); + $text->translate(50/mm, ($height-247)/mm); + $text->text($deliverydetails->{branchaddress3}); + $text->translate(50/mm, ($height-252)/mm); + $text->text(join(' ', $deliverydetails->{branchzip}, $deliverydetails->{branchcity}, $deliverydetails->{branchcountry})); + } $text->translate(50/mm, ($height-262)/mm); $text->text($basketgroup->{deliverycomment}); } diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 45e09da60a..514b2ba242 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -4227,6 +4227,13 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = 'XXX'; +if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { + $dbh->do("ALTER TABLE `aqbasketgroups` ADD `freedeliveryplace` TEXT NULL AFTER `deliveryplace`;"); + print "Upgrade to $DBversion done (adding freedeliveryplace to basketgroups)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 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 3d33b73c29..4bf41e64c7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tmpl @@ -232,6 +232,9 @@ function submitForm(form) { +

or

+

+

-- 2.39.5