View | Details | Raw Unified | Return to bug 5749
Collapse All | Expand All

(-)a/C4/Members.pm (-33 / +32 lines)
Lines 42-67 BEGIN { Link Here
42
	#Get data
42
	#Get data
43
	push @EXPORT, qw(
43
	push @EXPORT, qw(
44
		&Search
44
		&Search
45
		&SearchMember 
45
		&SearchMember
46
		&GetMemberDetails
46
		&GetMemberDetails
47
		&GetMember
47
		&GetMember
48
48
49
		&GetGuarantees 
49
		&GetGuarantees
50
50
51
		&GetMemberIssuesAndFines
51
		&GetMemberIssuesAndFines
52
		&GetPendingIssues
52
		&GetPendingIssues
53
		&GetAllIssues
53
		&GetAllIssues
54
54
55
		&get_institutions 
55
		&get_institutions
56
		&getzipnamecity 
56
		&getzipnamecity
57
		&getidcity
57
		&getidcity
58
58
59
                &GetFirstValidEmailAddress
59
                &GetFirstValidEmailAddress
60
60
61
		&GetAge 
61
		&GetAge
62
		&GetCities 
62
		&GetCities
63
		&GetRoadTypes 
63
		&GetRoadTypes
64
		&GetRoadTypeDetails 
64
		&GetRoadTypeDetails
65
		&GetSortDetails
65
		&GetSortDetails
66
		&GetTitles
66
		&GetTitles
67
67
Lines 73-79 BEGIN { Link Here
73
		&GetMemberAccountRecords
73
		&GetMemberAccountRecords
74
		&GetBorNotifyAcctRecord
74
		&GetBorNotifyAcctRecord
75
75
76
		&GetborCatFromCatType 
76
		&GetborCatFromCatType
77
		&GetBorrowercategory
77
		&GetBorrowercategory
78
    &GetBorrowercategoryList
78
    &GetBorrowercategoryList
79
79
Lines 176-182 sub SearchMember { Link Here
176
    my $count;
176
    my $count;
177
    my @data;
177
    my @data;
178
    my @bind = ();
178
    my @bind = ();
179
    
179
180
    # this is used by circulation everytime a new borrowers cardnumber is scanned
180
    # this is used by circulation everytime a new borrowers cardnumber is scanned
181
    # so we can check an exact match first, if that works return, otherwise do the rest
181
    # so we can check an exact match first, if that works return, otherwise do the rest
182
    $query = "SELECT * FROM borrowers
182
    $query = "SELECT * FROM borrowers
Lines 209-216 sub SearchMember { Link Here
209
        if (C4::Context->preference("IndependantBranches") && !$showallbranches){
209
        if (C4::Context->preference("IndependantBranches") && !$showallbranches){
210
          if (C4::Context->userenv && C4::Context->userenv->{flags} % 2 !=1 && C4::Context->userenv->{'branch'}){
210
          if (C4::Context->userenv && C4::Context->userenv->{flags} % 2 !=1 && C4::Context->userenv->{'branch'}){
211
            $query.=" borrowers.branchcode =".$dbh->quote(C4::Context->userenv->{'branch'})." AND " unless (C4::Context->userenv->{'branch'} eq "insecure");
211
            $query.=" borrowers.branchcode =".$dbh->quote(C4::Context->userenv->{'branch'})." AND " unless (C4::Context->userenv->{'branch'} eq "insecure");
212
          }      
212
          }
213
        }     
213
        }
214
        $query.="((surname LIKE ? OR surname LIKE ?
214
        $query.="((surname LIKE ? OR surname LIKE ?
215
                OR firstname  LIKE ? OR firstname LIKE ?
215
                OR firstname  LIKE ? OR firstname LIKE ?
216
                OR othernames LIKE ? OR othernames LIKE ?)
216
                OR othernames LIKE ? OR othernames LIKE ?)
Lines 746-755 sub AddMember { Link Here
746
    my $dbh = C4::Context->dbh;
746
    my $dbh = C4::Context->dbh;
747
    $data{'password'} = '!' if (not $data{'password'} and $data{'userid'});
747
    $data{'password'} = '!' if (not $data{'password'} and $data{'userid'});
748
    $data{'password'} = md5_base64( $data{'password'} ) if $data{'password'};
748
    $data{'password'} = md5_base64( $data{'password'} ) if $data{'password'};
749
	$data{'borrowernumber'}=InsertInTable("borrowers",\%data);	
749
	$data{'borrowernumber'}=InsertInTable("borrowers",\%data);
750
    # mysql_insertid is probably bad.  not necessarily accurate and mysql-specific at best.
750
	# mysql_insertid is probably bad.  not necessarily accurate and mysql-specific at best.
751
    logaction("MEMBERS", "CREATE", $data{'borrowernumber'}, "") if C4::Context->preference("BorrowersLog");
751
    logaction("MEMBERS", "CREATE", $data{'borrowernumber'}, "") if C4::Context->preference("BorrowersLog");
752
    
752
753
    # check for enrollment fee & add it if needed
753
    # check for enrollment fee & add it if needed
754
    my $sth = $dbh->prepare("SELECT enrolmentfee FROM categories WHERE categorycode=?");
754
    my $sth = $dbh->prepare("SELECT enrolmentfee FROM categories WHERE categorycode=?");
755
    $sth->execute($data{'categorycode'});
755
    $sth->execute($data{'categorycode'});
Lines 817-825 sub changepassword { Link Here
817
        $sth->execute( $uid, $digest, $member );
817
        $sth->execute( $uid, $digest, $member );
818
        $resultcode=1;
818
        $resultcode=1;
819
    }
819
    }
820
    
820
821
    logaction("MEMBERS", "CHANGE PASS", $member, "") if C4::Context->preference("BorrowersLog");
821
    logaction("MEMBERS", "CHANGE PASS", $member, "") if C4::Context->preference("BorrowersLog");
822
    return $resultcode;    
822
    return $resultcode;
823
}
823
}
824
824
825
825
Lines 894-900 sub fixup_cardnumber ($) { Link Here
894
        my ($result) = $sth->fetchrow;
894
        my ($result) = $sth->fetchrow;
895
        return $result + 1;
895
        return $result + 1;
896
    }
896
    }
897
    return $cardnumber;     # just here as a fallback/reminder 
897
    return $cardnumber;     # just here as a fallback/reminder
898
}
898
}
899
899
900
=head2 GetGuarantees
900
=head2 GetGuarantees
Lines 931-937 sub GetGuarantees { Link Here
931
=head2 UpdateGuarantees
931
=head2 UpdateGuarantees
932
932
933
  &UpdateGuarantees($parent_borrno);
933
  &UpdateGuarantees($parent_borrno);
934
  
934
935
935
936
C<&UpdateGuarantees> borrower data for an adult and updates all the guarantees
936
C<&UpdateGuarantees> borrower data for an adult and updates all the guarantees
937
with the modified information
937
with the modified information
Lines 1209-1215 sub checkcardnumber { Link Here
1209
    else {
1209
    else {
1210
        return 0;
1210
        return 0;
1211
    }
1211
    }
1212
}  
1212
}
1213
1213
1214
1214
1215
=head2 getzipnamecity (OUEST-PROVENCE)
1215
=head2 getzipnamecity (OUEST-PROVENCE)
Lines 1388-1395 sub GetBorrowercategory { Link Here
1388
        my $data =
1388
        my $data =
1389
        $sth->fetchrow_hashref;
1389
        $sth->fetchrow_hashref;
1390
        return $data;
1390
        return $data;
1391
    } 
