[Koha-patches] [PATCH] bug_7001: Added TRANSFERSLIP to the letters

Srdjan Jankovic srdjan at catalyst.net.nz
Wed Feb 29 02:07:25 CET 2012


---
 C4/Circulation.pm                                  |   30 ++++++++++++++++
 circ/transfer-slip.pl                              |   32 ++++++++++-------
 .../data/mysql/en/mandatory/sample_notices.sql     |   36 ++++++++++++--------
 installer/data/mysql/updatedatabase.pl             |   13 ++++++-
 4 files changed, 83 insertions(+), 28 deletions(-)
 mode change 100755 => 100644 installer/data/mysql/updatedatabase.pl

diff --git a/C4/Circulation.pm b/C4/Circulation.pm
index a62f26e..1ee0c34 100644
--- a/C4/Circulation.pm
+++ b/C4/Circulation.pm
@@ -99,6 +99,7 @@ BEGIN {
                 &IsBranchTransferAllowed
                 &CreateBranchTransferLimit
                 &DeleteBranchTransferLimits
+        &TransferSlip
 	);
 }
 
@@ -3036,6 +3037,35 @@ sub LostItem{
 }
 
 
+=head2 ReserveSlip
+
+  ReserveSlip($branchcode, $borrowernumber, $biblionumber)
+
+  Returns letter hash ( see C4::Letters::GetPreparedLetter ) or undef
+
+=cut
+
+sub TransferSlip {
+    my ($branch, $itemnumber, $to_branch) = @_;
+
+    my $item =  GetItem( $itemnumber )
+      or return;
+
+    my $pulldate = C4::Dates->new();
+
+    return C4::Letters::GetPreparedLetter (
+        module => 'circulation',
+        letter_code => 'TRANSFERSLIP',
+        branchcode => $branch,
+        tables => {
+            'branches'    => $to_branch,
+            'biblio'      => $item->{biblionumber},
+            'items'       => $item,
+        },
+    );
+}
+
+
 1;
 
 __END__
diff --git a/circ/transfer-slip.pl b/circ/transfer-slip.pl
index f054ca4..c8e97a0 100755
--- a/circ/transfer-slip.pl
+++ b/circ/transfer-slip.pl
@@ -24,11 +24,8 @@ use warnings;
 use C4::Context;
 use C4::Output;
 use CGI;
-use C4::Auth;
-use C4::Biblio;
-use C4::Items;
-use C4::Branch;
-use C4::Dates qw/format_date format_date_in_iso/;
+use C4::Auth qw/:DEFAULT get_session/;
+use C4::Circulation;
 
 use vars qw($debug);
 
@@ -37,12 +34,15 @@ BEGIN {
 }
 
 my $input = new CGI;
+my $sessionID = $input->cookie("CGISESSID");
+my $session = get_session($sessionID);
+
 my $itemnumber = $input->param('transferitem');
 my $branchcode = $input->param('branchcode');
 
 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     {
-        template_name   => "circ/transfer-slip.tmpl",
+        template_name   => "circ/printslip.tmpl",
         query           => $input,
         type            => "intranet",
         authnotrequired => 0,
@@ -51,15 +51,21 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     }
 );
 
-my $pulldate = C4::Dates->new();
-my $item =  GetItem( $itemnumber );
-my ( undef, $biblio ) = GetBiblio($item->{biblionumber});
 
+my $userenv = C4::Context->userenv;
+my ($slip, $is_html);
+if ( my $letter = TransferSlip ($session->param('branch') || $userenv->{branch}, $itemnumber, $branchcode) ) {
+    $slip = $letter->{content};
+    $is_html = $letter->{is_html};
+}
+else {
+    $slip = "Item not found";
+}
 $template->param(
-    pulldate => $pulldate->output(),
-    branchname => GetBranchName($branchcode),
-    biblio => $biblio,
-    item => $item,
+    slip => $slip,
+    plain => !$is_html,
+    title => "Koha -- Circulation: Transfers",
+    stylesheet => C4::Context->preference("SlipCSS"),
 );
 
 output_html_with_http_headers $input, $cookie, $template->output;
