Bugzilla – Attachment 8532 Details for
Bug 5356
Shipping billing address improvements
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 5356: delivery place and billing place centralised in basket management
0001-Bug-5356-delivery-place-and-billing-place-centralise.patch (text/plain), 18.82 KB, created by
Jonathan Druart
on 2012-03-22 16:15:20 UTC
(
hide
)
Description:
Bug 5356: delivery place and billing place centralised in basket management
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2012-03-22 16:15:20 UTC
Size:
18.82 KB
patch
obsolete
>From 952983ca53fe01580022265a4eee984a07f39a91 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Fri, 2 Mar 2012 10:39:54 +0100 >Subject: [PATCH 1/1] Bug 5356: delivery place and billing place centralised > in basket management > >- adding 2 select option in basdketheader.tmpl (delivery and billing place) >- adding 2 more fields in basket csv export >--- > C4/Acquisition.pm | 68 +++++++++------- > acqui/basket.pl | 12 +++- > acqui/basketheader.pl | 86 ++++++++++++++++++-- > installer/data/mysql/kohastructure.sql | 3 + > installer/data/mysql/updatedatabase.pl | 12 +++ > .../intranet-tmpl/prog/en/modules/acqui/basket.tt | 8 ++- > .../prog/en/modules/acqui/basketgroup.tt | 1 + > .../prog/en/modules/acqui/basketheader.tt | 22 +++++ > 8 files changed, 172 insertions(+), 40 deletions(-) > >diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm >index 4fd5cc2..a275de3 100644 >--- a/C4/Acquisition.pm >+++ b/C4/Acquisition.pm >@@ -42,7 +42,7 @@ BEGIN { > @ISA = qw(Exporter); > @EXPORT = qw( > &GetBasket &NewBasket &CloseBasket &DelBasket &ModBasket >- &GetBasketAsCSV >+ &GetBasketAsCSV > &GetBasketsByBookseller &GetBasketsByBasketgroup > &GetBasketsInfosByBookseller > >@@ -182,7 +182,7 @@ The other parameters are optional, see ModBasketHeader for more info on them. > # FIXME : this function seems to be unused. > > sub NewBasket { >- my ( $booksellerid, $authorisedby, $basketname, $basketnote, $basketbooksellernote, $basketcontractnumber ) = @_; >+ my ( $booksellerid, $authorisedby, $basketname, $basketnote, $basketbooksellernote, $basketcontractnumber, $deliveryplace, $billingplace ) = @_; > my $dbh = C4::Context->dbh; > my $query = " > INSERT INTO aqbasket >@@ -193,7 +193,7 @@ sub NewBasket { > $dbh->do($query); > #find & return basketno MYSQL dependant, but $dbh->last_insert_id always returns null :-( > my $basket = $dbh->{'mysql_insertid'}; >- ModBasketHeader($basket, $basketname || '', $basketnote || '', $basketbooksellernote || '', $basketcontractnumber || undef); >+ ModBasketHeader( $basket, $basketname || '', $basketnote || '', $basketbooksellernote || '', $basketcontractnumber || undef, $deliveryplace || undef, $billingplace || undef ); > return $basket; > } > >@@ -240,38 +240,38 @@ sub GetBasketAsCSV { > # TODO: Translate headers > my @headers = qw(contractname ordernumber entrydate isbn author title publishercode collectiontitle notes quantity rrp); > >- $csv->combine(@headers); >- $output = $csv->string() . "\n"; >+ $csv->combine(@headers); >+ $output = $csv->string() . "\n"; > > my @rows; > foreach my $order (@orders) { >- my @cols; >- # newlines are not valid characters for Text::CSV combine() >+ my @cols; >+ # newlines are not valid characters for Text::CSV combine() > $order->{'notes'} =~ s/[\r\n]+//g; >- push(@cols, >- $contract->{'contractname'}, >- $order->{'ordernumber'}, >- $order->{'entrydate'}, >- $order->{'isbn'}, >- $order->{'author'}, >- $order->{'title'}, >- $order->{'publishercode'}, >- $order->{'collectiontitle'}, >- $order->{'notes'}, >- $order->{'quantity'}, >- $order->{'rrp'}, >- ); >- push (@rows, \@cols); >+ push(@cols, >+ $contract->{'contractname'}, >+ $order->{'ordernumber'}, >+ $order->{'entrydate'}, >+ $order->{'isbn'}, >+ $order->{'author'}, >+ $order->{'title'}, >+ $order->{'publishercode'}, >+ $order->{'collectiontitle'}, >+ $order->{'notes'}, >+ $order->{'quantity'}, >+ $order->{'rrp'}, >+ $basket->{'deliveryplace'}, >+ $basket->{'billingplace'}, >+ ); >+ push (@rows, \@cols); > } > > foreach my $row (@rows) { >- $csv->combine(@$row); >- $output .= $csv->string() . "\n"; >- >+ $csv->combine(@$row); >+ $output .= $csv->string() . "\n"; > } >- >- return $output; > >+ return $output; > } > > >@@ -385,7 +385,7 @@ sub ModBasket { > > =head3 ModBasketHeader > >- &ModBasketHeader($basketno, $basketname, $note, $booksellernote, $contractnumber); >+ &ModBasketHeader($basketno, $basketname, $note, $booksellernote, $contractnumber, $deliveryplace, $billingplace); > > Modifies a basket's header. > >@@ -401,16 +401,24 @@ Modifies a basket's header. > > =item C<$contractnumber> is the "contractnumber" (foreign) key in the "aqbasket" table. > >+=item C<$deliveryplace> is the "deliveryplace" field in the aqbasket table. >+ >+=item C<$billingplace> is the "billingplace" field in the aqbasket table. >+ > =back > > =cut > > sub ModBasketHeader { >- my ($basketno, $basketname, $note, $booksellernote, $contractnumber) = @_; >- my $query = "UPDATE aqbasket SET basketname=?, note=?, booksellernote=? WHERE basketno=?"; >+ my ($basketno, $basketname, $note, $booksellernote, $contractnumber, $deliveryplace, $billingplace) = @_; >+ my $query = qq{ >+ UPDATE aqbasket >+ SET basketname=?, note=?, booksellernote=?, deliveryplace=?, billingplace=? >+ WHERE basketno=? >+ }; > my $dbh = C4::Context->dbh; > my $sth = $dbh->prepare($query); >- $sth->execute($basketname,$note,$booksellernote,$basketno); >+ $sth->execute($basketname, $note, $booksellernote, $deliveryplace, $billingplace, $basketno); > if ( $contractnumber ) { > my $query2 ="UPDATE aqbasket SET contractnumber=? WHERE basketno=?"; > my $sth2 = $dbh->prepare($query2); >diff --git a/acqui/basket.pl b/acqui/basket.pl >index 4386125..b43d6e7 100755 >--- a/acqui/basket.pl >+++ b/acqui/basket.pl >@@ -129,6 +129,8 @@ if ( $op eq 'delete_confirm' ) { > authorisedby => $basket->{authorisedby}, > authorisedbyname => $basket->{authorisedbyname}, > closedate => $basket->{closedate}, >+ deliveryplace => $basket->{deliveryplace} || $basket->{freedeliveryplace}, >+ billingplace => $basket->{billingplace}, > active => $bookseller->{'active'}, > booksellerid => $bookseller->{'id'}, > name => $bookseller->{'name'}, >@@ -339,7 +341,13 @@ my $total_est_gste; > > my $contract = &GetContract($basket->{contractnumber}); > my @orders = GetOrders($basketno); >- >+ if ($basket->{basketgroupid}){ >+ my $basketgroup = GetBasketgroup($basket->{basketgroupid}); >+ for my $key (keys %$basketgroup ){ >+ $basketgroup->{"basketgroup$key"} = delete $basketgroup->{$key}; >+ } >+ $template->param(%$basketgroup); >+ } > my $borrower= GetMember('borrowernumber' => $loggedinuser); > my $budgets = GetBudgetHierarchy(q{},$borrower->{branchcode},$borrower->{borrowernumber}); > my $has_budgets = 0; >@@ -367,6 +375,8 @@ my $total_est_gste; > authorisedby => $basket->{authorisedby}, > authorisedbyname => $basket->{authorisedbyname}, > closedate => $basket->{closedate}, >+ deliveryplace => $basket->{deliveryplace} || $basket->{freedeliveryplace}, >+ billingplace => $basket->{billingplace}, > active => $bookseller->{'active'}, > booksellerid => $bookseller->{'id'}, > name => $bookseller->{'name'}, >diff --git a/acqui/basketheader.pl b/acqui/basketheader.pl >index b33e4ef..aa3ed6e 100755 >--- a/acqui/basketheader.pl >+++ b/acqui/basketheader.pl >@@ -50,6 +50,7 @@ use warnings; > use CGI; > use C4::Context; > use C4::Auth; >+use C4::Branch; > use C4::Output; > use C4::Acquisition qw/GetBasket NewBasket GetContracts ModBasketHeader/; > use C4::Bookseller qw/GetBookSellerFromId/; >@@ -68,9 +69,9 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > ); > > #parameters: >-my $booksellerid; >-$booksellerid = $input->param('booksellerid'); >+my $booksellerid = $input->param('booksellerid'); > my $basketno = $input->param('basketno'); >+my $branches = GetBranches; > my $basket; > my $op = $input ->param('op'); > my $is_an_edit= $input ->param('is_an_edit'); >@@ -107,17 +108,86 @@ if ( $op eq 'add_form' ) { > basketbooksellernote => $basket->{'booksellernote'}, > booksellername => $bookseller->{'name'}, > booksellerid => $booksellerid, >- basketno => $basketno >- ); >+ basketno => $basketno, >+ deliveryplace => $basket->{deliveryplace}, >+ billingplace => $basket->{billingplace}, >+ ); >+ >+ my $billingplace = $basket->{'billingplace'} || C4::Context->userenv->{"branch"}; >+ my $deliveryplace = $basket->{'deliveryplace'} || C4::Context->userenv->{"branch"}; >+ >+ # Build the combobox to select the billing place >+ my @billingplaceloop; >+ >+ # In case there's no branch selected >+ if ($billingplace eq "NO_LIBRARY_SET") { >+ my %row = ( >+ value => "", >+ selected => 1, >+ branchname => "--", >+ ); >+ push @billingplaceloop, \%row; >+ } >+ >+ for ( sort keys %$branches ) { >+ my $selected = 1 if $_ eq $billingplace; >+ my %row = ( >+ value => $_, >+ selected => $selected, >+ branchname => $branches->{$_}->{branchname}, >+ ); >+ push @billingplaceloop, \%row; >+ } >+ $template->param( billingplaceloop => \@billingplaceloop ); >+ >+ # Build the combobox to select the delivery place >+ my @deliveryplaceloop; >+ >+ # In case there's no branch selected >+ if ($deliveryplace eq "NO_LIBRARY_SET") { >+ my %row = ( >+ value => "", >+ selected => 1, >+ branchname => "--", >+ ); >+ push @deliveryplaceloop, \%row; >+ } >+ >+ 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 ); >+ > #End Edit > } elsif ( $op eq 'add_validate' ) { > #we are confirming the changes, save the basket >- my $basketno; > if ( $is_an_edit ) { >- $basketno = $input->param('basketno'); >- ModBasketHeader($input->param('basketno'),$input->param('basketname'),$input->param('basketnote'),$input->param('basketbooksellernote'),$input->param('basketcontractnumber')); >+ ModBasketHeader( >+ $basketno, >+ $input->param('basketname'), >+ $input->param('basketnote'), >+ $input->param('basketbooksellernote'), >+ $input->param('basketcontractnumber'), >+ $input->param('deliveryplace'), >+ $input->param('billingplace'), >+ ); > } else { #New basket >- $basketno = NewBasket($booksellerid, $loggedinuser, $input->param('basketname'), $input->param('basketnote'), $input->param('basketbooksellernote'), $input->param('basketcontractnumber')); >+ $basketno = NewBasket( >+ $booksellerid, >+ $loggedinuser, >+ $input->param('basketname'), >+ $input->param('basketnote'), >+ $input->param('basketbooksellernote'), >+ $input->param('basketcontractnumber'), >+ $input->param('deliveryplace'), >+ $input->param('billingplace'), >+ ); > } > print $input->redirect('basket.pl?basketno='.$basketno); > exit 0; >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index c478214..07d0681 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -2549,6 +2549,9 @@ CREATE TABLE `aqbasket` ( > `authorisedby` varchar(10) default NULL, > `booksellerinvoicenumber` mediumtext, > `basketgroupid` int(11), >+ deliveryplace varchar(10) default NULL, >+ billingplace varchar(10) default NULL, >+ freedeliveryplace VARCHAR(10) default NULL, > PRIMARY KEY (`basketno`), > KEY `booksellerid` (`booksellerid`), > KEY `basketgroupid` (`basketgroupid`), >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index ec08012..d0c78d9 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -5013,6 +5013,18 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { > SetVersion($DBversion); > } > >+ >+ >+ >+$DBversion = "3.07.00.XXX"; >+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { >+ $dbh->do("ALTER TABLE aqbasket ADD deliveryplace VARCHAR(10) default NULL;"); >+ $dbh->do("ALTER TABLE aqbasket ADD billingplace VARCHAR(10) default NULL;"); >+ $dbh->do("ALTER TABLE aqbasket ADD freedeliveryplace VARCHAR(10) default NULL;"); >+ print "Upgrade to $DBversion done (Added billingplace and deliveryplace to aqbasket)\n"; >+ SetVersion($DBversion); >+} >+ > =head1 FUNCTIONS > > =head2 DropAllForeignKeys($table) >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt >index cc64cae..fc5b35f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt >@@ -135,11 +135,14 @@ > // YUI Toolbar Functions > function yuiToolbar() { > new YAHOO.widget.Button("reopenbutton"); >+ new YAHOO.widget.Button("exportbutton"); > } > //]]> > </script> > <ul id="toolbar-list" class="toolbar"> > <li><a href="javascript:confirm_reopen([% skip_confirm_reopen %]);" class="button" id="reopenbutton">Reopen this basket</a></li> >+ <li><a href="[% script_name %]?op=export&basketno=[% basketno %]&booksellerid=[% booksellerid %]" class="button" id="exportbutton">Export this basket as CSV</a></li> >+ > </ul> > </div> > [% END %] >@@ -178,6 +181,8 @@ > [% IF ( basketcontractno ) %] > <li><span class="label">Contract name:</span> <a href="../admin/aqcontract.pl?op=add_form&contractnumber=[% basketcontractno %]&booksellerid=[% booksellerid %]">[% basketcontractname %]</a></li> > [% END %] >+ [% IF ( deliveryplace ) %]<li><span class="label">Delivery place:</span> [% deliveryplace %]</li>[% END %] >+ [% IF ( billingplace ) %]<li><span class="label">Billing place:</span> [% billingplace %]</li>[% END %] > [% IF ( authorisedbyname ) %]<li><span class="label">Managed by:</span> [% authorisedbyname %]</li>[% END %] > [% IF ( creationdate ) %]<li><span class="label">Opened on:</span> [% creationdate | $KohaDates %]</li>[% END %] > [% IF ( closedate ) %]<li><span class="label">Closed on:</span> [% closedate | $KohaDates %]</li>[% END %] >@@ -204,8 +209,9 @@ > <input type="hidden" value="mod_basket" name="op" /> > <input type="hidden" name="booksellerid" value="[% booksellerid %]" /> > <input type="submit" value="Change basket group" /></p> >- > </form> >+ [% IF ( basketgroupdeliveryplace ) %]<p>Basketgroup Delivery place: [% basketgroupdeliveryplace %]</p>[% END %] >+ [% IF ( basketgroupbillingplace ) %]<p>Basketgroup Billing place: [% basketgroupbillingplace %]</p>[% END %] > </div> > [% END %] > </div> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt >index c651e00..0e5d99f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt >@@ -189,6 +189,7 @@ function yuiToolbar() { > <input type="text" name="basketgroupname" id="basketgroupname" value="[% name %]" /></li> > <li><label for="billingplace">Billing Place:</label> > <select name="billingplace" id="billingplace" style="width:13em;"> >+ <option value="">--</option> > [% FOREACH billingplaceloo IN billingplaceloop %] > [% IF ( billingplaceloo.selected ) %]<option value="[% billingplaceloo.value %]" selected="selected">[% billingplaceloo.branchname %]</option> > [% ELSE %]<option value="[% billingplaceloo.value %]">[% billingplaceloo.branchname %]</option>[% END%] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt >index 160c5f6..5164e10 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt >@@ -125,6 +125,28 @@ li.list2 { > <label for="basketname" class="required">Basket name</label> > <input type="text" name="basketname" id="basketname" size="40" maxlength="80" value="[% basketname %]" /> > </li> >+ <li> >+ <label for="billingplace">Billing Place:</label> >+ <select name="billingplace" id="billingplace"> >+ <option value="">--</option> >+ [% FOREACH billingplace IN billingplaceloop %] >+ <option value="[% billingplace.value %]"[% IF ( billingplace.selected ) %] selected="selected"[% END %]> >+ [% billingplace.branchname %] >+ </option> >+ [% END %] >+ </select> >+ </li> >+ <li> >+ <label for="deliveryplace">Delivery Place:</label> >+ <select name="deliveryplace" id="deliveryplace"> >+ <option value="">--</option> >+ [% FOREACH deliveryplace IN deliveryplaceloop %] >+ <option value="[% deliveryplace.value %]"[% IF ( deliveryplace.selected ) %] selected="selected"[% END %]> >+ [% deliveryplace.branchname %] >+ </option> >+ [% END %] >+ </select> >+ </li> > <li> > <label for="basketnote">Internal note</label> > <textarea name="basketnote" id="basketnote" rows="5" cols="40">[% basketnote %]</textarea> >-- >1.7.7.3 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 5356
:
8405
|
8409
|
8532
|
8940
|
9228
|
9230
|
9975
|
10152
|
10201
|
10338
|
10340
|
10341
|
11120
|
11952
|
12376
|
12377
|
12407
|
12484
|
12838