1391
    }
1392
    return;  
1392
    return;
1393
}    # sub getborrowercategory
1393
}    # sub getborrowercategory
1394
1394
1395
=head2 GetBorrowercategoryList
1395
=head2 GetBorrowercategoryList
Lines 1646-1665 sub DelMember { Link Here
1646
1646
1647
=head2 SetMemberInfosInTemplate
1647
=head2 SetMemberInfosInTemplate
1648
    &SetMemberInfosInTemplate($borrowernumber, $template)
1648
    &SetMemberInfosInTemplate($borrowernumber, $template)
1649
    
1649
1650
    
1650
1651
Settings borrower informations for template user
1651
Settings borrower informations for template user
1652
1652
1653
=cut
1653
=cut
1654
1654
1655
sub SetMemberInfosInTemplate {
1655
sub SetMemberInfosInTemplate {
1656
    my ($borrowernumber, $template) = @_;
1656
    my ($borrowernumber, $template) = @_;
1657
    
1657
1658
    my $borrower = GetMemberDetails( $borrowernumber, 0 );
1658
    my $borrower = GetMemberDetails( $borrowernumber, 0 );
1659
    foreach my $key (keys %$borrower){
1659
    foreach my $key (keys %$borrower){
1660
        $template->param($key => $borrower->{$key});
1660
        $template->param($key => $borrower->{$key});
1661
    }
1661
    }
1662
    
1662
1663
    # Computes full borrower address
1663
    # Computes full borrower address
1664
    my (undef, $roadttype_hashref) = &GetRoadTypes();
1664
    my (undef, $roadttype_hashref) = &GetRoadTypes();
1665
    my $address = $borrower->{'streetnumber'}.' '.$roadttype_hashref->{$borrower->{'streettype'}}.' '.$borrower->{'address'};
1665
    my $address = $borrower->{'streetnumber'}.' '.$roadttype_hashref->{$borrower->{'streettype'}}.' '.$borrower->{'address'};
Lines 1667-1673 sub SetMemberInfosInTemplate { Link Here
1667
                    address    => $address,
1667
                    address    => $address,
1668
                    branchname => GetBranchName($borrower->{'branchcode'}),
1668
                    branchname => GetBranchName($borrower->{'branchcode'}),
1669
                    );
1669
                    );
1670
                    
1670
1671
    foreach (qw(dateenrolled dateexpiry dateofbirth)) {
1671
    foreach (qw(dateenrolled dateexpiry dateofbirth)) {
1672
		my $userdate = $borrower->{$_};
1672
		my $userdate = $borrower->{$_};
1673
		unless ($userdate) {
1673
		unless ($userdate) {
Lines 1678-1684 sub SetMemberInfosInTemplate { Link Here
1678
		$borrower->{$_} = $userdate || '';
1678
		$borrower->{$_} = $userdate || '';
1679
		$template->param( $_ => $userdate );
1679
		$template->param( $_ => $userdate );
1680
    }
1680
    }
1681
    
1681
1682
    my $attributes = GetBorrowerAttributes($borrowernumber);
1682
    my $attributes = GetBorrowerAttributes($borrowernumber);
1683
    $template->param(
1683
    $template->param(
1684
        extendedattributes => $attributes,
1684
        extendedattributes => $attributes,
Lines 1923-1935 sub GetBorrowersWhoHaveNotBorrowedSince { Link Here
1923
    }
1923
    }
1924
    warn $query if $debug;
1924
    warn $query if $debug;
1925
    my $sth = $dbh->prepare($query);
1925
    my $sth = $dbh->prepare($query);
1926
    if (scalar(@query_params)>0){  
1926
    if (scalar(@query_params)>0){
1927
        $sth->execute(@query_params);
1927
        $sth->execute(@query_params);
1928
    } 
1928
    }
1929
    else {
1929
    else {
1930
        $sth->execute;
1930
        $sth->execute;
1931
    }      
1931
    }
1932
    
1932
1933
    my @results;
1933
    my @results;
1934
    while ( my $data = $sth->fetchrow_hashref ) {
1934
    while ( my $data = $sth->fetchrow_hashref ) {
1935
        push @results, $data;
1935
        push @results, $data;
1936
- 

Return to bug 5749