--- /dev/null
+#!/usr/bin/perl
+
+# This file is part of Koha.
+#
+# Copyright 2014 BibLibre
+#
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY 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, see <http://www.gnu.org/licenses>.
+
+use Modern::Perl;
+
+use CGI qw ( -utf8 );
+use C4::Auth;
+use C4::Output;
+use C4::Members;
+
+my $input = new CGI;
+
+my $dbh = C4::Context->dbh;
+
+my ( $template, $loggedinuser, $cookie, $staff_flags ) = get_template_and_user(
+ { template_name => "common/patron_search.tt",
+ query => $input,
+ type => "intranet",
+ authnotrequired => 0,
+ flagsrequired => { acquisition => 'budget_modify' },
+ }
+);
+
+my $q = $input->param('q') || '';
+my $op = $input->param('op') || '';
+my $selection_type = $input->param('selection_type') || 'add';
+
+my $referer = $input->referer();
+
+# If this script is called by acqui/basket.pl
+# the patrons to return should be superlibrarian or have the order_manage
+# acquisition flag.
+my $search_patrons_with_acq_perm_only =
+ ( $referer =~ m|admin/aqbudgets.pl| )
+ ? 1 : 0;
+
+$template->param(
+ patrons_with_acq_perm_only => $search_patrons_with_acq_perm_only,
+ view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
+ columns => ['cardnumber', 'name', 'branch', 'category', 'action'],
+ json_template => 'acqui/tables/members_results.tt',
+ selection_type => $selection_type,
+);
+output_html_with_http_headers( $input, $cookie, $template->output );
+++ /dev/null
-#!/usr/bin/perl
-
-# script to find owner and users for a budget
-
-# Copyright 2008-2009 BibLibre SARL
-#
-# This file is part of Koha.
-#
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
-#
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# 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.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-use Modern::Perl;
-
-use C4::Auth ;
-use C4::Output;
-use CGI qw ( -utf8 );
-use C4::Dates qw/format_date/;
-use C4::Members;
-
-my $input = new CGI;
-
-my $dbh = C4::Context->dbh;
-
-my ( $template, $loggedinuser, $cookie, $staff_flags ) = get_template_and_user(
- { template_name => "admin/aqbudget_user_search.tt",
- query => $input,
- type => "intranet",
- authnotrequired => 0,
- flagsrequired => { acquisition => 'budget_modify' },
- debug => 1,
- }
-);
-
-# only used if allowthemeoverride is set
-my $type = $input->param('type');
-my $member = $input->param('member') // '';
-
-$member =~ s/,//g; #remove any commas from search string
-$member =~ s/\*/%/g;
-if ( $member eq '' ) {
- $template->param( results => 0 );
-} else {
- $template->param( results => 1 );
-}
-
-my @resultsdata;
-
-if ( $member ) {
- my $results = Search($member, "surname");
-
- foreach my $res (@$results) {
- my $perms = haspermission( $res->{'userid'} );
- my $subperms = get_user_subpermissions( $res->{'userid'} );
-
- # if the member has 'acqui' permission set, then display to table.
- if ( $perms->{superlibrarian} == 1 ||
- $perms->{acquisition} == 1 ||
- exists $subperms->{acquisition} )
- {
- my %row = (
- borrowernumber => $res->{'borrowernumber'},
- cardnumber => $res->{'cardnumber'},
- surname => $res->{'surname'},
- firstname => $res->{'firstname'},
- categorycode => $res->{'categorycode'},
- branchcode => $res->{'branchcode'},
- );
- push( @resultsdata, \%row );
- }
- }
-}
-
-$template->param(
- type => $type,
- member => $member,
- resultsloop => \@resultsdata
-);
-
-output_html_with_http_headers $input, $cookie, $template->output;
+[% USE To %]
{
"sEcho": [% sEcho %],
"iTotalRecords": [% iTotalRecords %],
"dt_category":
"[% data.category_description |html %] ([% data.category_type |html %])",
"dt_action":
- "<a style='cursor:pointer' onclick='add_user(\"[% data.borrowernumber %]\", \"[% data.firstname %] [% data.surname %]\");'>Select</a>"
+ [%- IF selection_type == 'select' -%]
+ "<a style='cursor:pointer' onclick='select_user(\"[% data.borrowernumber %]\", [% To.json(data) | html %] );'>Select</a>"
+ [%- ELSE -%]
+ "<a style='cursor:pointer' onclick='add_user(\"[% data.borrowernumber %]\", \"[% data.firstname %] [% data.surname %]\");'>Select</a>"
+ [%- END -%]
}[% UNLESS loop.last %],[% END %]
[% END %]
]
+++ /dev/null
-[% INCLUDE 'doc-head-open.inc' %]
-<title>Koha › Budget
- [% IF (type == 'owner') %]
- owner
- [% ELSE %]
- user
- [% END %]
- search
-</title>
-[% INCLUDE 'doc-head-close.inc' %]
- <style type="text/css">
- #custom-doc {
- width:44.46em;
- *width:43.39em;
- min-width:578px;
- margin:auto;
- text-align:left;
- }
- </style>
-
- <script type="text/javascript">
- //<![CDATA[
-
- // modify parent window owner element
- function add_user(borrowernumber, borrowername) {
- [% IF (type == 'owner') %]
- top.opener.edit_owner(borrowernumber, borrowername);
- window.close();
- [% ELSE %]
- var ret = top.opener.add_user(borrowernumber, borrowername);
- if (ret != 0) {
- alert(_("This user is already in the list."));
- }
- [% END %]
- }
-
- //]]>
- </script>
-</head>
-
-<body id="admin_aqbudget_owner_search" class="admin">
-<div id="custom-doc" class="yui-t7">
-<div id="bd">
-<div class="yui-g">
-
-<h3>Search for budget
- [% IF (type == 'owner') %]
- owner
- [% ELSE %]
- user
- [% END %]
-</h3>
-<form action="/cgi-bin/koha/admin/aqbudget_user_search.pl" method="post">
- <fieldset>
- <input type="text" name="member" id="member" value="[% member %]"
- class="focus" />
-
- <input type="hidden" name="type" value="[% type %]" />
- <input type="submit" class="button" value="Search" />
- </fieldset>
-
- <div class="hint">
- Only staff with superlibrarian or acquisitions permissions are returned
- in the search results.
- </div>
-</form>
-
-
-[% IF ( results ) %]
- <p>Searched for <span class="ex">[% member %]</span>,
- [% resultsloop.size || 0 %] patron(s) found:</p>
-
- <table>
- <thead>
- <tr>
- <th>Cardnumber</th>
- <th>Name</th>
- <th>Library</th>
- <th>Categorycode</th>
- <th>Select?</th>
- </tr>
- </thead>
-
- <tbody>
- [% FOREACH result IN resultsloop %]
- <tr>
- <td>[% result.cardnumber %]</td>
- <td>[% result.surname %], [% result.firstname %]</td>
- <td>[% result.branchcode %]</td>
- <td>[% result.categorycode %]</td>
- <td>
- <a style="cursor:pointer"
- onclick="add_user(
- '[% result.borrowernumber %]',
- '[% result.surname %]',
- '[% result.firstname %]'
- );"
- />Select</a>
- </td>
- </tr>
- [% END %]
- </tbody>
- </table>
-[% END %]
-
-<div id="closewindow">
- <a href="#" class="close">Close</a>
-</div>
-</div>
-</div>
-[% INCLUDE 'intranet-bottom.inc' %]
//<![CDATA[
function userPopup() {
- window.open("/cgi-bin/koha/admin/aqbudget_user_search.pl?type=user",
+ window.open("/cgi-bin/koha/admin/add_user_search.pl?selection_type=add",
'PatronPopup',
'width=740,height=450,location=yes,toolbar=no,'
+ 'scrollbars=yes,resize=yes'
}
function ownerPopup() {
- window.open("/cgi-bin/koha/admin/aqbudget_user_search.pl?type=owner",
+ window.open("/cgi-bin/koha/admin/add_user_search.pl?selection_type=select",
'PatronPopup',
'width=740,height=450,location=yes,toolbar=no,'
+ 'scrollbars=yes,resize=yes'
);
}
- function edit_owner(borrowernumber, borrowername) {
- $('#budget_owner_name').empty();
- $('#budget_owner_id').val('');
+ function select_user(borrowernumber, borrower) {
+ ownerRemove();
+ var borrowername = borrower.firstname + ' ' + borrower.surname
if (borrowernumber) {
var ownerlink = '<a href="/cgi-bin/koha/members/moremember.pl'
+ '?borrowernumber=' + borrowernumber + '">'
}
function ownerRemove() {
- edit_owner(0);
+ $('#budget_owner_name').empty();
+ $('#budget_owner_id').val('');
}
function add_user(borrowernumber, borrowername) {
<input type="hidden" name="budget_owner_id" id="budget_owner_id"
value="[% budget_owner_id %]" />
- <!-- FIXME: hardcoded button positions :/ -->
<input type="button" id="edit_owner" value="Edit owner"
onclick="ownerPopup(); return false;" />
<input type="button" id="remove_owner" value="Remove owner"
},{
'name': 'template_path',
'value': '[% json_template %]',
+ },{
+ 'name': 'selection_type',
+ 'value': '[% selection_type %]',
}
[% IF patrons_with_acq_perm_only %]
,{
my $searchtype = $input->param('searchtype');
my $searchfieldstype = $input->param('searchfieldstype') || 'standard';
my $has_permission = $input->param('has_permission');
+my $selection_type = $input->param('selection_type');
if ( $searchfieldstype eq "dateofbirth" ) {
$searchmember = output_pref({dt => dt_from_string($searchmember), dateformat => 'iso', dateonly => 1});
sEcho => $sEcho,
iTotalRecords => $results->{iTotalRecords},
iTotalDisplayRecords => $results->{iTotalDisplayRecords},
- aaData => $results->{patrons}
+ aaData => $results->{patrons},
+ selection_type => $selection_type,
);
output_with_http_headers $input, $cookie, $template->output, 'json';