--- a/C4/Utils/DataTables/Members.pm
+++ a/C4/Utils/DataTables/Members.pm
@@ -37,7 +37,7 @@ sub search {
borrowers.address2, borrowers.city, borrowers.state, borrowers.zipcode,
borrowers.country, cardnumber, borrowers.dateexpiry,
borrowers.borrowernotes, borrowers.branchcode, borrowers.email,
- borrowers.userid,
+ borrowers.userid, borrowers.dateofbirth,
categories.description AS category_description, categories.category_type,
branches.branchname";
my $from = "FROM borrowers
--- a/Koha/Template/Plugin/To.pm
+++ a/Koha/Template/Plugin/To.pm
@@ -0,0 +1,33 @@
+package Koha::Template::Plugin::To;
+
+# This file is part of Koha.
+#
+# Copyright BibLibre 2014
+#
+# 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, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+use Modern::Perl;
+
+use base qw( Template::Plugin );
+
+use JSON qw( to_json );
+
+sub json {
+ my ( $self, $value ) = @_;
+
+ my $json = JSON->new->allow_nonref(1);
+ return $json->encode( $value );
+}
+
+1;
--- a/acqui/add_user_search.pl
+++ a/acqui/add_user_search.pl
@@ -52,5 +52,8 @@ my $search_patrons_with_acq_perm_only =
$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 => 'add',
);
output_html_with_http_headers( $input, $cookie, $template->output );
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/tables/members_results.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/tables/members_results.tt
@@ -14,7 +14,7 @@
"dt_category":
"[% data.category_description |html %] ([% data.category_type |html %])",
"dt_action":
- "Add"
+ "Select"
}[% UNLESS loop.last %],[% END %]
[% END %]
]
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudget_user_search.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudget_user_search.tt
@@ -22,12 +22,12 @@
//'
- + firstname + ' ' + surname + '';
+ + borrowername + '';
$('#budget_owner_name').html(ownerlink);
$('#budget_owner_id').val(borrowernumber);
}
@@ -47,12 +47,12 @@ var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget")
edit_owner(0);
}
- function add_user(borrowernumber, surname, firstname) {
+ function add_user(borrowernumber, borrowername) {
var ids = $("#budget_users_id").val().split(':');
if(borrowernumber && ids.indexOf(borrowernumber) == -1) {
var li = '
'
+ '' + firstname + ' ' + surname
+ + borrowernumber + '">' + borrowername
+ ' [Remove]';
$(li).insertBefore("li#add_user_button");
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt
@@ -35,7 +35,7 @@ $(document).ready(function(){
},
{
'name': 'template_path',
- 'value': 'acqui/tables/members_results.tt',
+ 'value': '[% json_template %]',
}
[% IF patrons_with_acq_perm_only %]
,{
@@ -55,11 +55,14 @@ $(document).ready(function(){
});
},
'aoColumns':[
- { 'mDataProp': 'dt_cardnumber' },
- { 'mDataProp': 'dt_name' },
- { 'mDataProp': 'dt_branch' },
- { 'mDataProp': 'dt_category' },
- { 'mDataProp': 'dt_action', 'bSortable': false }
+ [% FOR column IN columns %]
+ [% IF column == 'action' %]
+ { 'mDataProp': 'dt_action', 'bSortable': false }
+ [% ELSE %]
+ { 'mDataProp': 'dt_[% column %]' }
+ [% END %]
+ [% UNLESS loop.last %],[% END %]
+ [% END %]
],
'bAutoWidth': false,
[% IF patrons_with_acq_perm_only %]
@@ -97,19 +100,27 @@ function filter() {
}
// modify parent window owner element
- function add_user(borrowernumber, borrowername) {
- var p = window.opener;
- $("#info").hide();
- $("#error").hide();
- if ( p.add_user(borrowernumber, borrowername) < 0 ) {
- $("#error").html(_("Borrower '%s' is already in the list.").format(borrowername));
- $("#error").show();
- } else {
- $("#info").html(_("Borrower '%s' added.").format(borrowername));
- $("#info").show();
-
+ [% IF selection_type == 'add' %]
+ [%# Note that add_user could sent data instead of borrowername too %]
+ function add_user(borrowernumber, borrowername) {
+ var p = window.opener;
+ $("#info").hide();
+ $("#error").hide();
+ if ( p.add_user(borrowernumber, borrowername) < 0 ) {
+ $("#error").html(_("Borrower '%s' is already in the list.").format(borrowername));
+ $("#error").show();
+ } else {
+ $("#info").html(_("Borrower '%s' added.").format(borrowername));
+ $("#info").show();
+ }
}
- }
+ [% ELSIF selection_type == 'select' %]
+ function select_user(borrowernumber, data) {
+ var p = window.opener;
+ p.select_user(borrowernumber, data);
+ window.close();
+ }
+ [% END %]
//]]>
@@ -135,11 +146,17 @@ function filter() {
- Card |
- Name |
- Library |
- Category |
- |
+ [% FOR column IN columns %]
+ [% SWITCH column %]
+ [% CASE 'cardnumber' %]Card |
+ [% CASE 'dateofbirth' %]Date of birth |
+ [% CASE 'address' %]Address |
+ [% CASE 'name' %]Name |
+ [% CASE 'branch' %]Library |
+ [% CASE 'category' %]Category |
+ [% CASE 'action' %] |
+ [% END %]
+ [% END %]
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt
@@ -100,6 +100,43 @@
$(mytables).find(" li[data-category_code='']").show();
}
+ function select_user(borrowernumber, borrower) {
+ var form = $('#entryform').get(0);
+ if (form.guarantorid.value) {
+ $("#contact-details").find('a').remove();
+ $("#contactname, #contactfirstname").parent().find('span').remove();
+ }
+
+ var id = borrower.borrowernumber;
+ form.guarantorid.value = id;
+ $('#contact-details')
+ .show()
+ .find('span')
+ .after('' + id + '');
+
+ $(form.contactname)
+ .val(borrower.surname)
+ .before('' + borrower.surname + '').get(0).type = 'hidden';
+ $(form.contactfirstname)
+ .val(borrower.firstname)
+ .before('' + borrower.firstname + '').get(0).type = 'hidden';
+
+ form.streetnumber.value = borrower.streetnumber;
+ form.address.value = borrower.address;
+ form.address2.value = borrower.address2;
+ form.city.value = borrower.city;
+ form.state.value = borrower.state;
+ form.zipcode.value = borrower.zipcode;
+ form.country.value = borrower.country;
+ form.branchcode.value = borrower.branchcode;
+
+ form.guarantorsearch.value = 'Change';
+
+ return 0;
+ }
+
+
+
var MSG_SEPARATOR = _("Separator must be / in field %s");
var MSG_INCORRECT_DAY = _("Invalid day entered in field %s");
var MSG_INCORRECT_MONTH = _("Invalid month entered in field %s");
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/tables/guarantor_search.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/tables/guarantor_search.tt
@@ -0,0 +1,21 @@
+[% USE To %]
+[% USE KohaDates %]
+{
+ "sEcho": [% sEcho %],
+ "iTotalRecords": [% iTotalRecords %],
+ "iTotalDisplayRecords": [% iTotalDisplayRecords %],
+ "aaData": [
+ [% FOREACH data IN aaData %]
+ {
+ "dt_cardnumber":
+ "[% data.cardnumber %]",
+ "dt_dateofbirth":
+ "[% data.dateofbirth | $KohaDates %]",
+ "dt_address":
+ "[% data.streetnumber %] [% data.address | html %] [% data.address2 | html %] [% data.city | html %] [% data.state | html %] [% data.zipcode | html %] [% data.country | html %] [% data.branchcode %]",
+ "dt_action":
+ "Select"
+ }[% UNLESS loop.last %],[% END %]
+ [% END %]
+ ]
+}
--- a/members/guarantor_search.pl
+++ a/members/guarantor_search.pl
@@ -1,100 +1,51 @@
#!/usr/bin/perl
-# script to find a guarantor
-
-# Copyright 2006 OUEST PROVENCE
-#
# 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.
+# Copyright 2014 BibLibre
#
-# 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.
+# 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.
#
-# 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.
+# 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 .
use Modern::Perl;
use CGI qw ( -utf8 );
-
use C4::Auth;
use C4::Output;
-use C4::Dates qw/format_date/;
use C4::Members;
my $input = new CGI;
-my ( $template, $loggedinuser, $cookie );
-( $template, $loggedinuser, $cookie ) = get_template_and_user(
- {
- template_name => "members/guarantor_search.tt",
+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 => { borrowers => 1 },
- debug => 1,
}
);
-my $member = $input->param('member') // '';
-my $orderby = $input->param('orderby');
-my $category_type = $input->param('category_type');
-
-$orderby = "surname,firstname" unless $orderby;
-$member =~ s/,//g; #remove any commas from search string
-$member =~ s/\*/%/g;
-
-$template->param( results => $member );
+my $q = $input->param('q') || '';
+my $op = $input->param('op') || '';
-my $search_category = 'A';
-if ( $category_type eq 'P' ) {
- $search_category = 'I';
-}
-
-my ( $count, $results );
-my @resultsdata;
-
-if ( $member ne '' ) {
- $results =
- Search( { '' => $member, category_type => $search_category }, $orderby );
-
- $count = $results ? @$results : 0;
-
- for ( my $i = 0 ; $i < $count ; $i++ ) {
- my %row = (
- count => $i + 1,
- borrowernumber => $results->[$i]{'borrowernumber'},
- cardnumber => $results->[$i]{'cardnumber'},
- surname => $results->[$i]{'surname'},
- firstname => $results->[$i]{'firstname'},
- categorycode => $results->[$i]{'categorycode'},
- streetnumber => $results->[$i]{'streetnumber'},
- address => $results->[$i]{'address'},
- address2 => $results->[$i]{'address2'},
- city => $results->[$i]{'city'},
- state => $results->[$i]{'state'},
- zipcode => $results->[$i]{'zipcode'},
- country => $results->[$i]{'country'},
- branchcode => $results->[$i]{'branchcode'},
- dateofbirth => format_date( $results->[$i]{'dateofbirth'} ),
- borrowernotes => $results->[$i]{'borrowernotes'}
- );
-
- push( @resultsdata, \%row );
- }
-}
+my $referer = $input->referer();
$template->param(
- member => $member,
- numresults => $count,
- category_type => $category_type,
- resultsloop => \@resultsdata
+ view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
+ columns => ['cardnumber', 'dateofbirth', 'address', 'action' ],
+ json_template => 'members/tables/guarantor_search.tt',
+ selection_type => 'select',
);
-
-output_html_with_http_headers $input, $cookie, $template->output;
+output_html_with_http_headers( $input, $cookie, $template->output );
--