From 670a262504ae2d2496e0c762a7c84e7d6e9df1e8 Mon Sep 17 00:00:00 2001 From: Srdjan Jankovic Date: Thu, 17 Mar 2011 22:18:17 -0400 Subject: [PATCH] Bug 5928 :wr77152 : AllowPurchaseSuggestionBranchChoice sys pref Signed-off-by: Nicole C. Engard Signed-off-by: Chris Cormack --- admin/systempreferences.pl | 1 + installer/data/mysql/en/mandatory/sysprefs.sql | 2 ++ installer/data/mysql/updatedatabase.pl | 8 ++++++++ .../prog/en/modules/admin/preferences/opac.pref | 13 +++++++++++++ .../prog/en/modules/opac-suggestions.tmpl | 13 +++++++++++++ opac/opac-suggestions.pl | 15 ++++++++++++++- 6 files changed, 51 insertions(+), 1 deletion(-) diff --git a/admin/systempreferences.pl b/admin/systempreferences.pl index b33c7ece4c..4e72229697 100755 --- a/admin/systempreferences.pl +++ b/admin/systempreferences.pl @@ -380,6 +380,7 @@ $tabsysprefs{OPACGroupResults} = "OPAC"; $tabsysprefs{XSLTDetailsDisplay} = "OPAC"; $tabsysprefs{XSLTResultsDisplay} = "OPAC"; $tabsysprefs{OPACShowCheckoutName} = "OPAC"; +$tabsysprefs{AllowPurchaseSuggestionBranchChoice} = "OPAC"; # Serials $tabsysprefs{RoutingListAddReserves} = "Serials"; diff --git a/installer/data/mysql/en/mandatory/sysprefs.sql b/installer/data/mysql/en/mandatory/sysprefs.sql index 98e9b36de8..282764735f 100644 --- a/installer/data/mysql/en/mandatory/sysprefs.sql +++ b/installer/data/mysql/en/mandatory/sysprefs.sql @@ -294,3 +294,5 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OPACAllowUserToChooseBranch', 1, 'Allow the user to choose the branch they want to pickup their hold from','1','YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('displayFacetCount', '0', NULL, NULL, 'YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('maxRecordsForFacets', '20', NULL, NULL, 'Integer'); +INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('AllowPurchaseSuggestionBranchChoice', 0, 'Allow user to choose branch when making a purchase suggestion','1','YesNo'); + diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 084fad46b9..eb3b13f796 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -4106,6 +4106,14 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { } +$DBversion = "3.03.00.XXX"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('AllowPurchaseSuggestionBranchChoice', 0, 'Allow user to choose branch when making a purchase suggestion','1','YesNo')"); + print "Upgrade to $DBversion done (Add syspref to control if user can choose branch when making purchase suggestion)\n"; + SetVersion ($DBversion); +} + + =head1 FUNCTIONS =head2 DropAllForeignKeys($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index 3014e6313d..ac3206a3ed 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -274,6 +274,19 @@ OPAC: yes: Show no: "Don't show" - purchase suggestions from other patrons on the OPAC. + - + - pref: AllowPurchaseSuggestionBranchChoice + default: 0 + choices: + no: "Don't allow" + yes: Allow + - patrons to select branch when making a purchase suggestion + - + - pref: SearchMyLibraryFirst + choices: + yes: Limit + no: "Don't limit" + - "patrons' searches to the library they are registered at." Privacy: - - pref: AnonSuggestions diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-suggestions.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-suggestions.tmpl index ab1e811f53..6783bb3844 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-suggestions.tmpl +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-suggestions.tmpl @@ -91,6 +91,19 @@ $.tablesorter.addParser({ + +
  • + +
  • +
  • diff --git a/opac/opac-suggestions.pl b/opac/opac-suggestions.pl index 2f0dc36886..15eebf9144 100755 --- a/opac/opac-suggestions.pl +++ b/opac/opac-suggestions.pl @@ -20,6 +20,7 @@ use warnings; use CGI; use C4::Auth; # get_template_and_user +use C4::Members; use C4::Branch; use C4::Koha; use C4::Output; @@ -77,7 +78,7 @@ if ( $op eq "add_confirm" ) { } else { $$suggestion{'suggesteddate'}=C4::Dates->today; - $$suggestion{'branchcode'}=C4::Context->userenv->{"branch"}; + $$suggestion{'branchcode'}= $input->param('branch') || C4::Context->userenv->{"branch"}; &NewSuggestion($suggestion); # empty fields, to avoid filter in "SearchSuggestion" $$suggestion{$_}='' foreach qw; @@ -122,6 +123,18 @@ foreach my $suggestion(@$suggestions_loop) { my $patron_reason_loop = GetAuthorisedValues("OPAC_SUG"); +# Is the person allowed to choose their branch +if ( C4::Context->preference("AllowPurchaseSuggestionBranchChoice") ) { + my ( $borr ) = GetMemberDetails( $borrowernumber ); + +# pass the pickup branch along.... + my $branch = $input->param('branch') || $borr->{'branchcode'} || C4::Context->userenv->{branch} || '' ; + +# make branch selection options... + my $CGIbranchloop = GetBranchesLoop($branch); + $template->param( branch_loop => $CGIbranchloop ); +} + $template->param( %$suggestion, itemtypeloop=> $supportlist, -- 2.39.5