47 files to go, 47 files to go, take one down, pass it around...
[koha.git] / misc / makebaskets.pl
1 #!/usr/bin/perl
2
3 use strict;
4 use C4::Database;
5
6 my $dbh=C4Connect;
7 my $count=0;
8 my $basket='HLT-';
9 for (my $i=1;$i<59;$i++){
10   my $query = "Select authorisedby,entrydate from aqorders where booksellerid='$i'";            
11   $query.=" group by authorisedby,entrydate order by entrydate"; 
12   my $sth=$dbh->prepare($query);
13   $sth->execute;
14   while (my $data=$sth->fetchrow_hashref){
15     $basket=$count;
16     $data->{'authorisedby'}=~ s/\'/\\\'/g;
17     my $query2="update aqorders set basketno='$basket' where booksellerid='$i' and authorisedby=
18     '$data->{'authorisedby'}' and entrydate='$data->{'entrydate'}'";
19     my $sth2=$dbh->prepare($query2);
20     $sth2->execute;
21     $sth2->finish;
22     $count++;
23   }
24   $sth->finish;
25 }
26
27 $dbh->disconnect;