Lines 34-45
sub search {
Link Here
|
34 |
my $dbh = C4::Context->dbh; |
34 |
my $dbh = C4::Context->dbh; |
35 |
my @columns = qw( borrowernumber surname firstname streetnumber streettype address address2 city state zipcode country cardnumber dateexpiry borrowernotes branchcode email userid dateofbirth categorycode ); |
35 |
my @columns = qw( borrowernumber surname firstname streetnumber streettype address address2 city state zipcode country cardnumber dateexpiry borrowernotes branchcode email userid dateofbirth categorycode ); |
36 |
if( my @guarantor_attributes = @{ get_guarantor_shared_attributes() }){ |
36 |
if( my @guarantor_attributes = @{ get_guarantor_shared_attributes() }){ |
37 |
my %seen = (); |
37 |
foreach my $item (@guarantor_attributes) { |
38 |
@columns = grep { ! $seen{ $_ }++ } ( @columns, @guarantor_attributes ); |
38 |
if (! grep {$_ eq $item} @columns) { |
|
|
39 |
push @columns, $item; |
40 |
} |
41 |
} |
39 |
}; |
42 |
}; |
40 |
$_ = "borrowers.".$dbh->quote_identifier($_) for (@columns); |
43 |
my $borrowers_columns = ""; |
|
|
44 |
foreach my $item (@columns) { |
45 |
$borrowers_columns .= "borrowers." . $item . ", "; |
46 |
} |
41 |
|
47 |
|
42 |
my $select = "SELECT ${ \join(',', @columns) }, |
48 |
my $select = "SELECT " . $borrowers_columns . " |
43 |
categories.description AS category_description, categories.category_type, |
49 |
categories.description AS category_description, categories.category_type, |
44 |
branches.branchname"; |
50 |
branches.branchname"; |
45 |
my $from = "FROM borrowers |
51 |
my $from = "FROM borrowers |