Bugzilla – Attachment 34489 Details for
Bug 12648
Link patrons to an order
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12648: Link patrons to an order
0003-Bug-12648-Link-patrons-to-an-order.patch (text/plain), 11.67 KB, created by
Paola Rossi
on 2014-12-17 16:50:04 UTC
(
hide
)
Description:
Bug 12648: Link patrons to an order
Filename:
MIME Type:
Creator:
Paola Rossi
Created:
2014-12-17 16:50:04 UTC
Size:
11.67 KB
patch
obsolete
>From 01c11aae0d3487c2ddcddb06ecda65553e486746 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Thu, 24 Jul 2014 13:43:05 +0200 >Subject: [PATCH 3/9] Bug 12648: Link patrons to an order > >This patch is the main patch. > >This feature adds the ability to link patrons to an order. >On that way, they will be notified when the order is completely >received. > >Test plan: >1/ Execute the updatedb entry and verify you have a new notification template in your table (tools/letter.pl). >code: ACQ_NOTIF_ON_RECEIV, module: acquisition >2/ You can edit it if you want >3/ Create a basket and create an order with 1 or more items >4/ Link 1+ patrons to this order >5/ Close the basket and receive the order >6/ When you have received all items for this order, all patrons attached >will be notified. Check the message_queue table to check if the letters >have correctly been added to the queue. > >Signed-off-by: Paola Rossi <paola.rossi@cineca.it> >--- > C4/Acquisition.pm | 108 ++++++++++++++++++++ > acqui/addorder.pl | 8 +- > acqui/basket.pl | 6 +- > acqui/neworderempty.pl | 9 ++ > .../prog/en/modules/acqui/neworderempty.tt | 57 +++++++++++ > tools/letter.pl | 3 + > 6 files changed, 186 insertions(+), 5 deletions(-) > >diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm >index ecf96fe..b2da561 100644 >--- a/C4/Acquisition.pm >+++ b/C4/Acquisition.pm >@@ -81,6 +81,10 @@ BEGIN { > > &AddClaim > &GetBiblioCountByBasketno >+ >+ &GetOrderUsers >+ &ModOrderUsers >+ &NotifyOrderUsers > ); > } > >@@ -1476,6 +1480,10 @@ q{SELECT * FROM aqorders WHERE biblionumber=? AND aqorders.ordernumber=?}, > $biblionumber, > $ordernumber > ); >+ >+ # All items have been received, sent a notification to users >+ NotifyOrderUsers( $ordernumber ); >+ > } > return ($datereceived, $new_ordernumber); > } >@@ -2883,6 +2891,106 @@ sub GetBiblioCountByBasketno { > return $sth->fetchrow; > } > >+ >+=head3 GetOrderUsers >+ >+ $order_users_ids = &GetOrderUsers($ordernumber); >+ >+Returns a list of all borrowernumbers that are in order users list >+ >+=cut >+ >+sub GetOrderUsers { >+ my ($ordernumber) = @_; >+ >+ return unless $ordernumber; >+ >+ my $query = q| >+ SELECT borrowernumber >+ FROM aqorderusers >+ WHERE ordernumber = ? >+ |; >+ my $dbh = C4::Context->dbh; >+ my $sth = $dbh->prepare($query); >+ $sth->execute($ordernumber); >+ my $results = $sth->fetchall_arrayref( {} ); >+ >+ my @borrowernumbers; >+ foreach (@$results) { >+ push @borrowernumbers, $_->{'borrowernumber'}; >+ } >+ >+ return @borrowernumbers; >+} >+ >+=head3 ModOrderUsers >+ >+ my @order_users_ids = (1, 2, 3); >+ &ModOrderUsers($ordernumber, @basketusers_ids); >+ >+Delete all users from order users list, and add users in C<@order_users_ids> >+to this users list. >+ >+=cut >+ >+sub ModOrderUsers { >+ my ( $ordernumber, @order_users_ids ) = @_; >+ >+ return unless $ordernumber; >+ >+ my $dbh = C4::Context->dbh; >+ my $query = q| >+ DELETE FROM aqorderusers >+ WHERE ordernumber = ? >+ |; >+ my $sth = $dbh->prepare($query); >+ $sth->execute($ordernumber); >+ >+ $query = q| >+ INSERT INTO aqorderusers (ordernumber, borrowernumber) >+ VALUES (?, ?) >+ |; >+ $sth = $dbh->prepare($query); >+ foreach my $order_user_id (@order_users_ids) { >+ $sth->execute( $ordernumber, $order_user_id ); >+ } >+} >+ >+sub NotifyOrderUsers { >+ my ($ordernumber) = @_; >+ >+ my @borrowernumbers = GetOrderUsers($ordernumber); >+ return unless @borrowernumbers; >+ >+ my $order = GetOrder( $ordernumber ); >+ for my $borrowernumber (@borrowernumbers) { >+ my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber ); >+ my $branch = C4::Branch::GetBranchDetail( $borrower->{branchcode} ); >+ my $biblio = C4::Biblio::GetBiblio( $order->{biblionumber} ); >+ my $letter = C4::Letters::GetPreparedLetter( >+ module => 'acquisition', >+ letter_code => 'ACQ_NOTIF_ON_RECEIV', >+ branchcode => $branch->{branchcode}, >+ tables => { >+ 'branches' => $branch, >+ 'borrowers' => $borrower, >+ 'biblio' => $biblio, >+ 'aqorders' => $order, >+ }, >+ ); >+ if ( $letter ) { >+ C4::Letters::EnqueueLetter( >+ { >+ letter => $letter, >+ borrowernumber => $borrowernumber, >+ LibraryName => C4::Context->preference("LibraryName"), >+ message_transport_type => 'email', >+ } >+ ) or warn "can't enqueue letter $letter"; >+ } >+ } >+} >+ > 1; > __END__ > >diff --git a/acqui/addorder.pl b/acqui/addorder.pl >index f5508a2..c52c563 100755 >--- a/acqui/addorder.pl >+++ b/acqui/addorder.pl >@@ -263,8 +263,12 @@ if ( $orderinfo->{quantity} ne '0' ) { > > # if we already have $ordernumber, then it's an ordermodif > my $order = Koha::Acquisition::Order->new($orderinfo); >- if ($$orderinfo{ordernumber}) { >- ModOrder( $orderinfo); >+ if ( $orderinfo->{ordernumber} ) { >+ ModOrder($orderinfo); >+ my $order_users_ids = $input->param('users_ids'); >+ my @order_users = split( /:/, $order_users_ids ); >+ >+ ModOrderUsers( $orderinfo->{ordernumber}, @order_users ); > } > else { # else, it's a new line > $order->insert; >diff --git a/acqui/basket.pl b/acqui/basket.pl >index 0ca8e3a..98e5e05 100755 >--- a/acqui/basket.pl >+++ b/acqui/basket.pl >@@ -238,7 +238,7 @@ if ( $op eq 'delete_confirm' ) { > ReopenBasket($query->param('basketno')); > print $query->redirect('/cgi-bin/koha/acqui/basket.pl?basketno='.$basket->{'basketno'}) > } elsif ( $op eq 'mod_users' ) { >- my $basketusers_ids = $query->param('basketusers_ids'); >+ my $basketusers_ids = $query->param('users_ids'); > my @basketusers = split( /:/, $basketusers_ids ); > ModBasketUsers($basketno, @basketusers); > print $query->redirect("/cgi-bin/koha/acqui/basket.pl?basketno=$basketno"); >@@ -408,8 +408,8 @@ if ( $op eq 'delete_confirm' ) { > creationdate => $basket->{creationdate}, > authorisedby => $basket->{authorisedby}, > authorisedbyname => $basket->{authorisedbyname}, >- basketusers_ids => join(':', @basketusers_ids), >- basketusers => \@basketusers, >+ users_ids => join(':', @basketusers_ids), >+ users => \@basketusers, > closedate => $basket->{closedate}, > estimateddeliverydate=> $estimateddeliverydate, > deliveryplace => C4::Branch::GetBranchName( $basket->{deliveryplace} ), >diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl >index 69a194a..e32cf29 100755 >--- a/acqui/neworderempty.pl >+++ b/acqui/neworderempty.pl >@@ -173,6 +173,7 @@ if ( $ordernumber eq '' and defined $params->{'breedingid'}){ > > > >+my ( @order_user_ids, @order_users ); > if ( $ordernumber eq '' ) { # create order > $new = 'yes'; > >@@ -195,6 +196,12 @@ else { #modify order > > $basket = GetBasket( $data->{'basketno'} ); > $basketno = $basket->{'basketno'}; >+ >+ @order_user_ids = GetOrderUsers($ordernumber); >+ foreach my $order_user_id (@order_user_ids) { >+ my $order_user = GetMember(borrowernumber => $order_user_id); >+ push @order_users, $order_user if $order_user; >+ } > } > > my $suggestion; >@@ -399,6 +406,8 @@ $template->param( > import_batch_id => $import_batch_id, > subscriptionid => $subscriptionid, > acqcreate => C4::Context->preference("AcqCreateItem") eq "ordering" ? 1 : "", >+ users_ids => join(':', @order_user_ids), >+ users => \@order_users, > (uc(C4::Context->preference("marcflavour"))) => 1 > ); > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt >index fcf15a0..27cb53b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt >@@ -160,6 +160,40 @@ $(document).ready(function() > }); > $("#budget_id").change(); > }); >+ >+ function UserSearchPopup(f) { >+ window.open( >+ "/cgi-bin/koha/acqui/add_user_search.pl", >+ 'UserSearchPopup', >+ 'width=740,height=450,toolbar=no,' >+ ); >+ } >+ >+ function add_user(borrowernumber, borrowername) { >+ var ids = $("#users_ids").val(); >+ if(ids.length > 0) { >+ ids = ids.split(':'); >+ } else { >+ ids = new Array; >+ } >+ if (ids.indexOf(borrowernumber) < 0) { >+ ids.push(borrowernumber); >+ $("#users_ids").val(ids.join(':')); >+ var li = '<li id="user_'+borrowernumber+'">'+borrowername >+ + ' [<a style="cursor:pointer" onclick="del_user('+borrowernumber+');">' >+ + _("Delete user") + '</a>]</li>'; >+ $("#users_names").append(li); >+ return 0; >+ } >+ return -1; >+ } >+ >+ function del_user(borrowernumber) { >+ $("#user_"+borrowernumber).remove(); >+ var ids = $("#users_ids").val().split(':'); >+ ids.splice(ids.indexOf(borrowernumber.toString()), 1); >+ $("#users_ids").val(ids.join(':')); >+ } > //]]> > </script> > </head> >@@ -227,6 +261,29 @@ $(document).ready(function() > > <form action="/cgi-bin/koha/acqui/addorder.pl" method="post" id="Aform" onsubmit="return Check(this);"> > >+ <fieldset class="rows"> >+ <legend>Patrons</legend> >+ <ol> >+ <li> >+ <span class="label">To notify on reveiving:</span> >+ <div style="float:left"> >+ <ul id="users_names" style="padding-left:0"> >+ [% FOREACH user IN users %] >+ <li id="user_[% user.borrowernumber %]"> >+ [% user.firstname %] [% user.surname %] >+ [<a onclick="del_user([% user.borrowernumber %]);" style="cursor:pointer">Delete user</a>] >+ </li> >+ [% END %] >+ </ul> >+ <input type="hidden" id="basketno" name="basketno" value="[% basketno %]" /> >+ <input type="hidden" id="users_ids" name="users_ids" value="[% users_ids %]" /> >+ <input type="hidden" id="op" name="op" value="mod_users" /> >+ <input type="button" id="add_user" onclick="UserSearchPopup();" value="Add user" /> >+ </div> >+ </li> >+ </ol> >+ </fieldset> >+ > <fieldset class="rows"> > <legend> > Catalog details >diff --git a/tools/letter.pl b/tools/letter.pl >index ab4f78f..5dce575 100755 >--- a/tools/letter.pl >+++ b/tools/letter.pl >@@ -196,6 +196,9 @@ sub add_form { > if ($module eq 'reserves') { > push @{$field_selection}, add_fields('borrowers', 'reserves', 'biblio', 'items'); > } >+ elsif ( $module eq 'acquisition' ) { >+ push @{$field_selection}, add_fields('aqbooksellers', 'aqorders', 'biblio', 'items'); >+ } > elsif ($module eq 'claimacquisition') { > push @{$field_selection}, add_fields('aqbooksellers', 'aqorders', 'biblio', 'biblioitems'); > } >-- >1.7.10.4 >
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 12648
:
30024
|
30025
|
30026
|
30027
|
30988
|
30989
|
30990
|
30991
|
31273
|
31960
|
31961
|
32230
|
33186
|
33187
|
33188
|
33189
|
33190
|
33191
|
33192
|
33193
|
34224
|
34225
|
34226
|
34227
|
34228
|
34229
|
34230
|
34231
|
34477
|
34487
|
34488
|
34489
|
34490
|
34491
|
34492
|
34493
|
34494
|
34495
|
35056
|
35058
|
35059
|
35060
|
35061
|
35062
|
35063
|
35064
|
35065
|
35066
|
36795
|
36796
|
36797
|
36798
|
36799
|
36800
|
36801
|
36802
|
36803
|
36804
|
36805
|
36807
|
36810
|
36817