#'
@ISA = qw(Exporter);
-@EXPORT = qw();
@EXPORT = qw(
- &BornameSearch &getmember &borrdata &borrdata2 &fixup_cardnumber &findguarantees &findguarantor &GuarantornameSearch &NewBorrowerNumber &modmember &newmember &changepassword &borrissues &allissues
- &checkuniquemember &getzipnamecity &getidcity &getguarantordata &getcategorytype
- &calcexpirydate &checkuserpassword
- &getboracctrecord
- &borrowercategories &getborrowercategory
- &fixEthnicity
- ðnicitycategories get_institutions add_member_orgs
- &get_age
+&allissues
+&borrdata
+&borrdata2
+&BornameSearch
+&borrissues
+&borrowercategories
+
+&changepassword
+&checkuniquemember
+&calcexpirydate
+&checkuserpassword
+ðnicitycategories get_institutions add_member_orgs
+&fixEthnicity
+&fixup_cardnumber
+&findguarantees
+&findguarantor
+
+
+
+&getmember
+&getzipnamecity
+&getidcity
+&getguarantordata
+&getcategorytype
+&getboracctrecord
+&getborrowercategory
+&get_age
+&GetBorrowersFromSurname
+&GetBranchCodeFromBorrowers
+&GetFlagsAndBranchFromBorrower
+&GuarantornameSearch
+
+&NewBorrowerNumber
+&modmember
+&newmember
);
=cut
+=head3 GetFlagsAndBranchFromBorrower
+
+=over 4
+
+($flags, $homebranch) = GetFlagsAndBranchFromBorrower($loggedinuser);
+
+this function read on the database to get flags and homebranch for a user
+given on input arg.
+
+return :
+it returns the $flags & the homebranch in scalar context.
+
+=back
+
+=cut
+
+sub GetFlagsAndBranchFromBorrower {
+ my $loggedinuser = @_;
+ my $dbh = C4::Context->dbh;
+ my $query = "
+ SELECT flags, branchcode
+ FROM borrowers
+ WHERE borrowernumber = ?
+ ";
+ my $sth = $dbh->prepare($query);
+ $sth->execute($loggedinuser);
+
+ return $sth->fetchrow;
+}
+
+
#'
sub getmember {
my ( $cardnumber, $bornum ) = @_;
$data{'dateofbirth'}=format_date_in_iso($data{'dateofbirth'});
$data{'dateexpiry'}=format_date_in_iso($data{'dateexpiry'});
$data{'dateenrolled'}=format_date_in_iso($data{'dateenrolled'});
- warn "la date:".$data{dateenrolled};
+# warn "num user".$data{'borrowernumber'};
my $query;
my $sth;
$data{'userid'}='' if ($data{'password'}eq '');
# is adult check guarantees;
updateguarantees(%data);
- }
+ }
-
}
$data{'dateofbirth'} = format_date_in_iso( $data{'dateofbirth'} );
$data{'dateenrolled'} = format_date_in_iso( $data{'dateenrolled'} );
$data{'dateexpiry'} = format_date_in_iso( $data{'dateexpiry'} );
- my $query =
+ my $query =
"insert into borrowers set cardnumber="
. $dbh->quote( $data{'cardnumber'} )
. ",surname="
. $dbh->quote( $data{'dateexpiry'} )
. ",contactnote="
. $dbh->quote( $data{'contactnote'} )
- . ",b_address="
- . $dbh->quote( $data{'b_address'} )
- . ",b_zipcode="
- . $dbh->quote( $data{'b_zipcode'} )
- . ",b_city="
- . $dbh->quote( $data{'b_city'} )
- . ",b_phone="
- . $dbh->quote( $data{'b_phone'} )
- . ",b_email="
- . $dbh->quote( $data{'b_email'}, )
+ . ",B_address="
+ . $dbh->quote( $data{'B_address'} )
+ . ",B_zipcode="
+ . $dbh->quote( $data{'B_zipcode'} )
+ . ",B_city="
+ . $dbh->quote( $data{'B_city'} )
+ . ",B_phone="
+ . $dbh->quote( $data{'B_phone'} )
+ . ",B_email="
+ . $dbh->quote( $data{'B_email'}, )
. ",password="
. $dbh->quote( $data{'password'} )
. ",userid="
. $dbh->quote( $data{'flags'} )
. ",relationship="
. $dbh->quote( $data{'relationship'} )
- . ",b_streetnumber="
- . $dbh->quote( $data{'b_streetnumber'})
- . ",b_streettype="
- . $dbh->quote( $data{'b_streettype'})
+ . ",B_streetnumber="
+ . $dbh->quote( $data{'B_streetnumber'})
+ . ",B_streettype="
+ . $dbh->quote( $data{'B_streettype'})
. ",gonenoaddress="
. $dbh->quote( $data{'gonenoaddress'})
. ",lost="
my $sth = $dbh->prepare($query);
$sth->execute;
$sth->finish;
- $data{'borrowerid'} = $dbh->{'mysql_insertid'};
- return $data{'borrowerid'};
+ $data{'borrowernumber'} = $dbh->{'mysql_insertid'};
+ return $data{'borrowernumber'};
}
sub changepassword {
#FIXME: sanity-check order and limit
my $dbh = C4::Context->dbh;
+ my $count=0;
my $query = "Select * from issues,biblio,items,biblioitems
where borrowernumber=? and
items.biblioitemnumber=biblioitems.biblioitemnumber and
while ( my $data = $sth->fetchrow_hashref ) {
$result[$i] = $data;
$i++;
+ $count++;
+ }
+
+ # get all issued items for bornum from oldissues table
+ # large chunk of older issues data put into table oldissues
+ # to speed up db calls for issuing items
+ if(C4::Context->preference("ReadingHistory")){
+ my $query2="SELECT * FROM oldissues,biblio,items,biblioitems
+ WHERE borrowernumber=?
+ AND items.biblioitemnumber=biblioitems.biblioitemnumber
+ AND items.itemnumber=oldissues.itemnumber
+ AND items.biblionumber=biblio.biblionumber
+ ORDER BY $order";
+ if ($limit !=0){
+ $limit=$limit-$count;
+ $query2.=" limit $limit";
+ }
+
+ my $sth2=$dbh->prepare($query2);
+ $sth2->execute($bornum);
+
+ while (my $data2=$sth2->fetchrow_hashref){
+ $result[$i]=$data2;
+ $i++;
+ }
+ $sth2->finish;
}
$sth->finish;
+
return ( $i, \@result );
}
my $dbh = C4::Context->dbh;
my $sth =
$dbh->prepare(
-"Select title,firstname,surname,streetnumber,address,streettype,address2,zipcode,city,phone,phonepro,mobile,email,emailpro from borrowers where borrowernumber =? "
+"Select title,firstname,surname,streetnumber,address,streettype,address2,zipcode,city,phone,phonepro,mobile,email,emailpro,fax from borrowers where borrowernumber =? "
);
$sth->execute($borrowerid);
my $guarantor_data = $sth->fetchrow_hashref;
=cut
sub checkuserpassword {
- my ( $borrowerid, $userid, $password ) = @_;
+ my ( $borrowernumber, $userid, $password ) = @_;
$password = md5_base64($password);
my $dbh = C4::Context->dbh;
my $sth =
$dbh->prepare(
"Select count(*) from borrowers where borrowernumber !=? and userid =? and password=? "
);
- $sth->execute( $borrowerid, $userid, $password );
+ $sth->execute( $borrowernumber, $userid, $password );
my $number_rows = $sth->fetchrow;
return $number_rows;
=head2 getborrowercategory
- $description = &getborrowercategory($categorycode);
+ $description,$dateofbirthrequired,$upperagelimit,$category_type = &getborrowercategory($categorycode);
Given the borrower's category code, the function returns the corresponding
-description for a comprehensive information display.
+description , dateofbirthrequired , upperagelimit and category type for a comprehensive information display.
=cut
my $dbh = C4::Context->dbh;
my $sth =
$dbh->prepare(
- "SELECT description FROM categories WHERE categorycode = ?");
+ "SELECT description,dateofbirthrequired,upperagelimit,category_type FROM categories WHERE categorycode = ?");
$sth->execute($catcode);
- my $description = $sth->fetchrow();
+ my ($description,$dateofbirthrequired,$upperagelimit,$category_type) = $sth->fetchrow();
$sth->finish();
- return $description;
+ return ($description,$dateofbirthrequired,$upperagelimit,$category_type);
} # sub getborrowercategory
+
+
=head2 ethnicitycategories
($codes_arrayref, $labels_hashref) = ðnicitycategories();
$sth->finish();
} # sub add_member_orgs
+
+=head2 GetBorrowersFromSurname
+
+=over 4
+
+\@resutlts = GetBorrowersFromSurname($surname)
+this function get the list of borrower names like $surname.
+return :
+the table of results in @results
+
+=back
+
+=cut
+sub GetBorrowersFromSurname {
+ my ($searchstring)=@_;
+ my $dbh = C4::Context->dbh;
+ $searchstring=~ s/\'/\\\'/g;
+ my @data=split(' ',$searchstring);
+ my $count=@data;
+ my $query = qq|
+ SELECT surname,firstname
+ FROM borrowers
+ WHERE (surname like ?)
+ ORDER BY surname
+ |;
+ my $sth=$dbh->prepare($query);
+ $sth->execute("$data[0]%");
+ my @results;
+ my $count = 0;
+ while (my $data=$sth->fetchrow_hashref){
+ push(@results,$data);
+ $count++;
+ }
+ $sth->finish;
+ return ($count,\@results);
+}
+
+END { } # module clean-up code here (global destructor)
+
1;