diff --git a/installer/data/mysql/en/mandatory/sample_notices.sql b/installer/data/mysql/en/mandatory/sample_notices.sql
index a600373..f5015bf 100644
--- a/installer/data/mysql/en/mandatory/sample_notices.sql
+++ b/installer/data/mysql/en/mandatory/sample_notices.sql
@@ -70,8 +70,6 @@ Date due: <<issues.date_due>><br />
 
 <h3> Transfer to/Hold in <<branches.branchname>></h3>
 
-<reserves>
-<div>
 <h3><<borrowers.surname>>, <<borrowers.firstname>></h3>
 
 <ul>
@@ -85,16 +83,26 @@ Date due: <<issues.date_due>><br />
 </ul>
 <br />
 <h3>ITEM ON HOLD</h3>
- <h4><<biblio.title>></h4>
- <h5><<biblio.author>></h5>
- <ul>
-    <li><<items.barcode>></li>
-    <li><<items.itemcallnumber>></li>
-    <li><<reserves.waitingdate>></li>
- </ul>
- <p>Notes:
- <pre><<reserves.reservenotes>></pre>
- </p>
-</div>
-</reserves>', 1);
+<h4><<biblio.title>></h4>
+<h5><<biblio.author>></h5>
+<ul>
+   <li><<items.barcode>></li>
+   <li><<items.itemcallnumber>></li>
+   <li><<reserves.waitingdate>></li>
+</ul>
+<p>Notes:
+<pre><<reserves.reservenotes>></pre>
+</p>
+', 1),
+('circulation','TRANSFERSLIP','Transfer Slip','Transfer Slip', '<h5>Date: <<today>></h5>
+
+<h3>Transfer to <<branches.branchname>></h3>
+
+<h3>ITEM</h3>
+<h4><<biblio.title>></h4>
+<h5><<biblio.author>></h5>
+<ul>
+   <li><<items.barcode>></li>
+   <li><<items.itemcallnumber>></li>
+</ul>', 1);
 
diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
old mode 100755
new mode 100644
index 48c1333..11e4437
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -4807,13 +4807,24 @@ Date due: <<issues.date_due>><br />
 <p>Notes:
 <pre><<reserves.reservenotes>></pre>
 </p>', 1)");
+    $dbh->do("INSERT INTO `letter` (module, code, name, title, content, is_html)
+              VALUES ('circulation','TRANSFERSLIP','Transfer Slip','Transfer Slip', '<h5>Date: <<today>></h5>
+<h3>Transfer to <<branches.branchname>></h3>
+
+<h3>ITEM</h3>
+<h4><<biblio.title>></h4>
+<h5><<biblio.author>></h5>
+<ul>
+   <li><<items.barcode>></li>
+   <li><<items.itemcallnumber>></li>
+</ul>', 1)");
 
     $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('NoticeCSS','','Notices CSS url.',NULL,'free')");
     $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('SlipCSS','','Slips CSS url.',NULL,'free')");
 
     $dbh->do("UPDATE `letter` SET content = replace(content, '<<title>>', '<<biblio.title>>') WHERE code = 'HOLDPLACED'");
 
-    print "Upgrade to $DBversion done (Add branchcode and is_html to letter table; Default ISSUESLIP and RESERVESLIP letters; Add NoticeCSS and SlipCSS sysprefs)\n";
+    print "Upgrade to $DBversion done (Add branchcode and is_html to letter table; Default ISSUESLIP, RESERVESLIP and TRANSFERSLIP letters; Add NoticeCSS and SlipCSS sysprefs)\n";
     SetVersion($DBversion);
 }
 
-- 
1.6.5



More information about the Koha-patches mailing list