Browse Source

Work on accounts - can change comments

master
olwen 22 years ago
parent
commit
4b7b1ec978
  1. 12
      C4/Database.pm
  2. 19
      C4/Search.pm
  3. 10
      insertdata.pl

12
C4/Database.pm

@ -86,6 +86,9 @@ sub sqlupdate {
my $dbh=C4Connect;
my $query="UPDATE $table SET ";
my @sets;
my @keyarr = split("\t",$keyfld);
my @keyvalarr = split("\t",$keyval);
my $numkeys = @keyarr;
while (my ($key,$value) = each %data){
if (($key ne 'type')&&($key ne 'updtype')){
my $temp = " ".$key."='".$value."' ";
@ -93,7 +96,14 @@ sub sqlupdate {
}
}
my $fsets = join(",", @sets);
$query=$query.$fsets." WHERE $keyfld = '$keyval'";
$query=$query.$fsets." WHERE $keyarr[0] = '$keyvalarr[0]'";
if ($numkeys > 1) {
my $i = 1;
while ($i < $numkeys) {
$query=$query." AND $keyarr[$i] = '$keyvalarr[$i]'";
$i++;
}
}
# $query=~ s/\,$/\)/;
print $query;
my $sth=$dbh->prepare($query);

19
C4/Search.pm

@ -355,7 +355,7 @@ sub BornameSearch {
or lower(firstname) like '%$searchstring%'
or lower(othernames) like '%$searchstring%'
order by lower(surname),lower(firstname)";
print $query,"\n";
#print $query,"\n";
my $sth=$dbh->prepare($query);
$sth->execute;
my @results;
@ -389,13 +389,16 @@ sub getacctlist {
my $dbh=C4Connect;
my @acctlines;
my $numlines;
my $query = "Select borrowernumber, date, amount, description,
dispute, accounttype, amountoutstanding, barcode, title
from accountlines,items,biblio
where borrowernumber=$params->{'borrowernumber'}
and accountlines.itemnumber = items.itemnumber
and items.biblionumber = biblio.biblionumber
and accountlines.amountoutstanding<>0";
my $query = "Select borrowernumber, accountno, date, amount, description,
dispute, accounttype, amountoutstanding, barcode, title
from accountlines,items,biblio
where borrowernumber = $params->{'borrowernumber'} ";
if ($params->{'acctno'} ne "") {
my $query = $query." and accountlines.accountno = $params->{'acctno'} ";
}
my $query = $query." and accountlines.itemnumber = items.itemnumber
and items.biblionumber = biblio.biblionumber
and accountlines.amountoutstanding<>0 order by date";
my $sth=$dbh->prepare($query);
$sth->execute;
my $total=0;

10
insertdata.pl

@ -18,6 +18,7 @@ print $input->dump;
my @names=$input->param;
my %data;
my $keyfld;
my $keyval;
my $problems;
my $env;
foreach my $key (@names){
@ -58,11 +59,18 @@ if ($data{'type'} eq 'biblio'){
$data{'branchcode'}="L";
}
}
} elsif ($data{'type'} eq "accountlines") {
$keyfld = "accountno\tborrowernumber";
$keyval = $data{'accountno'}."\t".$data{'borrowernumber'};
}
if ($problems eq "") {
if ($updtype eq "M") {
&sqlupdate($data{'type'},$keyfld,$data{$keyfld},%data);
if ($keyval eq "") {
&sqlupdate($data{'type'},$keyfld,$data{$keyfld},%data);
} else {
&sqlupdate($data{'type'},$keyfld,$keyval,%data);
}
} else {
&sqlinsert($data{'type'},%data);
}

Loading…
Cancel
Save