[Koha-patches] [PATCH] Bug 5970: Adds the ability to use a free delivery address for basket
Julian Maurice
julian.maurice at biblibre.com
Mon Mar 28 13:54:31 CEST 2011
From: Matthias Meusburger <matthias.meusburger at biblibre.com>
When editing a basket group, user can choose a library for delivery
place, or enter address of his choice in a text field.
---
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 c1b837b..2232d78 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 2a35f3a..457b616 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 768fdec..148394a 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 f081b56..7dab18f 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 23b5d67..1c4e4c8 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -4134,6 +4134,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 3d33b73..4bf41e6 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) {
<option value="<!-- TMPL_VAR name="value" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->><!-- TMPL_VAR name="branchname" --></option>
<!-- /TMPL_LOOP -->
</select>
+ <p>or</p>
+ <h3><label for="freedeliveryplace">Delivery Place:</label></h3>
+ <textarea cols="26" name="freedeliveryplace" id="freedeliveryplace"><!-- TMPL_VAR NAME="freedeliveryplace" --></textarea>
<h3><label for="deliverycomment">Delivery comment:</label></h3>
<textarea cols="26" name="deliverycomment" id="deliverycomment"><!-- TMPL_VAR NAME="deliverycomment" --></textarea>
<div class="workarea">
--
1.7.4.1
More information about the Koha-patches
mailing list