From 2d8a039a31dca76666a90f19c3e9baf479d4cb29 Mon Sep 17 00:00:00 2001 From: Srdjan Jankovic Date: Wed, 29 Feb 2012 14:04:50 +1300 Subject: [PATCH] bug_7001: Added TRANSFERSLIP to the letters --- 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: <>

Transfer to/Hold in <>

- -

<>, <>

    @@ -85,16 +83,26 @@ Date due: <>

ITEM ON HOLD

-

<>

-
<>
-
    -
  • <>
  • -
  • <>
  • -
  • <>
  • -
-

Notes: -

<>
-

-
-
', 1); +

<>

+
<>
+ +

Notes: +

<>
+

+', 1), +('circulation','TRANSFERSLIP','Transfer Slip','Transfer Slip', '
Date: <>
+ +

Transfer to <>

+ +

ITEM

+

<>

+
<>
+', 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: <>

Notes:

<>

', 1)"); + $dbh->do("INSERT INTO `letter` (module, code, name, title, content, is_html) + VALUES ('circulation','TRANSFERSLIP','Transfer Slip','Transfer Slip', '
Date: <>
+

Transfer to <>

+ +

ITEM

+

<>

+
<>
+
    +
  • <>
  • +
  • <>
  • +
', 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, '<>', '<<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