Update of /cvsroot/koha/koha In directory usw-pr-cvs1:/tmp/cvs-serv12125 Modified Files: insertdata.pl loadmodules.pl memberentry.pl modbibitem.pl moredetail.pl moremember.pl request.pl search.pl Added Files: koha.t testKoha.pl Log Message: refactored slashifyDate function out of inline code, created C4/Koha.pm to hold it and wrote tests for it, started marking other places for potential refactoring. --- NEW FILE --- BEGIN { $| = 1; print "1..2\n"; } END {print "not ok 1\n" unless $loaded;} use C4::Koha; $loaded = 1; print "ok 1\n"; $date = "01/01/2002"; $newdate = &slashifyDate("2002-01-01"); if ($date eq $newdate) { print "ok 2\n"; } else { print "not ok 2\n"; } --- NEW FILE --- #!/usr/bin/perl -w use strict; use Test::Harness; runtests 'koha.t'; Index: insertdata.pl =================================================================== RCS file: /cvsroot/koha/koha/insertdata.pl,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** insertdata.pl 8 Apr 2002 22:47:18 -0000 1.5 --- insertdata.pl 8 Apr 2002 23:44:43 -0000 1.6 *************** *** 41,47 **** categorycode='$data{'categorycode'}',city='$data{'city'}',area='$data{'area'}',phone='$data{'phone'}', borrowernotes='$data{'borrowernotes'}',altphone='$data{'altphone'}',surname='$data{'surname'}', ! initials='$data{'initials'}',physstreet='$data{'streetaddress'}',ethnicity='$data{'ethnicity'}', ! gonenoaddress='$data{'gna'}',lost='$data{'lost'}',debarred='$data{'debarred'}',textmessaging='$data{'textmessaging'}', ! guarantor='$data{'guarantor'}' where borrowernumber=$data{'borrowernumber'}"; # print $query; --- 41,46 ---- categorycode='$data{'categorycode'}',city='$data{'city'}',area='$data{'area'}',phone='$data{'phone'}', borrowernotes='$data{'borrowernotes'}',altphone='$data{'altphone'}',surname='$data{'surname'}', ! initials='$data{'initials'}',streetaddress='$data{'address'}',ethnicity='$data{'ethnicity'}', ! gonenoaddress='$data{'gna'}',lost='$data{'lost'}',debarred='$data{'debarred'}' where borrowernumber=$data{'borrowernumber'}"; # print $query; *************** *** 55,60 **** firstname,altnotes,dateofbirth,contactname,emailaddress,dateenrolled,streetcity, altrelationship,othernames,phoneday,categorycode,city,area,phone,borrowernotes,altphone,surname, ! initials,ethnicity,textmessaging) ! values ('$data{'title'}','$data{'expiry'}','$data{'cardnumber'}', '$data{'sex'}','$data{'ethnotes'}','$data{'address'}','$data{'faxnumber'}', '$data{'firstname'}','$data{'altnotes'}','$data{'dateofbirth'}','$data{'contactname'}','$data{'emailaddress'}', --- 54,58 ---- firstname,altnotes,dateofbirth,contactname,emailaddress,dateenrolled,streetcity, altrelationship,othernames,phoneday,categorycode,city,area,phone,borrowernotes,altphone,surname, ! initials,ethnicity,borrowernumber) values ('$data{'title'}','$data{'expiry'}','$data{'cardnumber'}', '$data{'sex'}','$data{'ethnotes'}','$data{'address'}','$data{'faxnumber'}', '$data{'firstname'}','$data{'altnotes'}','$data{'dateofbirth'}','$data{'contactname'}','$data{'emailaddress'}', *************** *** 62,66 **** '$data{'phoneday'}','$data{'categorycode'}','$data{'city'}','$data{'area'}','$data{'phone'}', '$data{'borrowernotes'}','$data{'altphone'}','$data{'surname'}','$data{'initials'}', ! '$data{'ethnicity'}','$data{'textmessaging'}')"; } # ok if its an adult (type) it may have borrowers that depend on it as a guarantor --- 60,64 ---- '$data{'phoneday'}','$data{'categorycode'}','$data{'city'}','$data{'area'}','$data{'phone'}', '$data{'borrowernotes'}','$data{'altphone'}','$data{'surname'}','$data{'initials'}', ! '$data{'ethnicity'}','$data{'borrowernumber'}')"; } # ok if its an adult (type) it may have borrowers that depend on it as a guarantor *************** *** 72,75 **** --- 70,77 ---- my ($count,$guarantees)=findguarantees($data{'borrowernumber'}); for (my $i=0;$i<$count;$i++){ + # FIXME + # It looks like the $i is only being returned to handle walking through + # the array, which is probably better done as a foreach loop. + # my $guaquery="update borrowers set streetaddress='$data{'address'}',faxnumber='$data{'faxnumber'}', streetcity='$data{'streetcity'}',phoneday='$data{'phoneday'}',city='$data{'city'}',area='$data{'area'}',phone='$data{'phone'}' Index: loadmodules.pl =================================================================== RCS file: /cvsroot/koha/koha/loadmodules.pl,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** loadmodules.pl 5 Feb 2001 18:48:15 -0000 1.1 --- loadmodules.pl 8 Apr 2002 23:44:43 -0000 1.2 *************** *** 19,22 **** --- 19,26 ---- sub acquisitions { + # FIXME + # instead of getting a hash, then reading/writing to it at least twice + # and up to four times, maybe this should be a different function - + # areAquisitionsSimple() which returns a boolean my %systemprefs=systemprefs(); ($systemprefs{'acquisitions'}) || ($systemprefs{'acquisitions'}='normal'); Index: memberentry.pl =================================================================== RCS file: /cvsroot/koha/koha/memberentry.pl,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** memberentry.pl 5 Jul 2001 21:37:15 -0000 1.4 --- memberentry.pl 8 Apr 2002 23:44:43 -0000 1.5 *************** *** 46,50 **** my $cardnumber=$data->{'cardnumber'}; ! my %systemprefs=systemprefs(); if ($cardnumber eq '' && $systemprefs{'autoMemberNum'} eq '1') { my $dbh=C4Connect; --- 46,54 ---- my $cardnumber=$data->{'cardnumber'}; ! my %sysemprefs=systemprefs(); ! # FIXME ! # This logic should probably be moved out of the presentation code. ! # Not tonight though. ! # if ($cardnumber eq '' && $systemprefs{'autoMemberNum'} eq '1') { my $dbh=C4Connect; Index: modbibitem.pl =================================================================== RCS file: /cvsroot/koha/koha/modbibitem.pl,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** modbibitem.pl 10 Oct 2001 19:26:14 -0000 1.3 --- modbibitem.pl 8 Apr 2002 23:44:43 -0000 1.4 *************** *** 9,14 **** use C4::Search; - use CGI; use C4::Output; my $input = new CGI; --- 9,16 ---- use C4::Search; use C4::Output; + use C4::Koha; + use CGI; + my $input = new CGI; *************** *** 153,158 **** my $count=@items; for (my $i=0;$i<$count;$i++){ ! my @temp=split('-',$items[$i]->{'datelastseen'}); ! $items[$i]->{'datelastseen'}="$temp[2]/$temp[1]/$temp[0]"; print <<printend <tr valign=top gcolor=#ffffcc> --- 155,159 ---- my $count=@items; for (my $i=0;$i<$count;$i++){ ! $items[$i]->{'datelastseen'} = slashifyDate($items[$i]->{'datelastseen'}); print <<printend <tr valign=top gcolor=#ffffcc> Index: moredetail.pl =================================================================== RCS file: /cvsroot/koha/koha/moredetail.pl,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** moredetail.pl 10 Sep 2001 23:37:09 -0000 1.3 --- moredetail.pl 8 Apr 2002 23:44:43 -0000 1.4 *************** *** 7,14 **** #use DBI; use C4::Search; ! use CGI; use C4::Output; use C4::Acquisitions; my $input = new CGI; print $input->header; --- 7,15 ---- #use DBI; use C4::Search; ! use C4::Koha; use C4::Output; use C4::Acquisitions; + use CGI; my $input = new CGI; print $input->header; *************** *** 131,142 **** $items[$i]->{'withdrawn'}=~ s/1/Yes/; $items[$i]->{'replacementprice'}+=0.00; my $year=substr($items[$i]->{'timestamp0'},0,4); my $mon=substr($items[$i]->{'timestamp0'},4,2); my $day=substr($items[$i]->{'timestamp0'},6,2); $items[$i]->{'timestamp0'}="$day/$mon/$year"; ! my @temp=split('-',$items[$i]->{'dateaccessioned'}); ! $items[$i]->{'dateaccessioned'}="$temp[2]/$temp[1]/$temp[0]"; ! @temp=split('-',$items[$i]->{'datelastseen'}); ! $items[$i]->{'datelastseen'}="$temp[2]/$temp[1]/$temp[0]"; print <<printend <FONT SIZE=2 face="arial, helvetica"> --- 132,144 ---- $items[$i]->{'withdrawn'}=~ s/1/Yes/; $items[$i]->{'replacementprice'}+=0.00; + my $year=substr($items[$i]->{'timestamp0'},0,4); my $mon=substr($items[$i]->{'timestamp0'},4,2); my $day=substr($items[$i]->{'timestamp0'},6,2); $items[$i]->{'timestamp0'}="$day/$mon/$year"; ! ! $items[$i]->{'dateaccessioned'} = slashifyDate($items[$i]->{'dateaccessioned'}); ! $items[$i]->{'datelastseen'} = slashifyDate($items[$i]->{'datelastseen'}); ! print <<printend <FONT SIZE=2 face="arial, helvetica"> Index: moremember.pl =================================================================== RCS file: /cvsroot/koha/koha/moremember.pl,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** moremember.pl 13 Mar 2002 03:26:43 -0000 1.9 --- moremember.pl 8 Apr 2002 23:44:43 -0000 1.10 *************** *** 16,23 **** --- 16,30 ---- use C4::Circulation::Renewals2; use C4::Circulation::Circ2; + use C4::Koha; + my $input = new CGI; my $bornum=$input->param('bornum'); + + # FIXME + # this hash is never assigned, though it is used (as a placeholder?) + # my %env; + print $input->header; #start the page and read in includes *************** *** 25,34 **** print startmenu('member'); my $data=borrdata('',$bornum); ! my @temp=split('-',$data->{'dateenrolled'}); ! $data->{'dateenrolled'}="$temp[2]/$temp[1]/$temp[0]"; ! @temp=split('-',$data->{'expiry'}); ! $data->{'expiry'}="$temp[2]/$temp[1]/$temp[0]"; ! @temp=split('-',$data->{'dateofbirth'}); ! $data->{'dateofbirth'}="$temp[2]/$temp[1]/$temp[0]"; if ($data->{'ethnicity'} eq 'maori'){ $data->{'ethnicity'} = 'Maori'; --- 32,57 ---- print startmenu('member'); my $data=borrdata('',$bornum); ! ! ! $data->{'dateenrolled'} = slashifyDate($data->{'dateenrolled'}); ! $data->{'expiry'} = slashifyDate($data->{'expiry'}); ! $data->{'dateofbirth'} = slashifyDate($data->{'dateofbirth'}); ! ! # FIXME ! # turn the ethnicity into a function and make it generalizable ! # check these files to see if one convention or the other makes sense ! # boraccount.pl ! # imemberentry.pl ! # jmemberentry.pl ! # mancredit.pl ! # maninvoice.pl ! # member.pl ! # memberentry.pl ! # moremember.pl ! # moremember.pl ! # pay.pl ! # placerequest.pl ! # readingrec.pl ! # if ($data->{'ethnicity'} eq 'maori'){ $data->{'ethnicity'} = 'Maori'; *************** *** 43,46 **** --- 66,70 ---- $data->{'ethnicity'} = 'Asian'; } + print <<printend <FONT SIZE=6><em>$data->{'firstname'} $data->{'surname'}</em></FONT><P> *************** *** 98,101 **** --- 122,129 ---- if ($data->{'categorycode'} ne 'C'){ print " Guarantees:"; + # FIXME + # It looks like the $i is only being returned to handle walking through + # the array, which is probably better done as a foreach loop. + # my ($count,$guarantees)=findguarantees($data->{'borrowernumber'}); for (my $i=0;$i<$count;$i++){ *************** *** 138,141 **** --- 166,175 ---- my %bor; $bor{'borrowernumber'}=$bornum; + + # FIXME + # it looks like $numaccts is a temp variable and that the + # for (my $i;$i<$numaccts;$i+++) + # can be turned into a foreach loop instead + # my ($numaccts,$accts,$total)=getboracctrecord('',\%bor); #if ($numaccts > 10){ *************** *** 149,154 **** print "<tr VALIGN=TOP >"; my $item=" "; ! @temp=split('-',$accts->[$i]{'date'}); ! $accts->[$i]{'date'}="$temp[2]/$temp[1]/$temp[0]"; if ($accts->[$i]{'accounttype'} ne 'Res'){ #get item data --- 183,189 ---- print "<tr VALIGN=TOP >"; my $item=" "; ! ! $accts->[$i]{'date'} = slashifyDate($accts->[$i]{'date'}); ! if ($accts->[$i]{'accounttype'} ne 'Res'){ #get item data *************** *** 158,161 **** --- 193,200 ---- # print "<TD>$accts->[$i]{'accounttype'}</td>"; print "<TD>"; + + # FIXME + # why set this variable if it's not going to be used? + # my $env; if ($accts->[$i]{'accounttype'} ne 'Res'){ *************** *** 207,212 **** <TD>"; my $datedue=ParseDate($issue->[$i]{'date_due'}); ! @temp=split('-',$issue->[$i]{'date_due'}); ! $issue->[$i]{'date_due'}="$temp[2]/$temp[1]/$temp[0]"; if ($datedue < $today){ print "<font color=red>"; --- 246,252 ---- <TD>"; my $datedue=ParseDate($issue->[$i]{'date_due'}); ! ! $issue->[$i]{'date_due'} = slashifyDate($issue->[$i]{'date_due'}); ! if ($datedue < $today){ print "<font color=red>"; *************** *** 277,284 **** printend ; my ($rescount,$reserves)=FindReserves('',$bornum); #From C4::Reserves2 for (my $i=0;$i<$rescount;$i++){ ! @temp=split('-',$reserves->[$i]{'reservedate'}); ! $reserves->[$i]{'reservedate'}="$temp[2]/$temp[1]/$temp[0]"; print "<tr VALIGN=TOP > <TD><a href=\"/cgi-bin/koha/request.pl?bib=$reserves->[$i]{'biblionumber'}\">$reserves->[$i]{'btitle'}</a></td> --- 317,330 ---- printend ; + my ($rescount,$reserves)=FindReserves('',$bornum); #From C4::Reserves2 + + # FIXME + # does it make sense to turn this into a foreach my $i (0..$rescount) + # kind of loop? + # for (my $i=0;$i<$rescount;$i++){ ! $reserves->[$i]{'reservedate'} = slashifyDate($reserves->[$i]{'reservedate'}); ! print "<tr VALIGN=TOP > <TD><a href=\"/cgi-bin/koha/request.pl?bib=$reserves->[$i]{'biblionumber'}\">$reserves->[$i]{'btitle'}</a></td> *************** *** 311,312 **** --- 357,360 ---- print endmenu('member'); print endpage(); + + Index: request.pl =================================================================== RCS file: /cvsroot/koha/koha/request.pl,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -r1.1.1.1 -r1.2 *** request.pl 19 Dec 2000 23:45:53 -0000 1.1.1.1 --- request.pl 8 Apr 2002 23:44:43 -0000 1.2 *************** *** 7,14 **** #use DBI; use C4::Search; - use CGI; use C4::Output; use C4::Reserves2; use C4::Acquisitions; my $input = new CGI; print $input->header; --- 7,16 ---- #use DBI; use C4::Search; use C4::Output; use C4::Reserves2; use C4::Acquisitions; + use C4::Koha; + + use CGI; my $input = new CGI; print $input->header; *************** *** 160,165 **** #$bor=~ s/ /%20/g; my $bor=$reserves->[$i]{'borrowernumber'}; ! my @temp=split('-',$reserves->[$i]{'reservedate'}); ! $date="$temp[2]/$temp[1]/$temp[0]"; my $type=$reserves->[$i]{'constrainttype'}; #print "test"; --- 162,167 ---- #$bor=~ s/ /%20/g; my $bor=$reserves->[$i]{'borrowernumber'}; ! $date = slashifyDate($reserves->[$i]{'reservedate'}); ! my $type=$reserves->[$i]{'constrainttype'}; #print "test"; Index: search.pl =================================================================== RCS file: /cvsroot/koha/koha/search.pl,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** search.pl 13 Mar 2002 07:46:43 -0000 1.5 --- search.pl 8 Apr 2002 23:44:43 -0000 1.6 *************** *** 11,29 **** print $input->header; #print $input->dump; ! #whether it is called from the opac of the intranet ! my $type=$input->param('type'); ! if ($type eq ''){ $type = 'intra'; } my $ttype=$input->param('ttype'); ! #setup colours ! my $main; ! my $secondary; ! if ($type eq 'opac'){ $main='#99cccc'; $secondary='#efe5ef'; ! } else { ! $main='#cccc99'; ! $secondary='#ffffcc'; } --- 11,32 ---- print $input->header; #print $input->dump; ! ! #whether it is called from the opac or the intranet ! my $type=$input->param('type');if ($type eq ''){ $type = 'intra'; } + my $ttype=$input->param('ttype'); ! ! #setup colours ! my $main; ! my $secondary; ! ! if ($type eq 'opac'){ $main='#99cccc'; $secondary='#efe5ef'; ! } else { ! $main='#cccc99'; ! $secondary='#ffffcc'; } *************** *** 31,59 **** --- 34,76 ---- my $blah; my %search; + #build hash of users input my $title=validate($input->param('title')); $search{'title'}=$title; + my $keyword=validate($input->param('keyword')); $search{'keyword'}=$keyword; + $search{'front'}=validate($input->param('front')); + my $author=validate($input->param('author')); $search{'author'}=$author; + my $illustrator=validate($input->param('illustrator')); $search{'illustrator'}=$illustrator; + my $subject=validate($input->param('subject')); $search{'subject'}=$subject; + my $itemnumber=validate($input->param('item')); $search{'item'}=$itemnumber; + my $isbn=validate($input->param('isbn')); $search{'isbn'}=$isbn; + my $datebefore=validate($input->param('date-before')); $search{'date-before'}; + my $class=$input->param('class'); $search{'class'}=$class; + $search{'ttype'}=$ttype; + my $dewey=validate($input->param('dewey')); $search{'dewey'}=$dewey; + my $branch=validate($input->param('branch')); $search{'branch'}=$branch; + my @results; my $offset=$input->param('offset');