Bug 4330 : Fixing copyright and removing unconditional warn chris c mail 2010-12...
[koha.git] / members / moremember.pl
index 691ad1d..bb593c4 100755 (executable)
@@ -1,6 +1,7 @@
 #!/usr/bin/perl
 
 # Copyright 2000-2002 Katipo Communications
+# Copyright 2010 BibLibre
 #
 # This file is part of Koha.
 #
@@ -13,9 +14,9 @@
 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 #
-# You should have received a copy of the GNU General Public License along with
-# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
-# Suite 330, Boston, MA  02111-1307 USA
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 
 =head1 moremember.pl
@@ -32,6 +33,7 @@
 =cut
 
 use strict;
+#use warnings; FIXME - Bug 2505
 use CGI;
 use C4::Context;
 use C4::Auth;
@@ -48,6 +50,7 @@ use C4::Biblio;
 use C4::Reserves;
 use C4::Branch; # GetBranchName
 use C4::Form::MessagingPreferences;
+use C4::NewsChannels; #get slip news
 
 #use Smart::Comments;
 #use Data::Dumper;
@@ -75,10 +78,26 @@ for my $failedret (@failedreturns) { $return_failed{$failedret} = 1; }
 my $template_name;
 my $quickslip = 0;
 
-if    ($print eq "page") { $template_name = "members/moremember-print.tmpl";   }
-elsif ($print eq "slip") { $template_name = "members/moremember-receipt.tmpl"; }
-elsif ($print eq "qslip") { $template_name = "members/moremember-receipt.tmpl"; $quickslip = 1; }
-else {                     $template_name = "members/moremember.tmpl";         }
+my $flagsrequired;
+if ($print eq "page") {
+    $template_name = "members/moremember-print.tmpl";
+    $flagsrequired = { borrowers => 1 };
+} elsif ($print eq "slip") {
+    $template_name = "members/moremember-receipt.tmpl";
+    # circ staff who process checkouts but can't edit
+    # patrons still need to be able to print receipts
+    $flagsrequired =  { circulate => "circulate_remaining_permissions" };
+} elsif ($print eq "qslip") {
+    $template_name = "members/moremember-receipt.tmpl";
+    $quickslip = 1;
+    $flagsrequired =  { circulate => "circulate_remaining_permissions" };
+} elsif ($print eq "brief") {
+    $template_name = "members/moremember-brief.tmpl";
+    $flagsrequired = { borrowers => 1 };
+} else {
+    $template_name = "members/moremember.tmpl";
+    $flagsrequired = { borrowers => 1 };
+}
 
 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     {
@@ -86,7 +105,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
         query           => $input,
         type            => "intranet",
         authnotrequired => 0,
-        flagsrequired   => { borrowers => 1 },
+        flagsrequired   => $flagsrequired,
         debug           => 1,
     }
 );
@@ -137,7 +156,7 @@ $data->{ "sex_".$data->{'sex'}."_p" } = 1;
 
 my $catcode;
 if ( $category_type eq 'C') {
-       if ($data->{'guarantorid'} ne '0' ) {
+       if ($data->{guarantorid} ) {
        my $data2 = GetMember( 'borrowernumber' => $data->{'guarantorid'} );
        foreach (qw(address city B_address B_city phone mobile zipcode country B_country)) {
            $data->{$_} = $data2->{$_};
@@ -154,7 +173,7 @@ if ( $category_type eq 'C') {
 if ( $data->{'ethnicity'} || $data->{'ethnotes'} ) {
     $template->param( printethnicityline => 1 );
 }
-if ( $category_type eq 'A' ) {
+if ( $category_type eq 'A' || $category_type eq 'I') {
     $template->param( isguarantee => 1 );
 
     # FIXME
@@ -174,7 +193,7 @@ if ( $category_type eq 'A' ) {
         );
     }
     $template->param( guaranteeloop => \@guaranteedata );
-    ( $template->param( adultborrower => 1 ) ) if ( $category_type eq 'A' );
+    ( $template->param( adultborrower => 1 ) ) if ( $category_type eq 'A' || $category_type eq 'I' );
 }
 else {
     if ($data->{'guarantorid'}){
@@ -204,8 +223,7 @@ if ( C4::Context->preference("IndependantBranches") ) {
     $samebranch = 1;
 }
 my $branchdetail = GetBranchDetail( $data->{'branchcode'});
-$data->{'branchname'} = $branchdetail->{branchname};
-
+@{$data}{keys %$branchdetail} = values %$branchdetail; # merge in all branch columns
 
 my ( $total, $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber );
 my $lib1 = &GetSortDetails( "Bsort1", $data->{'sort1'} );
@@ -213,6 +231,12 @@ my $lib2 = &GetSortDetails( "Bsort2", $data->{'sort2'} );
 $template->param( lib1 => $lib1 ) if ($lib1);
 $template->param( lib2 => $lib2 ) if ($lib2);
 
+# Show OPAC privacy preference is system preference is set
+if ( C4::Context->preference('OPACPrivacy') ) {
+    $template->param( OPACPrivacy => 1);
+    $template->param( "privacy".$data->{'privacy'} => 1);
+}
+
 # current issues
 #
 my $issue = GetPendingIssues($borrowernumber);
@@ -409,6 +433,7 @@ $template->param(
     categoryname    => $data->{'description'},
     reregistration  => $reregistration,
     branch          => $branch,
+    todaysdate      => C4::Dates->today(),
     totalprice      => sprintf("%.2f", $totalprice),
     totaldue        => sprintf("%.2f", $total),
     totaldue_raw    => $total,
@@ -426,4 +451,13 @@ $template->param(
     quickslip            => $quickslip,
 );
 
+#Get the slip news items
+my $all_koha_news   = &GetNewsToDisplay("slip");
+my $koha_news_count = scalar @$all_koha_news;
+
+$template->param(
+    koha_news       => $all_koha_news,
+    koha_news_count => $koha_news_count
+);
+
 output_html_with_http_headers $input, $cookie, $template->output;