Adds billing address support in the basketgroup.

Also fixes a bug in ModBasketgroup, and renames the PDF uploaded to the client.
This commit is contained in:
Jean-André Santoni 2009-11-04 13:17:09 +01:00
parent 4a119ecb41
commit eff46d395e
7 changed files with 83 additions and 42 deletions

View File

@ -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});
}

View File

@ -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,

Binary file not shown.

Binary file not shown.

View File

@ -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)

View File

@ -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)

View File

@ -207,10 +207,16 @@ fieldset.various li {
<fieldset id="various" class='various' >
<h3><label for="basketgroupname">Basketgroup Name:</label></h3>
<input type="text" name="basketgroupname" id="basketgroupname" value="<!-- TMPL_VAR NAME="name" -->" />
<h3><label for="billingplace">Billing Place:</label></h3>
<select name="billingplace" id="billingplace">
<!-- TMPL_LOOP name="billingplaceloop" -->
<option value="<!-- TMPL_VAR name="value" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->><!-- TMPL_VAR name="branchname" --></option>
<!-- /TMPL_LOOP -->
</select>
<h3><label for="deliveryplace">Delivery Place:</label></h3>
<select name="deliveryplace" id="deliveryplace">
<option value="">--</option>
<!-- TMPL_LOOP name="branchloop" -->
<!-- TMPL_LOOP name="deliveryplaceloop" -->
<option value="<!-- TMPL_VAR name="value" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->><!-- TMPL_VAR name="branchname" --></option>
<!-- /TMPL_LOOP -->
</select>